| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef __PJSUA_INTERNAL_H__ |
| 20 |
#define __PJSUA_INTERNAL_H__ |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
PJ_BEGIN_DECL |
| 28 |
|
| 29 |
|
| 30 |
typedef struct pjsua_call pjsua_call; |
| 31 |
|
| 32 |
|
| 33 |
typedef struct pjsua_call_media pjsua_call_media; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
struct pjsua_call_media |
| 40 |
{ |
| 41 |
pjsua_call *call; |
| 42 |
pjmedia_type type; |
| 43 |
unsigned idx; |
| 44 |
pj_str_t rem_mid; |
| 45 |
pjsua_call_media_status state; |
| 46 |
pjsua_call_media_status prev_state; |
| 47 |
pjmedia_dir def_dir; |
| 48 |
pjmedia_dir dir; |
| 49 |
|
| 50 |
|
| 51 |
struct { |
| 52 |
|
| 53 |
struct { |
| 54 |
pjmedia_stream *stream; |
| 55 |
pjmedia_port *media_port; |
| 56 |
pj_bool_t destroy_port; |
| 57 |
int conf_slot; |
| 58 |
} a; |
| 59 |
|
| 60 |
|
| 61 |
struct { |
| 62 |
pjmedia_vid_stream *stream; |
| 63 |
pjsua_conf_port_id strm_enc_slot; |
| 64 |
pjsua_conf_port_id strm_dec_slot; |
| 65 |
pjsua_vid_win_id cap_win_id; |
| 66 |
pjsua_vid_win_id rdr_win_id; |
| 67 |
pjmedia_vid_dev_index cap_dev; |
| 68 |
pjmedia_vid_dev_index rdr_dev; |
| 69 |
} v; |
| 70 |
|
| 71 |
|
| 72 |
struct { |
| 73 |
pjmedia_txt_stream *stream; |
| 74 |
} t; |
| 75 |
|
| 76 |
} strm; |
| 77 |
|
| 78 |
pj_uint32_t ssrc; |
| 79 |
pj_uint32_t rtp_tx_ts; |
| 80 |
pj_uint16_t rtp_tx_seq; |
| 81 |
pj_uint8_t rtp_tx_seq_ts_set; |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
pjmedia_type prev_type; |
| 88 |
pj_sockaddr prev_local_addr; |
| 89 |
pj_sockaddr prev_rem_addr; |
| 90 |
pj_bool_t prev_srtp_use; |
| 91 |
pjmedia_srtp_info prev_srtp_info; |
| 92 |
pj_bool_t prev_ice_use; |
| 93 |
pjmedia_ice_transport_info prev_ice_info; |
| 94 |
|
| 95 |
pjmedia_transport *tp; |
| 96 |
pj_status_t tp_ready; |
| 97 |
pj_status_t tp_result; |
| 98 |
pjmedia_transport *tp_orig; |
| 99 |
pj_bool_t tp_auto_del; |
| 100 |
pjsua_med_tp_st tp_st; |
| 101 |
pj_bool_t use_custom_med_tp; |
| 102 |
pj_bool_t enable_rtcp_mux; |
| 103 |
pj_sockaddr rtp_addr; |
| 104 |
|
| 105 |
|
| 106 |
pjmedia_srtp_use rem_srtp_use; |
| 107 |
pj_timestamp last_req_keyframe; |
| 108 |
|
| 109 |
pj_bool_t use_upnp; |
| 110 |
pj_sockaddr mapped_addr[2]; |
| 111 |
|
| 112 |
pjsua_med_tp_state_cb med_init_cb; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
pj_status_t (*med_create_cb)(pjsua_call_media *call_med, |
| 117 |
pj_status_t status, int security_level, |
| 118 |
int *sip_err_code); |
| 119 |
}; |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
#define PJSUA_MAX_CALL_MEDIA PJMEDIA_MAX_SDP_MEDIA |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
#define PJSUA_MAX_AVI_NUM_STREAMS PJMEDIA_AVI_MAX_NUM_STREAMS |
| 130 |
|
| 131 |
|
| 132 |
typedef struct call_answer |
| 133 |
{ |
| 134 |
PJ_DECL_LIST_MEMBER(struct call_answer); |
| 135 |
pjsua_msg_data *msg_data; |
| 136 |
pj_str_t *reason; |
| 137 |
unsigned code; |
| 138 |
pjsua_call_setting *opt; |
| 139 |
} call_answer; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
typedef enum pjsua_op_state { |
| 144 |
PJSUA_OP_STATE_NULL, |
| 145 |
PJSUA_OP_STATE_READY, |
| 146 |
PJSUA_OP_STATE_RUNNING, |
| 147 |
PJSUA_OP_STATE_DONE, |
| 148 |
} pjsua_op_state; |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
struct pjsua_call |
| 156 |
{ |
| 157 |
unsigned index; |
| 158 |
pjsua_call_setting opt; |
| 159 |
pj_bool_t opt_inited; |
| 160 |
|
| 161 |
pjsip_inv_session *inv; |
| 162 |
void *user_data; |
| 163 |
pjsip_status_code last_code; |
| 164 |
pj_str_t last_text; |
| 165 |
pj_time_val start_time; |
| 166 |
pj_time_val res_time; |
| 167 |
pj_time_val conn_time; |
| 168 |
pj_time_val dis_time; |
| 169 |
pjsua_acc_id acc_id; |
| 170 |
int secure_level; |
| 171 |
pjsua_call_hold_type call_hold_type; |
| 172 |
pj_bool_t local_hold; |
| 173 |
void *hold_msg; |
| 174 |
pj_str_t cname; |
| 175 |
char cname_buf[16]; |
| 176 |
|
| 177 |
unsigned med_cnt; |
| 178 |
pjsua_call_media media[PJSUA_MAX_CALL_MEDIA]; |
| 179 |
unsigned med_prov_cnt; |
| 180 |
pjsua_call_media media_prov[PJSUA_MAX_CALL_MEDIA]; |
| 181 |
|
| 182 |
pj_bool_t med_update_success; |
| 183 |
|
| 184 |
pj_bool_t hanging_up; |
| 185 |
|
| 186 |
int audio_idx; |
| 187 |
pj_mutex_t *med_ch_mutex; |
| 188 |
pjsua_med_tp_state_cb med_ch_cb; |
| 189 |
pjsua_med_tp_state_info med_ch_info; |
| 190 |
|
| 191 |
pjsip_evsub *xfer_sub; |
| 192 |
|
| 193 |
pj_stun_nat_type rem_nat_type; |
| 194 |
|
| 195 |
char last_text_buf_[128]; |
| 196 |
|
| 197 |
struct { |
| 198 |
int retry_cnt; |
| 199 |
} lock_codec; |
| 200 |
|
| 201 |
|
| 202 |
struct { |
| 203 |
pjsip_dialog *dlg; |
| 204 |
pjmedia_sdp_session *rem_sdp; |
| 205 |
pj_pool_t *pool_prov; |
| 206 |
pj_bool_t med_ch_deinit; |
| 207 |
union { |
| 208 |
struct { |
| 209 |
pjsua_msg_data *msg_data; |
| 210 |
pj_bool_t hangup; |
| 211 |
} out_call; |
| 212 |
struct { |
| 213 |
call_answer answers; |
| 214 |
pj_bool_t hangup; |
| 215 |
pjsip_dialog *replaced_dlg; |
| 216 |
} inc_call; |
| 217 |
} call_var; |
| 218 |
} async_call; |
| 219 |
|
| 220 |
|
| 221 |
pj_bool_t rem_offerer; |
| 222 |
unsigned rem_aud_cnt; |
| 223 |
|
| 224 |
unsigned rem_vid_cnt; |
| 225 |
|
| 226 |
unsigned rem_txt_cnt; |
| 227 |
|
| 228 |
|
| 229 |
pj_bool_t rx_reinv_async; |
| 230 |
pj_timer_entry reinv_timer; |
| 231 |
pj_bool_t reinv_pending; |
| 232 |
pj_bool_t reinv_ice_sent; |
| 233 |
pjsip_rx_data *incoming_data; |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
struct { |
| 242 |
pj_bool_t enabled; |
| 243 |
pj_bool_t remote_sup; |
| 244 |
pj_bool_t remote_dlg_est; |
| 245 |
pjsua_op_state trickling; |
| 246 |
int retrans18x_count; |
| 247 |
pj_bool_t pending_info; |
| 248 |
pj_timer_entry timer; |
| 249 |
} trickle_ice; |
| 250 |
|
| 251 |
pj_timer_entry hangup_timer; |
| 252 |
unsigned hangup_retry; |
| 253 |
unsigned hangup_code; |
| 254 |
pj_str_t hangup_reason; |
| 255 |
pjsua_msg_data *hangup_msg_data; |
| 256 |
pj_str_t siprec_metadata; |
| 257 |
|
| 258 |
pjmedia_av_sync *av_sync; |
| 259 |
}; |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
struct pjsua_srv_pres |
| 266 |
{ |
| 267 |
PJ_DECL_LIST_MEMBER(struct pjsua_srv_pres); |
| 268 |
pjsip_evsub *sub; |
| 269 |
char *remote; |
| 270 |
int acc_id; |
| 271 |
pjsip_dialog *dlg; |
| 272 |
unsigned expires; |
| 273 |
|
| 274 |
|
| 275 |
}; |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
typedef struct pjsua_acc |
| 281 |
{ |
| 282 |
pj_pool_t *pool; |
| 283 |
pjsua_acc_config cfg; |
| 284 |
pj_bool_t valid; |
| 285 |
|
| 286 |
int index; |
| 287 |
pj_str_t display; |
| 288 |
pj_str_t user_part; |
| 289 |
pj_bool_t is_sips; |
| 290 |
pj_str_t contact; |
| 291 |
pj_str_t reg_contact; |
| 292 |
|
| 293 |
|
| 294 |
pj_bool_t contact_rewritten; |
| 295 |
|
| 296 |
pjsip_host_port via_addr; |
| 297 |
pjsip_transport *via_tp; |
| 298 |
|
| 299 |
|
| 300 |
pj_str_t srv_domain; |
| 301 |
int srv_port; |
| 302 |
|
| 303 |
pjsip_regc *regc; |
| 304 |
pj_status_t reg_last_err; |
| 305 |
int reg_last_code; |
| 306 |
|
| 307 |
pj_str_t reg_mapped_addr; |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
struct { |
| 312 |
pj_bool_t active; |
| 313 |
pj_timer_entry timer; |
| 314 |
void *reg_tp; |
| 315 |
unsigned attempt_cnt; |
| 316 |
} auto_rereg; |
| 317 |
|
| 318 |
pj_timer_entry ka_timer; |
| 319 |
pjsip_transport *ka_transport; |
| 320 |
pj_sockaddr ka_target; |
| 321 |
unsigned ka_target_len; |
| 322 |
|
| 323 |
pjsip_route_hdr route_set; |
| 324 |
pj_uint32_t global_route_crc; |
| 325 |
pj_uint32_t local_route_crc; |
| 326 |
|
| 327 |
unsigned rfc5626_status; |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
pj_str_t rfc5626_instprm; |
| 332 |
pj_str_t rfc5626_regprm; |
| 333 |
unsigned rfc5626_flowtmr; |
| 334 |
|
| 335 |
unsigned cred_cnt; |
| 336 |
pjsip_cred_info cred[PJSUA_ACC_MAX_PROXIES]; |
| 337 |
|
| 338 |
pj_bool_t online_status; |
| 339 |
pjrpid_element rpid; |
| 340 |
pjsua_srv_pres pres_srv_list; |
| 341 |
pjsip_publishc *publish_sess; |
| 342 |
pj_bool_t publish_state; |
| 343 |
|
| 344 |
pjsip_evsub *mwi_sub; |
| 345 |
pjsip_dialog *mwi_dlg; |
| 346 |
|
| 347 |
pj_uint16_t next_rtp_port; |
| 348 |
pjsip_transport_type_e tp_type; |
| 349 |
|
| 350 |
pjsua_ip_change_op ip_change_op; |
| 351 |
pjsip_auth_clt_sess shared_auth_sess; |
| 352 |
|
| 353 |
} pjsua_acc; |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
typedef struct pjsua_transport_data |
| 360 |
{ |
| 361 |
int index; |
| 362 |
pjsip_transport_type_e type; |
| 363 |
pjsip_host_port local_name; |
| 364 |
pj_sockaddr pub_addr; |
| 365 |
|
| 366 |
union { |
| 367 |
pjsip_transport *tp; |
| 368 |
pjsip_tpfactory *factory; |
| 369 |
void *ptr; |
| 370 |
} data; |
| 371 |
|
| 372 |
pj_bool_t is_restarting; |
| 373 |
pj_status_t restart_status; |
| 374 |
pj_bool_t has_cfg_addr; |
| 375 |
} pjsua_transport_data; |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
#define PJSUA_BUDDY_SUB_TERM_REASON_LEN 32 |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
typedef struct pjsua_buddy |
| 385 |
{ |
| 386 |
pj_pool_t *pool; |
| 387 |
unsigned index; |
| 388 |
pjsua_acc_id acc_id; |
| 389 |
void *user_data; |
| 390 |
pj_str_t uri; |
| 391 |
pj_str_t contact; |
| 392 |
pj_str_t name; |
| 393 |
pj_str_t display; |
| 394 |
pj_str_t host; |
| 395 |
unsigned port; |
| 396 |
pj_bool_t monitor; |
| 397 |
pjsip_dialog *dlg; |
| 398 |
pjsip_evsub *sub; |
| 399 |
pj_bool_t presence; |
| 400 |
unsigned term_code; |
| 401 |
pj_str_t term_reason; |
| 402 |
pjsip_pres_status status; |
| 403 |
pjsip_dlg_event_status dlg_ev_status; |
| 404 |
pj_timer_entry timer; |
| 405 |
} pjsua_buddy; |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
typedef struct pjsua_file_data |
| 412 |
{ |
| 413 |
pj_bool_t type; |
| 414 |
pjmedia_port *port; |
| 415 |
pj_pool_t *pool; |
| 416 |
unsigned slot; |
| 417 |
} pjsua_file_data; |
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
typedef struct pjsua_avi_player_data |
| 423 |
{ |
| 424 |
pj_pool_t *pool; |
| 425 |
pjmedia_avi_streams *avi_streams; |
| 426 |
unsigned vid_cnt; |
| 427 |
unsigned aud_cnt; |
| 428 |
pjmedia_vid_dev_index vid_dev_id; |
| 429 |
pjsua_conf_port_id slot[PJSUA_MAX_AVI_NUM_STREAMS]; |
| 430 |
pjmedia_port *port[PJSUA_MAX_AVI_NUM_STREAMS]; |
| 431 |
pjmedia_type type[PJSUA_MAX_AVI_NUM_STREAMS]; |
| 432 |
|
| 433 |
} pjsua_avi_player_data; |
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
typedef struct pjsua_avi_recorder_data |
| 439 |
{ |
| 440 |
pj_pool_t *pool; |
| 441 |
pjmedia_avi_streams *avi_streams; |
| 442 |
pjsua_conf_port_id aud_slot; |
| 443 |
pjsua_conf_port_id vid_slot; |
| 444 |
pjmedia_port *aud_port; |
| 445 |
pjmedia_port *vid_port; |
| 446 |
void (*cb)(pjsua_avi_rec_id id, |
| 447 |
void *user_data); |
| 448 |
void *user_data; |
| 449 |
} pjsua_avi_recorder_data; |
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
typedef struct pjsua_conf_setting |
| 455 |
{ |
| 456 |
unsigned channel_count; |
| 457 |
unsigned samples_per_frame; |
| 458 |
unsigned bits_per_sample; |
| 459 |
} pjsua_conf_setting; |
| 460 |
|
| 461 |
typedef struct pjsua_stun_resolve |
| 462 |
{ |
| 463 |
PJ_DECL_LIST_MEMBER(struct pjsua_stun_resolve); |
| 464 |
|
| 465 |
pj_pool_t *pool; |
| 466 |
int ref_cnt; |
| 467 |
pj_bool_t destroy_flag; |
| 468 |
pj_bool_t has_result; |
| 469 |
unsigned count; |
| 470 |
pj_str_t *srv; |
| 471 |
unsigned idx; |
| 472 |
void *token; |
| 473 |
pj_stun_resolve_cb cb; |
| 474 |
pj_bool_t blocking; |
| 475 |
pj_thread_t *waiter; |
| 476 |
pj_timer_entry timer; |
| 477 |
pj_status_t status; |
| 478 |
pj_sockaddr addr; |
| 479 |
pj_stun_sock *stun_sock; |
| 480 |
int af; |
| 481 |
pj_bool_t async_wait; |
| 482 |
|
| 483 |
} pjsua_stun_resolve; |
| 484 |
|
| 485 |
|
| 486 |
typedef enum pjsua_vid_win_type |
| 487 |
{ |
| 488 |
PJSUA_WND_TYPE_NONE, |
| 489 |
PJSUA_WND_TYPE_PREVIEW, |
| 490 |
PJSUA_WND_TYPE_STREAM |
| 491 |
} pjsua_vid_win_type; |
| 492 |
|
| 493 |
typedef struct pjsua_vid_win |
| 494 |
{ |
| 495 |
pjsua_vid_win_type type; |
| 496 |
pj_pool_t *pool; |
| 497 |
unsigned ref_cnt; |
| 498 |
pjmedia_vid_port *vp_cap; |
| 499 |
pjmedia_vid_port *vp_rend; |
| 500 |
pjsua_conf_port_id cap_slot; |
| 501 |
pjsua_conf_port_id rend_slot; |
| 502 |
pjmedia_vid_dev_index preview_cap_id; |
| 503 |
pj_bool_t preview_running; |
| 504 |
pj_bool_t is_native; |
| 505 |
} pjsua_vid_win; |
| 506 |
|
| 507 |
|
| 508 |
typedef struct pjsua_timer_list |
| 509 |
{ |
| 510 |
PJ_DECL_LIST_MEMBER(struct pjsua_timer_list); |
| 511 |
pj_timer_entry entry; |
| 512 |
void (*cb)(void *user_data); |
| 513 |
void *user_data; |
| 514 |
} pjsua_timer_list; |
| 515 |
|
| 516 |
|
| 517 |
typedef struct pjsua_event_list |
| 518 |
{ |
| 519 |
PJ_DECL_LIST_MEMBER(struct pjsua_event_list); |
| 520 |
pjmedia_event event; |
| 521 |
pjsua_call_id call_id; |
| 522 |
unsigned med_idx; |
| 523 |
} pjsua_event_list; |
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
struct pjsua_data |
| 530 |
{ |
| 531 |
|
| 532 |
|
| 533 |
pj_caching_pool cp; |
| 534 |
pj_pool_t *pool; |
| 535 |
pj_pool_t *timer_pool; |
| 536 |
pj_mutex_t *mutex; |
| 537 |
unsigned mutex_nesting_level; |
| 538 |
pj_thread_t *mutex_owner; |
| 539 |
pjsua_state state; |
| 540 |
|
| 541 |
|
| 542 |
pjsua_logging_config log_cfg; |
| 543 |
pj_oshandle_t log_file; |
| 544 |
|
| 545 |
|
| 546 |
pjsip_endpoint *endpt; |
| 547 |
pjsip_module mod; |
| 548 |
pjsua_transport_data tpdata[8]; |
| 549 |
pjsip_tp_state_callback old_tp_cb; |
| 550 |
|
| 551 |
|
| 552 |
pj_bool_t thread_quit_flag; |
| 553 |
pj_thread_t *thread[4]; |
| 554 |
|
| 555 |
|
| 556 |
pj_stun_config stun_cfg; |
| 557 |
pj_sockaddr stun_srv; |
| 558 |
pj_status_t stun_status; |
| 559 |
pjsua_stun_resolve stun_res; |
| 560 |
unsigned stun_srv_idx; |
| 561 |
unsigned stun_opt; |
| 562 |
pj_dns_resolver *resolver; |
| 563 |
|
| 564 |
|
| 565 |
pj_status_t upnp_status; |
| 566 |
|
| 567 |
|
| 568 |
pj_stun_nat_type nat_type; |
| 569 |
pj_status_t nat_status; |
| 570 |
pj_bool_t nat_in_progress; |
| 571 |
|
| 572 |
|
| 573 |
pjsip_route_hdr outbound_proxy; |
| 574 |
|
| 575 |
|
| 576 |
unsigned acc_cnt; |
| 577 |
pjsua_acc_id default_acc; |
| 578 |
pjsua_acc acc[PJSUA_MAX_ACC]; |
| 579 |
pjsua_acc_id acc_ids[PJSUA_MAX_ACC]; |
| 580 |
|
| 581 |
|
| 582 |
pjsua_config ua_cfg; |
| 583 |
unsigned call_cnt; |
| 584 |
pjsua_call *calls; |
| 585 |
pjsua_call_id next_call_id; |
| 586 |
|
| 587 |
|
| 588 |
unsigned buddy_cnt; |
| 589 |
pjsua_buddy buddy[PJSUA_MAX_BUDDIES]; |
| 590 |
|
| 591 |
|
| 592 |
pj_timer_entry pres_timer; |
| 593 |
|
| 594 |
|
| 595 |
pjsua_media_config media_cfg; |
| 596 |
pjmedia_endpt *med_endpt; |
| 597 |
pjsua_conf_setting mconf_cfg; |
| 598 |
pjmedia_conf *mconf; |
| 599 |
pj_bool_t is_mswitch; |
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
pjmedia_aud_dev_index cap_dev; |
| 604 |
pjmedia_aud_dev_index play_dev; |
| 605 |
pj_uint32_t aud_svmask; |
| 606 |
pjmedia_aud_param aud_param; |
| 607 |
pj_bool_t aud_open_cnt; |
| 608 |
pj_bool_t no_snd; |
| 609 |
pj_pool_t *snd_pool; |
| 610 |
pjmedia_snd_port *snd_port; |
| 611 |
pj_timer_entry snd_idle_timer; |
| 612 |
pjmedia_master_port *null_snd; |
| 613 |
pjmedia_port *null_port; |
| 614 |
pj_bool_t snd_is_on; |
| 615 |
unsigned snd_mode; |
| 616 |
|
| 617 |
|
| 618 |
pjmedia_vid_dev_index vcap_dev; |
| 619 |
pjmedia_vid_dev_index vrdr_dev; |
| 620 |
|
| 621 |
|
| 622 |
#if PJSUA_HAS_VIDEO |
| 623 |
pjmedia_vid_conf *vid_conf; |
| 624 |
pj_uint32_t vid_caps[PJMEDIA_VID_DEV_MAX_DEVS]; |
| 625 |
pjmedia_vid_dev_param vid_param[PJMEDIA_VID_DEV_MAX_DEVS]; |
| 626 |
#endif |
| 627 |
|
| 628 |
|
| 629 |
unsigned player_cnt; |
| 630 |
pjsua_file_data player[PJSUA_MAX_PLAYERS]; |
| 631 |
|
| 632 |
|
| 633 |
unsigned rec_cnt; |
| 634 |
pjsua_file_data recorder[PJSUA_MAX_RECORDERS]; |
| 635 |
|
| 636 |
#if PJSUA_HAS_VIDEO |
| 637 |
|
| 638 |
pjmedia_vid_dev_factory *avi_factory; |
| 639 |
unsigned avi_player_cnt; |
| 640 |
pjsua_avi_player_data avi_player[PJSUA_MAX_AVI_PLAYERS]; |
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
unsigned avi_rec_cnt; |
| 645 |
pjsua_avi_recorder_data avi_recorder[PJSUA_MAX_AVI_RECORDERS]; |
| 646 |
|
| 647 |
#endif |
| 648 |
|
| 649 |
|
| 650 |
#if PJSUA_HAS_VIDEO |
| 651 |
pjsua_vid_win win[PJSUA_MAX_VID_WINS]; |
| 652 |
#endif |
| 653 |
|
| 654 |
|
| 655 |
pjsua_timer_list active_timer_list; |
| 656 |
pjsua_timer_list timer_list; |
| 657 |
pjsua_event_list event_list; |
| 658 |
pj_mutex_t *timer_mutex; |
| 659 |
}; |
| 660 |
|
| 661 |
|
| 662 |
extern struct pjsua_data pjsua_var; |
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
PJ_DECL(struct pjsua_data*) pjsua_get_var(void); |
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
typedef struct pjsua_im_data |
| 675 |
{ |
| 676 |
pjsua_acc_id acc_id; |
| 677 |
pjsua_call_id call_id; |
| 678 |
pj_str_t to; |
| 679 |
pj_str_t body; |
| 680 |
void *user_data; |
| 681 |
} pjsua_im_data; |
| 682 |
|
| 683 |
pj_status_t pjsua_media_apply_xml_control(pjsua_call_id call_id, |
| 684 |
const pj_str_t *xml_st); |
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
PJ_INLINE(pjsua_im_data*) pjsua_im_data_dup(pj_pool_t *pool, |
| 691 |
const pjsua_im_data *src) |
| 692 |
{ |
| 693 |
pjsua_im_data *dst; |
| 694 |
|
| 695 |
dst = (pjsua_im_data*) pj_pool_alloc(pool, sizeof(*dst)); |
| 696 |
dst->acc_id = src->acc_id; |
| 697 |
dst->call_id = src->call_id; |
| 698 |
pj_strdup_with_null(pool, &dst->to, &src->to); |
| 699 |
dst->user_data = src->user_data; |
| 700 |
pj_strdup_with_null(pool, &dst->body, &src->body); |
| 701 |
|
| 702 |
return dst; |
| 703 |
} |
| 704 |
|
| 705 |
|
| 706 |
#if 1 |
| 707 |
|
| 708 |
PJ_INLINE(void) PJSUA_LOCK() |
| 709 |
{ |
| 710 |
pj_mutex_lock(pjsua_var.mutex); |
| 711 |
pjsua_var.mutex_owner = pj_thread_this(); |
| 712 |
++pjsua_var.mutex_nesting_level; |
| 713 |
} |
| 714 |
|
| 715 |
PJ_INLINE(void) PJSUA_UNLOCK() |
| 716 |
{ |
| 717 |
if (--pjsua_var.mutex_nesting_level == 0) |
| 718 |
pjsua_var.mutex_owner = NULL; |
| 719 |
pj_mutex_unlock(pjsua_var.mutex); |
| 720 |
} |
| 721 |
|
| 722 |
PJ_INLINE(pj_status_t) PJSUA_TRY_LOCK() |
| 723 |
{ |
| 724 |
pj_status_t status; |
| 725 |
status = pj_mutex_trylock(pjsua_var.mutex); |
| 726 |
if (status == PJ_SUCCESS) { |
| 727 |
pjsua_var.mutex_owner = pj_thread_this(); |
| 728 |
++pjsua_var.mutex_nesting_level; |
| 729 |
} |
| 730 |
return status; |
| 731 |
} |
| 732 |
|
| 733 |
PJ_INLINE(pj_bool_t) PJSUA_LOCK_IS_LOCKED() |
| 734 |
{ |
| 735 |
return pjsua_var.mutex_owner == pj_thread_this(); |
| 736 |
} |
| 737 |
|
| 738 |
|
| 739 |
PJ_INLINE(unsigned) PJSUA_RELEASE_LOCK() |
| 740 |
{ |
| 741 |
unsigned num_locks = 0; |
| 742 |
while (PJSUA_LOCK_IS_LOCKED()) { |
| 743 |
num_locks++; |
| 744 |
PJSUA_UNLOCK(); |
| 745 |
} |
| 746 |
return num_locks; |
| 747 |
} |
| 748 |
|
| 749 |
|
| 750 |
PJ_INLINE(void) PJSUA_RELOCK(unsigned num_locks) |
| 751 |
{ |
| 752 |
for (; num_locks > 0; num_locks--) |
| 753 |
PJSUA_LOCK(); |
| 754 |
} |
| 755 |
|
| 756 |
#else |
| 757 |
#define PJSUA_LOCK() |
| 758 |
#define PJSUA_TRY_LOCK() PJ_SUCCESS |
| 759 |
#define PJSUA_UNLOCK() |
| 760 |
#define PJSUA_LOCK_IS_LOCKED() PJ_TRUE |
| 761 |
#endif |
| 762 |
|
| 763 |
|
| 764 |
void pjsua_set_state(pjsua_state new_state); |
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
pj_status_t resolve_stun_server(pj_bool_t wait, pj_bool_t retry_if_cur_error, |
| 771 |
unsigned options); |
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
pj_status_t normalize_route_uri(pj_pool_t *pool, pj_str_t *uri); |
| 778 |
|
| 779 |
|
| 780 |
pj_bool_t pjsua_sip_acc_is_using_stun(pjsua_acc_id acc_id); |
| 781 |
pj_bool_t pjsua_media_acc_is_using_stun(pjsua_acc_id acc_id); |
| 782 |
|
| 783 |
|
| 784 |
pj_bool_t pjsua_sip_acc_is_using_upnp(pjsua_acc_id acc_id); |
| 785 |
pj_bool_t pjsua_media_acc_is_using_upnp(pjsua_acc_id acc_id); |
| 786 |
|
| 787 |
|
| 788 |
pj_bool_t pjsua_sip_acc_is_using_ipv6(pjsua_acc_id acc_id); |
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
pj_status_t pjsua_acc_get_uac_addr(pjsua_acc_id acc_id, |
| 794 |
pj_pool_t *pool, |
| 795 |
const pj_str_t *dst_uri, |
| 796 |
pjsip_host_port *addr, |
| 797 |
pjsip_transport_type_e *p_tp_type, |
| 798 |
int *p_secure, |
| 799 |
const void **p_tp); |
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
pj_bool_t pjsua_call_on_incoming(pjsip_rx_data *rdata); |
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
pj_status_t pjsua_media_channel_init(pjsua_call_id call_id, |
| 810 |
pjsip_role_e role, |
| 811 |
int security_level, |
| 812 |
pj_pool_t *tmp_pool, |
| 813 |
const pjmedia_sdp_session *rem_sdp, |
| 814 |
int *sip_err_code, |
| 815 |
pj_bool_t async, |
| 816 |
pjsua_med_tp_state_cb cb); |
| 817 |
pj_status_t pjsua_media_channel_create_sdp(pjsua_call_id call_id, |
| 818 |
pj_pool_t *pool, |
| 819 |
const pjmedia_sdp_session *rem_sdp, |
| 820 |
pjmedia_sdp_session **p_sdp, |
| 821 |
int *sip_err_code); |
| 822 |
pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, |
| 823 |
const pjmedia_sdp_session *local_sdp, |
| 824 |
const pjmedia_sdp_session *remote_sdp); |
| 825 |
pj_status_t pjsua_media_channel_deinit(pjsua_call_id call_id); |
| 826 |
|
| 827 |
void pjsua_ice_check_start_trickling(pjsua_call *call, |
| 828 |
pj_bool_t forceful, |
| 829 |
pjsip_event *e); |
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
#define ERR_MEDIA_CHANGING " because another media operation is in progress" |
| 835 |
|
| 836 |
pj_bool_t pjsua_call_media_is_changing(pjsua_call *call); |
| 837 |
pj_status_t pjsua_call_media_init(pjsua_call_media *call_med, |
| 838 |
pjmedia_type type, |
| 839 |
const pjmedia_sdp_session *rem_sdp, |
| 840 |
const pjsua_transport_config *tcfg, |
| 841 |
int security_level, |
| 842 |
int *sip_err_code, |
| 843 |
pj_bool_t async, |
| 844 |
pjsua_med_tp_state_cb cb); |
| 845 |
void pjsua_call_cleanup_flag(pjsua_call_setting *opt); |
| 846 |
void pjsua_set_media_tp_state(pjsua_call_media *call_med, pjsua_med_tp_st tp_st); |
| 847 |
|
| 848 |
void pjsua_media_prov_clean_up(pjsua_call_id call_id); |
| 849 |
void pjsua_media_prov_revert(pjsua_call_id call_id); |
| 850 |
|
| 851 |
|
| 852 |
pj_status_t on_media_event(pjmedia_event *event, void *user_data); |
| 853 |
void call_med_event_cb(void *user_data); |
| 854 |
pj_status_t call_media_on_event(pjmedia_event *event, |
| 855 |
void *user_data); |
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
pj_status_t pjsua_pres_init(void); |
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
pj_status_t pjsua_pres_start(void); |
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
void pjsua_pres_refresh(void); |
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
void pjsua_pres_update_acc(int acc_id, pj_bool_t force); |
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
void pjsua_pres_shutdown(unsigned flags); |
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
pj_status_t pjsua_pres_init_acc(int acc_id); |
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
pj_status_t pjsua_pres_init_publish_acc(int acc_id); |
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
void pjsua_pres_unpublish(pjsua_acc *acc, unsigned flags); |
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
void pjsua_pres_delete_acc(int acc_id, unsigned flags); |
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
pj_status_t pjsua_im_init(void); |
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
pj_status_t pjsua_start_mwi(pjsua_acc_id acc_id, pj_bool_t force_renew); |
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
pj_status_t pjsua_call_subsys_init(const pjsua_config *cfg); |
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
pj_status_t pjsua_call_subsys_start(void); |
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
pj_status_t pjsua_media_subsys_init(const pjsua_media_config *cfg); |
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
pj_status_t pjsua_media_subsys_start(void); |
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
pj_status_t pjsua_media_subsys_destroy(unsigned flags); |
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata, |
| 943 |
pjsip_accept_hdr **p_accept_hdr); |
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
void pjsua_im_process_pager(int call_id, const pj_str_t *from, |
| 950 |
const pj_str_t *to, pjsip_rx_data *rdata); |
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
pjsip_accept_hdr* pjsua_im_create_accept(pj_pool_t *pool); |
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
void pjsua_process_msg_data(pjsip_tx_data *tdata, |
| 963 |
const pjsua_msg_data *msg_data); |
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
void pjsua_set_msg_route_set( pjsip_tx_data *tdata, |
| 970 |
const pjsip_route_hdr *route_set ); |
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
void pjsua_parse_media_type( pj_pool_t *pool, |
| 977 |
const pj_str_t *mime, |
| 978 |
pjsip_media_type *media_type); |
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
void pjsua_init_tpselector(pjsua_transport_id tp_id, |
| 985 |
pjsip_tpselector *sel); |
| 986 |
|
| 987 |
pjsip_dialog* on_dlg_forked(pjsip_dialog *first_set, pjsip_rx_data *res); |
| 988 |
pj_status_t acquire_call(const char *title, |
| 989 |
pjsua_call_id call_id, |
| 990 |
pjsua_call **p_call, |
| 991 |
pjsip_dialog **p_dlg); |
| 992 |
const char *good_number(char *buf, unsigned buf_size, pj_int32_t val); |
| 993 |
void print_call(const char *title, |
| 994 |
int call_id, |
| 995 |
char *buf, pj_size_t size); |
| 996 |
|
| 997 |
char *pjsua_get_basename(const char *path, unsigned len); |
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
void pjsua_reset_avi_player_data(pjsua_avi_player_id id); |
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
void pjsua_reset_avi_recorder_data(pjsua_avi_rec_id id); |
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
pj_status_t pjsua_aud_subsys_init(void); |
| 1013 |
pj_status_t pjsua_aud_subsys_start(void); |
| 1014 |
pj_status_t pjsua_aud_subsys_destroy(void); |
| 1015 |
void pjsua_aud_stop_stream(pjsua_call_media *call_med); |
| 1016 |
pj_status_t pjsua_aud_channel_update(pjsua_call_media *call_med, |
| 1017 |
pj_pool_t *tmp_pool, |
| 1018 |
pjmedia_stream_info *si, |
| 1019 |
const pjmedia_sdp_session *local_sdp, |
| 1020 |
const pjmedia_sdp_session *remote_sdp); |
| 1021 |
void pjsua_check_snd_dev_idle(void); |
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
pj_status_t pjsua_vid_subsys_init(void); |
| 1027 |
pj_status_t pjsua_vid_subsys_start(void); |
| 1028 |
pj_status_t pjsua_vid_subsys_destroy(void); |
| 1029 |
void pjsua_vid_stop_stream(pjsua_call_media *call_med); |
| 1030 |
pj_status_t pjsua_vid_channel_init(pjsua_call_media *call_med); |
| 1031 |
pj_status_t pjsua_vid_channel_update(pjsua_call_media *call_med, |
| 1032 |
pj_pool_t *tmp_pool, |
| 1033 |
pjmedia_vid_stream_info *si, |
| 1034 |
const pjmedia_sdp_session *local_sdp, |
| 1035 |
const pjmedia_sdp_session *remote_sdp); |
| 1036 |
|
| 1037 |
#if PJSUA_HAS_VIDEO |
| 1038 |
void pjsua_vid_win_reset(pjsua_vid_win_id wid); |
| 1039 |
#else |
| 1040 |
# define pjsua_vid_win_reset(wid) |
| 1041 |
#endif |
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
void pjsua_txt_stop_stream(pjsua_call_media *call_med); |
| 1047 |
pj_status_t pjsua_txt_channel_update(pjsua_call_media *call_med, |
| 1048 |
pj_pool_t *tmp_pool, |
| 1049 |
pjmedia_txt_stream_info *si, |
| 1050 |
const pjmedia_sdp_session *local_sdp, |
| 1051 |
const pjmedia_sdp_session *remote_sdp); |
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
void pjsua_call_schedule_reinvite_check(pjsua_call *call, unsigned delay_ms); |
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
pj_status_t pjsua_acc_update_contact_on_ip_change(pjsua_acc *acc); |
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
pj_status_t pjsua_acc_handle_call_on_ip_change(pjsua_acc *acc); |
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
void pjsua_acc_end_ip_change(pjsua_acc *acc); |
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
pj_bool_t pjsua_auth_on_challenge( |
| 1077 |
pjsip_auth_clt_sess *sess, |
| 1078 |
void *token, |
| 1079 |
const pjsip_auth_clt_async_on_chal_param *param); |
| 1080 |
|
| 1081 |
PJ_END_DECL |
| 1082 |
|
| 1083 |
#endif |
| 1084 |
|