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