linphone_core_add_call(lc,call);
linphone_call_ref(call); /*prevent the call from being destroyed while we are notifying, if the user declines within the state callback */
- if (linphone_core_get_firewall_policy(lc) == LinphonePolicyUseIce) {
+ if ((linphone_core_get_firewall_policy(lc) == LinphonePolicyUseIce) && sal_op_get_ice_session(call->op)) {
/* Defer ringing until the end of the ICE candidates gathering process. */
ms_message("Defer ringing to gather ICE candidates");
return;
static void call_accepted(SalOp *op){
LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
+ IceSession *ice_session=sal_op_get_ice_session(op);
SalMediaDescription *md;
if (call==NULL){
ms_warning("No call to accept.");
return ;
}
-
+
+ if (ice_session == NULL) {
+ /* Ensure the ICE check list pointers for the call streams are resetted to prevent crashes */
+ if (call->audiostream != NULL) call->audiostream->ice_check_list = NULL;
+ if (call->videostream != NULL) call->videostream->ice_check_list = NULL;
+ }
+
md=sal_call_get_final_media_description(op);
if (call->state==LinphoneCallOutgoingProgress ||
linphone_call_start_media_streams_for_ice_gathering(call);
if (linphone_core_gather_ice_candidates(call->core,call)<0) {
/* Ice candidates gathering failed, proceed with the call anyway. */
- ice_session_destroy(sal_op_get_ice_session(call->op));
- sal_op_set_ice_session(call->op, NULL);
+ linphone_call_delete_ice_session(call);
linphone_call_stop_media_streams(call);
}
break;
/* No break to also destroy ice session in this case. */
default:
if (sal_op_get_ice_session(call->op) != NULL) {
- ice_session_destroy(sal_op_get_ice_session(call->op));
- sal_op_set_ice_session(call->op, NULL);
+ linphone_call_delete_ice_session(call);
}
break;
}
}
}
+void linphone_call_delete_ice_session(LinphoneCall *call){
+ IceSession *ice_session = sal_op_get_ice_session(call->op);
+ if (ice_session != NULL) {
+ ice_session_destroy(ice_session);
+ sal_op_set_ice_session(call->op, NULL);
+ if (call->audiostream != NULL) call->audiostream->ice_check_list = NULL;
+ if (call->videostream != NULL) call->videostream->ice_check_list = NULL;
+ }
+}
+
static void linphone_call_log_fill_stats(LinphoneCallLog *log, AudioStream *st){
audio_stream_get_local_rtp_stats (st,&log->local_stats);
log->quality=audio_stream_get_average_quality_rating(st);
void linphone_call_stop_media_streams(LinphoneCall *call){
if (call->audiostream!=NULL) {
+ call->audiostream->ice_check_list = NULL;
rtp_session_unregister_event_queue(call->audiostream->session,call->audiostream_app_evq);
ortp_ev_queue_flush(call->audiostream_app_evq);
ortp_ev_queue_destroy(call->audiostream_app_evq);
#ifdef VIDEO_ENABLED
if (call->videostream!=NULL){
+ call->videostream->ice_check_list = NULL;
rtp_session_unregister_event_queue(call->videostream->session,call->videostream_app_evq);
ortp_ev_queue_flush(call->videostream_app_evq);
ortp_ev_queue_destroy(call->videostream_app_evq);
+ call->videostream_app_evq=NULL;
video_stream_stop(call->videostream);
call->videostream=NULL;
}
ice_session_eliminate_redundant_candidates(ice_session);
ice_session_choose_default_candidates(ice_session);
} else {
- ice_session_destroy(ice_session);
- sal_op_set_ice_session(call->op, NULL);
+ linphone_call_delete_ice_session(call);
}
if (call->state==LinphoneCallOutgoingInit) {
linphone_core_start_invite(call->core,call,NULL);
ice_session_eliminate_redundant_candidates(ice_session);
ice_session_choose_default_candidates(ice_session);
} else {
- ice_session_destroy(sal_op_get_ice_session(call->op));
- sal_op_set_ice_session(call->op, NULL);
+ linphone_call_delete_ice_session(call);
}
if (call->state==LinphoneCallOutgoingInit) {
linphone_core_start_invite(call->core,call,NULL);
/*start the call even if the OPTIONS reply did not arrive*/
if (sal_op_get_ice_session(call->op) != NULL) {
/* ICE candidates gathering has not finished yet, proceed with the call without ICE anyway. */
- ice_session_destroy(sal_op_get_ice_session(call->op));
- sal_op_set_ice_session(call->op, NULL);
+ linphone_call_delete_ice_session(call);
linphone_call_stop_media_streams(call);
}
linphone_core_start_invite(lc,call,NULL);
call->start_time=time(NULL);
if (linphone_core_gather_ice_candidates(lc,call)<0) {
/* Ice candidates gathering failed, proceed with the call anyway. */
- ice_session_destroy(sal_op_get_ice_session(call->op));
- sal_op_set_ice_session(call->op, NULL);
+ linphone_call_delete_ice_session(call);
linphone_call_stop_media_streams(call);
} else {
if (real_url!=NULL) ms_free(real_url);