blob: 92c9dce1c7237fae574ff149ecee5d450a84f1bd [file] [log] [blame]
Benny Prijonoeebe9af2006-06-13 22:57:13 +00001/* $Id$ */
2/*
Nanang Izzuddina62ffc92011-05-05 06:14:19 +00003 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
Benny Prijono32177c02008-06-20 22:44:47 +00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijonoeebe9af2006-06-13 22:57:13 +00005 *
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_INTERNAL_H__
21#define __PJSUA_INTERNAL_H__
22
23/**
24 * This is the private header used by pjsua library implementation.
25 * Applications should not include this file.
26 */
27
28PJ_BEGIN_DECL
29
30/**
Benny Prijono224b4e22008-06-19 14:10:28 +000031 * Media transport state.
32 */
33typedef enum pjsua_med_tp_st
34{
35 /** Not initialized */
36 PJSUA_MED_TP_IDLE,
37
38 /** Initialized (media_create() has been called) */
39 PJSUA_MED_TP_INIT,
40
41 /** Running (media_start() has been called) */
42 PJSUA_MED_TP_RUNNING
43
44} pjsua_med_tp_st;
45
46/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +000047 * Structure to be attached to invite dialog.
48 * Given a dialog "dlg", application can retrieve this structure
49 * by accessing dlg->mod_data[pjsua.mod.id].
50 */
51typedef struct pjsua_call
52{
53 unsigned index; /**< Index in pjsua array. */
54 pjsip_inv_session *inv; /**< The invite session. */
55 void *user_data; /**< User/application data. */
56 pjsip_status_code last_code; /**< Last status code seen. */
57 pj_str_t last_text; /**< Last status text seen. */
58 pj_time_val start_time;/**< First INVITE sent/received. */
59 pj_time_val res_time; /**< First response sent/received. */
60 pj_time_val conn_time; /**< Connected/confirmed time. */
61 pj_time_val dis_time; /**< Disconnect time. */
62 pjsua_acc_id acc_id; /**< Account index being used. */
Benny Prijonodb844a42008-02-02 17:07:18 +000063 int secure_level;/**< Signaling security level. */
Benny Prijonodd63b992010-10-01 02:03:42 +000064 pjsua_call_hold_type call_hold_type; /**< How to do call hold. */
Nanang Izzuddin99d69522008-08-04 15:01:38 +000065 pj_bool_t local_hold;/**< Flag for call-hold by local. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +000066 pjsua_call_media_status media_st;/**< Media state. */
67 pjmedia_dir media_dir; /**< Media direction. */
68 pjmedia_session *session; /**< The media session. */
Benny Prijonoa310bd22008-06-27 21:19:44 +000069 int audio_idx; /**< Index of m=audio in SDP. */
Benny Prijono8147f402007-11-21 14:50:07 +000070 pj_uint32_t ssrc; /**< RTP SSRC */
Nanang Izzuddina815ceb2008-08-26 16:51:28 +000071 pj_uint32_t rtp_tx_ts; /**< Initial RTP timestamp for sender. */
72 pj_uint16_t rtp_tx_seq;/**< Initial RTP sequence for sender. */
73 pj_uint8_t rtp_tx_seq_ts_set;
74 /**< Bitmask flags if initial RTP sequence
75 and/or timestamp for sender are set.
76 bit 0/LSB : sequence flag
77 bit 1 : timestamp flag */
Benny Prijonoeebe9af2006-06-13 22:57:13 +000078 int conf_slot; /**< Slot # in conference bridge. */
79 pjsip_evsub *xfer_sub; /**< Xfer server subscription, if this
80 call was triggered by xfer. */
Benny Prijonod8179652008-01-23 20:39:07 +000081 pjmedia_transport *med_tp; /**< Current media transport. */
Benny Prijono224b4e22008-06-19 14:10:28 +000082 pj_status_t med_tp_ready;/**< Media transport status. */
Benny Prijonod8179652008-01-23 20:39:07 +000083 pjmedia_transport *med_orig; /**< Original media transport */
Benny Prijono40860c32008-09-04 13:55:33 +000084 pj_bool_t med_tp_auto_del; /**< May delete media transport */
Benny Prijono224b4e22008-06-19 14:10:28 +000085 pjsua_med_tp_st med_tp_st; /**< Media transport state */
Benny Prijonof5d9f1f2009-10-14 13:13:18 +000086 pj_sockaddr med_rtp_addr; /**< Current RTP source address
87 (used to update ICE default
88 address) */
Benny Prijono91a6a172007-10-31 08:59:29 +000089 pj_stun_nat_type rem_nat_type; /**< NAT type of remote endpoint. */
Nanang Izzuddin4375f902008-06-26 19:12:09 +000090 pjmedia_srtp_use rem_srtp_use; /**< Remote's SRTP usage policy. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +000091
92 char last_text_buf_[128]; /**< Buffer for last_text. */
93
Nanang Izzuddin93bacd02010-06-15 09:56:39 +000094 struct {
95 pj_timer_entry reinv_timer;/**< Reinvite retry timer. */
Benny Prijono1e601552010-10-20 05:31:08 +000096 pj_uint32_t sdp_ver; /**< SDP version of the bad answer */
97 int retry_cnt; /**< Retry count. */
Nanang Izzuddinec919002010-11-25 09:27:06 +000098 pj_bool_t pending; /**< Pending until CONFIRMED state */
Nanang Izzuddin93bacd02010-06-15 09:56:39 +000099 } lock_codec; /**< Data for codec locking when answer
100 contains multiple codecs. */
101
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000102} pjsua_call;
103
104
105/**
106 * Server presence subscription list head.
107 */
Benny Prijono63fba012008-07-17 14:19:10 +0000108struct pjsua_srv_pres
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000109{
110 PJ_DECL_LIST_MEMBER(struct pjsua_srv_pres);
Benny Prijono63fba012008-07-17 14:19:10 +0000111 pjsip_evsub *sub; /**< The evsub. */
112 char *remote; /**< Remote URI. */
113 int acc_id; /**< Account ID. */
114 pjsip_dialog *dlg; /**< Dialog. */
115 int expires; /**< "expires" value in the request. */
116};
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000117
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000118/**
119 * Account
120 */
121typedef struct pjsua_acc
122{
Benny Prijonoc91ed8d2008-07-13 12:24:55 +0000123 pj_pool_t *pool; /**< Pool for this account. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000124 pjsua_acc_config cfg; /**< Account configuration. */
125 pj_bool_t valid; /**< Is this account valid? */
126
127 int index; /**< Index in accounts array. */
Benny Prijonoc570f2d2006-07-18 00:33:02 +0000128 pj_str_t display; /**< Display name, if any. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000129 pj_str_t user_part; /**< User part of local URI. */
Nanang Izzuddin5af37ff2009-08-05 18:41:23 +0000130 pj_str_t contact; /**< Our Contact header. */
Benny Prijonob54719f2010-11-16 03:07:46 +0000131 pj_str_t reg_contact; /**< Contact header for REGISTER.
132 It may be different than acc
133 contact if outbound is used */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000134
Benny Prijonob4a17c92006-07-10 14:40:21 +0000135 pj_str_t srv_domain; /**< Host part of reg server. */
136 int srv_port; /**< Port number of reg server. */
137
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000138 pjsip_regc *regc; /**< Client registration session. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000139 pj_status_t reg_last_err; /**< Last registration error. */
140 int reg_last_code; /**< Last status last register. */
141
Nanang Izzuddin36dd5b62010-03-30 11:13:59 +0000142 struct {
143 pj_bool_t active; /**< Flag of reregister status. */
144 pj_timer_entry timer; /**< Timer for reregistration. */
145 void *reg_tp; /**< Transport for registration. */
146 unsigned attempt_cnt; /**< Attempt counter. */
147 } auto_rereg; /**< Reregister/reconnect data. */
148
Benny Prijonobddef2c2007-10-31 13:28:08 +0000149 pj_timer_entry ka_timer; /**< Keep-alive timer for UDP. */
150 pjsip_transport *ka_transport; /**< Transport for keep-alive. */
151 pj_sockaddr ka_target; /**< Destination address for K-A */
152 unsigned ka_target_len; /**< Length of ka_target. */
153
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000154 pjsip_route_hdr route_set; /**< Complete route set inc. outbnd.*/
Nanang Izzuddinc3ea16a2010-04-20 14:36:38 +0000155 pj_uint32_t global_route_crc; /** CRC of global route setting. */
156 pj_uint32_t local_route_crc; /** CRC of account route setting.*/
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000157
Benny Prijonob54719f2010-11-16 03:07:46 +0000158 unsigned rfc5626_status;/**< SIP outbound status:
159 0: not used
160 1: requested
161 2: acknowledged by servers */
162 pj_str_t rfc5626_instprm;/**< SIP outbound instance param. */
163 pj_str_t rfc5626_regprm;/**< SIP outbound reg param. */
164
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000165 unsigned cred_cnt; /**< Number of credentials. */
166 pjsip_cred_info cred[PJSUA_ACC_MAX_PROXIES]; /**< Complete creds. */
167
168 pj_bool_t online_status; /**< Our online status. */
Benny Prijono4461c7d2007-08-25 13:36:15 +0000169 pjrpid_element rpid; /**< RPID element information. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000170 pjsua_srv_pres pres_srv_list; /**< Server subscription list. */
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000171 pjsip_publishc *publish_sess; /**< Client publication session. */
172 pj_bool_t publish_state; /**< Last published online status */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000173
Benny Prijono4dd961b2009-10-26 11:21:37 +0000174 pjsip_evsub *mwi_sub; /**< MWI client subscription */
175 pjsip_dialog *mwi_dlg; /**< Dialog for MWI sub. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000176} pjsua_acc;
177
178
179/**
180 *Transport.
181 */
Benny Prijono62c5c5b2007-01-13 23:22:40 +0000182typedef struct pjsua_transport_data
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000183{
Benny Prijonoe93e2872006-06-28 16:46:49 +0000184 int index;
185 pjsip_transport_type_e type;
186 pjsip_host_port local_name;
187
188 union {
189 pjsip_transport *tp;
190 pjsip_tpfactory *factory;
191 void *ptr;
192 } data;
193
Benny Prijono62c5c5b2007-01-13 23:22:40 +0000194} pjsua_transport_data;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000195
196
Benny Prijono63fba012008-07-17 14:19:10 +0000197/** Maximum length of subscription termination reason. */
198#define PJSUA_BUDDY_SUB_TERM_REASON_LEN 32
199
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000200/**
201 * Buddy data.
202 */
203typedef struct pjsua_buddy
204{
Benny Prijonoc91ed8d2008-07-13 12:24:55 +0000205 pj_pool_t *pool; /**< Pool for this buddy. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000206 unsigned index; /**< Buddy index. */
Benny Prijono705e7842008-07-21 18:12:51 +0000207 void *user_data; /**< Application data. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000208 pj_str_t uri; /**< Buddy URI. */
209 pj_str_t contact; /**< Contact learned from subscrp. */
210 pj_str_t name; /**< Buddy name. */
211 pj_str_t display; /**< Buddy display name. */
212 pj_str_t host; /**< Buddy host. */
213 unsigned port; /**< Buddy port. */
214 pj_bool_t monitor; /**< Should we monitor? */
Benny Prijonof9c40c32007-06-28 07:20:26 +0000215 pjsip_dialog *dlg; /**< The underlying dialog. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000216 pjsip_evsub *sub; /**< Buddy presence subscription */
Benny Prijono73bb7232009-10-20 13:56:26 +0000217 unsigned term_code; /**< Subscription termination code */
Benny Prijono63fba012008-07-17 14:19:10 +0000218 pj_str_t term_reason;/**< Subscription termination reason */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000219 pjsip_pres_status status; /**< Buddy presence status. */
Benny Prijono73bb7232009-10-20 13:56:26 +0000220 pj_timer_entry timer; /**< Resubscription timer */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000221} pjsua_buddy;
222
223
224/**
225 * File player/recorder data.
226 */
227typedef struct pjsua_file_data
228{
Benny Prijonoa66c3312007-01-21 23:12:40 +0000229 pj_bool_t type; /* 0=player, 1=playlist */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000230 pjmedia_port *port;
Benny Prijonod5696da2007-07-17 16:25:45 +0000231 pj_pool_t *pool;
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000232 unsigned slot;
233} pjsua_file_data;
234
235
236/**
237 * Additional parameters for conference bridge.
238 */
239typedef struct pjsua_conf_setting
240{
241 unsigned channel_count;
242 unsigned samples_per_frame;
243 unsigned bits_per_sample;
244} pjsua_conf_setting;
245
Benny Prijonobb995fd2009-08-12 11:03:23 +0000246typedef struct pjsua_stun_resolve
247{
248 PJ_DECL_LIST_MEMBER(struct pjsua_stun_resolve);
249
250 pj_pool_t *pool; /**< Pool */
251 unsigned count; /**< # of entries */
252 pj_str_t *srv; /**< Array of entries */
253 unsigned idx; /**< Current index */
254 void *token; /**< App token */
255 pj_stun_resolve_cb cb; /**< App callback */
256 pj_bool_t blocking; /**< Blocking? */
257 pj_status_t status; /**< Session status */
258 pj_sockaddr addr; /**< Result */
259 pj_stun_sock *stun_sock; /**< Testing STUN sock */
260} pjsua_stun_resolve;
261
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000262
263/**
264 * Global pjsua application data.
265 */
266struct pjsua_data
267{
268
269 /* Control: */
270 pj_caching_pool cp; /**< Global pool factory. */
271 pj_pool_t *pool; /**< pjsua's private pool. */
272 pj_mutex_t *mutex; /**< Mutex protection for this data */
273
274 /* Logging: */
275 pjsua_logging_config log_cfg; /**< Current logging config. */
276 pj_oshandle_t log_file; /**<Output log file handle */
277
278 /* SIP: */
279 pjsip_endpoint *endpt; /**< Global endpoint. */
280 pjsip_module mod; /**< pjsua's PJSIP module. */
Benny Prijono62c5c5b2007-01-13 23:22:40 +0000281 pjsua_transport_data tpdata[8]; /**< Array of transports. */
Benny Prijono21407322010-03-10 13:33:25 +0000282 pjsip_tp_state_callback old_tp_cb; /**< Old transport callback. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000283
284 /* Threading: */
285 pj_bool_t thread_quit_flag; /**< Thread quit flag. */
286 pj_thread_t *thread[4]; /**< Array of threads. */
287
Benny Prijonoc97608e2007-03-23 16:34:20 +0000288 /* STUN and resolver */
289 pj_stun_config stun_cfg; /**< Global STUN settings. */
290 pj_sockaddr stun_srv; /**< Resolved STUN server address */
291 pj_status_t stun_status; /**< STUN server status. */
Benny Prijonobb995fd2009-08-12 11:03:23 +0000292 pjsua_stun_resolve stun_res; /**< List of pending STUN resolution*/
Benny Prijonoc97608e2007-03-23 16:34:20 +0000293 pj_dns_resolver *resolver; /**< DNS resolver. */
294
Benny Prijono6ba8c542007-10-16 01:34:14 +0000295 /* Detected NAT type */
296 pj_stun_nat_type nat_type; /**< NAT type. */
297 pj_status_t nat_status; /**< Detection status. */
298 pj_bool_t nat_in_progress; /**< Detection in progress */
299
Benny Prijono29c8ca32010-06-22 06:02:13 +0000300 /* List of outbound proxies: */
301 pjsip_route_hdr outbound_proxy;
302
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000303 /* Account: */
304 unsigned acc_cnt; /**< Number of accounts. */
305 pjsua_acc_id default_acc; /**< Default account ID */
306 pjsua_acc acc[PJSUA_MAX_ACC]; /**< Account array. */
Benny Prijono093d3022006-09-24 00:07:11 +0000307 pjsua_acc_id acc_ids[PJSUA_MAX_ACC]; /**< Acc sorted by prio*/
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000308
309 /* Calls: */
310 pjsua_config ua_cfg; /**< UA config. */
311 unsigned call_cnt; /**< Call counter. */
312 pjsua_call calls[PJSUA_MAX_CALLS];/**< Calls array. */
Benny Prijono5773cd62008-01-19 13:01:42 +0000313 pjsua_call_id next_call_id; /**< Next call id to use*/
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000314
315 /* Buddy; */
316 unsigned buddy_cnt; /**< Buddy count. */
317 pjsua_buddy buddy[PJSUA_MAX_BUDDIES]; /**< Buddy array. */
318
Benny Prijono7a5f5102007-05-29 00:33:09 +0000319 /* Presence: */
320 pj_timer_entry pres_timer;/**< Presence refresh timer. */
321
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000322 /* Media: */
323 pjsua_media_config media_cfg; /**< Media config. */
324 pjmedia_endpt *med_endpt; /**< Media endpoint. */
325 pjsua_conf_setting mconf_cfg; /**< Additionan conf. bridge. param */
326 pjmedia_conf *mconf; /**< Conference bridge. */
Benny Prijonof798e502009-03-09 13:08:16 +0000327 pj_bool_t is_mswitch;/**< Are we using audio switchboard
328 (a.k.a APS-Direct) */
329
330 /* Sound device */
331 pjmedia_aud_dev_index cap_dev; /**< Capture device ID. */
332 pjmedia_aud_dev_index play_dev; /**< Playback device ID. */
333 pj_uint32_t aud_svmask;/**< Which settings to save */
334 pjmedia_aud_param aud_param; /**< User settings to sound dev */
335 pj_bool_t aud_open_cnt;/**< How many # device is opened */
Benny Prijonoe909eac2006-07-27 22:04:56 +0000336 pj_bool_t no_snd; /**< No sound (app will manage it) */
Nanang Izzuddin68559c32008-06-13 17:01:46 +0000337 pj_pool_t *snd_pool; /**< Sound's private pool. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000338 pjmedia_snd_port *snd_port; /**< Sound port. */
Nanang Izzuddin68559c32008-06-13 17:01:46 +0000339 pj_timer_entry snd_idle_timer;/**< Sound device idle timer. */
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000340 pjmedia_master_port *null_snd; /**< Master port for null sound. */
341 pjmedia_port *null_port; /**< Null port. */
342
343
344 /* File players: */
345 unsigned player_cnt;/**< Number of file players. */
Benny Prijonocba59d92007-02-16 09:22:56 +0000346 pjsua_file_data player[PJSUA_MAX_PLAYERS];/**< Array of players.*/
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000347
348 /* File recorders: */
349 unsigned rec_cnt; /**< Number of file recorders. */
Benny Prijonocba59d92007-02-16 09:22:56 +0000350 pjsua_file_data recorder[PJSUA_MAX_RECORDERS];/**< Array of recs.*/
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000351};
352
353
354extern struct pjsua_data pjsua_var;
355
Benny Prijono44e88ea2007-10-30 15:42:35 +0000356/**
357 * Get the instance of pjsua
358 */
359PJ_DECL(struct pjsua_data*) pjsua_get_var(void);
360
361
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000362
363/**
364 * IM callback data.
365 */
366typedef struct pjsua_im_data
367{
368 pjsua_acc_id acc_id;
369 pjsua_call_id call_id;
370 pj_str_t to;
371 pj_str_t body;
372 void *user_data;
373} pjsua_im_data;
374
375
376/**
377 * Duplicate IM data.
378 */
379PJ_INLINE(pjsua_im_data*) pjsua_im_data_dup(pj_pool_t *pool,
380 const pjsua_im_data *src)
381{
382 pjsua_im_data *dst;
383
Benny Prijono07113c92006-11-21 08:38:00 +0000384 dst = (pjsua_im_data*) pj_pool_alloc(pool, sizeof(*dst));
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000385 dst->acc_id = src->acc_id;
386 dst->call_id = src->call_id;
387 pj_strdup_with_null(pool, &dst->to, &src->to);
388 dst->user_data = src->user_data;
389 pj_strdup_with_null(pool, &dst->body, &src->body);
390
391 return dst;
392}
393
394
Benny Prijono148c9dd2006-09-19 13:37:53 +0000395#if 1
396#define PJSUA_LOCK() pj_mutex_lock(pjsua_var.mutex)
397#define PJSUA_TRY_LOCK() pj_mutex_trylock(pjsua_var.mutex)
398#define PJSUA_UNLOCK() pj_mutex_unlock(pjsua_var.mutex)
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000399#else
400#define PJSUA_LOCK()
Benny Prijono148c9dd2006-09-19 13:37:53 +0000401#define PJSUA_TRY_LOCK() PJ_SUCCESS
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000402#define PJSUA_UNLOCK()
403#endif
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000404
Benny Prijonobb995fd2009-08-12 11:03:23 +0000405/******
406 * STUN resolution
407 */
408/* Resolve the STUN server */
409pj_status_t resolve_stun_server(pj_bool_t wait);
410
Benny Prijono91d06b62008-09-20 12:16:56 +0000411/**
412 * Normalize route URI (check for ";lr" and append one if it doesn't
413 * exist and pjsua_config.force_lr is set.
414 */
415pj_status_t normalize_route_uri(pj_pool_t *pool, pj_str_t *uri);
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000416
Benny Prijonoc97608e2007-03-23 16:34:20 +0000417/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000418 * Handle incoming invite request.
419 */
420pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata);
421
Benny Prijonoc97608e2007-03-23 16:34:20 +0000422/*
423 * Media channel.
424 */
425pj_status_t pjsua_media_channel_init(pjsua_call_id call_id,
Benny Prijonod8179652008-01-23 20:39:07 +0000426 pjsip_role_e role,
Benny Prijono25b2ea12008-01-24 19:20:54 +0000427 int security_level,
Benny Prijono224b4e22008-06-19 14:10:28 +0000428 pj_pool_t *tmp_pool,
429 const pjmedia_sdp_session *rem_sdp,
Benny Prijono25b2ea12008-01-24 19:20:54 +0000430 int *sip_err_code);
Benny Prijonoc97608e2007-03-23 16:34:20 +0000431pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id,
432 pj_pool_t *pool,
Benny Prijonod8179652008-01-23 20:39:07 +0000433 const pjmedia_sdp_session *rem_sdp,
Benny Prijono25b2ea12008-01-24 19:20:54 +0000434 pjmedia_sdp_session **p_sdp,
435 int *sip_err_code);
Benny Prijonoc97608e2007-03-23 16:34:20 +0000436pj_status_t pjsua_media_channel_update(pjsua_call_id call_id,
Benny Prijono224b4e22008-06-19 14:10:28 +0000437 const pjmedia_sdp_session *local_sdp,
Benny Prijonodbce2cf2007-03-28 16:24:00 +0000438 const pjmedia_sdp_session *remote_sdp);
Benny Prijonoc97608e2007-03-23 16:34:20 +0000439pj_status_t pjsua_media_channel_deinit(pjsua_call_id call_id);
440
441
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000442/**
443 * Init presence.
444 */
445pj_status_t pjsua_pres_init();
446
447/*
448 * Start presence subsystem.
449 */
450pj_status_t pjsua_pres_start(void);
451
452/**
453 * Refresh presence subscriptions
454 */
455void pjsua_pres_refresh(void);
456
457/*
Benny Prijono4461c7d2007-08-25 13:36:15 +0000458 * Update server subscription (e.g. when our online status has changed)
459 */
460void pjsua_pres_update_acc(int acc_id, pj_bool_t force);
461
462/*
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000463 * Shutdown presence.
464 */
465void pjsua_pres_shutdown(void);
466
467/**
Benny Prijono3a5e1ab2006-08-15 20:26:34 +0000468 * Init presence for aoocunt.
469 */
470pj_status_t pjsua_pres_init_acc(int acc_id);
471
472/**
Benny Prijono8b6834f2007-02-24 13:29:22 +0000473 * Send PUBLISH
474 */
475pj_status_t pjsua_pres_init_publish_acc(int acc_id);
476
477/**
Benny Prijono166d5022010-02-10 14:24:48 +0000478 * Send un-PUBLISH
479 */
480void pjsua_pres_unpublish(pjsua_acc *acc);
481
482/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000483 * Terminate server subscription for the account
484 */
485void pjsua_pres_delete_acc(int acc_id);
486
487/**
488 * Init IM module handler to handle incoming MESSAGE outside dialog.
489 */
490pj_status_t pjsua_im_init(void);
491
492/**
Benny Prijono4dd961b2009-10-26 11:21:37 +0000493 * Start MWI subscription
494 */
495void pjsua_start_mwi(pjsua_acc *acc);
496
497/**
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000498 * Init call subsystem.
499 */
500pj_status_t pjsua_call_subsys_init(const pjsua_config *cfg);
501
502/**
503 * Start call subsystem.
504 */
505pj_status_t pjsua_call_subsys_start(void);
506
507/**
508 * Init media subsystems.
509 */
510pj_status_t pjsua_media_subsys_init(const pjsua_media_config *cfg);
511
512/**
513 * Start pjsua media subsystem.
514 */
515pj_status_t pjsua_media_subsys_start(void);
516
517/**
518 * Destroy pjsua media subsystem.
519 */
520pj_status_t pjsua_media_subsys_destroy(void);
521
522/**
523 * Private: check if we can accept the message.
524 * If not, then p_accept header will be filled with a valid
525 * Accept header.
526 */
527pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata,
528 pjsip_accept_hdr **p_accept_hdr);
529
530/**
531 * Private: process pager message.
532 * This may trigger pjsua_ui_on_pager() or pjsua_ui_on_typing().
533 */
534void pjsua_im_process_pager(int call_id, const pj_str_t *from,
535 const pj_str_t *to, pjsip_rx_data *rdata);
536
537
538/**
539 * Create Accept header for MESSAGE.
540 */
541pjsip_accept_hdr* pjsua_im_create_accept(pj_pool_t *pool);
542
543/*
544 * Add additional headers etc in msg_data specified by application
545 * when sending requests.
546 */
547void pjsua_process_msg_data(pjsip_tx_data *tdata,
548 const pjsua_msg_data *msg_data);
549
550
551/*
552 * Add route_set to outgoing requests
553 */
554void pjsua_set_msg_route_set( pjsip_tx_data *tdata,
555 const pjsip_route_hdr *route_set );
556
557
558/*
559 * Simple version of MIME type parsing (it doesn't support parameters)
560 */
561void pjsua_parse_media_type( pj_pool_t *pool,
562 const pj_str_t *mime,
563 pjsip_media_type *media_type);
564
565
Benny Prijono62c5c5b2007-01-13 23:22:40 +0000566/*
567 * Internal function to init transport selector from transport id.
568 */
569void pjsua_init_tpselector(pjsua_transport_id tp_id,
570 pjsip_tpselector *sel);
571
Benny Prijono3c5e28b2008-09-24 10:10:15 +0000572pjsip_dialog* on_dlg_forked(pjsip_dialog *first_set, pjsip_rx_data *res);
Benny Prijono627cbb42007-09-25 20:48:49 +0000573pj_status_t acquire_call(const char *title,
574 pjsua_call_id call_id,
575 pjsua_call **p_call,
576 pjsip_dialog **p_dlg);
577const char *good_number(char *buf, pj_int32_t val);
578void print_call(const char *title,
579 int call_id,
580 char *buf, pj_size_t size);
581
Benny Prijono62c5c5b2007-01-13 23:22:40 +0000582
Benny Prijonoeebe9af2006-06-13 22:57:13 +0000583PJ_END_DECL
584
585#endif /* __PJSUA_INTERNAL_H__ */
586