Commit a9716fe6 authored by Pekka Pessi's avatar Pekka Pessi
Browse files

Added separate nua_i_ack event. Generating it after ACK is received.

darcs-hash:20051010163849-65a35-4b5a970377c1cdb6c45de6ad402b17a714e7d488.gz
parent 00669681
......@@ -74,11 +74,12 @@ typedef enum nua_event_e {
nua_i_error, /**< Error indication */
nua_i_invite, /**< Incoming call */
nua_i_cancel, /**< Incoming INVITE has been cancelled */
nua_i_ack, /**< Response to INVITE has been ACKed */
nua_i_fork, /**< Outgoing call has been forked */
nua_i_active, /**< A call has been activated */
nua_i_terminated, /**< A call has been terminated */
nua_i_state, /**< Call state has changed */
nua_i_cancel, /**< Incoming INVITE has been cancelled */
nua_i_bye, /**< Incoming call hangup */
nua_i_options, /**< Incoming options */
......
......@@ -176,11 +176,13 @@ char const *nua_event_name(nua_event_t event)
switch (event) {
case nua_i_error: return "nua_i_error";
case nua_i_invite: return "nua_i_invite";
case nua_i_cancel: return "nua_i_cancel";
case nua_i_ack: return "nua_i_ack";
case nua_i_fork: return "nua_i_fork";
case nua_i_active: return "nua_i_active";
case nua_i_terminated: return "nua_i_terminated";
case nua_i_state: return "nua_i_state";
case nua_i_cancel: return "nua_i_cancel";
case nua_i_bye: return "nua_i_bye";
case nua_i_options: return "nua_i_options";
......
......@@ -3557,8 +3557,6 @@ static int process_response_to_invite(nua_handle_t *nh,
}
else if (status >= 200) {
ss->ss_state = nua_callstate_ready;
ss->ss_ack_needed = 1;
du->du_ready = 1;
if (!ss->ss_usage)
ss->ss_usage = du;
......@@ -3575,10 +3573,13 @@ static int process_response_to_invite(nua_handle_t *nh,
/* signal_call_state_change */
if (session_process_response(nh, cr, orq, sip, &received) >= 0) {
signal_call_state_change(nh, status, phrase,
nua_callstate_ready, received, 0);
ss->ss_ack_needed = received ? received : "";
if (NH_PGET(nh, auto_ack))
ua_ack(nua, nh, NULL);
else
signal_call_state_change(nh, status, phrase,
nua_callstate_completing, received, 0);
nh_referral_respond(nh, SIP_200_OK);
return 0;
}
......@@ -3608,19 +3609,22 @@ static int process_response_to_invite(nua_handle_t *nh,
nh_referral_respond(nh, status, phrase);
process_response(nh, cr, orq, sip, TAG_END());
if (terminated)
signal_call_state_change(nh, status, phrase,
nua_callstate_terminated, 0, 0);
if (terminated < 0) {
signal_call_state_change(nh, status, phrase, nua_callstate_terminated, 0, 0);
dialog_terminated(nh, nh->nh_ds, status, phrase);
}
else if (terminated > 0) {
signal_call_state_change(nh, status, phrase, nua_callstate_terminated, 0, 0);
dialog_usage_remove(nh, nh->nh_ds, du);
}
else if (gracefully) {
char *reason =
su_sprintf(NULL, "SIP;cause=%u;text=\"%s\"", status, phrase);
signal_call_state_change(nh, status, phrase, nua_callstate_terminating, 0, 0);
signal_call_state_change(nh, status, phrase,
nua_callstate_terminating, 0, 0);
stack_signal(nh, nua_r_bye, SIPTAG_REASON_STR(reason), TAG_END());
......@@ -3639,12 +3643,16 @@ int ua_ack(nua_t *nua, nua_handle_t *nh, tagi_t const *tags)
sip_t *sip;
int status = 200;
char const *phrase = "OK", *reason = NULL, *sent = NULL;
char const *received = ss->ss_ack_needed;
if (!ss->ss_ack_needed)
return UA_EVENT2(nua_i_error, 500, "No response to ACK");
ss->ss_ack_needed = 0;
if (!received[0])
received = NULL;
if (tags)
ua_set_params(nua, nh, nua_r_ack, tags);
......@@ -3699,7 +3707,8 @@ int ua_ack(nua_t *nua, nua_handle_t *nh, tagi_t const *tags)
nta_outgoing_destroy(ack); /* Timer keeps this around for T2 */
if (status < 300) {
signal_call_state_change(nh, status, phrase, nua_callstate_ready, 0, sent);
signal_call_state_change(nh, status, phrase, nua_callstate_ready,
received, sent);
}
else {
signal_call_state_change(nh, status, phrase, nua_callstate_terminating, 0, 0);
......@@ -4412,10 +4421,10 @@ int process_ack(nua_handle_t *nh,
{
struct nua_session_state *ss = nh->nh_ss;
nua_server_request_t *sr = ss->ss_srequest;
msg_t *msg = nta_incoming_getrequest(irq);
char const *recv = NULL;
if (nh->nh_soa && sr->sr_offer_sent && !sr->sr_answer_recv) {
msg_t *msg = nta_incoming_getrequest(irq);
char const *sdp;
int len;
......@@ -4429,6 +4438,8 @@ int process_ack(nua_handle_t *nh,
status = soa_error_as_sip_response(nh->nh_soa, &phrase);
reason = soa_error_as_sip_reason(nh->nh_soa);
ua_event(nh->nh_nua, nh, NULL,
nua_i_ack, status, phrase, TAG_END());
ua_event(nh->nh_nua, nh, NULL,
nua_i_media_error, status, phrase, TAG_END());
......@@ -4440,12 +4451,14 @@ int process_ack(nua_handle_t *nh,
return 0;
}
msg_destroy(msg);
}
soa_clear_remote_sdp(nh->nh_soa);
ua_event(nh->nh_nua, nh, msg, nua_i_ack, SIP_200_OK, TAG_END());
msg_destroy(msg);
signal_call_state_change(nh, 200, "OK", nua_callstate_ready, recv, 0);
set_session_timer(nh);
......
......@@ -220,7 +220,6 @@ typedef struct nua_session_state
unsigned ss_100rel:1; /**< Use 100rel, send 183 */
unsigned ss_alerting:1; /**< 180 is sent/received */
unsigned ss_ack_needed:2; /**< Send an ACK (do O/A, if >1) */
unsigned ss_update_needed:2; /**< Send an UPDATE (do O/A if > 1) */
unsigned ss_precondition:1; /**< Precondition required */
......@@ -233,6 +232,10 @@ typedef struct nua_session_state
unsigned ss_min_se; /**< Minimum session expires */
enum nua_session_refresher ss_refresher; /**< none, local or remote */
char const *ss_ack_needed; /**< Send an ACK
* (do O/A, if "offer" or "answer")
*/
nua_dialog_usage_t *ss_usage;
/* Outgoing invite */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment