From 262575f921edbc087a0365a06864bd995e8f07dd Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 25 Nov 2015 10:27:22 +0100 Subject: [PATCH] fix ice destination change in case of call with rtp-mux --- coreapi/linphonecore.c | 9 ++++++++- coreapi/linphonecore.h | 9 ++++++++- mediastreamer2 | 2 +- tester/call_tester.c | 25 ++++++++++++++++++------- tester/tester.c | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 10 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 5cd5c6322..eab5cb708 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -7387,4 +7387,11 @@ const char* linphone_transport_to_string(LinphoneTransportType transport) { LinphoneTransportType linphone_transport_parse(const char* transport) { return (LinphoneTransportType)sal_transport_parse(transport); } - +const char *linphone_streamtype_to_string(const LinphoneStreamType type) { + switch (type) { + case LinphoneStreamTypeAudio: return "LinphoneStreamTypeAudio"; + case LinphoneStreamTypeVideo: return "LinphoneStreamTypeVideo"; + case LinphoneStreamTypeText: return "LinphoneStreamTypeText"; + case LinphoneStreamTypeUnknown: return "LinphoneStreamTypeUnknown"; + } +} diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 82fe4f84b..79aeebb0e 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -139,7 +139,14 @@ enum _LinphoneStreamType { * @ingroup initializing **/ typedef enum _LinphoneStreamType LinphoneStreamType; - +/** + * Function returning a humain readable value for LinphoneStreamType. + * @param LinphoneStreamType + * @returns + * @ingroup initializing + **/ + +LINPHONE_PUBLIC const char *linphone_streamtype_to_string(const LinphoneStreamType); /** * Object that represents a SIP address. * diff --git a/mediastreamer2 b/mediastreamer2 index d289c123b..30e4d5e32 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit d289c123b120a312533e90709442d9923218810e +Subproject commit 30e4d5e32feadd93ecdd6090d488d9c512cf62a5 diff --git a/tester/call_tester.c b/tester/call_tester.c index 8932cc1c9..c6973f3a0 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -319,7 +319,9 @@ bool_t call_with_params2(LinphoneCoreManager* caller_mgr /*wait ice re-invite*/ if (linphone_core_get_firewall_policy(caller_mgr->lc) == LinphonePolicyUseIce && linphone_core_get_firewall_policy(callee_mgr->lc) == LinphonePolicyUseIce - && !linphone_core_sdp_200_ack_enabled(caller_mgr->lc)) { /*ice does not work with sdp less invite*/ + && !linphone_core_sdp_200_ack_enabled(caller_mgr->lc) /*ice does not work with sdp less invite*/ + && lp_config_get_int(callee_mgr->lc->config, "sip", "update_call_when_ice_completed", TRUE) + && lp_config_get_int(caller_mgr->lc->config, "sip", "update_call_when_ice_completed", TRUE)) { BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+2)); BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+2)); @@ -5422,7 +5424,7 @@ end: linphone_core_manager_destroy(pauline); } -static void _call_with_rtcp_mux(bool_t caller_rtcp_mux, bool_t callee_rtcp_mux, bool_t with_ice){ +static void _call_with_rtcp_mux(bool_t caller_rtcp_mux, bool_t callee_rtcp_mux, bool_t with_ice,bool_t with_ice_reinvite){ LinphoneCoreManager * marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); const LinphoneCallParams *params; @@ -5438,9 +5440,15 @@ static void _call_with_rtcp_mux(bool_t caller_rtcp_mux, bool_t callee_rtcp_mux, lp_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "rtcp_mux", 1); } if (with_ice){ + linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL); + linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL); linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); } + if (!with_ice_reinvite) { + lp_config_set_int(linphone_core_get_config(pauline->lc), "sip", "update_call_when_ice_completed", 0); + lp_config_set_int(linphone_core_get_config(marie->lc), "sip", "update_call_when_ice_completed", 0); + } if (!BC_ASSERT_TRUE(call(marie,pauline))) goto end; @@ -5476,18 +5484,20 @@ end: } static void call_with_rtcp_mux(void){ - _call_with_rtcp_mux(TRUE, TRUE, FALSE); + _call_with_rtcp_mux(TRUE, TRUE, FALSE,TRUE); } static void call_with_rtcp_mux_not_accepted(void){ - _call_with_rtcp_mux(TRUE, FALSE, FALSE); + _call_with_rtcp_mux(TRUE, FALSE, FALSE,TRUE); } static void call_with_ice_and_rtcp_mux(void){ - - _call_with_rtcp_mux(TRUE, TRUE, TRUE); + _call_with_rtcp_mux(TRUE, TRUE, TRUE,TRUE); } +static void call_with_ice_and_rtcp_mux_without_reinvite(void){ + _call_with_rtcp_mux(TRUE, TRUE, TRUE,FALSE); +} test_t call_tests[] = { { "Early declined call", early_declined_call }, @@ -5650,7 +5660,8 @@ test_t call_tests[] = { { "Call with network switch with socket refresh", call_with_network_switch_and_socket_refresh }, { "Call with rtcp-mux", call_with_rtcp_mux}, { "Call with rtcp-mux not accepted", call_with_rtcp_mux_not_accepted}, - { "Call with ICE and rtcp-mux", call_with_ice_and_rtcp_mux} + { "Call with ICE and rtcp-mux", call_with_ice_and_rtcp_mux}, + { "Call with ICE and rtcp-mux without ICE re-invite", call_with_ice_and_rtcp_mux_without_reinvite} }; test_suite_t call_test_suite = {"Single Call", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, diff --git a/tester/tester.c b/tester/tester.c index 9eb28c0d9..0fbc7c7c0 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -549,6 +549,37 @@ void liblinphone_tester_uninit(void) { bc_tester_uninit(); } +static void check_ice_from_rtp(LinphoneCall *c1, LinphoneCall *c2, LinphoneStreamType stream_type) { + MediaStream ms; + switch (stream_type) { + case LinphoneStreamTypeAudio: + ms=c1->audiostream->ms; + break; + case LinphoneStreamTypeVideo: + ms=c1->videostream->ms; + break; + case LinphoneStreamTypeUnknown: + ms=c1->textstream->ms; + break; + default: + ms_error("Uknown stream type [%s]", linphone_streamtype_to_string(stream_type)); + break; + } + + + if (linphone_call_get_audio_stats(c1)->ice_state == LinphoneIceStateHostConnection && media_stream_started(&ms)) { + char ip[16]; + char port[8]; + getnameinfo((const struct sockaddr *)&c1->audiostream->ms.sessions.rtp_session->rtp.gs.rem_addr + , c1->audiostream->ms.sessions.rtp_session->rtp.gs.rem_addrlen + , ip + , sizeof(ip) + , port + , sizeof(port) + , NI_NUMERICHOST|NI_NUMERICSERV); + BC_ASSERT_STRING_EQUAL(ip, c2->media_localip); + } +} bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, LinphoneIceState state) { LinphoneCall *c1,*c2; bool_t audio_success=FALSE; @@ -576,6 +607,8 @@ bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, Linph if (linphone_call_get_audio_stats(c1)->ice_state==state && linphone_call_get_audio_stats(c2)->ice_state==state ){ audio_success=TRUE; + check_ice_from_rtp(c1,c2,LinphoneStreamTypeAudio); + check_ice_from_rtp(c2,c1,LinphoneStreamTypeAudio); break; } linphone_core_iterate(caller->lc); @@ -591,6 +624,8 @@ bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, Linph if (linphone_call_get_video_stats(c1)->ice_state==state && linphone_call_get_video_stats(c2)->ice_state==state ){ video_success=TRUE; + check_ice_from_rtp(c1,c2,LinphoneStreamTypeVideo); + check_ice_from_rtp(c2,c1,LinphoneStreamTypeVideo); break; } linphone_core_iterate(caller->lc); @@ -607,6 +642,8 @@ bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, Linph if (linphone_call_get_text_stats(c1)->ice_state==state && linphone_call_get_text_stats(c2)->ice_state==state ){ text_success=TRUE; + check_ice_from_rtp(c1,c2,LinphoneStreamTypeText); + check_ice_from_rtp(c2,c1,LinphoneStreamTypeText); break; } linphone_core_iterate(caller->lc);