From b025abb63a65c3194661038c0b0a7ef4ea950c59 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 8 Oct 2015 14:05:15 +0200 Subject: [PATCH] Fix useless media restart on ICE re-invite. --- coreapi/linphonecall.c | 2 ++ coreapi/private.h | 1 + coreapi/sal.c | 8 ++++---- tester/call_tester.c | 12 ++++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 990fba60d..9cc3eee92 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -3353,6 +3353,8 @@ void linphone_call_start_media_streams(LinphoneCall *call, LinphoneCallState nex ms_fatal("start_media_stream() called without prior init !"); return; } + + call->nb_media_starts++; #if defined(VIDEO_ENABLED) if (vstream!=NULL && vstream->dir!=SalStreamInactive && vstream->payloads!=NULL){ /*when video is used, do not make adaptive rate control on audio, it is stupid.*/ diff --git a/coreapi/private.h b/coreapi/private.h index 66cf24a64..860143fbc 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -302,6 +302,7 @@ struct _LinphoneCall{ int localdesc_changed;/*not a boolean, contains a mask representing changes*/ LinphonePlayer *player; unsigned long bg_task_id; /*used to prevent device to suspend app while a call is received in background*/ + unsigned int nb_media_starts; char *dtmf_sequence; /*DTMF sequence needed to be sent using #dtmfs_timer*/ belle_sip_source_t *dtmfs_timer; /*DTMF timer needed to send a DTMF sequence*/ diff --git a/coreapi/sal.c b/coreapi/sal.c index 10fcc44d5..7698e80b1 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -328,8 +328,8 @@ int sal_stream_description_equals(const SalStreamDescription *sd1, const SalStre if (sd1->dir != sd2->dir) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; /* ICE */ - if (sd1->ice_ufrag != sd2->ice_ufrag) result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED; - if (sd1->ice_pwd != sd2->ice_pwd) result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED; + if (strcmp(sd1->ice_ufrag, sd2->ice_ufrag) != 0) result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED; + if (strcmp(sd1->ice_pwd, sd2->ice_pwd) != 0) result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED; /*DTLS*/ if (sd1->dtls_role != sd2->dtls_role) result |= SAL_MEDIA_DESCRIPTION_CRYPTO_KEYS_CHANGED; @@ -390,8 +390,8 @@ int sal_media_description_equals(const SalMediaDescription *md1, const SalMediaD if (md1->bandwidth != md2->bandwidth) result |= SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; /* ICE */ - if (md1->ice_ufrag != md2->ice_ufrag) result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED; - if (md1->ice_pwd != md2->ice_pwd) result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED; + if (strcmp(md1->ice_ufrag, md2->ice_ufrag) != 0) result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED; + if (strcmp(md1->ice_pwd, md2->ice_pwd) != 0) result |= SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED; for(i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; ++i){ if (!sal_stream_description_active(&md1->streams[i]) && !sal_stream_description_active(&md2->streams[i])) continue; diff --git a/tester/call_tester.c b/tester/call_tester.c index 29edbcb6b..9913d22a6 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -1087,11 +1087,23 @@ static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager return; if (callee_with_ice && caller_with_ice) { + LinphoneCall *c1, *c2; + /*wait for the ICE reINVITE to complete*/ BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); BC_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection)); + c1 = linphone_core_get_current_call(pauline->lc); + c2 = linphone_core_get_current_call(marie->lc); + BC_ASSERT_PTR_NOT_NULL(c1); + BC_ASSERT_PTR_NOT_NULL(c2); + if (c1) { + BC_ASSERT_EQUAL(c1->nb_media_starts, 1, unsigned int, "%u"); + } + if (c2) { + BC_ASSERT_EQUAL(c2->nb_media_starts, 1, unsigned int, "%u"); + } } liblinphone_tester_check_rtcp(marie,pauline);