From 006e1ead57498ef488b53eb0988fde8b8ef9dd3c Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Tue, 17 Feb 2015 17:44:02 +0100 Subject: [PATCH 1/3] Update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 7c9ff4ca0..ef83b7a28 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 7c9ff4ca0e597cc36e1ddf14dacfb4bf7a239d74 +Subproject commit ef83b7a2899bc838fe9a490afbb31ae017c7d810 From 5c30b4d6c091ae044b1e3b1e0b2d6d3270e548d1 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 17 Feb 2015 18:21:52 +0100 Subject: [PATCH 2/3] skip call forking with multicast tests on windows, as it is not possible on this platform --- tester/multicast_call_tester.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tester/multicast_call_tester.c b/tester/multicast_call_tester.c index e5a05c11e..356cf3e74 100644 --- a/tester/multicast_call_tester.c +++ b/tester/multicast_call_tester.c @@ -96,6 +96,15 @@ static void early_media_with_multicast_base(bool_t video) { int begin; LinphoneVideoPolicy marie_policy, pauline_policy; LpConfig *marie_lp; + +#ifdef WIN32 + /* + * "Do not call IP_ADD_MEMBERSHIP with the same group more than once on the same network interface." + * https://msdn.microsoft.com/en-us/library/windows/desktop/ms739174%28v=vs.85%29.aspx + */ + ms_warning("Call forking with multicast can't be tested on windows, test skipped"); + return; +#endif belle_sip_object_enable_leak_detector(TRUE); begin=belle_sip_object_get_object_count(); From 41a3e1e06db3268eeee713fc4a06b57c1b2b2a38 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 17 Feb 2015 23:43:20 +0100 Subject: [PATCH 3/3] rework multicast. It is not necessary to bind to the multicast address. 0.0.0.0 just works while the binding to the multicast address is rejected on windows fixes reading provisionning config file from disk on windows. --- coreapi/linphonecall.c | 27 ++++++++++++------- coreapi/private.h | 2 ++ coreapi/remote_provisioning.c | 49 +++++++++++++++++++---------------- mediastreamer2 | 2 +- oRTP | 2 +- tester/call_tester.c | 2 +- 6 files changed, 49 insertions(+), 35 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index afcd516e5..cbf2d4362 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -555,14 +555,11 @@ 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=call->af==AF_INET6 ? "::0" : "0.0.0.0"; - + if (stream_index<2 && call->media_ports[stream_index].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*/ + /*as multicast sender, we must decide a local interface to use to send multicast, and bind to it*/ bind_ip=call->localip; - }else{ - /*as receiver, just bind to the multicast address*/ - bind_ip=call->media_ports[stream_index].multicast_ip; } } return bind_ip; @@ -1003,8 +1000,8 @@ void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, c if (md->streams[i].rtp_addr[i]!='\0' && ms_is_multicast(md->streams[i].rtp_addr)) { strncpy(call->media_ports[i].multicast_ip,md->streams[i].rtp_addr,sizeof(call->media_ports[i].multicast_ip)); ms_message("Disabling rtcp on call [%p], stream [%i] because of multicast",call,i); - call->media_ports[i].rtp_port=md->streams[i].rtp_port; - call->media_ports[i].rtcp_port=0; + call->media_ports[i].mcast_rtp_port=md->streams[i].rtp_port; + call->media_ports[i].mcast_rtcp_port=0; } } } @@ -1844,7 +1841,12 @@ int linphone_call_prepare_ice(LinphoneCall *call, bool_t incoming_offer){ return 0; } - +/*eventually join to a multicast group if told to do so*/ +static void linphone_call_join_multicast_group(LinphoneCall *call, int stream_index, MediaStream *ms){ + if (call->media_ports[stream_index].multicast_ip[stream_index]!='\0' && call->media_ports[stream_index].mcast_rtp_port!=0){ + media_stream_join_multicast_group(ms, call->media_ports[stream_index].multicast_ip); + } +} void linphone_call_init_audio_stream(LinphoneCall *call){ LinphoneCore *lc=call->core; @@ -1859,7 +1861,10 @@ void linphone_call_init_audio_stream(LinphoneCall *call){ if (call->audiostream != NULL) return; if (call->sessions[0].rtp_session==NULL){ call->audiostream=audiostream=audio_stream_new2(linphone_call_get_bind_ip_for_stream(call,0), - call->media_ports[0].rtp_port, call->media_ports[0].rtcp_port); + call->media_ports[0].mcast_rtp_port ? call->media_ports[0].mcast_rtp_port : call->media_ports[0].rtp_port, + call->media_ports[0].mcast_rtcp_port ? call->media_ports[0].mcast_rtcp_port : call->media_ports[0].rtcp_port); + linphone_call_join_multicast_group(call, 0, &audiostream->ms); + cname = linphone_address_as_string_uri_only(call->me); audio_stream_set_rtcp_information(call->audiostream, cname, rtcp_tool); ms_free(cname); @@ -1965,7 +1970,9 @@ void linphone_call_init_video_stream(LinphoneCall *call){ if (call->sessions[1].rtp_session==NULL){ call->videostream=video_stream_new2(linphone_call_get_bind_ip_for_stream(call,1), - call->media_ports[1].rtp_port,call->media_ports[1].rtcp_port); + call->media_ports[1].mcast_rtp_port>0 ? call->media_ports[1].mcast_rtp_port : call->media_ports[1].rtp_port, + call->media_ports[1].mcast_rtcp_port>0 ? call->media_ports[1].mcast_rtcp_port : call->media_ports[1].rtcp_port); + linphone_call_join_multicast_group(call, 1, &call->videostream->ms); cname = linphone_address_as_string_uri_only(call->me); video_stream_set_rtcp_information(call->videostream, cname, rtcp_tool); ms_free(cname); diff --git a/coreapi/private.h b/coreapi/private.h index 15083943e..d5a59d85f 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -203,6 +203,8 @@ typedef struct StunCandidate{ typedef struct _PortConfig{ char multicast_ip[LINPHONE_IPADDR_SIZE]; + int mcast_rtp_port; + int mcast_rtcp_port; int rtp_port; int rtcp_port; }PortConfig; diff --git a/coreapi/remote_provisioning.c b/coreapi/remote_provisioning.c index fd5d2eb92..5562f65db 100644 --- a/coreapi/remote_provisioning.c +++ b/coreapi/remote_provisioning.c @@ -60,33 +60,38 @@ static void linphone_remote_provisioning_apply(LinphoneCore *lc, const char *xml , error_msg); } +static char *load_file_content(const char *path){ + FILE *f=fopen(path,"rb"); + size_t bufsize=2048; + size_t step=bufsize; + size_t pos=0; + size_t count; + char *buffer=ms_malloc(bufsize+1); + if (!f) { + ms_error("load_file_content(): could not open [%s]",path); + return NULL; + } + while((count=fread(buffer+pos, 1, step, f))>0){ + pos+=count; + if (pos+step>=bufsize){ + bufsize*=2; + buffer=ms_realloc(buffer, bufsize+1); + } + } + buffer[pos]='\0'; + fclose(f); + return buffer; +} + int linphone_remote_provisioning_load_file( LinphoneCore* lc, const char* file_path){ int status = -1; - FILE* f = fopen(file_path, "r"); + char* provisioning=load_file_content(file_path); - if( f ){ - long fsize; - char* provisioning; - - fseek(f, 0, SEEK_END); - fsize = ftell(f); - fseek(f, 0, SEEK_SET); - - provisioning = ms_malloc(fsize + 1); - provisioning[fsize]='\0'; - if (fread(provisioning, fsize, 1, f)==0){ - ms_error("Could not read xml provisioning file from %s",file_path); - status=-1; - }else{ - linphone_remote_provisioning_apply(lc, provisioning); - status = 0; - } + if (provisioning){ + linphone_remote_provisioning_apply(lc, provisioning); + status = 0; ms_free(provisioning); - fclose(f); - } else { - ms_error("Couldn't open file %s for provisioning", file_path); } - return status; } diff --git a/mediastreamer2 b/mediastreamer2 index ef83b7a28..acca89ed2 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit ef83b7a2899bc838fe9a490afbb31ae017c7d810 +Subproject commit acca89ed2e726ac53eddce9ffbfd378ea0c9bf9f diff --git a/oRTP b/oRTP index cd468445a..cd3f64ec0 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit cd468445a4f276f54ee9f9948712855f3cd1a0dc +Subproject commit cd3f64ec021534413f247b2f0185d9e934348529 diff --git a/tester/call_tester.c b/tester/call_tester.c index 9fe4c5913..ced4de373 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -3272,7 +3272,7 @@ static void call_with_in_dialog_codec_change_base(bool_t no_sdp) { CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1)); CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); CU_ASSERT_STRING_EQUAL("PCMA",linphone_payload_type_get_mime_type(linphone_call_params_get_used_audio_codec(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc))))); - wait_for_until(marie->lc, pauline->lc, &dummy, 1, 3000); + wait_for_until(marie->lc, pauline->lc, &dummy, 1, 5000); CU_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(marie->lc))->download_bandwidth>70); CU_ASSERT_TRUE(linphone_call_get_audio_stats(linphone_core_get_current_call(pauline->lc))->download_bandwidth>70);