diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index cbf2d4362..ecd68f76f 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2334,6 +2334,21 @@ void static start_dtls( MSMediaStreamSessions *sessions, const SalStreamDescrip } } } +void static start_dtls_on_all_streams(LinphoneCall *call) { + SalMediaDescription *remote_desc = sal_call_get_remote_media_description(call->op); + SalMediaDescription *result_desc = sal_call_get_final_media_description(call->op); + if (call->audiostream && (media_stream_get_state((const MediaStream *)call->audiostream) == MSStreamStarted))/*dtls must start at the end of ice*/ + start_dtls(&call->audiostream->ms.sessions + ,sal_media_description_find_best_stream(result_desc,SalAudio) + ,sal_media_description_find_best_stream(remote_desc,SalAudio)); +#if VIDEO_ENABLED + if (call->videostream && (media_stream_get_state((const MediaStream *)call->videostream) == MSStreamStarted))/*dtls must start at the end of ice*/ + start_dtls(&call->videostream->ms.sessions + ,sal_media_description_find_best_stream(result_desc,SalVideo) + ,sal_media_description_find_best_stream(remote_desc,SalVideo)); +#endif + return; +} static void linphone_call_start_audio_stream(LinphoneCall *call, bool_t muted, bool_t send_ringbacktone, bool_t use_arc){ LinphoneCore *lc=call->core; LpConfig* conf; @@ -2456,10 +2471,6 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, bool_t muted, b if (send_ringbacktone){ setup_ring_player(lc,call); } - { - SalMediaDescription *remote_desc = sal_call_get_remote_media_description(call->op); - start_dtls(&call->audiostream->ms.sessions,stream,&remote_desc->streams[0]); - } if (call->params->in_conference){ /*transform the graph to connect it to the conference filter */ @@ -2586,11 +2597,6 @@ static void linphone_call_start_video_stream(LinphoneCall *call, bool_t all_inpu used_pt, linphone_core_get_video_jittcomp(lc), cam); } } - { - SalMediaDescription *remote_desc = sal_call_get_remote_media_description(call->op); - start_dtls(&call->videostream->ms.sessions,vstream,&remote_desc->streams[1]); - } - }else ms_warning("No video stream accepted."); }else{ ms_message("No valid video stream defined."); @@ -2662,6 +2668,9 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut if ((call->ice_session != NULL) && (ice_session_state(call->ice_session) != IS_Completed)) { ice_session_start_connectivity_checks(call->ice_session); + } else { + /*should not start dtls until ice is completed*/ + start_dtls_on_all_streams(call); } } @@ -2701,10 +2710,8 @@ void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescript if (call->audiostream && local_st_desc && old_stream && new_stream && update_stream_crypto_params(call,local_st_desc,old_stream,new_stream,&call->audiostream->ms)){ } - if (call->audiostream) { - SalMediaDescription *remote_desc = sal_call_get_remote_media_description(call->op); - start_dtls(&call->audiostream->ms.sessions,&new_md->streams[0],&remote_desc->streams[0]); - } + + start_dtls_on_all_streams(call); #ifdef VIDEO_ENABLED local_st_desc = sal_media_description_find_secure_stream_of_type(call->localdesc, SalVideo); @@ -2713,10 +2720,6 @@ void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescript if (call->videostream && local_st_desc && old_stream && new_stream && update_stream_crypto_params(call,local_st_desc,old_stream,new_stream,&call->videostream->ms)){ } - if (call->videostream) { - SalMediaDescription *remote_desc = sal_call_get_remote_media_description(call->op); - start_dtls(&call->videostream->ms.sessions,&new_md->streams[1],&remote_desc->streams[1]); - } #endif } @@ -3289,6 +3292,7 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ linphone_core_update_call(call->core, call, params); } change_ice_media_destinations(call); + start_dtls_on_all_streams(call); break; case IS_Failed: if (ice_session_has_completed_check_list(call->ice_session) == TRUE) { diff --git a/coreapi/sal.c b/coreapi/sal.c index 11934f572..a5a0755d1 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -322,7 +322,6 @@ int sal_stream_description_equals(const SalStreamDescription *sd1, const SalStre if (sd1->dtls_role != sd2->dtls_role) result |= SAL_MEDIA_DESCRIPTION_CRYPTO_KEYS_CHANGED; if (strcmp(sd1->dtls_fingerprint, sd2->dtls_fingerprint) != 0) result |= SAL_MEDIA_DESCRIPTION_CRYPTO_KEYS_CHANGED; - return result; } diff --git a/mediastreamer2 b/mediastreamer2 index 6924f3396..4bb21da47 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 6924f33961f54aa8ddb58a5cc0a0c8aaa624cdce +Subproject commit 4bb21da476acd45b6f12ef3149d45fbdd49e71d2 diff --git a/oRTP b/oRTP index fa091e035..39a807584 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit fa091e0350afaa2a26348ed0ca678135184d628c +Subproject commit 39a807584c9b176eb01c391aa43f6c49a8fe518c diff --git a/tester/transport_tester.c b/tester/transport_tester.c index a291ec0c0..e847e0fe8 100644 --- a/tester/transport_tester.c +++ b/tester/transport_tester.c @@ -167,6 +167,14 @@ static void tunnel_zrtp_video_ice_call(void) { else ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__); } + +static void tunnel_dtls_video_ice_call(void) { + if (linphone_core_tunnel_available()) + call_base(LinphoneMediaEncryptionDTLS,TRUE,FALSE,LinphonePolicyUseIce,TRUE); + else + ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__); +} + static void tunnel_video_ice_call(void) { if (linphone_core_tunnel_available()) call_base(LinphoneMediaEncryptionNone,TRUE,FALSE,LinphonePolicyUseIce,TRUE); @@ -207,6 +215,7 @@ test_t transport_tests[] = { #ifdef VIDEO_ENABLED { "Tunnel ice video call", tunnel_video_ice_call }, { "Tunnel SRTP ice video call", tunnel_srtp_video_ice_call }, + { "Tunnel DTLS ice video call", tunnel_dtls_video_ice_call }, { "Tunnel ZRTP ice video call", tunnel_zrtp_video_ice_call }, #endif };