Commit e1867cbe authored by Simon Morlat's avatar Simon Morlat
Browse files

fix crash in SAL, because of late 180/200 response arriving once the call is cancelled.

parent 6594a22d
...@@ -63,12 +63,12 @@ int lc_callback_obj_invoke(LCCallbackObj *obj, LinphoneCore *lc){ ...@@ -63,12 +63,12 @@ int lc_callback_obj_invoke(LCCallbackObj *obj, LinphoneCore *lc){
} }
static MSList *make_codec_list(const MSList *codecs, bool_t only_one_codec){ static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, bool_t only_one_codec){
MSList *l=NULL; MSList *l=NULL;
const MSList *it; const MSList *it;
for(it=codecs;it!=NULL;it=it->next){ for(it=codecs;it!=NULL;it=it->next){
PayloadType *pt=(PayloadType*)it->data; PayloadType *pt=(PayloadType*)it->data;
if (pt->flags & PAYLOAD_TYPE_ENABLED){ if ((pt->flags & PAYLOAD_TYPE_ENABLED) && linphone_core_check_payload_type_usability(lc,pt)){
l=ms_list_append(l,payload_type_clone(pt)); l=ms_list_append(l,payload_type_clone(pt));
if (only_one_codec) break; if (only_one_codec) break;
} }
...@@ -90,7 +90,7 @@ static SalMediaDescription *create_local_media_description(LinphoneCore *lc, ...@@ -90,7 +90,7 @@ static SalMediaDescription *create_local_media_description(LinphoneCore *lc,
md->streams[0].proto=SalProtoRtpAvp; md->streams[0].proto=SalProtoRtpAvp;
md->streams[0].type=SalAudio; md->streams[0].type=SalAudio;
md->streams[0].ptime=lc->net_conf.down_ptime; md->streams[0].ptime=lc->net_conf.down_ptime;
l=make_codec_list(lc->codecs_conf.audio_codecs,only_one_codec); l=make_codec_list(lc,lc->codecs_conf.audio_codecs,only_one_codec);
pt=payload_type_clone(rtp_profile_get_payload_from_mime(&av_profile,"telephone-event")); pt=payload_type_clone(rtp_profile_get_payload_from_mime(&av_profile,"telephone-event"));
l=ms_list_append(l,pt); l=ms_list_append(l,pt);
md->streams[0].payloads=l; md->streams[0].payloads=l;
...@@ -103,7 +103,7 @@ static SalMediaDescription *create_local_media_description(LinphoneCore *lc, ...@@ -103,7 +103,7 @@ static SalMediaDescription *create_local_media_description(LinphoneCore *lc,
md->streams[1].port=linphone_core_get_video_port(lc); md->streams[1].port=linphone_core_get_video_port(lc);
md->streams[1].proto=SalProtoRtpAvp; md->streams[1].proto=SalProtoRtpAvp;
md->streams[1].type=SalVideo; md->streams[1].type=SalVideo;
l=make_codec_list(lc->codecs_conf.video_codecs,only_one_codec); l=make_codec_list(lc,lc->codecs_conf.video_codecs,only_one_codec);
md->streams[1].payloads=l; md->streams[1].payloads=l;
if (lc->dw_video_bw) if (lc->dw_video_bw)
md->streams[1].bandwidth=lc->dw_video_bw; md->streams[1].bandwidth=lc->dw_video_bw;
......
...@@ -276,6 +276,12 @@ bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType ...@@ -276,6 +276,12 @@ bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType
case PAYLOAD_AUDIO_PACKETIZED: case PAYLOAD_AUDIO_PACKETIZED:
codec_band=get_audio_payload_bandwidth(lc,pt); codec_band=get_audio_payload_bandwidth(lc,pt);
ret=bandwidth_is_greater(min_audio_bw*1000,codec_band); ret=bandwidth_is_greater(min_audio_bw*1000,codec_band);
/*hack to avoid using uwb codecs when having low bitrate and video*/
if (bandwidth_is_greater(199,min_audio_bw)){
if (linphone_core_video_enabled(lc) && pt->clock_rate>16000){
ret=FALSE;
}
}
//ms_message("Payload %s: %g",pt->mime_type,codec_band); //ms_message("Payload %s: %g",pt->mime_type,codec_band);
break; break;
case PAYLOAD_VIDEO: case PAYLOAD_VIDEO:
......
...@@ -593,6 +593,16 @@ static void set_network_origin(SalOp *op, osip_message_t *req){ ...@@ -593,6 +593,16 @@ static void set_network_origin(SalOp *op, osip_message_t *req){
__sal_op_set_network_origin(op,origin); __sal_op_set_network_origin(op,origin);
} }
static SalOp *find_op(Sal *sal, eXosip_event_t *ev){
if (ev->cid>0)
return (SalOp*)eXosip_call_get_reference(ev->cid);;
if (ev->rid>0){
return sal_find_register(sal,ev->rid);
}
if (ev->response) return sal_find_other(sal,ev->response);
return NULL;
}
static void inc_new_call(Sal *sal, eXosip_event_t *ev){ static void inc_new_call(Sal *sal, eXosip_event_t *ev){
SalOp *op=sal_op_new(sal); SalOp *op=sal_op_new(sal);
osip_from_t *from,*to; osip_from_t *from,*to;
...@@ -626,7 +636,7 @@ static void inc_new_call(Sal *sal, eXosip_event_t *ev){ ...@@ -626,7 +636,7 @@ static void inc_new_call(Sal *sal, eXosip_event_t *ev){
} }
static void handle_reinvite(Sal *sal, eXosip_event_t *ev){ static void handle_reinvite(Sal *sal, eXosip_event_t *ev){
SalOp *op=(SalOp*)ev->external_reference; SalOp *op=find_op(sal,ev);
sdp_message_t *sdp; sdp_message_t *sdp;
osip_message_t *msg=NULL; osip_message_t *msg=NULL;
...@@ -669,7 +679,7 @@ static void handle_reinvite(Sal *sal, eXosip_event_t *ev){ ...@@ -669,7 +679,7 @@ static void handle_reinvite(Sal *sal, eXosip_event_t *ev){
} }
static void handle_ack(Sal *sal, eXosip_event_t *ev){ static void handle_ack(Sal *sal, eXosip_event_t *ev){
SalOp *op=(SalOp*)ev->external_reference; SalOp *op=find_op(sal,ev);
sdp_message_t *sdp; sdp_message_t *sdp;
if (op==NULL) { if (op==NULL) {
...@@ -714,7 +724,7 @@ static void update_contact_from_response(SalOp *op, osip_message_t *response){ ...@@ -714,7 +724,7 @@ static void update_contact_from_response(SalOp *op, osip_message_t *response){
} }
static int call_proceeding(Sal *sal, eXosip_event_t *ev){ static int call_proceeding(Sal *sal, eXosip_event_t *ev){
SalOp *op=(SalOp*)ev->external_reference; SalOp *op=find_op(sal,ev);
if (op==NULL) { if (op==NULL) {
ms_warning("This call has been canceled."); ms_warning("This call has been canceled.");
...@@ -750,10 +760,9 @@ static void call_ringing(Sal *sal, eXosip_event_t *ev){ ...@@ -750,10 +760,9 @@ static void call_ringing(Sal *sal, eXosip_event_t *ev){
static void call_accepted(Sal *sal, eXosip_event_t *ev){ static void call_accepted(Sal *sal, eXosip_event_t *ev){
sdp_message_t *sdp; sdp_message_t *sdp;
osip_message_t *msg=NULL; osip_message_t *msg=NULL;
SalOp *op; SalOp *op=find_op(sal,ev);
const char *contact; const char *contact;
op=(SalOp*)ev->external_reference;
if (op==NULL){ if (op==NULL){
ms_error("A closed call is accepted ?"); ms_error("A closed call is accepted ?");
return; return;
...@@ -778,9 +787,8 @@ static void call_accepted(Sal *sal, eXosip_event_t *ev){ ...@@ -778,9 +787,8 @@ static void call_accepted(Sal *sal, eXosip_event_t *ev){
} }
static void call_terminated(Sal *sal, eXosip_event_t *ev){ static void call_terminated(Sal *sal, eXosip_event_t *ev){
SalOp *op;
char *from; char *from;
op=(SalOp*)ev->external_reference; SalOp *op=find_op(sal,ev);
if (op==NULL){ if (op==NULL){
ms_warning("Call terminated for already closed call ?"); ms_warning("Call terminated for already closed call ?");
return; return;
...@@ -793,8 +801,7 @@ static void call_terminated(Sal *sal, eXosip_event_t *ev){ ...@@ -793,8 +801,7 @@ static void call_terminated(Sal *sal, eXosip_event_t *ev){
} }
static void call_released(Sal *sal, eXosip_event_t *ev){ static void call_released(Sal *sal, eXosip_event_t *ev){
SalOp *op; SalOp *op=find_op(sal,ev);
op=(SalOp*)ev->external_reference;
if (op==NULL){ if (op==NULL){
return; return;
} }
...@@ -857,16 +864,6 @@ int sal_op_get_auth_requested(SalOp *op, const char **realm, const char **userna ...@@ -857,16 +864,6 @@ int sal_op_get_auth_requested(SalOp *op, const char **realm, const char **userna
return -1; return -1;
} }
static SalOp *find_op(Sal *sal, eXosip_event_t *ev){
if (ev->external_reference)
return (SalOp*)ev->external_reference;
if (ev->rid>0){
return sal_find_register(sal,ev->rid);
}
if (ev->response) return sal_find_other(sal,ev->response);
return NULL;
}
static bool_t process_authentication(Sal *sal, eXosip_event_t *ev){ static bool_t process_authentication(Sal *sal, eXosip_event_t *ev){
SalOp *op; SalOp *op;
const char *username,*realm; const char *username,*realm;
......
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