From 7acf1678c036b771ac1277adc1f50653bbdf9670 Mon Sep 17 00:00:00 2001 From: smorlat Date: Tue, 13 Jan 2009 21:42:52 +0000 Subject: [PATCH] fix bug with aborted calls. git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@235 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/coreapi/exevents.c | 27 ++++++++++++++++++++++----- linphone/oRTP/src/tests/rtpsend.c | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/linphone/coreapi/exevents.c b/linphone/coreapi/exevents.c index 5de760e7b..a3b23a356 100644 --- a/linphone/coreapi/exevents.c +++ b/linphone/coreapi/exevents.c @@ -27,9 +27,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static int linphone_answer_sdp(LinphoneCore *lc, eXosip_event_t *ev, sdp_message_t *sdp); +static bool_t linphone_call_matches_event(LinphoneCall *call, eXosip_event_t *ev){ + return call->cid==ev->cid; +} + static void linphone_call_proceeding(LinphoneCore *lc, eXosip_event_t *ev){ - if (lc->call==NULL){ - ms_warning("Bug in call_proceeding()"); + if (lc->call==NULL || (lc->call->cid!=-1 && !linphone_call_matches_event(lc->call,ev)) ) { + ms_warning("This call has been canceled."); + eXosip_lock(); + eXosip_call_terminate(ev->cid,ev->did); + eXosip_unlock(); return; } lc->call->cid=ev->cid; @@ -65,6 +72,7 @@ int linphone_call_accepted(LinphoneCore *lc, eXosip_event_t *ev) return 0; } linphone_call_proceeding(lc,ev); + if (!linphone_call_matches_event(lc->call,ev)) return 0; call->auth_pending=FALSE; if (call->state==LCStateAVRunning){ return 0; /*already accepted*/ @@ -154,6 +162,15 @@ int linphone_call_failure(LinphoneCore *lc, eXosip_event_t *ev) char *msg603=_("Call declined."); char* tmpmsg=msg486; int code; + LinphoneCall *call=lc->call; + + if (call){ + /*check that the faillure is related to this call, not an old one*/ + if (!linphone_call_matches_event(call,ev)) { + ms_warning("Failure reported for an old call."); + return 0; + } + } if (ev->response){ code=osip_message_get_status_code(ev->response); @@ -220,8 +237,8 @@ int linphone_call_failure(LinphoneCore *lc, eXosip_event_t *ev) lc->ringstream=NULL; } linphone_core_stop_media_streams(lc); - if (lc->call!=NULL) { - linphone_call_destroy(lc->call); + if (call!=NULL) { + linphone_call_destroy(call); gstate_new_state(lc, GSTATE_CALL_ERROR, NULL); lc->call=NULL; } @@ -807,7 +824,7 @@ void linphone_call_ringing(LinphoneCore *lc, eXosip_event_t *ev){ LinphoneCall *call=lc->call; linphone_call_proceeding(lc,ev); - + if (call==NULL) return; if (sdp==NULL){ if (lc->ringstream!=NULL) return; /*already ringing !*/ if (lc->sound_conf.play_sndcard!=NULL){ diff --git a/linphone/oRTP/src/tests/rtpsend.c b/linphone/oRTP/src/tests/rtpsend.c index d3fd0723a..d1fefe830 100644 --- a/linphone/oRTP/src/tests/rtpsend.c +++ b/linphone/oRTP/src/tests/rtpsend.c @@ -34,7 +34,7 @@ void stophandler(int signum) runcond=0; } -static char *help="usage: rtpsend filename dest_ip4addr dest_port [ --with-clockslide ] [ --with-jitter ]\n"; +static const char *help="usage: rtpsend filename dest_ip4addr dest_port [ --with-clockslide ] [ --with-jitter ]\n"; int main(int argc, char *argv[]) {