From ad1d7c12c9b459660b34d63408b144bf5890f3b6 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 2 Jun 2015 17:49:55 +0200 Subject: [PATCH] Fix ZRTP conference --- coreapi/callbacks.c | 11 ++++++---- include/sal/sal.h | 22 ++++++++------------ tester/multi_call_tester.c | 42 ++++++++++++++++++++++++++++++-------- 3 files changed, 49 insertions(+), 26 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 393bbd350..556ecaac3 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -35,10 +35,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void register_failure(SalOp *op); static int media_parameters_changed(LinphoneCall *call, SalMediaDescription *oldmd, SalMediaDescription *newmd) { - if (call->params->in_conference != call->current_params->in_conference) return SAL_MEDIA_DESCRIPTION_CHANGED; - if (call->up_bw != linphone_core_get_upload_bandwidth(call->core)) return SAL_MEDIA_DESCRIPTION_CHANGED; + int result=0; + if (call->params->in_conference != call->current_params->in_conference) return SAL_MEDIA_DESCRIPTION_FORCE_STREAM_RECONSTRUCTION; + if (call->up_bw != linphone_core_get_upload_bandwidth(call->core)) return SAL_MEDIA_DESCRIPTION_FORCE_STREAM_RECONSTRUCTION; if (call->localdesc_changed) ms_message("Local description has changed: %i", call->localdesc_changed); - return call->localdesc_changed | sal_media_description_equals(oldmd, newmd); + result = call->localdesc_changed | sal_media_description_equals(oldmd, newmd); + return result; } void linphone_core_update_streams_destinations(LinphoneCore *lc, LinphoneCall *call, SalMediaDescription *old_md, SalMediaDescription *new_md) { @@ -152,7 +154,8 @@ void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMedia md_changed = media_parameters_changed(call, oldmd, new_md); if ((md_changed & ( SAL_MEDIA_DESCRIPTION_CODEC_CHANGED |SAL_MEDIA_DESCRIPTION_STREAMS_CHANGED - |SAL_MEDIA_DESCRIPTION_NETWORK_XXXCAST_CHANGED))){ + |SAL_MEDIA_DESCRIPTION_NETWORK_XXXCAST_CHANGED + |SAL_MEDIA_DESCRIPTION_FORCE_STREAM_RECONSTRUCTION ))){ ms_message("Media descriptions are different, need to restart the streams."); } else if ( call->playing_ringbacktone) { ms_message("Playing ringback tone, will restart the streams."); diff --git a/include/sal/sal.h b/include/sal/sal.h index ac0aed989..6ba8554d3 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -68,20 +68,16 @@ typedef enum { SalTransportDTLS, /*DTLS*/ }SalTransport; -#define SAL_MEDIA_DESCRIPTION_UNCHANGED 0x00 -#define SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED (1) -#define SAL_MEDIA_DESCRIPTION_CODEC_CHANGED (1<<1) -#define SAL_MEDIA_DESCRIPTION_CRYPTO_KEYS_CHANGED (1<<2) -#define SAL_MEDIA_DESCRIPTION_CRYPTO_POLICY_CHANGED (1<<3) -#define SAL_MEDIA_DESCRIPTION_STREAMS_CHANGED (1<<4) -#define SAL_MEDIA_DESCRIPTION_NETWORK_XXXCAST_CHANGED (1<<5) /* use to notify when switching from multicast to unicast*/ +#define SAL_MEDIA_DESCRIPTION_UNCHANGED 0x00 +#define SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED (1) +#define SAL_MEDIA_DESCRIPTION_CODEC_CHANGED (1<<1) +#define SAL_MEDIA_DESCRIPTION_CRYPTO_KEYS_CHANGED (1<<2) +#define SAL_MEDIA_DESCRIPTION_CRYPTO_POLICY_CHANGED (1<<3) +#define SAL_MEDIA_DESCRIPTION_STREAMS_CHANGED (1<<4) +#define SAL_MEDIA_DESCRIPTION_NETWORK_XXXCAST_CHANGED (1<<5) /* use to notify when switching from multicast to unicast*/ +#define SAL_MEDIA_DESCRIPTION_FORCE_STREAM_RECONSTRUCTION (1<<6) /* use force graph reconstruction*/ + -#define SAL_MEDIA_DESCRIPTION_CHANGED (SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED \ - |SAL_MEDIA_DESCRIPTION_CODEC_CHANGED \ - |SAL_MEDIA_DESCRIPTION_CRYPTO_KEYS_CHANGED \ - |SAL_MEDIA_DESCRIPTION_CRYPTO_POLICY_CHANGED \ - |SAL_MEDIA_DESCRIPTION_STREAMS_CHANGED \ - |SAL_MEDIA_DESCRIPTION_NETWORK_XXXCAST_CHANGED) const char* sal_transport_to_string(SalTransport transport); SalTransport sal_transport_parse(const char*); diff --git a/tester/multi_call_tester.c b/tester/multi_call_tester.c index 47e884a0f..9da71f672 100644 --- a/tester/multi_call_tester.c +++ b/tester/multi_call_tester.c @@ -186,7 +186,7 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag LinphoneCall* marie_call_pauline; LinphoneCall* pauline_called_by_marie; LinphoneCall* marie_call_laure; - + const MSList* calls; MSList* lcs=ms_list_append(NULL,marie->lc); lcs=ms_list_append(lcs,pauline->lc); lcs=ms_list_append(lcs,laure->lc); @@ -229,6 +229,10 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag } } */ + for (calls=linphone_core_get_calls(marie->lc);calls!=NULL;calls=calls->next) { + LinphoneCall *call=(LinphoneCall *)calls->data; + BC_ASSERT_EQUAL(linphone_core_get_media_encryption(marie->lc),linphone_call_params_get_media_encryption(linphone_call_get_current_params(call)),int,"%d"); + } linphone_core_terminate_conference(marie->lc); @@ -250,24 +254,43 @@ static void simple_conference(void) { linphone_core_manager_destroy(laure); } -static void simple_conference_with_ice(void) { + + +static void simple_encrypted_conference_with_ice(LinphoneMediaEncryption mode) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); - linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); - linphone_core_set_stun_server(marie->lc,"stun.linphone.org"); - linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); - linphone_core_set_stun_server(pauline->lc,"stun.linphone.org"); - linphone_core_set_firewall_policy(laure->lc,LinphonePolicyUseIce); - linphone_core_set_stun_server(laure->lc,"stun.linphone.org"); + if (linphone_core_media_encryption_supported(marie->lc,mode)) { + linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); + linphone_core_set_stun_server(marie->lc,"stun.linphone.org"); + linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); + linphone_core_set_stun_server(pauline->lc,"stun.linphone.org"); + linphone_core_set_firewall_policy(laure->lc,LinphonePolicyUseIce); + linphone_core_set_stun_server(laure->lc,"stun.linphone.org"); + + linphone_core_set_media_encryption(marie->lc,mode); + linphone_core_set_media_encryption(pauline->lc,mode); + linphone_core_set_media_encryption(laure->lc,mode); + + simple_conference_base(marie,pauline,laure); + } else { + ms_warning("No [%s] support available",linphone_media_encryption_to_string(mode)); + BC_PASS("Passed"); + } - simple_conference_base(marie,pauline,laure); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(laure); } +static void simple_conference_with_ice(void) { + simple_encrypted_conference_with_ice(LinphoneMediaEncryptionNone); +} +static void simple_zrtp_conference_with_ice(void) { + simple_encrypted_conference_with_ice(LinphoneMediaEncryptionZRTP); +} + static void simple_call_transfer(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); @@ -496,6 +519,7 @@ test_t multi_call_tests[] = { { "Call waiting indication with privacy", call_waiting_indication_with_privacy }, { "Simple conference", simple_conference }, { "Simple conference with ICE",simple_conference_with_ice}, + { "Simple ZRTP conference with ICE",simple_zrtp_conference_with_ice}, { "Simple call transfer", simple_call_transfer }, { "Unattended call transfer", unattended_call_transfer }, { "Unattended call transfer with error", unattended_call_transfer_with_error },