diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 16fb038c3..518aa245f 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -36,10 +36,12 @@ static void register_failure(SalOp *op); static int media_parameters_changed(LinphoneCall *call, SalMediaDescription *oldmd, SalMediaDescription *newmd) { int result=0; + char *tmp=NULL; 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); + if (call->localdesc_changed) ms_message("Local description has changed: %s", tmp = sal_media_description_print_differences(call->localdesc_changed)); result = call->localdesc_changed | sal_media_description_equals(oldmd, newmd); + if (tmp) ms_free(tmp); return result; } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index cba490570..ca6e99c91 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -105,25 +105,30 @@ bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call){ return call->auth_token_verified; } +static bool_t at_least_one_stream_started(const LinphoneCall *call){ + return (call->audiostream && media_stream_get_state((MediaStream *)call->audiostream) == MSStreamStarted ) + || (call->videostream && media_stream_get_state((MediaStream *)call->videostream) == MSStreamStarted) + || (call->textstream && media_stream_get_state((MediaStream *)call->textstream) == MSStreamStarted); +} + static bool_t linphone_call_all_streams_encrypted(const LinphoneCall *call) { int number_of_encrypted_stream = 0; int number_of_active_stream = 0; - if (call) { - if (call->audiostream && media_stream_get_state((MediaStream *)call->audiostream) == MSStreamStarted) { - number_of_active_stream++; - if(media_stream_secured((MediaStream *)call->audiostream)) - number_of_encrypted_stream++; - } - if (call->videostream && media_stream_get_state((MediaStream *)call->videostream) == MSStreamStarted) { - number_of_active_stream++; - if (media_stream_secured((MediaStream *)call->videostream)) - number_of_encrypted_stream++; - } - if (call->textstream && media_stream_get_state((MediaStream *)call->textstream) == MSStreamStarted) { - number_of_active_stream++; - if (media_stream_secured((MediaStream *)call->textstream)) - number_of_encrypted_stream++; - } + + if (call->audiostream && media_stream_get_state((MediaStream *)call->audiostream) == MSStreamStarted) { + number_of_active_stream++; + if(media_stream_secured((MediaStream *)call->audiostream)) + number_of_encrypted_stream++; + } + if (call->videostream && media_stream_get_state((MediaStream *)call->videostream) == MSStreamStarted) { + number_of_active_stream++; + if (media_stream_secured((MediaStream *)call->videostream)) + number_of_encrypted_stream++; + } + if (call->textstream && media_stream_get_state((MediaStream *)call->textstream) == MSStreamStarted) { + number_of_active_stream++; + if (media_stream_secured((MediaStream *)call->textstream)) + number_of_encrypted_stream++; } return number_of_active_stream>0 && number_of_active_stream==number_of_encrypted_stream; } @@ -1658,6 +1663,7 @@ LinphoneCall * linphone_call_ref(LinphoneCall *obj){ void linphone_call_unref(LinphoneCall *obj){ belle_sip_object_unref(obj); } + static unsigned int linphone_call_get_n_active_streams(const LinphoneCall *call) { SalMediaDescription *md=NULL; if (call->op) @@ -1699,23 +1705,27 @@ const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call){ switch (call->params->media_encryption) { case LinphoneMediaEncryptionZRTP: - if ((all_streams_encrypted = linphone_call_all_streams_encrypted(call)) && linphone_call_get_authentication_token(call)) { - call->current_params->media_encryption=LinphoneMediaEncryptionZRTP; - } else { - ms_message("Encryption was resquested to be %s, but isn't effective (all_streams_encrypted=%i, auth_token=%s)", - linphone_media_encryption_to_string(call->params->media_encryption), all_streams_encrypted, call->auth_token); - call->current_params->media_encryption=LinphoneMediaEncryptionNone; - } + if (at_least_one_stream_started(call)){ + if ((all_streams_encrypted = linphone_call_all_streams_encrypted(call)) && linphone_call_get_authentication_token(call)) { + call->current_params->media_encryption=LinphoneMediaEncryptionZRTP; + } else { + ms_message("Encryption was resquested to be %s, but isn't effective (all_streams_encrypted=%i, auth_token=%s)", + linphone_media_encryption_to_string(call->params->media_encryption), all_streams_encrypted, call->auth_token); + call->current_params->media_encryption=LinphoneMediaEncryptionNone; + } + }//else don't update the state if all streams are shutdown. break; case LinphoneMediaEncryptionDTLS: case LinphoneMediaEncryptionSRTP: - if (linphone_call_get_n_active_streams(call)==0 || (all_streams_encrypted = linphone_call_all_streams_encrypted(call))) { - call->current_params->media_encryption = call->params->media_encryption; - } else { - ms_message("Encryption was resquested to be %s, but isn't effective (all_streams_encrypted=%i)", - linphone_media_encryption_to_string(call->params->media_encryption), all_streams_encrypted); - call->current_params->media_encryption=LinphoneMediaEncryptionNone; - } + if (at_least_one_stream_started(call)){ + if (linphone_call_get_n_active_streams(call)==0 || (all_streams_encrypted = linphone_call_all_streams_encrypted(call))) { + call->current_params->media_encryption = call->params->media_encryption; + } else { + ms_message("Encryption was resquested to be %s, but isn't effective (all_streams_encrypted=%i)", + linphone_media_encryption_to_string(call->params->media_encryption), all_streams_encrypted); + call->current_params->media_encryption=LinphoneMediaEncryptionNone; + } + }//else don't update the state if all streams are shutdown. break; case LinphoneMediaEncryptionNone: call->current_params->media_encryption=LinphoneMediaEncryptionNone; diff --git a/coreapi/misc.c b/coreapi/misc.c index 6cc1a9490..f971d898c 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -795,7 +795,6 @@ void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDes if (session == NULL) return; if (ice_session_state(session) == IS_Completed) return; - ms_message("linphone_call_stop_ice_for_inactive_streams: nb_streams = %i", desc->nb_streams); for (i = 0; i < desc->nb_streams; i++) { IceCheckList *cl = ice_session_check_list(session, i); if (!sal_stream_description_active(&desc->streams[i]) && cl) { diff --git a/coreapi/sal.c b/coreapi/sal.c index ab3649a1e..a6f031dce 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -336,6 +336,47 @@ int sal_stream_description_equals(const SalStreamDescription *sd1, const SalStre return result; } +char * sal_media_description_print_differences(int result){ + char *out = NULL; + if (result & SAL_MEDIA_DESCRIPTION_CODEC_CHANGED){ + out = ms_strcat_printf(out, "%s ", "CODEC_CHANGED"); + result &= ~SAL_MEDIA_DESCRIPTION_CODEC_CHANGED; + } + if (result & SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED){ + out = ms_strcat_printf(out, "%s ", "NETWORK_CHANGED"); + result &= ~SAL_MEDIA_DESCRIPTION_NETWORK_CHANGED; + } + if (result & SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED){ + out = ms_strcat_printf(out, "%s ", "ICE_RESTART_DETECTED"); + result &= ~SAL_MEDIA_DESCRIPTION_ICE_RESTART_DETECTED; + } + if (result & SAL_MEDIA_DESCRIPTION_CRYPTO_KEYS_CHANGED){ + out = ms_strcat_printf(out, "%s ", "CRYPTO_KEYS_CHANGED"); + result &= ~SAL_MEDIA_DESCRIPTION_CRYPTO_KEYS_CHANGED; + } + if (result & SAL_MEDIA_DESCRIPTION_NETWORK_XXXCAST_CHANGED){ + out = ms_strcat_printf(out, "%s ", "NETWORK_XXXCAST_CHANGED"); + result &= ~SAL_MEDIA_DESCRIPTION_NETWORK_XXXCAST_CHANGED; + } + if (result & SAL_MEDIA_DESCRIPTION_STREAMS_CHANGED){ + out = ms_strcat_printf(out, "%s ", "STREAMS_CHANGED"); + result &= ~SAL_MEDIA_DESCRIPTION_STREAMS_CHANGED; + } + if (result & SAL_MEDIA_DESCRIPTION_CRYPTO_POLICY_CHANGED){ + out = ms_strcat_printf(out, "%s ", "CRYPTO_POLICY_CHANGED"); + result &= ~SAL_MEDIA_DESCRIPTION_CRYPTO_POLICY_CHANGED; + } + if (result & SAL_MEDIA_DESCRIPTION_FORCE_STREAM_RECONSTRUCTION){ + out = ms_strcat_printf(out, "%s ", "FORCE_STREAM_RECONSTRUCTION"); + result &= ~SAL_MEDIA_DESCRIPTION_FORCE_STREAM_RECONSTRUCTION; + } + if (result){ + ms_fatal("There are unhandled result bitmasks in sal_media_description_print_differences(), fix it"); + } + if (!out) out = ms_strdup("NONE"); + return out; +} + int sal_media_description_equals(const SalMediaDescription *md1, const SalMediaDescription *md2) { int result = SAL_MEDIA_DESCRIPTION_UNCHANGED; int i; @@ -356,6 +397,7 @@ int sal_media_description_equals(const SalMediaDescription *md1, const SalMediaD } return result; } + static void assign_address(SalAddress** address, const char *value){ if (*address){ sal_address_destroy(*address); diff --git a/include/sal/sal.h b/include/sal/sal.h index 423ed7ab1..f17a01faf 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -292,6 +292,7 @@ SalMediaDescription * sal_media_description_ref(SalMediaDescription *md); void sal_media_description_unref(SalMediaDescription *md); bool_t sal_media_description_empty(const SalMediaDescription *md); int sal_media_description_equals(const SalMediaDescription *md1, const SalMediaDescription *md2); +char * sal_media_description_print_differences(int result); bool_t sal_media_description_has_dir(const SalMediaDescription *md, SalStreamDir dir); LINPHONE_PUBLIC SalStreamDescription *sal_media_description_find_stream(SalMediaDescription *md, SalMediaProto proto, SalStreamType type); unsigned int sal_media_description_nb_active_streams_of_type(SalMediaDescription *md, SalStreamType type); diff --git a/mediastreamer2 b/mediastreamer2 index f3debaa38..205092d4e 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit f3debaa3892717512f1bee4ce2e9fbc2cca01e8a +Subproject commit 205092d4e4a13e2c60ae626cbc2626fdd9b144eb diff --git a/oRTP b/oRTP index 67cfa080b..66fcf36ab 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 67cfa080b1f4a337d01a5d53b691296463a6e56b +Subproject commit 66fcf36abb30ddf65ca3f99d9bd0aecf8085e5f3 diff --git a/tester/call_tester.c b/tester/call_tester.c index 190d457b6..7c245f00e 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -2636,7 +2636,6 @@ void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video linphone_core_iterate(pauline->lc); ms_usleep(20000); } - } if (policy == LinphonePolicyUseIce){ @@ -2646,13 +2645,13 @@ void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video #ifdef VIDEO_ENABLED if (enable_video) { if (linphone_core_video_supported(marie->lc)) { - add_video(pauline,marie, TRUE); - if (policy == LinphonePolicyUseIce) - BC_ASSERT_TRUE(check_ice(pauline,marie,enable_tunnel?LinphoneIceStateReflexiveConnection:LinphoneIceStateHostConnection)); - + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + if (policy == LinphonePolicyUseIce){ + BC_ASSERT_TRUE(check_ice(pauline, marie, + enable_tunnel?LinphoneIceStateReflexiveConnection:LinphoneIceStateHostConnection)); + } liblinphone_tester_check_rtcp(marie,pauline); - /*make sure video is properly received and decoded*/ - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_IframeDecoded,1)); + } else { ms_warning ("not tested because video not available"); }