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 | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 71 | /** |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 72 | * Account configuration. |
| 73 | */ |
| 74 | struct pjsua_acc_config |
| 75 | { |
| 76 | /** SIP URL for account ID (mandatory) */ |
| 77 | pj_str_t id; |
| 78 | |
| 79 | /** Registrar URI (mandatory) */ |
| 80 | pj_str_t reg_uri; |
| 81 | |
| 82 | /** Optional contact URI */ |
| 83 | pj_str_t contact; |
| 84 | |
| 85 | /** Service proxy (default: none) */ |
| 86 | pj_str_t proxy; |
| 87 | |
| 88 | /** Default timeout (mandatory) */ |
| 89 | pj_int32_t reg_timeout; |
| 90 | |
| 91 | /** Number of credentials. */ |
| 92 | unsigned cred_count; |
| 93 | |
| 94 | /** Array of credentials. */ |
| 95 | pjsip_cred_info cred_info[4]; |
| 96 | |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | /** |
| 101 | * @see pjsua_acc_config |
| 102 | */ |
| 103 | typedef struct pjsua_acc_config pjsua_acc_config; |
| 104 | |
| 105 | |
| 106 | /** |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 107 | * PJSUA settings. |
| 108 | */ |
| 109 | struct pjsua_config |
| 110 | { |
| 111 | /** SIP UDP signaling port. Set to zero to disable UDP signaling, |
| 112 | * which in this case application must manually add a transport |
| 113 | * to SIP endpoint. |
| 114 | * (default: 5060) |
| 115 | */ |
| 116 | unsigned udp_port; |
| 117 | |
| 118 | /** Optional hostname or IP address to publish as the host part of |
| 119 | * Contact header. This must be specified if UDP transport is |
| 120 | * disabled. |
| 121 | * (default: NULL) |
| 122 | */ |
| 123 | pj_str_t sip_host; |
| 124 | |
| 125 | /** Optional port number to publish in the port part of Contact header. |
| 126 | * This must be specified if UDP transport is disabled. |
| 127 | * (default: 0) |
| 128 | */ |
| 129 | unsigned sip_port; |
| 130 | |
| 131 | /** Start of RTP port. Set to zero to prevent pjsua from creating |
| 132 | * media transports, which in this case application must manually |
| 133 | * create media transport for each calls. |
| 134 | * (default: 4000) |
| 135 | */ |
| 136 | unsigned start_rtp_port; |
| 137 | |
| 138 | /** Maximum calls to support (default: 4) */ |
| 139 | unsigned max_calls; |
| 140 | |
| 141 | /** Maximum slots in the conference bridge (default: 0/calculated |
| 142 | * as max_calls*2 |
| 143 | */ |
| 144 | unsigned conf_ports; |
| 145 | |
| 146 | /** Number of worker threads (default: 1) */ |
| 147 | unsigned thread_cnt; |
| 148 | |
| 149 | /** First STUN server IP address. When STUN is configured, then the |
| 150 | * two STUN server settings must be fully set. |
| 151 | * (default: none) |
| 152 | */ |
| 153 | pj_str_t stun_srv1; |
| 154 | |
| 155 | /** First STUN port number */ |
| 156 | unsigned stun_port1; |
| 157 | |
| 158 | /** Second STUN server IP address */ |
| 159 | pj_str_t stun_srv2; |
| 160 | |
| 161 | /** Second STUN server port number */ |
| 162 | unsigned stun_port2; |
| 163 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 164 | /** Sound player device ID (default: 0) */ |
| 165 | unsigned snd_player_id; |
| 166 | |
| 167 | /** Sound capture device ID (default: 0) */ |
| 168 | unsigned snd_capture_id; |
| 169 | |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 170 | /** Internal clock rate (to be applied to sound devices and conference |
| 171 | * bridge, default is 0/follows the codec, or 44100 for MacOS). |
| 172 | */ |
| 173 | unsigned clock_rate; |
| 174 | |
| 175 | /** Do not use sound device (default: 0). */ |
| 176 | pj_bool_t null_audio; |
| 177 | |
| 178 | /** WAV file to load for auto_play (default: NULL) */ |
| 179 | pj_str_t wav_file; |
| 180 | |
| 181 | /** Auto play WAV file for calls? (default: no) */ |
| 182 | pj_bool_t auto_play; |
| 183 | |
| 184 | /** Auto loopback calls? (default: no) */ |
| 185 | pj_bool_t auto_loop; |
| 186 | |
| 187 | /** Automatically put calls to conference? (default: no) */ |
| 188 | pj_bool_t auto_conf; |
| 189 | |
| 190 | /** Speex codec complexity? (default: 10) */ |
| 191 | unsigned complexity; |
| 192 | |
| 193 | /** Speex codec quality? (default: 10) */ |
| 194 | unsigned quality; |
| 195 | |
| 196 | /** Codec ptime? (default: 0 (follows the codec)) */ |
| 197 | unsigned ptime; |
| 198 | |
| 199 | /** Number of additional codecs/"--add-codec" with pjsua (default: 0) */ |
| 200 | unsigned codec_cnt; |
| 201 | |
| 202 | /** Additional codecs/"--add-codec" options */ |
| 203 | pj_str_t codec_arg[32]; |
| 204 | |
| 205 | /** SIP status code to be automatically sent to incoming calls |
| 206 | * (default: 100). |
| 207 | */ |
| 208 | unsigned auto_answer; |
| 209 | |
| 210 | /** Periodic time to refresh call with re-INVITE (default: 0) |
| 211 | */ |
| 212 | unsigned uas_refresh; |
| 213 | |
| 214 | /** Maximum incoming call duration (default: 3600) */ |
| 215 | unsigned uas_duration; |
| 216 | |
| 217 | /** Outbound proxy (default: none) */ |
| 218 | pj_str_t outbound_proxy; |
| 219 | |
| 220 | /** URI to call. */ |
| 221 | pj_str_t uri_to_call; |
| 222 | |
| 223 | /** Number of SIP accounts */ |
| 224 | unsigned acc_cnt; |
| 225 | |
| 226 | /** SIP accounts configuration */ |
| 227 | pjsua_acc_config acc_config[32]; |
| 228 | |
| 229 | /** Logging verbosity (default: 5). */ |
| 230 | unsigned log_level; |
| 231 | |
| 232 | /** Logging to be displayed to stdout (default: 4) */ |
| 233 | unsigned app_log_level; |
| 234 | |
| 235 | /** Log decoration */ |
| 236 | unsigned log_decor; |
| 237 | |
| 238 | /** Optional log filename (default: NULL) */ |
| 239 | pj_str_t log_filename; |
| 240 | |
| 241 | /** Number of buddies in address book (default: 0) */ |
| 242 | unsigned buddy_cnt; |
| 243 | |
| 244 | /** Buddies URI */ |
| 245 | pj_str_t buddy_uri[256]; |
| 246 | }; |
| 247 | |
| 248 | |
| 249 | /** |
| 250 | * @see pjsua_config |
| 251 | */ |
| 252 | typedef struct pjsua_config pjsua_config; |
| 253 | |
| 254 | |
| 255 | |
| 256 | /** |
| 257 | * Application callbacks. |
| 258 | */ |
| 259 | struct pjsua_callback |
| 260 | { |
| 261 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 262 | * Notify application when invite state has changed. |
| 263 | * Application may then query the call info to get the |
| 264 | * detail call states. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 265 | */ |
| 266 | void (*on_call_state)(int call_index, pjsip_event *e); |
| 267 | |
| 268 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 269 | * Notify application on call being transfered. |
| 270 | * Application can decide to accept/reject transfer request |
| 271 | * by setting the code (default is 200). When this callback |
| 272 | * is not defined, the default behavior is to accept the |
| 273 | * transfer. |
| 274 | */ |
| 275 | void (*on_call_transfered)(int call_index, |
| 276 | const pj_str_t *dst, |
| 277 | pjsip_status_code *code); |
| 278 | |
| 279 | /** |
| 280 | * Notify application when registration status has changed. |
| 281 | * Application may then query the account info to get the |
| 282 | * registration details. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 283 | */ |
| 284 | void (*on_reg_state)(int acc_index); |
| 285 | |
| 286 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 287 | * Notify application when the buddy state has changed. |
| 288 | * Application may then query the buddy into to get the details. |
| 289 | */ |
| 290 | void (*on_buddy_state)(int buddy_index); |
| 291 | |
| 292 | /** |
| 293 | * Notify application on incoming pager (i.e. MESSAGE request). |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 294 | * Argument call_index will be -1 if MESSAGE request is not related to an |
| 295 | * existing call. |
| 296 | */ |
| 297 | void (*on_pager)(int call_index, const pj_str_t *from, |
| 298 | const pj_str_t *to, const pj_str_t *txt); |
| 299 | |
| 300 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 301 | * Notify application about typing indication. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 302 | */ |
| 303 | void (*on_typing)(int call_index, const pj_str_t *from, |
| 304 | const pj_str_t *to, pj_bool_t is_typing); |
| 305 | |
| 306 | }; |
| 307 | |
| 308 | /** |
| 309 | * @see pjsua_callback |
| 310 | */ |
| 311 | typedef struct pjsua_callback pjsua_callback; |
| 312 | |
| 313 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 314 | /** |
| 315 | * Call info. |
| 316 | */ |
| 317 | struct pjsua_call_info |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 318 | { |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 319 | unsigned index; |
| 320 | pj_bool_t active; |
| 321 | pjsip_role_e role; |
| 322 | pj_str_t local_info; |
| 323 | pj_str_t remote_info; |
| 324 | pjsip_inv_state state; |
| 325 | pj_str_t state_text; |
| 326 | pj_time_val connect_duration; |
| 327 | pj_time_val total_duration; |
| 328 | pjsip_status_code cause; |
| 329 | pj_str_t cause_text; |
| 330 | pj_bool_t has_media; |
| 331 | unsigned conf_slot; |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 332 | }; |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 333 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 334 | typedef struct pjsua_call_info pjsua_call_info; |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 335 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 336 | |
| 337 | enum pjsua_buddy_status |
| 338 | { |
| 339 | PJSUA_BUDDY_STATUS_UNKNOWN, |
| 340 | PJSUA_BUDDY_STATUS_ONLINE, |
| 341 | PJSUA_BUDDY_STATUS_OFFLINE, |
| 342 | }; |
| 343 | |
| 344 | typedef enum pjsua_buddy_status pjsua_buddy_status; |
| 345 | |
| 346 | |
| 347 | /** |
| 348 | * Buddy info. |
| 349 | */ |
| 350 | struct pjsua_buddy_info |
| 351 | { |
| 352 | unsigned index; |
| 353 | pj_bool_t is_valid; |
| 354 | pj_str_t name; |
| 355 | pj_str_t display_name; |
| 356 | pj_str_t host; |
| 357 | unsigned port; |
| 358 | pj_str_t uri; |
| 359 | pjsua_buddy_status status; |
| 360 | pj_str_t status_text; |
| 361 | pj_bool_t monitor; |
| 362 | }; |
| 363 | |
| 364 | typedef struct pjsua_buddy_info pjsua_buddy_info; |
| 365 | |
| 366 | |
| 367 | /** |
| 368 | * Account info. |
| 369 | */ |
| 370 | struct pjsua_acc_info |
| 371 | { |
| 372 | unsigned index; |
| 373 | pj_str_t acc_id; |
| 374 | pj_bool_t has_registration; |
| 375 | int expires; |
| 376 | pjsip_status_code status; |
| 377 | pj_str_t status_text; |
| 378 | pj_bool_t online_status; |
| 379 | char buf[PJ_ERR_MSG_SIZE]; |
| 380 | }; |
| 381 | |
| 382 | typedef struct pjsua_acc_info pjsua_acc_info; |
| 383 | |
| 384 | |
| 385 | typedef int pjsua_player_id; |
| 386 | typedef int pjsua_recorder_id; |
Benny Prijono | 9519658 | 2006-02-09 00:13:40 +0000 | [diff] [blame] | 387 | |
| 388 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 389 | |
| 390 | /***************************************************************************** |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 391 | * PJSUA API (defined in pjsua_core.c). |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 392 | */ |
| 393 | |
| 394 | /** |
| 395 | * Initialize pjsua settings with default parameters. |
| 396 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 397 | PJ_DECL(void) pjsua_default_config(pjsua_config *cfg); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 398 | |
| 399 | |
| 400 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 401 | * Validate configuration. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 402 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 403 | PJ_DECL(pj_status_t) pjsua_test_config(const pjsua_config *cfg, |
| 404 | char *errmsg, |
| 405 | int len); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 406 | |
| 407 | |
| 408 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 409 | * Instantiate pjsua application. This initializes pjlib/pjlib-util, and |
| 410 | * creates memory pool factory to be used by application. |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 411 | */ |
| 412 | PJ_DECL(pj_status_t) pjsua_create(void); |
| 413 | |
| 414 | |
| 415 | /** |
| 416 | * Initialize pjsua application with the specified settings. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 417 | * |
| 418 | * This will initialize all libraries, create endpoint instance, and register |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 419 | * pjsip modules. |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 420 | * |
| 421 | * Application may register module after calling this function. |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 422 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 423 | PJ_DECL(pj_status_t) pjsua_init(const pjsua_config *cfg, |
| 424 | const pjsua_callback *cb); |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 425 | |
| 426 | |
| 427 | /** |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 428 | * Start pjsua stack. Application calls this after pjsua settings has been |
| 429 | * configured. |
| 430 | * |
| 431 | * This will start the transport, worker threads (if any), and registration |
| 432 | * process, if registration is configured. |
| 433 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 434 | PJ_DECL(pj_status_t) pjsua_start(void); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 435 | |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 436 | /** |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 437 | * Destroy pjsua. |
| 438 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 439 | PJ_DECL(pj_status_t) pjsua_destroy(void); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 440 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 441 | /** |
| 442 | * Get SIP endpoint instance. |
| 443 | * Only valid after pjsua_init(). |
| 444 | */ |
| 445 | PJ_DECL(pjsip_endpoint*) pjsua_get_pjsip_endpt(void); |
| 446 | |
| 447 | /** |
| 448 | * Get media endpoint instance. |
| 449 | * Only valid after pjsua_init(). |
| 450 | */ |
| 451 | PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedia_endpt(void); |
| 452 | |
| 453 | /** |
| 454 | * Replace media transport. |
| 455 | */ |
| 456 | PJ_DECL(pj_status_t) pjsua_set_call_media_transport(unsigned call_index, |
| 457 | const pjmedia_sock_info *i, |
| 458 | pjmedia_transport *tp); |
| 459 | |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 460 | |
| 461 | /***************************************************************************** |
| 462 | * PJSUA Call API (defined in pjsua_call.c). |
| 463 | */ |
| 464 | |
| 465 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 466 | * Get maximum number of calls configured in pjsua. |
| 467 | */ |
| 468 | PJ_DECL(unsigned) pjsua_get_max_calls(void); |
| 469 | |
| 470 | /** |
| 471 | * Get current number of active calls. |
| 472 | */ |
| 473 | PJ_DECL(unsigned) pjsua_get_call_count(void); |
| 474 | |
| 475 | /** |
| 476 | * Check if the specified call has active INVITE session and the INVITE |
| 477 | * session has not been disconnected. |
| 478 | */ |
| 479 | PJ_DECL(pj_bool_t) pjsua_call_is_active(unsigned call_index); |
| 480 | |
| 481 | |
| 482 | /** |
| 483 | * Check if call has a media session. |
| 484 | */ |
| 485 | PJ_DECL(pj_bool_t) pjsua_call_has_media(unsigned call_index); |
| 486 | |
| 487 | |
| 488 | /** |
| 489 | * Get call info. |
| 490 | */ |
| 491 | PJ_DECL(pj_status_t) pjsua_get_call_info(unsigned call_index, |
| 492 | pjsua_call_info *info); |
| 493 | |
| 494 | |
| 495 | /** |
| 496 | * Duplicate call info. |
| 497 | */ |
| 498 | PJ_DECL(void) pjsua_dup_call_info(pj_pool_t *pool, |
| 499 | pjsua_call_info *dst_info, |
| 500 | const pjsua_call_info *src_info); |
| 501 | |
| 502 | |
| 503 | /** |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 504 | * Make outgoing call. |
| 505 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 506 | PJ_DECL(pj_status_t) pjsua_make_call(unsigned acc_index, |
| 507 | const pj_str_t *dst_uri, |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 508 | int *p_call_index); |
Benny Prijono | 84126ab | 2006-02-09 09:30:09 +0000 | [diff] [blame] | 509 | |
| 510 | |
| 511 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 512 | * Answer call. |
| 513 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 514 | PJ_DECL(void) pjsua_call_answer(int call_index, int code); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 515 | |
| 516 | /** |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 517 | * Hangup call. |
| 518 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 519 | PJ_DECL(void) pjsua_call_hangup(int call_index); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 520 | |
| 521 | |
| 522 | /** |
| 523 | * Put call on-hold. |
| 524 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 525 | PJ_DECL(void) pjsua_call_set_hold(int call_index); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 526 | |
| 527 | |
| 528 | /** |
| 529 | * Send re-INVITE (to release hold). |
| 530 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 531 | PJ_DECL(void) pjsua_call_reinvite(int call_index); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 532 | |
| 533 | |
| 534 | /** |
| 535 | * Transfer call. |
| 536 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 537 | PJ_DECL(void) pjsua_call_xfer(unsigned call_index, const pj_str_t *dest); |
| 538 | |
| 539 | /** |
| 540 | * Dial DTMF. |
| 541 | */ |
| 542 | PJ_DECL(pj_status_t) pjsua_call_dial_dtmf(unsigned call_index, |
| 543 | const pj_str_t *digits); |
Benny Prijono | 26ff906 | 2006-02-21 23:47:00 +0000 | [diff] [blame] | 544 | |
| 545 | |
| 546 | /** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 547 | * Send instant messaging inside INVITE session. |
| 548 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 549 | PJ_DECL(void) pjsua_call_send_im(int call_index, const pj_str_t *text); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 550 | |
| 551 | |
| 552 | /** |
| 553 | * Send IM typing indication inside INVITE session. |
| 554 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 555 | 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] | 556 | |
| 557 | /** |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 558 | * Terminate all calls. |
| 559 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 560 | PJ_DECL(void) pjsua_call_hangup_all(void); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 561 | |
| 562 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 563 | /***************************************************************************** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 564 | * PJSUA Account and Client Registration API (defined in pjsua_reg.c). |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 565 | */ |
| 566 | |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 567 | |
| 568 | /** |
| 569 | * Get number of accounts. |
| 570 | */ |
| 571 | PJ_DECL(unsigned) pjsua_get_acc_count(void); |
| 572 | |
| 573 | /** |
| 574 | * Get account info. |
| 575 | */ |
| 576 | PJ_DECL(pj_status_t) pjsua_acc_get_info(unsigned acc_index, |
| 577 | pjsua_acc_info *info); |
| 578 | |
| 579 | /** |
| 580 | * Add a new account. |
| 581 | * This function should be called after pjsua_init(). |
| 582 | * Application should call pjsua_acc_set_registration() to start |
| 583 | * registration for this account. |
| 584 | */ |
| 585 | PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *cfg, |
| 586 | int *acc_index); |
| 587 | |
| 588 | |
| 589 | /** |
| 590 | * Set account's presence status. |
| 591 | * Must call pjsua_pres_refresh() after this. |
| 592 | */ |
| 593 | PJ_DECL(pj_status_t) pjsua_acc_set_online_status(unsigned acc_index, |
| 594 | pj_bool_t is_online); |
| 595 | |
| 596 | |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 597 | /** |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 598 | * Update registration or perform unregistration. If renew argument is zero, |
| 599 | * this will start unregistration process. |
| 600 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 601 | PJ_DECL(void) pjsua_acc_set_registration(unsigned acc_index, pj_bool_t renew); |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 602 | |
| 603 | |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 604 | |
| 605 | |
| 606 | /***************************************************************************** |
| 607 | * PJSUA Presence (pjsua_pres.c) |
| 608 | */ |
| 609 | |
| 610 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 611 | * Get buddy count. |
| 612 | */ |
| 613 | PJ_DECL(unsigned) pjsua_get_buddy_count(void); |
| 614 | |
| 615 | |
| 616 | /** |
| 617 | * Get buddy info. |
| 618 | */ |
| 619 | PJ_DECL(pj_status_t) pjsua_buddy_get_info(unsigned buddy_index, |
| 620 | pjsua_buddy_info *info); |
| 621 | |
| 622 | /** |
| 623 | * Add new buddy. |
| 624 | */ |
| 625 | PJ_DECL(pj_status_t) pjsua_buddy_add(const pj_str_t *uri, |
| 626 | int *buddy_index); |
| 627 | |
| 628 | |
| 629 | /** |
| 630 | * Enable/disable buddy's presence monitoring. |
| 631 | * Must call pjsua_pres_refresh() after this. |
| 632 | */ |
| 633 | PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(unsigned buddy_index, |
| 634 | pj_bool_t monitor); |
| 635 | |
| 636 | |
| 637 | /** |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 638 | * Refresh both presence client and server subscriptions. |
| 639 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 640 | PJ_DECL(void) pjsua_pres_refresh(int acc_index); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 641 | |
| 642 | /** |
| 643 | * Dump presence subscriptions. |
| 644 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 645 | PJ_DECL(void) pjsua_pres_dump(pj_bool_t detail); |
Benny Prijono | 834aee3 | 2006-02-19 01:38:06 +0000 | [diff] [blame] | 646 | |
| 647 | |
Benny Prijono | ccf9562 | 2006-02-07 18:48:01 +0000 | [diff] [blame] | 648 | /***************************************************************************** |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 649 | * PJSUA Instant Messaging (pjsua_im.c) |
| 650 | */ |
| 651 | |
| 652 | /** |
| 653 | * The MESSAGE method (defined in pjsua_im.c) |
| 654 | */ |
| 655 | extern const pjsip_method pjsip_message_method; |
| 656 | |
| 657 | |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 658 | |
| 659 | /** |
| 660 | * Send IM outside dialog. |
| 661 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 662 | PJ_DECL(pj_status_t) pjsua_im_send(int acc_index, const pj_str_t *dst_uri, |
| 663 | const pj_str_t *text); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 664 | |
| 665 | |
| 666 | /** |
| 667 | * Send typing indication outside dialog. |
| 668 | */ |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 669 | PJ_DECL(pj_status_t) pjsua_im_typing(int acc_index, const pj_str_t *dst_uri, |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 670 | pj_bool_t is_typing); |
Benny Prijono | b080837 | 2006-03-02 21:18:58 +0000 | [diff] [blame] | 671 | |
| 672 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 673 | |
| 674 | /***************************************************************************** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 675 | * Media. |
| 676 | */ |
| 677 | |
| 678 | /** |
| 679 | * Get maxinum number of conference ports. |
| 680 | */ |
| 681 | PJ_DECL(unsigned) pjsua_conf_max_ports(void); |
| 682 | |
| 683 | |
| 684 | /** |
| 685 | * Enum all conference ports. |
| 686 | */ |
| 687 | PJ_DECL(pj_status_t) pjsua_conf_enum_ports(unsigned *count, |
| 688 | pjmedia_conf_port_info info[]); |
| 689 | |
| 690 | |
| 691 | /** |
| 692 | * Connect conference port. |
| 693 | */ |
| 694 | PJ_DECL(pj_status_t) pjsua_conf_connect(unsigned src_port, |
| 695 | unsigned dst_port); |
| 696 | |
| 697 | |
| 698 | /** |
| 699 | * Connect conference port connection. |
| 700 | */ |
| 701 | PJ_DECL(pj_status_t) pjsua_conf_disconnect(unsigned src_port, |
| 702 | unsigned dst_port); |
| 703 | |
| 704 | |
| 705 | /** |
| 706 | * Create a file player. |
| 707 | */ |
| 708 | PJ_DECL(pj_status_t) pjsua_player_create(const pj_str_t *filename, |
| 709 | pjsua_player_id *id); |
| 710 | |
| 711 | |
| 712 | /** |
| 713 | * Get conference port associated with player. |
| 714 | */ |
| 715 | PJ_DECL(unsigned) pjsua_player_get_conf_port(pjsua_player_id id); |
| 716 | |
| 717 | |
| 718 | /** |
| 719 | * Set playback position. |
| 720 | */ |
| 721 | PJ_DECL(pj_status_t) pjsua_player_set_pos(pjsua_player_id id, |
| 722 | pj_uint32_t samples); |
| 723 | |
| 724 | |
| 725 | /** |
| 726 | * Destroy player. |
| 727 | */ |
| 728 | PJ_DECL(pj_status_t) pjsua_player_destroy(pjsua_player_id id); |
| 729 | |
| 730 | |
| 731 | |
| 732 | /** |
| 733 | * Create a file recorder. |
| 734 | */ |
| 735 | PJ_DECL(pj_status_t) pjsua_recorder_create(const pj_str_t *filename, |
| 736 | pjsua_recorder_id *id); |
| 737 | |
| 738 | |
| 739 | /** |
| 740 | * Get conference port associated with recorder. |
| 741 | */ |
| 742 | PJ_DECL(unsigned) pjsua_recorder_get_conf_port(pjsua_recorder_id id); |
| 743 | |
| 744 | |
| 745 | /** |
| 746 | * Destroy recorder (will complete recording). |
| 747 | */ |
| 748 | PJ_DECL(pj_status_t) pjsua_recorder_destroy(pjsua_recorder_id id); |
| 749 | |
| 750 | |
| 751 | /** |
| 752 | * Enum sound devices. |
| 753 | */ |
| 754 | PJ_DECL(pj_status_t) pjsua_enum_snd_devices(unsigned *count, |
| 755 | pjmedia_snd_dev_info info[]); |
| 756 | |
| 757 | |
| 758 | /** |
| 759 | * Select or change sound device. |
| 760 | * This will only change the device ID in configuration (not changing |
| 761 | * the current device). |
| 762 | */ |
| 763 | PJ_DECL(pj_status_t) pjsua_set_snd_dev(int snd_capture_id, |
| 764 | int snd_player_id); |
| 765 | |
| 766 | |
| 767 | /***************************************************************************** |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 768 | * Utilities. |
| 769 | * |
| 770 | */ |
| 771 | |
| 772 | /** String to describe invite session states */ |
| 773 | extern const char *pjsua_inv_state_names[]; |
| 774 | |
| 775 | /** |
| 776 | * Parse arguments (pjsua_opt.c). |
| 777 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 778 | PJ_DECL(pj_status_t) pjsua_parse_args(int argc, char *argv[], |
| 779 | pjsua_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 780 | |
| 781 | /** |
| 782 | * Load settings from a file. |
| 783 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 784 | PJ_DECL(pj_status_t) pjsua_load_settings(const char *filename, |
| 785 | pjsua_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 786 | |
| 787 | /** |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 788 | * Get pjsua running config. |
| 789 | */ |
| 790 | PJ_DECL(const pjsua_config*) pjsua_get_config(void); |
| 791 | |
| 792 | |
| 793 | /** |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 794 | * Dump settings. |
Benny Prijono | 9fc735d | 2006-05-28 14:58:12 +0000 | [diff] [blame^] | 795 | * If cfg is NULL, it will dump current settings. |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 796 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 797 | PJ_DECL(int) pjsua_dump_settings(const pjsua_config *cfg, |
| 798 | char *buf, pj_size_t max); |
Benny Prijono | a91a003 | 2006-02-26 21:23:45 +0000 | [diff] [blame] | 799 | |
| 800 | /** |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 801 | * Save settings to a file. |
| 802 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 803 | PJ_DECL(pj_status_t) pjsua_save_settings(const char *filename, |
| 804 | const pjsua_config *cfg); |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 805 | |
| 806 | |
| 807 | /* |
| 808 | * Verify that valid SIP url is given. |
| 809 | * @return PJ_SUCCESS if valid. |
| 810 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 811 | 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] | 812 | |
| 813 | /* |
| 814 | * Dump application states. |
| 815 | */ |
Benny Prijono | dc39fe8 | 2006-05-26 12:17:46 +0000 | [diff] [blame] | 816 | PJ_DECL(void) pjsua_dump(pj_bool_t detail); |
| 817 | |
| 818 | /** |
| 819 | * Display error message for the specified error code. |
| 820 | */ |
| 821 | PJ_DECL(void) pjsua_perror(const char *sender, const char *title, |
| 822 | pj_status_t status); |
| 823 | |
| 824 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 825 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 826 | |
Benny Prijono | 1a01ad3 | 2006-02-07 21:13:28 +0000 | [diff] [blame] | 827 | PJ_END_DECL |
| 828 | |
Benny Prijono | f319507 | 2006-02-14 21:15:30 +0000 | [diff] [blame] | 829 | |
Benny Prijono | 268ca61 | 2006-02-07 12:34:11 +0000 | [diff] [blame] | 830 | #endif /* __PJSUA_H__ */ |