From a5a65227b36d0cfb6d4b34b93521986bc371b685 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 18 Oct 2016 23:10:21 +0200 Subject: [PATCH] Repair multicast when ipv6 is enabled. --- coreapi/linphonecall.c | 17 ++++++++++------- coreapi/private.h | 1 + coreapi/sal.c | 15 +++++++++++++++ include/sal/sal.h | 1 + tester/call_multicast_tester.c | 4 ++-- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 0d37317f9..cfcc42554 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -637,11 +637,14 @@ static void transfer_already_assigned_payload_types(SalMediaDescription *old, Sa static const char *linphone_call_get_bind_ip_for_stream(LinphoneCall *call, int stream_index){ const char *bind_ip = lp_config_get_string(call->core->config,"rtp","bind_address", call->af == AF_INET6 ? "::0" : "0.0.0.0"); - - if (stream_index<2 && call->media_ports[stream_index].multicast_ip[0]!='\0'){ + PortConfig *pc = &call->media_ports[stream_index]; + if (stream_index<2 && pc->multicast_ip[0]!='\0'){ if (call->dir==LinphoneCallOutgoing){ /*as multicast sender, we must decide a local interface to use to send multicast, and bind to it*/ - bind_ip=call->media_localip; + linphone_core_get_local_ip_for(strchr(pc->multicast_ip,':') ? AF_INET6 : AF_INET, + NULL, pc->multicast_bind_ip); + bind_ip = pc->multicast_bind_ip; + } } return bind_ip; @@ -1152,6 +1155,7 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneCall, belle_sip_object_t, NULL, // marshal FALSE ); + void linphone_call_fill_media_multicast_addr(LinphoneCall *call) { if (linphone_call_params_audio_multicast_enabled(call->params)){ strncpy(call->media_ports[call->main_audio_stream_index].multicast_ip, @@ -2410,12 +2414,11 @@ static SalMulticastRole linphone_call_get_multicast_role(const LinphoneCall *cal stream_desc = sal_media_description_find_best_stream(remotedesc, type); if (stream_desc) - multicast_role=stream_desc->multicast_role; - else - ms_message("Cannot determine multicast role for stream type [%s] on call [%p]",sal_stream_type_to_string(type),call); - + multicast_role = stream_desc->multicast_role; end: + ms_message("Call [%p], stream type [%s], multicast role is [%s]",call, sal_stream_type_to_string(type), + sal_multicast_role_to_string(multicast_role)); return multicast_role; } diff --git a/coreapi/private.h b/coreapi/private.h index 5573e6af2..99c72c6c1 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -280,6 +280,7 @@ typedef struct StunCandidate{ typedef struct _PortConfig{ char multicast_ip[LINPHONE_IPADDR_SIZE]; + char multicast_bind_ip[LINPHONE_IPADDR_SIZE]; int rtp_port; int rtcp_port; }PortConfig; diff --git a/coreapi/sal.c b/coreapi/sal.c index 08c671189..133241be1 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -28,6 +28,21 @@ This file contains SAL API functions that do not depend on the underlying implem #include + +const char *sal_multicast_role_to_string(SalMulticastRole role){ + switch(role){ + case SalMulticastInactive: + return "inactive"; + case SalMulticastReceiver: + return "receiver"; + case SalMulticastSender: + return "sender"; + case SalMulticastSenderReceiver: + return "sender-receiver"; + } + return "INVALID"; +} + const char* sal_transport_to_string(SalTransport transport) { switch (transport) { case SalTransportUDP:return "udp"; diff --git a/include/sal/sal.h b/include/sal/sal.h index f49f0b580..af3fcf1f7 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -272,6 +272,7 @@ typedef struct SalStreamDescription{ SalMulticastRole multicast_role; } SalStreamDescription; +const char *sal_multicast_role_to_string(SalMulticastRole role); const char *sal_stream_description_get_type_as_string(const SalStreamDescription *desc); const char *sal_stream_description_get_proto_as_string(const SalStreamDescription *desc); diff --git a/tester/call_multicast_tester.c b/tester/call_multicast_tester.c index 566256ab9..b1ff8d67a 100644 --- a/tester/call_multicast_tester.c +++ b/tester/call_multicast_tester.c @@ -168,10 +168,10 @@ static void early_media_with_multicast_base(bool_t video) { wait_for_list(lcs, &dummy, 1, 3000); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline),70,int,"%i"); - BC_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->download_bandwidth<90); + BC_ASSERT_LOWER(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->download_bandwidth, 90, int, "%i"); BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline2),70,int,"%i"); - BC_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline2->lc))->download_bandwidth<90); + BC_ASSERT_LOWER(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline2->lc))->download_bandwidth,90, int, "%i"); BC_ASSERT_TRUE(linphone_call_params_audio_multicast_enabled(linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)))); BC_ASSERT_TRUE(linphone_call_params_audio_multicast_enabled(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc))));