From 11ffe4f9436c1dac46a1bd05d9d6c300a913a852 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 19 Feb 2015 17:17:30 +0100 Subject: [PATCH] move rtp_session_set_symmetric_rtp for ice to the completion of ice --- coreapi/callbacks.c | 2 +- coreapi/linphonecall.c | 3 +- tester/call_tester.c | 66 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 7de84e19f..fa29096b7 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -76,7 +76,7 @@ void linphone_core_update_streams_destinations(LinphoneCore *lc, LinphoneCall *c static void _clear_early_media_destinations(LinphoneCall *call, MediaStream *ms){ RtpSession *session=ms->sessions.rtp_session; rtp_session_clear_aux_remote_addr(session); - if (!call->ice_session) rtp_session_set_symmetric_rtp(session,TRUE);/*restore symmetric rtp if ICE is not used*/ + if (!call->ice_session) rtp_session_set_symmetric_rtp(session,linphone_core_symmetric_rtp_enabled(call->core));/*restore symmetric rtp if ICE is not used*/ } static void clear_early_media_destinations(LinphoneCall *call){ diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 1b678fea3..b118b163f 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1792,7 +1792,6 @@ static void _linphone_call_prepare_ice_for_stream(LinphoneCall *call, int stream if ((linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseIce) && (call->ice_session != NULL)){ IceCheckList *cl; rtp_session_set_pktinfo(ms->sessions.rtp_session, TRUE); - rtp_session_set_symmetric_rtp(ms->sessions.rtp_session, FALSE); cl=ice_session_check_list(call->ice_session, stream_index); if (cl == NULL && create_checklist) { cl=ice_check_list_new(); @@ -3283,6 +3282,7 @@ static void change_ice_media_destinations(LinphoneCall *call) { result = ice_check_list_selected_valid_remote_candidate(ice_session_check_list(call->ice_session, 0), &rtp_addr, &rtp_port, &rtcp_addr, &rtcp_port); if (result == TRUE) { ms_message("Change audio stream destination: RTP=%s:%d RTCP=%s:%d", rtp_addr, rtp_port, rtcp_addr, rtcp_port); + rtp_session_set_symmetric_rtp(call->audiostream->ms.sessions.rtp_session, FALSE); rtp_session_set_remote_addr_full(call->audiostream->ms.sessions.rtp_session, rtp_addr, rtp_port, rtcp_addr, rtcp_port); } } @@ -3291,6 +3291,7 @@ static void change_ice_media_destinations(LinphoneCall *call) { result = ice_check_list_selected_valid_remote_candidate(ice_session_check_list(call->ice_session, 1), &rtp_addr, &rtp_port, &rtcp_addr, &rtcp_port); if (result == TRUE) { ms_message("Change video stream destination: RTP=%s:%d RTCP=%s:%d", rtp_addr, rtp_port, rtcp_addr, rtcp_port); + rtp_session_set_symmetric_rtp(call->videostream->ms.sessions.rtp_session, FALSE); rtp_session_set_remote_addr_full(call->videostream->ms.sessions.rtp_session, rtp_addr, rtp_port, rtcp_addr, rtcp_port); } } diff --git a/tester/call_tester.c b/tester/call_tester.c index 644727618..5442364d7 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -240,7 +240,7 @@ bool_t call_with_params2(LinphoneCoreManager* caller_mgr CU_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call_remote_address(callee_mgr->lc)); if(!linphone_core_get_current_call(caller_mgr->lc) || !linphone_core_get_current_call(callee_mgr->lc) || !linphone_core_get_current_call_remote_address(callee_mgr->lc)) { return 0; - } else { + } else if (caller_mgr->identity){ LinphoneAddress* callee_from=linphone_address_clone(caller_mgr->identity); linphone_address_set_port(callee_from,0); /*remove port because port is never present in from header*/ @@ -3678,7 +3678,67 @@ static void call_with_generic_cn(void) { ms_free(audio_file_with_silence); ms_free(recorded_file); } +void static call_state_changed_2(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){ + LCSipTransports sip_tr; + if (cstate==LinphoneCallReleased) { + /*to make sure transport is changed*/ + sip_tr.udp_port = 0; + sip_tr.tcp_port = 45876; + sip_tr.tls_port = 0; + linphone_core_set_sip_transports(lc,&sip_tr); + } +} + +static void call_with_transport_change_base(bool_t succesfull_call) { + int begin; + int leaked_objects; + LCSipTransports sip_tr; + LinphoneCoreManager* marie; + LinphoneCoreManager* pauline; + LinphoneCoreVTable * v_table; + belle_sip_object_enable_leak_detector(TRUE); + begin=belle_sip_object_get_object_count(); + v_table = linphone_core_v_table_new(); + v_table->call_state_changed=call_state_changed_2; + marie = linphone_core_manager_new("marie_rc"); + pauline = linphone_core_manager_new( "pauline_rc"); + linphone_core_add_listener(marie->lc,v_table); + + sip_tr.udp_port = 0; + sip_tr.tcp_port = 45875; + sip_tr.tls_port = 0; + linphone_core_set_sip_transports(marie->lc,&sip_tr); + if (succesfull_call) { + CU_ASSERT_TRUE(call(marie,pauline)); + linphone_core_terminate_all_calls(marie->lc); + } + else + linphone_core_invite(marie->lc,"nexiste_pas"); + + if (succesfull_call) + CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallEnd,1)); + CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallReleased,1)); + if (succesfull_call) { + CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallEnd,1)); + CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallReleased,1)); + } + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + + leaked_objects=belle_sip_object_get_object_count()-begin; + CU_ASSERT_TRUE(leaked_objects==0); + if (leaked_objects>0){ + belle_sip_object_dump_active_objects(); + } + +} +static void call_with_transport_change_after_released(void) { + call_with_transport_change_base(TRUE); +} +static void unsucessfull_call_with_transport_change_after_released(void) { + call_with_transport_change_base(FALSE); +} test_t call_tests[] = { { "Early declined call", early_declined_call }, @@ -3782,7 +3842,9 @@ test_t call_tests[] = { { "Outgoing INVITE with invalid ACK SDP",outgoing_invite_with_invalid_sdp}, { "Incoming REINVITE with invalid SDP in ACK",incoming_reinvite_with_invalid_ack_sdp}, { "Outgoing REINVITE with invalid SDP in ACK",outgoing_reinvite_with_invalid_ack_sdp}, - { "Call with generic CN", call_with_generic_cn } + { "Call with generic CN", call_with_generic_cn }, + { "Call with transport change after released", call_with_transport_change_after_released }, + { "Unsuccessful call with transport change after released",unsucessfull_call_with_transport_change_after_released} }; test_suite_t call_test_suite = {