Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | 844653c | 2008-12-23 17:27:53 +0000 | [diff] [blame] | 3 | * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) |
Benny Prijono | 32177c0 | 2008-06-20 22:44:47 +0000 | [diff] [blame] | 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 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_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 | |
| 28 | PJ_BEGIN_DECL |
| 29 | |
| 30 | /** |
Benny Prijono | 224b4e2 | 2008-06-19 14:10:28 +0000 | [diff] [blame] | 31 | * Media transport state. |
| 32 | */ |
| 33 | typedef 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 Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 47 | * 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 | */ |
| 51 | typedef 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 Prijono | db844a4 | 2008-02-02 17:07:18 +0000 | [diff] [blame] | 63 | int secure_level;/**< Signaling security level. */ |
Benny Prijono | dd63b99 | 2010-10-01 02:03:42 +0000 | [diff] [blame^] | 64 | pjsua_call_hold_type call_hold_type; /**< How to do call hold. */ |
Nanang Izzuddin | 99d6952 | 2008-08-04 15:01:38 +0000 | [diff] [blame] | 65 | pj_bool_t local_hold;/**< Flag for call-hold by local. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 66 | pjsua_call_media_status media_st;/**< Media state. */ |
| 67 | pjmedia_dir media_dir; /**< Media direction. */ |
| 68 | pjmedia_session *session; /**< The media session. */ |
Benny Prijono | a310bd2 | 2008-06-27 21:19:44 +0000 | [diff] [blame] | 69 | int audio_idx; /**< Index of m=audio in SDP. */ |
Benny Prijono | 8147f40 | 2007-11-21 14:50:07 +0000 | [diff] [blame] | 70 | pj_uint32_t ssrc; /**< RTP SSRC */ |
Nanang Izzuddin | a815ceb | 2008-08-26 16:51:28 +0000 | [diff] [blame] | 71 | 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 Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 78 | int conf_slot; /**< Slot # in conference bridge. */ |
| 79 | pjsip_evsub *xfer_sub; /**< Xfer server subscription, if this |
| 80 | call was triggered by xfer. */ |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 81 | pjmedia_transport *med_tp; /**< Current media transport. */ |
Benny Prijono | 224b4e2 | 2008-06-19 14:10:28 +0000 | [diff] [blame] | 82 | pj_status_t med_tp_ready;/**< Media transport status. */ |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 83 | pjmedia_transport *med_orig; /**< Original media transport */ |
Benny Prijono | 40860c3 | 2008-09-04 13:55:33 +0000 | [diff] [blame] | 84 | pj_bool_t med_tp_auto_del; /**< May delete media transport */ |
Benny Prijono | 224b4e2 | 2008-06-19 14:10:28 +0000 | [diff] [blame] | 85 | pjsua_med_tp_st med_tp_st; /**< Media transport state */ |
Benny Prijono | f5d9f1f | 2009-10-14 13:13:18 +0000 | [diff] [blame] | 86 | pj_sockaddr med_rtp_addr; /**< Current RTP source address |
| 87 | (used to update ICE default |
| 88 | address) */ |
Benny Prijono | 91a6a17 | 2007-10-31 08:59:29 +0000 | [diff] [blame] | 89 | pj_stun_nat_type rem_nat_type; /**< NAT type of remote endpoint. */ |
Nanang Izzuddin | 4375f90 | 2008-06-26 19:12:09 +0000 | [diff] [blame] | 90 | pjmedia_srtp_use rem_srtp_use; /**< Remote's SRTP usage policy. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 91 | |
| 92 | char last_text_buf_[128]; /**< Buffer for last_text. */ |
| 93 | |
Nanang Izzuddin | 93bacd0 | 2010-06-15 09:56:39 +0000 | [diff] [blame] | 94 | struct { |
| 95 | pj_timer_entry reinv_timer;/**< Reinvite retry timer. */ |
| 96 | pjmedia_sdp_session *new_sdp;/**< The new SDP offer. */ |
| 97 | } lock_codec; /**< Data for codec locking when answer |
| 98 | contains multiple codecs. */ |
| 99 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 100 | } pjsua_call; |
| 101 | |
| 102 | |
| 103 | /** |
| 104 | * Server presence subscription list head. |
| 105 | */ |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 106 | struct pjsua_srv_pres |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 107 | { |
| 108 | PJ_DECL_LIST_MEMBER(struct pjsua_srv_pres); |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 109 | pjsip_evsub *sub; /**< The evsub. */ |
| 110 | char *remote; /**< Remote URI. */ |
| 111 | int acc_id; /**< Account ID. */ |
| 112 | pjsip_dialog *dlg; /**< Dialog. */ |
| 113 | int expires; /**< "expires" value in the request. */ |
| 114 | }; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 115 | |
| 116 | |
| 117 | /** |
| 118 | * Account |
| 119 | */ |
| 120 | typedef struct pjsua_acc |
| 121 | { |
Benny Prijono | c91ed8d | 2008-07-13 12:24:55 +0000 | [diff] [blame] | 122 | pj_pool_t *pool; /**< Pool for this account. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 123 | pjsua_acc_config cfg; /**< Account configuration. */ |
| 124 | pj_bool_t valid; /**< Is this account valid? */ |
| 125 | |
| 126 | int index; /**< Index in accounts array. */ |
Benny Prijono | c570f2d | 2006-07-18 00:33:02 +0000 | [diff] [blame] | 127 | pj_str_t display; /**< Display name, if any. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 128 | pj_str_t user_part; /**< User part of local URI. */ |
Nanang Izzuddin | 5af37ff | 2009-08-05 18:41:23 +0000 | [diff] [blame] | 129 | pj_str_t contact; /**< Our Contact header. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 130 | |
Benny Prijono | b4a17c9 | 2006-07-10 14:40:21 +0000 | [diff] [blame] | 131 | pj_str_t srv_domain; /**< Host part of reg server. */ |
| 132 | int srv_port; /**< Port number of reg server. */ |
| 133 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 134 | pjsip_regc *regc; /**< Client registration session. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 135 | pj_status_t reg_last_err; /**< Last registration error. */ |
| 136 | int reg_last_code; /**< Last status last register. */ |
| 137 | |
Nanang Izzuddin | 36dd5b6 | 2010-03-30 11:13:59 +0000 | [diff] [blame] | 138 | struct { |
| 139 | pj_bool_t active; /**< Flag of reregister status. */ |
| 140 | pj_timer_entry timer; /**< Timer for reregistration. */ |
| 141 | void *reg_tp; /**< Transport for registration. */ |
| 142 | unsigned attempt_cnt; /**< Attempt counter. */ |
| 143 | } auto_rereg; /**< Reregister/reconnect data. */ |
| 144 | |
Benny Prijono | bddef2c | 2007-10-31 13:28:08 +0000 | [diff] [blame] | 145 | pj_timer_entry ka_timer; /**< Keep-alive timer for UDP. */ |
| 146 | pjsip_transport *ka_transport; /**< Transport for keep-alive. */ |
| 147 | pj_sockaddr ka_target; /**< Destination address for K-A */ |
| 148 | unsigned ka_target_len; /**< Length of ka_target. */ |
| 149 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 150 | pjsip_route_hdr route_set; /**< Complete route set inc. outbnd.*/ |
Nanang Izzuddin | c3ea16a | 2010-04-20 14:36:38 +0000 | [diff] [blame] | 151 | pj_uint32_t global_route_crc; /** CRC of global route setting. */ |
| 152 | pj_uint32_t local_route_crc; /** CRC of account route setting.*/ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 153 | |
| 154 | unsigned cred_cnt; /**< Number of credentials. */ |
| 155 | pjsip_cred_info cred[PJSUA_ACC_MAX_PROXIES]; /**< Complete creds. */ |
| 156 | |
| 157 | pj_bool_t online_status; /**< Our online status. */ |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 158 | pjrpid_element rpid; /**< RPID element information. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 159 | pjsua_srv_pres pres_srv_list; /**< Server subscription list. */ |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 160 | pjsip_publishc *publish_sess; /**< Client publication session. */ |
| 161 | pj_bool_t publish_state; /**< Last published online status */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 162 | |
Benny Prijono | 4dd961b | 2009-10-26 11:21:37 +0000 | [diff] [blame] | 163 | pjsip_evsub *mwi_sub; /**< MWI client subscription */ |
| 164 | pjsip_dialog *mwi_dlg; /**< Dialog for MWI sub. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 165 | } pjsua_acc; |
| 166 | |
| 167 | |
| 168 | /** |
| 169 | *Transport. |
| 170 | */ |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 171 | typedef struct pjsua_transport_data |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 172 | { |
Benny Prijono | e93e287 | 2006-06-28 16:46:49 +0000 | [diff] [blame] | 173 | int index; |
| 174 | pjsip_transport_type_e type; |
| 175 | pjsip_host_port local_name; |
| 176 | |
| 177 | union { |
| 178 | pjsip_transport *tp; |
| 179 | pjsip_tpfactory *factory; |
| 180 | void *ptr; |
| 181 | } data; |
| 182 | |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 183 | } pjsua_transport_data; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 184 | |
| 185 | |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 186 | /** Maximum length of subscription termination reason. */ |
| 187 | #define PJSUA_BUDDY_SUB_TERM_REASON_LEN 32 |
| 188 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 189 | /** |
| 190 | * Buddy data. |
| 191 | */ |
| 192 | typedef struct pjsua_buddy |
| 193 | { |
Benny Prijono | c91ed8d | 2008-07-13 12:24:55 +0000 | [diff] [blame] | 194 | pj_pool_t *pool; /**< Pool for this buddy. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 195 | unsigned index; /**< Buddy index. */ |
Benny Prijono | 705e784 | 2008-07-21 18:12:51 +0000 | [diff] [blame] | 196 | void *user_data; /**< Application data. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 197 | pj_str_t uri; /**< Buddy URI. */ |
| 198 | pj_str_t contact; /**< Contact learned from subscrp. */ |
| 199 | pj_str_t name; /**< Buddy name. */ |
| 200 | pj_str_t display; /**< Buddy display name. */ |
| 201 | pj_str_t host; /**< Buddy host. */ |
| 202 | unsigned port; /**< Buddy port. */ |
| 203 | pj_bool_t monitor; /**< Should we monitor? */ |
Benny Prijono | f9c40c3 | 2007-06-28 07:20:26 +0000 | [diff] [blame] | 204 | pjsip_dialog *dlg; /**< The underlying dialog. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 205 | pjsip_evsub *sub; /**< Buddy presence subscription */ |
Benny Prijono | 73bb723 | 2009-10-20 13:56:26 +0000 | [diff] [blame] | 206 | unsigned term_code; /**< Subscription termination code */ |
Benny Prijono | 63fba01 | 2008-07-17 14:19:10 +0000 | [diff] [blame] | 207 | pj_str_t term_reason;/**< Subscription termination reason */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 208 | pjsip_pres_status status; /**< Buddy presence status. */ |
Benny Prijono | 73bb723 | 2009-10-20 13:56:26 +0000 | [diff] [blame] | 209 | pj_timer_entry timer; /**< Resubscription timer */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 210 | } pjsua_buddy; |
| 211 | |
| 212 | |
| 213 | /** |
| 214 | * File player/recorder data. |
| 215 | */ |
| 216 | typedef struct pjsua_file_data |
| 217 | { |
Benny Prijono | a66c331 | 2007-01-21 23:12:40 +0000 | [diff] [blame] | 218 | pj_bool_t type; /* 0=player, 1=playlist */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 219 | pjmedia_port *port; |
Benny Prijono | d5696da | 2007-07-17 16:25:45 +0000 | [diff] [blame] | 220 | pj_pool_t *pool; |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 221 | unsigned slot; |
| 222 | } pjsua_file_data; |
| 223 | |
| 224 | |
| 225 | /** |
| 226 | * Additional parameters for conference bridge. |
| 227 | */ |
| 228 | typedef struct pjsua_conf_setting |
| 229 | { |
| 230 | unsigned channel_count; |
| 231 | unsigned samples_per_frame; |
| 232 | unsigned bits_per_sample; |
| 233 | } pjsua_conf_setting; |
| 234 | |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 235 | typedef struct pjsua_stun_resolve |
| 236 | { |
| 237 | PJ_DECL_LIST_MEMBER(struct pjsua_stun_resolve); |
| 238 | |
| 239 | pj_pool_t *pool; /**< Pool */ |
| 240 | unsigned count; /**< # of entries */ |
| 241 | pj_str_t *srv; /**< Array of entries */ |
| 242 | unsigned idx; /**< Current index */ |
| 243 | void *token; /**< App token */ |
| 244 | pj_stun_resolve_cb cb; /**< App callback */ |
| 245 | pj_bool_t blocking; /**< Blocking? */ |
| 246 | pj_status_t status; /**< Session status */ |
| 247 | pj_sockaddr addr; /**< Result */ |
| 248 | pj_stun_sock *stun_sock; /**< Testing STUN sock */ |
| 249 | } pjsua_stun_resolve; |
| 250 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 251 | |
| 252 | /** |
| 253 | * Global pjsua application data. |
| 254 | */ |
| 255 | struct pjsua_data |
| 256 | { |
| 257 | |
| 258 | /* Control: */ |
| 259 | pj_caching_pool cp; /**< Global pool factory. */ |
| 260 | pj_pool_t *pool; /**< pjsua's private pool. */ |
| 261 | pj_mutex_t *mutex; /**< Mutex protection for this data */ |
| 262 | |
| 263 | /* Logging: */ |
| 264 | pjsua_logging_config log_cfg; /**< Current logging config. */ |
| 265 | pj_oshandle_t log_file; /**<Output log file handle */ |
| 266 | |
| 267 | /* SIP: */ |
| 268 | pjsip_endpoint *endpt; /**< Global endpoint. */ |
| 269 | pjsip_module mod; /**< pjsua's PJSIP module. */ |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 270 | pjsua_transport_data tpdata[8]; /**< Array of transports. */ |
Benny Prijono | 2140732 | 2010-03-10 13:33:25 +0000 | [diff] [blame] | 271 | pjsip_tp_state_callback old_tp_cb; /**< Old transport callback. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 272 | |
| 273 | /* Threading: */ |
| 274 | pj_bool_t thread_quit_flag; /**< Thread quit flag. */ |
| 275 | pj_thread_t *thread[4]; /**< Array of threads. */ |
| 276 | |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 277 | /* STUN and resolver */ |
| 278 | pj_stun_config stun_cfg; /**< Global STUN settings. */ |
| 279 | pj_sockaddr stun_srv; /**< Resolved STUN server address */ |
| 280 | pj_status_t stun_status; /**< STUN server status. */ |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 281 | pjsua_stun_resolve stun_res; /**< List of pending STUN resolution*/ |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 282 | pj_dns_resolver *resolver; /**< DNS resolver. */ |
| 283 | |
Benny Prijono | 6ba8c54 | 2007-10-16 01:34:14 +0000 | [diff] [blame] | 284 | /* Detected NAT type */ |
| 285 | pj_stun_nat_type nat_type; /**< NAT type. */ |
| 286 | pj_status_t nat_status; /**< Detection status. */ |
| 287 | pj_bool_t nat_in_progress; /**< Detection in progress */ |
| 288 | |
Benny Prijono | 29c8ca3 | 2010-06-22 06:02:13 +0000 | [diff] [blame] | 289 | /* List of outbound proxies: */ |
| 290 | pjsip_route_hdr outbound_proxy; |
| 291 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 292 | /* Account: */ |
| 293 | unsigned acc_cnt; /**< Number of accounts. */ |
| 294 | pjsua_acc_id default_acc; /**< Default account ID */ |
| 295 | pjsua_acc acc[PJSUA_MAX_ACC]; /**< Account array. */ |
Benny Prijono | 093d302 | 2006-09-24 00:07:11 +0000 | [diff] [blame] | 296 | pjsua_acc_id acc_ids[PJSUA_MAX_ACC]; /**< Acc sorted by prio*/ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 297 | |
| 298 | /* Calls: */ |
| 299 | pjsua_config ua_cfg; /**< UA config. */ |
| 300 | unsigned call_cnt; /**< Call counter. */ |
| 301 | pjsua_call calls[PJSUA_MAX_CALLS];/**< Calls array. */ |
Benny Prijono | 5773cd6 | 2008-01-19 13:01:42 +0000 | [diff] [blame] | 302 | pjsua_call_id next_call_id; /**< Next call id to use*/ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 303 | |
| 304 | /* Buddy; */ |
| 305 | unsigned buddy_cnt; /**< Buddy count. */ |
| 306 | pjsua_buddy buddy[PJSUA_MAX_BUDDIES]; /**< Buddy array. */ |
| 307 | |
Benny Prijono | 7a5f510 | 2007-05-29 00:33:09 +0000 | [diff] [blame] | 308 | /* Presence: */ |
| 309 | pj_timer_entry pres_timer;/**< Presence refresh timer. */ |
| 310 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 311 | /* Media: */ |
| 312 | pjsua_media_config media_cfg; /**< Media config. */ |
| 313 | pjmedia_endpt *med_endpt; /**< Media endpoint. */ |
| 314 | pjsua_conf_setting mconf_cfg; /**< Additionan conf. bridge. param */ |
| 315 | pjmedia_conf *mconf; /**< Conference bridge. */ |
Benny Prijono | f798e50 | 2009-03-09 13:08:16 +0000 | [diff] [blame] | 316 | pj_bool_t is_mswitch;/**< Are we using audio switchboard |
| 317 | (a.k.a APS-Direct) */ |
| 318 | |
| 319 | /* Sound device */ |
| 320 | pjmedia_aud_dev_index cap_dev; /**< Capture device ID. */ |
| 321 | pjmedia_aud_dev_index play_dev; /**< Playback device ID. */ |
| 322 | pj_uint32_t aud_svmask;/**< Which settings to save */ |
| 323 | pjmedia_aud_param aud_param; /**< User settings to sound dev */ |
| 324 | pj_bool_t aud_open_cnt;/**< How many # device is opened */ |
Benny Prijono | e909eac | 2006-07-27 22:04:56 +0000 | [diff] [blame] | 325 | pj_bool_t no_snd; /**< No sound (app will manage it) */ |
Nanang Izzuddin | 68559c3 | 2008-06-13 17:01:46 +0000 | [diff] [blame] | 326 | pj_pool_t *snd_pool; /**< Sound's private pool. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 327 | pjmedia_snd_port *snd_port; /**< Sound port. */ |
Nanang Izzuddin | 68559c3 | 2008-06-13 17:01:46 +0000 | [diff] [blame] | 328 | pj_timer_entry snd_idle_timer;/**< Sound device idle timer. */ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 329 | pjmedia_master_port *null_snd; /**< Master port for null sound. */ |
| 330 | pjmedia_port *null_port; /**< Null port. */ |
| 331 | |
| 332 | |
| 333 | /* File players: */ |
| 334 | unsigned player_cnt;/**< Number of file players. */ |
Benny Prijono | cba59d9 | 2007-02-16 09:22:56 +0000 | [diff] [blame] | 335 | pjsua_file_data player[PJSUA_MAX_PLAYERS];/**< Array of players.*/ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 336 | |
| 337 | /* File recorders: */ |
| 338 | unsigned rec_cnt; /**< Number of file recorders. */ |
Benny Prijono | cba59d9 | 2007-02-16 09:22:56 +0000 | [diff] [blame] | 339 | pjsua_file_data recorder[PJSUA_MAX_RECORDERS];/**< Array of recs.*/ |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 340 | }; |
| 341 | |
| 342 | |
| 343 | extern struct pjsua_data pjsua_var; |
| 344 | |
Benny Prijono | 44e88ea | 2007-10-30 15:42:35 +0000 | [diff] [blame] | 345 | /** |
| 346 | * Get the instance of pjsua |
| 347 | */ |
| 348 | PJ_DECL(struct pjsua_data*) pjsua_get_var(void); |
| 349 | |
| 350 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 351 | |
| 352 | /** |
| 353 | * IM callback data. |
| 354 | */ |
| 355 | typedef struct pjsua_im_data |
| 356 | { |
| 357 | pjsua_acc_id acc_id; |
| 358 | pjsua_call_id call_id; |
| 359 | pj_str_t to; |
| 360 | pj_str_t body; |
| 361 | void *user_data; |
| 362 | } pjsua_im_data; |
| 363 | |
| 364 | |
| 365 | /** |
| 366 | * Duplicate IM data. |
| 367 | */ |
| 368 | PJ_INLINE(pjsua_im_data*) pjsua_im_data_dup(pj_pool_t *pool, |
| 369 | const pjsua_im_data *src) |
| 370 | { |
| 371 | pjsua_im_data *dst; |
| 372 | |
Benny Prijono | 07113c9 | 2006-11-21 08:38:00 +0000 | [diff] [blame] | 373 | dst = (pjsua_im_data*) pj_pool_alloc(pool, sizeof(*dst)); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 374 | dst->acc_id = src->acc_id; |
| 375 | dst->call_id = src->call_id; |
| 376 | pj_strdup_with_null(pool, &dst->to, &src->to); |
| 377 | dst->user_data = src->user_data; |
| 378 | pj_strdup_with_null(pool, &dst->body, &src->body); |
| 379 | |
| 380 | return dst; |
| 381 | } |
| 382 | |
| 383 | |
Benny Prijono | 148c9dd | 2006-09-19 13:37:53 +0000 | [diff] [blame] | 384 | #if 1 |
| 385 | #define PJSUA_LOCK() pj_mutex_lock(pjsua_var.mutex) |
| 386 | #define PJSUA_TRY_LOCK() pj_mutex_trylock(pjsua_var.mutex) |
| 387 | #define PJSUA_UNLOCK() pj_mutex_unlock(pjsua_var.mutex) |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 388 | #else |
| 389 | #define PJSUA_LOCK() |
Benny Prijono | 148c9dd | 2006-09-19 13:37:53 +0000 | [diff] [blame] | 390 | #define PJSUA_TRY_LOCK() PJ_SUCCESS |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 391 | #define PJSUA_UNLOCK() |
| 392 | #endif |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 393 | |
Benny Prijono | bb995fd | 2009-08-12 11:03:23 +0000 | [diff] [blame] | 394 | /****** |
| 395 | * STUN resolution |
| 396 | */ |
| 397 | /* Resolve the STUN server */ |
| 398 | pj_status_t resolve_stun_server(pj_bool_t wait); |
| 399 | |
Benny Prijono | 91d06b6 | 2008-09-20 12:16:56 +0000 | [diff] [blame] | 400 | /** |
| 401 | * Normalize route URI (check for ";lr" and append one if it doesn't |
| 402 | * exist and pjsua_config.force_lr is set. |
| 403 | */ |
| 404 | pj_status_t normalize_route_uri(pj_pool_t *pool, pj_str_t *uri); |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 405 | |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 406 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 407 | * Handle incoming invite request. |
| 408 | */ |
| 409 | pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata); |
| 410 | |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 411 | /* |
| 412 | * Media channel. |
| 413 | */ |
| 414 | pj_status_t pjsua_media_channel_init(pjsua_call_id call_id, |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 415 | pjsip_role_e role, |
Benny Prijono | 25b2ea1 | 2008-01-24 19:20:54 +0000 | [diff] [blame] | 416 | int security_level, |
Benny Prijono | 224b4e2 | 2008-06-19 14:10:28 +0000 | [diff] [blame] | 417 | pj_pool_t *tmp_pool, |
| 418 | const pjmedia_sdp_session *rem_sdp, |
Benny Prijono | 25b2ea1 | 2008-01-24 19:20:54 +0000 | [diff] [blame] | 419 | int *sip_err_code); |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 420 | pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id, |
| 421 | pj_pool_t *pool, |
Benny Prijono | d817965 | 2008-01-23 20:39:07 +0000 | [diff] [blame] | 422 | const pjmedia_sdp_session *rem_sdp, |
Benny Prijono | 25b2ea1 | 2008-01-24 19:20:54 +0000 | [diff] [blame] | 423 | pjmedia_sdp_session **p_sdp, |
| 424 | int *sip_err_code); |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 425 | pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, |
Benny Prijono | 224b4e2 | 2008-06-19 14:10:28 +0000 | [diff] [blame] | 426 | const pjmedia_sdp_session *local_sdp, |
Benny Prijono | dbce2cf | 2007-03-28 16:24:00 +0000 | [diff] [blame] | 427 | const pjmedia_sdp_session *remote_sdp); |
Benny Prijono | c97608e | 2007-03-23 16:34:20 +0000 | [diff] [blame] | 428 | pj_status_t pjsua_media_channel_deinit(pjsua_call_id call_id); |
| 429 | |
| 430 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 431 | /** |
| 432 | * Init presence. |
| 433 | */ |
| 434 | pj_status_t pjsua_pres_init(); |
| 435 | |
| 436 | /* |
| 437 | * Start presence subsystem. |
| 438 | */ |
| 439 | pj_status_t pjsua_pres_start(void); |
| 440 | |
| 441 | /** |
| 442 | * Refresh presence subscriptions |
| 443 | */ |
| 444 | void pjsua_pres_refresh(void); |
| 445 | |
| 446 | /* |
Benny Prijono | 4461c7d | 2007-08-25 13:36:15 +0000 | [diff] [blame] | 447 | * Update server subscription (e.g. when our online status has changed) |
| 448 | */ |
| 449 | void pjsua_pres_update_acc(int acc_id, pj_bool_t force); |
| 450 | |
| 451 | /* |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 452 | * Shutdown presence. |
| 453 | */ |
| 454 | void pjsua_pres_shutdown(void); |
| 455 | |
| 456 | /** |
Benny Prijono | 3a5e1ab | 2006-08-15 20:26:34 +0000 | [diff] [blame] | 457 | * Init presence for aoocunt. |
| 458 | */ |
| 459 | pj_status_t pjsua_pres_init_acc(int acc_id); |
| 460 | |
| 461 | /** |
Benny Prijono | 8b6834f | 2007-02-24 13:29:22 +0000 | [diff] [blame] | 462 | * Send PUBLISH |
| 463 | */ |
| 464 | pj_status_t pjsua_pres_init_publish_acc(int acc_id); |
| 465 | |
| 466 | /** |
Benny Prijono | 166d502 | 2010-02-10 14:24:48 +0000 | [diff] [blame] | 467 | * Send un-PUBLISH |
| 468 | */ |
| 469 | void pjsua_pres_unpublish(pjsua_acc *acc); |
| 470 | |
| 471 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 472 | * Terminate server subscription for the account |
| 473 | */ |
| 474 | void pjsua_pres_delete_acc(int acc_id); |
| 475 | |
| 476 | /** |
| 477 | * Init IM module handler to handle incoming MESSAGE outside dialog. |
| 478 | */ |
| 479 | pj_status_t pjsua_im_init(void); |
| 480 | |
| 481 | /** |
Benny Prijono | 4dd961b | 2009-10-26 11:21:37 +0000 | [diff] [blame] | 482 | * Start MWI subscription |
| 483 | */ |
| 484 | void pjsua_start_mwi(pjsua_acc *acc); |
| 485 | |
| 486 | /** |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 487 | * Init call subsystem. |
| 488 | */ |
| 489 | pj_status_t pjsua_call_subsys_init(const pjsua_config *cfg); |
| 490 | |
| 491 | /** |
| 492 | * Start call subsystem. |
| 493 | */ |
| 494 | pj_status_t pjsua_call_subsys_start(void); |
| 495 | |
| 496 | /** |
| 497 | * Init media subsystems. |
| 498 | */ |
| 499 | pj_status_t pjsua_media_subsys_init(const pjsua_media_config *cfg); |
| 500 | |
| 501 | /** |
| 502 | * Start pjsua media subsystem. |
| 503 | */ |
| 504 | pj_status_t pjsua_media_subsys_start(void); |
| 505 | |
| 506 | /** |
| 507 | * Destroy pjsua media subsystem. |
| 508 | */ |
| 509 | pj_status_t pjsua_media_subsys_destroy(void); |
| 510 | |
| 511 | /** |
| 512 | * Private: check if we can accept the message. |
| 513 | * If not, then p_accept header will be filled with a valid |
| 514 | * Accept header. |
| 515 | */ |
| 516 | pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata, |
| 517 | pjsip_accept_hdr **p_accept_hdr); |
| 518 | |
| 519 | /** |
| 520 | * Private: process pager message. |
| 521 | * This may trigger pjsua_ui_on_pager() or pjsua_ui_on_typing(). |
| 522 | */ |
| 523 | void pjsua_im_process_pager(int call_id, const pj_str_t *from, |
| 524 | const pj_str_t *to, pjsip_rx_data *rdata); |
| 525 | |
| 526 | |
| 527 | /** |
| 528 | * Create Accept header for MESSAGE. |
| 529 | */ |
| 530 | pjsip_accept_hdr* pjsua_im_create_accept(pj_pool_t *pool); |
| 531 | |
| 532 | /* |
| 533 | * Add additional headers etc in msg_data specified by application |
| 534 | * when sending requests. |
| 535 | */ |
| 536 | void pjsua_process_msg_data(pjsip_tx_data *tdata, |
| 537 | const pjsua_msg_data *msg_data); |
| 538 | |
| 539 | |
| 540 | /* |
| 541 | * Add route_set to outgoing requests |
| 542 | */ |
| 543 | void pjsua_set_msg_route_set( pjsip_tx_data *tdata, |
| 544 | const pjsip_route_hdr *route_set ); |
| 545 | |
| 546 | |
| 547 | /* |
| 548 | * Simple version of MIME type parsing (it doesn't support parameters) |
| 549 | */ |
| 550 | void pjsua_parse_media_type( pj_pool_t *pool, |
| 551 | const pj_str_t *mime, |
| 552 | pjsip_media_type *media_type); |
| 553 | |
| 554 | |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 555 | /* |
| 556 | * Internal function to init transport selector from transport id. |
| 557 | */ |
| 558 | void pjsua_init_tpselector(pjsua_transport_id tp_id, |
| 559 | pjsip_tpselector *sel); |
| 560 | |
Benny Prijono | 3c5e28b | 2008-09-24 10:10:15 +0000 | [diff] [blame] | 561 | pjsip_dialog* on_dlg_forked(pjsip_dialog *first_set, pjsip_rx_data *res); |
Benny Prijono | 627cbb4 | 2007-09-25 20:48:49 +0000 | [diff] [blame] | 562 | pj_status_t acquire_call(const char *title, |
| 563 | pjsua_call_id call_id, |
| 564 | pjsua_call **p_call, |
| 565 | pjsip_dialog **p_dlg); |
| 566 | const char *good_number(char *buf, pj_int32_t val); |
| 567 | void print_call(const char *title, |
| 568 | int call_id, |
| 569 | char *buf, pj_size_t size); |
| 570 | |
Benny Prijono | 62c5c5b | 2007-01-13 23:22:40 +0000 | [diff] [blame] | 571 | |
Benny Prijono | eebe9af | 2006-06-13 22:57:13 +0000 | [diff] [blame] | 572 | PJ_END_DECL |
| 573 | |
| 574 | #endif /* __PJSUA_INTERNAL_H__ */ |
| 575 | |