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 |
| 51 | # define PJSUA_MAX_BUDDIES 32 |
| 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 | /** |
| 64 | * Aditional ports to be allocated in the conference ports for non-call |
| 65 | * streams. |
| 66 | */ |
Benny Prijono | de38058 | 2006-03-15 19:32:41 +0000 | [diff] [blame] | 67 | #define PJSUA_CONF_MORE_PORTS 3 |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 68 | |
| 69 | |
| 70 | /** |
| 71 | * Maximum accounts. |
| 72 | */ |
| 73 | #ifndef PJSUA_MAX_ACC |
| 74 | # define PJSUA_MAX_ACC 8 |
| 75 | #endif |
| 76 | |
| 77 | |
| 78 | /** |
| 79 | * Maximum credentials. |
| 80 | */ |
| 81 | #ifndef PJSUA_MAX_CRED |
| 82 | # define PJSUA_MAX_CRED PJSUA_MAX_ACC |
| 83 | #endif |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 84 | |
| 85 | |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 86 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 87 | * Structure to be attached to invite dialog. |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 88 | * Given a dialog "dlg", application can retrieve this structure |
| 89 | * by accessing dlg->mod_data[pjsua.mod.id]. |
| 90 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 91 | struct pjsua_call |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 92 | { |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 93 | unsigned index; /**< Index in pjsua array. */ |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 94 | pjsip_inv_session *inv; /**< The invite session. */ |
Benny Prijono | e21e784 | 2006-04-09 16:46:05 +0000 | [diff] [blame^] | 95 | pj_time_val start_time;/**< First INVITE sent/received. */ |
| 96 | pj_time_val res_time; /**< First response sent/received. */ |
| 97 | pj_time_val conn_time; /**< Connected/confirmed time. */ |
| 98 | pj_time_val dis_time; /**< Disconnect time. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 99 | int acc_index; /**< Account index being used. */ |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 100 | pjmedia_session *session; /**< The media session. */ |
| 101 | unsigned conf_slot; /**< Slot # in conference bridge. */ |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 102 | pjsip_evsub *xfer_sub; /**< Xfer server subscription, if this |
| 103 | call was triggered by xfer. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 104 | pjmedia_sock_info skinfo; /**< Preallocated media sockets. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 105 | void *app_data; /**< Application data. */ |
Benny Prijono | 105217f | 2006-03-06 16:25:59 +0000 | [diff] [blame] | 106 | pj_timer_entry refresh_tm;/**< Timer to send re-INVITE. */ |
| 107 | pj_timer_entry hangup_tm; /**< Timer to hangup call. */ |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 108 | }; |
| 109 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 110 | typedef struct pjsua_call pjsua_call; |
| 111 | |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 112 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 113 | /** |
| 114 | * Buddy data. |
| 115 | */ |
| 116 | struct pjsua_buddy |
| 117 | { |
| 118 | pj_str_t uri; /**< Buddy URI */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 119 | int acc_index; /**< Which account to use. */ |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 120 | pj_bool_t monitor; /**< Should we monitor? */ |
| 121 | pjsip_evsub *sub; /**< Buddy presence subscription */ |
| 122 | pjsip_pres_status status; /**< Buddy presence status. */ |
| 123 | }; |
| 124 | |
| 125 | typedef struct pjsua_buddy pjsua_buddy; |
| 126 | |
| 127 | |
| 128 | /** |
| 129 | * Server presence subscription list head. |
| 130 | */ |
| 131 | struct pjsua_srv_pres |
| 132 | { |
| 133 | PJ_DECL_LIST_MEMBER(struct pjsua_srv_pres); |
| 134 | pjsip_evsub *sub; |
| 135 | char *remote; |
| 136 | }; |
| 137 | |
| 138 | typedef struct pjsua_srv_pres pjsua_srv_pres; |
| 139 | |
| 140 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 141 | /** |
| 142 | * Account |
| 143 | */ |
| 144 | struct pjsua_acc |
| 145 | { |
| 146 | int index; /**< Index in accounts array. */ |
| 147 | pj_str_t local_uri; /**< Uri in From: header. */ |
| 148 | pj_str_t user_part; /**< User part of local URI. */ |
| 149 | pj_str_t host_part; /**< Host part of local URI. */ |
| 150 | pj_str_t contact_uri; /**< Uri in Contact: header. */ |
| 151 | |
| 152 | pj_str_t reg_uri; /**< Registrar URI. */ |
| 153 | pjsip_regc *regc; /**< Client registration session. */ |
| 154 | pj_int32_t reg_timeout; /**< Default timeout. */ |
| 155 | pj_timer_entry reg_timer; /**< Registration timer. */ |
| 156 | pj_status_t reg_last_err; /**< Last registration error. */ |
| 157 | int reg_last_code; /**< Last status last register. */ |
| 158 | |
| 159 | pj_str_t proxy; /**< Proxy URL. */ |
| 160 | pjsip_route_hdr route_set; /**< Route set. */ |
| 161 | |
| 162 | pj_bool_t online_status; /**< Our online status. */ |
| 163 | pjsua_srv_pres pres_srv_list; /**< Server subscription list. */ |
| 164 | |
| 165 | void *app_data; /**< Application data. */ |
| 166 | }; |
| 167 | |
| 168 | |
| 169 | typedef struct pjsua_acc pjsua_acc; |
| 170 | |
Benny Prijono | 632ce71 | 2006-02-09 14:01:40 +0000 | [diff] [blame] | 171 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 172 | /* PJSUA application variables. */ |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 173 | struct pjsua |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 174 | { |
| 175 | /* Control: */ |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 176 | pj_caching_pool cp; /**< Global pool factory. */ |
| 177 | pjsip_endpoint *endpt; /**< Global endpoint. */ |
| 178 | pj_pool_t *pool; /**< pjsua's private pool. */ |
| 179 | pjsip_module mod; /**< pjsua's PJSIP module. */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 180 | |
| 181 | |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 182 | /* Media: */ |
Benny Prijono | cbf3740 | 2006-03-01 19:29:10 +0000 | [diff] [blame] | 183 | int start_rtp_port;/**< Start of RTP port to try. */ |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 184 | pjmedia_endpt *med_endpt; /**< Media endpoint. */ |
Benny Prijono | 08e0d06 | 2006-03-04 14:52:44 +0000 | [diff] [blame] | 185 | unsigned clock_rate; /**< Internal clock rate. */ |
Benny Prijono | fa137ca | 2006-03-20 17:42:37 +0000 | [diff] [blame] | 186 | pj_bool_t has_wb; /**< Include wideband codecs */ |
| 187 | pj_bool_t has_uwb; /**< Include ultra-wideband codecs */ |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 188 | pjmedia_conf *mconf; /**< Media conference. */ |
| 189 | pj_bool_t null_audio; /**< Null audio flag. */ |
Benny Prijono | 8e3344c | 2006-03-08 12:37:22 +0000 | [diff] [blame] | 190 | pj_bool_t no_mic; /**< Disable microphone. */ |
Benny Prijono | 3987915 | 2006-02-23 02:09:10 +0000 | [diff] [blame] | 191 | char *wav_file; /**< WAV file name to play. */ |
| 192 | unsigned wav_slot; /**< WAV player slot in bridge */ |
Benny Prijono | de38058 | 2006-03-15 19:32:41 +0000 | [diff] [blame] | 193 | pjmedia_port *file_port; /**< WAV player port. */ |
| 194 | pjmedia_port *null_port; /**< NULL port. */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 195 | pj_bool_t auto_play; /**< Auto play file for calls? */ |
| 196 | pj_bool_t auto_loop; /**< Auto loop RTP stream? */ |
| 197 | pj_bool_t auto_conf; /**< Auto put to conference? */ |
Benny Prijono | 1c2bf46 | 2006-03-05 11:54:02 +0000 | [diff] [blame] | 198 | int complexity; /**< Codec complexity. */ |
| 199 | int quality; /**< Codec quality. */ |
| 200 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 201 | |
Benny Prijono | eb30bf5 | 2006-03-04 20:43:52 +0000 | [diff] [blame] | 202 | /* Codec arguments: */ |
| 203 | int codec_cnt; /**< Number of --add-codec args. */ |
| 204 | pj_str_t codec_arg[32]; /**< Array of --add-codec args. */ |
| 205 | pj_status_t (*codec_deinit[32])(void); /**< Array of funcs. */ |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 206 | |
Benny Prijono | 64f851e | 2006-02-23 13:49:28 +0000 | [diff] [blame] | 207 | /* User Agent behaviour: */ |
Benny Prijono | 64f851e | 2006-02-23 13:49:28 +0000 | [diff] [blame] | 208 | int auto_answer; /**< Automatically answer in calls. */ |
Benny Prijono | 105217f | 2006-03-06 16:25:59 +0000 | [diff] [blame] | 209 | int uas_refresh; /**< Time to re-INVITE. */ |
| 210 | int uas_duration; /**< Max call duration. */ |
Benny Prijono | 64f851e | 2006-02-23 13:49:28 +0000 | [diff] [blame] | 211 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 212 | /* Account: */ |
Benny Prijono | ccb03fa | 2006-03-06 13:35:47 +0000 | [diff] [blame] | 213 | pj_bool_t has_acc; /**< Any --id cmdline? */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 214 | int acc_cnt; /**< Number of client registrations */ |
| 215 | pjsua_acc acc[PJSUA_MAX_ACC]; /** Client regs array. */ |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 216 | |
| 217 | |
| 218 | /* Authentication credentials: */ |
| 219 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 220 | int cred_count; /**< Number of credentials. */ |
| 221 | pjsip_cred_info cred_info[10]; /**< Array of credentials. */ |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 222 | |
| 223 | |
Benny Prijono | f04ffdd | 2006-02-21 00:11:18 +0000 | [diff] [blame] | 224 | /* Threading (optional): */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 225 | int thread_cnt; /**< Thread count. */ |
| 226 | pj_thread_t *threads[8]; /**< Thread instances. */ |
| 227 | pj_bool_t quit_flag; /**< To signal thread to quit. */ |
| 228 | |
| 229 | /* Transport (UDP): */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 230 | pj_uint16_t sip_port; /**< SIP signaling port. */ |
| 231 | pj_sock_t sip_sock; /**< SIP UDP socket. */ |
| 232 | pj_sockaddr_in sip_sock_name; /**< Public/STUN UDP socket addr. */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 233 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 234 | pj_str_t outbound_proxy;/**< Outbound proxy. */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 235 | |
| 236 | |
| 237 | /* STUN: */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 238 | pj_str_t stun_srv1; |
| 239 | int stun_port1; |
| 240 | pj_str_t stun_srv2; |
| 241 | int stun_port2; |
| 242 | |
| 243 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 244 | /* Logging: */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 245 | int log_level; /**< Logging verbosity. */ |
| 246 | int app_log_level; /**< stdout log verbosity. */ |
| 247 | unsigned log_decor; /**< Log decoration. */ |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 248 | char *log_filename; /**< Log filename. */ |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 249 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 250 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 251 | /* PJSUA Calls: */ |
| 252 | int max_calls; /**< Max nb of calls. */ |
| 253 | int call_cnt; /**< Number of calls. */ |
| 254 | pjsua_call calls[PJSUA_MAX_CALLS]; /** Calls array. */ |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 255 | |
| 256 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 257 | /* SIMPLE and buddy status: */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 258 | int buddy_cnt; |
| 259 | pjsua_buddy buddies[PJSUA_MAX_BUDDIES]; |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 260 | }; |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 261 | |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 262 | |
| 263 | /** PJSUA instance. */ |
| 264 | extern struct pjsua pjsua; |
| 265 | |
| 266 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 267 | |
| 268 | /***************************************************************************** |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 269 | * PJSUA API (defined in pjsua_core.c). |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 270 | */ |
| 271 | |
| 272 | /** |
| 273 | * Initialize pjsua settings with default parameters. |
| 274 | */ |
| 275 | void pjsua_default(void); |
| 276 | |
| 277 | |
| 278 | /** |
| 279 | * Display error message for the specified error code. |
| 280 | */ |
Benny Prijono | bcaed6c | 2006-02-19 15:37:19 +0000 | [diff] [blame] | 281 | void pjsua_perror(const char *sender, const char *title, |
| 282 | pj_status_t status); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 283 | |
| 284 | |
| 285 | /** |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 286 | * Initialize pjsua application. Application can call this before parsing |
| 287 | * application settings. |
| 288 | * |
| 289 | * This will initialize all libraries, create endpoint instance, and register |
| 290 | * pjsip modules. Transport will NOT be created however. |
| 291 | * |
| 292 | * Application may register module after calling this function. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 293 | */ |
| 294 | pj_status_t pjsua_init(void); |
| 295 | |
| 296 | |
| 297 | /** |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 298 | * Start pjsua stack. Application calls this after pjsua settings has been |
| 299 | * configured. |
| 300 | * |
| 301 | * This will start the transport, worker threads (if any), and registration |
| 302 | * process, if registration is configured. |
| 303 | */ |
| 304 | pj_status_t pjsua_start(void); |
| 305 | |
| 306 | |
| 307 | /** |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 308 | * Destroy pjsua. |
| 309 | */ |
| 310 | pj_status_t pjsua_destroy(void); |
| 311 | |
| 312 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 313 | /** |
| 314 | * Find account for incoming request. |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 315 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 316 | int pjsua_find_account_for_incoming(pjsip_rx_data *rdata); |
| 317 | |
| 318 | |
| 319 | /** |
| 320 | * Find account for outgoing request. |
| 321 | */ |
| 322 | int pjsua_find_account_for_outgoing(const pj_str_t *url); |
| 323 | |
| 324 | |
| 325 | /***************************************************************************** |
| 326 | * PJSUA Call API (defined in pjsua_call.c). |
| 327 | */ |
| 328 | |
| 329 | /** |
| 330 | * Init pjsua call module. |
| 331 | */ |
| 332 | pj_status_t pjsua_call_init(void); |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 333 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 334 | /** |
| 335 | * Make outgoing call. |
| 336 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 337 | pj_status_t pjsua_make_call(int acc_index, |
| 338 | const char *cstr_dest_uri, |
| 339 | int *p_call_index); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 340 | |
| 341 | |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 342 | /** |
| 343 | * Handle incoming invite request. |
| 344 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 345 | pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata); |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 346 | |
| 347 | |
| 348 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 349 | * Answer call. |
| 350 | */ |
| 351 | void pjsua_call_answer(int call_index, int code); |
| 352 | |
| 353 | /** |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 354 | * Hangup call. |
| 355 | */ |
Benny Prijono | 1c2bf46 | 2006-03-05 11:54:02 +0000 | [diff] [blame] | 356 | void pjsua_call_hangup(int call_index); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 357 | |
| 358 | |
| 359 | /** |
| 360 | * Put call on-hold. |
| 361 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 362 | void pjsua_call_set_hold(int call_index); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 363 | |
| 364 | |
| 365 | /** |
| 366 | * Send re-INVITE (to release hold). |
| 367 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 368 | void pjsua_call_reinvite(int call_index); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 369 | |
| 370 | |
| 371 | /** |
| 372 | * Transfer call. |
| 373 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 374 | void pjsua_call_xfer(int call_index, const char *dest); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 375 | |
| 376 | |
| 377 | /** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 378 | * Send instant messaging inside INVITE session. |
| 379 | */ |
| 380 | void pjsua_call_send_im(int call_index, const char *text); |
| 381 | |
| 382 | |
| 383 | /** |
| 384 | * Send IM typing indication inside INVITE session. |
| 385 | */ |
| 386 | void pjsua_call_typing(int call_index, pj_bool_t is_typing); |
| 387 | |
| 388 | /** |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 389 | * Terminate all calls. |
| 390 | */ |
Benny Prijono | 1a17414 | 2006-03-01 20:46:13 +0000 | [diff] [blame] | 391 | void pjsua_call_hangup_all(void); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 392 | |
| 393 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 394 | /***************************************************************************** |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 395 | * PJSUA Client Registration API (defined in pjsua_reg.c). |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 396 | */ |
| 397 | |
| 398 | /** |
| 399 | * Initialize client registration session. |
| 400 | * |
| 401 | * @param app_callback Optional callback |
| 402 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 403 | pj_status_t pjsua_regc_init(int acc_index); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 404 | |
| 405 | /** |
| 406 | * Update registration or perform unregistration. If renew argument is zero, |
| 407 | * this will start unregistration process. |
| 408 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 409 | void pjsua_regc_update(int acc_index, pj_bool_t renew); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 410 | |
| 411 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 412 | |
| 413 | |
| 414 | /***************************************************************************** |
| 415 | * PJSUA Presence (pjsua_pres.c) |
| 416 | */ |
| 417 | |
| 418 | /** |
| 419 | * Init presence. |
| 420 | */ |
| 421 | pj_status_t pjsua_pres_init(); |
| 422 | |
| 423 | /** |
| 424 | * Refresh both presence client and server subscriptions. |
| 425 | */ |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 426 | void pjsua_pres_refresh(int acc_index); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 427 | |
| 428 | /** |
| 429 | * Terminate all subscriptions |
| 430 | */ |
| 431 | void pjsua_pres_shutdown(void); |
| 432 | |
| 433 | /** |
| 434 | * Dump presence subscriptions. |
| 435 | */ |
Benny Prijono | 1a17414 | 2006-03-01 20:46:13 +0000 | [diff] [blame] | 436 | void pjsua_pres_dump(pj_bool_t detail); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 437 | |
| 438 | |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 439 | /***************************************************************************** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 440 | * PJSUA Instant Messaging (pjsua_im.c) |
| 441 | */ |
| 442 | |
| 443 | /** |
| 444 | * The MESSAGE method (defined in pjsua_im.c) |
| 445 | */ |
| 446 | extern const pjsip_method pjsip_message_method; |
| 447 | |
| 448 | |
| 449 | /** |
| 450 | * Init IM module handler to handle incoming MESSAGE outside dialog. |
| 451 | */ |
| 452 | pj_status_t pjsua_im_init(); |
| 453 | |
| 454 | |
| 455 | /** |
| 456 | * Create Accept header for MESSAGE. |
| 457 | */ |
| 458 | pjsip_accept_hdr* pjsua_im_create_accept(pj_pool_t *pool); |
| 459 | |
| 460 | /** |
| 461 | * Send IM outside dialog. |
| 462 | */ |
| 463 | pj_status_t pjsua_im_send(int acc_index, const char *dst_uri, |
| 464 | const char *text); |
| 465 | |
| 466 | |
| 467 | /** |
| 468 | * Send typing indication outside dialog. |
| 469 | */ |
| 470 | pj_status_t pjsua_im_typing(int acc_index, const char *dst_uri, |
| 471 | pj_bool_t is_typing); |
| 472 | |
| 473 | |
| 474 | /** |
| 475 | * Private: check if we can accept the message. |
| 476 | * If not, then p_accept header will be filled with a valid |
| 477 | * Accept header. |
| 478 | */ |
| 479 | pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata, |
Benny Prijono | f9c668f | 2006-03-06 15:14:59 +0000 | [diff] [blame] | 480 | pjsip_accept_hdr **p_accept_hdr); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 481 | |
| 482 | /** |
| 483 | * Private: process pager message. |
| 484 | * This may trigger pjsua_ui_on_pager() or pjsua_ui_on_typing(). |
| 485 | */ |
| 486 | void pjsua_im_process_pager(int call_id, const pj_str_t *from, |
| 487 | const pj_str_t *to, pjsip_rx_data *rdata); |
| 488 | |
| 489 | |
| 490 | /***************************************************************************** |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 491 | * User Interface API. |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 492 | * |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 493 | * The UI API specifies functions that will be called by pjsua upon |
| 494 | * occurence of various events. |
| 495 | */ |
| 496 | |
| 497 | /** |
| 498 | * Notify UI when invite state has changed. |
| 499 | */ |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 500 | void pjsua_ui_on_call_state(int call_index, pjsip_event *e); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 501 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 502 | /** |
| 503 | * Notify UI when registration status has changed. |
| 504 | */ |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 505 | void pjsua_ui_on_reg_state(int acc_index); |
| 506 | |
| 507 | /** |
| 508 | * Notify UI on incoming pager (i.e. MESSAGE request). |
| 509 | * Argument call_index will be -1 if MESSAGE request is not related to an |
| 510 | * existing call. |
| 511 | */ |
| 512 | void pjsua_ui_on_pager(int call_index, const pj_str_t *from, |
| 513 | const pj_str_t *to, const pj_str_t *txt); |
| 514 | |
| 515 | |
| 516 | /** |
| 517 | * Notify UI about typing indication. |
| 518 | */ |
| 519 | void pjsua_ui_on_typing(int call_index, const pj_str_t *from, |
| 520 | const pj_str_t *to, pj_bool_t is_typing); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 521 | |
| 522 | |
| 523 | /***************************************************************************** |
| 524 | * Utilities. |
| 525 | * |
| 526 | */ |
| 527 | |
| 528 | /** String to describe invite session states */ |
| 529 | extern const char *pjsua_inv_state_names[]; |
| 530 | |
| 531 | /** |
| 532 | * Parse arguments (pjsua_opt.c). |
| 533 | */ |
| 534 | pj_status_t pjsua_parse_args(int argc, char *argv[]); |
| 535 | |
| 536 | /** |
| 537 | * Load settings from a file. |
| 538 | */ |
| 539 | pj_status_t pjsua_load_settings(const char *filename); |
| 540 | |
| 541 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 542 | * Dump settings. |
| 543 | */ |
| 544 | int pjsua_dump_settings(char *buf, pj_size_t max); |
| 545 | |
| 546 | /** |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 547 | * Save settings to a file. |
| 548 | */ |
| 549 | pj_status_t pjsua_save_settings(const char *filename); |
| 550 | |
| 551 | |
| 552 | /* |
| 553 | * Verify that valid SIP url is given. |
| 554 | * @return PJ_SUCCESS if valid. |
| 555 | */ |
| 556 | pj_status_t pjsua_verify_sip_url(const char *c_url); |
| 557 | |
| 558 | /* |
| 559 | * Dump application states. |
| 560 | */ |
Benny Prijono | 1a17414 | 2006-03-01 20:46:13 +0000 | [diff] [blame] | 561 | void pjsua_dump(pj_bool_t detail); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 562 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 563 | |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 564 | PJ_END_DECL |
| 565 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 566 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 567 | #endif /* __PJSUA_H__ */ |