-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
377 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## simple_pjsua.c流程 | ||
|
||
<img src="../img/make_call流程.png" alt="img" style="zoom:50%;" /> | ||
|
||
## pjsua_call_make_call | ||
|
||
<img src="../img/pjsua_call_make_call.png" alt="img" style="zoom:50%;" /> | ||
|
||
```c | ||
status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, NULL); | ||
``` | ||
|
||
### 1、参数详解 | ||
|
||
**acc_id ** 获得 | ||
|
||
``` | ||
pjsua_acc_add(&cfg, PJ_TRUE, &acc_id); | ||
``` | ||
|
||
**uri** 用户传入 | ||
|
||
``` | ||
pj_str_t uri = pj_str(argv[1]); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
## pjsua_acc | ||
|
||
``` | ||
/** | ||
* Account | ||
*/ | ||
typedef struct pjsua_acc | ||
{ | ||
pj_pool_t *pool; /**< Pool for this account. */ | ||
pjsua_acc_config cfg; /**< Account configuration. */ | ||
pj_bool_t valid; /**< Is this account valid? */ | ||
int index; /**< Index in accounts array. */ | ||
pj_str_t display; /**< Display name, if any. */ | ||
pj_str_t user_part; /**< User part of local URI. */ | ||
pj_bool_t is_sips; /**< Local URI uses "sips"? */ | ||
pj_str_t contact; /**< Our Contact header. */ | ||
pj_str_t reg_contact; /**< Contact header for REGISTER. | ||
It may be different than acc | ||
contact if outbound is used */ | ||
pj_bool_t contact_rewritten; | ||
/**< Contact rewrite has been done? */ | ||
pjsip_host_port via_addr; /**< Address for Via header */ | ||
pjsip_transport *via_tp; /**< Transport associated with | ||
the Via address */ | ||
pj_str_t srv_domain; /**< Host part of reg server. */ | ||
int srv_port; /**< Port number of reg server. */ | ||
pjsip_regc *regc; /**< Client registration session. */ | ||
pj_status_t reg_last_err; /**< Last registration error. */ | ||
int reg_last_code; /**< Last status last register. */ | ||
pj_str_t reg_mapped_addr;/**< Our addr as seen by reg srv. | ||
Only if allow_sdp_nat_rewrite | ||
is set */ | ||
struct { | ||
pj_bool_t active; /**< Flag of reregister status. */ | ||
pj_timer_entry timer; /**< Timer for reregistration. */ | ||
void *reg_tp; /**< Transport for registration. */ | ||
unsigned attempt_cnt; /**< Attempt counter. */ | ||
} auto_rereg; /**< Reregister/reconnect data. */ | ||
pj_timer_entry ka_timer; /**< Keep-alive timer for UDP. */ | ||
pjsip_transport *ka_transport; /**< Transport for keep-alive. */ | ||
pj_sockaddr ka_target; /**< Destination address for K-A */ | ||
unsigned ka_target_len; /**< Length of ka_target. */ | ||
pjsip_route_hdr route_set; /**< Complete route set inc. outbnd.*/ | ||
pj_uint32_t global_route_crc; /** CRC of global route setting. */ | ||
pj_uint32_t local_route_crc; /** CRC of account route setting.*/ | ||
unsigned rfc5626_status;/**< SIP outbound status: | ||
0: not used | ||
1: requested | ||
2: acknowledged by servers */ | ||
pj_str_t rfc5626_instprm;/**< SIP outbound instance param. */ | ||
pj_str_t rfc5626_regprm;/**< SIP outbound reg param. */ | ||
unsigned rfc5626_flowtmr;/**< SIP outbound flow timer. */ | ||
unsigned cred_cnt; /**< Number of credentials. */ | ||
pjsip_cred_info cred[PJSUA_ACC_MAX_PROXIES]; /**< Complete creds. */ | ||
pj_bool_t online_status; /**< Our online status. */ | ||
pjrpid_element rpid; /**< RPID element information. */ | ||
pjsua_srv_pres pres_srv_list; /**< Server subscription list. */ | ||
pjsip_publishc *publish_sess; /**< Client publication session. */ | ||
pj_bool_t publish_state; /**< Last published online status */ | ||
pjsip_evsub *mwi_sub; /**< MWI client subscription */ | ||
pjsip_dialog *mwi_dlg; /**< Dialog for MWI sub. */ | ||
pj_uint16_t next_rtp_port; /**< Next RTP port to be used. */ | ||
pjsip_transport_type_e tp_type; /**< Transport type (for local acc or | ||
transport binding) */ | ||
pjsua_ip_change_op ip_change_op;/**< IP change process progress. */ | ||
} pjsua_acc; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
## pjsua_call | ||
|
||
```c | ||
/** | ||
* Structure to be attached to invite dialog. | ||
* Given a dialog "dlg", application can retrieve this structure | ||
* by accessing dlg->mod_data[pjsua.mod.id]. | ||
*/ | ||
struct pjsua_call | ||
{ | ||
unsigned index; /**< Index in pjsua array. */ | ||
pjsua_call_setting opt; /**< Call setting. */ | ||
pj_bool_t opt_inited;/**< Initial call setting has been set, | ||
to avoid different opt in answer. */ | ||
pjsip_inv_session *inv; /**< The invite session. */ | ||
void *user_data; /**< User/application data. */ | ||
pjsip_status_code last_code; /**< Last status code seen. */ | ||
pj_str_t last_text; /**< Last status text seen. */ | ||
pj_time_val start_time;/**< First INVITE sent/received. */ | ||
pj_time_val res_time; /**< First response sent/received. */ | ||
pj_time_val conn_time; /**< Connected/confirmed time. */ | ||
pj_time_val dis_time; /**< Disconnect time. */ | ||
pjsua_acc_id acc_id; /**< Account index being used. */ | ||
int secure_level;/**< Signaling security level. */ | ||
pjsua_call_hold_type call_hold_type; /**< How to do call hold. */ | ||
pj_bool_t local_hold;/**< Flag for call-hold by local. */ | ||
void *hold_msg; /**< Outgoing hold tx_data. */ | ||
pj_str_t cname; /**< RTCP CNAME. */ | ||
char cname_buf[16];/**< cname buffer. */ | ||
|
||
unsigned med_cnt; /**< Number of media in SDP. */ | ||
pjsua_call_media media[PJSUA_MAX_CALL_MEDIA]; /**< Array of media */ | ||
unsigned med_prov_cnt;/**< Number of provisional media. */ | ||
pjsua_call_media media_prov[PJSUA_MAX_CALL_MEDIA]; | ||
/**< Array of provisional media. */ | ||
pj_bool_t med_update_success; | ||
/**< Is media update successful? */ | ||
pj_bool_t hanging_up;/**< Is call in the process of hangup? */ | ||
|
||
int audio_idx; /**< First active audio media. */ | ||
pj_mutex_t *med_ch_mutex;/**< Media channel callback's mutex. */ | ||
pjsua_med_tp_state_cb med_ch_cb;/**< Media channel callback. */ | ||
pjsua_med_tp_state_info med_ch_info;/**< Media channel info. */ | ||
|
||
pjsip_evsub *xfer_sub; /**< Xfer server subscription, if this | ||
call was triggered by xfer. */ | ||
pj_stun_nat_type rem_nat_type; /**< NAT type of remote endpoint. */ | ||
|
||
char last_text_buf_[128]; /**< Buffer for last_text. */ | ||
|
||
struct { | ||
int retry_cnt; /**< Retry count. */ | ||
} lock_codec; /**< Data for codec locking when answer | ||
contains multiple codecs. */ | ||
|
||
struct { | ||
pjsip_dialog *dlg; /**< Call dialog. */ | ||
pjmedia_sdp_session *rem_sdp;/**< Remote SDP. */ | ||
pj_pool_t *pool_prov;/**< Provisional pool. */ | ||
pj_bool_t med_ch_deinit;/**< Media channel de-init-ed? */ | ||
union { | ||
struct { | ||
pjsua_msg_data *msg_data;/**< Headers for outgoing INVITE. */ | ||
pj_bool_t hangup; /**< Call is hangup? */ | ||
} out_call; | ||
struct { | ||
call_answer answers;/**< A list of call answers. */ | ||
pj_bool_t hangup;/**< Call is hangup? */ | ||
pjsip_dialog *replaced_dlg; /**< Replaced dialog. */ | ||
} inc_call; | ||
} call_var; | ||
} async_call; /**< Temporary storage for async | ||
outgoing/incoming call. */ | ||
|
||
pj_bool_t rem_offerer; /**< Was remote SDP offerer? */ | ||
unsigned rem_aud_cnt; /**< No of active audio in last remote | ||
offer. */ | ||
unsigned rem_vid_cnt; /**< No of active video in last remote | ||
offer. */ | ||
|
||
pj_bool_t rx_reinv_async;/**< on_call_rx_reinvite() async. */ | ||
pj_timer_entry reinv_timer; /**< Reinvite retry timer. */ | ||
pj_bool_t reinv_pending;/**< Pending until CONFIRMED state. */ | ||
pj_bool_t reinv_ice_sent;/**< Has reinvite for ICE upd sent? */ | ||
pjsip_rx_data *incoming_data;/**< Cloned incoming call rdata. | ||
On pjsua2, when handling incoming | ||
call, onCreateMediaTransport() will | ||
not be called since the call isn't | ||
created yet. This temporary | ||
variable is used to handle such | ||
case, see ticket #1916. */ | ||
|
||
struct { | ||
pj_bool_t enabled; | ||
pj_bool_t remote_sup; | ||
pj_bool_t remote_dlg_est; | ||
pjsua_op_state trickling; | ||
int retrans18x_count; | ||
pj_bool_t pending_info; | ||
pj_timer_entry timer; | ||
} trickle_ice; | ||
|
||
pj_timer_entry hangup_timer; /**< Hangup retry timer. */ | ||
unsigned hangup_retry; /**< Number of hangup retries. */ | ||
unsigned hangup_code; /**< Hangup code. */ | ||
pj_str_t hangup_reason; /**< Hangup reason. */ | ||
pjsua_msg_data *hangup_msg_data;/**< Hangup message data. */ | ||
}; | ||
``` | ||
|
||
### pjsua_call_hold_type | ||
|
||
```c | ||
/** | ||
* This enumeration specifies how we should offer call hold request to | ||
* remote peer. The default value is set by compile time constant | ||
* PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting | ||
* on per-account basis by manipulating \a call_hold_type field in | ||
* #pjsua_acc_config. | ||
*/ | ||
typedef enum pjsua_call_hold_type | ||
{ | ||
/** | ||
* This will follow RFC 3264 recommendation to use a=sendonly, | ||
* a=recvonly, and a=inactive attribute as means to signal call | ||
* hold status. This is the correct value to use. | ||
*/ | ||
PJSUA_CALL_HOLD_TYPE_RFC3264, | ||
|
||
/** | ||
* This will use the old and deprecated method as specified in RFC 2543, | ||
* and will offer c=0.0.0.0 in the SDP instead. Using this has many | ||
* drawbacks such as inability to keep the media transport alive while | ||
* the call is being put on hold, and should only be used if remote | ||
* does not understand RFC 3264 style call hold offer. | ||
*/ | ||
PJSUA_CALL_HOLD_TYPE_RFC2543 | ||
|
||
} pjsua_call_hold_type; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
## pjsua_data pjsua_var | ||
|
||
```c | ||
/** | ||
* Global pjsua application data. | ||
*/ | ||
struct pjsua_data | ||
{ | ||
|
||
/* Control: */ | ||
pj_caching_pool cp; /**< Global pool factory. */ | ||
pj_pool_t *pool; /**< pjsua's private pool. */ | ||
pj_pool_t *timer_pool;/**< pjsua's timer pool. */ | ||
pj_mutex_t *mutex; /**< Mutex protection for this data */ | ||
unsigned mutex_nesting_level; /**< Mutex nesting level. */ | ||
pj_thread_t *mutex_owner; /**< Mutex owner. */ | ||
pjsua_state state; /**< Library state. */ | ||
|
||
/* Logging: */ | ||
pjsua_logging_config log_cfg; /**< Current logging config. */ | ||
pj_oshandle_t log_file; /**<Output log file handle */ | ||
|
||
/* SIP: */ | ||
pjsip_endpoint *endpt; /**< Global endpoint. */ | ||
pjsip_module mod; /**< pjsua's PJSIP module. */ | ||
pjsua_transport_data tpdata[8]; /**< Array of transports. */ | ||
pjsip_tp_state_callback old_tp_cb; /**< Old transport callback. */ | ||
|
||
/* Threading: */ | ||
pj_bool_t thread_quit_flag; /**< Thread quit flag. */ | ||
pj_thread_t *thread[4]; /**< Array of threads. */ | ||
|
||
/* STUN and resolver */ | ||
pj_stun_config stun_cfg; /**< Global STUN settings. */ | ||
pj_sockaddr stun_srv; /**< Resolved STUN server address */ | ||
pj_status_t stun_status; /**< STUN server status. */ | ||
pjsua_stun_resolve stun_res; /**< List of pending STUN resolution*/ | ||
unsigned stun_srv_idx; /**< Resolved STUN server index */ | ||
unsigned stun_opt; /**< STUN resolution option. */ | ||
pj_dns_resolver *resolver; /**< DNS resolver. */ | ||
|
||
/* UPnP */ | ||
pj_status_t upnp_status; /**< UPnP status. */ | ||
|
||
/* Detected NAT type */ | ||
pj_stun_nat_type nat_type; /**< NAT type. */ | ||
pj_status_t nat_status; /**< Detection status. */ | ||
pj_bool_t nat_in_progress; /**< Detection in progress */ | ||
|
||
/* List of outbound proxies: */ | ||
pjsip_route_hdr outbound_proxy; | ||
|
||
/* Account: */ | ||
unsigned acc_cnt; /**< Number of accounts. */ | ||
pjsua_acc_id default_acc; /**< Default account ID */ | ||
pjsua_acc acc[PJSUA_MAX_ACC]; /**< Account array. */ | ||
pjsua_acc_id acc_ids[PJSUA_MAX_ACC]; /**< Acc sorted by prio*/ | ||
|
||
/* Calls: */ | ||
pjsua_config ua_cfg; /**< UA config. */ | ||
unsigned call_cnt; /**< Call counter. */ | ||
pjsua_call calls[PJSUA_MAX_CALLS];/**< Calls array. */ | ||
pjsua_call_id next_call_id; /**< Next call id to use*/ | ||
|
||
/* Buddy; */ | ||
unsigned buddy_cnt; /**< Buddy count. */ | ||
pjsua_buddy buddy[PJSUA_MAX_BUDDIES]; /**< Buddy array. */ | ||
|
||
/* Presence: */ | ||
pj_timer_entry pres_timer;/**< Presence refresh timer. */ | ||
|
||
/* Media: */ | ||
pjsua_media_config media_cfg; /**< Media config. */ | ||
pjmedia_endpt *med_endpt; /**< Media endpoint. */ | ||
pjsua_conf_setting mconf_cfg; /**< Additionan conf. bridge. param */ | ||
pjmedia_conf *mconf; /**< Conference bridge. */ | ||
pj_bool_t is_mswitch;/**< Are we using audio switchboard | ||
(a.k.a APS-Direct) */ | ||
|
||
/* Sound device */ | ||
pjmedia_aud_dev_index cap_dev; /**< Capture device ID. */ | ||
pjmedia_aud_dev_index play_dev; /**< Playback device ID. */ | ||
pj_uint32_t aud_svmask;/**< Which settings to save */ | ||
pjmedia_aud_param aud_param; /**< User settings to sound dev */ | ||
pj_bool_t aud_open_cnt;/**< How many # device is opened */ | ||
pj_bool_t no_snd; /**< No sound (app will manage it) */ | ||
pj_pool_t *snd_pool; /**< Sound's private pool. */ | ||
pjmedia_snd_port *snd_port; /**< Sound port. */ | ||
pj_timer_entry snd_idle_timer;/**< Sound device idle timer. */ | ||
pjmedia_master_port *null_snd; /**< Master port for null sound. */ | ||
pjmedia_port *null_port; /**< Null port. */ | ||
pj_bool_t snd_is_on; /**< Media flow is currently active */ | ||
unsigned snd_mode; /**< Sound device mode. */ | ||
|
||
/* Video device */ | ||
pjmedia_vid_dev_index vcap_dev; /**< Capture device ID. */ | ||
pjmedia_vid_dev_index vrdr_dev; /**< Playback device ID. */ | ||
|
||
/* For keeping video device settings */ | ||
#if PJSUA_HAS_VIDEO | ||
pjmedia_vid_conf *vid_conf; | ||
pj_uint32_t vid_caps[PJMEDIA_VID_DEV_MAX_DEVS]; | ||
pjmedia_vid_dev_param vid_param[PJMEDIA_VID_DEV_MAX_DEVS]; | ||
#endif | ||
|
||
/* File players: */ | ||
unsigned player_cnt;/**< Number of file players. */ | ||
pjsua_file_data player[PJSUA_MAX_PLAYERS];/**< Array of players.*/ | ||
|
||
/* File recorders: */ | ||
unsigned rec_cnt; /**< Number of file recorders. */ | ||
pjsua_file_data recorder[PJSUA_MAX_RECORDERS];/**< Array of recs.*/ | ||
|
||
/* Video windows */ | ||
#if PJSUA_HAS_VIDEO | ||
pjsua_vid_win win[PJSUA_MAX_VID_WINS]; /**< Array of windows */ | ||
#endif | ||
|
||
/* Timer entry and event list */ | ||
pjsua_timer_list active_timer_list; | ||
pjsua_timer_list timer_list; | ||
pjsua_event_list event_list; | ||
pj_mutex_t *timer_mutex; | ||
}; | ||
``` | ||
|