Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #ifndef __PJSUA_H__ |
| 20 | #define __PJSUA_H__ |
| 21 | |
| 22 | /* Include all PJSIP core headers. */ |
| 23 | #include <pjsip.h> |
| 24 | |
| 25 | /* Include all PJMEDIA headers. */ |
| 26 | #include <pjmedia.h> |
| 27 | |
Benny Prijono | 1f9afba | 2006-02-10 15:57:32 +0000 | [diff] [blame] | 28 | /* Include all PJMEDIA-CODEC headers. */ |
| 29 | #include <pjmedia-codec.h> |
| 30 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 31 | /* Include all PJSIP-UA headers */ |
| 32 | #include <pjsip_ua.h> |
| 33 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 34 | /* Include all PJSIP-SIMPLE headers */ |
| 35 | #include <pjsip_simple.h> |
| 36 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 37 | /* Include all PJLIB-UTIL headers. */ |
| 38 | #include <pjlib-util.h> |
| 39 | |
| 40 | /* Include all PJLIB headers. */ |
| 41 | #include <pjlib.h> |
| 42 | |
| 43 | |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 44 | PJ_BEGIN_DECL |
| 45 | |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 46 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 47 | /** |
| 48 | * Max buddies in buddy list. |
| 49 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 50 | #ifndef PJSUA_MAX_BUDDIES |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 51 | # define PJSUA_MAX_BUDDIES 256 |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 52 | #endif |
| 53 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 54 | |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 55 | /** |
| 56 | * Max simultaneous calls. |
| 57 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 58 | #ifndef PJSUA_MAX_CALLS |
| 59 | # define PJSUA_MAX_CALLS 256 |
| 60 | #endif |
| 61 | |
| 62 | |
| 63 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 64 | * Maximum accounts. |
| 65 | */ |
| 66 | #ifndef PJSUA_MAX_ACC |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 67 | # define PJSUA_MAX_ACC 32 |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 68 | #endif |
| 69 | |
| 70 | |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 71 | |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 72 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 73 | * Structure to be attached to invite dialog. |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 74 | * Given a dialog "dlg", application can retrieve this structure |
| 75 | * by accessing dlg->mod_data[pjsua.mod.id]. |
| 76 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 77 | struct pjsua_call |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 78 | { |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 79 | unsigned index; /**< Index in pjsua array. */ |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 80 | pjsip_inv_session *inv; /**< The invite session. */ |
Benny Prijono | e21e784 | 2006-04-09 16:46:05 +0000 | [diff] [blame] | 81 | pj_time_val start_time;/**< First INVITE sent/received. */ |
| 82 | pj_time_val res_time; /**< First response sent/received. */ |
| 83 | pj_time_val conn_time; /**< Connected/confirmed time. */ |
| 84 | pj_time_val dis_time; /**< Disconnect time. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 85 | int acc_index; /**< Account index being used. */ |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 86 | pjmedia_session *session; /**< The media session. */ |
| 87 | unsigned conf_slot; /**< Slot # in conference bridge. */ |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 88 | pjsip_evsub *xfer_sub; /**< Xfer server subscription, if this |
| 89 | call was triggered by xfer. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 90 | pjmedia_sock_info skinfo; /**< Preallocated media sockets. */ |
Benny Prijono | b04c9e0 | 2006-05-17 17:17:39 +0000 | [diff] [blame] | 91 | pjmedia_transport *med_tp; /**< Media transport. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 92 | void *app_data; /**< Application data. */ |
Benny Prijono | 105217f | 2006-03-06 16:25:59 +0000 | [diff] [blame] | 93 | pj_timer_entry refresh_tm;/**< Timer to send re-INVITE. */ |
| 94 | pj_timer_entry hangup_tm; /**< Timer to hangup call. */ |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 95 | }; |
| 96 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 97 | typedef struct pjsua_call pjsua_call; |
| 98 | |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 99 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 100 | /** |
| 101 | * Buddy data. |
| 102 | */ |
| 103 | struct pjsua_buddy |
| 104 | { |
| 105 | pj_str_t uri; /**< Buddy URI */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 106 | int acc_index; /**< Which account to use. */ |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 107 | pj_bool_t monitor; /**< Should we monitor? */ |
| 108 | pjsip_evsub *sub; /**< Buddy presence subscription */ |
| 109 | pjsip_pres_status status; /**< Buddy presence status. */ |
| 110 | }; |
| 111 | |
| 112 | typedef struct pjsua_buddy pjsua_buddy; |
| 113 | |
| 114 | |
| 115 | /** |
| 116 | * Server presence subscription list head. |
| 117 | */ |
| 118 | struct pjsua_srv_pres |
| 119 | { |
| 120 | PJ_DECL_LIST_MEMBER(struct pjsua_srv_pres); |
| 121 | pjsip_evsub *sub; |
| 122 | char *remote; |
| 123 | }; |
| 124 | |
| 125 | typedef struct pjsua_srv_pres pjsua_srv_pres; |
| 126 | |
| 127 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 128 | /** |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 129 | * Account configuration. |
| 130 | */ |
| 131 | struct pjsua_acc_config |
| 132 | { |
| 133 | /** SIP URL for account ID (mandatory) */ |
| 134 | pj_str_t id; |
| 135 | |
| 136 | /** Registrar URI (mandatory) */ |
| 137 | pj_str_t reg_uri; |
| 138 | |
| 139 | /** Optional contact URI */ |
| 140 | pj_str_t contact; |
| 141 | |
| 142 | /** Service proxy (default: none) */ |
| 143 | pj_str_t proxy; |
| 144 | |
| 145 | /** Default timeout (mandatory) */ |
| 146 | pj_int32_t reg_timeout; |
| 147 | |
| 148 | /** Number of credentials. */ |
| 149 | unsigned cred_count; |
| 150 | |
| 151 | /** Array of credentials. */ |
| 152 | pjsip_cred_info cred_info[4]; |
| 153 | |
| 154 | }; |
| 155 | |
| 156 | |
| 157 | /** |
| 158 | * @see pjsua_acc_config |
| 159 | */ |
| 160 | typedef struct pjsua_acc_config pjsua_acc_config; |
| 161 | |
| 162 | |
| 163 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 164 | * Account |
| 165 | */ |
| 166 | struct pjsua_acc |
| 167 | { |
| 168 | int index; /**< Index in accounts array. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 169 | pj_str_t user_part; /**< User part of local URI. */ |
| 170 | pj_str_t host_part; /**< Host part of local URI. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 171 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 172 | pjsip_regc *regc; /**< Client registration session. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 173 | pj_timer_entry reg_timer; /**< Registration timer. */ |
| 174 | pj_status_t reg_last_err; /**< Last registration error. */ |
| 175 | int reg_last_code; /**< Last status last register. */ |
| 176 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 177 | pjsip_route_hdr route_set; /**< Route set. */ |
| 178 | |
| 179 | pj_bool_t online_status; /**< Our online status. */ |
| 180 | pjsua_srv_pres pres_srv_list; /**< Server subscription list. */ |
| 181 | |
| 182 | void *app_data; /**< Application data. */ |
| 183 | }; |
| 184 | |
| 185 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 186 | /** |
| 187 | * @see pjsua_acc |
| 188 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 189 | typedef struct pjsua_acc pjsua_acc; |
| 190 | |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 191 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 192 | /** |
| 193 | * PJSUA settings. |
| 194 | */ |
| 195 | struct pjsua_config |
| 196 | { |
| 197 | /** SIP UDP signaling port. Set to zero to disable UDP signaling, |
| 198 | * which in this case application must manually add a transport |
| 199 | * to SIP endpoint. |
| 200 | * (default: 5060) |
| 201 | */ |
| 202 | unsigned udp_port; |
| 203 | |
| 204 | /** Optional hostname or IP address to publish as the host part of |
| 205 | * Contact header. This must be specified if UDP transport is |
| 206 | * disabled. |
| 207 | * (default: NULL) |
| 208 | */ |
| 209 | pj_str_t sip_host; |
| 210 | |
| 211 | /** Optional port number to publish in the port part of Contact header. |
| 212 | * This must be specified if UDP transport is disabled. |
| 213 | * (default: 0) |
| 214 | */ |
| 215 | unsigned sip_port; |
| 216 | |
| 217 | /** Start of RTP port. Set to zero to prevent pjsua from creating |
| 218 | * media transports, which in this case application must manually |
| 219 | * create media transport for each calls. |
| 220 | * (default: 4000) |
| 221 | */ |
| 222 | unsigned start_rtp_port; |
| 223 | |
| 224 | /** Maximum calls to support (default: 4) */ |
| 225 | unsigned max_calls; |
| 226 | |
| 227 | /** Maximum slots in the conference bridge (default: 0/calculated |
| 228 | * as max_calls*2 |
| 229 | */ |
| 230 | unsigned conf_ports; |
| 231 | |
| 232 | /** Number of worker threads (default: 1) */ |
| 233 | unsigned thread_cnt; |
| 234 | |
| 235 | /** First STUN server IP address. When STUN is configured, then the |
| 236 | * two STUN server settings must be fully set. |
| 237 | * (default: none) |
| 238 | */ |
| 239 | pj_str_t stun_srv1; |
| 240 | |
| 241 | /** First STUN port number */ |
| 242 | unsigned stun_port1; |
| 243 | |
| 244 | /** Second STUN server IP address */ |
| 245 | pj_str_t stun_srv2; |
| 246 | |
| 247 | /** Second STUN server port number */ |
| 248 | unsigned stun_port2; |
| 249 | |
| 250 | /** Internal clock rate (to be applied to sound devices and conference |
| 251 | * bridge, default is 0/follows the codec, or 44100 for MacOS). |
| 252 | */ |
| 253 | unsigned clock_rate; |
| 254 | |
| 255 | /** Do not use sound device (default: 0). */ |
| 256 | pj_bool_t null_audio; |
| 257 | |
| 258 | /** WAV file to load for auto_play (default: NULL) */ |
| 259 | pj_str_t wav_file; |
| 260 | |
| 261 | /** Auto play WAV file for calls? (default: no) */ |
| 262 | pj_bool_t auto_play; |
| 263 | |
| 264 | /** Auto loopback calls? (default: no) */ |
| 265 | pj_bool_t auto_loop; |
| 266 | |
| 267 | /** Automatically put calls to conference? (default: no) */ |
| 268 | pj_bool_t auto_conf; |
| 269 | |
| 270 | /** Speex codec complexity? (default: 10) */ |
| 271 | unsigned complexity; |
| 272 | |
| 273 | /** Speex codec quality? (default: 10) */ |
| 274 | unsigned quality; |
| 275 | |
| 276 | /** Codec ptime? (default: 0 (follows the codec)) */ |
| 277 | unsigned ptime; |
| 278 | |
| 279 | /** Number of additional codecs/"--add-codec" with pjsua (default: 0) */ |
| 280 | unsigned codec_cnt; |
| 281 | |
| 282 | /** Additional codecs/"--add-codec" options */ |
| 283 | pj_str_t codec_arg[32]; |
| 284 | |
| 285 | /** SIP status code to be automatically sent to incoming calls |
| 286 | * (default: 100). |
| 287 | */ |
| 288 | unsigned auto_answer; |
| 289 | |
| 290 | /** Periodic time to refresh call with re-INVITE (default: 0) |
| 291 | */ |
| 292 | unsigned uas_refresh; |
| 293 | |
| 294 | /** Maximum incoming call duration (default: 3600) */ |
| 295 | unsigned uas_duration; |
| 296 | |
| 297 | /** Outbound proxy (default: none) */ |
| 298 | pj_str_t outbound_proxy; |
| 299 | |
| 300 | /** URI to call. */ |
| 301 | pj_str_t uri_to_call; |
| 302 | |
| 303 | /** Number of SIP accounts */ |
| 304 | unsigned acc_cnt; |
| 305 | |
| 306 | /** SIP accounts configuration */ |
| 307 | pjsua_acc_config acc_config[32]; |
| 308 | |
| 309 | /** Logging verbosity (default: 5). */ |
| 310 | unsigned log_level; |
| 311 | |
| 312 | /** Logging to be displayed to stdout (default: 4) */ |
| 313 | unsigned app_log_level; |
| 314 | |
| 315 | /** Log decoration */ |
| 316 | unsigned log_decor; |
| 317 | |
| 318 | /** Optional log filename (default: NULL) */ |
| 319 | pj_str_t log_filename; |
| 320 | |
| 321 | /** Number of buddies in address book (default: 0) */ |
| 322 | unsigned buddy_cnt; |
| 323 | |
| 324 | /** Buddies URI */ |
| 325 | pj_str_t buddy_uri[256]; |
| 326 | }; |
| 327 | |
| 328 | |
| 329 | /** |
| 330 | * @see pjsua_config |
| 331 | */ |
| 332 | typedef struct pjsua_config pjsua_config; |
| 333 | |
| 334 | |
| 335 | |
| 336 | /** |
| 337 | * Application callbacks. |
| 338 | */ |
| 339 | struct pjsua_callback |
| 340 | { |
| 341 | /** |
| 342 | * Notify UI when invite state has changed. |
| 343 | */ |
| 344 | void (*on_call_state)(int call_index, pjsip_event *e); |
| 345 | |
| 346 | /** |
| 347 | * Notify UI when registration status has changed. |
| 348 | */ |
| 349 | void (*on_reg_state)(int acc_index); |
| 350 | |
| 351 | /** |
| 352 | * Notify UI on incoming pager (i.e. MESSAGE request). |
| 353 | * Argument call_index will be -1 if MESSAGE request is not related to an |
| 354 | * existing call. |
| 355 | */ |
| 356 | void (*on_pager)(int call_index, const pj_str_t *from, |
| 357 | const pj_str_t *to, const pj_str_t *txt); |
| 358 | |
| 359 | /** |
| 360 | * Notify UI about typing indication. |
| 361 | */ |
| 362 | void (*on_typing)(int call_index, const pj_str_t *from, |
| 363 | const pj_str_t *to, pj_bool_t is_typing); |
| 364 | |
| 365 | }; |
| 366 | |
| 367 | /** |
| 368 | * @see pjsua_callback |
| 369 | */ |
| 370 | typedef struct pjsua_callback pjsua_callback; |
| 371 | |
| 372 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 373 | /* PJSUA application variables. */ |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 374 | struct pjsua |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 375 | { |
| 376 | /* Control: */ |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 377 | pj_caching_pool cp; /**< Global pool factory. */ |
| 378 | pjsip_endpoint *endpt; /**< Global endpoint. */ |
| 379 | pj_pool_t *pool; /**< pjsua's private pool. */ |
| 380 | pjsip_module mod; /**< pjsua's PJSIP module. */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 381 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 382 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 383 | /* Config: */ |
| 384 | pjsua_config config; /**< PJSUA configs */ |
| 385 | |
| 386 | /* Application callback: */ |
| 387 | pjsua_callback cb; /**< Application callback. */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 388 | |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 389 | /* Media: */ |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 390 | pjmedia_endpt *med_endpt; /**< Media endpoint. */ |
| 391 | pjmedia_conf *mconf; /**< Media conference. */ |
Benny Prijono | 3987915 | 2006-02-23 02:09:10 +0000 | [diff] [blame] | 392 | unsigned wav_slot; /**< WAV player slot in bridge */ |
Benny Prijono | de38058 | 2006-03-15 19:32:41 +0000 | [diff] [blame] | 393 | pjmedia_port *file_port; /**< WAV player port. */ |
Benny Prijono | 1c2bf46 | 2006-03-05 11:54:02 +0000 | [diff] [blame] | 394 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 395 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 396 | /* Account: */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 397 | pjsua_acc acc[PJSUA_MAX_ACC]; /** Client regs array. */ |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 398 | |
| 399 | |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 400 | /* Threading (optional): */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 401 | pj_thread_t *threads[8]; /**< Thread instances. */ |
| 402 | pj_bool_t quit_flag; /**< To signal thread to quit. */ |
| 403 | |
| 404 | /* Transport (UDP): */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 405 | pj_sock_t sip_sock; /**< SIP UDP socket. */ |
| 406 | pj_sockaddr_in sip_sock_name; /**< Public/STUN UDP socket addr. */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 407 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 408 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 409 | /* PJSUA Calls: */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 410 | int call_cnt; /**< Number of calls. */ |
| 411 | pjsua_call calls[PJSUA_MAX_CALLS]; /** Calls array. */ |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 412 | |
| 413 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 414 | /* SIMPLE and buddy status: */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 415 | int buddy_cnt; |
| 416 | pjsua_buddy buddies[PJSUA_MAX_BUDDIES]; |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 417 | }; |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 418 | |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 419 | |
| 420 | /** PJSUA instance. */ |
| 421 | extern struct pjsua pjsua; |
| 422 | |
| 423 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 424 | |
| 425 | /***************************************************************************** |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 426 | * PJSUA API (defined in pjsua_core.c). |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 427 | */ |
| 428 | |
| 429 | /** |
| 430 | * Initialize pjsua settings with default parameters. |
| 431 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 432 | PJ_DECL(void) pjsua_default_config(pjsua_config *cfg); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 433 | |
| 434 | |
| 435 | /** |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 436 | * Test configuration. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 437 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 438 | PJ_DECL(pj_status_t) pjsua_test_config(const pjsua_config *cfg, |
| 439 | char *errmsg, |
| 440 | int len); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 441 | |
| 442 | |
| 443 | /** |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 444 | * Create pjsua application. |
| 445 | * This initializes pjlib/pjlib-util, and creates memory pool factory to |
| 446 | * be used by application. |
| 447 | */ |
| 448 | PJ_DECL(pj_status_t) pjsua_create(void); |
| 449 | |
| 450 | |
| 451 | /** |
| 452 | * Initialize pjsua application with the specified settings. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 453 | * |
| 454 | * This will initialize all libraries, create endpoint instance, and register |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 455 | * pjsip modules. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 456 | * |
| 457 | * Application may register module after calling this function. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 458 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 459 | PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *cfg, |
| 460 | const pjsua_callback *cb); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 461 | |
| 462 | |
| 463 | /** |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 464 | * Start pjsua stack. Application calls this after pjsua settings has been |
| 465 | * configured. |
| 466 | * |
| 467 | * This will start the transport, worker threads (if any), and registration |
| 468 | * process, if registration is configured. |
| 469 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 470 | PJ_DECL(pj_status_t) pjsua_start(void); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 471 | |
| 472 | |
| 473 | /** |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 474 | * Destroy pjsua. |
| 475 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 476 | PJ_DECL(pj_status_t) pjsua_destroy(void); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 477 | |
| 478 | |
| 479 | /***************************************************************************** |
| 480 | * PJSUA Call API (defined in pjsua_call.c). |
| 481 | */ |
| 482 | |
| 483 | /** |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 484 | * Make outgoing call. |
| 485 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 486 | PJ_DECL(pj_status_t) pjsua_make_call(int acc_index, |
| 487 | const char *cstr_dest_uri, |
| 488 | int *p_call_index); |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 489 | |
| 490 | |
| 491 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 492 | * Answer call. |
| 493 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 494 | PJ_DECL(void) pjsua_call_answer(int call_index, int code); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 495 | |
| 496 | /** |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 497 | * Hangup call. |
| 498 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 499 | PJ_DECL(void) pjsua_call_hangup(int call_index); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 500 | |
| 501 | |
| 502 | /** |
| 503 | * Put call on-hold. |
| 504 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 505 | PJ_DECL(void) pjsua_call_set_hold(int call_index); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 506 | |
| 507 | |
| 508 | /** |
| 509 | * Send re-INVITE (to release hold). |
| 510 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 511 | PJ_DECL(void) pjsua_call_reinvite(int call_index); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 512 | |
| 513 | |
| 514 | /** |
| 515 | * Transfer call. |
| 516 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 517 | PJ_DECL(void) pjsua_call_xfer(int call_index, const char *dest); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 518 | |
| 519 | |
| 520 | /** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 521 | * Send instant messaging inside INVITE session. |
| 522 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 523 | PJ_DECL(void) pjsua_call_send_im(int call_index, const char *text); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 524 | |
| 525 | |
| 526 | /** |
| 527 | * Send IM typing indication inside INVITE session. |
| 528 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 529 | PJ_DECL(void) pjsua_call_typing(int call_index, pj_bool_t is_typing); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 530 | |
| 531 | /** |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 532 | * Terminate all calls. |
| 533 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 534 | PJ_DECL(void) pjsua_call_hangup_all(void); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 535 | |
| 536 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 537 | /***************************************************************************** |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 538 | * PJSUA Client Registration API (defined in pjsua_reg.c). |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 539 | */ |
| 540 | |
| 541 | /** |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 542 | * Update registration or perform unregistration. If renew argument is zero, |
| 543 | * this will start unregistration process. |
| 544 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 545 | PJ_DECL(void) pjsua_regc_update(int acc_index, pj_bool_t renew); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 546 | |
| 547 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 548 | |
| 549 | |
| 550 | /***************************************************************************** |
| 551 | * PJSUA Presence (pjsua_pres.c) |
| 552 | */ |
| 553 | |
| 554 | /** |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 555 | * Refresh both presence client and server subscriptions. |
| 556 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 557 | PJ_DECL(void) pjsua_pres_refresh(int acc_index); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 558 | |
| 559 | /** |
| 560 | * Dump presence subscriptions. |
| 561 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 562 | PJ_DECL(void) pjsua_pres_dump(pj_bool_t detail); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 563 | |
| 564 | |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 565 | /***************************************************************************** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 566 | * PJSUA Instant Messaging (pjsua_im.c) |
| 567 | */ |
| 568 | |
| 569 | /** |
| 570 | * The MESSAGE method (defined in pjsua_im.c) |
| 571 | */ |
| 572 | extern const pjsip_method pjsip_message_method; |
| 573 | |
| 574 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 575 | |
| 576 | /** |
| 577 | * Send IM outside dialog. |
| 578 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 579 | PJ_DECL(pj_status_t) pjsua_im_send(int acc_index, const char *dst_uri, |
| 580 | const char *text); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 581 | |
| 582 | |
| 583 | /** |
| 584 | * Send typing indication outside dialog. |
| 585 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 586 | PJ_DECL(pj_status_t) pjsua_im_typing(int acc_index, const char *dst_uri, |
| 587 | pj_bool_t is_typing); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 588 | |
| 589 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 590 | |
| 591 | /***************************************************************************** |
| 592 | * Utilities. |
| 593 | * |
| 594 | */ |
| 595 | |
| 596 | /** String to describe invite session states */ |
| 597 | extern const char *pjsua_inv_state_names[]; |
| 598 | |
| 599 | /** |
| 600 | * Parse arguments (pjsua_opt.c). |
| 601 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 602 | PJ_DECL(pj_status_t) pjsua_parse_args(int argc, char *argv[], |
| 603 | pjsua_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 604 | |
| 605 | /** |
| 606 | * Load settings from a file. |
| 607 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 608 | PJ_DECL(pj_status_t) pjsua_load_settings(const char *filename, |
| 609 | pjsua_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 610 | |
| 611 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 612 | * Dump settings. |
| 613 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 614 | PJ_DECL(int) pjsua_dump_settings(const pjsua_config *cfg, |
| 615 | char *buf, pj_size_t max); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 616 | |
| 617 | /** |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 618 | * Save settings to a file. |
| 619 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 620 | PJ_DECL(pj_status_t) pjsua_save_settings(const char *filename, |
| 621 | const pjsua_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 622 | |
| 623 | |
| 624 | /* |
| 625 | * Verify that valid SIP url is given. |
| 626 | * @return PJ_SUCCESS if valid. |
| 627 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 628 | PJ_DECL(pj_status_t) pjsua_verify_sip_url(const char *c_url); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 629 | |
| 630 | /* |
| 631 | * Dump application states. |
| 632 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 633 | PJ_DECL(void) pjsua_dump(pj_bool_t detail); |
| 634 | |
| 635 | /** |
| 636 | * Display error message for the specified error code. |
| 637 | */ |
| 638 | PJ_DECL(void) pjsua_perror(const char *sender, const char *title, |
| 639 | pj_status_t status); |
| 640 | |
| 641 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 642 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 643 | |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 644 | PJ_END_DECL |
| 645 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 646 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 647 | #endif /* __PJSUA_H__ */ |