Commit a33fb9dc authored by Simon Morlat's avatar Simon Morlat

allow UDP retransmissions to be stopped in case a call is cancelled.

parent f4b127d9
......@@ -83,6 +83,12 @@ BELLESIP_EXPORT belle_sip_refresher_t* belle_sip_client_transaction_create_refre
* */
BELLESIP_EXPORT belle_sip_request_t* belle_sip_client_transaction_create_authenticated_request(belle_sip_client_transaction_t *t,belle_sip_list_t** auth_infos,const char* realm);
/**
* For transactions over unreliable transports, stop retransmissions. This avoids for example to keep sending INVITE retransmissions of a call that has just been terminated, while
* keeping the transaction alive in order to eventually let a response being handled, so that the transaction can be cancelled properly.
**/
BELLESIP_EXPORT void belle_sip_client_transaction_stop_retransmissions(belle_sip_client_transaction_t *t);
#define BELLE_SIP_TRANSACTION(t) BELLE_SIP_CAST(t,belle_sip_transaction_t)
#define BELLE_SIP_SERVER_TRANSACTION(t) BELLE_SIP_CAST(t,belle_sip_server_transaction_t)
#define BELLE_SIP_CLIENT_TRANSACTION(t) BELLE_SIP_CAST(t,belle_sip_client_transaction_t)
......
......@@ -725,6 +725,7 @@ struct belle_sip_client_transaction{
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_client_transaction_t,belle_sip_transaction_t)
void (*send_request)(belle_sip_client_transaction_t *);
void (*on_response)(belle_sip_client_transaction_t *obj, belle_sip_response_t *resp);
void (*stop_retransmissions)(belle_sip_client_transaction_t *obj);
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
void belle_sip_client_transaction_init(belle_sip_client_transaction_t *obj, belle_sip_provider_t *prov, belle_sip_request_t *req);
......
......@@ -173,6 +173,15 @@ static int ict_on_timer_B(belle_sip_ict_t *obj){
return BELLE_SIP_STOP;
}
static void ict_stop_retransmissions(belle_sip_ict_t *obj){
belle_sip_transaction_t *base=(belle_sip_transaction_t*)obj;
belle_sip_message("ICT retransmissions stopped");
if (obj->timer_A){
belle_sip_transaction_stop_timer(base,obj->timer_A);
belle_sip_object_unref(obj->timer_A);
obj->timer_A=NULL;
}
}
static void ict_send_request(belle_sip_ict_t *obj){
belle_sip_transaction_t *base=(belle_sip_transaction_t*)obj;
......@@ -206,7 +215,8 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_ict_t)
(void (*)(belle_sip_transaction_t*))on_ict_terminate
},
(void (*)(belle_sip_client_transaction_t*))ict_send_request,
(void (*)(belle_sip_client_transaction_t*,belle_sip_response_t*))ict_on_response
(void (*)(belle_sip_client_transaction_t*,belle_sip_response_t*))ict_on_response,
(void (*)(belle_sip_client_transaction_t*))ict_stop_retransmissions
}
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_END
......
......@@ -126,6 +126,15 @@ static int nict_on_timer_E(belle_sip_nict_t *obj){
return BELLE_SIP_CONTINUE;
}
static void nict_stop_retransmissions(belle_sip_nict_t *obj){
belle_sip_transaction_t *base=(belle_sip_transaction_t*)obj;
if (obj->timer_E){
belle_sip_transaction_stop_timer(base,obj->timer_E);
belle_sip_object_unref(obj->timer_E);
obj->timer_E=NULL;
}
}
static void nict_send_request(belle_sip_nict_t *obj){
belle_sip_transaction_t *base=(belle_sip_transaction_t*)obj;
const belle_sip_timer_config_t *cfg=belle_sip_transaction_get_timer_config(base);
......@@ -163,7 +172,8 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_nict_t)
(void (*)(belle_sip_transaction_t *))nict_on_terminate
},
(void (*)(belle_sip_client_transaction_t*))nict_send_request,
(void (*)(belle_sip_client_transaction_t*,belle_sip_response_t*))nict_on_response
(void (*)(belle_sip_client_transaction_t*,belle_sip_response_t*))nict_on_response,
(void (*)(belle_sip_client_transaction_t*))nict_stop_retransmissions
}
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_END
......
......@@ -638,6 +638,7 @@ BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_BEGIN(belle_sip_client_transaction_t)
NULL
},
NULL,
NULL,
NULL
BELLE_SIP_INSTANCIATE_CUSTOM_VPTR_END
......@@ -732,6 +733,9 @@ int belle_sip_client_transaction_is_notify_matching_pending_subscribe(belle_sip_
return strcmp(belle_sip_header_call_id_get_call_id(sub_call_id),belle_sip_header_call_id_get_call_id(notif_call_id))==0
&& sub_from_tag && notif_to_tag && strcmp(sub_from_tag,notif_to_tag)==0
&& strcasecmp(belle_sip_header_event_get_package_name(sub_event),belle_sip_header_event_get_package_name(notif_event))==0;
}
void belle_sip_client_transaction_stop_retransmissions(belle_sip_client_transaction_t *t){
BELLE_SIP_OBJECT_VPTR(t,belle_sip_client_transaction_t)->stop_retransmissions(t);
}
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