From 3030d9a9c90a0b4bf45e3986fdeabd571284d4bc Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 30 Mar 2016 14:10:58 +0200 Subject: [PATCH 001/124] Use new STUN API. --- coreapi/misc.c | 125 +++++++++++++++++++++---------------------- tester/stun_tester.c | 71 +++++++++--------------- 2 files changed, 86 insertions(+), 110 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 835acb6e9..65bf11ad5 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -317,28 +317,30 @@ static ortp_socket_t create_socket(int local_port){ return sock; } -static int sendStunRequest(int sock, const struct sockaddr *server, socklen_t addrlen, int id, bool_t changeAddr){ - char buf[STUN_MAX_MESSAGE_SIZE]; - int len = STUN_MAX_MESSAGE_SIZE; - StunAtrString username; - StunAtrString password; - StunMessage req; - int err; - memset(&req, 0, sizeof(StunMessage)); - memset(&username,0,sizeof(username)); - memset(&password,0,sizeof(password)); - stunBuildReqSimple( &req, &username, changeAddr , changeAddr , id); - len = stunEncodeMessage( &req, buf, len, &password); - if (len<=0){ +static int send_stun_request(int sock, const struct sockaddr *server, socklen_t addrlen, int id, bool_t change_addr){ + char *buf = NULL; + int len; + int err = 0; + MSStunMessage *req = ms_stun_binding_request_create(); + UInt96 tr_id = ms_stun_message_get_tr_id(req); + tr_id.octet[0] = id; + ms_stun_message_set_tr_id(req, tr_id); + ms_stun_message_enable_change_ip(req, change_addr); + ms_stun_message_enable_change_port(req, change_addr); + len = ms_stun_message_encode(req, &buf); + if (len <= 0) { ms_error("Fail to encode stun message."); - return -1; + err = -1; + } else { + err = sendto(sock, buf, len, 0, server, addrlen); + if (err < 0) { + ms_error("sendto failed: %s",strerror(errno)); + err = -1; + } } - err=sendto(sock,buf,len,0,server,addrlen); - if (err<0){ - ms_error("sendto failed: %s",strerror(errno)); - return -1; - } - return 0; + if (buf != NULL) ms_free(buf); + ms_free(req); + return err; } int linphone_parse_host_port(const char *input, char *host, size_t hostlen, int *port){ @@ -387,23 +389,32 @@ int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, sock return 0; } -static int recvStunResponse(ortp_socket_t sock, char *ipaddr, int *port, int *id){ - char buf[STUN_MAX_MESSAGE_SIZE]; - int len = STUN_MAX_MESSAGE_SIZE; - StunMessage resp; - len=recv(sock,buf,len,0); - if (len>0){ +static int recv_stun_response(ortp_socket_t sock, char *ipaddr, int *port, int *id) { + char buf[MS_STUN_MAX_MESSAGE_SIZE]; + int len = MS_STUN_MAX_MESSAGE_SIZE; + MSStunMessage *resp; + + len = recv(sock, buf, len, 0); + if (len > 0) { struct in_addr ia; - stunParseMessage(buf,len, &resp ); - *id=resp.msgHdr.tr_id.octet[0]; - if (resp.hasXorMappedAddress){ - *port = resp.xorMappedAddress.ipv4.port; - ia.s_addr=htonl(resp.xorMappedAddress.ipv4.addr); - }else if (resp.hasMappedAddress){ - *port = resp.mappedAddress.ipv4.port; - ia.s_addr=htonl(resp.mappedAddress.ipv4.addr); - }else return -1; - strncpy(ipaddr,inet_ntoa(ia),LINPHONE_IPADDR_SIZE); + resp = ms_stun_message_create_from_buffer_parsing(buf, len); + if (resp != NULL) { + const MSStunAddress *stun_addr; + UInt96 tr_id = ms_stun_message_get_tr_id(resp); + *id = tr_id.octet[0]; + stun_addr = ms_stun_message_get_xor_mapped_address(resp); + if (stun_addr != NULL) { + *port = stun_addr->ipv4.port; + ia.s_addr = htonl(stun_addr->ipv4.addr); + } else { + stun_addr = ms_stun_message_get_mapped_address(resp); + if (stun_addr != NULL) { + *port = stun_addr->ipv4.port; + ia.s_addr = htonl(stun_addr->ipv4.addr); + } else len = -1; + } + if (len > 0) strncpy(ipaddr, inet_ntoa(ia), LINPHONE_IPADDR_SIZE); + } } return len; } @@ -459,44 +470,32 @@ int linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call){ int id; if (loops%20==0){ ms_message("Sending stun requests..."); - sendStunRequest((int)sock1,ai->ai_addr,(socklen_t)ai->ai_addrlen,11,TRUE); - sendStunRequest((int)sock1,ai->ai_addr,(socklen_t)ai->ai_addrlen,1,FALSE); + send_stun_request((int)sock1,ai->ai_addr,(socklen_t)ai->ai_addrlen,11,TRUE); + send_stun_request((int)sock1,ai->ai_addr,(socklen_t)ai->ai_addrlen,1,FALSE); if (sock2!=-1){ - sendStunRequest((int)sock2,ai->ai_addr,(socklen_t)ai->ai_addrlen,22,TRUE); - sendStunRequest((int)sock2,ai->ai_addr,(socklen_t)ai->ai_addrlen,2,FALSE); + send_stun_request((int)sock2,ai->ai_addr,(socklen_t)ai->ai_addrlen,22,TRUE); + send_stun_request((int)sock2,ai->ai_addr,(socklen_t)ai->ai_addrlen,2,FALSE); } if (sock3!=-1){ - sendStunRequest((int)sock3,ai->ai_addr,(socklen_t)ai->ai_addrlen,33,TRUE); - sendStunRequest((int)sock3,ai->ai_addr,(socklen_t)ai->ai_addrlen,3,FALSE); + send_stun_request((int)sock3,ai->ai_addr,(socklen_t)ai->ai_addrlen,33,TRUE); + send_stun_request((int)sock3,ai->ai_addr,(socklen_t)ai->ai_addrlen,3,FALSE); } } ms_usleep(10000); - if (recvStunResponse(sock1,ac->addr, - &ac->port,&id)>0){ - ms_message("STUN test result: local audio port maps to %s:%i", - ac->addr, - ac->port); - if (id==11) - cone_audio=TRUE; + if (recv_stun_response(sock1, ac->addr, &ac->port, &id) > 0) { + ms_message("STUN test result: local audio port maps to %s:%i", ac->addr, ac->port); + if (id==11) cone_audio=TRUE; got_audio=TRUE; } - if (recvStunResponse(sock2,vc->addr, - &vc->port,&id)>0){ - ms_message("STUN test result: local video port maps to %s:%i", - vc->addr, - vc->port); - if (id==22) - cone_video=TRUE; + if (recv_stun_response(sock2, vc->addr, &vc->port, &id) > 0) { + ms_message("STUN test result: local video port maps to %s:%i", vc->addr, vc->port); + if (id==22) cone_video=TRUE; got_video=TRUE; } - if (recvStunResponse(sock3,tc->addr, - &tc->port,&id)>0){ - ms_message("STUN test result: local text port maps to %s:%i", - tc->addr, - tc->port); - if (id==33) - cone_text=TRUE; + if (recv_stun_response(sock3, tc->addr, &tc->port, &id)>0) { + ms_message("STUN test result: local text port maps to %s:%i", tc->addr, tc->port); + if (id==33) cone_text=TRUE; got_text=TRUE; } ortp_gettimeofday(&cur,NULL); diff --git a/tester/stun_tester.c b/tester/stun_tester.c index e52927386..bccd747ac 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -16,7 +16,6 @@ along with this program. If not, see . */ - #include "linphonecore.h" #include "private.h" #include "liblinphone_tester.h" @@ -24,52 +23,36 @@ #include "ortp/port.h" -static const char* stun_address = "stun.linphone.org"; +static const char *stun_address = "stun.linphone.org"; -static int test_stun_encode( char*buffer, size_t len, bool_t expect_fail ) +static size_t test_stun_encode(char **buffer) { - StunAtrString username; - StunAtrString password; - StunMessage req; - memset(&req, 0, sizeof(StunMessage)); - memset(&username,0,sizeof(username)); - memset(&password,0,sizeof(password)); - stunBuildReqSimple( &req, &username, TRUE , TRUE , 11); - len = stunEncodeMessage( &req, buffer, (unsigned int)len, &password); - if (len<=0){ - if( expect_fail ) - ms_message("Fail to encode stun message (EXPECTED).\n"); - else - ms_error("Fail to encode stun message.\n"); - return -1; - } - return (int)len; + MSStunMessage *req = ms_stun_binding_request_create(); + UInt96 tr_id = ms_stun_message_get_tr_id(req); + tr_id.octet[0] = 11; + ms_stun_message_set_tr_id(req, tr_id); + return ms_stun_message_encode(req, buffer); } static void linphone_stun_test_encode(void) { - char smallBuff[12]; - size_t smallLen = 12; - char bigBuff[STUN_MAX_MESSAGE_SIZE]; - size_t bigLen = STUN_MAX_MESSAGE_SIZE; - - size_t len = test_stun_encode(smallBuff, smallLen, TRUE); - BC_ASSERT(len == -1); - - len = test_stun_encode(bigBuff, bigLen, TRUE); + char *buffer = NULL; + size_t len = test_stun_encode(&buffer); BC_ASSERT(len > 0); + BC_ASSERT_PTR_NOT_NULL(buffer); + if (buffer != NULL) ms_free(buffer); ms_message("STUN message encoded in %i bytes", (int)len); } static void linphone_stun_test_grab_ip(void) { - LinphoneCoreManager* lc_stun = linphone_core_manager_new2( "stun_rc", FALSE); + LinphoneCoreManager* lc_stun = linphone_core_manager_new2("stun_rc", FALSE); LinphoneCall dummy_call; int ping_time; - int tmp=0; + int tmp = 0; memset(&dummy_call, 0, sizeof(LinphoneCall)); dummy_call.main_audio_stream_index = 0; @@ -82,33 +65,27 @@ static void linphone_stun_test_grab_ip(void) linphone_core_set_stun_server(lc_stun->lc, stun_address); BC_ASSERT_STRING_EQUAL(stun_address, linphone_core_get_stun_server(lc_stun->lc)); - wait_for(lc_stun->lc,lc_stun->lc,&tmp,1); + wait_for(lc_stun->lc, lc_stun->lc, &tmp, 1); ping_time = linphone_core_run_stun_tests(lc_stun->lc, &dummy_call); BC_ASSERT(ping_time != -1); ms_message("Round trip to STUN: %d ms", ping_time); - BC_ASSERT( dummy_call.ac.addr[0] != '\0'); - BC_ASSERT( dummy_call.ac.port != 0); + BC_ASSERT(dummy_call.ac.addr[0] != '\0'); + BC_ASSERT(dummy_call.ac.port != 0); #ifdef VIDEO_ENABLED - BC_ASSERT( dummy_call.vc.addr[0] != '\0'); - BC_ASSERT( dummy_call.vc.port != 0); + BC_ASSERT(dummy_call.vc.addr[0] != '\0'); + BC_ASSERT(dummy_call.vc.port != 0); #endif - BC_ASSERT( dummy_call.tc.addr[0] != '\0'); - BC_ASSERT( dummy_call.tc.port != 0); + BC_ASSERT(dummy_call.tc.addr[0] != '\0'); + BC_ASSERT(dummy_call.tc.port != 0); - ms_message("STUN test result: local audio port maps to %s:%i", - dummy_call.ac.addr, - dummy_call.ac.port); + ms_message("STUN test result: local audio port maps to %s:%i", dummy_call.ac.addr, dummy_call.ac.port); #ifdef VIDEO_ENABLED - ms_message("STUN test result: local video port maps to %s:%i", - dummy_call.vc.addr, - dummy_call.vc.port); + ms_message("STUN test result: local video port maps to %s:%i", dummy_call.vc.addr, dummy_call.vc.port); #endif - ms_message("STUN test result: local text port maps to %s:%i", - dummy_call.tc.addr, - dummy_call.tc.port); + ms_message("STUN test result: local text port maps to %s:%i", dummy_call.tc.addr, dummy_call.tc.port); linphone_core_manager_destroy(lc_stun); } @@ -116,7 +93,7 @@ static void linphone_stun_test_grab_ip(void) test_t stun_tests[] = { TEST_NO_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip), - TEST_NO_TAG("STUN encode buffer protection", linphone_stun_test_encode) + TEST_NO_TAG("STUN encode", linphone_stun_test_encode) }; test_suite_t stun_test_suite = {"Stun", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, From b6076942fc3697c534df635f1c872878784ba169 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 30 Mar 2016 17:10:50 +0200 Subject: [PATCH 002/124] Add LinphoneNatPolicy API and deprecate LinphoneFirewallPolicy. --- coreapi/CMakeLists.txt | 2 + coreapi/Makefile.am | 2 + coreapi/linphone_proxy_config.h | 18 +++ coreapi/linphonecore.c | 127 +++++++++++++------- coreapi/linphonecore.h | 25 ++++ coreapi/lpconfig.c | 41 +++++++ coreapi/lpconfig.h | 13 ++ coreapi/nat_policy.c | 205 ++++++++++++++++++++++++++++++++ coreapi/nat_policy.h | 164 +++++++++++++++++++++++++ coreapi/private.h | 21 +++- coreapi/proxy.c | 23 ++++ 11 files changed, 597 insertions(+), 44 deletions(-) create mode 100644 coreapi/nat_policy.c create mode 100644 coreapi/nat_policy.h diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index 564d80d51..ea97ad5f3 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -48,6 +48,7 @@ set(LINPHONE_HEADER_FILES linphone_tunnel.h lpc2xml.h lpconfig.h + nat_policy.h ringtoneplayer.h sipsetup.h sqlite3_bctbx_vfs.h @@ -102,6 +103,7 @@ set(LINPHONE_SOURCE_FILES_C lsd.c message_storage.c misc.c + nat_policy.c offeranswer.c offeranswer.h player.c diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index 4d2f230d2..3b12d4132 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -42,6 +42,7 @@ linphone_include_HEADERS=\ linphone_tunnel.h \ lpc2xml.h \ lpconfig.h \ + nat_policy.h \ sipsetup.h \ xml2lpc.h \ xmlrpc.h \ @@ -80,6 +81,7 @@ liblinphone_la_SOURCES=\ lsd.c \ message_storage.c \ misc.c \ + nat_policy.c \ offeranswer.c offeranswer.h\ player.c \ presence.c \ diff --git a/coreapi/linphone_proxy_config.h b/coreapi/linphone_proxy_config.h index 2fb5bda9f..128d777a3 100644 --- a/coreapi/linphone_proxy_config.h +++ b/coreapi/linphone_proxy_config.h @@ -547,6 +547,24 @@ LINPHONE_PUBLIC const char * linphone_proxy_config_get_ref_key(const LinphonePro **/ LINPHONE_PUBLIC void linphone_proxy_config_set_ref_key(LinphoneProxyConfig *cfg, const char *refkey); +/** + * Get The policy that is used to pass through NATs/firewalls when using this proxy config. + * If it is set to NULL, the default NAT policy from the core will be used instead. + * @param[in] cfg #LinphoneProxyConfig object + * @return LinphoneNatPolicy object in use. + * @see linphone_core_get_nat_policy() + */ +LINPHONE_PUBLIC const LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const LinphoneProxyConfig *cfg); + +/** + * Set the policy to use to pass through NATs/firewalls when using this proxy config. + * If it is set to NULL, the default NAT policy from the core will be used instead. + * @param[in] cfg #LinphoneProxyConfig object + * @param[in] policy LinphoneNatPolicy object + * @see linphone_core_set_nat_policy() + */ +LINPHONE_PUBLIC void linphone_proxy_config_set_nat_policy(LinphoneProxyConfig *cfg, LinphoneNatPolicy *policy); + /** * @} */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index aedc39a40..9e44ac9dd 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -755,13 +755,22 @@ static void net_config_read (LinphoneCore *lc) int tmp; const char *tmpstr; LpConfig *config=lc->config; + const char *nat_policy_ref; + + nat_policy_ref = lp_config_get_string(lc->config, "net", "nat_policy_ref", NULL); + if (nat_policy_ref != NULL) { + lc->nat_policy = linphone_nat_policy_new_from_config(lc->config, nat_policy_ref); + } lc->net_conf.nat_address_ip = NULL; tmp=lp_config_get_int(config,"net","download_bw",0); linphone_core_set_download_bandwidth(lc,tmp); tmp=lp_config_get_int(config,"net","upload_bw",0); linphone_core_set_upload_bandwidth(lc,tmp); - linphone_core_set_stun_server(lc,lp_config_get_string(config,"net","stun_server",NULL)); + if (lc->nat_policy == NULL) /* For compatibility, now the STUN server is stored in the NAT policy. */ + linphone_core_set_stun_server(lc,lp_config_get_string(config,"net","stun_server",NULL)); + else + linphone_core_set_stun_server(lc, linphone_nat_policy_get_stun_server(lc->nat_policy)); tmpstr=lp_config_get_string(lc->config,"net","nat_address",NULL); if (tmpstr!=NULL && (strlen(tmpstr)<1)) tmpstr=NULL; linphone_core_set_nat_address(lc,tmpstr); @@ -778,7 +787,8 @@ static void net_config_read (LinphoneCore *lc) linphone_core_enable_dns_srv(lc, tmp); /* This is to filter out unsupported firewall policies */ - linphone_core_set_firewall_policy(lc, linphone_core_get_firewall_policy(lc)); + if (nat_policy_ref == NULL) + linphone_core_set_firewall_policy(lc, linphone_core_get_firewall_policy(lc)); } static void build_sound_devices_table(LinphoneCore *lc){ @@ -5080,7 +5090,9 @@ void linphone_core_set_stun_server(LinphoneCore *lc, const char *server){ linphone_core_resolve_stun_server(lc); } - if (linphone_core_ready(lc)) + if (lc->nat_policy != NULL) + linphone_nat_policy_set_stun_server(lc->nat_policy, lc->net_conf.stun_server); + else if (linphone_core_ready(lc)) lp_config_set_string(lc->config,"net","stun_server",lc->net_conf.stun_server); } @@ -5154,66 +5166,59 @@ const char *linphone_core_get_nat_address_resolved(LinphoneCore *lc) return lc->net_conf.nat_address_ip; } -void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol){ - const char *policy = "none"; +void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol) { + LinphoneNatPolicy *nat_policy; + + if (lc->nat_policy != NULL) { + nat_policy = linphone_nat_policy_ref(lc->nat_policy); + linphone_nat_policy_clear(nat_policy); + } else { + nat_policy = linphone_nat_policy_new(); + } switch (pol) { default: case LinphonePolicyNoFirewall: - policy = "none"; - break; case LinphonePolicyUseNatAddress: - policy = "nat_address"; break; case LinphonePolicyUseStun: - policy = "stun"; + linphone_nat_policy_enable_stun(nat_policy, TRUE); break; case LinphonePolicyUseIce: - policy = "ice"; + linphone_nat_policy_enable_ice(nat_policy, TRUE); + linphone_nat_policy_enable_stun(nat_policy, TRUE); break; case LinphonePolicyUseUpnp: #ifdef BUILD_UPNP - policy = "upnp"; + linphone_nat_policy_enable_upnp(nat_policy); #else ms_warning("UPNP is not available, reset firewall policy to no firewall"); - pol = LinphonePolicyNoFirewall; - policy = "none"; #endif //BUILD_UPNP break; } -#ifdef BUILD_UPNP - if(pol == LinphonePolicyUseUpnp) { - if(lc->upnp == NULL) { - lc->upnp = linphone_upnp_context_new(lc); - } - } else { - if(lc->upnp != NULL) { - linphone_upnp_context_destroy(lc->upnp); - lc->upnp = NULL; - } - } - linphone_core_enable_keep_alive(lc, (lc->sip_conf.keepalive_period > 0)); -#endif //BUILD_UPNP - switch(pol) { - case LinphonePolicyUseUpnp: - sal_nat_helper_enable(lc->sal, FALSE); - sal_enable_auto_contacts(lc->sal,FALSE); - sal_use_rport(lc->sal, FALSE); - break; - default: - sal_nat_helper_enable(lc->sal, lp_config_get_int(lc->config,"net","enable_nat_helper",1)); - sal_enable_auto_contacts(lc->sal,TRUE); - sal_use_rport(lc->sal, lp_config_get_int(lc->config,"sip","use_rport",1)); - break; - } - if (lc->sip_conf.contact) update_primary_contact(lc); - if (linphone_core_ready(lc)) - lp_config_set_string(lc->config,"net","firewall_policy",policy); + + linphone_nat_policy_set_stun_server(nat_policy, linphone_core_get_stun_server(lc)); + linphone_core_set_nat_policy(lc, nat_policy); + linphone_nat_policy_unref(nat_policy); } -LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc){ + +LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc) { const char *policy; + policy = lp_config_get_string(lc->config, "net", "firewall_policy", NULL); - if ((policy == NULL) || (strcmp(policy, "0") == 0)) + if (policy == NULL) { + LinphoneNatPolicy *nat_policy = linphone_core_get_nat_policy(lc); + if (nat_policy == NULL) { + return LinphonePolicyNoFirewall; + } else if (linphone_nat_policy_upnp_enabled(nat_policy)) + return LinphonePolicyUseUpnp; + else if (linphone_nat_policy_ice_enabled(nat_policy)) + return LinphonePolicyUseIce; + else if (linphone_nat_policy_stun_enabled(nat_policy)) + return LinphonePolicyUseStun; + else + return LinphonePolicyNoFirewall; + } else if (strcmp(policy, "0") == 0) return LinphonePolicyNoFirewall; else if ((strcmp(policy, "nat_address") == 0) || (strcmp(policy, "1") == 0)) return LinphonePolicyUseNatAddress; @@ -5227,6 +5232,38 @@ LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc) return LinphonePolicyNoFirewall; } +void linphone_core_set_nat_policy(LinphoneCore *lc, LinphoneNatPolicy *policy) { + if (policy != NULL) policy = linphone_nat_policy_ref(policy); /* Prevent object destruction if the same policy is used */ + if (lc->nat_policy != NULL) linphone_nat_policy_unref(lc->nat_policy); + if (policy != NULL) lc->nat_policy = policy; + +#ifdef BUILD_UPNP + linphone_core_enable_keep_alive(lc, (lc->sip_conf.keepalive_period > 0)); + if (linphone_nat_policy_upnp_enabled(policy)) { + if (lc->upnp == NULL) { + lc->upnp = linphone_upnp_context_new(lc); + } + sal_nat_helper_enable(lc->sal, FALSE); + sal_enable_auto_contacts(lc->sal, FALSE); + sal_use_rport(lc->sal, FALSE); + } else { + if (lc->upnp != NULL) { + linphone_upnp_context_destroy(lc->upnp); + lc->upnp = NULL; + } +#endif + sal_nat_helper_enable(lc->sal, lp_config_get_int(lc->config, "net", "enable_nat_helper", 1)); + sal_enable_auto_contacts(lc->sal, TRUE); + sal_use_rport(lc->sal, lp_config_get_int(lc->config, "sip", "use_rport", 1)); + if (lc->sip_conf.contact) update_primary_contact(lc); +#ifdef BUILD_UPNP + } +#endif +} + +LinphoneNatPolicy * linphone_core_get_nat_policy(const LinphoneCore *lc) { + return lc->nat_policy; +} /******************************************************************************* @@ -6342,6 +6379,10 @@ void net_config_uninit(LinphoneCore *lc) ms_free(lc->net_conf.nat_address_ip); } lp_config_set_int(lc->config,"net","mtu",config->mtu); + if (lc->nat_policy != NULL) { + lp_config_set_string(lc->config, "net", "nat_policy_ref", lc->nat_policy->ref); + linphone_nat_policy_save_to_config(lc->nat_policy, lc->config); + } } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 92b1eb09b..343b088f8 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -407,6 +407,7 @@ LINPHONE_PUBLIC const char* linphone_privacy_to_string(LinphonePrivacy privacy); #include "content.h" #include "event.h" #include "linphonefriend.h" +#include "nat_policy.h" #include "xmlrpc.h" #include "conference.h" #else @@ -416,6 +417,7 @@ LINPHONE_PUBLIC const char* linphone_privacy_to_string(LinphonePrivacy privacy); #include "linphone/content.h" #include "linphone/event.h" #include "linphone/linphonefriend.h" +#include "linphone/nat_policy.h" #include "linphone/xmlrpc.h" #include "linphone/conference.h" #endif @@ -2178,6 +2180,7 @@ typedef struct _LCCallbackObj /** * Policy to use to pass through firewalls. * @ingroup network_parameters + * @deprecated Use LinphoneNatPolicy instead **/ typedef enum _LinphoneFirewallPolicy { LinphonePolicyNoFirewall, /**< Do not use any mechanism to pass through firewalls */ @@ -3190,6 +3193,7 @@ LINPHONE_PUBLIC const char *linphone_core_get_nat_address(const LinphoneCore *lc * @param[in] lc #LinphoneCore object. * @param[in] pol The #LinphoneFirewallPolicy to use. * @ingroup network_parameters + * @deprecated Use linphone_core_set_nat_policy() instead. */ LINPHONE_PUBLIC void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol); @@ -3198,9 +3202,30 @@ LINPHONE_PUBLIC void linphone_core_set_firewall_policy(LinphoneCore *lc, Linphon * @param[in] lc #LinphoneCore object. * @return The #LinphoneFirewallPolicy that is being used. * @ingroup network_parameters + * @deprecated Use linphone_core_get_nat_policy() instead. */ LINPHONE_PUBLIC LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc); +/** + * Set the policy to use to pass through NATs/firewalls. + * It may be overridden by a NAT policy for a specific proxy config. + * @param[in] lc #LinphoneCore object + * @param[in] policy LinphoneNatPolicy object + * @ingroup network_parameters + * @see linphone_proxy_config_set_nat_policy() + */ +LINPHONE_PUBLIC void linphone_core_set_nat_policy(LinphoneCore *lc, LinphoneNatPolicy *policy); + +/** + * Get The policy that is used to pass through NATs/firewalls. + * It may be overridden by a NAT policy for a specific proxy config. + * @param[in] lc #LinphoneCore object + * @return LinphoneNatPolicy object in use. + * @ingroup network_parameters + * @see linphone_proxy_config_get_nat_policy() + */ +LINPHONE_PUBLIC LinphoneNatPolicy * linphone_core_get_nat_policy(const LinphoneCore *lc); + /* sound functions */ /* returns a null terminated static array of string describing the sound devices */ LINPHONE_PUBLIC const char** linphone_core_get_sound_devices(LinphoneCore *lc); diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index 131378cc0..b466c4d7c 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -529,6 +529,31 @@ const char *lp_config_get_string(const LpConfig *lpconfig, const char *section, return default_string; } +MSList * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, MSList *default_list) { + LpItem *item; + LpSection *sec = lp_config_find_section(lpconfig, section); + if (sec != NULL) { + item = lp_section_find_item(sec, key); + if (item != NULL) { + MSList *l = NULL; + char *str; + char *ptr; + str = ptr = ms_strdup(item->value); + while (ptr != NULL) { + char *next = strstr(ptr, ","); + if (next != NULL) { + *(next++) = '\0'; + } + l = ms_list_append(l, ms_strdup(ptr)); + ptr = next; + } + ms_free(str); + return l; + } + } + return default_list; +} + bool_t lp_config_get_range(const LpConfig *lpconfig, const char *section, const char *key, int *min, int *max, int default_min, int default_max) { const char *str = lp_config_get_string(lpconfig, section, key, NULL); if (str != NULL) { @@ -644,6 +669,22 @@ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *ke lpconfig->modified++; } +void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const MSList *value) { + char *strvalue = NULL; + char *tmp = NULL; + const MSList *elem; + for (elem = value; elem != NULL; elem = elem->next) { + if (strvalue) { + tmp = ms_strdup_printf("%s,%s", strvalue, (const char *)elem->data); + ms_free(strvalue); + strvalue = tmp; + } + else strvalue = ms_strdup((const char *)elem->data); + } + lp_config_set_string(lpconfig, section, key, strvalue); + if (strvalue) ms_free(strvalue); +} + void lp_config_set_range(LpConfig *lpconfig, const char *section, const char *key, int min_value, int max_value) { char tmp[30]; snprintf(tmp, sizeof(tmp), "%i-%i", min_value, max_value); diff --git a/coreapi/lpconfig.h b/coreapi/lpconfig.h index d99264bed..feae2a88d 100644 --- a/coreapi/lpconfig.h +++ b/coreapi/lpconfig.h @@ -104,6 +104,13 @@ LINPHONE_PUBLIC int lp_config_read_file(LpConfig *lpconfig, const char *filename **/ LINPHONE_PUBLIC const char *lp_config_get_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_string); +/** + * Retrieves a configuration item as a list of strings, given its section, key, and default value. + * @ingroup misc + * The default value is returned if the config item isn't found. + */ +LINPHONE_PUBLIC MSList * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, MSList *default_list); + /** * Retrieves a configuration item as a range, given its section, key, and default min and max values. * @@ -144,6 +151,12 @@ LINPHONE_PUBLIC float lp_config_get_float(const LpConfig *lpconfig,const char *s **/ LINPHONE_PUBLIC void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *key, const char *value); +/** + * Sets a string list config item + * @ingroup misc + */ +LINPHONE_PUBLIC void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const MSList *value); + /** * Sets a range config item * diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c new file mode 100644 index 000000000..926900461 --- /dev/null +++ b/coreapi/nat_policy.c @@ -0,0 +1,205 @@ +/* +linphone +Copyright (C) 2010-2016 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "linphonecore.h" +#include "private.h" + + +static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) { + if (policy->ref) belle_sip_free(policy->ref); + if (policy->stun_server) belle_sip_free(policy->stun_server); +} + + +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneNatPolicy); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneNatPolicy, belle_sip_object_t, + (belle_sip_object_destroy_t)linphone_nat_policy_destroy, + NULL, // clone + NULL, // marshal + TRUE +); + + +static LinphoneNatPolicy * _linphone_nat_policy_new_with_ref(const char *ref) { + LinphoneNatPolicy *policy = belle_sip_object_new(LinphoneNatPolicy); + belle_sip_object_ref(policy); + policy->ref = belle_sip_strdup(ref); + return policy; +} + +LinphoneNatPolicy * linphone_nat_policy_new(void) { + char ref[17] = { 0 }; + belle_sip_random_token(ref, 16); + return _linphone_nat_policy_new_with_ref(ref); +} + +LinphoneNatPolicy * linphone_nat_policy_new_from_config(LpConfig *config, const char *ref) { + LinphoneNatPolicy *policy = NULL; + char *section; + int index; + bool_t finished = FALSE; + + for (index = 0; finished != TRUE; index++) { + section = belle_sip_strdup_printf("nat_policy_%i", index); + if (lp_config_has_section(config, section)) { + const char *config_ref = lp_config_get_string(config, section, "ref", NULL); + if ((config_ref != NULL) && (strcmp(config_ref, ref) == 0)) { + const char *server = lp_config_get_string(config, section, "stun_server", NULL); + MSList *l = lp_config_get_string_list(config, section, "protocols", NULL); + policy = _linphone_nat_policy_new_with_ref(ref); + if (server != NULL) linphone_nat_policy_set_stun_server(policy, server); + if (l != NULL) { + bool_t upnp_enabled = FALSE; + MSList *elem; + for (elem = l; elem != NULL; elem = elem->next) { + const char *value = (const char *)elem->data; + if (strcmp(value, "stun") == 0) linphone_nat_policy_enable_stun(policy, TRUE); + else if (strcmp(value, "turn") == 0) linphone_nat_policy_enable_turn(policy, TRUE); + else if (strcmp(value, "ice") == 0) linphone_nat_policy_enable_ice(policy, TRUE); + else if (strcmp(value, "upnp") == 0) upnp_enabled = TRUE; + } + if (upnp_enabled) linphone_nat_policy_enable_upnp(policy, TRUE); + } + finished = TRUE; + } + } else finished = TRUE; + belle_sip_free(section); + } + return policy; +} + +static void _linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, LpConfig *config, int index) { + char *section; + MSList *l = NULL; + + section = belle_sip_strdup_printf("nat_policy_%i", index); + lp_config_set_string(config, section, "ref", policy->ref); + lp_config_set_string(config, section, "stun_server", policy->stun_server); + if (linphone_nat_policy_upnp_enabled(policy)) { + l = ms_list_append(l, "upnp"); + } else { + if (linphone_nat_policy_stun_enabled(policy)) l = ms_list_append(l, "stun"); + if (linphone_nat_policy_turn_enabled(policy)) l = ms_list_append(l, "turn"); + if (linphone_nat_policy_ice_enabled(policy)) l = ms_list_append(l, "ice"); + } + lp_config_set_string_list(config, section, "protocols", l); + belle_sip_free(section); +} + +void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, LpConfig *config) { + char *section; + int index; + bool_t finished = FALSE; + + for (index = 0; finished != TRUE; index++) { + section = belle_sip_strdup_printf("nat_policy_%i", index); + if (lp_config_has_section(config, section)) { + const char *config_ref = lp_config_get_string(config, section, "ref", NULL); + if ((config_ref != NULL) && (strcmp(config_ref, policy->ref) == 0)) { + _linphone_nat_policy_save_to_config(policy, config, index); + finished = TRUE; + } + } else { + _linphone_nat_policy_save_to_config(policy, config, index); + finished = TRUE; + } + belle_sip_free(section); + } +} + +LinphoneNatPolicy * linphone_nat_policy_ref(LinphoneNatPolicy *policy) { + belle_sip_object_ref(policy); + return policy; +} + +void linphone_nat_policy_unref(LinphoneNatPolicy *policy) { + belle_sip_object_unref(policy); +} + +void *linphone_nat_policy_get_user_data(const LinphoneNatPolicy *policy) { + return policy->user_data; +} + +void linphone_nat_policy_set_user_data(LinphoneNatPolicy *policy, void *ud) { + policy->user_data = ud; +} + + +void linphone_nat_policy_clear(LinphoneNatPolicy *policy) { + linphone_nat_policy_enable_stun(policy, FALSE); + linphone_nat_policy_enable_turn(policy, FALSE); + linphone_nat_policy_enable_ice(policy, FALSE); + linphone_nat_policy_enable_upnp(policy, FALSE); + linphone_nat_policy_set_stun_server(policy, NULL); +} + +bool_t linphone_nat_policy_stun_enabled(const LinphoneNatPolicy *policy) { + return policy->stun_enabled; +} + +void linphone_nat_policy_enable_stun(LinphoneNatPolicy *policy, bool_t enable) { + policy->stun_enabled = enable; +} + +bool_t linphone_nat_policy_turn_enabled(const LinphoneNatPolicy *policy) { + return policy->turn_enabled; +} + +void linphone_nat_policy_enable_turn(LinphoneNatPolicy *policy, bool_t enable) { + policy->turn_enabled = enable; +} + +bool_t linphone_nat_policy_ice_enabled(const LinphoneNatPolicy *policy) { + return policy->ice_enabled; +} + +void linphone_nat_policy_enable_ice(LinphoneNatPolicy *policy, bool_t enable) { + policy->ice_enabled = enable; +} + +bool_t linphone_nat_policy_upnp_enabled(const LinphoneNatPolicy *policy) { + return policy->upnp_enabled; +} + +void linphone_nat_policy_enable_upnp(LinphoneNatPolicy *policy, bool_t enable) { + policy->upnp_enabled = enable; + if (enable) { +#ifdef BUILD_UPNP + policy->stun_enabled = policy->turn_enabled = policy->ice_enabled = FALSE; + ms_warning("Enabling uPnP NAT policy has disabled any other previously enabled policies"); +#else + ms_warning("Cannot enable the uPnP NAT policy because the uPnP support is not compiled in"); +#endif + } +} + +const char * linphone_nat_policy_get_stun_server(const LinphoneNatPolicy *policy) { + return policy->stun_server; +} + +void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char *stun_server) { + if (policy->stun_server != NULL) { + belle_sip_free(policy->stun_server); + policy->stun_server = NULL; + } + if (stun_server != NULL) { + policy->stun_server = belle_sip_strdup(stun_server); + } +} diff --git a/coreapi/nat_policy.h b/coreapi/nat_policy.h new file mode 100644 index 000000000..b46d7129a --- /dev/null +++ b/coreapi/nat_policy.h @@ -0,0 +1,164 @@ +/* +nat_policy.h +Copyright (C) 2010-2016 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef LINPHONE_NAT_POLICY_H_ +#define LINPHONE_NAT_POLICY_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * @addtogroup network_parameters + * @{ + */ + +/** + * Policy to use to pass through NATs/firewalls. + */ +typedef struct _LinphoneNatPolicy LinphoneNatPolicy; + + +/** + * Create a new LinphoneNatPolicy object with every policies being disabled. + * @return A new LinphoneNatPolicy object. + */ +LINPHONE_PUBLIC LinphoneNatPolicy * linphone_nat_policy_new(void); + +/** + * Acquire a reference to the LinphoneNatPolicy object. + * @param[in] policy LinphoneNatPolicy object. + * @return The same LinphoneNatPolicy object. +**/ +LINPHONE_PUBLIC LinphoneNatPolicy * linphone_nat_policy_ref(LinphoneNatPolicy *policy); + +/** + * Release reference to the LinphoneNatPolicy object. + * @param[in] policy LinphoneNatPolicy object. +**/ +LINPHONE_PUBLIC void linphone_nat_policy_unref(LinphoneNatPolicy *policy); + +/** + * Retrieve the user pointer associated with the LinphoneNatPolicy object. + * @param[in] policy LinphoneNatPolicy object. + * @return The user pointer associated with the LinphoneNatPolicy object. +**/ +LINPHONE_PUBLIC void *linphone_nat_policy_get_user_data(const LinphoneNatPolicy *policy); + +/** + * Assign a user pointer to the LinphoneNatPolicy object. + * @param[in] policy LinphoneNatPolicy object. + * @param[in] ud The user pointer to associate with the LinphoneNatPolicy object. +**/ +LINPHONE_PUBLIC void linphone_nat_policy_set_user_data(LinphoneNatPolicy *policy, void *ud); + +/** + * Clear a NAT policy (deactivate all protocols and unset the STUN server). + * @param[in] policy LinphoneNatPolicy object. + */ +LINPHONE_PUBLIC void linphone_nat_policy_clear(LinphoneNatPolicy *policy); + +/** + * Tell whether STUN is enabled. + * @param[in] policy LinphoneNatPolicy object + * @return Boolean value telling whether STUN is enabled. + */ +LINPHONE_PUBLIC bool_t linphone_nat_policy_stun_enabled(const LinphoneNatPolicy *policy); + +/** + * Enable STUN. + * If TURN is also enabled, TURN will be used instead of STUN. + * @param[in] policy LinphoneNatPolicy object + * @param[in] enable Boolean value telling whether to enable STUN. + */ +LINPHONE_PUBLIC void linphone_nat_policy_enable_stun(LinphoneNatPolicy *policy, bool_t enable); + +/** + * Tell whether TURN is enabled. + * @param[in] policy LinphoneNatPolicy object + * @return Boolean value telling whether TURN is enabled. + */ +LINPHONE_PUBLIC bool_t linphone_nat_policy_turn_enabled(const LinphoneNatPolicy *policy); + +/** + * Enable TURN. + * If STUN is also enabled, it is ignored and TURN is used. + * @param[in] policy LinphoneNatPolicy object + * @param[in] enable Boolean value telling whether to enable TURN. + */ +LINPHONE_PUBLIC void linphone_nat_policy_enable_turn(LinphoneNatPolicy *policy, bool_t enable); + +/** + * Tell whether ICE is enabled. + * @param[in] policy LinphoneNatPolicy object + * @return Boolean value telling whether ICE is enabled. + */ +LINPHONE_PUBLIC bool_t linphone_nat_policy_ice_enabled(const LinphoneNatPolicy *policy); + +/** + * Enable ICE. + * ICE can be enabled without STUN/TURN, in which case only the local candidates will be used. + * @param[in] policy LinphoneNatPolicy object + * @param[in] enable Boolean value telling whether to enable ICE. + */ +LINPHONE_PUBLIC void linphone_nat_policy_enable_ice(LinphoneNatPolicy *policy, bool_t enable); + +/** + * Tell whether uPnP is enabled. + * @param[in] policy LinphoneNatPolicy object + * @return Boolean value telling whether uPnP is enabled. + */ +LINPHONE_PUBLIC bool_t linphone_nat_policy_upnp_enabled(const LinphoneNatPolicy *policy); + +/** + * Enable uPnP. + * This has the effect to disable every other policies (ICE, STUN and TURN). + * @param[in] policy LinphoneNatPolicy object + * @param[in] enable Boolean value telling whether to enable uPnP. + */ +LINPHONE_PUBLIC void linphone_nat_policy_enable_upnp(LinphoneNatPolicy *policy, bool_t enable); + +/** + * Get the STUN server to use with this NAT policy. + * Used when STUN or TURN are enabled. + * @param[in] policy LinphoneNatPolicy object + * @return The STUN server used by this NAT policy. + */ +LINPHONE_PUBLIC const char * linphone_nat_policy_get_stun_server(const LinphoneNatPolicy *policy); + +/** + * Set the STUN server to use with this NAT policy. + * Used when STUN or TURN are enabled. + * @param[in] policy LinphoneNatPolicy object + * @param[in] stun_server The STUN server to use with this NAT policy. + */ +LINPHONE_PUBLIC void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char *stun_server); + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif + +#endif /* LINPHONE_NAT_POLICY_H_ */ diff --git a/coreapi/private.h b/coreapi/private.h index 436228f3d..881d5ce6a 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -614,6 +614,7 @@ struct _LinphoneProxyConfig char *dial_prefix; LinphoneRegistrationState state; LinphoneAVPFMode avpf_mode; + LinphoneNatPolicy *nat_policy; bool_t commit; bool_t reg_sendregister; @@ -957,6 +958,7 @@ struct _LinphoneCore char* user_certificates_path; LinphoneVideoPolicy video_policy; time_t network_last_check; + LinphoneNatPolicy *nat_policy; bool_t use_files; bool_t apply_nat_settings; @@ -1185,6 +1187,22 @@ struct _LinphoneBuffer { BELLE_SIP_DECLARE_VPTR(LinphoneBuffer); +struct _LinphoneNatPolicy { + belle_sip_object_t base; + void *user_data; + char *stun_server; + char *ref; + bool_t stun_enabled; + bool_t turn_enabled; + bool_t ice_enabled; + bool_t upnp_enabled; +}; + +BELLE_SIP_DECLARE_VPTR(LinphoneNatPolicy); + +LinphoneNatPolicy * linphone_nat_policy_new_from_config(LpConfig *config, const char *ref); +void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, LpConfig *config); + /***************************************************************************** * XML-RPC interface * @@ -1405,7 +1423,8 @@ BELLE_SIP_TYPE_ID(LinphoneXmlRpcRequestCbs), BELLE_SIP_TYPE_ID(LinphoneXmlRpcSession), BELLE_SIP_TYPE_ID(LinphoneTunnelConfig), BELLE_SIP_TYPE_ID(LinphoneFriendListCbs), -BELLE_SIP_TYPE_ID(LinphoneEvent) +BELLE_SIP_TYPE_ID(LinphoneEvent), +BELLE_SIP_TYPE_ID(LinphoneNatPolicy) BELLE_SIP_DECLARE_TYPES_END diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 6cd24c61f..2f0532455 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -1355,6 +1355,11 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC lp_config_set_int(config,key,"privacy",cfg->privacy); if (cfg->refkey) lp_config_set_string(config,key,"refkey",cfg->refkey); lp_config_set_int(config, key, "publish_expires", cfg->publish_expires); + + if (cfg->nat_policy != NULL) { + lp_config_set_string(config, key, "nat_policy_ref", cfg->nat_policy->ref); + linphone_nat_policy_save_to_config(cfg->nat_policy, config); + } } @@ -1377,6 +1382,7 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore* lc LinphoneProxyConfig *cfg; char key[50]; LpConfig *config=lc->config; + const char *nat_policy_ref; sprintf(key,"proxy_%i",index); @@ -1415,6 +1421,11 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore* lc CONFIGURE_STRING_VALUE(cfg,config,key,ref_key,"refkey") CONFIGURE_INT_VALUE(cfg,config,key,publish_expires,"publish_expires") + nat_policy_ref = lp_config_get_string(config, key, "nat_policy_ref", NULL); + if (nat_policy_ref != NULL) { + cfg->nat_policy = linphone_nat_policy_new_from_config(config, nat_policy_ref); + } + return cfg; } @@ -1677,3 +1688,15 @@ void linphone_proxy_config_set_ref_key(LinphoneProxyConfig *cfg, const char *ref } if (refkey) cfg->refkey=ms_strdup(refkey); } + +const LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const LinphoneProxyConfig *cfg) { + return cfg->nat_policy; +} + +void linphone_proxy_config_set_nat_policy(LinphoneProxyConfig *cfg, LinphoneNatPolicy *policy) { + if (cfg->nat_policy != NULL) { + linphone_nat_policy_unref(cfg->nat_policy); + cfg->nat_policy = NULL; + } + if (policy != NULL) cfg->nat_policy = linphone_nat_policy_ref(policy); +} From e224761160d94478655ffd51715dff55233c290c Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 26 Apr 2016 13:46:20 +0200 Subject: [PATCH 003/124] Handle DNS SRV resolution of STUN server. --- coreapi/bellesip_sal/sal_impl.c | 4 + coreapi/linphonecore.c | 42 ++------ coreapi/misc.c | 48 +++++---- coreapi/nat_policy.c | 180 +++++++++++++++++++++++--------- coreapi/nat_policy.h | 35 +++++-- coreapi/private.h | 8 +- coreapi/proxy.c | 4 +- include/sal/sal.h | 1 + 8 files changed, 209 insertions(+), 113 deletions(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 90083418d..7f58094e2 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -1154,6 +1154,10 @@ SalResolverContext * sal_resolve_a(Sal* sal, const char *name, int port, int fam return (SalResolverContext*)belle_sip_stack_resolve_a(sal->stack,name,port,family,(belle_sip_resolver_callback_t)cb,data); } +SalResolverContext * sal_resolve(Sal *sal, const char *service, const char *transport, const char *name, int port, int family, SalResolverCallback cb, void *data) { + return (SalResolverContext *)belle_sip_stack_resolve(sal->stack, service, transport, name, port, family, (belle_sip_resolver_callback_t)cb, data); +} + /* void sal_resolve_cancel(Sal *sal, SalResolverContext* ctx){ belle_sip_stack_resolve_cancel(sal->stack,ctx); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 9e44ac9dd..bb44d5da3 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -759,7 +759,7 @@ static void net_config_read (LinphoneCore *lc) nat_policy_ref = lp_config_get_string(lc->config, "net", "nat_policy_ref", NULL); if (nat_policy_ref != NULL) { - lc->nat_policy = linphone_nat_policy_new_from_config(lc->config, nat_policy_ref); + lc->nat_policy = linphone_core_create_nat_policy_from_config(lc, nat_policy_ref); } lc->net_conf.nat_address_ip = NULL; @@ -5073,31 +5073,18 @@ void linphone_core_send_dtmf(LinphoneCore *lc, char dtmf) linphone_call_send_dtmf(call, dtmf); } -void linphone_core_set_stun_server(LinphoneCore *lc, const char *server){ - if (lc->net_conf.stun_server!=NULL) - ms_free(lc->net_conf.stun_server); - if (server) - lc->net_conf.stun_server=ms_strdup(server); - else lc->net_conf.stun_server=NULL; - - /* each time the stun server is changed, we must clean the resolved cached addrinfo*/ - if (lc->net_conf.stun_addrinfo){ - freeaddrinfo(lc->net_conf.stun_addrinfo); - lc->net_conf.stun_addrinfo=NULL; - } - /*if a stun server is set, we must request asynchronous resolution immediately to be ready for call*/ - if (lc->net_conf.stun_server){ - linphone_core_resolve_stun_server(lc); - } - +void linphone_core_set_stun_server(LinphoneCore *lc, const char *server) { if (lc->nat_policy != NULL) - linphone_nat_policy_set_stun_server(lc->nat_policy, lc->net_conf.stun_server); - else if (linphone_core_ready(lc)) - lp_config_set_string(lc->config,"net","stun_server",lc->net_conf.stun_server); + linphone_nat_policy_set_stun_server(lc->nat_policy, server); + else + lp_config_set_string(lc->config, "net", "stun_server", server); } const char * linphone_core_get_stun_server(const LinphoneCore *lc){ - return lc->net_conf.stun_server; + if (lc->nat_policy != NULL) + return linphone_nat_policy_get_stun_server(lc->nat_policy); + else + return lp_config_get_string(lc->config, "net", "stun_server", NULL); } @@ -5173,7 +5160,7 @@ void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy nat_policy = linphone_nat_policy_ref(lc->nat_policy); linphone_nat_policy_clear(nat_policy); } else { - nat_policy = linphone_nat_policy_new(); + nat_policy = linphone_core_create_nat_policy(lc); } switch (pol) { @@ -6364,13 +6351,6 @@ void net_config_uninit(LinphoneCore *lc) { net_config_t *config=&lc->net_conf; - if (config->stun_server!=NULL){ - ms_free(config->stun_server); - } - if (config->stun_addrinfo){ - freeaddrinfo(config->stun_addrinfo); - config->stun_addrinfo=NULL; - } if (config->nat_address!=NULL){ lp_config_set_string(lc->config,"net","nat_address",config->nat_address); ms_free(lc->net_conf.nat_address); @@ -6381,7 +6361,7 @@ void net_config_uninit(LinphoneCore *lc) lp_config_set_int(lc->config,"net","mtu",config->mtu); if (lc->nat_policy != NULL) { lp_config_set_string(lc->config, "net", "nat_policy_ref", lc->nat_policy->ref); - linphone_nat_policy_save_to_config(lc->nat_policy, lc->config); + linphone_nat_policy_save_to_config(lc->nat_policy); } } diff --git a/coreapi/misc.c b/coreapi/misc.c index 65bf11ad5..33ef72146 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -584,16 +584,20 @@ static void stun_server_resolved(LinphoneCore *lc, const char *name, struct addr } void linphone_core_resolve_stun_server(LinphoneCore *lc){ - /* - * WARNING: stun server resolution only done in IPv4. - * TODO: use IPv6 resolution if linphone_core_ipv6_enabled()==TRUE and use V4Mapped addresses for ICE gathering. - */ - const char *server=lc->net_conf.stun_server; - if (lc->sal && server && !lc->net_conf.stun_res){ - char host[NI_MAXHOST]; - int port=3478; - linphone_parse_host_port(server,host,sizeof(host),&port); - lc->net_conf.stun_res=sal_resolve_a(lc->sal,host,port,AF_INET,(SalResolverCallback)stun_server_resolved,lc); + if (lc->nat_policy != NULL) { + linphone_nat_policy_resolve_stun_server(lc->nat_policy); + } else { + /* + * WARNING: stun server resolution only done in IPv4. + * TODO: use IPv6 resolution if linphone_core_ipv6_enabled()==TRUE and use V4Mapped addresses for ICE gathering. + */ + const char *server=linphone_core_get_stun_server(lc); + if (lc->sal && server && !lc->net_conf.stun_res){ + char host[NI_MAXHOST]; + int port=3478; + linphone_parse_host_port(server,host,sizeof(host),&port); + lc->net_conf.stun_res=sal_resolve_a(lc->sal,host,port,AF_INET,(SalResolverCallback)stun_server_resolved,lc); + } } } @@ -609,18 +613,22 @@ void linphone_core_resolve_stun_server(LinphoneCore *lc){ * changed. **/ const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc){ - const char *server=linphone_core_get_stun_server(lc); - if (server){ - int wait_ms=0; - int wait_limit=1000; - linphone_core_resolve_stun_server(lc); - while (!lc->net_conf.stun_addrinfo && lc->net_conf.stun_res!=NULL && wait_mssal); - ms_usleep(50000); - wait_ms+=50; + if (lc->nat_policy != NULL) { + return linphone_nat_policy_get_stun_server_addrinfo(lc->nat_policy); + } else { + const char *server=linphone_core_get_stun_server(lc); + if (server){ + int wait_ms=0; + int wait_limit=1000; + linphone_core_resolve_stun_server(lc); + while (!lc->net_conf.stun_addrinfo && lc->net_conf.stun_res!=NULL && wait_mssal); + ms_usleep(50000); + wait_ms+=50; + } } + return lc->net_conf.stun_addrinfo; } - return lc->net_conf.stun_addrinfo; } void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable) { diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 926900461..f28bf7985 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -21,11 +21,33 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "private.h" +static LinphoneNatPolicy * _linphone_nat_policy_new_with_ref(LinphoneCore *lc, const char *ref) { + LinphoneNatPolicy *policy = belle_sip_object_new(LinphoneNatPolicy); + belle_sip_object_ref(policy); + policy->lc = lc; + policy->ref = belle_sip_strdup(ref); + return policy; +} + +static LinphoneNatPolicy * linphone_nat_policy_new(LinphoneCore *lc) { + char ref[17] = { 0 }; + belle_sip_random_token(ref, 16); + return _linphone_nat_policy_new_with_ref(lc, ref); +} + static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) { if (policy->ref) belle_sip_free(policy->ref); if (policy->stun_server) belle_sip_free(policy->stun_server); + if (policy->stun_addrinfo) freeaddrinfo(policy->stun_addrinfo); } +static bool_t linphone_nat_policy_stun_server_activated(LinphoneNatPolicy *policy) { + const char *server = linphone_nat_policy_get_stun_server(policy); + return (server != NULL) && (server[0] != '\0') + && ((linphone_nat_policy_stun_enabled(policy) == TRUE) || (linphone_nat_policy_turn_enabled(policy) == TRUE)); +} + + BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneNatPolicy); @@ -37,54 +59,6 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneNatPolicy, belle_sip_object_t, ); -static LinphoneNatPolicy * _linphone_nat_policy_new_with_ref(const char *ref) { - LinphoneNatPolicy *policy = belle_sip_object_new(LinphoneNatPolicy); - belle_sip_object_ref(policy); - policy->ref = belle_sip_strdup(ref); - return policy; -} - -LinphoneNatPolicy * linphone_nat_policy_new(void) { - char ref[17] = { 0 }; - belle_sip_random_token(ref, 16); - return _linphone_nat_policy_new_with_ref(ref); -} - -LinphoneNatPolicy * linphone_nat_policy_new_from_config(LpConfig *config, const char *ref) { - LinphoneNatPolicy *policy = NULL; - char *section; - int index; - bool_t finished = FALSE; - - for (index = 0; finished != TRUE; index++) { - section = belle_sip_strdup_printf("nat_policy_%i", index); - if (lp_config_has_section(config, section)) { - const char *config_ref = lp_config_get_string(config, section, "ref", NULL); - if ((config_ref != NULL) && (strcmp(config_ref, ref) == 0)) { - const char *server = lp_config_get_string(config, section, "stun_server", NULL); - MSList *l = lp_config_get_string_list(config, section, "protocols", NULL); - policy = _linphone_nat_policy_new_with_ref(ref); - if (server != NULL) linphone_nat_policy_set_stun_server(policy, server); - if (l != NULL) { - bool_t upnp_enabled = FALSE; - MSList *elem; - for (elem = l; elem != NULL; elem = elem->next) { - const char *value = (const char *)elem->data; - if (strcmp(value, "stun") == 0) linphone_nat_policy_enable_stun(policy, TRUE); - else if (strcmp(value, "turn") == 0) linphone_nat_policy_enable_turn(policy, TRUE); - else if (strcmp(value, "ice") == 0) linphone_nat_policy_enable_ice(policy, TRUE); - else if (strcmp(value, "upnp") == 0) upnp_enabled = TRUE; - } - if (upnp_enabled) linphone_nat_policy_enable_upnp(policy, TRUE); - } - finished = TRUE; - } - } else finished = TRUE; - belle_sip_free(section); - } - return policy; -} - static void _linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, LpConfig *config, int index) { char *section; MSList *l = NULL; @@ -103,7 +77,8 @@ static void _linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, belle_sip_free(section); } -void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, LpConfig *config) { +void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy) { + LpConfig *config = policy->lc->config; char *section; int index; bool_t finished = FALSE; @@ -195,11 +170,114 @@ const char * linphone_nat_policy_get_stun_server(const LinphoneNatPolicy *policy } void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char *stun_server) { + char *new_stun_server = NULL; + + if (stun_server != NULL) new_stun_server = belle_sip_strdup(stun_server); if (policy->stun_server != NULL) { belle_sip_free(policy->stun_server); policy->stun_server = NULL; } - if (stun_server != NULL) { - policy->stun_server = belle_sip_strdup(stun_server); + if (new_stun_server != NULL) { + policy->stun_server = new_stun_server; + linphone_nat_policy_resolve_stun_server(policy); } } + +static void stun_server_resolved(LinphoneNatPolicy *policy, const char *name, struct addrinfo *addrinfo) { + if (policy->stun_addrinfo) { + belle_sip_freeaddrinfo(policy->stun_addrinfo); + policy->stun_addrinfo = NULL; + } + if (addrinfo) { + ms_message("Stun server resolution successful."); + } else { + ms_warning("Stun server resolution failed."); + } + policy->stun_addrinfo = addrinfo; + policy->stun_resolver_context = NULL; +} + +void linphone_nat_policy_resolve_stun_server(LinphoneNatPolicy *policy) { + const char *service = NULL; + + /* + * WARNING: stun server resolution only done in IPv4. + * TODO: use IPv6 resolution if linphone_core_ipv6_enabled()==TRUE and use V4Mapped addresses for ICE gathering. + */ + if (linphone_nat_policy_stun_server_activated(policy) + && (policy->lc->sal != NULL) + && !policy->stun_resolver_context) { + char host[NI_MAXHOST]; + int port = 3478; + linphone_parse_host_port(policy->stun_server, host, sizeof(host), &port); + if (linphone_nat_policy_turn_enabled(policy)) service = "turn"; + else if (linphone_nat_policy_stun_enabled(policy)) service = "stun"; + if (service != NULL) { + policy->stun_resolver_context = sal_resolve(policy->lc->sal, service, "udp", host, port, AF_INET, (SalResolverCallback)stun_server_resolved, policy); + } + } +} + +const struct addrinfo * linphone_nat_policy_get_stun_server_addrinfo(LinphoneNatPolicy *policy) { + /* + * It is critical not to block for a long time if it can't be resolved, otherwise this stucks the main thread when making a call. + * On the contrary, a fully asynchronous call initiation is complex to develop. + * The compromise is then: + * - have a cache of the stun server addrinfo + * - this cached value is returned when it is non-null + * - an asynchronous resolution is asked each time this function is called to ensure frequent refreshes of the cached value. + * - if no cached value exists, block for a short time; this case must be unprobable because the resolution will be asked each + * time the stun server value is changed. + */ + if (linphone_nat_policy_stun_server_activated(policy)) { + int wait_ms = 0; + int wait_limit = 1000; + linphone_nat_policy_resolve_stun_server(policy); + while ((policy->stun_addrinfo == NULL) && (policy->stun_resolver_context != NULL) && (wait_ms < wait_limit)) { + sal_iterate(policy->lc->sal); + ms_usleep(50000); + wait_ms += 50; + } + } + return policy->stun_addrinfo; +} + +LinphoneNatPolicy * linphone_core_create_nat_policy(LinphoneCore *lc) { + return linphone_nat_policy_new(lc); +} + +LinphoneNatPolicy * linphone_core_create_nat_policy_from_config(LinphoneCore *lc, const char *ref) { + LpConfig *config = lc->config; + LinphoneNatPolicy *policy = NULL; + char *section; + int index; + bool_t finished = FALSE; + + for (index = 0; finished != TRUE; index++) { + section = belle_sip_strdup_printf("nat_policy_%i", index); + if (lp_config_has_section(config, section)) { + const char *config_ref = lp_config_get_string(config, section, "ref", NULL); + if ((config_ref != NULL) && (strcmp(config_ref, ref) == 0)) { + const char *server = lp_config_get_string(config, section, "stun_server", NULL); + MSList *l = lp_config_get_string_list(config, section, "protocols", NULL); + policy = _linphone_nat_policy_new_with_ref(lc, ref); + if (server != NULL) linphone_nat_policy_set_stun_server(policy, server); + if (l != NULL) { + bool_t upnp_enabled = FALSE; + MSList *elem; + for (elem = l; elem != NULL; elem = elem->next) { + const char *value = (const char *)elem->data; + if (strcmp(value, "stun") == 0) linphone_nat_policy_enable_stun(policy, TRUE); + else if (strcmp(value, "turn") == 0) linphone_nat_policy_enable_turn(policy, TRUE); + else if (strcmp(value, "ice") == 0) linphone_nat_policy_enable_ice(policy, TRUE); + else if (strcmp(value, "upnp") == 0) upnp_enabled = TRUE; + } + if (upnp_enabled) linphone_nat_policy_enable_upnp(policy, TRUE); + } + finished = TRUE; + } + } else finished = TRUE; + belle_sip_free(section); + } + return policy; +} diff --git a/coreapi/nat_policy.h b/coreapi/nat_policy.h index b46d7129a..96147ce67 100644 --- a/coreapi/nat_policy.h +++ b/coreapi/nat_policy.h @@ -37,12 +37,6 @@ extern "C" { typedef struct _LinphoneNatPolicy LinphoneNatPolicy; -/** - * Create a new LinphoneNatPolicy object with every policies being disabled. - * @return A new LinphoneNatPolicy object. - */ -LINPHONE_PUBLIC LinphoneNatPolicy * linphone_nat_policy_new(void); - /** * Acquire a reference to the LinphoneNatPolicy object. * @param[in] policy LinphoneNatPolicy object. @@ -152,6 +146,35 @@ LINPHONE_PUBLIC const char * linphone_nat_policy_get_stun_server(const LinphoneN */ LINPHONE_PUBLIC void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char *stun_server); +/** + * Start a STUN server DNS resolution. + * @param[in] policy LinphoneNatPolicy object + */ +LINPHONE_PUBLIC void linphone_nat_policy_resolve_stun_server(LinphoneNatPolicy *policy); + +/** + * Get the addrinfo representation of the STUN server address. + * WARNING: This function may block for up to 1 second. + * @param[in] policy LinphoneNatPolicy object + * @return addrinfo representation of the STUN server address. + */ +LINPHONE_PUBLIC const struct addrinfo * linphone_nat_policy_get_stun_server_addrinfo(LinphoneNatPolicy *policy); + +/** + * Create a new LinphoneNatPolicy object with every policies being disabled. + * @param[in] lc LinphoneCore object + * @return A new LinphoneNatPolicy object. + */ +LINPHONE_PUBLIC LinphoneNatPolicy * linphone_core_create_nat_policy(LinphoneCore *lc); + +/** + * Create a new LinphoneNatPolicy by reading the config of a LinphoneCore according to the passed ref. + * @param[in] lc LinphoneCore object + * @param[in] ref The reference of a NAT policy in the config of the LinphoneCore + * @return A new LinphoneNatPolicy object. + */ +LINPHONE_PUBLIC LinphoneNatPolicy * linphone_core_create_nat_policy_from_config(LinphoneCore *lc, const char *ref); + /** * @} */ diff --git a/coreapi/private.h b/coreapi/private.h index 881d5ce6a..6d36cf6ed 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -437,6 +437,7 @@ LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, Li LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc); LINPHONE_PUBLIC LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t synchronize); +int linphone_parse_host_port(const char *input, char *host, size_t hostlen, int *port); int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, socklen_t *socklen, int default_port); bool_t host_has_ipv6_network(void); @@ -799,7 +800,6 @@ typedef struct net_config { char *nat_address; /* may be IP or host name */ char *nat_address_ip; /* ip translated from nat_address */ - char *stun_server; struct addrinfo *stun_addrinfo; SalResolverContext * stun_res; int download_bw; @@ -1190,6 +1190,9 @@ BELLE_SIP_DECLARE_VPTR(LinphoneBuffer); struct _LinphoneNatPolicy { belle_sip_object_t base; void *user_data; + LinphoneCore *lc; + SalResolverContext *stun_resolver_context; + struct addrinfo *stun_addrinfo; char *stun_server; char *ref; bool_t stun_enabled; @@ -1200,8 +1203,7 @@ struct _LinphoneNatPolicy { BELLE_SIP_DECLARE_VPTR(LinphoneNatPolicy); -LinphoneNatPolicy * linphone_nat_policy_new_from_config(LpConfig *config, const char *ref); -void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, LpConfig *config); +void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy); /***************************************************************************** diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 2f0532455..0231d1ced 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -1358,7 +1358,7 @@ void linphone_proxy_config_write_to_config_file(LpConfig *config, LinphoneProxyC if (cfg->nat_policy != NULL) { lp_config_set_string(config, key, "nat_policy_ref", cfg->nat_policy->ref); - linphone_nat_policy_save_to_config(cfg->nat_policy, config); + linphone_nat_policy_save_to_config(cfg->nat_policy); } } @@ -1423,7 +1423,7 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LinphoneCore* lc nat_policy_ref = lp_config_get_string(config, key, "nat_policy_ref", NULL); if (nat_policy_ref != NULL) { - cfg->nat_policy = linphone_nat_policy_new_from_config(config, nat_policy_ref); + cfg->nat_policy = linphone_core_create_nat_policy_from_config(lc, nat_policy_ref); } return cfg; diff --git a/include/sal/sal.h b/include/sal/sal.h index 057c9d1b5..0fa288ea0 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -807,6 +807,7 @@ typedef void (*SalResolverCallback)(void *data, const char *name, struct addrinf typedef struct SalResolverContext SalResolverContext; LINPHONE_PUBLIC SalResolverContext * sal_resolve_a(Sal* sal, const char *name, int port, int family, SalResolverCallback cb, void *data); +LINPHONE_PUBLIC SalResolverContext * sal_resolve(Sal *sal, const char *service, const char *transport, const char *name, int port, int family, SalResolverCallback cb, void *data); //void sal_resolve_cancel(Sal *sal, SalResolverContext *ctx); SalCustomHeader *sal_custom_header_append(SalCustomHeader *ch, const char *name, const char *value); From ef66a8e39253e84c99ad1cf6b2c358a0392533df Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 27 Apr 2016 17:02:25 +0200 Subject: [PATCH 004/124] Enable TURN for the ICE session if the NAT policy tells to do so. --- coreapi/linphone_proxy_config.h | 2 +- coreapi/linphonecall.c | 26 +++++++++++--------------- coreapi/misc.c | 17 ++++++++++++----- coreapi/proxy.c | 2 +- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/coreapi/linphone_proxy_config.h b/coreapi/linphone_proxy_config.h index 128d777a3..a12dac9be 100644 --- a/coreapi/linphone_proxy_config.h +++ b/coreapi/linphone_proxy_config.h @@ -554,7 +554,7 @@ LINPHONE_PUBLIC void linphone_proxy_config_set_ref_key(LinphoneProxyConfig *cfg, * @return LinphoneNatPolicy object in use. * @see linphone_core_get_nat_policy() */ -LINPHONE_PUBLIC const LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const LinphoneProxyConfig *cfg); +LINPHONE_PUBLIC LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const LinphoneProxyConfig *cfg); /** * Set the policy to use to pass through NATs/firewalls when using this proxy config. diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index b90445d40..fddffa09c 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1311,7 +1311,7 @@ static void linphone_call_compute_streams_indexes(LinphoneCall *call, const SalM LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op){ LinphoneCall *call = belle_sip_object_new(LinphoneCall); SalMediaDescription *md; - LinphoneFirewallPolicy fpol; + LinphoneNatPolicy *nat_policy = NULL; int i; call->dir=LinphoneCallIncoming; @@ -1386,28 +1386,26 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro } } - fpol=linphone_core_get_firewall_policy(call->core); - /*create the ice session now if ICE is required*/ - if (fpol==LinphonePolicyUseIce){ + if (call->dest_proxy != NULL) nat_policy = linphone_proxy_config_get_nat_policy(call->dest_proxy); + if (nat_policy == NULL) nat_policy = linphone_core_get_nat_policy(call->core); + if ((nat_policy != NULL) && linphone_nat_policy_ice_enabled(nat_policy)) { + /* Create the ice session now if ICE is required */ if (md){ linphone_call_create_ice_session(call, IR_Controlled); }else{ - fpol=LinphonePolicyNoFirewall; + nat_policy = NULL; ms_warning("ICE not supported for incoming INVITE without SDP."); } } /*reserve the sockets immediately*/ linphone_call_init_media_streams(call); - switch (fpol) { - case LinphonePolicyUseIce: + if (nat_policy != NULL) { + if (linphone_nat_policy_ice_enabled(nat_policy)) { call->defer_notify_incoming = linphone_call_prepare_ice(call,TRUE) == 1; - break; - case LinphonePolicyUseStun: + } else if (linphone_nat_policy_stun_enabled(nat_policy)) { call->ping_time=linphone_core_run_stun_tests(call->core,call); - /* No break to also destroy ice session in this case. */ - break; - case LinphonePolicyUseUpnp: + } else if (linphone_nat_policy_upnp_enabled(nat_policy)) { #ifdef BUILD_UPNP if(!lc->rtp_conf.disable_upnp) { call->upnp_session = linphone_upnp_session_new(call); @@ -1419,9 +1417,7 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro } } #endif //BUILD_UPNP - break; - default: - break; + } } discover_mtu(lc,linphone_address_get_domain(from)); diff --git a/coreapi/misc.c b/coreapi/misc.c index 33ef72146..f6cca47f6 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -641,7 +641,12 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){ IceCheckList *audio_check_list; IceCheckList *video_check_list; IceCheckList *text_check_list; - const char *server = linphone_core_get_stun_server(lc); + LinphoneNatPolicy *nat_policy = NULL; + const char *server = NULL; + + if (call->dest_proxy != NULL) nat_policy = linphone_proxy_config_get_nat_policy(call->dest_proxy); + if (nat_policy == NULL) nat_policy = linphone_core_get_nat_policy(lc); + if (nat_policy != NULL) server = linphone_nat_policy_get_stun_server(nat_policy); if (call->ice_session == NULL) return -1; audio_check_list = ice_session_check_list(call->ice_session, call->main_audio_stream_index); @@ -653,8 +658,8 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){ ms_warning("Ice gathering is not implemented for ipv6"); return -1; } - if (server){ - ai=linphone_core_get_stun_server_addrinfo(lc); + if ((nat_policy != NULL) && (server != NULL) && (server[0] != '\0')) { + ai=linphone_nat_policy_get_stun_server_addrinfo(nat_policy); if (ai==NULL){ ms_warning("Fail to resolve STUN server for ICE gathering, continuing without stun."); } @@ -687,9 +692,11 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){ ice_add_local_candidate(text_check_list, "host", local_addr, call->media_ports[call->main_text_stream_index].rtcp_port, 2, NULL); call->stats[LINPHONE_CALL_STATS_TEXT].ice_state = LinphoneIceStateInProgress; } - if (ai){ - ms_message("ICE: gathering candidate from [%s]",server); + if ((ai != NULL) && (nat_policy != NULL) + && (linphone_nat_policy_stun_enabled(nat_policy) || linphone_nat_policy_turn_enabled(nat_policy))) { + ms_message("ICE: gathering candidate from [%s] using %s", server, linphone_nat_policy_turn_enabled(nat_policy) ? "TURN" : "STUN"); /* Gather local srflx candidates. */ + ice_session_enable_turn(call->ice_session, linphone_nat_policy_turn_enabled(nat_policy)); ice_session_gather_candidates(call->ice_session, ai->ai_addr, (socklen_t)ai->ai_addrlen); return 1; } else { diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 0231d1ced..9d63f5125 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -1689,7 +1689,7 @@ void linphone_proxy_config_set_ref_key(LinphoneProxyConfig *cfg, const char *ref if (refkey) cfg->refkey=ms_strdup(refkey); } -const LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const LinphoneProxyConfig *cfg) { +LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const LinphoneProxyConfig *cfg) { return cfg->nat_policy; } From 8f6d6539e64a5194ee456db9df8d083234e97682 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 29 Apr 2016 10:39:26 +0200 Subject: [PATCH 005/124] Implement STUN authentication request callback. --- coreapi/linphonecall.c | 4 ++-- coreapi/misc.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index fddffa09c..36f1a6f5a 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1434,11 +1434,11 @@ void linphone_call_free_media_resources(LinphoneCall *call){ int i; linphone_call_stop_media_streams(call); + linphone_call_delete_upnp_session(call); + linphone_call_delete_ice_session(call); for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; ++i){ ms_media_stream_sessions_uninit(&call->sessions[i]); } - linphone_call_delete_upnp_session(call); - linphone_call_delete_ice_session(call); linphone_call_stats_uninit(&call->stats[LINPHONE_CALL_STATS_AUDIO]); linphone_call_stats_uninit(&call->stats[LINPHONE_CALL_STATS_VIDEO]); linphone_call_stats_uninit(&call->stats[LINPHONE_CALL_STATS_TEXT]); diff --git a/coreapi/misc.c b/coreapi/misc.c index f6cca47f6..9e63a94e6 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -635,6 +635,36 @@ void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable) { lc->forced_ice_relay = enable; } +static void stun_auth_requested_cb(LinphoneCall *call, const char *realm, const char *nonce, const char **username, const char **password, const char **ha1) { + LinphoneProxyConfig *proxy = NULL; + const LinphoneAddress *addr = NULL; + const LinphoneAuthInfo *auth_info = NULL; + LinphoneCore *lc = call->core; + const char *user; + + // Get the username from the proxy config + if (call->dest_proxy != NULL) proxy = call->dest_proxy; + else proxy = linphone_core_get_default_proxy_config(call->core); + if (proxy == NULL) return; + addr = linphone_proxy_config_get_identity_address(proxy); + if (addr == NULL) return; + user = linphone_address_get_username(addr); + if (user == NULL) return; + + auth_info = linphone_core_find_auth_info(lc, realm, user, NULL); + if (auth_info != NULL) { + const char *hash = linphone_auth_info_get_ha1(auth_info); + if (hash != NULL) { + *ha1 = hash; + } else { + *password = linphone_auth_info_get_passwd(auth_info); + } + *username = user; + } else { + ms_warning("No auth info found for STUN auth request"); + } +} + int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){ char local_addr[64]; const struct addrinfo *ai = NULL; @@ -697,6 +727,7 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){ ms_message("ICE: gathering candidate from [%s] using %s", server, linphone_nat_policy_turn_enabled(nat_policy) ? "TURN" : "STUN"); /* Gather local srflx candidates. */ ice_session_enable_turn(call->ice_session, linphone_nat_policy_turn_enabled(nat_policy)); + ice_session_set_stun_auth_requested_cb(call->ice_session, (MSStunAuthRequestedCb)stun_auth_requested_cb, call); ice_session_gather_candidates(call->ice_session, ai->ai_addr, (socklen_t)ai->ai_addrlen); return 1; } else { From 22900baaec5b0f1d9fb493750082bf77d361447d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 6 May 2016 15:38:53 +0200 Subject: [PATCH 006/124] Add possibility to define in the nat policy the username to use for STUN/TURN server authentication. --- coreapi/linphonecore.c | 14 +++++++++++++- coreapi/misc.c | 21 +++++++++++++++++---- coreapi/nat_policy.c | 19 +++++++++++++++++++ coreapi/nat_policy.h | 22 ++++++++++++++++++++-- coreapi/private.h | 1 + 5 files changed, 70 insertions(+), 7 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index bb44d5da3..f78a5d5cd 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5155,12 +5155,17 @@ const char *linphone_core_get_nat_address_resolved(LinphoneCore *lc) void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy pol) { LinphoneNatPolicy *nat_policy; + char *stun_server = NULL; + char *stun_server_username = NULL; if (lc->nat_policy != NULL) { nat_policy = linphone_nat_policy_ref(lc->nat_policy); + stun_server = ms_strdup(linphone_nat_policy_get_stun_server(lc->nat_policy)); + stun_server_username = ms_strdup(linphone_nat_policy_get_stun_server_username(lc->nat_policy)); linphone_nat_policy_clear(nat_policy); } else { nat_policy = linphone_core_create_nat_policy(lc); + stun_server = ms_strdup(linphone_core_get_stun_server(lc)); } switch (pol) { @@ -5184,7 +5189,14 @@ void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy break; } - linphone_nat_policy_set_stun_server(nat_policy, linphone_core_get_stun_server(lc)); + if (stun_server_username != NULL) { + linphone_nat_policy_set_stun_server_username(nat_policy, stun_server_username); + ms_free(stun_server_username); + } + if (stun_server != NULL) { + linphone_nat_policy_set_stun_server(nat_policy, stun_server); + ms_free(stun_server); + } linphone_core_set_nat_policy(lc, nat_policy); linphone_nat_policy_unref(nat_policy); } diff --git a/coreapi/misc.c b/coreapi/misc.c index 9e63a94e6..5cc467d67 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -637,18 +637,31 @@ void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable) { static void stun_auth_requested_cb(LinphoneCall *call, const char *realm, const char *nonce, const char **username, const char **password, const char **ha1) { LinphoneProxyConfig *proxy = NULL; + const LinphoneNatPolicy *nat_policy = NULL; const LinphoneAddress *addr = NULL; const LinphoneAuthInfo *auth_info = NULL; LinphoneCore *lc = call->core; const char *user; - // Get the username from the proxy config + // Get the username from the nat policy or the proxy config if (call->dest_proxy != NULL) proxy = call->dest_proxy; else proxy = linphone_core_get_default_proxy_config(call->core); if (proxy == NULL) return; - addr = linphone_proxy_config_get_identity_address(proxy); - if (addr == NULL) return; - user = linphone_address_get_username(addr); + nat_policy = linphone_proxy_config_get_nat_policy(proxy); + if (nat_policy != NULL) { + user = linphone_nat_policy_get_stun_server_username(nat_policy); + } else { + nat_policy = linphone_core_get_nat_policy(call->core); + if (nat_policy != NULL) { + user = linphone_nat_policy_get_stun_server_username(nat_policy); + } + } + if (user == NULL) { + /* If the username has not been found in the nat_policy, take the username from the currently used proxy config. */ + addr = linphone_proxy_config_get_identity_address(proxy); + if (addr == NULL) return; + user = linphone_address_get_username(addr); + } if (user == NULL) return; auth_info = linphone_core_find_auth_info(lc, realm, user, NULL); diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index f28bf7985..9d172a0a0 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -38,6 +38,7 @@ static LinphoneNatPolicy * linphone_nat_policy_new(LinphoneCore *lc) { static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) { if (policy->ref) belle_sip_free(policy->ref); if (policy->stun_server) belle_sip_free(policy->stun_server); + if (policy->stun_server_username) belle_sip_free(policy->stun_server_username); if (policy->stun_addrinfo) freeaddrinfo(policy->stun_addrinfo); } @@ -66,6 +67,7 @@ static void _linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, section = belle_sip_strdup_printf("nat_policy_%i", index); lp_config_set_string(config, section, "ref", policy->ref); lp_config_set_string(config, section, "stun_server", policy->stun_server); + lp_config_set_string(config, section, "stun_server_username", policy->stun_server_username); if (linphone_nat_policy_upnp_enabled(policy)) { l = ms_list_append(l, "upnp"); } else { @@ -183,6 +185,21 @@ void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char * } } +const char * linphone_nat_policy_get_stun_server_username(const LinphoneNatPolicy *policy) { + return policy->stun_server_username; +} + +void linphone_nat_policy_set_stun_server_username(LinphoneNatPolicy *policy, const char *username) { + char *new_username = NULL; + + if (username != NULL) new_username = belle_sip_strdup(username); + if (policy->stun_server_username != NULL) { + belle_sip_free(policy->stun_server_username); + policy->stun_server_username = NULL; + } + if (new_username != NULL) policy->stun_server_username = new_username; +} + static void stun_server_resolved(LinphoneNatPolicy *policy, const char *name, struct addrinfo *addrinfo) { if (policy->stun_addrinfo) { belle_sip_freeaddrinfo(policy->stun_addrinfo); @@ -259,9 +276,11 @@ LinphoneNatPolicy * linphone_core_create_nat_policy_from_config(LinphoneCore *lc const char *config_ref = lp_config_get_string(config, section, "ref", NULL); if ((config_ref != NULL) && (strcmp(config_ref, ref) == 0)) { const char *server = lp_config_get_string(config, section, "stun_server", NULL); + const char *username = lp_config_get_string(config, section, "stun_server_username", NULL); MSList *l = lp_config_get_string_list(config, section, "protocols", NULL); policy = _linphone_nat_policy_new_with_ref(lc, ref); if (server != NULL) linphone_nat_policy_set_stun_server(policy, server); + if (username != NULL) linphone_nat_policy_set_stun_server_username(policy, username); if (l != NULL) { bool_t upnp_enabled = FALSE; MSList *elem; diff --git a/coreapi/nat_policy.h b/coreapi/nat_policy.h index 96147ce67..e122508aa 100644 --- a/coreapi/nat_policy.h +++ b/coreapi/nat_policy.h @@ -131,7 +131,7 @@ LINPHONE_PUBLIC bool_t linphone_nat_policy_upnp_enabled(const LinphoneNatPolicy LINPHONE_PUBLIC void linphone_nat_policy_enable_upnp(LinphoneNatPolicy *policy, bool_t enable); /** - * Get the STUN server to use with this NAT policy. + * Get the STUN/TURN server to use with this NAT policy. * Used when STUN or TURN are enabled. * @param[in] policy LinphoneNatPolicy object * @return The STUN server used by this NAT policy. @@ -139,13 +139,31 @@ LINPHONE_PUBLIC void linphone_nat_policy_enable_upnp(LinphoneNatPolicy *policy, LINPHONE_PUBLIC const char * linphone_nat_policy_get_stun_server(const LinphoneNatPolicy *policy); /** - * Set the STUN server to use with this NAT policy. + * Set the STUN/TURN server to use with this NAT policy. * Used when STUN or TURN are enabled. * @param[in] policy LinphoneNatPolicy object * @param[in] stun_server The STUN server to use with this NAT policy. */ LINPHONE_PUBLIC void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char *stun_server); +/** + * Get the username used to authenticate with the STUN/TURN server. + * The authentication will search for a LinphoneAuthInfo with this username. + * If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo. + * @param[in] policy LinphoneNatPolicy object + * @return The username used to authenticate with the STUN/TURN server. + */ +LINPHONE_PUBLIC const char * linphone_nat_policy_get_stun_server_username(const LinphoneNatPolicy *policy); + +/** + * Seth the username used to authenticate with the STUN/TURN server. + * The authentication will search for a LinphoneAuthInfo with this username. + * If it is not set the username of the currently used LinphoneProxyConfig is used to search for a LinphoneAuthInfo. + * @param[in] policy LinphoneNatPolicy object + * @param[in] username The username used to authenticate with the STUN/TURN server. + */ +LINPHONE_PUBLIC void linphone_nat_policy_set_stun_server_username(LinphoneNatPolicy *policy, const char *username); + /** * Start a STUN server DNS resolution. * @param[in] policy LinphoneNatPolicy object diff --git a/coreapi/private.h b/coreapi/private.h index 6d36cf6ed..365e0c9e4 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1194,6 +1194,7 @@ struct _LinphoneNatPolicy { SalResolverContext *stun_resolver_context; struct addrinfo *stun_addrinfo; char *stun_server; + char *stun_server_username; char *ref; bool_t stun_enabled; bool_t turn_enabled; From 7e47f0bb556e9e482e97f3adfd8cdaed2bbb183e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 9 May 2016 16:09:50 +0200 Subject: [PATCH 007/124] Add tests for ICE+TURN. --- tester/call_tester.c | 2 +- tester/liblinphone_tester.h | 1 + tester/stun_tester.c | 66 ++++++++++++++++++++++++++++++++++--- tester/tester.c | 10 +++--- 4 files changed, 70 insertions(+), 9 deletions(-) diff --git a/tester/call_tester.c b/tester/call_tester.c index 1be87acb4..f35a1a4cf 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -1173,7 +1173,7 @@ static void call_with_no_sdp_ack_without_sdp(void){ linphone_core_manager_destroy(pauline); } -static void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts) { +void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts) { LinphoneCall *c1 = linphone_core_get_current_call(caller->lc); LinphoneCall *c2 = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(c1); diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 9718e3b1b..9cc244ad8 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -367,6 +367,7 @@ void liblinphone_tester_init(void(*ftester_printf)(int level, const char *fmt, v void liblinphone_tester_uninit(void); int liblinphone_tester_set_log_file(const char *filename); bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, LinphoneIceState state); +void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts); LinphoneConferenceServer* linphone_conference_server_new(const char *rc_file, bool_t do_registration); void linphone_conference_server_destroy(LinphoneConferenceServer *conf_srv); diff --git a/tester/stun_tester.c b/tester/stun_tester.c index bccd747ac..d9f850bce 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -35,7 +35,6 @@ static size_t test_stun_encode(char **buffer) return ms_stun_message_encode(req, buffer); } - static void linphone_stun_test_encode(void) { char *buffer = NULL; @@ -46,7 +45,6 @@ static void linphone_stun_test_encode(void) ms_message("STUN message encoded in %i bytes", (int)len); } - static void linphone_stun_test_grab_ip(void) { LinphoneCoreManager* lc_stun = linphone_core_manager_new2("stun_rc", FALSE); @@ -90,10 +88,70 @@ static void linphone_stun_test_grab_ip(void) linphone_core_manager_destroy(lc_stun); } +static void configure_nat_policy(LinphoneCore *lc) { + const char *username = "liblinphone-tester"; + const char *password = "retset-enohpnilbil"; + LinphoneAuthInfo *auth_info = linphone_core_create_auth_info(lc, username, NULL, password, NULL, "sip.linphone.org", NULL); + LinphoneNatPolicy *nat_policy = linphone_core_create_nat_policy(lc); + linphone_nat_policy_enable_ice(nat_policy, TRUE); + linphone_nat_policy_enable_turn(nat_policy, TRUE); + linphone_nat_policy_set_stun_server(nat_policy, "sip1.linphone.org:3479"); + linphone_nat_policy_set_stun_server_username(nat_policy, username); + linphone_core_set_nat_policy(lc, nat_policy); + linphone_core_add_auth_info(lc, auth_info); +} + +static void ice_turn_call_base(bool_t forced_relay) { + LinphoneCoreManager *marie; + LinphoneCoreManager *pauline; + LinphoneIceState expected_ice_state = LinphoneIceStateHostConnection; + MSList *lcs = NULL; + + marie = linphone_core_manager_new("marie_rc"); + lcs = ms_list_append(lcs, marie->lc); + pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + lcs = ms_list_append(lcs, pauline->lc); + + configure_nat_policy(marie->lc); + configure_nat_policy(pauline->lc); + if (forced_relay == TRUE) { + linphone_core_enable_forced_ice_relay(marie->lc, TRUE); + linphone_core_enable_forced_ice_relay(pauline->lc, TRUE); + expected_ice_state = LinphoneIceStateRelayConnection; + } + + BC_ASSERT_TRUE(call(marie, pauline)); + + /* Wait for the ICE reINVITE to complete */ + BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2)); + BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); + BC_ASSERT_TRUE(check_ice(pauline, marie, expected_ice_state)); + check_nb_media_starts(pauline, marie, 1, 1); + check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive); + check_media_direction(pauline, linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive); + liblinphone_tester_check_rtcp(marie, pauline); + + end_call(marie, pauline); + + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(marie); + ms_list_free(lcs); +} + +static void basic_ice_turn_call(void) { + ice_turn_call_base(FALSE); +} + +static void relayed_ice_turn_call(void) { + ice_turn_call_base(TRUE); +} + test_t stun_tests[] = { - TEST_NO_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip), - TEST_NO_TAG("STUN encode", linphone_stun_test_encode) + TEST_ONE_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip, "STUN"), + TEST_ONE_TAG("STUN encode", linphone_stun_test_encode, "STUN"), + TEST_TWO_TAGS("Basic ICE+TURN call", basic_ice_turn_call, "ICE", "TURN"), + TEST_TWO_TAGS("Relayed ICE+TURN call", relayed_ice_turn_call, "ICE", "TURN") }; test_suite_t stun_test_suite = {"Stun", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, diff --git a/tester/tester.c b/tester/tester.c index 56a4dab12..cd32a1189 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -215,13 +215,12 @@ bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) { bool_t wait_for_stun_resolution(LinphoneCoreManager *m) { MSTimeSpec start; int timeout_ms = 10000; - liblinphone_tester_clock_start(&start); - while (m->lc->net_conf.stun_addrinfo == NULL && !liblinphone_tester_clock_elapsed(&start,timeout_ms)) { + while (linphone_core_get_stun_server_addrinfo(m->lc) == NULL && !liblinphone_tester_clock_elapsed(&start,timeout_ms)) { linphone_core_iterate(m->lc); ms_usleep(20000); } - return m->lc->net_conf.stun_addrinfo != NULL; + return linphone_core_get_stun_server_addrinfo(m->lc) != NULL; } static void set_codec_enable(LinphoneCore* lc,const char* type,int rate,bool_t enable) { @@ -339,6 +338,7 @@ void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file) { void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies) { LinphoneProxyConfig* proxy; + LinphoneNatPolicy *nat_policy; int proxy_count; /*BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count, int, "%d");*/ @@ -370,7 +370,9 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies linphone_address_clean(mgr->identity); } - if (linphone_core_get_stun_server(mgr->lc) != NULL){ + nat_policy = linphone_core_get_nat_policy(mgr->lc); + if ((nat_policy != NULL) && (linphone_nat_policy_get_stun_server(nat_policy) != NULL) && + (linphone_nat_policy_stun_enabled(nat_policy) || linphone_nat_policy_turn_enabled(nat_policy))) { /*before we go, ensure that the stun server is resolved, otherwise all ice related test will fail*/ BC_ASSERT_TRUE(wait_for_stun_resolution(mgr)); } From 2e0ab2b759f23108fa6ebf52a84731a6441e594e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 16 May 2016 17:57:09 +0200 Subject: [PATCH 008/124] Fix compilation according to changes made in ms2. --- coreapi/misc.c | 29 ++++++++++++++++------------- coreapi/nat_policy.c | 4 ++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 5cc467d67..19b917870 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -397,20 +397,20 @@ static int recv_stun_response(ortp_socket_t sock, char *ipaddr, int *port, int * len = recv(sock, buf, len, 0); if (len > 0) { struct in_addr ia; - resp = ms_stun_message_create_from_buffer_parsing(buf, len); + resp = ms_stun_message_create_from_buffer_parsing((uint8_t *)buf, len); if (resp != NULL) { const MSStunAddress *stun_addr; UInt96 tr_id = ms_stun_message_get_tr_id(resp); *id = tr_id.octet[0]; stun_addr = ms_stun_message_get_xor_mapped_address(resp); if (stun_addr != NULL) { - *port = stun_addr->ipv4.port; - ia.s_addr = htonl(stun_addr->ipv4.addr); + *port = stun_addr->ip.v4.port; + ia.s_addr = htonl(stun_addr->ip.v4.addr); } else { stun_addr = ms_stun_message_get_mapped_address(resp); if (stun_addr != NULL) { - *port = stun_addr->ipv4.port; - ia.s_addr = htonl(stun_addr->ipv4.addr); + *port = stun_addr->ip.v4.port; + ia.s_addr = htonl(stun_addr->ip.v4.addr); } else len = -1; } if (len > 0) strncpy(ipaddr, inet_ntoa(ia), LINPHONE_IPADDR_SIZE); @@ -713,26 +713,27 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){ ice_session_enable_forced_relay(call->ice_session, lc->forced_ice_relay); + // TODO: Handle IPv6 /* Gather local host candidates. */ if (linphone_core_get_local_ip_for(AF_INET, NULL, local_addr) < 0) { ms_error("Fail to get local ip"); return -1; } if ((ice_check_list_state(audio_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(audio_check_list) == FALSE)) { - ice_add_local_candidate(audio_check_list, "host", local_addr, call->media_ports[call->main_audio_stream_index].rtp_port, 1, NULL); - ice_add_local_candidate(audio_check_list, "host", local_addr, call->media_ports[call->main_audio_stream_index].rtcp_port, 2, NULL); + ice_add_local_candidate(audio_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_audio_stream_index].rtp_port, 1, NULL); + ice_add_local_candidate(audio_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_audio_stream_index].rtcp_port, 2, NULL); call->stats[LINPHONE_CALL_STATS_AUDIO].ice_state = LinphoneIceStateInProgress; } if (linphone_core_video_enabled(lc) && (video_check_list != NULL) && (ice_check_list_state(video_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(video_check_list) == FALSE)) { - ice_add_local_candidate(video_check_list, "host", local_addr, call->media_ports[call->main_video_stream_index].rtp_port, 1, NULL); - ice_add_local_candidate(video_check_list, "host", local_addr, call->media_ports[call->main_video_stream_index].rtcp_port, 2, NULL); + ice_add_local_candidate(video_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_video_stream_index].rtp_port, 1, NULL); + ice_add_local_candidate(video_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_video_stream_index].rtcp_port, 2, NULL); call->stats[LINPHONE_CALL_STATS_VIDEO].ice_state = LinphoneIceStateInProgress; } if (call->params->realtimetext_enabled && (text_check_list != NULL) && (ice_check_list_state(text_check_list) != ICL_Completed) && (ice_check_list_candidates_gathered(text_check_list) == FALSE)) { - ice_add_local_candidate(text_check_list, "host", local_addr, call->media_ports[call->main_text_stream_index].rtp_port, 1, NULL); - ice_add_local_candidate(text_check_list, "host", local_addr, call->media_ports[call->main_text_stream_index].rtcp_port, 2, NULL); + ice_add_local_candidate(text_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_text_stream_index].rtp_port, 1, NULL); + ice_add_local_candidate(text_check_list, "host", AF_INET, local_addr, call->media_ports[call->main_text_stream_index].rtcp_port, 2, NULL); call->stats[LINPHONE_CALL_STATS_TEXT].ice_state = LinphoneIceStateInProgress; } if ((ai != NULL) && (nat_policy != NULL) @@ -1124,7 +1125,8 @@ void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call, get_default_addr_and_port(candidate->componentID, md, stream, &addr, &port); if (addr && (candidate->port == port) && (strlen(candidate->addr) == strlen(addr)) && (strcmp(candidate->addr, addr) == 0)) default_candidate = TRUE; - ice_add_remote_candidate(cl, candidate->type, candidate->addr, candidate->port, candidate->componentID, + // TODO: Handle IPv6 + ice_add_remote_candidate(cl, candidate->type, AF_INET, candidate->addr, candidate->port, candidate->componentID, candidate->priority, candidate->foundation, default_candidate); } if (ice_restarted == FALSE) { @@ -1140,7 +1142,8 @@ void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call, /* If we receive a re-invite and we finished ICE processing on our side, use the candidates given by the remote. */ ice_check_list_unselect_valid_pairs(cl); } - ice_add_losing_pair(cl, j + 1, remote_candidate->addr, remote_candidate->port, addr, port); + // TODO: Handle IPv6 + ice_add_losing_pair(cl, j + 1, AF_INET, remote_candidate->addr, remote_candidate->port, addr, port); losing_pairs_added = TRUE; } if (losing_pairs_added == TRUE) ice_check_list_check_completed(cl); diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 9d172a0a0..2e7e01b66 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -39,7 +39,7 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) { if (policy->ref) belle_sip_free(policy->ref); if (policy->stun_server) belle_sip_free(policy->stun_server); if (policy->stun_server_username) belle_sip_free(policy->stun_server_username); - if (policy->stun_addrinfo) freeaddrinfo(policy->stun_addrinfo); + if (policy->stun_addrinfo) bctbx_freeaddrinfo(policy->stun_addrinfo); } static bool_t linphone_nat_policy_stun_server_activated(LinphoneNatPolicy *policy) { @@ -202,7 +202,7 @@ void linphone_nat_policy_set_stun_server_username(LinphoneNatPolicy *policy, con static void stun_server_resolved(LinphoneNatPolicy *policy, const char *name, struct addrinfo *addrinfo) { if (policy->stun_addrinfo) { - belle_sip_freeaddrinfo(policy->stun_addrinfo); + bctbx_freeaddrinfo(policy->stun_addrinfo); policy->stun_addrinfo = NULL; } if (addrinfo) { From 79c89bbb5564c9bd12f18b11a10b111644c93d7d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 23 May 2016 14:28:52 +0200 Subject: [PATCH 009/124] Fix compilation according to changes made in mediastreamer2. --- coreapi/misc.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 19b917870..4fb1f5a94 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -894,7 +894,8 @@ void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDes } void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session, bool_t use_nortpproxy) { - const char *rtp_addr, *rtcp_addr; + IceCandidate *rtp_candidate = NULL; + IceCandidate *rtcp_candidate = NULL; IceSessionState session_state = ice_session_state(session); int nb_candidates; int i, j; @@ -902,9 +903,9 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess if (session_state == IS_Completed) { if (use_nortpproxy) desc->set_nortpproxy = TRUE; - result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, 0), &rtp_addr, NULL, NULL, NULL); + result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, 0), &rtp_candidate, NULL); if (result == TRUE) { - strncpy(desc->addr, rtp_addr, sizeof(desc->addr)); + strncpy(desc->addr, rtp_candidate->taddr.ip, sizeof(desc->addr)); } else { ms_warning("If ICE has completed successfully, rtp_addr should be set!"); } @@ -921,14 +922,16 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess if (!sal_stream_description_active(stream) || (cl == NULL)) continue; if (ice_check_list_state(cl) == ICL_Completed) { if (use_nortpproxy) stream->set_nortpproxy = TRUE; - result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port); + result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, i), &rtp_candidate, &rtcp_candidate); } else { stream->set_nortpproxy = FALSE; - result = ice_check_list_default_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port); + result = ice_check_list_default_local_candidate(ice_session_check_list(session, i), &rtp_candidate, &rtcp_candidate); } if (result == TRUE) { - strncpy(stream->rtp_addr, rtp_addr, sizeof(stream->rtp_addr)); - strncpy(stream->rtcp_addr, rtcp_addr, sizeof(stream->rtcp_addr)); + strncpy(stream->rtp_addr, rtp_candidate->taddr.ip, sizeof(stream->rtp_addr)); + strncpy(stream->rtcp_addr, rtcp_candidate->taddr.ip, sizeof(stream->rtcp_addr)); + stream->rtp_port = rtp_candidate->taddr.port; + stream->rtcp_port = rtcp_candidate->taddr.port; } else { memset(stream->rtp_addr, 0, sizeof(stream->rtp_addr)); memset(stream->rtcp_addr, 0, sizeof(stream->rtcp_addr)); @@ -975,13 +978,12 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess } } if ((ice_check_list_state(cl) == ICL_Completed) && (ice_session_role(session) == IR_Controlling)) { - int rtp_port, rtcp_port; memset(stream->ice_remote_candidates, 0, sizeof(stream->ice_remote_candidates)); - if (ice_check_list_selected_valid_remote_candidate(cl, &rtp_addr, &rtp_port, &rtcp_addr, &rtcp_port) == TRUE) { - strncpy(stream->ice_remote_candidates[0].addr, rtp_addr, sizeof(stream->ice_remote_candidates[0].addr)); - stream->ice_remote_candidates[0].port = rtp_port; - strncpy(stream->ice_remote_candidates[1].addr, rtcp_addr, sizeof(stream->ice_remote_candidates[1].addr)); - stream->ice_remote_candidates[1].port = rtcp_port; + if (ice_check_list_selected_valid_remote_candidate(cl, &rtp_candidate, &rtcp_candidate) == TRUE) { + strncpy(stream->ice_remote_candidates[0].addr, rtp_candidate->taddr.ip, sizeof(stream->ice_remote_candidates[0].addr)); + stream->ice_remote_candidates[0].port = rtp_candidate->taddr.port; + strncpy(stream->ice_remote_candidates[1].addr, rtcp_candidate->taddr.ip, sizeof(stream->ice_remote_candidates[1].addr)); + stream->ice_remote_candidates[1].port = rtcp_candidate->taddr.port; } else { ms_error("ice: Selected valid remote candidates should be present if the check list is in the Completed state"); } From bc59fe4bee0fb31947d070dc95570698fc0b917d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 23 May 2016 14:31:27 +0200 Subject: [PATCH 010/124] Add "Relayed ICE+TURN to ICE+STUN call" test. --- tester/stun_tester.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/tester/stun_tester.c b/tester/stun_tester.c index d9f850bce..885054ff1 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -88,20 +88,25 @@ static void linphone_stun_test_grab_ip(void) linphone_core_manager_destroy(lc_stun); } -static void configure_nat_policy(LinphoneCore *lc) { +static void configure_nat_policy(LinphoneCore *lc, bool_t turn_enabled) { const char *username = "liblinphone-tester"; const char *password = "retset-enohpnilbil"; LinphoneAuthInfo *auth_info = linphone_core_create_auth_info(lc, username, NULL, password, NULL, "sip.linphone.org", NULL); LinphoneNatPolicy *nat_policy = linphone_core_create_nat_policy(lc); linphone_nat_policy_enable_ice(nat_policy, TRUE); - linphone_nat_policy_enable_turn(nat_policy, TRUE); - linphone_nat_policy_set_stun_server(nat_policy, "sip1.linphone.org:3479"); - linphone_nat_policy_set_stun_server_username(nat_policy, username); + if (turn_enabled) { + linphone_nat_policy_enable_turn(nat_policy, TRUE); + linphone_nat_policy_set_stun_server(nat_policy, "sip1.linphone.org:3479"); + linphone_nat_policy_set_stun_server_username(nat_policy, username); + } else { + linphone_nat_policy_enable_stun(nat_policy, TRUE); + linphone_nat_policy_set_stun_server(nat_policy, "stun.linphone.org"); + } linphone_core_set_nat_policy(lc, nat_policy); linphone_core_add_auth_info(lc, auth_info); } -static void ice_turn_call_base(bool_t forced_relay) { +static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, bool_t callee_turn_enabled) { LinphoneCoreManager *marie; LinphoneCoreManager *pauline; LinphoneIceState expected_ice_state = LinphoneIceStateHostConnection; @@ -112,8 +117,8 @@ static void ice_turn_call_base(bool_t forced_relay) { pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); lcs = ms_list_append(lcs, pauline->lc); - configure_nat_policy(marie->lc); - configure_nat_policy(pauline->lc); + configure_nat_policy(marie->lc, caller_turn_enabled); + configure_nat_policy(pauline->lc, callee_turn_enabled); if (forced_relay == TRUE) { linphone_core_enable_forced_ice_relay(marie->lc, TRUE); linphone_core_enable_forced_ice_relay(pauline->lc, TRUE); @@ -130,6 +135,20 @@ static void ice_turn_call_base(bool_t forced_relay) { check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive); check_media_direction(pauline, linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive); liblinphone_tester_check_rtcp(marie, pauline); + if (forced_relay == TRUE) { + LinphoneCall *call = linphone_core_get_current_call(marie->lc); + BC_ASSERT_PTR_NOT_NULL(call->ice_session); + if (call->ice_session != NULL) { + IceCheckList *cl = ice_session_check_list(call->ice_session, 0); + BC_ASSERT_PTR_NOT_NULL(cl); + if (cl != NULL) { + BC_ASSERT_TRUE(cl->rtp_turn_context->stats_nb_send_indication > 0); + BC_ASSERT_TRUE(cl->rtp_turn_context->stats_nb_data_indication > 0); + BC_ASSERT_TRUE(cl->rtp_turn_context->stats_nb_received_channel_msg > 0); + BC_ASSERT_TRUE(cl->rtp_turn_context->stats_nb_sent_channel_msg > 0); + } + } + } end_call(marie, pauline); @@ -139,11 +158,15 @@ static void ice_turn_call_base(bool_t forced_relay) { } static void basic_ice_turn_call(void) { - ice_turn_call_base(FALSE); + ice_turn_call_base(FALSE, TRUE, TRUE); } static void relayed_ice_turn_call(void) { - ice_turn_call_base(TRUE); + ice_turn_call_base(TRUE, TRUE, TRUE); +} + +static void relayed_ice_turn_to_ice_stun_call(void) { + ice_turn_call_base(TRUE, TRUE, FALSE); } @@ -151,7 +174,8 @@ test_t stun_tests[] = { TEST_ONE_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip, "STUN"), TEST_ONE_TAG("STUN encode", linphone_stun_test_encode, "STUN"), TEST_TWO_TAGS("Basic ICE+TURN call", basic_ice_turn_call, "ICE", "TURN"), - TEST_TWO_TAGS("Relayed ICE+TURN call", relayed_ice_turn_call, "ICE", "TURN") + TEST_TWO_TAGS("Relayed ICE+TURN call", relayed_ice_turn_call, "ICE", "TURN"), + TEST_TWO_TAGS("Relayed ICE+TURN to ICE+STUN call", relayed_ice_turn_to_ice_stun_call, "ICE", "TURN") }; test_suite_t stun_test_suite = {"Stun", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, From 86705803e42cf0039c0647ee33a7d0de19757de5 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 1 Jun 2016 13:58:53 +0200 Subject: [PATCH 011/124] Fix memory leaks. --- coreapi/linphonecall.c | 4 +++- coreapi/linphonecore.c | 8 +++++--- coreapi/misc.c | 2 +- coreapi/nat_policy.c | 1 + coreapi/presence.c | 1 + coreapi/proxy.c | 11 ++++++----- tester/call_tester.c | 6 +++--- tester/stun_tester.c | 2 ++ tester/tester.c | 1 + 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 36f1a6f5a..c3c8d6336 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2475,13 +2475,15 @@ void linphone_call_init_audio_stream(LinphoneCall *call){ /* init zrtp even if we didn't explicitely set it, just in case peer offers it */ if (ms_zrtp_available()) { + char *uri = linphone_address_as_string_uri_only((call->dir==LinphoneCallIncoming) ? call->log->from : call->log->to); MSZrtpParams params; memset(¶ms,0,sizeof(MSZrtpParams)); /*call->current_params.media_encryption will be set later when zrtp is activated*/ params.zid_file=lc->zrtp_secrets_cache; - params.uri= linphone_address_as_string_uri_only((call->dir==LinphoneCallIncoming) ? call->log->from : call->log->to); + params.uri=uri; setZrtpCryptoTypesParameters(¶ms,call->core); audio_stream_enable_zrtp(call->audiostream,¶ms); + if (uri != NULL) ms_free(uri); } media_stream_reclaim_sessions(&audiostream->ms, &call->sessions[call->main_audio_stream_index]); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index f78a5d5cd..d766d9855 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5159,9 +5159,9 @@ void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy char *stun_server_username = NULL; if (lc->nat_policy != NULL) { - nat_policy = linphone_nat_policy_ref(lc->nat_policy); - stun_server = ms_strdup(linphone_nat_policy_get_stun_server(lc->nat_policy)); - stun_server_username = ms_strdup(linphone_nat_policy_get_stun_server_username(lc->nat_policy)); + nat_policy = lc->nat_policy; + stun_server = ms_strdup(linphone_nat_policy_get_stun_server(nat_policy)); + stun_server_username = ms_strdup(linphone_nat_policy_get_stun_server_username(nat_policy)); linphone_nat_policy_clear(nat_policy); } else { nat_policy = linphone_core_create_nat_policy(lc); @@ -6374,6 +6374,8 @@ void net_config_uninit(LinphoneCore *lc) if (lc->nat_policy != NULL) { lp_config_set_string(lc->config, "net", "nat_policy_ref", lc->nat_policy->ref); linphone_nat_policy_save_to_config(lc->nat_policy); + linphone_nat_policy_unref(lc->nat_policy); + lc->nat_policy = NULL; } } diff --git a/coreapi/misc.c b/coreapi/misc.c index 4fb1f5a94..6c989b066 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -641,7 +641,7 @@ static void stun_auth_requested_cb(LinphoneCall *call, const char *realm, const const LinphoneAddress *addr = NULL; const LinphoneAuthInfo *auth_info = NULL; LinphoneCore *lc = call->core; - const char *user; + const char *user = NULL; // Get the username from the nat policy or the proxy config if (call->dest_proxy != NULL) proxy = call->dest_proxy; diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 2e7e01b66..5df7e3c24 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -77,6 +77,7 @@ static void _linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, } lp_config_set_string_list(config, section, "protocols", l); belle_sip_free(section); + ms_list_free(l); } void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy) { diff --git a/coreapi/presence.c b/coreapi/presence.c index 22887cfd1..744cc7605 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -446,6 +446,7 @@ int linphone_presence_model_add_activity(LinphonePresenceModel *model, LinphoneP return -1; presence_model_add_person(model, person); + linphone_presence_person_unref(person); } else { /* Add the activity to the first person in the model. */ person = (LinphonePresencePerson *)ms_list_nth_data(model->persons, 0); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 9d63f5125..1a8f964c4 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -221,6 +221,9 @@ void _linphone_proxy_config_destroy(LinphoneProxyConfig *cfg){ if (cfg->sent_headers!=NULL) sal_custom_header_free(cfg->sent_headers); if (cfg->pending_contact) linphone_address_unref(cfg->pending_contact); if (cfg->refkey) ms_free(cfg->refkey); + if (cfg->nat_policy != NULL) { + linphone_nat_policy_unref(cfg->nat_policy); + } _linphone_proxy_config_release_ops(cfg); } @@ -1694,9 +1697,7 @@ LinphoneNatPolicy * linphone_proxy_config_get_nat_policy(const LinphoneProxyConf } void linphone_proxy_config_set_nat_policy(LinphoneProxyConfig *cfg, LinphoneNatPolicy *policy) { - if (cfg->nat_policy != NULL) { - linphone_nat_policy_unref(cfg->nat_policy); - cfg->nat_policy = NULL; - } - if (policy != NULL) cfg->nat_policy = linphone_nat_policy_ref(policy); + if (policy != NULL) policy = linphone_nat_policy_ref(policy); /* Prevent object destruction if the same policy is used */ + if (cfg->nat_policy != NULL) linphone_nat_policy_unref(cfg->nat_policy); + if (policy != NULL) cfg->nat_policy = policy; } diff --git a/tester/call_tester.c b/tester/call_tester.c index f35a1a4cf..2cdfc4686 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -3997,10 +3997,10 @@ void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList* if (video_dir != LinphoneMediaDirectionInactive){ BC_ASSERT_TRUE(linphone_call_params_video_enabled(params)); + BC_ASSERT_EQUAL(linphone_call_params_get_video_direction(params), video_dir, int, "%d"); + linphone_call_set_next_video_frame_decoded_callback(call,linphone_call_iframe_decoded_cb,mgr->lc); + linphone_call_send_vfu_request(call); } - BC_ASSERT_EQUAL(linphone_call_params_get_video_direction(params), video_dir, int, "%d"); - linphone_call_set_next_video_frame_decoded_callback(call,linphone_call_iframe_decoded_cb,mgr->lc); - linphone_call_send_vfu_request(call); switch (video_dir) { case LinphoneMediaDirectionInactive: diff --git a/tester/stun_tester.c b/tester/stun_tester.c index 885054ff1..41df639cb 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -104,6 +104,8 @@ static void configure_nat_policy(LinphoneCore *lc, bool_t turn_enabled) { } linphone_core_set_nat_policy(lc, nat_policy); linphone_core_add_auth_info(lc, auth_info); + linphone_nat_policy_unref(nat_policy); + linphone_auth_info_destroy(auth_info); } static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, bool_t callee_turn_enabled) { diff --git a/tester/tester.c b/tester/tester.c index cd32a1189..c932f68ce 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -556,6 +556,7 @@ int liblinphone_tester_after_each(void) { ms_error("%s", format); all_leaks_buffer = ms_strcat_printf(all_leaks_buffer, "\n%s", format); + ms_free(format); } // prevent any future leaks From cac2bc4d9595b6913dc45e617d2c57391f9db2d8 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 1 Jun 2016 17:06:20 +0200 Subject: [PATCH 012/124] Add missing nat policy ref. --- coreapi/linphonecore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index eb4cab7e9..12f9b87cc 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5199,7 +5199,7 @@ void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy char *stun_server_username = NULL; if (lc->nat_policy != NULL) { - nat_policy = lc->nat_policy; + nat_policy = linphone_nat_policy_ref(lc->nat_policy); stun_server = ms_strdup(linphone_nat_policy_get_stun_server(nat_policy)); stun_server_username = ms_strdup(linphone_nat_policy_get_stun_server_username(nat_policy)); linphone_nat_policy_clear(nat_policy); From def27c4f5e7cc9b928884f4bd32bca36f13b22a9 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 3 Jun 2016 10:11:35 +0200 Subject: [PATCH 013/124] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 9dbf6cd97..56fb62d8a 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 9dbf6cd9723f359b8b1bc0fe2a06a3de5100e2ad +Subproject commit 56fb62d8a4a6b1ed0f54b543f74074279a29fa83 From 7aead3de5bf82b18649906ca2b82d7c8242c93f8 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 3 Jun 2016 10:23:22 +0200 Subject: [PATCH 014/124] Update ms2 and ortp submodules. --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 56fb62d8a..04d0238a0 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 56fb62d8a4a6b1ed0f54b543f74074279a29fa83 +Subproject commit 04d0238a0e061f83586ba6b8d50239445a932cec diff --git a/oRTP b/oRTP index d511e07b9..f21765b4a 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit d511e07b937c22996dea1ee3f1449756d16597cb +Subproject commit f21765b4ae0a012906add1473768a1bf0b57567c From da59ab0bae4ab06adb046642db3eb85ac06ef25a Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 3 Jun 2016 10:31:01 +0200 Subject: [PATCH 015/124] submodules: update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 04d0238a0..1433a1b1e 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 04d0238a0e061f83586ba6b8d50239445a932cec +Subproject commit 1433a1b1e7be41d02f3918b4ad3d674c6768347d From 82106e85a2fb142bdcc91a9b530257bc9aebd199 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 3 Jun 2016 10:33:15 +0200 Subject: [PATCH 016/124] liblinphone_tester.c: properly handle --6 option --- tester/liblinphone_tester.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index bbd1052bf..927ac8303 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -191,7 +191,9 @@ static const char* liblinphone_helper = "\t\t\t--auth-domain \n" "\t\t\t--dns-hosts \n" "\t\t\t--keep-recorded-files\n" - "\t\t\t--disable-leak-detector\n"; + "\t\t\t--disable-leak-detector\n" + "\t\t\t--6\n" + ; int main (int argc, char *argv[]) { From eaed5fe047caf52b47c078ac4d99f16ce042f3d8 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 3 Jun 2016 10:37:36 +0200 Subject: [PATCH 017/124] fix sqlite openings: don't convert to utf8 --- coreapi/message_storage.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 997c7f108..b87bc8390 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -43,6 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sqlite3.h" #include +#if 0 static char *utf8_convert(const char *filename){ char db_file_utf8[MAX_PATH_SIZE] = ""; #if defined(_WIN32) @@ -66,7 +67,7 @@ static char *utf8_convert(const char *filename){ #endif return ms_strdup(db_file_utf8); } - +#endif int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) { char* errmsg = NULL; @@ -79,9 +80,9 @@ int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) { flags |= SQLITE_OPEN_FILEPROTECTION_NONE; #endif - char *utf8_filename = utf8_convert(db_file); - ret = sqlite3_open_v2(utf8_filename, db, flags, LINPHONE_SQLITE3_VFS); - ms_free(utf8_filename); + /*since we plug our vfs into sqlite, there is no need to convert to UTF-8. + * Indeed, our filesystem wrapper uses the default system encoding*/ + ret = sqlite3_open_v2(db_file, db, flags, LINPHONE_SQLITE3_VFS); if (ret != SQLITE_OK) return ret; // Some platforms do not provide a way to create temporary files which are needed From 8b310c888ec43c1345e099b1a216e29a29e0b48b Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 3 Jun 2016 11:22:43 +0200 Subject: [PATCH 018/124] Update ms2 submodule. --- coreapi/misc.c | 2 +- mediastreamer2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 6c989b066..b627b35c7 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -397,7 +397,7 @@ static int recv_stun_response(ortp_socket_t sock, char *ipaddr, int *port, int * len = recv(sock, buf, len, 0); if (len > 0) { struct in_addr ia; - resp = ms_stun_message_create_from_buffer_parsing((uint8_t *)buf, len); + resp = ms_stun_message_create_from_buffer_parsing((uint8_t *)buf, (ssize_t)len); if (resp != NULL) { const MSStunAddress *stun_addr; UInt96 tr_id = ms_stun_message_get_tr_id(resp); diff --git a/mediastreamer2 b/mediastreamer2 index 1433a1b1e..1d9ededc3 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 1433a1b1e7be41d02f3918b4ad3d674c6768347d +Subproject commit 1d9ededc3a45372b6e2ba4b8b6052edbdfadc450 From 4bd7ac755741280347a1f59423c0b1dcb76de8c8 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 3 Jun 2016 12:11:56 +0200 Subject: [PATCH 019/124] tester: add simple call using UDP --- tester/Makefile.am | 4 +- tester/call_tester.c | 82 +++++++++++++++---- tester/flexisip_tester.c | 2 +- tester/multi_call_tester.c | 26 +++--- tester/rcfiles/{laure_rc => laure_rc_udp} | 0 .../rcfiles/{michelle_rc => michelle_rc_udp} | 0 tester/video_tester.c | 4 +- 7 files changed, 83 insertions(+), 35 deletions(-) rename tester/rcfiles/{laure_rc => laure_rc_udp} (100%) rename tester/rcfiles/{michelle_rc => michelle_rc_udp} (100%) diff --git a/tester/Makefile.am b/tester/Makefile.am index fbe2cb25d..59b61fd66 100644 --- a/tester/Makefile.am +++ b/tester/Makefile.am @@ -33,7 +33,7 @@ CERTIFICATE_FILES = $(CERTIFICATE_ALT_FILES) $(CERTIFICATE_CN_FILES) RCFILES = \ rcfiles/empty_rc\ rcfiles/laure_call_logs_rc\ - rcfiles/laure_rc\ + rcfiles/laure_rc_udp\ rcfiles/marie_early_rc\ rcfiles/marie_h264_rc\ rcfiles/marie_quality_reporting_rc\ @@ -54,7 +54,7 @@ RCFILES = \ rcfiles/marie_zrtp_aes256_rc\ rcfiles/marie_zrtp_b256_rc\ rcfiles/marie_zrtp_srtpsuite_aes256_rc\ - rcfiles/michelle_rc\ + rcfiles/michelle_rc_udp\ rcfiles/multi_account_rc\ rcfiles/pauline_alt_rc\ rcfiles/pauline_h264_rc\ diff --git a/tester/call_tester.c b/tester/call_tester.c index de678eac8..09b597af5 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -243,7 +243,7 @@ static void setup_sdp_handling(const LinphoneCallTestParams* params, LinphoneCor * This function should be used only in test case where the programmer exactly knows the caller params, and then can deduce how * callee params will be set by linphone_core_create_call_params(). * This function was developped at a time where the use of the API about incoming params was not yet clarified. - * Tests relying on this function are then not testing the correct way to use the api (through linphone_core_create_call_params()), and so + * Tests relying on this function are then not testing the correct way to use the api (through linphone_core_create_call_params()), and so * it is not a so good idea to build new tests based on this function. **/ bool_t call_with_params2(LinphoneCoreManager* caller_mgr @@ -403,7 +403,7 @@ bool_t call_with_params2(LinphoneCoreManager* caller_mgr * This function should be used only in test case where the programmer exactly knows the caller params, and then can deduce how * callee params will be set by linphone_core_create_call_params(). * This function was developped at a time where the use of the API about incoming params was not yet clarified. - * Tests relying on this function are then not testing the correct way to use the api (through linphone_core_create_call_params()), and so + * Tests relying on this function are then not testing the correct way to use the api (through linphone_core_create_call_params()), and so * it is not a so good idea to build new tests based on this function. **/ bool_t call_with_params(LinphoneCoreManager* caller_mgr @@ -424,7 +424,7 @@ bool_t call_with_params(LinphoneCoreManager* caller_mgr * This function should be used only in test case where the programmer exactly knows the caller params, and then can deduce how * callee params will be set by linphone_core_create_call_params(). * This function was developped at a time where the use of the API about incoming params was not yet clarified. - * Tests relying on this function are then not testing the correct way to use the api (through linphone_core_create_call_params()), and so + * Tests relying on this function are then not testing the correct way to use the api (through linphone_core_create_call_params()), and so * it is not a so good idea to build new tests based on this function. **/ bool_t call_with_test_params(LinphoneCoreManager* caller_mgr @@ -496,7 +496,6 @@ void simple_call_base(bool_t enable_multicast_recv_side) { } } - liblinphone_tester_check_rtcp(marie,pauline); end_call(marie,pauline); linphone_core_manager_destroy(pauline); @@ -507,6 +506,54 @@ static void simple_call(void) { simple_call_base(FALSE); } +static void simple_call_with_udp(void) { + LinphoneCoreManager* michelle; + LinphoneCoreManager* laure; + const LinphoneAddress *from; + LinphoneCall *laure_call; + LinphoneProxyConfig* michelle_cfg; + + michelle = linphone_core_manager_new( "michelle_rc_udp"); + laure = linphone_core_manager_new("laure_rc_udp"); + + /* with the account manager, we might lose the identity */ + michelle_cfg = linphone_core_get_default_proxy_config(michelle->lc); + { + LinphoneAddress* michelle_addr = linphone_address_clone(linphone_proxy_config_get_identity_address(michelle_cfg)); + char* michelle_tmp_id = NULL; + linphone_address_set_display_name(michelle_addr, "Super michelle"); + michelle_tmp_id = linphone_address_as_string(michelle_addr); + + linphone_proxy_config_edit(michelle_cfg); + linphone_proxy_config_set_identity(michelle_cfg,michelle_tmp_id); + linphone_proxy_config_done(michelle_cfg); + + ms_free(michelle_tmp_id); + linphone_address_destroy(michelle_addr); + } + + BC_ASSERT_TRUE(call(michelle,laure)); + laure_call=linphone_core_get_current_call(laure->lc); + BC_ASSERT_PTR_NOT_NULL(laure_call); + /*check that display name is correctly propagated in From */ + if (laure_call){ + from=linphone_call_get_remote_address(linphone_core_get_current_call(laure->lc)); + BC_ASSERT_PTR_NOT_NULL(from); + if (from){ + const char *dname=linphone_address_get_display_name(from); + BC_ASSERT_PTR_NOT_NULL(dname); + if (dname){ + BC_ASSERT_STRING_EQUAL(dname, "Super michelle"); + } + } + } + + liblinphone_tester_check_rtcp(michelle,laure); + end_call(michelle,laure); + linphone_core_manager_destroy(laure); + linphone_core_manager_destroy(michelle); +} + static void automatic_call_termination(void) { LinphoneCoreManager* marie; LinphoneCoreManager* pauline; @@ -1440,7 +1487,7 @@ void call_paused_resumed_base(bool_t multicast, bool_t with_losses) { } linphone_core_pause_call(pauline->lc,call_pauline); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); - + if (with_losses) { BC_ASSERT_FALSE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1,1000)); sal_set_send_error(marie->lc->sal,0); /*to trash 200ok without generating error*/ @@ -1483,10 +1530,10 @@ void call_paused_resumed_base(bool_t multicast, bool_t with_losses) { linphone_core_resume_call(pauline->lc,call_pauline); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); - + } - + end_call(pauline, marie); end: linphone_core_manager_destroy(marie); @@ -3728,7 +3775,7 @@ static void call_established_with_rejected_incoming_reinvite(void) { static void call_redirect(void){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new("laure_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new("laure_rc_udp"); MSList* lcs = NULL; char *laure_url = NULL; LinphoneCall* marie_call; @@ -4137,7 +4184,7 @@ void two_accepted_call_in_send_only(void) { marie = linphone_core_manager_new("marie_rc"); linphone_core_use_files(marie->lc, TRUE); pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - laure = linphone_core_manager_new("laure_rc"); + laure = linphone_core_manager_new("laure_rc_udp"); lcs=ms_list_append(lcs,pauline->lc); lcs=ms_list_append(lcs,marie->lc); @@ -4307,16 +4354,16 @@ static void call_with_very_early_call_update(void) { LinphoneCoreManager* marie; LinphoneCoreManager* pauline; LinphoneCallParams *params; - + marie = linphone_core_manager_new( "marie_rc"); pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); linphone_core_invite_address(marie->lc,pauline->identity); - + BC_ASSERT_TRUE (wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallIncomingReceived,1)); BC_ASSERT_TRUE(linphone_core_inc_invite_pending(pauline->lc)); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingProgress,1, int, "%d"); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallOutgoingRinging,1)); - + BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call_remote_address(pauline->lc)); if (linphone_core_get_current_call_remote_address(pauline->lc)) { linphone_core_accept_call(pauline->lc,linphone_core_get_current_call(pauline->lc)); @@ -4328,13 +4375,13 @@ static void call_with_very_early_call_update(void) { linphone_core_update_call(pauline->lc,linphone_core_get_current_call(pauline->lc),params); linphone_call_params_destroy(params); } - + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallUpdating,1)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdatedByRemote,1)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); end_call(marie,pauline); - + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -6166,12 +6213,12 @@ static void _call_with_rtcp_mux(bool_t caller_rtcp_mux, bool_t callee_rtcp_mux, check_ice(marie, pauline, LinphoneIceStateHostConnection); } liblinphone_tester_check_rtcp(marie,pauline); - + if (caller_rtcp_mux && callee_rtcp_mux){ BC_ASSERT_EQUAL(marie->stat.number_of_rtcp_received_via_mux, marie->stat.number_of_rtcp_received, int, "%i"); - + BC_ASSERT_EQUAL(pauline->stat.number_of_rtcp_received_via_mux, pauline->stat.number_of_rtcp_received, int, "%i"); - + }else{ BC_ASSERT_TRUE(marie->stat.number_of_rtcp_received_via_mux == 0); BC_ASSERT_TRUE(pauline->stat.number_of_rtcp_received_via_mux == 0); @@ -6339,6 +6386,7 @@ test_t call_tests[] = { TEST_NO_TAG("Cancelled ringing call", cancelled_ringing_call), TEST_NO_TAG("Call busy when calling self", call_busy_when_calling_self), TEST_NO_TAG("Simple call", simple_call), + TEST_NO_TAG("Simple call with UDP", simple_call_with_udp), TEST_ONE_TAG("Call terminated automatically by linphone_core_destroy", automatic_call_termination, "LeaksMemory"), TEST_NO_TAG("Call with http proxy", call_with_http_proxy), TEST_NO_TAG("Call with timeouted bye", call_with_timeouted_bye), diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 2a9dea118..96cf74252 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -1066,7 +1066,7 @@ static void test_publish_unpublish(void) { static void test_list_subscribe (void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); char *list = "\n" "lc, NULL); LinphoneCallParams *marie_params=linphone_core_create_call_params(marie->lc, NULL); @@ -364,7 +364,7 @@ end: static void simple_conference(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); simple_conference_base(marie,pauline,laure, NULL); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); @@ -374,7 +374,7 @@ static void simple_conference(void) { static void simple_encrypted_conference_with_ice(LinphoneMediaEncryption mode) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); if (linphone_core_media_encryption_supported(marie->lc,mode)) { linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); @@ -409,7 +409,7 @@ static void simple_zrtp_conference_with_ice(void) { static void simple_call_transfer(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); LinphoneCall* pauline_called_by_marie; LinphoneCall *marie_calling_pauline; LinphoneCall *marie_calling_laure; @@ -473,7 +473,7 @@ end: static void unattended_call_transfer(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); LinphoneCall* pauline_called_by_marie; char* laure_identity=linphone_address_as_string(laure->identity); @@ -562,7 +562,7 @@ static void unattended_call_transfer_with_error(void) { static void call_transfer_existing_call_outgoing_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); LinphoneCall* marie_call_pauline; LinphoneCall* pauline_called_by_marie; LinphoneCall* marie_call_laure; @@ -735,7 +735,7 @@ end: static void eject_from_3_participants_local_conference(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); eject_from_3_participants_conference(marie, pauline, laure, NULL); @@ -747,8 +747,8 @@ static void eject_from_3_participants_local_conference(void) { static void eject_from_4_participants_conference(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); - LinphoneCoreManager* michelle = linphone_core_manager_new( "michelle_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); + LinphoneCoreManager* michelle = linphone_core_manager_new( "michelle_rc_udp"); int timeout_ms = 5000; stats initial_laure_stat; stats initial_michelle_stat; @@ -837,7 +837,7 @@ end: void simple_remote_conference(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); - LinphoneCoreManager *laure = linphone_core_manager_new("laure_rc"); + LinphoneCoreManager *laure = linphone_core_manager_new("laure_rc_udp"); LinphoneConferenceServer *focus = linphone_conference_server_new("conference_focus_rc", TRUE); LpConfig *marie_config = linphone_core_get_config(marie->lc); LinphoneProxyConfig *focus_proxy_config = linphone_core_get_default_proxy_config(((LinphoneCoreManager *)focus)->lc); @@ -868,7 +868,7 @@ void simple_remote_conference(void) { void simple_remote_conference_shut_down_focus(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); - LinphoneCoreManager *laure = linphone_core_manager_new("laure_rc"); + LinphoneCoreManager *laure = linphone_core_manager_new("laure_rc_udp"); LinphoneConferenceServer *focus = linphone_conference_server_new("conference_focus_rc", FALSE); LpConfig *marie_config = linphone_core_get_config(marie->lc); LinphoneProxyConfig *focus_proxy_config = linphone_core_get_default_proxy_config(((LinphoneCoreManager *)focus)->lc); @@ -899,7 +899,7 @@ void simple_remote_conference_shut_down_focus(void) { void eject_from_3_participants_remote_conference(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc"); + LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); LinphoneConferenceServer *focus = linphone_conference_server_new("conference_focus_rc", TRUE); LpConfig *marie_config = linphone_core_get_config(marie->lc); LinphoneProxyConfig *focus_proxy_config = linphone_core_get_default_proxy_config(((LinphoneCoreManager *)focus)->lc); diff --git a/tester/rcfiles/laure_rc b/tester/rcfiles/laure_rc_udp similarity index 100% rename from tester/rcfiles/laure_rc rename to tester/rcfiles/laure_rc_udp diff --git a/tester/rcfiles/michelle_rc b/tester/rcfiles/michelle_rc_udp similarity index 100% rename from tester/rcfiles/michelle_rc rename to tester/rcfiles/michelle_rc_udp diff --git a/tester/video_tester.c b/tester/video_tester.c index 35aa44228..d1be16593 100644 --- a/tester/video_tester.c +++ b/tester/video_tester.c @@ -257,7 +257,7 @@ static void early_media_video_during_video_call_test(void) { marie = linphone_core_manager_new("marie_rc"); pauline = linphone_core_manager_new("pauline_tcp_rc"); - laure = linphone_core_manager_new("laure_rc"); + laure = linphone_core_manager_new("laure_rc_udp"); marie_params = configure_for_early_media_video_receiving(marie); pauline_params = configure_for_video(pauline); laure_params = configure_for_early_media_video_sending(laure); @@ -307,7 +307,7 @@ static void two_incoming_early_media_video_calls_test(void) { marie = linphone_core_manager_new("marie_rc"); pauline = linphone_core_manager_new("pauline_tcp_rc"); - laure = linphone_core_manager_new("laure_rc"); + laure = linphone_core_manager_new("laure_rc_udp"); marie_params = configure_for_early_media_video_receiving(marie); pauline_params = configure_for_early_media_video_sending(pauline); laure_params = configure_for_early_media_video_sending(laure); From 49d0eadbab1f10439fb68994f6d34585baff3487 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 2 Jun 2016 17:09:24 +0200 Subject: [PATCH 020/124] tester: fix crash on iOS, and do NOT check for stun when not in ICE test --- tester/log_collection_tester.c | 2 +- tester/multi_call_tester.c | 23 +++++++++++++++-------- tester/tester.c | 10 +++++++--- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tester/log_collection_tester.c b/tester/log_collection_tester.c index a18c90e69..4f58223d3 100644 --- a/tester/log_collection_tester.c +++ b/tester/log_collection_tester.c @@ -215,7 +215,6 @@ static time_t check_file(LinphoneCoreManager* mgr) { timediff = labs((long int)log_time - (long int)cur_time); - (void)timediff; #ifndef _WIN32 BC_ASSERT_LOWER(timediff, 1, unsigned, "%u"); if( !(timediff <= 1) ){ @@ -230,6 +229,7 @@ static time_t check_file(LinphoneCoreManager* mgr) { ); } #else + (void)timediff; ms_warning("strptime() not available for this platform, test is incomplete."); #endif } diff --git a/tester/multi_call_tester.c b/tester/multi_call_tester.c index 968d72529..e1f2ebef3 100644 --- a/tester/multi_call_tester.c +++ b/tester/multi_call_tester.c @@ -216,7 +216,7 @@ static void incoming_call_accepted_when_outgoing_call_in_state(LinphoneCallState linphone_core_terminate_all_calls(marie->lc); - + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,10000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,2,10000)); BC_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallEnd,1,10000)); @@ -580,12 +580,18 @@ static void call_transfer_existing_call_outgoing_call(void) { marie_call_pauline=linphone_core_get_current_call(marie->lc); pauline_called_by_marie=linphone_core_get_current_call(pauline->lc); /*marie pause pauline*/ - BC_ASSERT_TRUE(pause_call_1(marie,marie_call_pauline,pauline,pauline_called_by_marie)); + if (!BC_ASSERT_TRUE(pause_call_1(marie,marie_call_pauline,pauline,pauline_called_by_marie))) { + goto end; + } /*marie call laure*/ - BC_ASSERT_TRUE(call(marie,laure)); + if (!BC_ASSERT_TRUE(call(marie,laure))) { + end_call(marie, pauline); + goto end; + } marie_call_laure=linphone_core_get_current_call(marie->lc); laure_called_by_marie=linphone_core_get_current_call(laure->lc); + /*marie pause laure*/ BC_ASSERT_TRUE(pause_call_1(marie,marie_call_laure,laure,laure_called_by_marie)); @@ -629,6 +635,7 @@ static void call_transfer_existing_call_outgoing_call(void) { end_call(pauline, laure); } +end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(laure); linphone_core_manager_destroy(pauline); @@ -808,23 +815,23 @@ static void eject_from_4_participants_conference(void) { BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(laure->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(michelle->lc)); - + linphone_core_terminate_all_calls(laure->lc); linphone_core_terminate_all_calls(pauline->lc); linphone_core_terminate_all_calls(michelle->lc); - + BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphoneCallEnd, 1, 10000)); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallEnd, 1, 10000)); BC_ASSERT_TRUE(wait_for_list(lcs, &michelle->stat.number_of_LinphoneCallEnd, 1, 10000)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallEnd, 3, 10000)); - + BC_ASSERT_PTR_NULL(linphone_core_get_conference(marie->lc)); - + BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphoneCallReleased, 1, 10000)); BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallReleased, 1, 10000)); BC_ASSERT_TRUE(wait_for_list(lcs, &michelle->stat.number_of_LinphoneCallReleased, 1, 10000)); BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallEnd, 3, 10000)); - + end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); diff --git a/tester/tester.c b/tester/tester.c index 315428bc1..3fde70ea2 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -149,9 +149,9 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c linphone_core_set_ringback(lc, ringbackpath); linphone_core_set_root_ca(lc,rootcapath); } - + linphone_core_enable_ipv6(lc, liblinphonetester_ipv6); - + sal_enable_test_features(lc->sal,TRUE); sal_set_dns_user_hosts_file(lc->sal, dnsuserhostspath); linphone_core_set_static_picture(lc,nowebcampath); @@ -377,7 +377,11 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies if ((nat_policy != NULL) && (linphone_nat_policy_get_stun_server(nat_policy) != NULL) && (linphone_nat_policy_stun_enabled(nat_policy) || linphone_nat_policy_turn_enabled(nat_policy))) { /*before we go, ensure that the stun server is resolved, otherwise all ice related test will fail*/ - BC_ASSERT_TRUE(wait_for_stun_resolution(mgr)); + const char **tags = bc_tester_current_test_tags(); + int ice_test = (tags && ((tags[0] && !strcmp(tags[0], "ICE")) || (tags[1] && !strcmp(tags[1], "ICE")))); + if (ice_test) { + BC_ASSERT_TRUE(wait_for_stun_resolution(mgr)); + } } if (!check_for_proxies){ /*now that stun server resolution is done, we can start registering*/ From 015e7e7861e1906cae167758a362def1a678bee0 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 3 Jun 2016 14:42:50 +0200 Subject: [PATCH 021/124] Fix crash when there is no default friend list --- coreapi/presence.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coreapi/presence.c b/coreapi/presence.c index ad74eb83a..d4b93f7ff 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -1496,9 +1496,15 @@ void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf){ void linphone_core_notify_all_friends(LinphoneCore *lc, LinphonePresenceModel *presence){ LinphonePresenceActivity *activity = linphone_presence_model_get_activity(presence); char *activity_str = linphone_presence_activity_to_string(activity); + LinphoneFriendList *lfl = linphone_core_get_default_friend_list(lc); ms_message("Notifying all friends that we are [%s]", activity_str); if (activity_str != NULL) ms_free(activity_str); - linphone_friend_list_notify_presence(linphone_core_get_default_friend_list(lc), presence); + + if (lfl) { + linphone_friend_list_notify_presence(lfl, presence); + } else { + ms_error("Default friend list is null, skipping..."); + } } void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){ From e664b73e68cd5a6fce8558b66bbd835ad1567e9e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 3 Jun 2016 14:58:05 +0200 Subject: [PATCH 022/124] Add some checks in the TURN tests + add test of TURN with rtcp-mux. --- coreapi/misc.c | 5 +++++ coreapi/private.h | 3 ++- mediastreamer2 | 2 +- tester/stun_tester.c | 53 +++++++++++++++++++++++++++++++------------- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index b627b35c7..8e11a4348 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -635,6 +635,10 @@ void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable) { lc->forced_ice_relay = enable; } +void linphone_core_enable_short_turn_refresh(LinphoneCore *lc, bool_t enable) { + lc->short_turn_refresh = enable; +} + static void stun_auth_requested_cb(LinphoneCall *call, const char *realm, const char *nonce, const char **username, const char **password, const char **ha1) { LinphoneProxyConfig *proxy = NULL; const LinphoneNatPolicy *nat_policy = NULL; @@ -712,6 +716,7 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call){ linphone_core_notify_display_status(lc, _("ICE local candidates gathering in progress...")); ice_session_enable_forced_relay(call->ice_session, lc->forced_ice_relay); + ice_session_enable_short_turn_refresh(call->ice_session, lc->short_turn_refresh); // TODO: Handle IPv6 /* Gather local host candidates. */ diff --git a/coreapi/private.h b/coreapi/private.h index fd5b16b35..151c0dad1 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -505,6 +505,7 @@ LINPHONE_PUBLIC const struct addrinfo *linphone_core_get_stun_server_addrinfo(Li void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params); int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call); LINPHONE_PUBLIC void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable); +LINPHONE_PUBLIC void linphone_core_enable_short_turn_refresh(LinphoneCore *lc, bool_t enable); void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call); void linphone_call_stats_fill(LinphoneCallStats *stats, MediaStream *ms, OrtpEvent *ev); void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDescription *result); @@ -980,7 +981,7 @@ struct _LinphoneCore bool_t vtables_running; bool_t send_call_stats_periodical_updates; bool_t forced_ice_relay; - bool_t pad; + bool_t short_turn_refresh; char localip[LINPHONE_IPADDR_SIZE]; int device_rotation; int max_calls; diff --git a/mediastreamer2 b/mediastreamer2 index 1d9ededc3..bdf34ccb0 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 1d9ededc3a45372b6e2ba4b8b6052edbdfadc450 +Subproject commit bdf34ccb02acb99f6ac7996a6d5e625d34dd47cf diff --git a/tester/stun_tester.c b/tester/stun_tester.c index 41df639cb..1b2e92c54 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -108,9 +108,23 @@ static void configure_nat_policy(LinphoneCore *lc, bool_t turn_enabled) { linphone_auth_info_destroy(auth_info); } -static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, bool_t callee_turn_enabled) { +static void check_turn_context_statistics(MSTurnContext *turn_context, bool_t forced_relay) { + BC_ASSERT_TRUE(turn_context->stats.nb_successful_allocate > 1); + if (forced_relay == TRUE) { + BC_ASSERT_TRUE(turn_context->stats.nb_send_indication > 0); + BC_ASSERT_TRUE(turn_context->stats.nb_data_indication > 0); + BC_ASSERT_TRUE(turn_context->stats.nb_received_channel_msg > 0); + BC_ASSERT_TRUE(turn_context->stats.nb_sent_channel_msg > 0); + BC_ASSERT_TRUE(turn_context->stats.nb_successful_refresh > 0); + BC_ASSERT_TRUE(turn_context->stats.nb_successful_create_permission > 1); + BC_ASSERT_TRUE(turn_context->stats.nb_successful_channel_bind > 1); + } +} + +static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, bool_t callee_turn_enabled, bool_t rtcp_mux_enabled) { LinphoneCoreManager *marie; LinphoneCoreManager *pauline; + LinphoneCall *lcall; LinphoneIceState expected_ice_state = LinphoneIceStateHostConnection; MSList *lcs = NULL; @@ -124,8 +138,14 @@ static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, if (forced_relay == TRUE) { linphone_core_enable_forced_ice_relay(marie->lc, TRUE); linphone_core_enable_forced_ice_relay(pauline->lc, TRUE); + linphone_core_enable_short_turn_refresh(marie->lc, TRUE); + linphone_core_enable_short_turn_refresh(pauline->lc, TRUE); expected_ice_state = LinphoneIceStateRelayConnection; } + if (rtcp_mux_enabled == TRUE) { + lp_config_set_int(linphone_core_get_config(marie->lc), "rtp", "rtcp_mux", 1); + lp_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "rtcp_mux", 1); + } BC_ASSERT_TRUE(call(marie, pauline)); @@ -137,18 +157,14 @@ static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive); check_media_direction(pauline, linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive); liblinphone_tester_check_rtcp(marie, pauline); - if (forced_relay == TRUE) { - LinphoneCall *call = linphone_core_get_current_call(marie->lc); - BC_ASSERT_PTR_NOT_NULL(call->ice_session); - if (call->ice_session != NULL) { - IceCheckList *cl = ice_session_check_list(call->ice_session, 0); - BC_ASSERT_PTR_NOT_NULL(cl); - if (cl != NULL) { - BC_ASSERT_TRUE(cl->rtp_turn_context->stats_nb_send_indication > 0); - BC_ASSERT_TRUE(cl->rtp_turn_context->stats_nb_data_indication > 0); - BC_ASSERT_TRUE(cl->rtp_turn_context->stats_nb_received_channel_msg > 0); - BC_ASSERT_TRUE(cl->rtp_turn_context->stats_nb_sent_channel_msg > 0); - } + lcall = linphone_core_get_current_call(marie->lc); + BC_ASSERT_PTR_NOT_NULL(lcall->ice_session); + if (lcall->ice_session != NULL) { + IceCheckList *cl = ice_session_check_list(lcall->ice_session, 0); + BC_ASSERT_PTR_NOT_NULL(cl); + if (cl != NULL) { + check_turn_context_statistics(cl->rtp_turn_context, forced_relay); + if (!rtcp_mux_enabled) check_turn_context_statistics(cl->rtcp_turn_context, forced_relay); } } @@ -160,15 +176,19 @@ static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, } static void basic_ice_turn_call(void) { - ice_turn_call_base(FALSE, TRUE, TRUE); + ice_turn_call_base(FALSE, TRUE, TRUE, FALSE); } static void relayed_ice_turn_call(void) { - ice_turn_call_base(TRUE, TRUE, TRUE); + ice_turn_call_base(TRUE, TRUE, TRUE, FALSE); +} + +static void relayed_ice_turn_call_with_rtcp_mux(void) { + ice_turn_call_base(TRUE, TRUE, TRUE, TRUE); } static void relayed_ice_turn_to_ice_stun_call(void) { - ice_turn_call_base(TRUE, TRUE, FALSE); + ice_turn_call_base(TRUE, TRUE, FALSE, FALSE); } @@ -177,6 +197,7 @@ test_t stun_tests[] = { TEST_ONE_TAG("STUN encode", linphone_stun_test_encode, "STUN"), TEST_TWO_TAGS("Basic ICE+TURN call", basic_ice_turn_call, "ICE", "TURN"), TEST_TWO_TAGS("Relayed ICE+TURN call", relayed_ice_turn_call, "ICE", "TURN"), + TEST_TWO_TAGS("Relayed ICE+TURN call with rtcp-mux", relayed_ice_turn_call_with_rtcp_mux, "ICE", "TURN"), TEST_TWO_TAGS("Relayed ICE+TURN to ICE+STUN call", relayed_ice_turn_to_ice_stun_call, "ICE", "TURN") }; From 9f949c70d206cdf7c8383983b910475ae5ef4b51 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 3 Jun 2016 15:22:42 +0200 Subject: [PATCH 023/124] Add tests of TURN with video. --- tester/stun_tester.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tester/stun_tester.c b/tester/stun_tester.c index 1b2e92c54..d6e5ec686 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -121,11 +121,12 @@ static void check_turn_context_statistics(MSTurnContext *turn_context, bool_t fo } } -static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, bool_t callee_turn_enabled, bool_t rtcp_mux_enabled) { +static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t caller_turn_enabled, bool_t callee_turn_enabled, bool_t rtcp_mux_enabled) { LinphoneCoreManager *marie; LinphoneCoreManager *pauline; LinphoneCall *lcall; LinphoneIceState expected_ice_state = LinphoneIceStateHostConnection; + LinphoneMediaDirection expected_video_dir = LinphoneMediaDirectionInactive; MSList *lcs = NULL; marie = linphone_core_manager_new("marie_rc"); @@ -147,15 +148,20 @@ static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, lp_config_set_int(linphone_core_get_config(pauline->lc), "rtp", "rtcp_mux", 1); } - BC_ASSERT_TRUE(call(marie, pauline)); + if (video_enabled) { + video_call_base_2(marie, pauline, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); + expected_video_dir = LinphoneMediaDirectionSendRecv; + } else { + BC_ASSERT_TRUE(call(marie, pauline)); + } /* Wait for the ICE reINVITE to complete */ BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); BC_ASSERT_TRUE(check_ice(pauline, marie, expected_ice_state)); check_nb_media_starts(pauline, marie, 1, 1); - check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive); - check_media_direction(pauline, linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionInactive); + check_media_direction(marie, linphone_core_get_current_call(marie->lc), lcs, LinphoneMediaDirectionSendRecv, expected_video_dir); + check_media_direction(pauline, linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionSendRecv, expected_video_dir); liblinphone_tester_check_rtcp(marie, pauline); lcall = linphone_core_get_current_call(marie->lc); BC_ASSERT_PTR_NOT_NULL(lcall->ice_session); @@ -176,19 +182,27 @@ static void ice_turn_call_base(bool_t forced_relay, bool_t caller_turn_enabled, } static void basic_ice_turn_call(void) { - ice_turn_call_base(FALSE, TRUE, TRUE, FALSE); + ice_turn_call_base(FALSE, FALSE, TRUE, TRUE, FALSE); +} + +static void video_ice_turn_call(void) { + ice_turn_call_base(TRUE, FALSE, TRUE, TRUE, FALSE); } static void relayed_ice_turn_call(void) { - ice_turn_call_base(TRUE, TRUE, TRUE, FALSE); + ice_turn_call_base(FALSE, TRUE, TRUE, TRUE, FALSE); +} + +static void relayed_video_ice_turn_call(void) { + ice_turn_call_base(TRUE, TRUE, TRUE, TRUE, FALSE); } static void relayed_ice_turn_call_with_rtcp_mux(void) { - ice_turn_call_base(TRUE, TRUE, TRUE, TRUE); + ice_turn_call_base(FALSE, TRUE, TRUE, TRUE, TRUE); } static void relayed_ice_turn_to_ice_stun_call(void) { - ice_turn_call_base(TRUE, TRUE, FALSE, FALSE); + ice_turn_call_base(FALSE, TRUE, TRUE, FALSE, FALSE); } @@ -196,7 +210,9 @@ test_t stun_tests[] = { TEST_ONE_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip, "STUN"), TEST_ONE_TAG("STUN encode", linphone_stun_test_encode, "STUN"), TEST_TWO_TAGS("Basic ICE+TURN call", basic_ice_turn_call, "ICE", "TURN"), + TEST_TWO_TAGS("Video ICE+TURN call", video_ice_turn_call, "ICE", "TURN"), TEST_TWO_TAGS("Relayed ICE+TURN call", relayed_ice_turn_call, "ICE", "TURN"), + TEST_TWO_TAGS("Relayed video ICE+TURN call", relayed_video_ice_turn_call, "ICE", "TURN"), TEST_TWO_TAGS("Relayed ICE+TURN call with rtcp-mux", relayed_ice_turn_call_with_rtcp_mux, "ICE", "TURN"), TEST_TWO_TAGS("Relayed ICE+TURN to ICE+STUN call", relayed_ice_turn_to_ice_stun_call, "ICE", "TURN") }; From 34cd736aa2bee6de4bc8c264a0fb7c49f191401b Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 3 Jun 2016 18:56:03 +0200 Subject: [PATCH 024/124] fix audio-only build --- tester/stun_tester.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tester/stun_tester.c b/tester/stun_tester.c index d6e5ec686..b05471a49 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -149,8 +149,10 @@ static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t } if (video_enabled) { +#ifdef VIDEO_ENABLED video_call_base_2(marie, pauline, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); expected_video_dir = LinphoneMediaDirectionSendRecv; +#endif } else { BC_ASSERT_TRUE(call(marie, pauline)); } @@ -185,17 +187,21 @@ static void basic_ice_turn_call(void) { ice_turn_call_base(FALSE, FALSE, TRUE, TRUE, FALSE); } +#ifdef VIDEO_ENABLED static void video_ice_turn_call(void) { ice_turn_call_base(TRUE, FALSE, TRUE, TRUE, FALSE); } +#endif static void relayed_ice_turn_call(void) { ice_turn_call_base(FALSE, TRUE, TRUE, TRUE, FALSE); } +#ifdef VIDEO_ENABLED static void relayed_video_ice_turn_call(void) { ice_turn_call_base(TRUE, TRUE, TRUE, TRUE, FALSE); } +#endif static void relayed_ice_turn_call_with_rtcp_mux(void) { ice_turn_call_base(FALSE, TRUE, TRUE, TRUE, TRUE); @@ -210,9 +216,11 @@ test_t stun_tests[] = { TEST_ONE_TAG("Basic Stun test (Ping/public IP)", linphone_stun_test_grab_ip, "STUN"), TEST_ONE_TAG("STUN encode", linphone_stun_test_encode, "STUN"), TEST_TWO_TAGS("Basic ICE+TURN call", basic_ice_turn_call, "ICE", "TURN"), +#ifdef VIDEO_ENABLED TEST_TWO_TAGS("Video ICE+TURN call", video_ice_turn_call, "ICE", "TURN"), - TEST_TWO_TAGS("Relayed ICE+TURN call", relayed_ice_turn_call, "ICE", "TURN"), TEST_TWO_TAGS("Relayed video ICE+TURN call", relayed_video_ice_turn_call, "ICE", "TURN"), +#endif + TEST_TWO_TAGS("Relayed ICE+TURN call", relayed_ice_turn_call, "ICE", "TURN"), TEST_TWO_TAGS("Relayed ICE+TURN call with rtcp-mux", relayed_ice_turn_call_with_rtcp_mux, "ICE", "TURN"), TEST_TWO_TAGS("Relayed ICE+TURN to ICE+STUN call", relayed_ice_turn_to_ice_stun_call, "ICE", "TURN") }; From 5b29f574649e401c8cd9aaadc376fabdcd61396d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 6 Jun 2016 10:39:43 +0200 Subject: [PATCH 025/124] Fix build with upnp. --- coreapi/linphonecore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 12f9b87cc..b1bd4d612 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5222,7 +5222,7 @@ void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy break; case LinphonePolicyUseUpnp: #ifdef BUILD_UPNP - linphone_nat_policy_enable_upnp(nat_policy); + linphone_nat_policy_enable_upnp(nat_policy, TRUE); #else ms_warning("UPNP is not available, reset firewall policy to no firewall"); #endif //BUILD_UPNP From d6424def2a28eb3276aeb97ced780edeb8a3b390 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 6 Jun 2016 11:11:02 +0200 Subject: [PATCH 026/124] Little ICE fixes. --- coreapi/misc.c | 3 ++- mediastreamer2 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 8e11a4348..d7233c977 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -912,7 +912,7 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess if (result == TRUE) { strncpy(desc->addr, rtp_candidate->taddr.ip, sizeof(desc->addr)); } else { - ms_warning("If ICE has completed successfully, rtp_addr should be set!"); + ms_warning("If ICE has completed successfully, rtp_candidate should be set!"); } } else { @@ -924,6 +924,7 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess SalStreamDescription *stream = &desc->streams[i]; IceCheckList *cl = ice_session_check_list(session, i); nb_candidates = 0; + rtp_candidate = rtcp_candidate = NULL; if (!sal_stream_description_active(stream) || (cl == NULL)) continue; if (ice_check_list_state(cl) == ICL_Completed) { if (use_nortpproxy) stream->set_nortpproxy = TRUE; diff --git a/mediastreamer2 b/mediastreamer2 index bdf34ccb0..85c5f163f 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit bdf34ccb02acb99f6ac7996a6d5e625d34dd47cf +Subproject commit 85c5f163f534183eda22cfcefb099bd5c128ee34 From 062abe3cf1899dd7d90bfa0957df3953086e8385 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 6 Jun 2016 11:15:35 +0200 Subject: [PATCH 027/124] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 85c5f163f..f6e55b278 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 85c5f163f534183eda22cfcefb099bd5c128ee34 +Subproject commit f6e55b278997a48fcfe799c6a98bbf221adad9ab From 7b4af96a4a8c9939a1e0f6c2bd373b0ade53f2c0 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 6 Jun 2016 11:35:31 +0200 Subject: [PATCH 028/124] Fix Python module build. --- coreapi/lpconfig.h | 11 ++++++++++- tools/python/apixml2python.py | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/coreapi/lpconfig.h b/coreapi/lpconfig.h index 2e3a99d60..c69f3d999 100644 --- a/coreapi/lpconfig.h +++ b/coreapi/lpconfig.h @@ -106,8 +106,13 @@ LINPHONE_PUBLIC const char *lp_config_get_string(const LpConfig *lpconfig, const /** * Retrieves a configuration item as a list of strings, given its section, key, and default value. + * The default value is returned if the config item is not found. * @ingroup misc - * The default value is returned if the config item isn't found. + * @param[in] lpconfig A LpConfig object + * @param[in] section The section from which to retrieve a configuration item + * @param[in] key The name of the configuration item to retrieve + * @param[in] default_list \mslist{const char *} + * @return \mslist{const char *} */ LINPHONE_PUBLIC MSList * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, MSList *default_list); @@ -154,6 +159,10 @@ LINPHONE_PUBLIC void lp_config_set_string(LpConfig *lpconfig,const char *section /** * Sets a string list config item * @ingroup misc + * @param[in] lpconfig A LpConfig object + * @param[in] section The name of the section to put the configuration item into + * @param[in] key The name of the configuration item to set + * @param[in] value \mslist{const char *} The value to set */ LINPHONE_PUBLIC void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const MSList *value); diff --git a/tools/python/apixml2python.py b/tools/python/apixml2python.py index ba4fa7a72..3151a2aed 100755 --- a/tools/python/apixml2python.py +++ b/tools/python/apixml2python.py @@ -47,6 +47,7 @@ blacklisted_functions = [ 'linphone_core_can_we_add_call', # private function 'linphone_core_enable_log_collection', # need to handle class properties 'linphone_core_get_audio_port_range', # to be handwritten because of result via arguments + 'linphone_core_get_network_simulator_params', # missing OrtpNetworkSimulatorParams 'linphone_core_get_supported_video_sizes', # missing MSVideoSizeDef 'linphone_core_get_video_policy', # missing LinphoneVideoPolicy 'linphone_core_get_video_port_range', # to be handwritten because of result via arguments @@ -60,6 +61,7 @@ blacklisted_functions = [ 'linphone_core_set_log_handler', # Hand-written but put directly in the linphone module 'linphone_core_set_log_level', # There is no use to wrap this function 'linphone_core_set_log_level_mask', # There is no use to wrap this function + 'linphone_core_set_network_simulator_params', # missing OrtpNetworkSimulatorParams 'linphone_core_set_video_policy', # missing LinphoneVideoPolicy 'linphone_proxy_config_get_privacy', # missing LinphonePrivacyMask 'linphone_proxy_config_normalize_number', # to be handwritten because of result via arguments From f426902ebe60f1467eb72c12d5aa493087eaf09d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 6 Jun 2016 11:56:55 +0200 Subject: [PATCH 029/124] Fixed Sqlite VFS for Android --- coreapi/linphonecore.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b1bd4d612..fc29dc920 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1823,13 +1823,14 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab lc->ringtoneplayer = linphone_ringtoneplayer_new(); +#ifdef SQLITE_STORAGE_ENABLED + sqlite3_bctbx_vfs_register(0); +#endif + remote_provisioning_uri = linphone_core_get_provisioning_uri(lc); if (remote_provisioning_uri == NULL) { linphone_configuring_terminated(lc, LinphoneConfiguringSkipped, NULL); } // else linphone_core_start will be called after the remote provisioning (see linphone_core_iterate) -#ifdef SQLITE_STORAGE_ENABLED - sqlite3_bctbx_vfs_register(0); -#endif } LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable, From e3ed72b70dfe19352cf388a41db52e777080d9bb Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 6 Jun 2016 12:38:38 +0200 Subject: [PATCH 030/124] Blacklist linphone_nat_policy_get_stun_server_addrinfo() for Python module. --- tools/python/apixml2python.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/python/apixml2python.py b/tools/python/apixml2python.py index 3151a2aed..423df355d 100755 --- a/tools/python/apixml2python.py +++ b/tools/python/apixml2python.py @@ -63,6 +63,7 @@ blacklisted_functions = [ 'linphone_core_set_log_level_mask', # There is no use to wrap this function 'linphone_core_set_network_simulator_params', # missing OrtpNetworkSimulatorParams 'linphone_core_set_video_policy', # missing LinphoneVideoPolicy + 'linphone_nat_policy_get_stun_server_addrinfo', 'linphone_proxy_config_get_privacy', # missing LinphonePrivacyMask 'linphone_proxy_config_normalize_number', # to be handwritten because of result via arguments 'linphone_proxy_config_set_file_transfer_server', # defined but not implemented in linphone core From 77bdd092bd8bb32ddc0a2c8fb0702673df57d102 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 6 Jun 2016 14:31:35 +0200 Subject: [PATCH 031/124] update oRTP to fix bug with RtpModifiers --- oRTP | 2 +- tester/call_tester.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oRTP b/oRTP index f21765b4a..1f1acfbd7 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit f21765b4ae0a012906add1473768a1bf0b57567c +Subproject commit 1f1acfbd71c55c621831e7304545e4c6eae1b718 diff --git a/tester/call_tester.c b/tester/call_tester.c index 09b597af5..c6b21f854 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -5700,8 +5700,8 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { rtp_stats_t pauline_rtp_stats = linphone_call_stats_get_rtp_stats(pauline_stats); ms_message("Marie sent %i RTP packets and received %i (for real)", (int)marie_rtp_stats.packet_sent, (int)marie_rtp_stats.packet_recv); ms_message("Pauline sent %i RTP packets and received %i (for real)", (int)pauline_rtp_stats.packet_sent, (int)pauline_rtp_stats.packet_recv); - BC_ASSERT_TRUE(data_marie->packetReceivedCount == marie_rtp_stats.packet_recv); - BC_ASSERT_TRUE(data_marie->packetSentCount == marie_rtp_stats.packet_sent); + BC_ASSERT_EQUAL(data_marie->packetReceivedCount, marie_rtp_stats.packet_recv, int, "%i"); + BC_ASSERT_EQUAL(data_marie->packetSentCount, marie_rtp_stats.packet_sent, int, "%i"); // There can be a small difference between the number of packets received in the modifier and the number processed in reception because the processing is asynchronous BC_ASSERT_TRUE(data_pauline->packetReceivedCount - pauline_rtp_stats.packet_recv < 20); BC_ASSERT_TRUE(data_pauline->packetSentCount == pauline_rtp_stats.packet_sent); From f1f5172156ccc85adfdf5dce7a5a5538026c1f71 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Mon, 6 Jun 2016 16:12:25 +0200 Subject: [PATCH 032/124] Reset ca path if not valid --- coreapi/linphonecore.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index fc29dc920..046a0f2da 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -928,17 +928,21 @@ static void sound_config_read(LinphoneCore *lc) static void certificates_config_read(LinphoneCore *lc) { const char *rootca; -#ifdef __linux + struct stat sb; - rootca=lp_config_get_string(lc->config,"sip","root_ca", "/etc/ssl/certs"); - if (stat("/etc/ssl/certs", &sb) != 0 || !S_ISDIR(sb.st_mode)) - { - ms_warning("/etc/ssl/certs not found, using %s instead", ROOT_CA_FILE); - rootca=lp_config_get_string(lc->config,"sip","root_ca", ROOT_CA_FILE); - } -#else - rootca=lp_config_get_string(lc->config,"sip","root_ca", ROOT_CA_FILE); + rootca=lp_config_get_string(lc->config,"sip","root_ca", NULL); + // If rootca is not existing anymore, we reset it to the default value + if (rootca == NULL || !bctbx_file_exist(rootca)) { +#ifdef __linux + if (stat("/etc/ssl/certs", &sb) == 0 && S_ISDIR(sb.st_mode)) { + rootca = "/etc/ssl/certs"; + } else #endif + if (bctbx_file_exist(ROOT_CA_FILE)) { + ms_warning("/etc/ssl/certs not found, using %s instead", ROOT_CA_FILE); + rootca=lp_config_get_string(lc->config,"sip","root_ca", ROOT_CA_FILE); + } + } linphone_core_set_root_ca(lc,rootca); linphone_core_verify_server_certificates(lc,lp_config_get_int(lc->config,"sip","verify_server_certs",TRUE)); linphone_core_verify_server_cn(lc,lp_config_get_int(lc->config,"sip","verify_server_cn",TRUE)); From 2825ec6a5569ba74944024bc5edb3557d677fc58 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Mon, 6 Jun 2016 16:32:40 +0200 Subject: [PATCH 033/124] Fix previous commit --- coreapi/linphonecore.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 046a0f2da..a392670b6 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -927,13 +927,11 @@ static void sound_config_read(LinphoneCore *lc) static void certificates_config_read(LinphoneCore *lc) { - const char *rootca; - - struct stat sb; - rootca=lp_config_get_string(lc->config,"sip","root_ca", NULL); + const char *rootca = lp_config_get_string(lc->config,"sip","root_ca", NULL); // If rootca is not existing anymore, we reset it to the default value if (rootca == NULL || !bctbx_file_exist(rootca)) { #ifdef __linux + struct stat sb; if (stat("/etc/ssl/certs", &sb) == 0 && S_ISDIR(sb.st_mode)) { rootca = "/etc/ssl/certs"; } else From 0e798af5e3db95fd62daed343615e111b428ac55 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 6 Jun 2016 17:10:48 +0200 Subject: [PATCH 034/124] Update ms2 and ortp submodules. --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index f6e55b278..b08106d17 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit f6e55b278997a48fcfe799c6a98bbf221adad9ab +Subproject commit b08106d173a5fae42b35b3af5b4210a5864ab093 diff --git a/oRTP b/oRTP index 1f1acfbd7..7612f40de 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 1f1acfbd71c55c621831e7304545e4c6eae1b718 +Subproject commit 7612f40de599ebdde055290366281905904f902c From 1b62cd64e211bc8eccf90702eb8b9de450aac055 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 6 Jun 2016 17:11:35 +0200 Subject: [PATCH 035/124] Use correct pragma for deprecation in Visual Studio. --- coreapi/private.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/coreapi/private.h b/coreapi/private.h index 151c0dad1..ddc3d60d1 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -255,12 +255,17 @@ struct _LinphoneChatMessage { belle_http_request_listener_t *http_listener; /* our listener, only owned by us*/ char *file_transfer_filepath; -#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#if defined(__clang__) || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#if defined(__clang__) || defined(__GNUC__) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif +#ifdef _MSC_VER +#pragma deprecated(message_state_changed_cb) +#endif LinphoneChatMessageStateChangedCb message_state_changed_cb; -#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#if defined(__clang__) || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic pop #endif }; From 728c6887f1650345cb681c695aced74e3266c4c4 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 6 Jun 2016 17:12:01 +0200 Subject: [PATCH 036/124] Fix some compilation warnings. --- coreapi/conference.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coreapi/conference.cc b/coreapi/conference.cc index a3401f758..bd5660840 100644 --- a/coreapi/conference.cc +++ b/coreapi/conference.cc @@ -924,7 +924,7 @@ LinphoneConferenceParams *linphone_conference_params_clone(const LinphoneConfere } void linphone_conference_params_enable_video(LinphoneConferenceParams *params, bool_t enable) { - ((Conference::Params *)params)->enableVideo(enable); + ((Conference::Params *)params)->enableVideo((enable == TRUE) ? true : false); } bool_t linphone_conference_params_video_requested(const LinphoneConferenceParams *params) { @@ -994,7 +994,7 @@ AudioStream *linphone_conference_get_audio_stream(const LinphoneConference *obj) } int linphone_conference_mute_microphone(LinphoneConference *obj, bool_t val) { - return ((Conference *)obj)->muteMicrophone(val); + return ((Conference *)obj)->muteMicrophone((val == TRUE) ? true : false); } bool_t linphone_conference_microphone_is_muted(const LinphoneConference *obj) { @@ -1028,7 +1028,7 @@ int linphone_conference_stop_recording(LinphoneConference *obj) { } void linphone_conference_on_call_stream_starting(LinphoneConference *obj, LinphoneCall *call, bool_t is_paused_by_remote) { - ((Conference *)obj)->onCallStreamStarting(call, is_paused_by_remote); + ((Conference *)obj)->onCallStreamStarting(call, (is_paused_by_remote == TRUE) ? true : false); } void linphone_conference_on_call_stream_stopping(LinphoneConference *obj, LinphoneCall *call) { From 2fee71cdea12a917e82a6a49d7d37b2dd8371fbd Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 7 Jun 2016 12:00:46 +0200 Subject: [PATCH 037/124] Fix use of bctbx_file_exist for reseting of ca path --- coreapi/linphonecore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index a392670b6..e36b6e61b 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -929,14 +929,14 @@ static void certificates_config_read(LinphoneCore *lc) { const char *rootca = lp_config_get_string(lc->config,"sip","root_ca", NULL); // If rootca is not existing anymore, we reset it to the default value - if (rootca == NULL || !bctbx_file_exist(rootca)) { + if (rootca == NULL || (bctbx_file_exist(rootca) < 0)) { #ifdef __linux struct stat sb; if (stat("/etc/ssl/certs", &sb) == 0 && S_ISDIR(sb.st_mode)) { rootca = "/etc/ssl/certs"; } else #endif - if (bctbx_file_exist(ROOT_CA_FILE)) { + if (bctbx_file_exist(ROOT_CA_FILE) < 0) { ms_warning("/etc/ssl/certs not found, using %s instead", ROOT_CA_FILE); rootca=lp_config_get_string(lc->config,"sip","root_ca", ROOT_CA_FILE); } From 3b84bfcaf9ec4b9c6be34f8e6f0096680fb0a269 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 7 Jun 2016 13:58:42 +0200 Subject: [PATCH 038/124] improve nat64 support for Apple platform --- coreapi/bellesip_sal/sal_op_impl.c | 26 ++++++++++---- coreapi/linphonecall.c | 6 ++-- tester/call_tester.c | 35 +++++++++++++++++-- tester/liblinphone_tester.h | 1 + tester/rcfiles/marie_nat64_rc | 55 ++++++++++++++++++++++++++++++ tester/rcfiles/pauline_nat64_rc | 51 +++++++++++++++++++++++++++ tester/tester.c | 19 +++++++++++ tester/tester_hosts | 1 + 8 files changed, 183 insertions(+), 11 deletions(-) create mode 100644 tester/rcfiles/marie_nat64_rc create mode 100644 tester/rcfiles/pauline_nat64_rc diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index 51b7d23a5..92686da46 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -741,7 +741,7 @@ void sal_op_set_manual_refresher_mode(SalOp *op, bool_t enabled){ bool_t sal_op_is_ipv6(SalOp *op){ belle_sip_transaction_t *tr=NULL; belle_sip_header_address_t *contact; - belle_sip_request_t *req; + if (op->refresher) tr=(belle_sip_transaction_t *)belle_sip_refresher_get_transaction(op->refresher); @@ -750,17 +750,29 @@ bool_t sal_op_is_ipv6(SalOp *op){ tr=(belle_sip_transaction_t *)op->pending_client_trans; if (tr==NULL) tr=(belle_sip_transaction_t *)op->pending_server_trans; - + if (tr==NULL){ ms_error("Unable to determine IP version from signaling operation."); return FALSE; } - req=belle_sip_transaction_get_request(tr); - contact=(belle_sip_header_address_t*)belle_sip_message_get_header_by_type(req,belle_sip_header_contact_t); - if (!contact){ - ms_error("Unable to determine IP version from signaling operation, no contact header found."); + + + if (op->refresher) { + belle_sip_response_t *resp = belle_sip_transaction_get_response(tr); + belle_sip_header_via_t *via = resp ?belle_sip_message_get_header_by_type(resp,belle_sip_header_via_t):NULL; + if (!via){ + ms_error("Unable to determine IP version from signaling operation, no via header found."); + return FALSE; + } + return strchr(belle_sip_header_via_get_host(via),':') != NULL; + } else { + belle_sip_request_t *req = belle_sip_transaction_get_request(tr); + contact=(belle_sip_header_address_t*)belle_sip_message_get_header_by_type(req,belle_sip_header_contact_t); + if (!contact){ + ms_error("Unable to determine IP version from signaling operation, no contact header found."); + } + return sal_address_is_ipv6((SalAddress*)contact); } - return sal_address_is_ipv6((SalAddress*)contact); } bool_t sal_op_is_idle(SalOp *op){ diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 21ba67ff9..5c6480244 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1202,10 +1202,12 @@ void linphone_call_set_compatible_incoming_call_parameters(LinphoneCall *call, S }else if (call->params->media_encryption != LinphoneMediaEncryptionZRTP){ call->params->media_encryption = LinphoneMediaEncryptionNone; } - if (!sal_media_description_has_ipv6(md)){ + + /*in case of nat64, even ipv4 addresses are reachable from v6. Should be enhanced to manage stream by stream connectivity (I.E v6 or v4)*/ + /*if (!sal_media_description_has_ipv6(md)){ ms_message("The remote SDP doesn't seem to offer any IPv6 connectivity, so disabling IPv6 for this call."); call->af = AF_INET; - } + }*/ linphone_call_fix_call_parameters(call, md); } diff --git a/tester/call_tester.c b/tester/call_tester.c index c6b21f854..40be0b536 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -6373,10 +6373,40 @@ static void call_with_zrtp_configured_callee_side(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); - - } + +static void v6_call_over_nat_64(void){ + LinphoneCoreManager* marie; + LinphoneCoreManager* pauline; + + if (!liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){ + + bool_t liblinphonetester_ipv6_save=liblinphonetester_ipv6; /*this test nee v6*/ + liblinphonetester_ipv6=TRUE; + + marie = linphone_core_manager_new("marie_nat64_rc"); + pauline = linphone_core_manager_new("pauline_nat64_rc"); + + linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL); + linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL); + + BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneRegistrationOk, 1, 2000)); + BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &marie->stat.number_of_LinphoneRegistrationOk, 1, 2000)); + + + BC_ASSERT_TRUE(call(marie,pauline)); + + liblinphone_tester_check_rtcp(marie,pauline); + end_call(marie,pauline); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + liblinphonetester_ipv6=liblinphonetester_ipv6_save; /*this test nee v6*/ + + }else ms_warning("Test skipped, no ipv6 nat64 available"); +} + + test_t call_tests[] = { TEST_NO_TAG("Early declined call", early_declined_call), TEST_NO_TAG("Call declined", call_declined), @@ -6391,6 +6421,7 @@ test_t call_tests[] = { TEST_NO_TAG("Call with http proxy", call_with_http_proxy), TEST_NO_TAG("Call with timeouted bye", call_with_timeouted_bye), TEST_NO_TAG("Direct call over IPv6", direct_call_over_ipv6), + TEST_NO_TAG("IPv6 call over NAT64", v6_call_over_nat_64), TEST_NO_TAG("Outbound call with multiple proxy possible", call_outbound_with_multiple_proxy), TEST_NO_TAG("Audio call recording", audio_call_recording_test), #if 0 /* not yet activated because not implemented */ diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 7c17d7231..242bc339d 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -70,6 +70,7 @@ extern test_suite_t complex_sip_call_test_suite; extern int manager_count; extern int liblinphone_tester_ipv6_available(void); +extern int liblinphone_tester_ipv4_available(void); /** * @brief Tells the tester whether or not to clean the accounts it has created between runs. diff --git a/tester/rcfiles/marie_nat64_rc b/tester/rcfiles/marie_nat64_rc new file mode 100644 index 000000000..a59516c72 --- /dev/null +++ b/tester/rcfiles/marie_nat64_rc @@ -0,0 +1,55 @@ +[sip] +sip_port=-1 +sip_tcp_port=-1 +sip_tls_port=-1 +default_proxy=0 +ping_with_options=0 +use_ipv6=1 +composing_idle_timeout=1 +store_ha1_passwd=0 #used for sipp + +[auth_info_0] +username=marie +userid=marie +passwd=secret +realm=sip.example.org + + +[proxy_0] +reg_proxy=sipv4.example.org;transport=tcp +reg_route=sipv4.example.org;transport=tcp;lr +reg_identity="Super Marie" +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 + +[friend_0] +url="Paupoche" +pol=accept +subscribe=0 + + +[rtp] +audio_rtp_port=18070-28000 +video_rtp_port=28070-38000 +text_rtp_port=39000-49000 + +[video] +display=0 +capture=0 +show_local=0 +size=qcif +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG + +[net] +dns_srv_enabled=0 #no srv needed in general +stun_server=stun.linphone.org + diff --git a/tester/rcfiles/pauline_nat64_rc b/tester/rcfiles/pauline_nat64_rc new file mode 100644 index 000000000..b2255c3c6 --- /dev/null +++ b/tester/rcfiles/pauline_nat64_rc @@ -0,0 +1,51 @@ +[sip] +sip_port=-1 +sip_tcp_port=-1 +sip_tls_port=-1 +default_proxy=0 +ping_with_options=0 +use_ipv6=1 +composing_idle_timeout=1 + +[auth_info_0] +username=pauline +userid=pauline +passwd=secret +realm=sip.example.org + + +[proxy_0] +reg_proxy=sipv4.example.org;transport=tls +reg_route=sipv4.example.org;transport=tls +reg_identity=sip:pauline@sip.example.org +reg_expires=3600 +reg_sendregister=1 +publish=0 +dial_escape_plus=0 + +#[friend_0] +#url="Mariette" +#pol=accept +#subscribe=0 + +[rtp] +audio_rtp_port=18070-28000 +video_rtp_port=39072-49000 + +[video] +display=0 +capture=0 +show_local=0 +size=qcif +enabled=0 +self_view=0 +automatically_initiate=0 +automatically_accept=0 +device=StaticImage: Static picture + +[sound] +echocancellation=0 #to not overload cpu in case of VG + +[net] +dns_srv_enabled=0 #no srv needed in general +stun_server=stun.linphone.org diff --git a/tester/tester.c b/tester/tester.c index 3fde70ea2..90a810b00 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -457,6 +457,25 @@ int liblinphone_tester_ipv6_available(void){ return FALSE; } +int liblinphone_tester_ipv4_available(void){ + struct addrinfo *ai=bctbx_ip_address_to_addrinfo(AF_INET,SOCK_STREAM,"212.27.40.240",53); + if (ai){ + struct sockaddr_storage ss; + struct addrinfo src; + socklen_t slen=sizeof(ss); + char localip[128]; + int port=0; + belle_sip_get_src_addr_for(ai->ai_addr,(socklen_t)ai->ai_addrlen,(struct sockaddr*) &ss,&slen,4444); + src.ai_addr=(struct sockaddr*) &ss; + src.ai_addrlen=slen; + bctbx_addrinfo_to_ip_address(&src,localip, sizeof(localip),&port); + freeaddrinfo(ai); + return strcmp(localip,"127.0.0.1")!=0; + } + return FALSE; +} + + void liblinphone_tester_keep_accounts( int keep ){ liblinphone_tester_keep_accounts_flag = keep; } diff --git a/tester/tester_hosts b/tester/tester_hosts index 638e4eb6d..6416ddebc 100644 --- a/tester/tester_hosts +++ b/tester/tester_hosts @@ -1,3 +1,4 @@ 94.23.19.176 sip2.linphone.org sip.example.org sipopen.example.org auth.example.org auth1.example.org auth2.example.org altname.linphone.org sip.wildcard1.linphone.org altname.wildcard2.linphone.org 2001:41d0:2:14b0::1 sip2.linphone.org sip.example.org sipopen.example.org auth.example.org auth1.example.org auth2.example.org altname.linphone.org sip.wildcard1.linphone.org altname.wildcard2.linphone.org 188.165.46.90 tunnel.wildcard2.linphone.org +64:ff9b::94.23.19.176 sipv4.example.org From 72dcaef493b249ff7b50a9333044d609d8e5a5d8 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 7 Jun 2016 14:10:36 +0200 Subject: [PATCH 039/124] Fix ca path for no linux system --- coreapi/linphonecore.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e36b6e61b..e95f6b6a3 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -929,15 +929,14 @@ static void certificates_config_read(LinphoneCore *lc) { const char *rootca = lp_config_get_string(lc->config,"sip","root_ca", NULL); // If rootca is not existing anymore, we reset it to the default value - if (rootca == NULL || (bctbx_file_exist(rootca) < 0)) { + if (rootca == NULL || (bctbx_file_exist(rootca) != 0)) { #ifdef __linux struct stat sb; if (stat("/etc/ssl/certs", &sb) == 0 && S_ISDIR(sb.st_mode)) { rootca = "/etc/ssl/certs"; } else #endif - if (bctbx_file_exist(ROOT_CA_FILE) < 0) { - ms_warning("/etc/ssl/certs not found, using %s instead", ROOT_CA_FILE); + if (bctbx_file_exist(ROOT_CA_FILE) == 0) { rootca=lp_config_get_string(lc->config,"sip","root_ca", ROOT_CA_FILE); } } From 795829bb10d8fb0975a439c0552c1b5cb5fa6bfe Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 7 Jun 2016 14:15:13 +0200 Subject: [PATCH 040/124] Fix previous commit --- coreapi/linphonecore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e95f6b6a3..2684e327a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -937,7 +937,7 @@ static void certificates_config_read(LinphoneCore *lc) } else #endif if (bctbx_file_exist(ROOT_CA_FILE) == 0) { - rootca=lp_config_get_string(lc->config,"sip","root_ca", ROOT_CA_FILE); + rootca = ROOT_CA_FILE; } } linphone_core_set_root_ca(lc,rootca); From b5606700c52e5febf257bbf6c8c5a90b77a0bc39 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 7 Jun 2016 15:45:53 +0200 Subject: [PATCH 041/124] address.c: dont check linphone_address_set_domain --- coreapi/address.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/coreapi/address.c b/coreapi/address.c index 8f4cb9df4..83e9d5a5e 100644 --- a/coreapi/address.c +++ b/coreapi/address.c @@ -106,17 +106,8 @@ int linphone_address_set_username(LinphoneAddress *uri, const char *username){ * Sets the domain. **/ int linphone_address_set_domain(LinphoneAddress *uri, const char *host){ - if (host) { - char *identity = ms_strdup_printf("sip:%s", host); - LinphoneAddress* test = linphone_address_new(identity); - ms_free(identity); - if (test) { - sal_address_set_domain(uri,host); - linphone_address_destroy(test); - return 0; - } - } - return -1; + sal_address_set_domain(uri,host); + return 0; } From abab667da569e843ed2fec0d5a62afa4dc6cc438 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 7 Jun 2016 15:50:24 +0200 Subject: [PATCH 042/124] Fix bug in migration from firewall_policy to nat_policy. Even after creating the nat_policy, the settings of the firewall_policy could still be used resulting in unexpected behavior. --- coreapi/linphonecore.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 2684e327a..4a57af379 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5241,6 +5241,9 @@ void linphone_core_set_firewall_policy(LinphoneCore *lc, LinphoneFirewallPolicy } linphone_core_set_nat_policy(lc, nat_policy); linphone_nat_policy_unref(nat_policy); + + /* Ensure that the firewall policy is cleared in the config because it has been replaced by the nat_policy. */ + lp_config_set_string(lc->config, "net", "firewall_policy", NULL); } LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc) { From 89bbd52d60f466ba21996cbbe9128efd9ab66b38 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 8 Jun 2016 11:23:37 +0200 Subject: [PATCH 043/124] call_tester.c: fix hardcoded ip 127.0.0.1 to work also in ipv6 --- tester/call_tester.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tester/call_tester.c b/tester/call_tester.c index 40be0b536..57eaf523b 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -4965,7 +4965,7 @@ static void video_call_ice_params(void) { linphone_core_manager_destroy(pauline); } -static void audio_call_with_video_policy_enabled(void){ +static void audio_call_with_ice_with_video_policy_enabled(void){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneVideoPolicy vpol; @@ -5347,8 +5347,8 @@ static void call_with_rtp_io_mode(void) { /* The callee uses the RTP IO mode with the PCMU codec to send back audio to the caller. */ disable_all_audio_codecs_except_one(pauline->lc, "pcmu", -1); lp_config_set_int(pauline->lc->config, "sound", "rtp_io", 1); - lp_config_set_string(pauline->lc->config, "sound", "rtp_local_addr", "127.0.0.1"); - lp_config_set_string(pauline->lc->config, "sound", "rtp_remote_addr", "127.0.0.1"); + lp_config_set_string(pauline->lc->config, "sound", "rtp_local_addr", "localhost"); + lp_config_set_string(pauline->lc->config, "sound", "rtp_remote_addr", "localhost"); lp_config_set_int(pauline->lc->config, "sound", "rtp_local_port", 17076); lp_config_set_int(pauline->lc->config, "sound", "rtp_remote_port", 17076); lp_config_set_string(pauline->lc->config, "sound", "rtp_map", "pcmu/8000/1"); @@ -6379,30 +6379,30 @@ static void call_with_zrtp_configured_callee_side(void) { static void v6_call_over_nat_64(void){ LinphoneCoreManager* marie; LinphoneCoreManager* pauline; - + if (!liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){ - + bool_t liblinphonetester_ipv6_save=liblinphonetester_ipv6; /*this test nee v6*/ liblinphonetester_ipv6=TRUE; - + marie = linphone_core_manager_new("marie_nat64_rc"); pauline = linphone_core_manager_new("pauline_nat64_rc"); - + linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL); linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL); BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneRegistrationOk, 1, 2000)); BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &marie->stat.number_of_LinphoneRegistrationOk, 1, 2000)); - - + + BC_ASSERT_TRUE(call(marie,pauline)); - + liblinphone_tester_check_rtcp(marie,pauline); end_call(marie,pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); liblinphonetester_ipv6=liblinphonetester_ipv6_save; /*this test nee v6*/ - + }else ms_warning("Test skipped, no ipv6 nat64 available"); } @@ -6500,7 +6500,7 @@ test_t call_tests[] = { TEST_ONE_TAG("Call with ICE, video and realtime text", call_with_ice_video_and_rtt, "ICE"), #endif TEST_ONE_TAG("Video call with ICE accepted using call params", video_call_ice_params, "ICE"), - TEST_NO_TAG("Audio call paused with caller video policy enabled", audio_call_with_video_policy_enabled), + TEST_ONE_TAG("Audio call with ICE paused with caller video policy enabled", audio_call_with_ice_with_video_policy_enabled, "ICE"), TEST_NO_TAG("Video call recording (H264)", video_call_recording_h264_test), TEST_NO_TAG("Video call recording (VP8)", video_call_recording_vp8_test), TEST_NO_TAG("Snapshot", video_call_snapshot), From c4cfbdf93b2b0b480047ffc18eb2d4102cb25ca4 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 8 Jun 2016 13:13:43 +0200 Subject: [PATCH 044/124] fix ordering of newly added codecs --- coreapi/linphonecore.c | 12 +++++----- tester/rcfiles/marie_rc | 5 +++++ tester/setup_tester.c | 49 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 4a57af379..a047b7471 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1258,24 +1258,26 @@ static SalStreamType payload_type_get_stream_type(const PayloadType *pt){ static MSList *add_missing_supported_codecs(LinphoneCore *lc, const MSList *default_list, MSList *l){ const MSList *elem; MSList *newlist; - PayloadType *last_inserted = NULL; + PayloadType *last_seen = NULL; for(elem=default_list; elem!=NULL; elem=elem->next){ MSList *elem2=ms_list_find(l,elem->data); if (!elem2){ PayloadType *pt=(PayloadType*)elem->data; - /*this codec from default list should be inserted in the list*/ + /*this codec from default list should be inserted in the list, with respect to the default_list order*/ if (!linphone_core_codec_supported(lc, payload_type_get_stream_type(pt), pt->mime_type)) continue; - if (!last_inserted){ + if (!last_seen){ l=ms_list_prepend(l,pt); }else{ - const MSList *after=ms_list_find(l,last_inserted); + const MSList *after=ms_list_find(l,last_seen); l=ms_list_insert(l, after->next, pt); } - last_inserted = pt; + last_seen = pt; ms_message("Supported codec %s/%i fmtp=%s automatically added to codec list.", pt->mime_type, pt->clock_rate, pt->recv_fmtp ? pt->recv_fmtp : ""); + }else{ + last_seen = (PayloadType*)elem2->data; } } newlist=ms_list_copy_with_data(l,(void *(*)(void*))payload_type_clone); diff --git a/tester/rcfiles/marie_rc b/tester/rcfiles/marie_rc index 2713c20eb..64c454bb1 100644 --- a/tester/rcfiles/marie_rc +++ b/tester/rcfiles/marie_rc @@ -53,3 +53,8 @@ echocancellation=0 #to not overload cpu in case of VG dns_srv_enabled=0 #no srv needed in general stun_server=stun.linphone.org +#leave this section, which is used by "Codec setup" test of "Setup" suite. +[video_codec_0] +mime=VP8 +rate=90000 +enabled=1 diff --git a/tester/setup_tester.c b/tester/setup_tester.c index fa88e4999..160856f7c 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -330,6 +330,52 @@ end: linphone_core_manager_destroy(mgr); } +/*this test checks default codec list, assuming VP8 and H264 are both supported. + * - with an empty config, the order must be as expected: VP8 first, H264 second. + * - with a config that references only H264, VP8 must be added automatically as first codec. + * - with a config that references only VP8, H264 must be added in second position. +**/ +static void codec_setup(void){ + LinphoneCoreManager *mgr = linphone_core_manager_new2("empty_rc", FALSE); + PayloadType *vp8, *h264; + const MSList *codecs; + if ((vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1)) == NULL || + (h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1)) == NULL){ + linphone_core_manager_destroy(mgr); + ms_error("H264 or VP8 not available, test skipped."); + BC_PASS("H264 or VP8 not available, test skipped."); + return; + } + codecs = linphone_core_get_video_codecs(mgr->lc); + BC_ASSERT_TRUE(ms_list_size(codecs)>=2); + BC_ASSERT_TRUE(codecs->data == vp8); + BC_ASSERT_TRUE(codecs->next->data == h264); + linphone_core_manager_destroy(mgr); + + mgr = linphone_core_manager_new2("marie_h264_rc", FALSE); + vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1); + h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1); + codecs = linphone_core_get_video_codecs(mgr->lc); + BC_ASSERT_TRUE(ms_list_size(codecs)>=2); + BC_ASSERT_PTR_NOT_NULL(vp8); + BC_ASSERT_PTR_NOT_NULL(h264); + BC_ASSERT_TRUE(codecs->data == vp8); + BC_ASSERT_TRUE(codecs->next->data == h264); + linphone_core_manager_destroy(mgr); + + mgr = linphone_core_manager_new2("marie_rc", FALSE); + vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1); + h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1); + codecs = linphone_core_get_video_codecs(mgr->lc); + BC_ASSERT_TRUE(ms_list_size(codecs)>=2); + BC_ASSERT_PTR_NOT_NULL(vp8); + BC_ASSERT_PTR_NOT_NULL(h264); + BC_ASSERT_TRUE(codecs->data == vp8); + BC_ASSERT_TRUE(codecs->next->data == h264); + linphone_core_manager_destroy(mgr); + +} + test_t setup_tests[] = { TEST_NO_TAG("Version check", linphone_version_test), TEST_NO_TAG("Linphone Address", linphone_address_test), @@ -344,7 +390,8 @@ test_t setup_tests[] = { TEST_NO_TAG("LPConfig zero_len value from XML", linphone_lpconfig_from_xml_zerolen_value), TEST_NO_TAG("Chat room", chat_room_test), TEST_NO_TAG("Devices reload", devices_reload_test), - TEST_NO_TAG("Codec usability", codec_usability_test) + TEST_NO_TAG("Codec usability", codec_usability_test), + TEST_NO_TAG("Codec setup", codec_setup) }; test_suite_t setup_test_suite = {"Setup", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, From ae235690ff3cb1f7ea28cc248a21edd042d25117 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 9 Jun 2016 11:19:37 +0200 Subject: [PATCH 045/124] Store LinphoneContent key (when using lime) in db --- coreapi/content.c | 1 + coreapi/message_storage.c | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/coreapi/content.c b/coreapi/content.c index cc0760b0a..d95a1476b 100644 --- a/coreapi/content.c +++ b/coreapi/content.c @@ -187,6 +187,7 @@ void linphone_content_set_key(LinphoneContent *content, const char *key, const s if (key != NULL) { content->key = belle_sip_malloc(keyLength); memcpy(content->key, key, keyLength); + content->keyLength = keyLength; } } diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index b87bc8390..2a549a014 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -129,7 +129,9 @@ static ORTP_INLINE LinphoneChatMessage* get_transient_message(LinphoneChatRoom* * | 3 | name * | 4 | encoding * | 5 | size - * | 6 | data + * | 6 | data (currently not stored) + * | 7 | size + * | 8 | size */ // Callback for sql request when getting linphone content static int callback_content(void *data, int argc, char **argv, char **colName) { @@ -145,6 +147,7 @@ static int callback_content(void *data, int argc, char **argv, char **colName) { if (argv[3]) linphone_content_set_name(message->file_transfer_information, argv[3]); if (argv[4]) linphone_content_set_encoding(message->file_transfer_information, argv[4]); linphone_content_set_size(message->file_transfer_information, (size_t)atoi(argv[5])); + if (argv[8]) linphone_content_set_key(message->file_transfer_information, argv[8], (size_t)atol(argv[7])); return 0; } @@ -267,13 +270,15 @@ static int linphone_chat_message_store_content(LinphoneChatMessage *msg) { int id = -1; if (lc->db) { LinphoneContent *content = msg->file_transfer_information; - char *buf = sqlite3_mprintf("INSERT INTO content VALUES(NULL,%Q,%Q,%Q,%Q,%i,%Q);", + char *buf = sqlite3_mprintf("INSERT INTO content VALUES(NULL,%Q,%Q,%Q,%Q,%i,%Q,%lld,%Q);", linphone_content_get_type(content), linphone_content_get_subtype(content), linphone_content_get_name(content), linphone_content_get_encoding(content), linphone_content_get_size(content), - NULL + NULL, + (int64_t)linphone_content_get_key_size(content), + linphone_content_get_key(content) ); linphone_sql_request(lc->db, buf); sqlite3_free(buf); @@ -637,6 +642,21 @@ void linphone_update_table(sqlite3* db) { ms_debug("Table content successfully created."); } } + + // new fields for content key storage when using lime + ret=sqlite3_exec(db,"ALTER TABLE content ADD COLUMN key_size INTEGER;",NULL,NULL,&errmsg); + if(ret != SQLITE_OK) { + ms_message("Table already up to date: %s.", errmsg); + sqlite3_free(errmsg); + } else { + ret=sqlite3_exec(db,"ALTER TABLE content ADD COLUMN key TEXT;",NULL,NULL,&errmsg); + if(ret != SQLITE_OK) { + ms_message("Table already up to date: %s.", errmsg); + sqlite3_free(errmsg); + } else { + ms_debug("Table history content successfully for lime key storage data."); + } + } } void linphone_message_storage_init_chat_rooms(LinphoneCore *lc) { From e6ea6151ce27e75b1b9a930f86844d4bf0d11a3d Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Fri, 10 Jun 2016 10:10:58 +0200 Subject: [PATCH 046/124] VFS fixes for Windows. --- coreapi/sqlite3_bctbx_vfs.c | 108 +++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 3 deletions(-) diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index ae9d4e869..8eb14329f 100644 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -115,7 +115,7 @@ static int sqlite3bctbx_Write(sqlite3_file *p, const void *buf, int count, sqlit */ static int sqlite3bctbx_FileSize(sqlite3_file *p, sqlite_int64 *pSize){ - int rc; /* Return code from fstat() call */ + int64_t rc; /* Return code from fstat() call */ sqlite3_bctbx_file_t *pFile = (sqlite3_bctbx_file_t*) p; if (pFile->pbctbx_file){ rc = bctbx_file_size(pFile->pbctbx_file); @@ -209,7 +209,9 @@ static int sqlite3bctbx_nolockUnlock(sqlite3_file *pUnused, int unused){ static int sqlite3bctbx_Sync(sqlite3_file *p, int flags){ sqlite3_bctbx_file_t *pFile = (sqlite3_bctbx_file_t*)p; #if _WIN32 - return (FlushFileBuffers(pFile->pbctbx_file->fd) ? SQLITE_OK : SQLITE_IOERR_FSYNC); + int ret; + ret = FlushFileBuffers(pFile->pbctbx_file->h); + return (ret!=0 ? SQLITE_OK : SQLITE_IOERR_FSYNC); #else int rc = fsync(pFile->pbctbx_file->fd); return (rc==0 ? SQLITE_OK : SQLITE_IOERR_FSYNC); @@ -300,7 +302,102 @@ sqlite3_vfs *sqlite3_bctbx_vfs_create(void){ }; return &bctbx_vfs; } +#if _WIN32 +static int sqlite3bctbx_winAccess( + sqlite3_vfs *pVfs, /* Not used on win32 */ + const char *zFilename, /* Name of file to check */ + int flags, /* Type of test to make on this file */ + int *pResOut /* OUT: Result */ +){ + DWORD attr; + int rc = 0; + + + //SimulateIOError(return SQLITE_IOERR_ACCESS;); + int cnt = 0; + WIN32_FILE_ATTRIBUTE_DATA sAttrData; + memset(&sAttrData, 0, sizeof(sAttrData)); + rc = GetFileAttributesExW((LPCWSTR)zFilename, + GetFileExInfoStandard, + &sAttrData); + + if (rc){ + /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file + ** as if it does not exist. + */ + if (flags == SQLITE_ACCESS_EXISTS + && sAttrData.nFileSizeHigh == 0 + && sAttrData.nFileSizeLow == 0){ + attr = INVALID_FILE_ATTRIBUTES; + } + else{ + attr = sAttrData.dwFileAttributes; + } + } + else{ + attr = INVALID_FILE_ATTRIBUTES; + } + + switch (flags){ + case SQLITE_ACCESS_READ: + case SQLITE_ACCESS_EXISTS: + rc = attr != INVALID_FILE_ATTRIBUTES; + break; + case SQLITE_ACCESS_READWRITE: + rc = attr != INVALID_FILE_ATTRIBUTES && + (attr & FILE_ATTRIBUTE_READONLY) == 0; + break; + default: + break; + //assert(!"Invalid flags argument"); + + } + *pResOut = rc; + return SQLITE_OK; +} +static int sqlite3bctbx_winFullPathname( + sqlite3_vfs *pVfs, /* Pointer to vfs object */ + const char *zRelative, /* Possibly relative input path */ + int nFull, /* Size of output buffer in bytes */ + char *zFull){ + //LPWSTR zTemp; + //DWORD nByte; + ///* If this path name begins with "/X:", where "X" is any alphabetic + //** character, discard the initial "/" from the pathname. + //*/ + //if (zRelative[0] == '/' && sqlite3Isalpha(zRelative[1]) && zRelative[2] == ':'){ + // zRelative++; + //} + + /*nByte = GetFullPathNameW((LPCWSTR)zRelative, 0, 0, 0); + if (nByte == 0){ + return SQLITE_CANTOPEN_FULLPATH; + } + nByte += 3; + zTemp = bctbx_malloc(nByte*sizeof(zTemp[0])); + memset(zTemp, 0, nByte*sizeof(zTemp[0])); + if (zTemp == 0){ + return SQLITE_IOERR_NOMEM; + } + nByte = GetFullPathNameW((LPCWSTR)zRelative, nByte, zTemp, 0); + if (nByte == 0){ + bctbx_free(zTemp); + return SQLITE_CANTOPEN_FULLPATH; + } + if (zTemp){ + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zTemp); + bctbx_free(zTemp); + return SQLITE_OK; + /*} + else{ + return SQLITE_IOERR_NOMEM; + }*/ + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); + return SQLITE_OK; +} + +#endif void sqlite3_bctbx_vfs_register( int makeDefault){ sqlite3_vfs* pVfsToUse = sqlite3_bctbx_vfs_create(); @@ -309,10 +406,15 @@ void sqlite3_bctbx_vfs_register( int makeDefault){ #else sqlite3_vfs* pDefault = sqlite3_vfs_find("unix-none"); #endif - pVfsToUse->xAccess = pDefault->xAccess; pVfsToUse->xCurrentTime = pDefault->xCurrentTime; +#if _WIN32 + pVfsToUse->xFullPathname = sqlite3bctbx_winFullPathname; + pVfsToUse->xAccess = sqlite3bctbx_winAccess; +#else + pVfsToUse->xAccess = pDefault->xAccess; pVfsToUse->xFullPathname = pDefault->xFullPathname; +#endif pVfsToUse->xDelete = pDefault->xDelete; pVfsToUse->xSleep = pDefault->xSleep; pVfsToUse->xRandomness = pDefault->xRandomness; From e374b6505f8840199d9e6fc2eafbd4e3776320c1 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 10 Jun 2016 16:45:01 +0200 Subject: [PATCH 047/124] tester: use H264 codec when using mire webcam because VP8 does not handle Mire properly, leading to failed tests on iOS --- tester/call_tester.c | 93 +++++++++++++++++++++++++--------- tester/multicast_call_tester.c | 12 ++++- 2 files changed, 78 insertions(+), 27 deletions(-) diff --git a/tester/call_tester.c b/tester/call_tester.c index 3d894f6e4..f4511666f 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -840,12 +840,12 @@ end: static void disable_all_codecs(const MSList* elem, LinphoneCoreManager* call){ - PayloadType *pt; + PayloadType *pt; - for(;elem!=NULL;elem=elem->next){ - pt=(PayloadType*)elem->data; - linphone_core_enable_payload_type(call->lc,pt,FALSE); - } + for(;elem!=NULL;elem=elem->next){ + pt=(PayloadType*)elem->data; + linphone_core_enable_payload_type(call->lc,pt,FALSE); + } } /*** Disable all audio codecs , sends an INVITE with RTP port 0 and payload 0. @@ -3220,6 +3220,12 @@ void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video LinphoneCoreManager* pauline = linphone_core_manager_new(pauline_rc); bool_t call_ok; + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); @@ -4104,6 +4110,13 @@ static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, Linphone pol.automatically_accept=1; pol.automatically_initiate=1; + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + linphone_core_enable_video_capture(pauline->lc, TRUE); linphone_core_enable_video_display(pauline->lc, TRUE); linphone_core_set_video_policy(pauline->lc,&pol); @@ -4223,6 +4236,13 @@ static void record_call(const char *filename, bool_t enableVideo, const char *vi marie = linphone_core_manager_new("marie_h264_rc"); pauline = linphone_core_manager_new("pauline_h264_rc"); + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + #if defined(HAVE_OPENH264) && defined(ANDROID) libmsopenh264_init(linphone_core_get_ms_factory(marie->lc)); linphone_core_reload_ms_plugins(marie->lc, NULL); @@ -4877,7 +4897,15 @@ static void video_call_with_re_invite_inactive_followed_by_re_invite_base(Linpho marie = linphone_core_manager_new( "marie_rc"); pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + linphone_core_set_avpf_mode(pauline->lc,TRUE); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); linphone_core_set_avpf_mode(marie->lc,TRUE); @@ -5030,6 +5058,14 @@ static void classic_video_entry_phone_setup(void) { linphone_core_set_avpf_mode(callee_mgr->lc, LinphoneAVPFEnabled); linphone_core_set_video_policy(caller_mgr->lc, &vpol); linphone_core_set_video_policy(callee_mgr->lc, &vpol); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(caller_mgr->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(caller_mgr->lc,"h264"); + disable_all_video_codecs_except_one(callee_mgr->lc,"h264"); + } + linphone_core_set_video_device(caller_mgr->lc, liblinphone_tester_mire_id); linphone_core_set_video_device(callee_mgr->lc, liblinphone_tester_mire_id); @@ -5195,6 +5231,14 @@ static void call_with_complex_late_offering(void){ linphone_core_enable_video_display(marie->lc, TRUE); linphone_core_set_video_policy(pauline->lc, &vpol); linphone_core_set_video_policy(marie->lc, &vpol); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); @@ -5700,8 +5744,8 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { rtp_stats_t pauline_rtp_stats = linphone_call_stats_get_rtp_stats(pauline_stats); ms_message("Marie sent %i RTP packets and received %i (for real)", (int)marie_rtp_stats.packet_sent, (int)marie_rtp_stats.packet_recv); ms_message("Pauline sent %i RTP packets and received %i (for real)", (int)pauline_rtp_stats.packet_sent, (int)pauline_rtp_stats.packet_recv); - BC_ASSERT_TRUE(data_marie->packetReceivedCount == marie_rtp_stats.packet_recv); - BC_ASSERT_TRUE(data_marie->packetSentCount == marie_rtp_stats.packet_sent); + BC_ASSERT_EQUAL(data_marie->packetReceivedCount, marie_rtp_stats.packet_recv, int, "%i"); + BC_ASSERT_EQUAL(data_marie->packetSentCount, marie_rtp_stats.packet_sent, int, "%i"); // There can be a small difference between the number of packets received in the modifier and the number processed in reception because the processing is asynchronous BC_ASSERT_TRUE(data_pauline->packetReceivedCount - pauline_rtp_stats.packet_recv < 20); BC_ASSERT_TRUE(data_pauline->packetSentCount == pauline_rtp_stats.packet_sent); @@ -6407,21 +6451,20 @@ static void v6_call_over_nat_64(void){ } static void call_with_ice_in_ipv4_with_v6_enabled(void) { - if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){ - bool_t liblinphonetester_ipv6_save=liblinphonetester_ipv6; /*this test nee v6*/ - LinphoneCoreManager* marie = linphone_core_manager_new("marie_v4proxy_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_v4proxy_rc"); - - liblinphonetester_ipv6=TRUE; - _call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); - liblinphonetester_ipv6=liblinphonetester_ipv6_save; /*this test nee v6*/ + if (liblinphone_tester_ipv4_available() && liblinphone_tester_ipv6_available()){ + bool_t liblinphonetester_ipv6_save=liblinphonetester_ipv6; /*this test nee v6*/ + LinphoneCoreManager* marie = linphone_core_manager_new("marie_v4proxy_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_v4proxy_rc"); - } else ms_warning("Test skipped, need both ipv6 and v4 available"); + liblinphonetester_ipv6=TRUE; + _call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + liblinphonetester_ipv6=liblinphonetester_ipv6_save; /*this test nee v6*/ + + } else ms_warning("Test skipped, need both ipv6 and v4 available"); } - test_t call_tests[] = { TEST_NO_TAG("Early declined call", early_declined_call), TEST_NO_TAG("Call declined", call_declined), @@ -6481,12 +6524,12 @@ test_t call_tests[] = { TEST_ONE_TAG("Audio call with ICE no matching audio codecs", audio_call_with_ice_no_matching_audio_codecs, "ICE"), #ifdef VIDEO_ENABLED TEST_NO_TAG("Simple video call AVPF", video_call_avpf), - TEST_NO_TAG("Simple video call implicit AVPF both", video_call_using_policy_AVPF_implicit_caller_and_callee), - TEST_NO_TAG("Simple video call disable implicit AVPF on callee", video_call_disable_implicit_AVPF_on_callee), - TEST_NO_TAG("Simple video call disable implicit AVPF on caller", video_call_disable_implicit_AVPF_on_caller), - TEST_NO_TAG("Simple video call AVPF to implicit AVPF", video_call_AVPF_to_implicit_AVPF), - TEST_NO_TAG("Simple video call implicit AVPF to AVPF", video_call_implicit_AVPF_to_AVPF), - TEST_NO_TAG("Simple video call", video_call), + TEST_NO_TAG("Simple video call implicit AVPF both", video_call_using_policy_AVPF_implicit_caller_and_callee), + TEST_NO_TAG("Simple video call disable implicit AVPF on callee", video_call_disable_implicit_AVPF_on_callee), + TEST_NO_TAG("Simple video call disable implicit AVPF on caller", video_call_disable_implicit_AVPF_on_caller), + TEST_NO_TAG("Simple video call AVPF to implicit AVPF", video_call_AVPF_to_implicit_AVPF), + TEST_NO_TAG("Simple video call implicit AVPF to AVPF", video_call_implicit_AVPF_to_AVPF), + TEST_NO_TAG("Simple video call", video_call), TEST_NO_TAG("Simple video call without rtcp",video_call_without_rtcp), TEST_NO_TAG("Simple ZRTP video call", video_call_zrtp), TEST_NO_TAG("Simple DTLS video call", video_call_dtls), diff --git a/tester/multicast_call_tester.c b/tester/multicast_call_tester.c index bd70bd8d5..818ebbff3 100644 --- a/tester/multicast_call_tester.c +++ b/tester/multicast_call_tester.c @@ -98,11 +98,19 @@ static void early_media_with_multicast_base(bool_t video) { linphone_core_enable_video_display(pauline2->lc, TRUE); linphone_core_enable_video_capture(marie->lc, TRUE); linphone_core_enable_video_display(marie->lc, FALSE); - + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(pauline2->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + linphone_core_set_video_device(pauline->lc, liblinphone_tester_mire_id); linphone_core_set_video_device(pauline2->lc, liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc, liblinphone_tester_mire_id); - + linphone_core_set_avpf_mode(pauline->lc, LinphoneAVPFEnabled); linphone_core_set_avpf_mode(pauline2->lc, LinphoneAVPFEnabled); linphone_core_set_avpf_mode(marie->lc, LinphoneAVPFEnabled); From 254b371a0c83e5bfeb83127dcd0dd175eb159efa Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 10 Jun 2016 16:45:01 +0200 Subject: [PATCH 048/124] tester: use H264 codec when using mire webcam because VP8 does not handle Mire properly, leading to failed tests on iOS --- tester/call_tester.c | 66 ++++++++++++++++++++++++++++------ tester/multicast_call_tester.c | 12 +++++-- 2 files changed, 65 insertions(+), 13 deletions(-) diff --git a/tester/call_tester.c b/tester/call_tester.c index 57eaf523b..9e5536093 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -840,12 +840,12 @@ end: static void disable_all_codecs(const MSList* elem, LinphoneCoreManager* call){ - PayloadType *pt; + PayloadType *pt; - for(;elem!=NULL;elem=elem->next){ - pt=(PayloadType*)elem->data; - linphone_core_enable_payload_type(call->lc,pt,FALSE); - } + for(;elem!=NULL;elem=elem->next){ + pt=(PayloadType*)elem->data; + linphone_core_enable_payload_type(call->lc,pt,FALSE); + } } /*** Disable all audio codecs , sends an INVITE with RTP port 0 and payload 0. @@ -3220,6 +3220,12 @@ void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video LinphoneCoreManager* pauline = linphone_core_manager_new(pauline_rc); bool_t call_ok; + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); @@ -4104,6 +4110,13 @@ static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, Linphone pol.automatically_accept=1; pol.automatically_initiate=1; + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + linphone_core_enable_video_capture(pauline->lc, TRUE); linphone_core_enable_video_display(pauline->lc, TRUE); linphone_core_set_video_policy(pauline->lc,&pol); @@ -4223,6 +4236,13 @@ static void record_call(const char *filename, bool_t enableVideo, const char *vi marie = linphone_core_manager_new("marie_h264_rc"); pauline = linphone_core_manager_new("pauline_h264_rc"); + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + #if defined(HAVE_OPENH264) && defined(ANDROID) libmsopenh264_init(linphone_core_get_ms_factory(marie->lc)); linphone_core_reload_ms_plugins(marie->lc, NULL); @@ -4877,7 +4897,15 @@ static void video_call_with_re_invite_inactive_followed_by_re_invite_base(Linpho marie = linphone_core_manager_new( "marie_rc"); pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + linphone_core_set_avpf_mode(pauline->lc,TRUE); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); linphone_core_set_avpf_mode(marie->lc,TRUE); @@ -5030,6 +5058,14 @@ static void classic_video_entry_phone_setup(void) { linphone_core_set_avpf_mode(callee_mgr->lc, LinphoneAVPFEnabled); linphone_core_set_video_policy(caller_mgr->lc, &vpol); linphone_core_set_video_policy(callee_mgr->lc, &vpol); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(caller_mgr->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(caller_mgr->lc,"h264"); + disable_all_video_codecs_except_one(callee_mgr->lc,"h264"); + } + linphone_core_set_video_device(caller_mgr->lc, liblinphone_tester_mire_id); linphone_core_set_video_device(callee_mgr->lc, liblinphone_tester_mire_id); @@ -5195,6 +5231,14 @@ static void call_with_complex_late_offering(void){ linphone_core_enable_video_display(marie->lc, TRUE); linphone_core_set_video_policy(pauline->lc, &vpol); linphone_core_set_video_policy(marie->lc, &vpol); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); @@ -6465,12 +6509,12 @@ test_t call_tests[] = { TEST_ONE_TAG("Audio call with ICE no matching audio codecs", audio_call_with_ice_no_matching_audio_codecs, "ICE"), #ifdef VIDEO_ENABLED TEST_NO_TAG("Simple video call AVPF", video_call_avpf), - TEST_NO_TAG("Simple video call implicit AVPF both", video_call_using_policy_AVPF_implicit_caller_and_callee), - TEST_NO_TAG("Simple video call disable implicit AVPF on callee", video_call_disable_implicit_AVPF_on_callee), - TEST_NO_TAG("Simple video call disable implicit AVPF on caller", video_call_disable_implicit_AVPF_on_caller), - TEST_NO_TAG("Simple video call AVPF to implicit AVPF", video_call_AVPF_to_implicit_AVPF), - TEST_NO_TAG("Simple video call implicit AVPF to AVPF", video_call_implicit_AVPF_to_AVPF), - TEST_NO_TAG("Simple video call", video_call), + TEST_NO_TAG("Simple video call implicit AVPF both", video_call_using_policy_AVPF_implicit_caller_and_callee), + TEST_NO_TAG("Simple video call disable implicit AVPF on callee", video_call_disable_implicit_AVPF_on_callee), + TEST_NO_TAG("Simple video call disable implicit AVPF on caller", video_call_disable_implicit_AVPF_on_caller), + TEST_NO_TAG("Simple video call AVPF to implicit AVPF", video_call_AVPF_to_implicit_AVPF), + TEST_NO_TAG("Simple video call implicit AVPF to AVPF", video_call_implicit_AVPF_to_AVPF), + TEST_NO_TAG("Simple video call", video_call), TEST_NO_TAG("Simple video call without rtcp",video_call_without_rtcp), TEST_NO_TAG("Simple ZRTP video call", video_call_zrtp), TEST_NO_TAG("Simple DTLS video call", video_call_dtls), diff --git a/tester/multicast_call_tester.c b/tester/multicast_call_tester.c index bd70bd8d5..818ebbff3 100644 --- a/tester/multicast_call_tester.c +++ b/tester/multicast_call_tester.c @@ -98,11 +98,19 @@ static void early_media_with_multicast_base(bool_t video) { linphone_core_enable_video_display(pauline2->lc, TRUE); linphone_core_enable_video_capture(marie->lc, TRUE); linphone_core_enable_video_display(marie->lc, FALSE); - + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(pauline2->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + linphone_core_set_video_device(pauline->lc, liblinphone_tester_mire_id); linphone_core_set_video_device(pauline2->lc, liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc, liblinphone_tester_mire_id); - + linphone_core_set_avpf_mode(pauline->lc, LinphoneAVPFEnabled); linphone_core_set_avpf_mode(pauline2->lc, LinphoneAVPFEnabled); linphone_core_set_avpf_mode(marie->lc, LinphoneAVPFEnabled); From 5a5ebe955da32294abe3c6fc13f16528df371f4b Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 10 Jun 2016 23:27:42 +0200 Subject: [PATCH 049/124] fix compilation warning and update oRTP --- coreapi/sqlite3_bctbx_vfs.c | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index 8eb14329f..5e48e2736 100644 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -389,7 +389,7 @@ static int sqlite3bctbx_winFullPathname( sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zTemp); bctbx_free(zTemp); return SQLITE_OK; - /*} + } else{ return SQLITE_IOERR_NOMEM; }*/ diff --git a/oRTP b/oRTP index 7612f40de..469444ddc 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 7612f40de599ebdde055290366281905904f902c +Subproject commit 469444ddc6c3bdf1312d33e2678f1ee99c7e9939 From db9bdf16718196aafef1923e597d480bd70704e1 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 09:32:58 +0200 Subject: [PATCH 050/124] call_tester.c: always compile disable_all_video_codecs_except_one to fix no video builds --- tester/call_tester.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tester/call_tester.c b/tester/call_tester.c index 9e5536093..f0f44eb02 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -1028,8 +1028,8 @@ void disable_all_audio_codecs_except_one(LinphoneCore *lc, const char *mime, int } } -#ifdef VIDEO_ENABLED void disable_all_video_codecs_except_one(LinphoneCore *lc, const char *mime) { +#ifdef VIDEO_ENABLED const MSList *codecs = linphone_core_get_video_codecs(lc); const MSList *it = NULL; PayloadType *pt = NULL; @@ -1041,8 +1041,8 @@ void disable_all_video_codecs_except_one(LinphoneCore *lc, const char *mime) { if (BC_ASSERT_PTR_NOT_NULL(pt)) { linphone_core_enable_payload_type(lc, pt, TRUE); } -} #endif +} static void call_with_dns_time_out(void) { LinphoneCoreManager* marie = linphone_core_manager_new2( "empty_rc", FALSE); From 7efea0504c964c7c7ded4f38964de626d2bb0bd6 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 09:32:58 +0200 Subject: [PATCH 051/124] call_tester.c: always compile disable_all_video_codecs_except_one to fix no video builds --- tester/call_tester.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tester/call_tester.c b/tester/call_tester.c index f4511666f..a749cc19f 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -1028,8 +1028,8 @@ void disable_all_audio_codecs_except_one(LinphoneCore *lc, const char *mime, int } } -#ifdef VIDEO_ENABLED void disable_all_video_codecs_except_one(LinphoneCore *lc, const char *mime) { +#ifdef VIDEO_ENABLED const MSList *codecs = linphone_core_get_video_codecs(lc); const MSList *it = NULL; PayloadType *pt = NULL; @@ -1041,8 +1041,8 @@ void disable_all_video_codecs_except_one(LinphoneCore *lc, const char *mime) { if (BC_ASSERT_PTR_NOT_NULL(pt)) { linphone_core_enable_payload_type(lc, pt, TRUE); } -} #endif +} static void call_with_dns_time_out(void) { LinphoneCoreManager* marie = linphone_core_manager_new2( "empty_rc", FALSE); From d88b44a53709e997a753a2ac936cf485defd627c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 10 Jun 2016 16:53:23 +0200 Subject: [PATCH 052/124] Prevent tester from crashing if error in openning database file --- tester/message_tester.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tester/message_tester.c b/tester/message_tester.c index 26c615e7c..2a000d15a 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1167,6 +1167,8 @@ static void database_migration(void) { // the messages.db has 10000 dummy messages with the very first DB scheme. // This will test the migration procedure linphone_core_set_chat_database_path(marie->lc, tmp_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); + if (!marie->lc->db) goto end; chatrooms = linphone_core_get_chat_rooms(marie->lc); BC_ASSERT(ms_list_size(chatrooms) > 0); @@ -1174,6 +1176,7 @@ static void database_migration(void) { // check that all messages have been migrated to the UTC time storage BC_ASSERT(sqlite3_exec(marie->lc->db, "SELECT COUNT(*) FROM history WHERE time != '-1';", check_no_strange_time, NULL, NULL) == SQLITE_OK ); +end: linphone_core_manager_destroy(marie); remove(tmp_db); ms_free(src_db); @@ -1190,6 +1193,8 @@ static void history_range(void){ BC_ASSERT_EQUAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d"); linphone_core_set_chat_database_path(marie->lc, tmp_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); + if (!marie->lc->db) goto end; chatroom = linphone_core_get_chat_room(marie->lc, jehan_addr); BC_ASSERT_PTR_NOT_NULL(chatroom); @@ -1213,6 +1218,8 @@ static void history_range(void){ history_message_count_helper(chatroom, -2, 2, 3); history_message_count_helper(chatroom, -3, 1, 2); } + +end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); remove(tmp_db); @@ -1231,6 +1238,8 @@ static void history_count(void) { BC_ASSERT_EQUAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d"); linphone_core_set_chat_database_path(marie->lc, tmp_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); + if (!marie->lc->db) goto end; chatroom = linphone_core_get_chat_room(marie->lc, jehan_addr); BC_ASSERT_PTR_NOT_NULL(chatroom); @@ -1279,6 +1288,8 @@ static void history_count(void) { BC_ASSERT_EQUAL(ms_list_size(messages), 1270-1265, int, "%d"); ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); } + +end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); remove(tmp_db); @@ -1345,7 +1356,9 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo if (sql_storage) { linphone_core_set_chat_database_path(marie->lc, marie_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); linphone_core_set_chat_database_path(pauline->lc, pauline_db); + BC_ASSERT_PTR_NOT_NULL(pauline->lc->db); if (do_not_store_rtt_messages_in_sql_storage) { lp_config_set_int(marie->lc->config, "misc", "store_rtt_messages", 0); lp_config_set_int(pauline->lc->config, "misc", "store_rtt_messages", 0); From 17c7bb61bff716bedbd0189e69268d6d2637de4c Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 10:55:55 +0200 Subject: [PATCH 053/124] tester: increase extra time for DNS SRV resolution timeout --- tester/accountmanager.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tester/accountmanager.c b/tester/accountmanager.c index 52973682c..90704d9ee 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -160,8 +160,9 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf linphone_proxy_config_set_expires(cfg,3*3600); //accounts are valid 3 hours linphone_core_add_proxy_config(lc,cfg); - /*wait 15 seconds, since the DNS SRV resolution make time a while*/ - if (wait_for_until(lc,NULL,&account->created,1,15000)==FALSE){ + /*wait 25 seconds, since the DNS SRV resolution may take a while - and + especially if router does NOT support DNS SRV and we have to wait its timeout*/ + if (wait_for_until(lc,NULL,&account->created,1,25000)==FALSE){ ms_fatal("Account for %s could not be created on server.", linphone_proxy_config_get_identity(refcfg)); } linphone_proxy_config_edit(cfg); From 865d08ffd1e2943ccb5b7be0f8eb1e835bf1ba3f Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 10 Jun 2016 23:27:42 +0200 Subject: [PATCH 054/124] fix compilation warning and update oRTP --- coreapi/sqlite3_bctbx_vfs.c | 78 ++++++++++++++++++++++++++++--------- oRTP | 2 +- 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index ae9d4e869..6730afd4d 100644 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -51,17 +51,17 @@ static int sqlite3bctbx_Close(sqlite3_file *p){ /** - * Read count bytes from the open file given by p, starting at offset and puts them in + * Read count bytes from the open file given by p, starting at offset and puts them in * the buffer pointed by buf. * Calls bctbx_file_read. - * + * * @param p sqlite3_file file handle pointer. * @param buf buffer to write the read bytes to. * @param count number of bytes to read * @param offset file offset where to start reading - * @return SQLITE_OK if read bytes equals count, + * @return SQLITE_OK if read bytes equals count, * SQLITE_IOERR_SHORT_READ if the number of bytes read is inferior to count - * SQLITE_IOERR_READ if an error occurred. + * SQLITE_IOERR_READ if an error occurred. */ static int sqlite3bctbx_Read(sqlite3_file *p, void *buf, int count, sqlite_int64 offset){ int ret; @@ -73,10 +73,10 @@ static int sqlite3bctbx_Read(sqlite3_file *p, void *buf, int count, sqlite_int64 } else if( ret >= 0 ){ /*fill in unread portion of buffer, as requested by sqlite3 documentation*/ - memset(((uint8_t*)buf) + ret, 0, count-ret); + memset(((uint8_t*)buf) + ret, 0, count-ret); return SQLITE_IOERR_SHORT_READ; }else { - + return SQLITE_IOERR_READ; } } @@ -104,14 +104,14 @@ static int sqlite3bctbx_Write(sqlite3_file *p, const void *buf, int count, sqlit } return SQLITE_IOERR_WRITE; } - + /** * Saves the file size associated with the file handle p into the argument pSize. * @param p sqlite3_file file handle pointer. - * @return SQLITE_OK if read bytes equals count, - * SQLITE_IOERR_FSTAT if the file size returned is negative - * SQLITE_ERROR if an error occurred. + * @return SQLITE_OK if read bytes equals count, + * SQLITE_IOERR_FSTAT if the file size returned is negative + * SQLITE_ERROR if an error occurred. */ static int sqlite3bctbx_FileSize(sqlite3_file *p, sqlite_int64 *pSize){ @@ -125,7 +125,7 @@ static int sqlite3bctbx_FileSize(sqlite3_file *p, sqlite_int64 *pSize){ if (pSize){ *pSize = rc; return SQLITE_OK; - } + } } return SQLITE_ERROR; @@ -134,7 +134,7 @@ static int sqlite3bctbx_FileSize(sqlite3_file *p, sqlite_int64 *pSize){ /************************ PLACE HOLDER FUNCTIONS ***********************/ -/** These functions were implemented to please the SQLite VFS +/** These functions were implemented to please the SQLite VFS implementation. Some of them are just stubs, some do a very limited job. */ @@ -177,7 +177,7 @@ static int sqlite3bctbx_nolockCheckReservedLock(sqlite3_file *pUnused, int *pRes } /** - * The lock file mechanism is not used with this VFS : locking the file + * The lock file mechanism is not used with this VFS : locking the file * is always OK. * @param pUnused sqlite3_file file handle pointer. * @param unused unused @@ -227,7 +227,7 @@ static int sqlite3bctbx_Sync(sqlite3_file *p, int flags){ * @param pVfs sqlite3_vfs VFS pointer. * @param fName filename * @param p file handle pointer - * @param flags db file access flags + * @param flags db file access flags * @param pOutFlags flags used by SQLite * @return SQLITE_CANTOPEN on error, SQLITE_OK on success. */ @@ -239,7 +239,7 @@ static int sqlite3bctbx_Open(sqlite3_vfs *pVfs, const char *fName, sqlite3_file sqlite3bctbx_Write, /* xWrite */ 0, /*xTruncate*/ sqlite3bctbx_Sync, - sqlite3bctbx_FileSize, + sqlite3bctbx_FileSize, sqlite3bctbx_nolockLock, sqlite3bctbx_nolockUnlock, sqlite3bctbx_nolockCheckReservedLock, @@ -301,6 +301,48 @@ sqlite3_vfs *sqlite3_bctbx_vfs_create(void){ return &bctbx_vfs; } +static int sqlite3bctbx_winFullPathname( + sqlite3_vfs *pVfs, /* Pointer to vfs object */ + const char *zRelative, /* Possibly relative input path */ + int nFull, /* Size of output buffer in bytes */ + char *zFull){ + //LPWSTR zTemp; + //DWORD nByte; + ///* If this path name begins with "/X:", where "X" is any alphabetic + //** character, discard the initial "/" from the pathname. + //*/ + //if (zRelative[0] == '/' && sqlite3Isalpha(zRelative[1]) && zRelative[2] == ':'){ + // zRelative++; + //} + + /*nByte = GetFullPathNameW((LPCWSTR)zRelative, 0, 0, 0); + if (nByte == 0){ + return SQLITE_CANTOPEN_FULLPATH; + } + nByte += 3; + zTemp = bctbx_malloc(nByte*sizeof(zTemp[0])); + memset(zTemp, 0, nByte*sizeof(zTemp[0])); + if (zTemp == 0){ + return SQLITE_IOERR_NOMEM; + } + nByte = GetFullPathNameW((LPCWSTR)zRelative, nByte, zTemp, 0); + if (nByte == 0){ + bctbx_free(zTemp); + return SQLITE_CANTOPEN_FULLPATH; + } + if (zTemp){ + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zTemp); + bctbx_free(zTemp); + return SQLITE_OK; + } + else{ + return SQLITE_IOERR_NOMEM; + }*/ + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); + return SQLITE_OK; +} + +#endif void sqlite3_bctbx_vfs_register( int makeDefault){ sqlite3_vfs* pVfsToUse = sqlite3_bctbx_vfs_create(); @@ -319,10 +361,10 @@ void sqlite3_bctbx_vfs_register( int makeDefault){ pVfsToUse->xGetLastError = pDefault->xGetLastError; /* Not implemented by sqlite3 :place holder */ /*Functions below should not be a problem sincve we are declaring ourselves in version 1 */ - - /* used in version 2 + + /* used in version 2 xCurrentTimeInt64;*/ - /* used in version 3 + /* used in version 3 xGetSystemCall xSetSystemCall xNextSystemCall*/ diff --git a/oRTP b/oRTP index 171c441fa..469444ddc 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 171c441fa7aa4cdc616461a88cad74fd842c6145 +Subproject commit 469444ddc6c3bdf1312d33e2678f1ee99c7e9939 From e5251162800375ba4959cf3a904f75adfdd250eb Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 10 Jun 2016 16:53:23 +0200 Subject: [PATCH 055/124] Prevent tester from crashing if error in openning database file --- tester/message_tester.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tester/message_tester.c b/tester/message_tester.c index 5ada03f4e..bf2d160bd 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1201,6 +1201,8 @@ static void database_migration(void) { // the messages.db has 10000 dummy messages with the very first DB scheme. // This will test the migration procedure linphone_core_set_chat_database_path(marie->lc, tmp_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); + if (!marie->lc->db) goto end; chatrooms = linphone_core_get_chat_rooms(marie->lc); BC_ASSERT(ms_list_size(chatrooms) > 0); @@ -1208,6 +1210,7 @@ static void database_migration(void) { // check that all messages have been migrated to the UTC time storage BC_ASSERT(sqlite3_exec(marie->lc->db, "SELECT COUNT(*) FROM history WHERE time != '-1';", check_no_strange_time, NULL, NULL) == SQLITE_OK ); +end: linphone_core_manager_destroy(marie); remove(tmp_db); ms_free(src_db); @@ -1224,6 +1227,8 @@ static void history_range(void){ BC_ASSERT_EQUAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d"); linphone_core_set_chat_database_path(marie->lc, tmp_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); + if (!marie->lc->db) goto end; chatroom = linphone_core_get_chat_room(marie->lc, jehan_addr); BC_ASSERT_PTR_NOT_NULL(chatroom); @@ -1247,6 +1252,8 @@ static void history_range(void){ history_message_count_helper(chatroom, -2, 2, 3); history_message_count_helper(chatroom, -3, 1, 2); } + +end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); remove(tmp_db); @@ -1265,6 +1272,8 @@ static void history_count(void) { BC_ASSERT_EQUAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d"); linphone_core_set_chat_database_path(marie->lc, tmp_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); + if (!marie->lc->db) goto end; chatroom = linphone_core_get_chat_room(marie->lc, jehan_addr); BC_ASSERT_PTR_NOT_NULL(chatroom); @@ -1313,6 +1322,8 @@ static void history_count(void) { BC_ASSERT_EQUAL(ms_list_size(messages), 1270-1265, int, "%d"); ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); } + +end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); remove(tmp_db); @@ -1378,7 +1389,9 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo if (sql_storage) { linphone_core_set_chat_database_path(marie->lc, marie_db); + BC_ASSERT_PTR_NOT_NULL(marie->lc->db); linphone_core_set_chat_database_path(pauline->lc, pauline_db); + BC_ASSERT_PTR_NOT_NULL(pauline->lc->db); if (do_not_store_rtt_messages_in_sql_storage) { lp_config_set_int(marie->lc->config, "misc", "store_rtt_messages", 0); lp_config_set_int(pauline->lc->config, "misc", "store_rtt_messages", 0); From 038d3080f3f4a0c128ad082511731010312cbf22 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 10:55:55 +0200 Subject: [PATCH 056/124] tester: increase extra time for DNS SRV resolution timeout --- tester/accountmanager.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tester/accountmanager.c b/tester/accountmanager.c index 52973682c..90704d9ee 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -160,8 +160,9 @@ void account_create_on_server(Account *account, const LinphoneProxyConfig *refcf linphone_proxy_config_set_expires(cfg,3*3600); //accounts are valid 3 hours linphone_core_add_proxy_config(lc,cfg); - /*wait 15 seconds, since the DNS SRV resolution make time a while*/ - if (wait_for_until(lc,NULL,&account->created,1,15000)==FALSE){ + /*wait 25 seconds, since the DNS SRV resolution may take a while - and + especially if router does NOT support DNS SRV and we have to wait its timeout*/ + if (wait_for_until(lc,NULL,&account->created,1,25000)==FALSE){ ms_fatal("Account for %s could not be created on server.", linphone_proxy_config_get_identity(refcfg)); } linphone_proxy_config_edit(cfg); From 77ba701820e47e05eb4b216556fb87264a299714 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 11:04:28 +0200 Subject: [PATCH 057/124] submodules: update ms2 --- coreapi/sqlite3_bctbx_vfs.c | 2 -- mediastreamer2 | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index 6730afd4d..5ab1343ad 100644 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -342,8 +342,6 @@ static int sqlite3bctbx_winFullPathname( return SQLITE_OK; } -#endif - void sqlite3_bctbx_vfs_register( int makeDefault){ sqlite3_vfs* pVfsToUse = sqlite3_bctbx_vfs_create(); #if _WIN32 diff --git a/mediastreamer2 b/mediastreamer2 index 05c196459..06ccea67f 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 05c1964597789d17219ed01d6749fd95bf81d54e +Subproject commit 06ccea67f9f9995da81fe0cf161494ce166c1e00 From de2543d65ca57d7b4a144ccd120fe5913bccf134 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 13 Jun 2016 11:06:16 +0200 Subject: [PATCH 058/124] Disable VFS until all issues are resolved --- coreapi/call_log.c | 3 ++- coreapi/friend.c | 3 ++- coreapi/message_storage.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/coreapi/call_log.c b/coreapi/call_log.c index 1e8a3786c..9bbc4c753 100644 --- a/coreapi/call_log.c +++ b/coreapi/call_log.c @@ -376,7 +376,8 @@ void linphone_core_call_log_storage_init(LinphoneCore *lc) { linphone_core_call_log_storage_close(lc); - ret=_linphone_sqlite3_open(lc->logs_db_file, &db); + //ret=_linphone_sqlite3_open(lc->logs_db_file, &db); + ret = sqlite3_open(lc->logs_db_file, &db); if(ret != SQLITE_OK) { errmsg = sqlite3_errmsg(db); ms_error("Error in the opening: %s.\n", errmsg); diff --git a/coreapi/friend.c b/coreapi/friend.c index 2251b370c..f69314375 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1141,7 +1141,8 @@ void linphone_core_friends_storage_init(LinphoneCore *lc) { linphone_core_friends_storage_close(lc); - ret = _linphone_sqlite3_open(lc->friends_db_file, &db); + //ret = _linphone_sqlite3_open(lc->friends_db_file, &db); + ret = sqlite3_open(lc->friends_db_file, &db); if (ret != SQLITE_OK) { errmsg = sqlite3_errmsg(db); ms_error("Error in the opening: %s.\n", errmsg); diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 8af587b7b..dc13d8f27 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -695,7 +695,8 @@ void linphone_core_message_storage_init(LinphoneCore *lc){ linphone_core_message_storage_close(lc); - ret=_linphone_sqlite3_open(lc->chat_db_file,&db); + //ret=_linphone_sqlite3_open(lc->chat_db_file,&db); + ret = sqlite3_open(lc->chat_db_file,&db); if(ret != SQLITE_OK) { errmsg=sqlite3_errmsg(db); ms_error("Error in the opening: %s.\n", errmsg); From f716330a56e1d4f4fcef141180fabb4d1e69aef6 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 13 Jun 2016 12:29:10 +0200 Subject: [PATCH 059/124] Commented out unused static method --- coreapi/sqlite3_bctbx_vfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index 5ab1343ad..5ca959837 100644 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -301,7 +301,7 @@ sqlite3_vfs *sqlite3_bctbx_vfs_create(void){ return &bctbx_vfs; } -static int sqlite3bctbx_winFullPathname( +/*static int sqlite3bctbx_winFullPathname( sqlite3_vfs *pVfs, /* Pointer to vfs object */ const char *zRelative, /* Possibly relative input path */ int nFull, /* Size of output buffer in bytes */ @@ -337,10 +337,10 @@ static int sqlite3bctbx_winFullPathname( } else{ return SQLITE_IOERR_NOMEM; - }*/ + }*\/ sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); return SQLITE_OK; -} +}*/ void sqlite3_bctbx_vfs_register( int makeDefault){ sqlite3_vfs* pVfsToUse = sqlite3_bctbx_vfs_create(); From 52dffdc1293d827298349c41bd28eb46d7a57ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Mon, 13 Jun 2016 12:31:39 +0200 Subject: [PATCH 060/124] Update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index b08106d17..964c47cf9 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit b08106d173a5fae42b35b3af5b4210a5864ab093 +Subproject commit 964c47cf9c0935395493f6f10841e5a8b4eea068 From d34fcc2cfdbeda5eb1a5cb5011db051c36f778f6 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 12:34:18 +0200 Subject: [PATCH 061/124] message_tester.c: increase DNS SRV resolution timeout --- tester/message_tester.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tester/message_tester.c b/tester/message_tester.c index 2a000d15a..bb10f038f 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -453,8 +453,10 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneMessageNotDelivered,1, 10000)); belle_http_provider_set_recv_error(marie->lc->http_provider, 0); } else { - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1)); - compare_files(send_filepath, receive_filepath); + /* wait for a long time in case the DNS SRV resolution takes times - it should be immediate though */ + if (BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1,55000))) { + compare_files(send_filepath, receive_filepath); + } } } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,2, int, "%d"); //sent twice because of file transfer @@ -1218,7 +1220,7 @@ static void history_range(void){ history_message_count_helper(chatroom, -2, 2, 3); history_message_count_helper(chatroom, -3, 1, 2); } - + end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); @@ -1288,7 +1290,7 @@ static void history_count(void) { BC_ASSERT_EQUAL(ms_list_size(messages), 1270-1265, int, "%d"); ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); } - + end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); @@ -1344,7 +1346,7 @@ static void file_transfer_io_error_after_destroying_chatroom(void) { file_transfer_io_error_base("https://www.linphone.org:444/lft.php", TRUE); } -static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, bool_t mess_with_marie_payload_number, bool_t mess_with_pauline_payload_number, +static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, bool_t mess_with_marie_payload_number, bool_t mess_with_pauline_payload_number, bool_t ice_enabled, bool_t sql_storage, bool_t do_not_store_rtt_messages_in_sql_storage) { LinphoneChatRoom *pauline_chat_room; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); @@ -1353,7 +1355,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo LinphoneCall *pauline_call, *marie_call; char *marie_db = bc_tester_file("marie.db"); char *pauline_db = bc_tester_file("pauline.db"); - + if (sql_storage) { linphone_core_set_chat_database_path(marie->lc, marie_db); BC_ASSERT_PTR_NOT_NULL(marie->lc->db); @@ -1430,7 +1432,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo } linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); - + if (sql_storage) { MSList *marie_messages = linphone_chat_room_get_history(marie_chat_room, 0); MSList *pauline_messages = linphone_chat_room_get_history(pauline_chat_room, 0); From a48fa8d01bbf847c544c2943fb3a7ee50fd0c9ad Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 12:34:18 +0200 Subject: [PATCH 062/124] message_tester.c: increase DNS SRV resolution timeout --- tester/message_tester.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tester/message_tester.c b/tester/message_tester.c index bf2d160bd..fb2eede13 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -453,8 +453,10 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneMessageNotDelivered,1, 10000)); belle_http_provider_set_recv_error(marie->lc->http_provider, 0); } else { - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1)); - compare_files(send_filepath, receive_filepath); + /* wait for a long time in case the DNS SRV resolution takes times - it should be immediate though */ + if (BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1,55000))) { + compare_files(send_filepath, receive_filepath); + } } } BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,2, int, "%d"); //sent twice because of file transfer @@ -817,7 +819,7 @@ static void lime_text_message_to_non_lime(void) { char* filepath; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); - + if (!linphone_core_lime_available(marie->lc)) { ms_warning("Lime not available, skiping"); goto end; @@ -857,7 +859,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st marie = linphone_core_manager_new( "marie_rc"); pauline = linphone_core_manager_new( "pauline_tcp_rc"); - + if (!linphone_core_lime_available(marie->lc)) { ms_warning("Lime not available, skiping"); goto end; @@ -1252,7 +1254,7 @@ static void history_range(void){ history_message_count_helper(chatroom, -2, 2, 3); history_message_count_helper(chatroom, -3, 1, 2); } - + end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); @@ -1322,7 +1324,7 @@ static void history_count(void) { BC_ASSERT_EQUAL(ms_list_size(messages), 1270-1265, int, "%d"); ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); } - + end: linphone_core_manager_destroy(marie); linphone_address_destroy(jehan_addr); @@ -1377,7 +1379,7 @@ static void file_transfer_io_error_after_destroying_chatroom(void) { file_transfer_io_error_base("https://www.linphone.org:444/lft.php", TRUE); } -static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, bool_t mess_with_marie_payload_number, bool_t mess_with_pauline_payload_number, +static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, bool_t mess_with_marie_payload_number, bool_t mess_with_pauline_payload_number, bool_t ice_enabled, bool_t sql_storage, bool_t do_not_store_rtt_messages_in_sql_storage) { LinphoneChatRoom *pauline_chat_room; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); @@ -1386,7 +1388,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo LinphoneCall *pauline_call, *marie_call; char *marie_db = bc_tester_file("marie.db"); char *pauline_db = bc_tester_file("pauline.db"); - + if (sql_storage) { linphone_core_set_chat_database_path(marie->lc, marie_db); BC_ASSERT_PTR_NOT_NULL(marie->lc->db); @@ -1463,7 +1465,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo } linphone_chat_room_send_chat_message(pauline_chat_room, rtt_message); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); - + if (sql_storage) { MSList *marie_messages = linphone_chat_room_get_history(marie_chat_room, 0); MSList *pauline_messages = linphone_chat_room_get_history(pauline_chat_room, 0); From e7eda74df980aaa21537a1fc720da579410cb4f6 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 13 Jun 2016 12:38:37 +0200 Subject: [PATCH 063/124] Fix typo --- coreapi/sqlite3_bctbx_vfs.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index 5ca959837..69bad997d 100644 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -302,20 +302,20 @@ sqlite3_vfs *sqlite3_bctbx_vfs_create(void){ } /*static int sqlite3bctbx_winFullPathname( - sqlite3_vfs *pVfs, /* Pointer to vfs object */ - const char *zRelative, /* Possibly relative input path */ - int nFull, /* Size of output buffer in bytes */ + sqlite3_vfs *pVfs, // Pointer to vfs object + const char *zRelative, // Possibly relative input path + int nFull, // Size of output buffer in bytes char *zFull){ //LPWSTR zTemp; //DWORD nByte; - ///* If this path name begins with "/X:", where "X" is any alphabetic - //** character, discard the initial "/" from the pathname. - //*/ + // If this path name begins with "/X:", where "X" is any alphabetic + // character, discard the initial "/" from the pathname. + // //if (zRelative[0] == '/' && sqlite3Isalpha(zRelative[1]) && zRelative[2] == ':'){ // zRelative++; //} - /*nByte = GetFullPathNameW((LPCWSTR)zRelative, 0, 0, 0); + nByte = GetFullPathNameW((LPCWSTR)zRelative, 0, 0, 0); if (nByte == 0){ return SQLITE_CANTOPEN_FULLPATH; } @@ -337,7 +337,7 @@ sqlite3_vfs *sqlite3_bctbx_vfs_create(void){ } else{ return SQLITE_IOERR_NOMEM; - }*\/ + } sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); return SQLITE_OK; }*/ From 311ddd603004af21a00f794c7e2e687e869d3a5d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 13 Jun 2016 14:43:49 +0200 Subject: [PATCH 064/124] Better way to disable VFS --- coreapi/call_log.c | 3 +-- coreapi/friend.c | 3 +-- coreapi/message_storage.c | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/coreapi/call_log.c b/coreapi/call_log.c index 9bbc4c753..1e8a3786c 100644 --- a/coreapi/call_log.c +++ b/coreapi/call_log.c @@ -376,8 +376,7 @@ void linphone_core_call_log_storage_init(LinphoneCore *lc) { linphone_core_call_log_storage_close(lc); - //ret=_linphone_sqlite3_open(lc->logs_db_file, &db); - ret = sqlite3_open(lc->logs_db_file, &db); + ret=_linphone_sqlite3_open(lc->logs_db_file, &db); if(ret != SQLITE_OK) { errmsg = sqlite3_errmsg(db); ms_error("Error in the opening: %s.\n", errmsg); diff --git a/coreapi/friend.c b/coreapi/friend.c index f69314375..2251b370c 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1141,8 +1141,7 @@ void linphone_core_friends_storage_init(LinphoneCore *lc) { linphone_core_friends_storage_close(lc); - //ret = _linphone_sqlite3_open(lc->friends_db_file, &db); - ret = sqlite3_open(lc->friends_db_file, &db); + ret = _linphone_sqlite3_open(lc->friends_db_file, &db); if (ret != SQLITE_OK) { errmsg = sqlite3_errmsg(db); ms_error("Error in the opening: %s.\n", errmsg); diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index dc13d8f27..877a0471e 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -80,7 +80,8 @@ int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) { #endif char *utf8_filename = utf8_convert(db_file); - ret = sqlite3_open_v2(utf8_filename, db, flags, LINPHONE_SQLITE3_VFS); + //ret = sqlite3_open_v2(utf8_filename, db, flags, LINPHONE_SQLITE3_VFS); + ret = sqlite3_open_v2(utf8_filename, db, flags, NULL); // Do not use VFS until all issues are resolved ms_free(utf8_filename); if (ret != SQLITE_OK) return ret; @@ -695,8 +696,7 @@ void linphone_core_message_storage_init(LinphoneCore *lc){ linphone_core_message_storage_close(lc); - //ret=_linphone_sqlite3_open(lc->chat_db_file,&db); - ret = sqlite3_open(lc->chat_db_file,&db); + ret=_linphone_sqlite3_open(lc->chat_db_file,&db); if(ret != SQLITE_OK) { errmsg=sqlite3_errmsg(db); ms_error("Error in the opening: %s.\n", errmsg); From a6a9c36e844e76c5dfec619f9a88dcf650224c5e Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 15:43:28 +0200 Subject: [PATCH 065/124] submodules: update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 06ccea67f..b62029600 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 06ccea67f9f9995da81fe0cf161494ce166c1e00 +Subproject commit b62029600a7c1b3bc8018e774bc90c38ac9fe9ed From e962f84b3607ba5a20df64810fe1782ced23ce87 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Tue, 14 Jun 2016 10:06:16 +0200 Subject: [PATCH 066/124] VFS activation. Using utf8 conversions, meaning converting back to Windows format on Windows with ConvertFromUtf8Filename in sqlite3bctbx_Open. Windows using win32 sqlite VFS methods for everything except open, read, write, close , sync, file control, device characteristics, file size and lock related methods. Some of them are just stubs, refer to source code. --- coreapi/message_storage.c | 12 +-- coreapi/sqlite3_bctbx_vfs.c | 156 ++++++++++++------------------------ 2 files changed, 60 insertions(+), 108 deletions(-) mode change 100644 => 100755 coreapi/sqlite3_bctbx_vfs.c diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 2a549a014..18867674d 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sqlite3.h" #include -#if 0 + static char *utf8_convert(const char *filename){ char db_file_utf8[MAX_PATH_SIZE] = ""; #if defined(_WIN32) @@ -67,7 +67,7 @@ static char *utf8_convert(const char *filename){ #endif return ms_strdup(db_file_utf8); } -#endif + int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) { char* errmsg = NULL; @@ -80,9 +80,11 @@ int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) { flags |= SQLITE_OPEN_FILEPROTECTION_NONE; #endif - /*since we plug our vfs into sqlite, there is no need to convert to UTF-8. - * Indeed, our filesystem wrapper uses the default system encoding*/ - ret = sqlite3_open_v2(db_file, db, flags, LINPHONE_SQLITE3_VFS); + /*since we plug our vfs into sqlite, we convert to UTF-8. + * On Windows, the filename has to be converted back to windows native charset.*/ + char *utf8_filename = utf8_convert(db_file); + ret = sqlite3_open_v2(utf8_filename, db, flags, LINPHONE_SQLITE3_VFS); + ms_free(utf8_filename); if (ret != SQLITE_OK) return ret; // Some platforms do not provide a way to create temporary files which are needed diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c old mode 100644 new mode 100755 index 5e48e2736..205c40ff2 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -220,6 +220,47 @@ static int sqlite3bctbx_Sync(sqlite3_file *p, int flags){ /************************ END OF PLACE HOLDER FUNCTIONS ***********************/ + +#if _WIN32 +static char* ConvertFromUtf8Filename(const char* fName){ + void *zConverted = 0; + char* zFilename; + int nChar, nByte; + LPWSTR zWideFilename; + + nChar = MultiByteToWideChar(CP_UTF8, 0, fName, -1, NULL, 0); + if (nChar == 0){ + return BCTBX_VFS_ERROR; + } + zWideFilename = bctbx_malloc(nChar*sizeof(zWideFilename[0])); + if (zWideFilename == 0){ + return 0; + } + nChar = MultiByteToWideChar(CP_UTF8, 0, fName, -1, zWideFilename, + nChar); + if (nChar == 0){ + bctbx_free(zWideFilename); + zWideFilename = 0; + } + + nByte = WideCharToMultiByte(CP_ACP, 0, zWideFilename, -1, 0, 0, 0, 0); + if (nByte == 0){ + return 0; + } + zFilename = bctbx_malloc(nByte); + if (zFilename == 0){ + return 0; + } + nByte = WideCharToMultiByte(CP_ACP, 0, zWideFilename, -1, zFilename, + nByte, 0, 0); + if (nByte == 0){ + bctbx_free(zFilename); + zFilename = 0; + } + return zFilename; + +} +#endif /** * Opens the file fName and populates the structure pointed by p * with the necessary io_methods @@ -251,21 +292,27 @@ static int sqlite3bctbx_Open(sqlite3_vfs *pVfs, const char *fName, sqlite3_file }; sqlite3_bctbx_file_t * pFile = (sqlite3_bctbx_file_t*)p; /*File handle sqlite3_bctbx_file_t*/ - int openFlags = 0; + const char* wFname; /*returns error if filename is empty or file handle not initialized*/ if (pFile == NULL || fName == NULL){ return SQLITE_IOERR; } - /* Set flags to open the file with */ if( flags&SQLITE_OPEN_EXCLUSIVE ) openFlags |= O_EXCL; if( flags&SQLITE_OPEN_CREATE ) openFlags |= O_CREAT; if( flags&SQLITE_OPEN_READONLY ) openFlags |= O_RDONLY; if( flags&SQLITE_OPEN_READWRITE ) openFlags |= O_RDWR; - pFile->pbctbx_file = bctbx_file_open2(bctbx_vfs_get_default(), fName, openFlags); +#if defined(_WIN32) + openFlags |= O_BINARY; + wFname = ConvertFromUtf8Filename(fName); +#else + wFname = fName; +#endif + pFile->pbctbx_file = bctbx_file_open2(bctbx_vfs_get_default(), wFname, openFlags); + if( pFile->pbctbx_file == NULL){ return SQLITE_CANTOPEN; } @@ -302,102 +349,9 @@ sqlite3_vfs *sqlite3_bctbx_vfs_create(void){ }; return &bctbx_vfs; } -#if _WIN32 -static int sqlite3bctbx_winAccess( - sqlite3_vfs *pVfs, /* Not used on win32 */ - const char *zFilename, /* Name of file to check */ - int flags, /* Type of test to make on this file */ - int *pResOut /* OUT: Result */ -){ - DWORD attr; - int rc = 0; - - - //SimulateIOError(return SQLITE_IOERR_ACCESS;); - int cnt = 0; - WIN32_FILE_ATTRIBUTE_DATA sAttrData; - memset(&sAttrData, 0, sizeof(sAttrData)); - rc = GetFileAttributesExW((LPCWSTR)zFilename, - GetFileExInfoStandard, - &sAttrData); - - if (rc){ - /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file - ** as if it does not exist. - */ - if (flags == SQLITE_ACCESS_EXISTS - && sAttrData.nFileSizeHigh == 0 - && sAttrData.nFileSizeLow == 0){ - attr = INVALID_FILE_ATTRIBUTES; - } - else{ - attr = sAttrData.dwFileAttributes; - } - } - else{ - attr = INVALID_FILE_ATTRIBUTES; - } - - switch (flags){ - case SQLITE_ACCESS_READ: - case SQLITE_ACCESS_EXISTS: - rc = attr != INVALID_FILE_ATTRIBUTES; - break; - case SQLITE_ACCESS_READWRITE: - rc = attr != INVALID_FILE_ATTRIBUTES && - (attr & FILE_ATTRIBUTE_READONLY) == 0; - break; - default: - break; - //assert(!"Invalid flags argument"); - - } - *pResOut = rc; - return SQLITE_OK; -} -static int sqlite3bctbx_winFullPathname( - sqlite3_vfs *pVfs, /* Pointer to vfs object */ - const char *zRelative, /* Possibly relative input path */ - int nFull, /* Size of output buffer in bytes */ - char *zFull){ - //LPWSTR zTemp; - //DWORD nByte; - ///* If this path name begins with "/X:", where "X" is any alphabetic - //** character, discard the initial "/" from the pathname. - //*/ - //if (zRelative[0] == '/' && sqlite3Isalpha(zRelative[1]) && zRelative[2] == ':'){ - // zRelative++; - //} - - /*nByte = GetFullPathNameW((LPCWSTR)zRelative, 0, 0, 0); - if (nByte == 0){ - return SQLITE_CANTOPEN_FULLPATH; - } - nByte += 3; - zTemp = bctbx_malloc(nByte*sizeof(zTemp[0])); - memset(zTemp, 0, nByte*sizeof(zTemp[0])); - if (zTemp == 0){ - return SQLITE_IOERR_NOMEM; - } - nByte = GetFullPathNameW((LPCWSTR)zRelative, nByte, zTemp, 0); - if (nByte == 0){ - bctbx_free(zTemp); - return SQLITE_CANTOPEN_FULLPATH; - } - if (zTemp){ - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zTemp); - bctbx_free(zTemp); - return SQLITE_OK; - } - else{ - return SQLITE_IOERR_NOMEM; - }*/ - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); - return SQLITE_OK; -} -#endif + void sqlite3_bctbx_vfs_register( int makeDefault){ sqlite3_vfs* pVfsToUse = sqlite3_bctbx_vfs_create(); @@ -407,14 +361,10 @@ void sqlite3_bctbx_vfs_register( int makeDefault){ sqlite3_vfs* pDefault = sqlite3_vfs_find("unix-none"); #endif pVfsToUse->xCurrentTime = pDefault->xCurrentTime; - -#if _WIN32 - pVfsToUse->xFullPathname = sqlite3bctbx_winFullPathname; - pVfsToUse->xAccess = sqlite3bctbx_winAccess; -#else + pVfsToUse->xAccess = pDefault->xAccess; pVfsToUse->xFullPathname = pDefault->xFullPathname; -#endif + pVfsToUse->xDelete = pDefault->xDelete; pVfsToUse->xSleep = pDefault->xSleep; pVfsToUse->xRandomness = pDefault->xRandomness; From 54767c23cc990b9aa65238ae3d295d93a8bf65d1 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 14 Jun 2016 10:34:59 +0200 Subject: [PATCH 067/124] submodules: update ms2 to add HD support to newest devices --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index b62029600..5819fe0a2 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit b62029600a7c1b3bc8018e774bc90c38ac9fe9ed +Subproject commit 5819fe0a243d88d152703a88d6ba04cf8e77b424 From 71125c17d51acd5dc180d25aaff565e80d708e59 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 14 Jun 2016 11:10:00 +0200 Subject: [PATCH 068/124] Replace old MSG_STORAGE_ENABLED and CALL_LOGS_STORAGE_ENABLED by SQL_STORAGE_ENABLED --- tester/call_tester.c | 4 ++-- tester/message_tester.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tester/call_tester.c b/tester/call_tester.c index f0f44eb02..d3601279d 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -5994,7 +5994,7 @@ end: } -#ifdef CALL_LOGS_STORAGE_ENABLED +#ifdef SQLITE_STORAGE_ENABLED static void call_logs_if_no_db_set(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); @@ -6615,7 +6615,7 @@ test_t call_tests[] = { TEST_NO_TAG("Call with RTP IO mode", call_with_rtp_io_mode), TEST_NO_TAG("Call with generic NACK RTCP feedback", call_with_generic_nack_rtcp_feedback), TEST_NO_TAG("Call with complex late offering", call_with_complex_late_offering), -#ifdef CALL_LOGS_STORAGE_ENABLED +#ifdef SQLITE_STORAGE_ENABLED TEST_NO_TAG("Call log working if no db set", call_logs_if_no_db_set), TEST_NO_TAG("Call log storage migration from rc to db", call_logs_migrate), TEST_NO_TAG("Call log storage in sqlite database", call_logs_sqlite_storage), diff --git a/tester/message_tester.c b/tester/message_tester.c index bb10f038f..984f0dfab 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -23,7 +23,7 @@ #include "liblinphone_tester.h" #include "lime.h" -#ifdef MSG_STORAGE_ENABLED +#ifdef SQLITE_STORAGE_ENABLED #include #endif @@ -1094,7 +1094,7 @@ static void lime_unit(void) { #endif /* HAVE_LIME */ -#ifdef MSG_STORAGE_ENABLED +#ifdef SQLITE_STORAGE_ENABLED /* * Copy file "from" to file "to". @@ -1800,7 +1800,7 @@ test_t message_tests[] = { TEST_NO_TAG("Lime transfer message without encryption", lime_transfer_message_without_encryption), TEST_NO_TAG("Lime unitary", lime_unit), #endif /* HAVE_LIME */ -#ifdef MSG_STORAGE_ENABLED +#ifdef SQLITE_STORAGE_ENABLED TEST_NO_TAG("Database migration", database_migration), TEST_NO_TAG("History range", history_range), TEST_NO_TAG("History count", history_count), From 5aa18ce2f9f814a41799e10b666c1d39afa2c2e8 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 14 Jun 2016 11:10:00 +0200 Subject: [PATCH 069/124] Replace old MSG_STORAGE_ENABLED and CALL_LOGS_STORAGE_ENABLED by SQL_STORAGE_ENABLED --- tester/call_tester.c | 4 ++-- tester/message_tester.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tester/call_tester.c b/tester/call_tester.c index a749cc19f..842f9e0ff 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -5994,7 +5994,7 @@ end: } -#ifdef CALL_LOGS_STORAGE_ENABLED +#ifdef SQLITE_STORAGE_ENABLED static void call_logs_if_no_db_set(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); @@ -6630,7 +6630,7 @@ test_t call_tests[] = { TEST_NO_TAG("Call with RTP IO mode", call_with_rtp_io_mode), TEST_NO_TAG("Call with generic NACK RTCP feedback", call_with_generic_nack_rtcp_feedback), TEST_NO_TAG("Call with complex late offering", call_with_complex_late_offering), -#ifdef CALL_LOGS_STORAGE_ENABLED +#ifdef SQLITE_STORAGE_ENABLED TEST_NO_TAG("Call log working if no db set", call_logs_if_no_db_set), TEST_NO_TAG("Call log storage migration from rc to db", call_logs_migrate), TEST_NO_TAG("Call log storage in sqlite database", call_logs_sqlite_storage), diff --git a/tester/message_tester.c b/tester/message_tester.c index fb2eede13..82d49378a 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -23,7 +23,7 @@ #include "liblinphone_tester.h" #include "lime.h" -#ifdef MSG_STORAGE_ENABLED +#ifdef SQLITE_STORAGE_ENABLED #include #endif @@ -1129,7 +1129,6 @@ static void lime_unit(void) { #endif /* HAVE_LIME */ - /* * Copy file "from" to file "to". * Destination file is truncated if existing. From 64ca9e82e581ea8f947e69274109a50ff902782c Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 14 Jun 2016 11:44:43 +0200 Subject: [PATCH 070/124] Improved import friends from vcards feature + set bctoolbox logger in linphone tester --- coreapi/friendlist.c | 42 +++++++++++++++++++++++-------------- tester/liblinphone_tester.c | 3 +++ tester/vcard_tester.c | 2 +- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index d48283d9b..9aeeff24a 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -768,24 +768,28 @@ LinphoneCore* linphone_friend_list_get_core(LinphoneFriendList *list) { } int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *list, const char *vcard_file) { - MSList *vcards = linphone_vcard_list_from_vcard4_file(vcard_file); + MSList *vcards = NULL; + MSList *vcards_iterator = NULL; int count = 0; #ifndef VCARD_ENABLED ms_error("vCard support wasn't enabled at compilation time"); return -1; #endif - if (!vcards) { - ms_error("Failed to parse the file %s", vcard_file); - return -1; - } if (!list) { ms_error("Can't import into a NULL list"); return -1; } + + vcards = linphone_vcard_list_from_vcard4_file(vcard_file); + vcards_iterator = vcards; + if (!vcards) { + ms_error("Failed to parse the file %s", vcard_file); + return -1; + } - while (vcards != NULL && vcards->data != NULL) { - LinphoneVcard *vcard = (LinphoneVcard *)vcards->data; + while (vcards_iterator != NULL && vcards_iterator->data != NULL) { + LinphoneVcard *vcard = (LinphoneVcard *)vcards_iterator->data; LinphoneFriend *lf = linphone_friend_new_from_vcard(vcard); if (lf) { if (LinphoneFriendListOK == linphone_friend_list_import_friend(list, lf, TRUE)) { @@ -795,31 +799,36 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis } else { linphone_vcard_free(vcard); } - vcards = ms_list_next(vcards); + vcards_iterator = ms_list_next(vcards_iterator); } + ms_list_free(vcards); linphone_core_store_friends_list_in_db(list->lc, list); return count; } int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *list, const char *vcard_buffer) { - MSList *vcards = linphone_vcard_list_from_vcard4_buffer(vcard_buffer); + MSList *vcards = NULL; + MSList *vcards_iterator = NULL; int count = 0; #ifndef VCARD_ENABLED ms_error("vCard support wasn't enabled at compilation time"); return -1; #endif - if (!vcards) { - ms_error("Failed to parse the buffer"); - return -1; - } if (!list) { ms_error("Can't import into a NULL list"); return -1; } + + vcards = linphone_vcard_list_from_vcard4_buffer(vcard_buffer); + vcards_iterator = vcards; + if (!vcards) { + ms_error("Failed to parse the buffer"); + return -1; + } - while (vcards != NULL && vcards->data != NULL) { - LinphoneVcard *vcard = (LinphoneVcard *)vcards->data; + while (vcards_iterator != NULL && vcards_iterator->data != NULL) { + LinphoneVcard *vcard = (LinphoneVcard *)vcards_iterator->data; LinphoneFriend *lf = linphone_friend_new_from_vcard(vcard); if (lf) { if (LinphoneFriendListOK == linphone_friend_list_import_friend(list, lf, TRUE)) { @@ -829,8 +838,9 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l } else { linphone_vcard_free(vcard); } - vcards = ms_list_next(vcards); + vcards_iterator = ms_list_next(vcards_iterator); } + ms_list_free(vcards); linphone_core_store_friends_list_in_db(list->lc, list); return count; } diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 927ac8303..185f814e6 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -176,6 +176,7 @@ int liblinphone_tester_set_log_file(const char *filename) { return -1; } ms_message("Redirecting traces to file [%s]", filename); + bctbx_set_log_file(log_file); ortp_set_log_file(log_file); return 0; } @@ -212,8 +213,10 @@ int main (int argc, char *argv[]) for(i = 1; i < argc; ++i) { if (strcmp(argv[i], "--verbose") == 0) { + bctbx_set_log_level(NULL, BCTBX_LOG_MESSAGE); linphone_core_set_log_level(ORTP_MESSAGE); } else if (strcmp(argv[i], "--silent") == 0) { + bctbx_set_log_level(NULL, BCTBX_LOG_FATAL); linphone_core_set_log_level(ORTP_FATAL); } else if (strcmp(argv[i],"--log-file")==0){ CHECK_ARG("--log-file", ++i, argc); diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 9ea80266f..bbe135e77 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -35,7 +35,7 @@ static void linphone_vcard_import_export_friends_test(void) { char *export_filepath = bc_tester_file("export_vcards.vcf"); int count = 0; BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d"); - + count = linphone_friend_list_import_friends_from_vcard4_file(lfl, import_filepath); BC_ASSERT_EQUAL(count, 3, int, "%d"); friends = linphone_friend_list_get_friends(lfl); From 4acb65212a57e4f496cf6d189e7fcfbd33877b5e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 14 Jun 2016 12:23:20 +0200 Subject: [PATCH 071/124] Moved bctoolbox set_log_level from tester to liblinphone --- coreapi/linphonecore.c | 1 + tester/liblinphone_tester.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index a047b7471..5c7b4f846 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -209,6 +209,7 @@ void linphone_core_set_log_level(OrtpLogLevel loglevel) { void linphone_core_set_log_level_mask(OrtpLogLevel loglevel) { ortp_set_log_level_mask(NULL, loglevel); + bctbx_set_log_level_mask(NULL, loglevel); if (loglevel == 0) { sal_disable_log(); } else { diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 185f814e6..686055a70 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -213,10 +213,8 @@ int main (int argc, char *argv[]) for(i = 1; i < argc; ++i) { if (strcmp(argv[i], "--verbose") == 0) { - bctbx_set_log_level(NULL, BCTBX_LOG_MESSAGE); linphone_core_set_log_level(ORTP_MESSAGE); } else if (strcmp(argv[i], "--silent") == 0) { - bctbx_set_log_level(NULL, BCTBX_LOG_FATAL); linphone_core_set_log_level(ORTP_FATAL); } else if (strcmp(argv[i],"--log-file")==0){ CHECK_ARG("--log-file", ++i, argc); From cb0baf724fc6ecde6981cb4f31897ae08675ae61 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 14 Jun 2016 12:30:17 +0200 Subject: [PATCH 072/124] Update ortp and ms2 submodules. --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 964c47cf9..1f7339920 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 964c47cf9c0935395493f6f10841e5a8b4eea068 +Subproject commit 1f7339920c9156b4f05ef34b5d83a79891f6f142 diff --git a/oRTP b/oRTP index 469444ddc..d134dae12 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 469444ddc6c3bdf1312d33e2678f1ee99c7e9939 +Subproject commit d134dae12ec433142ab5266e22f3bb7db91f624f From 16444fbc3e9cafd340123aa4b8ba4f680eb3a4a3 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 14 Jun 2016 12:30:28 +0200 Subject: [PATCH 073/124] Install pdb file on Windows when building in RelWithDebInfo. --- coreapi/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index ea97ad5f3..b2653469e 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -238,8 +238,8 @@ if(ENABLE_SHARED) add_dependencies(linphone linphonecore-jni-header) endif() if(MSVC) - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/linphone.pdb + if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/linphone.pdb DESTINATION ${CMAKE_INSTALL_BINDIR} PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) From 1ff3d2d1578fe53f2c20931d91cd252650c88748 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 14 Jun 2016 13:36:27 +0200 Subject: [PATCH 074/124] Added bctbx log handler for android --- tester/liblinphone_tester.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index 686055a70..e16c78301 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -82,6 +82,19 @@ static void liblinphone_android_ortp_log_handler(const char *domain, OrtpLogLeve liblinphone_android_log_handler(prio, fmt, args); } +static void liblinphone_android_bctbx_log_handler(const char *domain, BctbxLogLevel lev, const char *fmt, va_list args) { + int prio; + switch(lev){ + case BCTBX_LOG_DEBUG: prio = ANDROID_LOG_DEBUG; break; + case BCTBX_LOG_MESSAGE: prio = ANDROID_LOG_INFO; break; + case BCTBX_LOG_WARNING: prio = ANDROID_LOG_WARN; break; + case BCTBX_LOG_ERROR: prio = ANDROID_LOG_ERROR; break; + case BCTBX_LOG_FATAL: prio = ANDROID_LOG_FATAL; break; + default: prio = ANDROID_LOG_DEFAULT; break; + } + liblinphone_android_log_handler(prio, fmt, args); +} + void cunit_android_trace_handler(int level, const char *fmt, va_list args) { char buffer[CALLBACK_BUFFER_SIZE]; jstring javaString; @@ -158,6 +171,7 @@ void liblinphone_tester_init(void(*ftester_printf)(int level, const char *fmt, v if (! log_file) { #if defined(ANDROID) linphone_core_set_log_handler(liblinphone_android_ortp_log_handler); + bctbx_set_log_handler(liblinphone_android_bctbx_log_handler); #endif } From e047dcf829d2947c1a5a43568f5a1dba679a9799 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 14 Jun 2016 15:41:29 +0200 Subject: [PATCH 075/124] Improved vcard import/export code a bit --- coreapi/vcard.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/coreapi/vcard.cc b/coreapi/vcard.cc index 4dea0875e..16fb04191 100644 --- a/coreapi/vcard.cc +++ b/coreapi/vcard.cc @@ -40,6 +40,12 @@ LinphoneVcard* linphone_vcard_new(void) { return vCard; } +static LinphoneVcard* linphone_vcard_new_from_belcard(shared_ptr belcard) { + LinphoneVcard* vCard = (LinphoneVcard*) ms_new0(LinphoneVcard, 1); + vCard->belCard = belcard; + return vCard; +} + void linphone_vcard_free(LinphoneVcard *vCard) { if (!vCard) return; @@ -49,14 +55,13 @@ void linphone_vcard_free(LinphoneVcard *vCard) { MSList* linphone_vcard_list_from_vcard4_file(const char *filename) { MSList *result = NULL; - if (filename && ortp_file_exist(filename) == 0) { + if (filename) { belcard::BelCardParser parser = belcard::BelCardParser::getInstance(); shared_ptr belCards = parser.parseFile(filename); if (belCards) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { - shared_ptr belcard = (*it); - LinphoneVcard *vCard = linphone_vcard_new(); - vCard->belCard = belcard; + shared_ptr belCard = (*it); + LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard); result = ms_list_append(result, vCard); } } @@ -72,8 +77,7 @@ MSList* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { if (belCards) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { shared_ptr belCard = (*it); - LinphoneVcard *vCard = linphone_vcard_new(); - vCard->belCard = belCard; + LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard); result = ms_list_append(result, vCard); } } @@ -87,8 +91,7 @@ LinphoneVcard* linphone_vcard_new_from_vcard4_buffer(const char *buffer) { belcard::BelCardParser parser = belcard::BelCardParser::getInstance(); shared_ptr belCard = parser.parseOne(buffer); if (belCard) { - vCard = linphone_vcard_new(); - vCard->belCard = belCard; + vCard = linphone_vcard_new_from_belcard(belCard); } else { ms_error("Couldn't parse buffer %s", buffer); } From 11b98c90f3b41c60c25361325d6e11814c606729 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 14 Jun 2016 16:54:17 +0200 Subject: [PATCH 076/124] Get HANDLE from fd for sqlite sync on Windows. --- coreapi/sqlite3_bctbx_vfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index 205c40ff2..2fe847045 100755 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -210,7 +210,7 @@ static int sqlite3bctbx_Sync(sqlite3_file *p, int flags){ sqlite3_bctbx_file_t *pFile = (sqlite3_bctbx_file_t*)p; #if _WIN32 int ret; - ret = FlushFileBuffers(pFile->pbctbx_file->h); + ret = FlushFileBuffers((HANDLE)_get_osfhandle(pFile->pbctbx_file->fd)); return (ret!=0 ? SQLITE_OK : SQLITE_IOERR_FSYNC); #else int rc = fsync(pFile->pbctbx_file->fd); From ab5a15124a063a94c2fc8f7da04cb2f6e30d8370 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Tue, 14 Jun 2016 17:15:23 +0200 Subject: [PATCH 077/124] VFS - ConvertFromUtf8 extended to all platforms. --- coreapi/sqlite3_bctbx_vfs.c | 98 ++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 35 deletions(-) diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index 2fe847045..2796be7e9 100755 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -28,6 +28,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif /*_WIN32_WCE*/ +#ifndef _WIN32 +#if !defined(__QNXNTO__) +# include +# include +# include +# include +#endif + +#endif + /** * Closes the file whose file descriptor is stored in the file handle p. @@ -221,43 +231,64 @@ static int sqlite3bctbx_Sync(sqlite3_file *p, int flags){ /************************ END OF PLACE HOLDER FUNCTIONS ***********************/ -#if _WIN32 -static char* ConvertFromUtf8Filename(const char* fName){ - void *zConverted = 0; - char* zFilename; - int nChar, nByte; - LPWSTR zWideFilename; +static char* ConvertFromUtf8Filename(const char* fName){ +#if _WIN32 + char* convertedFilename; + int nChar, nb_byte; + LPWSTR wideFilename; + nChar = MultiByteToWideChar(CP_UTF8, 0, fName, -1, NULL, 0); if (nChar == 0){ return BCTBX_VFS_ERROR; } - zWideFilename = bctbx_malloc(nChar*sizeof(zWideFilename[0])); - if (zWideFilename == 0){ + wideFilename = bctbx_malloc(nChar*sizeof(wideFilename[0])); + if (wideFilename == 0){ return 0; } - nChar = MultiByteToWideChar(CP_UTF8, 0, fName, -1, zWideFilename, - nChar); + nChar = MultiByteToWideChar(CP_UTF8, 0, fName, -1, wideFilename, + nChar); if (nChar == 0){ - bctbx_free(zWideFilename); - zWideFilename = 0; + bctbx_free(wideFilename); + wideFilename = 0; } + + nb_byte = WideCharToMultiByte(CP_ACP, 0, wideFilename, -1, 0, 0, 0, 0); + if (nb_byte == 0){ + return 0; + } + convertedFilename = bctbx_malloc(nb_byte); + if (convertedFilename == 0){ + return 0; + } + nb_byte = WideCharToMultiByte(CP_ACP, 0, wideFilename, -1, convertedFilename, + nb_byte, 0, 0); + if (nb_byte == 0){ + bctbx_free(convertedFilename); + convertedFilename = 0; + } + bctbx_free(wideFilename); + return convertedFilename; +#else + #define MAX_PATH_SIZE 1024 + char db_file_utf8[MAX_PATH_SIZE] = {'\0'}; + char db_file_locale[MAX_PATH_SIZE] = ""; + char *outbuf=db_file_locale, *inbuf=db_file_utf8; + size_t inbyteleft = MAX_PATH_SIZE, outbyteleft = MAX_PATH_SIZE; + iconv_t cb; + + strncpy(db_file_utf8, fName, MAX_PATH_SIZE-1); + cb = iconv_open(nl_langinfo(CODESET), "UTF-8"); + if(cb != (iconv_t)-1) { + int ret; + ret = iconv(cb, &inbuf, &inbyteleft, &outbuf, &outbyteleft); + if(ret == -1) db_file_locale[0] = '\0'; + iconv_close(cb); + } + return bctbx_strdup(db_file_locale); + +#endif - nByte = WideCharToMultiByte(CP_ACP, 0, zWideFilename, -1, 0, 0, 0, 0); - if (nByte == 0){ - return 0; - } - zFilename = bctbx_malloc(nByte); - if (zFilename == 0){ - return 0; - } - nByte = WideCharToMultiByte(CP_ACP, 0, zWideFilename, -1, zFilename, - nByte, 0, 0); - if (nByte == 0){ - bctbx_free(zFilename); - zFilename = 0; - } - return zFilename; } #endif @@ -293,12 +324,13 @@ static int sqlite3bctbx_Open(sqlite3_vfs *pVfs, const char *fName, sqlite3_file sqlite3_bctbx_file_t * pFile = (sqlite3_bctbx_file_t*)p; /*File handle sqlite3_bctbx_file_t*/ int openFlags = 0; - const char* wFname; + char* wFname; /*returns error if filename is empty or file handle not initialized*/ if (pFile == NULL || fName == NULL){ return SQLITE_IOERR; } + /* Set flags to open the file with */ if( flags&SQLITE_OPEN_EXCLUSIVE ) openFlags |= O_EXCL; if( flags&SQLITE_OPEN_CREATE ) openFlags |= O_CREAT; @@ -307,12 +339,11 @@ static int sqlite3bctbx_Open(sqlite3_vfs *pVfs, const char *fName, sqlite3_file #if defined(_WIN32) openFlags |= O_BINARY; - wFname = ConvertFromUtf8Filename(fName); -#else - wFname = fName; #endif + wFname = ConvertFromUtf8Filename(fName); pFile->pbctbx_file = bctbx_file_open2(bctbx_vfs_get_default(), wFname, openFlags); - + bctbx_free(wFname); + if( pFile->pbctbx_file == NULL){ return SQLITE_CANTOPEN; } @@ -390,6 +421,3 @@ void sqlite3_bctbx_vfs_unregister(void) sqlite3_vfs_unregister(pVfs); } -#endif - - From a93e4cc4e4ba28e984d55d595d16af372611025a Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 15 Jun 2016 10:35:17 +0200 Subject: [PATCH 078/124] mk-ca-bundle.pl: die if no certs have been processed (currently happening due to mozilla website maintenance) --- scripts/mk-ca-bundle.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/mk-ca-bundle.pl b/scripts/mk-ca-bundle.pl index 283ebd13c..b397b2541 100755 --- a/scripts/mk-ca-bundle.pl +++ b/scripts/mk-ca-bundle.pl @@ -222,6 +222,11 @@ while () { } close(TXT) or die "Couldn't close $txt: $!\n"; close(CRT) or die "Couldn't close $crt.~: $!\n"; + +# this may happen if website is in maintenance - 200 OK is returned but it returns +# a HTML maintenance page instead of expected file +die "No certs processed (invalid input file?)!" if ($certnum == 0 and $skipnum == 0); + unless( $stdout ) { if ($opt_b && -e $crt) { my $bk = 1; From 0a44f21adfe499f8c3bba37f10eb7350745a44ee Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 15 Jun 2016 10:35:17 +0200 Subject: [PATCH 079/124] mk-ca-bundle.pl: die if no certs have been processed (currently happening due to mozilla website maintenance) --- scripts/mk-ca-bundle.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/mk-ca-bundle.pl b/scripts/mk-ca-bundle.pl index 283ebd13c..b397b2541 100755 --- a/scripts/mk-ca-bundle.pl +++ b/scripts/mk-ca-bundle.pl @@ -222,6 +222,11 @@ while () { } close(TXT) or die "Couldn't close $txt: $!\n"; close(CRT) or die "Couldn't close $crt.~: $!\n"; + +# this may happen if website is in maintenance - 200 OK is returned but it returns +# a HTML maintenance page instead of expected file +die "No certs processed (invalid input file?)!" if ($certnum == 0 and $skipnum == 0); + unless( $stdout ) { if ($opt_b && -e $crt) { my $bk = 1; From 68e470907cd78fbb265f942fe52bc1d094e60b60 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 14 Jun 2016 14:00:10 +0200 Subject: [PATCH 080/124] implement late ICE activation, add test for it. Application needs to set [net] allow_late_ice=1 --- coreapi/linphonecall.c | 18 ++++++++---- coreapi/linphonecore.c | 24 ++++++++++++---- coreapi/nat_policy.c | 1 + coreapi/private.h | 2 ++ tester/call_tester.c | 65 +++++++++++++++++++++++++++++++++++++++++- tester/tester.c | 2 +- 6 files changed, 98 insertions(+), 14 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 5c6480244..f6da6e656 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1113,7 +1113,15 @@ void linphone_call_fill_media_multicast_addr(LinphoneCall *call) { call->media_ports[call->main_video_stream_index].multicast_ip[0]='\0'; } -static void linphone_call_create_ice_session(LinphoneCall *call, IceRole role){ +void linphone_call_check_ice_session(LinphoneCall *call, IceRole role, bool_t is_reinvite){ + if (call->ice_session) return; /*already created*/ + + if (!linphone_nat_policy_ice_enabled(linphone_core_get_nat_policy(call->core))){ + return; + } + + if (is_reinvite && lp_config_get_int(call->core->config, "net", "allow_late_ice", 0) == 0) return; + call->ice_session = ice_session_new(); /*for backward compatibility purposes, shall be enabled by default in futur*/ ice_session_enable_message_integrity_check(call->ice_session,lp_config_get_int(call->core->config,"net","ice_session_enable_message_integrity_check",1)); @@ -1124,7 +1132,6 @@ static void linphone_call_create_ice_session(LinphoneCall *call, IceRole role){ types[2] = ICT_CandidateInvalid; ice_session_set_default_candidates_types(call->ice_session, types); } - ice_session_set_role(call->ice_session, role); } @@ -1142,9 +1149,8 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr linphone_call_fill_media_multicast_addr(call); - if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseIce) { - linphone_call_create_ice_session(call, IR_Controlling); - } + linphone_call_check_ice_session(call, IR_Controlling, FALSE); + if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseStun) { call->ping_time=linphone_core_run_stun_tests(call->core,call); } @@ -1393,7 +1399,7 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro if ((nat_policy != NULL) && linphone_nat_policy_ice_enabled(nat_policy)) { /* Create the ice session now if ICE is required */ if (md){ - linphone_call_create_ice_session(call, IR_Controlled); + linphone_call_check_ice_session(call, IR_Controlled, FALSE); }else{ nat_policy = NULL; ms_warning("ICE not supported for incoming INVITE without SDP."); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 5c7b4f846..e7a7274f3 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3615,6 +3615,8 @@ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const Linpho ms_error("linphone_core_update_call() is not allowed in [%s] state",linphone_call_state_to_string(call->state)); return -1; } + + linphone_call_check_ice_session(call, IR_Controlling, TRUE); if (params!=NULL){ call->broken = FALSE; @@ -3798,11 +3800,10 @@ int _linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, cons /*update multicast params according to call params*/ linphone_call_fill_media_multicast_addr(call); + linphone_call_check_ice_session(call, IR_Controlled, TRUE); linphone_call_init_media_streams(call); /*so that video stream is initialized if necessary*/ - if (call->ice_session != NULL) { - if (linphone_call_prepare_ice(call,TRUE)==1) - return 0;/*deferred to completion of ICE gathering*/ - } + if (linphone_call_prepare_ice(call,TRUE)==1) + return 0;/*deferred to completion of ICE gathering*/ #ifdef BUILD_UPNP if(call->upnp_session != NULL) { @@ -5281,8 +5282,19 @@ LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc) void linphone_core_set_nat_policy(LinphoneCore *lc, LinphoneNatPolicy *policy) { if (policy != NULL) policy = linphone_nat_policy_ref(policy); /* Prevent object destruction if the same policy is used */ - if (lc->nat_policy != NULL) linphone_nat_policy_unref(lc->nat_policy); - if (policy != NULL) lc->nat_policy = policy; + else{ + ms_error("linphone_core_set_nat_policy() setting to NULL is not allowed"); + return ; + } + if (lc->nat_policy != NULL) { + linphone_nat_policy_unref(lc->nat_policy); + lc->nat_policy = NULL; + } + if (policy != NULL){ + lc->nat_policy = policy; + /*start an immediate (but asynchronous) resolution.*/ + linphone_nat_policy_resolve_stun_server(policy); + } #ifdef BUILD_UPNP linphone_core_enable_keep_alive(lc, (lc->sip_conf.keepalive_period > 0)); diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 5df7e3c24..c41bd96e5 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -40,6 +40,7 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) { if (policy->stun_server) belle_sip_free(policy->stun_server); if (policy->stun_server_username) belle_sip_free(policy->stun_server_username); if (policy->stun_addrinfo) bctbx_freeaddrinfo(policy->stun_addrinfo); + //if (policy->stun_resolver_context) sal_resolve_cancel(policy->stun_resolver_context); } static bool_t linphone_nat_policy_stun_server_activated(LinphoneNatPolicy *policy) { diff --git a/coreapi/private.h b/coreapi/private.h index ddc3d60d1..7351cfbc5 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1552,6 +1552,8 @@ char *linphone_presence_model_to_xml(LinphonePresenceModel *model) ; #define LINPHONE_SQLITE3_VFS "sqlite3bctbx_vfs" +void linphone_call_check_ice_session(LinphoneCall *call, IceRole role, bool_t is_reinvite); + #ifdef __cplusplus } #endif diff --git a/tester/call_tester.c b/tester/call_tester.c index d3601279d..c48dd5f85 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -1304,7 +1304,7 @@ static void call_with_ice_no_sdp(void){ linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); - call(pauline,marie); + BC_ASSERT_TRUE(call(pauline,marie)); liblinphone_tester_check_rtcp(marie,pauline); @@ -1329,6 +1329,55 @@ static void not_ice_to_ice(void){ _call_with_ice(FALSE,TRUE,FALSE,FALSE); } +static void ice_added_by_reinvite(void){ + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneNatPolicy *pol; + LinphoneCallParams *params; + LinphoneCall *c; + bool_t call_ok; + + lp_config_set_int(linphone_core_get_config(marie->lc), "net", "allow_late_ice", 1); + lp_config_set_int(linphone_core_get_config(pauline->lc), "net", "allow_late_ice", 1); + + BC_ASSERT_TRUE((call_ok=call(pauline,marie))); + if (!call_ok) goto end; + liblinphone_tester_check_rtcp(marie,pauline); + + /*enable ICE on both ends*/ + pol = linphone_core_get_nat_policy(marie->lc); + linphone_nat_policy_enable_ice(pol, TRUE); + linphone_nat_policy_enable_stun(pol, TRUE); + linphone_core_set_nat_policy(marie->lc, pol); + + pol = linphone_core_get_nat_policy(pauline->lc); + linphone_nat_policy_enable_ice(pol, TRUE); + linphone_nat_policy_enable_stun(pol, TRUE); + linphone_core_set_nat_policy(pauline->lc, pol); + + c = linphone_core_get_current_call(marie->lc); + params = linphone_core_create_call_params(marie->lc, c); + linphone_core_update_call(marie->lc, c, params); + linphone_call_params_destroy(params); + + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); + + BC_ASSERT_TRUE(check_ice(marie, pauline, LinphoneIceStateHostConnection)); + + /*wait for the ICE reINVITE*/ + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); + + + end_call(pauline, marie); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + static void call_with_custom_headers(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -6371,6 +6420,18 @@ static void call_with_ice_without_stun(void){ linphone_core_manager_destroy(pauline); } +static void call_with_ice_without_stun2(void){ + LinphoneCoreManager * marie = linphone_core_manager_new( "marie_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + //linphone_core_set_stun_server(marie->lc, NULL); + linphone_core_set_stun_server(pauline->lc, NULL); + _call_with_ice_base(marie, pauline, TRUE, TRUE, TRUE, FALSE); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + static void call_with_zrtp_configured_calling_side(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -6578,6 +6639,7 @@ test_t call_tests[] = { TEST_ONE_TAG("Call with ICE (forced relay)", call_with_ice_forced_relay, "ICE"), TEST_ONE_TAG("Call from ICE to not ICE", ice_to_not_ice, "ICE"), TEST_ONE_TAG("Call from not ICE to ICE", not_ice_to_ice, "ICE"), + TEST_ONE_TAG("Call with ICE added by reINVITE", ice_added_by_reinvite, "ICE"), TEST_NO_TAG("Call with custom headers", call_with_custom_headers), TEST_NO_TAG("Call with custom SDP attributes", call_with_custom_sdp_attributes), TEST_NO_TAG("Call established with rejected INFO", call_established_with_rejected_info), @@ -6636,6 +6698,7 @@ test_t call_tests[] = { TEST_ONE_TAG("Call with ICE and rtcp-mux without ICE re-invite", call_with_ice_and_rtcp_mux_without_reinvite, "ICE"), TEST_ONE_TAG("Call with ICE with default candidate not stun", call_with_ice_with_default_candidate_not_stun, "ICE"), TEST_ONE_TAG("Call with ICE without stun server", call_with_ice_without_stun, "ICE"), + TEST_ONE_TAG("Call with ICE without stun server one side", call_with_ice_without_stun2, "ICE"), TEST_NO_TAG("call with ZRTP configured calling side only", call_with_zrtp_configured_calling_side), TEST_NO_TAG("call with ZRTP configured receiver side only", call_with_zrtp_configured_callee_side) }; diff --git a/tester/tester.c b/tester/tester.c index 90a810b00..57d4cc851 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -233,7 +233,7 @@ static void set_codec_enable(LinphoneCore* lc,const char* type,int rate,bool_t e for (codecs_it=codecs;codecs_it!=NULL;codecs_it=codecs_it->next) { linphone_core_enable_payload_type(lc,(PayloadType*)codecs_it->data,0); } - if((pt = linphone_core_find_payload_type(lc,type,rate,1))) { + if ((pt = linphone_core_find_payload_type(lc,type,rate,1))) { linphone_core_enable_payload_type(lc,pt, enable); } ms_list_free(codecs); From 65e3ef2009d6f157841392f01b3216da609c8db6 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 15 Jun 2016 14:41:52 +0200 Subject: [PATCH 081/124] offeranswer_tester.c: rename test to non-already-used name --- tester/offeranswer_tester.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tester/offeranswer_tester.c b/tester/offeranswer_tester.c index 138bae80c..901c65120 100644 --- a/tester/offeranswer_tester.c +++ b/tester/offeranswer_tester.c @@ -158,7 +158,7 @@ static void profile_call_base(bool_t avpf1 linphone_core_set_media_encryption_mandatory(marie->lc,TRUE); linphone_core_set_media_encryption_mandatory(pauline->lc,TRUE); } - + if (enable_video && linphone_core_video_supported(marie->lc)) { LinphoneVideoPolicy policy; policy.automatically_accept = TRUE; @@ -534,7 +534,7 @@ static test_t offeranswer_tests[] = { TEST_NO_TAG("SAVPF/DTLS to SAVPF/DTLS encryption mandatory video call", savpf_dtls_to_savpf_dtls_encryption_mandatory_video_call), TEST_NO_TAG("SAVPF/DTLS to SAVPF video call", savpf_dtls_to_savpf_video_call), TEST_NO_TAG("SAVPF/DTLS to SAVPF encryption mandatory video call", savpf_dtls_to_savpf_encryption_mandatory_video_call), - TEST_NO_TAG("SAVPF/DTLS to AVPF call", savpf_dtls_to_avpf_video_call), + TEST_NO_TAG("SAVPF/DTLS to AVPF video call", savpf_dtls_to_avpf_video_call), TEST_NO_TAG("Compatible AVPF features", compatible_avpf_features), TEST_NO_TAG("Incompatible AVPF features", incompatible_avpf_features) From 3c11cc74e608a6e236eae13c748db8511a4f1251 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 15 Jun 2016 14:41:52 +0200 Subject: [PATCH 082/124] offeranswer_tester.c: rename test to non-already-used name --- tester/offeranswer_tester.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tester/offeranswer_tester.c b/tester/offeranswer_tester.c index 138bae80c..901c65120 100644 --- a/tester/offeranswer_tester.c +++ b/tester/offeranswer_tester.c @@ -158,7 +158,7 @@ static void profile_call_base(bool_t avpf1 linphone_core_set_media_encryption_mandatory(marie->lc,TRUE); linphone_core_set_media_encryption_mandatory(pauline->lc,TRUE); } - + if (enable_video && linphone_core_video_supported(marie->lc)) { LinphoneVideoPolicy policy; policy.automatically_accept = TRUE; @@ -534,7 +534,7 @@ static test_t offeranswer_tests[] = { TEST_NO_TAG("SAVPF/DTLS to SAVPF/DTLS encryption mandatory video call", savpf_dtls_to_savpf_dtls_encryption_mandatory_video_call), TEST_NO_TAG("SAVPF/DTLS to SAVPF video call", savpf_dtls_to_savpf_video_call), TEST_NO_TAG("SAVPF/DTLS to SAVPF encryption mandatory video call", savpf_dtls_to_savpf_encryption_mandatory_video_call), - TEST_NO_TAG("SAVPF/DTLS to AVPF call", savpf_dtls_to_avpf_video_call), + TEST_NO_TAG("SAVPF/DTLS to AVPF video call", savpf_dtls_to_avpf_video_call), TEST_NO_TAG("Compatible AVPF features", compatible_avpf_features), TEST_NO_TAG("Incompatible AVPF features", incompatible_avpf_features) From 9992c9a4fefb164c2577df59dd15e4ed7b344a9a Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 15 Jun 2016 16:01:39 +0200 Subject: [PATCH 083/124] tester: split simple call tests in two suites: video calls and other calls and minor files reorganization --- tester/CMakeLists.txt | 31 +- tester/Makefile.am | 17 +- ...ulti_call_tester.c => call_multi_tester.c} | 0 ..._call_tester.c => call_multicast_tester.c} | 0 .../{call_tester.c => call_single_tester.c} | 1814 +---------------- tester/call_video_tester.c | 1782 ++++++++++++++++ ...all_tester.c => complex_sip_case_tester.c} | 2 +- tester/liblinphone_tester.h | 11 + tester/tester.c | 7 +- 9 files changed, 1824 insertions(+), 1840 deletions(-) rename tester/{multi_call_tester.c => call_multi_tester.c} (100%) rename tester/{multicast_call_tester.c => call_multicast_tester.c} (100%) rename tester/{call_tester.c => call_single_tester.c} (72%) create mode 100644 tester/call_video_tester.c rename tester/{complex_sip_call_tester.c => complex_sip_case_tester.c} (99%) diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 39643bfba..1483bc703 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -20,35 +20,8 @@ # ############################################################################ -set(SOURCE_FILES - accountmanager.c - audio_bypass_tester.c - call_tester.c - complex_sip_call_tester.c - dtmf_tester.c - eventapi_tester.c - flexisip_tester.c - liblinphone_tester.c - log_collection_tester.c - message_tester.c - multi_call_tester.c - multicast_call_tester.c - offeranswer_tester.c - player_tester.c - presence_tester.c - presence_server_tester.c - proxy_config_tester.c - quality_reporting_tester.c - register_tester.c - remote_provisioning_tester.c - setup_tester.c - stun_tester.c - tester.c - tunnel_tester.c - upnp_tester.c - video_tester.c - vcard_tester.c -) +file(GLOB SOURCE_FILES "*_tester.c") +list(APPEND SOURCE_FILES accountmanager.c tester.c) apply_compile_flags(SOURCE_FILES "CPP" "C") diff --git a/tester/Makefile.am b/tester/Makefile.am index 59b61fd66..75bc3ce2c 100644 --- a/tester/Makefile.am +++ b/tester/Makefile.am @@ -116,30 +116,31 @@ liblinphonetester_la_HEADERS = audio_bypass_wav_header.h liblinphonetester_la_SOURCES = \ accountmanager.c \ audio_bypass_tester.c \ - call_tester.c \ - complex_sip_call_tester.c \ + call_multi_tester.c \ + call_multicast_tester.c \ + call_single_tester.c \ + call_video_tester.c \ + complex_sip_case_tester.c \ dtmf_tester.c \ eventapi_tester.c \ flexisip_tester.c \ log_collection_tester.c \ message_tester.c \ - multi_call_tester.c \ - multicast_call_tester.c \ offeranswer_tester.c \ player_tester.c \ - presence_tester.c \ presence_server_tester.c \ + presence_tester.c \ proxy_config_tester.c \ quality_reporting_tester.c \ register_tester.c \ remote_provisioning_tester.c \ setup_tester.c \ stun_tester.c \ - tunnel_tester.c \ tester.c \ + tunnel_tester.c \ upnp_tester.c \ - video_tester.c \ - vcard_tester.c + vcard_tester.c \ + video_tester.c liblinphonetester_ladir = $(includedir)/linphone diff --git a/tester/multi_call_tester.c b/tester/call_multi_tester.c similarity index 100% rename from tester/multi_call_tester.c rename to tester/call_multi_tester.c diff --git a/tester/multicast_call_tester.c b/tester/call_multicast_tester.c similarity index 100% rename from tester/multicast_call_tester.c rename to tester/call_multicast_tester.c diff --git a/tester/call_tester.c b/tester/call_single_tester.c similarity index 72% rename from tester/call_tester.c rename to tester/call_single_tester.c index 842f9e0ff..2be54a4b0 100644 --- a/tester/call_tester.c +++ b/tester/call_single_tester.c @@ -34,7 +34,6 @@ #endif static void srtp_call(void); -static char *create_filepath(const char *dir, const char *filename, const char *ext); // prototype definition for call_recording() #ifdef ANDROID @@ -838,7 +837,7 @@ end: } -static void disable_all_codecs(const MSList* elem, LinphoneCoreManager* call){ +void disable_all_codecs(const MSList* elem, LinphoneCoreManager* call){ PayloadType *pt; @@ -877,59 +876,6 @@ static void call_with_no_audio_codec(void){ } -static void video_call_with_no_audio_and_no_video_codec(void){ - - LinphoneCoreManager* callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall* out_call ; - LinphoneVideoPolicy callee_policy, caller_policy; - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - - const MSList* elem_video =linphone_core_get_video_codecs(caller->lc); - - const MSList* elem_audio =linphone_core_get_audio_codecs(caller->lc); - - disable_all_codecs(elem_audio, caller); - disable_all_codecs(elem_video, caller); - - callee_policy.automatically_initiate=FALSE; - callee_policy.automatically_accept=TRUE; - caller_policy.automatically_initiate=TRUE; - caller_policy.automatically_accept=FALSE; - - linphone_core_set_video_policy(callee->lc,&callee_policy); - linphone_core_set_video_policy(caller->lc,&caller_policy); - - - linphone_core_enable_video_display(callee->lc, TRUE); - linphone_core_enable_video_capture(callee->lc, TRUE); - - linphone_core_enable_video_display(caller->lc, TRUE); - linphone_core_enable_video_capture(caller->lc, TRUE); - - /* Create call params */ - caller_test_params.base = linphone_core_create_call_params(caller->lc, NULL); - - - out_call = linphone_core_invite_address_with_params(caller->lc, callee->identity,caller_test_params.base); - linphone_call_ref(out_call); - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - - - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallOutgoingInit, 1)); - - BC_ASSERT_TRUE(wait_for_until(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallError, 1, 6000)); - BC_ASSERT_EQUAL(linphone_call_get_reason(out_call), LinphoneReasonNotAcceptable, int, "%d"); - BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallIncomingReceived, 0, int, "%d"); - - linphone_call_unref(out_call); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - static void simple_call_compatibility_mode(void) { char route[256]; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); @@ -1222,7 +1168,7 @@ static void call_with_no_sdp_ack_without_sdp(void){ linphone_core_manager_destroy(pauline); } -static void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts) { +void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts) { LinphoneCall *c1 = linphone_core_get_current_call(caller->lc); LinphoneCall *c2 = linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(c1); @@ -1235,7 +1181,7 @@ static void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManag } } -static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay) { +void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay) { linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL); linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL); @@ -1614,132 +1560,6 @@ end: ms_list_free(lcs); } -#ifdef VIDEO_ENABLED -static void call_paused_resumed_with_video_base_call_cb(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message) { - if (cstate == LinphoneCallUpdatedByRemote) { - LinphoneCallParams *params = linphone_core_create_call_params(lc, call); - linphone_call_params_enable_video(params, TRUE); - ms_message (" New state LinphoneCallUpdatedByRemote on call [%p], accepting with video on",call); - BC_ASSERT_NOT_EQUAL(linphone_core_accept_call_update(lc, call, params), 0, int, "%i"); - linphone_call_params_destroy(params); - } -} -/*this test makes sure that pause/resume will not bring up video by accident*/ -static void call_paused_resumed_with_video_base(bool_t sdp_200_ack - ,bool_t use_video_policy_for_re_invite_sdp_200 - ,bool_t resume_in_audio_send_only_video_inactive_first - ,bool_t with_call_accept){ - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall* call_pauline, *call_marie; - MSList *lcs = NULL; - LinphoneVideoPolicy vpol; - bool_t call_ok; - LinphoneCoreVTable *vtable = linphone_core_v_table_new(); - vtable->call_state_changed = call_paused_resumed_with_video_base_call_cb; - lcs = ms_list_append(lcs, pauline->lc); - lcs = ms_list_append(lcs, marie->lc); - - vpol.automatically_accept = FALSE; - vpol.automatically_initiate = TRUE; /* needed to present a video mline*/ - - linphone_core_set_video_policy(marie->lc, &vpol); - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - - vpol.automatically_accept = FALSE; - vpol.automatically_initiate = TRUE; - - linphone_core_set_video_policy(pauline->lc, &vpol); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, TRUE); - - BC_ASSERT_TRUE((call_ok=call(marie, pauline))); - - if (!call_ok) goto end; - - call_pauline = linphone_core_get_current_call(pauline->lc); - call_marie = linphone_core_get_current_call(marie->lc); - - wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); - - linphone_core_pause_call(pauline->lc,call_pauline); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1)); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_remote_params(call_marie))); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1)); - - /*stay in pause a little while in order to generate traffic*/ - wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); - - /*check if video stream is still offered even if disabled*/ - - BC_ASSERT_EQUAL(call_pauline->localdesc->nb_streams, 2, int, "%i"); - BC_ASSERT_EQUAL(call_marie->localdesc->nb_streams, 2, int, "%i"); - - linphone_core_enable_sdp_200_ack(pauline->lc,sdp_200_ack); - - if (use_video_policy_for_re_invite_sdp_200) { - LpConfig *marie_lp; - marie_lp = linphone_core_get_config(marie->lc); - lp_config_set_int(marie_lp,"sip","sdp_200_ack_follow_video_policy",1); - } - /*now pauline wants to resume*/ - if (resume_in_audio_send_only_video_inactive_first) { - LinphoneCallParams *params = linphone_core_create_call_params(pauline->lc, call_pauline); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly); - linphone_core_update_call(pauline->lc,call_pauline,params); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,2)); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdating,1)); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv); - if (with_call_accept) { - linphone_core_add_listener(marie->lc, vtable); - } - linphone_core_update_call(pauline->lc,call_pauline,params); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3)); - linphone_call_params_destroy(params); - } else { - linphone_core_resume_call(pauline->lc, call_pauline); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallResuming,1)); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); - } - - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); - - if (use_video_policy_for_re_invite_sdp_200) { - /*make sure video was offered*/ - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_remote_params(call_pauline))); - } else { - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_marie))); - } - end_call(marie, pauline); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); - ms_list_free(lcs); -} -static void call_paused_resumed_with_video(void){ - call_paused_resumed_with_video_base(FALSE, FALSE,FALSE,FALSE); -} - -static void call_paused_resumed_with_no_sdp_ack(void){ - call_paused_resumed_with_video_base(TRUE, FALSE,FALSE,FALSE); -} -static void call_paused_resumed_with_no_sdp_ack_using_video_policy(void){ - call_paused_resumed_with_video_base(TRUE, TRUE,FALSE,FALSE); -} -static void call_paused_updated_resumed_with_no_sdp_ack_using_video_policy(void){ - call_paused_resumed_with_video_base(TRUE, TRUE,TRUE,FALSE); -} -static void call_paused_updated_resumed_with_no_sdp_ack_using_video_policy_and_accept_call_update(void){ - call_paused_resumed_with_video_base(TRUE, TRUE,TRUE,TRUE); -} -#endif #define CHECK_CURRENT_LOSS_RATE() \ rtcp_count_current = pauline->stat.number_of_rtcp_sent; \ /*wait for an RTCP packet to have an accurate cumulative lost value*/ \ @@ -1910,921 +1730,6 @@ static void audio_call_with_ice_no_matching_audio_codecs(void) { linphone_core_manager_destroy(pauline); } -#ifdef VIDEO_ENABLED -static LinphoneCall* setup_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy) { - LinphoneVideoPolicy caller_policy; - LinphoneCallParams* callee_params; - LinphoneCall* call_obj; - - if (!linphone_core_get_current_call(callee->lc) || linphone_call_get_state(linphone_core_get_current_call(callee->lc)) != LinphoneCallStreamsRunning - || !linphone_core_get_current_call(caller->lc) || linphone_call_get_state(linphone_core_get_current_call(caller->lc)) != LinphoneCallStreamsRunning ) { - ms_warning("bad state for adding video"); - return NULL; - } - - if (change_video_policy) { - caller_policy.automatically_accept=TRUE; - caller_policy.automatically_initiate=TRUE; - linphone_core_set_video_policy(caller->lc,&caller_policy); - } - linphone_core_enable_video_capture(callee->lc, TRUE); - linphone_core_enable_video_display(callee->lc, TRUE); - linphone_core_enable_video_capture(caller->lc, TRUE); - linphone_core_enable_video_display(caller->lc, FALSE); - - if ((call_obj = linphone_core_get_current_call(callee->lc))) { - callee_params = linphone_core_create_call_params(callee->lc, call_obj); - /*add video*/ - linphone_call_params_enable_video(callee_params,TRUE); - linphone_core_update_call(callee->lc,call_obj,callee_params); - linphone_call_params_destroy(callee_params); - } - return call_obj; -} - -bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy) { - stats initial_caller_stat=caller->stat; - stats initial_callee_stat=callee->stat; - const LinphoneVideoPolicy *video_policy; - LinphoneCall *call_obj; - if ((call_obj=setup_video(caller, callee, change_video_policy))){ - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning+1)); - - video_policy = linphone_core_get_video_policy(caller->lc); - if (video_policy->automatically_accept) { - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); - } else { - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); - } - if (linphone_core_get_media_encryption(caller->lc) != LinphoneMediaEncryptionNone - && linphone_core_get_media_encryption(callee->lc) != LinphoneMediaEncryptionNone) { - const LinphoneCallParams* call_param; - - switch (linphone_core_get_media_encryption(caller->lc)) { - case LinphoneMediaEncryptionZRTP: - case LinphoneMediaEncryptionDTLS: - /*wait for encryption to be on, in case of zrtp/dtls, it can take a few seconds*/ - wait_for(callee->lc,caller->lc,&caller->stat.number_of_LinphoneCallEncryptedOn,initial_caller_stat.number_of_LinphoneCallEncryptedOn+1); - break; - case LinphoneMediaEncryptionNone: - case LinphoneMediaEncryptionSRTP: - break; - } - switch (linphone_core_get_media_encryption(callee->lc)) { - case LinphoneMediaEncryptionZRTP: - case LinphoneMediaEncryptionDTLS: - wait_for(callee->lc,caller->lc,&callee->stat.number_of_LinphoneCallEncryptedOn,initial_callee_stat.number_of_LinphoneCallEncryptedOn+1); - break; - case LinphoneMediaEncryptionNone: - case LinphoneMediaEncryptionSRTP: - break; - } - - call_param = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); - call_param = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); - - } - - if (video_policy->automatically_accept) { - linphone_call_set_next_video_frame_decoded_callback(call_obj,linphone_call_iframe_decoded_cb,callee->lc); - /*send vfu*/ - linphone_call_send_vfu_request(call_obj); - return wait_for(caller->lc,callee->lc,&callee->stat.number_of_IframeDecoded,initial_callee_stat.number_of_IframeDecoded+1); - } else { - return TRUE; - } - } - return FALSE; -} - -static bool_t remove_video(LinphoneCoreManager *caller, LinphoneCoreManager *callee) { - LinphoneCallParams *callee_params; - LinphoneCall *call_obj; - stats initial_caller_stat = caller->stat; - stats initial_callee_stat = callee->stat; - - if (!linphone_core_get_current_call(callee->lc) - || (linphone_call_get_state(linphone_core_get_current_call(callee->lc)) != LinphoneCallStreamsRunning) - || !linphone_core_get_current_call(caller->lc) - || (linphone_call_get_state(linphone_core_get_current_call(caller->lc)) != LinphoneCallStreamsRunning)) { - ms_warning("bad state for removing video"); - return FALSE; - } - - if ((call_obj = linphone_core_get_current_call(callee->lc))) { - callee_params = linphone_core_create_call_params(callee->lc, call_obj); - /* Remove video. */ - linphone_call_params_enable_video(callee_params, FALSE); - linphone_core_update_call(callee->lc, call_obj, callee_params); - linphone_call_params_destroy(callee_params); - - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallUpdatedByRemote, initial_caller_stat.number_of_LinphoneCallUpdatedByRemote + 1)); - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallUpdating, initial_callee_stat.number_of_LinphoneCallUpdating + 1)); - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, initial_callee_stat.number_of_LinphoneCallStreamsRunning + 1)); - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, initial_caller_stat.number_of_LinphoneCallStreamsRunning + 1)); - - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); - - return TRUE; - } - return FALSE; -} - -static void call_with_video_added(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - - BC_ASSERT_TRUE((call_ok=call(pauline,marie))); - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - - end_call(pauline, marie); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_video_added_2(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - /*in this variant marie is already in automatically accept*/ - LinphoneVideoPolicy marie_policy; - marie_policy.automatically_accept=TRUE; - - - linphone_core_set_video_policy(marie->lc,&marie_policy); - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, FALSE); - - BC_ASSERT_TRUE(call_ok=call(pauline,marie)); - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(marie,pauline, TRUE)); - - end_call(pauline, marie); -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_video_added_random_ports(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - - linphone_core_set_audio_port(marie->lc,-1); - linphone_core_set_video_port(marie->lc,-1); - linphone_core_set_audio_port(pauline->lc,-1); - linphone_core_set_video_port(pauline->lc,-1); - - BC_ASSERT_TRUE(call_ok=call(pauline,marie)); - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - end_call(pauline, marie); -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_several_video_switches(void) { - int dummy = 0; - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - BC_ASSERT_TRUE(call_ok=call(pauline,marie)); - - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ - BC_ASSERT_TRUE(remove_video(pauline,marie)); - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ - BC_ASSERT_TRUE(remove_video(pauline,marie)); - /**/ - end_call(pauline, marie); -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void srtp_call_with_several_video_switches(void) { - int dummy = 0; - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - - if (linphone_core_media_encryption_supported(marie->lc, LinphoneMediaEncryptionSRTP)) { - linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionSRTP); - linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionSRTP); - - BC_ASSERT_TRUE(call_ok=call(pauline,marie)); - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ - BC_ASSERT_TRUE(remove_video(pauline,marie)); - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ - BC_ASSERT_TRUE(remove_video(pauline,marie)); - /**/ - end_call(pauline, marie); - } else { - ms_warning("Not tested because SRTP is not available."); - } -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_declined_video_base(bool_t using_policy) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall* marie_call; - LinphoneCall* pauline_call; - LinphoneVideoPolicy marie_policy, pauline_policy; - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - bool_t call_ok; - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, FALSE); - - if (using_policy) { - pauline_policy.automatically_initiate=TRUE; - pauline_policy.automatically_accept=FALSE; - marie_policy.automatically_initiate=FALSE; - marie_policy.automatically_accept=FALSE; - - linphone_core_set_video_policy(marie->lc,&marie_policy); - linphone_core_set_video_policy(pauline->lc,&pauline_policy); - } - - caller_test_params.base=linphone_core_create_call_params(pauline->lc, NULL); - if (!using_policy) - linphone_call_params_enable_video(caller_test_params.base,TRUE); - - if (!using_policy){ - callee_test_params.base=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_video(callee_test_params.base,FALSE); - } - - BC_ASSERT_TRUE((call_ok=call_with_params2(pauline,marie,&caller_test_params,&callee_test_params,using_policy))); - if (!call_ok) goto end; - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - marie_call=linphone_core_get_current_call(marie->lc); - pauline_call=linphone_core_get_current_call(pauline->lc); - - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call))); - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call))); - - end_call(pauline, marie); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} -static void call_with_declined_video(void) { - call_with_declined_video_base(FALSE); -} - -static void call_with_declined_video_despite_policy(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall* marie_call; - LinphoneCall* pauline_call; - LinphoneVideoPolicy marie_policy, pauline_policy; - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - bool_t call_ok; - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, FALSE); - - pauline_policy.automatically_initiate=TRUE; - pauline_policy.automatically_accept=TRUE; - marie_policy.automatically_initiate=TRUE; - marie_policy.automatically_accept=TRUE; - - linphone_core_set_video_policy(marie->lc,&marie_policy); - linphone_core_set_video_policy(pauline->lc,&pauline_policy); - - caller_test_params.base=linphone_core_create_call_params(pauline->lc, NULL); - - callee_test_params.base=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_video(callee_test_params.base,FALSE); - - BC_ASSERT_TRUE((call_ok=call_with_params2(pauline,marie,&caller_test_params,&callee_test_params,FALSE))); - if (!call_ok) goto end; - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - marie_call=linphone_core_get_current_call(marie->lc); - pauline_call=linphone_core_get_current_call(pauline->lc); - - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call))); - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call))); - - end_call(pauline, marie); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_declined_video_using_policy(void) { - call_with_declined_video_base(TRUE); -} - - -void video_call_base_2(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - LinphoneCall* callee_call; - LinphoneCall* caller_call; - LinphoneVideoPolicy callee_policy, caller_policy; - - if (using_policy) { - callee_policy.automatically_initiate=FALSE; - callee_policy.automatically_accept=TRUE; - caller_policy.automatically_initiate=TRUE; - caller_policy.automatically_accept=FALSE; - - linphone_core_set_video_policy(callee->lc,&callee_policy); - linphone_core_set_video_policy(caller->lc,&caller_policy); - } - - linphone_core_enable_video_display(callee->lc, callee_video_enabled); - linphone_core_enable_video_capture(callee->lc, callee_video_enabled); - - linphone_core_enable_video_display(caller->lc, caller_video_enabled); - linphone_core_enable_video_capture(caller->lc, caller_video_enabled); - - if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */ - char *path = bc_tester_file("certificates-marie"); - callee->lc->user_certificates_path = ms_strdup(path); - bc_free(path); - path = bc_tester_file("certificates-pauline"); - caller->lc->user_certificates_path = ms_strdup(path); - bc_free(path); - belle_sip_mkdir(callee->lc->user_certificates_path); - belle_sip_mkdir(caller->lc->user_certificates_path); - } - - linphone_core_set_media_encryption(callee->lc,mode); - linphone_core_set_media_encryption(caller->lc,mode); - - caller_test_params.base=linphone_core_create_call_params(caller->lc, NULL); - if (!using_policy) - linphone_call_params_enable_video(caller_test_params.base,TRUE); - - if (!using_policy){ - callee_test_params.base=linphone_core_create_call_params(callee->lc, NULL); - linphone_call_params_enable_video(callee_test_params.base,TRUE); - } - - BC_ASSERT_TRUE(call_with_params2(caller,callee,&caller_test_params,&callee_test_params,using_policy)); - callee_call=linphone_core_get_current_call(callee->lc); - caller_call=linphone_core_get_current_call(caller->lc); - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - - if (callee_call && caller_call ) { - if (callee_video_enabled && caller_video_enabled) { - BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); - BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); - - /*check video path*/ - linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); - linphone_call_send_vfu_request(callee_call); - BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); - } else { - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); - } - liblinphone_tester_check_rtcp(callee,caller); - } -} - - -static void check_fir(LinphoneCoreManager* caller,LinphoneCoreManager* callee ){ - LinphoneCall* callee_call; - LinphoneCall* caller_call; - - callee_call=linphone_core_get_current_call(callee->lc); - caller_call=linphone_core_get_current_call(caller->lc); - - /*check video path is established in both directions. - Indeed, FIR are ignored until the first RTP packet is received, because SSRC is not known.*/ - linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); - linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); - - BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); - BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); - - linphone_call_send_vfu_request(callee_call); - - if (rtp_session_avpf_enabled(callee_call->sessions->rtp_session)){ - BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&caller_call->videostream->ms_video_stat.counter_rcvd_fir, 1)); - }else{ - BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&caller_call->videostream->ms_video_stat.counter_rcvd_fir, 0)); - } - ms_message ("check_fir : [%p] received %d FIR ",&caller_call ,caller_call->videostream->ms_video_stat.counter_rcvd_fir); - ms_message ("check_fir : [%p] stat number of iframe decoded %d ",&callee_call, callee->stat.number_of_IframeDecoded); - - linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); - linphone_call_send_vfu_request(caller_call); - BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); - - if (rtp_session_avpf_enabled(caller_call->sessions->rtp_session)) { - if (rtp_session_avpf_enabled(callee_call->sessions->rtp_session)){ - BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&callee_call->videostream->ms_video_stat.counter_rcvd_fir, 1)); - } - }else{ - BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&callee_call->videostream->ms_video_stat.counter_rcvd_fir, 0)); - } - ms_message ("check_fir : [%p] received %d FIR ",&callee_call ,callee_call->videostream->ms_video_stat.counter_rcvd_fir); - ms_message ("check_fir : [%p] stat number of iframe decoded %d ",&caller_call, caller->stat.number_of_IframeDecoded); - -} - -void video_call_base_3(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - - LinphoneCall* callee_call; - LinphoneCall* caller_call; - LinphoneVideoPolicy callee_policy, caller_policy; - - if (using_policy) { - callee_policy.automatically_initiate=FALSE; - callee_policy.automatically_accept=TRUE; - caller_policy.automatically_initiate=TRUE; - caller_policy.automatically_accept=FALSE; - - linphone_core_set_video_policy(callee->lc,&callee_policy); - linphone_core_set_video_policy(caller->lc,&caller_policy); - } - - linphone_core_enable_video_display(callee->lc, callee_video_enabled); - linphone_core_enable_video_capture(callee->lc, callee_video_enabled); - - linphone_core_enable_video_display(caller->lc, caller_video_enabled); - linphone_core_enable_video_capture(caller->lc, caller_video_enabled); - - if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */ - char *path = bc_tester_file("certificates-marie"); - callee->lc->user_certificates_path = ms_strdup(path); - bc_free(path); - path = bc_tester_file("certificates-pauline"); - caller->lc->user_certificates_path = ms_strdup(path); - bc_free(path); - belle_sip_mkdir(callee->lc->user_certificates_path); - belle_sip_mkdir(caller->lc->user_certificates_path); - } - - linphone_core_set_media_encryption(callee->lc,mode); - linphone_core_set_media_encryption(caller->lc,mode); - /* Create call params */ - caller_test_params.base=linphone_core_create_call_params(caller->lc, NULL); - - if (!using_policy) - linphone_call_params_enable_video(caller_test_params.base,TRUE); - - if (!using_policy){ - callee_test_params.base=linphone_core_create_call_params(callee->lc, NULL); - linphone_call_params_enable_video(callee_test_params.base,TRUE); - } - - BC_ASSERT_TRUE(call_with_params2(caller,callee,&caller_test_params,&callee_test_params,using_policy)); - callee_call=linphone_core_get_current_call(callee->lc); - caller_call=linphone_core_get_current_call(caller->lc); - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - - if (callee_call && caller_call ) { - if (callee_video_enabled && caller_video_enabled) { - check_fir(caller,callee); - } else { - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); - } - liblinphone_tester_check_rtcp(callee,caller); - } -} - - - -static void video_call_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { - video_call_base_2(pauline,marie,using_policy,mode,callee_video_enabled,caller_video_enabled); - end_call(pauline, marie); -} - -static void video_call(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_without_rtcp(void) { - LpConfig *lp; - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - lp = linphone_core_get_config(marie->lc); - lp_config_set_int(lp,"rtp","rtcp_enabled",0); - - lp = linphone_core_get_config(pauline->lc); - lp_config_set_int(lp,"rtp","rtcp_enabled",0); - - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_disable_implicit_AVPF_on_callee(void) { - LinphoneCoreManager* callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - LpConfig *callee_lp; - const LinphoneCallParams *params, *params2; - - callee_lp = linphone_core_get_config(callee->lc); - lp_config_set_int(callee_lp,"rtp","rtcp_fb_implicit_rtcp_fb",0); - - video_call_base_3(caller,callee,TRUE,LinphoneMediaEncryptionNone,TRUE,TRUE); - if(BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(callee->lc))) { - params = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); - BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), "RTP/AVP"); - } - if(BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(caller->lc))) { - params2 =linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); - BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params2), "RTP/AVP"); - } - end_call(caller, callee); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); -} - - -static void video_call_disable_implicit_AVPF_on_caller(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - LpConfig *caller_lp; - const LinphoneCallParams *params, *params2; - - caller_lp = linphone_core_get_config(caller->lc); - lp_config_set_int(caller_lp, "rtp", "rtcp_fb_implicit_rtcp_fb", 0); - - video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); - params = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); - BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), "RTP/AVP"); - params2 = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); - BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params2), "RTP/AVP"); - end_call(caller, callee); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - -static void video_call_AVPF_to_implicit_AVPF(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_avpf_mode(caller->lc, LinphoneAVPFEnabled); - video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); - end_call(caller, callee); - - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - -static void video_call_implicit_AVPF_to_AVPF(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_avpf_mode(callee->lc, LinphoneAVPFEnabled); - video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); - end_call(caller, callee); - - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - -static void video_call_using_policy_AVPF_implicit_caller_and_callee(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base_3(caller, callee, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); - end_call(caller, callee); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); -} - -static void video_call_base_avpf(LinphoneCoreManager *caller, LinphoneCoreManager *callee, bool_t using_policy, LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { - linphone_core_set_avpf_mode(caller->lc, LinphoneAVPFEnabled); - linphone_core_set_avpf_mode(callee->lc, LinphoneAVPFEnabled); - video_call_base_3(caller, callee, using_policy, mode, callee_video_enabled, caller_video_enabled); - end_call(caller, callee); -} - -static void video_call_avpf(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - video_call_base_avpf(caller, callee, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - -static void video_call_zrtp(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - if (linphone_core_media_encryption_supported(marie->lc,LinphoneMediaEncryptionZRTP)) { - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionZRTP,TRUE,TRUE); - } else - ms_message("Skipping video_call_zrtp"); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_dtls(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - if (linphone_core_media_encryption_supported(pauline->lc,LinphoneMediaEncryptionDTLS)) { - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionDTLS,TRUE,TRUE); - } else - ms_message("Skipping video_call_dtls"); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); - -} - - - -static void video_call_using_policy(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base(pauline,marie,TRUE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_using_policy_with_callee_video_disabled(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base(marie,pauline,TRUE,LinphoneMediaEncryptionNone,FALSE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_using_policy_with_caller_video_disabled(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base(marie,pauline,TRUE,LinphoneMediaEncryptionNone,TRUE,FALSE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_no_sdp(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - linphone_core_enable_sdp_200_ack(pauline->lc,TRUE); - video_call_base(pauline,marie,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_ice_video_to_novideo(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneVideoPolicy vpol={0}; - vpol.automatically_initiate=TRUE; - linphone_core_set_video_policy(pauline->lc,&vpol); - vpol.automatically_initiate=FALSE; - linphone_core_set_video_policy(marie->lc,&vpol); - _call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void _call_with_ice_video(LinphoneVideoPolicy caller_policy, LinphoneVideoPolicy callee_policy, - bool_t video_added_by_caller, bool_t video_added_by_callee, bool_t video_removed_by_caller, bool_t video_removed_by_callee) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - unsigned int nb_media_starts = 1; - - linphone_core_set_video_policy(pauline->lc, &caller_policy); - linphone_core_set_video_policy(marie->lc, &callee_policy); - linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); - linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); - - linphone_core_set_audio_port(marie->lc, -1); - linphone_core_set_video_port(marie->lc, -1); - linphone_core_set_audio_port(pauline->lc, -1); - linphone_core_set_video_port(pauline->lc, -1); - - BC_ASSERT_TRUE(call_ok = call(pauline, marie)); - if (!call_ok) goto end; - BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); - - /* Wait for ICE reINVITEs to complete. */ - BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2) - && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); - check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); - nb_media_starts++; - - if (video_added_by_caller) { - BC_ASSERT_TRUE(add_video(marie, pauline, FALSE)); - } else if (video_added_by_callee) { - BC_ASSERT_TRUE(add_video(pauline, marie, FALSE)); - } - if (video_added_by_caller || video_added_by_callee) { - BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); - if (linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)))){ - /* Wait for ICE reINVITEs to complete if video was really added */ - BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 4) - && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 4)); - check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); - nb_media_starts++; - } - } - - if (video_removed_by_caller) { - BC_ASSERT_TRUE(remove_video(marie, pauline)); - } else if (video_removed_by_callee) { - BC_ASSERT_TRUE(remove_video(pauline, marie)); - } - if (video_removed_by_caller || video_removed_by_callee) { - BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); - check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); - nb_media_starts++; - } - - end_call(pauline, marie); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_ice_video_added(void) { - LinphoneVideoPolicy vpol = { TRUE, TRUE }; - _call_with_ice_video(vpol, vpol, TRUE, FALSE, TRUE, FALSE); -} - -static void call_with_ice_video_added_2(void) { - LinphoneVideoPolicy vpol = { TRUE, TRUE }; - _call_with_ice_video(vpol, vpol, TRUE, FALSE, FALSE, TRUE); -} - -static void call_with_ice_video_added_3(void) { - LinphoneVideoPolicy vpol = { TRUE, TRUE }; - _call_with_ice_video(vpol, vpol, FALSE, TRUE, TRUE, FALSE); -} - -static void call_with_ice_video_added_and_refused(void) { - LinphoneVideoPolicy caller_policy = { TRUE, TRUE }; - LinphoneVideoPolicy callee_policy = { FALSE, FALSE }; - _call_with_ice_video(caller_policy, callee_policy, TRUE, FALSE, FALSE, FALSE); -} - -static void call_with_ice_video_added_with_video_policies_to_false(void) { - LinphoneVideoPolicy vpol = { FALSE, FALSE }; - _call_with_ice_video(vpol, vpol, FALSE, TRUE, FALSE, FALSE); -} - -#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT /*which is not the case at the moment*/ - -static void call_with_ice_video_and_rtt(void) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - LinphoneVideoPolicy policy = { TRUE, TRUE }; - LinphoneCallParams *params = NULL; - LinphoneCall *marie_call = NULL; - - linphone_core_set_video_policy(pauline->lc, &policy); - linphone_core_set_video_policy(marie->lc, &policy); - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, FALSE); - linphone_core_enable_video_capture(pauline->lc, FALSE); - linphone_core_enable_video_display(pauline->lc, TRUE); - linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); - linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); - - linphone_core_set_audio_port(marie->lc, -1); - linphone_core_set_video_port(marie->lc, -1); - linphone_core_set_text_port(marie->lc, -1); - linphone_core_set_audio_port(pauline->lc, -1); - linphone_core_set_video_port(pauline->lc, -1); - linphone_core_set_text_port(pauline->lc, -1); - - params = linphone_core_create_default_call_parameters(pauline->lc); - linphone_call_params_enable_realtime_text(params, TRUE); - BC_ASSERT_TRUE(call_ok = call_with_caller_params(pauline, marie, params)); - if (!call_ok) goto end; - BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); - - marie_call = linphone_core_get_current_call(marie->lc); - BC_ASSERT_TRUE(linphone_call_params_audio_enabled(linphone_call_get_current_params(marie_call))); - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marie_call))); - BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(marie_call))); - - end_call(pauline, marie); -end: - linphone_call_params_destroy(params); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -#endif - -static void video_call_with_early_media_no_matching_audio_codecs(void) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall *out_call, *pauline_call; - LinphoneVideoPolicy vpol={0}; - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, FALSE); - - vpol.automatically_initiate=TRUE; - vpol.automatically_accept=TRUE; - linphone_core_set_video_policy(pauline->lc,&vpol); - linphone_core_set_video_policy(marie->lc,&vpol); - - linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMU", 8000, 1), FALSE); /* Disable PCMU */ - linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMA", 8000, 1), TRUE); /* Enable PCMA */ - - out_call = linphone_core_invite_address(marie->lc, pauline->identity); - linphone_call_ref(out_call); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingInit, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1)); - - pauline_call = linphone_core_get_current_call(pauline->lc); - if (!pauline_call) goto end; - - linphone_core_accept_early_media(pauline->lc, pauline_call); - - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia, 1)); - /*audio stream shall not have been requested to start*/ - BC_ASSERT_PTR_NULL(pauline_call->audiostream->soundread); - - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(out_call))); - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(pauline_call))); - - linphone_core_accept_call(pauline->lc, pauline_call); - - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); - - end_call(marie, pauline); - -end: - linphone_call_unref(out_call); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_limited_bandwidth(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_download_bandwidth(pauline->lc, 100); - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -#endif /*VIDEO_ENABLED*/ - static void _call_with_media_relay(bool_t random_ports) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -2991,9 +1896,7 @@ static void zrtp_cipher_call(void) { call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_aes256_rc", "pauline_tcp_rc"); } -static void zrtp_video_call(void) { - call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyNoFirewall,FALSE); -} + static void dtls_srtp_call(void) { call_base(LinphoneMediaEncryptionDTLS,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE); @@ -3006,18 +1909,7 @@ static void dtls_srtp_call_with_media_realy(void) { static void dtls_srtp_ice_call(void) { call_base(LinphoneMediaEncryptionDTLS,FALSE,FALSE,LinphonePolicyUseIce,FALSE); } -#ifdef VIDEO_ENABLED -static void dtls_srtp_video_call(void) { - call_base(LinphoneMediaEncryptionDTLS,TRUE,FALSE,LinphonePolicyNoFirewall,FALSE); -} -static void dtls_srtp_ice_video_call(void) { - call_base(LinphoneMediaEncryptionDTLS,TRUE,FALSE,LinphonePolicyUseIce,FALSE); -} -static void dtls_srtp_ice_video_call_with_relay(void) { - call_base(LinphoneMediaEncryptionDTLS,TRUE,TRUE,LinphonePolicyUseIce,FALSE); -} -#endif static void call_with_declined_srtp(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -3087,7 +1979,7 @@ static void call_with_file_player(void) { LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphonePlayer *player; char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav"); - char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_file_player", "wav"); + char *recordpath = bc_tester_file("record-call_with_file_player.wav"); bool_t call_ok; int attempts; double similar=1; @@ -3162,7 +2054,7 @@ static void call_with_mkv_file_player(void) { ms_warning("Test skipped, no mkv support."); goto end; } - recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_mkv_file_player", "wav"); + recordpath = bc_tester_file("record-call_with_mkv_file_player.wav"); /*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/ unlink(recordpath); @@ -3334,15 +2226,6 @@ void call_base(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_r call_base_with_configfile(mode, enable_video, enable_relay, policy, enable_tunnel, "marie_rc", "pauline_tcp_rc"); } -#ifdef VIDEO_ENABLED -static void srtp_video_ice_call(void) { - call_base(LinphoneMediaEncryptionSRTP,TRUE,FALSE,LinphonePolicyUseIce,FALSE); -} -static void zrtp_video_ice_call(void) { - call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyUseIce,FALSE); -} -#endif - static void srtp_ice_call(void) { call_base(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyUseIce,FALSE); } @@ -3932,113 +2815,6 @@ static void call_rejected_without_403_because_wrong_credentials_no_auth_req_cb(v call_rejected_because_wrong_credentials_with_params("tester-no-403",FALSE); } -#ifdef VIDEO_ENABLED -static void video_early_media_call(void) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_early_rc"); - LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); - LinphoneCall *pauline_to_marie; - - linphone_core_set_video_device(pauline->lc, "Mire: Mire (synthetic moving picture)"); - - video_call_base_3(pauline, marie, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); - - BC_ASSERT_PTR_NOT_NULL(pauline_to_marie = linphone_core_get_current_call(pauline->lc)); - if(pauline_to_marie) { - BC_ASSERT_EQUAL(pauline_to_marie->videostream->source->desc->id, MS_MIRE_ID, int, "%d"); - } - - end_call(pauline, marie); - - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -/*this is call forking with early media managed at client side (not by flexisip server)*/ -static void multiple_early_media(void) { - LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc"); - LinphoneCoreManager* marie1 = linphone_core_manager_new("marie_early_rc"); - LinphoneCoreManager* marie2 = linphone_core_manager_new("marie_early_rc"); - MSList *lcs=NULL; - LinphoneCallParams *params=linphone_core_create_call_params(pauline->lc, NULL); - LinphoneVideoPolicy pol; - LinphoneCall *marie1_call; - LinphoneCall *marie2_call; - LinphoneCall *pauline_call; - LinphoneInfoMessage *info; - int dummy=0; - pol.automatically_accept=1; - pol.automatically_initiate=1; - - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, TRUE); - - linphone_core_enable_video_capture(marie1->lc, TRUE); - linphone_core_enable_video_display(marie1->lc, TRUE); - linphone_core_set_video_policy(marie1->lc,&pol); - - linphone_core_enable_video_capture(marie2->lc, TRUE); - linphone_core_enable_video_display(marie2->lc, TRUE); - linphone_core_set_video_policy(marie2->lc,&pol); - linphone_core_set_audio_port_range(marie2->lc,40200,40300); - linphone_core_set_video_port_range(marie2->lc,40400,40500); - - lcs=ms_list_append(lcs,marie1->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,pauline->lc); - - linphone_call_params_enable_early_media_sending(params,TRUE); - linphone_call_params_enable_video(params,TRUE); - - linphone_core_invite_address_with_params(pauline->lc,marie1->identity,params); - linphone_call_params_destroy(params); - - BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000)); - BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000)); - BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,3000)); - - pauline_call=linphone_core_get_current_call(pauline->lc); - marie1_call=linphone_core_get_current_call(marie1->lc); - marie2_call=linphone_core_get_current_call(marie2->lc); - - BC_ASSERT_PTR_NOT_NULL(pauline_call); - BC_ASSERT_PTR_NOT_NULL(marie1_call); - BC_ASSERT_PTR_NOT_NULL(marie2_call); - - if (pauline_call && marie1_call && marie2_call){ - - /*wait a bit that streams are established*/ - wait_for_list(lcs,&dummy,1,6000); - BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline),70,int,"%i"); - BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie1), 70, int, "%i"); - BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie2), 70, int, "%i"); - - linphone_core_accept_call(marie1->lc,linphone_core_get_current_call(marie1->lc)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallStreamsRunning,1,3000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,3000)); - - /*marie2 should get her call terminated*/ - BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); - - /*wait a bit that streams are established*/ - wait_for_list(lcs,&dummy,1,3000); - BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(pauline), 71, int, "%i"); - BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie1), 71, int, "%i"); - - /*send an INFO in reverse side to check that dialogs are properly established*/ - info=linphone_core_create_info_message(marie1->lc); - linphone_call_send_info_message(marie1_call,info); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_inforeceived,1,3000)); - } - - end_call(pauline, marie1); - - ms_list_free(lcs); - linphone_core_manager_destroy(marie1); - linphone_core_manager_destroy(marie2); - linphone_core_manager_destroy(pauline); -} -#endif - void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList* lcs,LinphoneMediaDirection audio_dir, LinphoneMediaDirection video_dir) { BC_ASSERT_PTR_NOT_NULL(call); if (call) { @@ -4101,128 +2877,8 @@ void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList* } } -#ifdef VIDEO_ENABLED -static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, LinphoneCoreManager *marie, MSList *lcs) { -#define DEFAULT_WAIT_FOR 10000 - LinphoneCallParams *params; - LinphoneVideoPolicy pol; - LinphoneCall *call; - pol.automatically_accept=1; - pol.automatically_initiate=1; - // important: VP8 has really poor performances with the mire camera, at least - // on iOS - so when ever h264 is available, let's use it instead - if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { - disable_all_video_codecs_except_one(pauline->lc,"h264"); - disable_all_video_codecs_except_one(marie->lc,"h264"); - } - - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, TRUE); - linphone_core_set_video_policy(pauline->lc,&pol); - linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_set_video_policy(marie->lc,&pol); - linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); - - linphone_call_set_next_video_frame_decoded_callback(linphone_core_invite_address(pauline->lc,marie->identity) - ,linphone_call_iframe_decoded_cb - ,pauline->lc); - - - BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallIncomingReceived,1,DEFAULT_WAIT_FOR)); - - { - char* remote_uri = linphone_address_as_string_uri_only(pauline->identity); - call = linphone_core_find_call_from_uri(marie->lc,remote_uri); - ms_free(remote_uri); - } - - if (call) { - params=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendOnly); - linphone_core_accept_call_with_params(marie->lc,call,params); - linphone_call_params_destroy(params); - - BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning,1,DEFAULT_WAIT_FOR)); - BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallPausedByRemote,1,DEFAULT_WAIT_FOR)); - - check_media_direction(marie,call,lcs,LinphoneMediaDirectionSendOnly,LinphoneMediaDirectionSendOnly); - } - - - call=linphone_core_get_current_call(pauline->lc); - if (call) { - check_media_direction(pauline,call,lcs,LinphoneMediaDirectionRecvOnly,LinphoneMediaDirectionRecvOnly); - } - -} -static void accept_call_in_send_base(bool_t caller_has_ice) { - LinphoneCoreManager *pauline, *marie; - MSList *lcs=NULL;; - - marie = linphone_core_manager_new("marie_rc"); - pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - if (caller_has_ice) { - linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); - } - - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - - accept_call_in_send_only_base(pauline,marie,lcs); - - - end_call(marie,pauline); - ms_list_free(lcs); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void accept_call_in_send_only(void) { - accept_call_in_send_base(FALSE); -} - -static void accept_call_in_send_only_with_ice(void) { - accept_call_in_send_base(TRUE); -} - -void two_accepted_call_in_send_only(void) { - LinphoneCoreManager *pauline, *marie, *laure; - MSList *lcs=NULL; - - marie = linphone_core_manager_new("marie_rc"); - linphone_core_use_files(marie->lc, TRUE); - pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - laure = linphone_core_manager_new("laure_rc_udp"); - - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,laure->lc); - - accept_call_in_send_only_base(pauline,marie,lcs); - - reset_counters(&marie->stat); - accept_call_in_send_only_base(laure,marie,lcs); - - end_call(pauline, marie); - end_call(laure, marie); - - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); - linphone_core_manager_destroy(laure); - ms_list_free(lcs); -} -#endif - -static char *create_filepath(const char *dir, const char *filename, const char *ext) { - return ms_strdup_printf("%s/%s.%s",dir,filename,ext); -} - -static void record_call(const char *filename, bool_t enableVideo, const char *video_codec) { +void record_call(const char *filename, bool_t enableVideo, const char *video_codec) { LinphoneCoreManager *marie = NULL; LinphoneCoreManager *pauline = NULL; LinphoneCallParams *marieParams = NULL; @@ -4270,7 +2926,9 @@ static void record_call(const char *filename, bool_t enableVideo, const char *vi formats = linphone_core_get_supported_file_formats(marie->lc); for(i=0, format = formats[0]; format != NULL; i++, format = formats[i]) { - filepath = create_filepath(bc_tester_get_writable_dir_prefix(), filename, format); + char* totalname = ms_strdup_printf("%s.%s", filename, format); + filepath = bc_tester_file(totalname); + ms_free(totalname); remove(filepath); linphone_call_params_set_record_file(marieParams, filepath); BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams)); @@ -4296,54 +2954,6 @@ static void audio_call_recording_test(void) { record_call("recording", FALSE, NULL); } -#ifdef VIDEO_ENABLED -static void video_call_recording_h264_test(void) { - record_call("recording", TRUE, "H264"); -} - -static void video_call_recording_vp8_test(void) { - record_call("recording", TRUE, "VP8"); -} - -static void video_call_snapshot(void) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCallParams *marieParams = linphone_core_create_call_params(marie->lc, NULL); - LinphoneCallParams *paulineParams = linphone_core_create_call_params(pauline->lc, NULL); - LinphoneCall *callInst = NULL; - char *filename = create_filepath(bc_tester_get_writable_dir_prefix(), "snapshot", "jpeg"); - int dummy = 0; - bool_t call_succeeded = FALSE; - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, FALSE); - linphone_call_params_enable_video(marieParams, TRUE); - linphone_call_params_enable_video(paulineParams, TRUE); - - BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams)); - BC_ASSERT_PTR_NOT_NULL(callInst = linphone_core_get_current_call(marie->lc)); - if((call_succeeded == TRUE) && (callInst != NULL)) { - int jpeg_support = linphone_call_take_video_snapshot(callInst, filename); - if (jpeg_support < 0) { - ms_warning("No jpegwriter support!"); - } else { - wait_for_until(marie->lc, pauline->lc, &dummy, 1, 5000); - BC_ASSERT_EQUAL(ortp_file_exist(filename), 0, int, "%d"); - remove(filename); - } - end_call(marie, pauline); - } - ms_free(filename); - linphone_call_params_unref(marieParams); - linphone_call_params_unref(paulineParams); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -#endif - static void call_with_in_dialog_update(void) { LinphoneCoreManager* marie; LinphoneCoreManager* pauline; @@ -4560,84 +3170,6 @@ static void outgoing_invite_with_invalid_sdp(void) { linphone_core_manager_destroy(caller); } -static void incoming_reinvite_with_invalid_ack_sdp(void){ -#ifdef VIDEO_ENABLED - LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc"); - LinphoneCall * inc_call; - BC_ASSERT_TRUE(call(caller,callee)); - inc_call = linphone_core_get_current_call(callee->lc); - - BC_ASSERT_PTR_NOT_NULL(inc_call); - if (inc_call) { - const LinphoneCallParams *caller_params; - stats initial_caller_stat=caller->stat; - stats initial_callee_stat=callee->stat; - sal_call_set_sdp_handling(inc_call->op, SalOpSDPSimulateError); /* will force a parse error for the ACK SDP*/ - BC_ASSERT_PTR_NOT_NULL(setup_video(caller, callee, TRUE)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning)); - /*Basically the negotiation failed but since the call was already running, we expect it to restore to - the previous state so error stats should not be changed*/ - BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallError,initial_callee_stat.number_of_LinphoneCallError, int, "%d"); - /*and remote should have received an update notification*/ - BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote+1, int, "%d"); - - - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - caller_params = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,(int*)&caller_params->has_video,FALSE)); - - sal_call_set_sdp_handling(inc_call->op, SalOpSDPNormal); - } - end_call(caller, callee); - - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); -#else - ms_warning("not tested because video not available"); -#endif -} - -static void outgoing_reinvite_with_invalid_ack_sdp(void) { -#ifdef VIDEO_ENABLED - LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc"); - LinphoneCall * out_call; - BC_ASSERT_TRUE(call(caller,callee)); - out_call = linphone_core_get_current_call(caller->lc); - - BC_ASSERT_PTR_NOT_NULL(out_call); - if (out_call) { - stats initial_caller_stat=caller->stat; - stats initial_callee_stat=callee->stat; - sal_call_set_sdp_handling(out_call->op, SalOpSDPSimulateError); /* will force a parse error for the ACK SDP*/ - BC_ASSERT_PTR_NOT_NULL(setup_video(caller, callee, TRUE)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning)); - /*Basically the negotiation failed but since the call was already running, we expect it to restore to - the previous state so error stats should not be changed*/ - BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallError,initial_callee_stat.number_of_LinphoneCallError, int, "%d"); - /*and remote should not have received any update notification*/ - BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote, int, "%d"); - - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); - - sal_call_set_sdp_handling(out_call->op, SalOpSDPNormal); - } - end_call(caller, callee); - - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); -#else - ms_warning("not tested because video not available"); -#endif -} - - static void call_with_paused_no_sdp_on_resume(void) { int dummy=0; LinphoneCoreManager* marie; @@ -4688,7 +3220,7 @@ end: linphone_core_manager_destroy(pauline); } -static void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ){ +void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); MSList* lcs = NULL; @@ -4760,10 +3292,6 @@ static void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ic linphone_core_manager_destroy(pauline); } -static void call_with_early_media_and_no_sdp_in_200_with_video(void){ - early_media_without_sdp_in_200_base(TRUE, FALSE); -} - static void call_with_early_media_and_no_sdp_in_200(void){ early_media_without_sdp_in_200_base(FALSE, FALSE); } @@ -4885,251 +3413,6 @@ static void call_with_transport_change_after_released(void) { static void unsucessfull_call_with_transport_change_after_released(void) { call_with_transport_change_base(FALSE); } -#ifdef VIDEO_ENABLED - -static void video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryption mode, bool_t no_sdp) { - LinphoneCoreManager* marie; - LinphoneCoreManager* pauline; - LinphoneCallParams *params; - const LinphoneCallParams *current_params; - MSList *lcs=NULL; - bool_t calls_ok; - - marie = linphone_core_manager_new( "marie_rc"); - pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_avpf_mode(pauline->lc,TRUE); - - // important: VP8 has really poor performances with the mire camera, at least - // on iOS - so when ever h264 is available, let's use it instead - if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { - disable_all_video_codecs_except_one(pauline->lc,"h264"); - disable_all_video_codecs_except_one(marie->lc,"h264"); - } - linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); - linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); - linphone_core_set_avpf_mode(marie->lc,TRUE); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - - video_call_base_2(marie,pauline,TRUE,mode,TRUE,TRUE); - - calls_ok = linphone_core_get_current_call(marie->lc) != NULL && linphone_core_get_current_call(pauline->lc) != NULL; - BC_ASSERT_TRUE(calls_ok); - - if (calls_ok) { - params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc)); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionInactive); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); - - linphone_core_update_call(marie->lc, linphone_core_get_current_call(marie->lc),params); - linphone_call_params_destroy(params); - - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,1)); - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1)); - - check_media_direction(marie,linphone_core_get_current_call(marie->lc),lcs,LinphoneMediaDirectionInactive,LinphoneMediaDirectionInactive); - check_media_direction(pauline,linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionInactive); - - if (no_sdp) { - linphone_core_enable_sdp_200_ack(marie->lc,TRUE); - } - - params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc)); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv); - linphone_core_update_call(marie->lc,linphone_core_get_current_call(marie->lc),params); - linphone_call_params_destroy(params); - - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); - - check_media_direction(marie,linphone_core_get_current_call(marie->lc),lcs,LinphoneMediaDirectionSendRecv,LinphoneMediaDirectionSendRecv); - check_media_direction(pauline,linphone_core_get_current_call(pauline->lc),lcs,LinphoneMediaDirectionSendRecv,LinphoneMediaDirectionSendRecv); - - /*assert that after pause and resume, SRTP is still being used*/ - current_params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(current_params) , mode, int, "%d"); - current_params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(current_params) , mode, int, "%d"); - - } - end_call(marie,pauline); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_with_re_invite_inactive_followed_by_re_invite(void) { - video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionNone,FALSE); -} - -static void video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp(void) { - video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionNone, TRUE); -} - -static void srtp_video_call_with_re_invite_inactive_followed_by_re_invite(void) { - if (ms_srtp_supported()) - video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionSRTP,FALSE); - else - ms_message("srtp_video_call_with_re_invite_inactive_followed_by_re_invite skipped, missing srtp support"); -} - -static void srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp(void) { - if (ms_srtp_supported()) - video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionSRTP, TRUE); - else - ms_message("srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp skipped, missing srtp support"); -} - -static void video_call_ice_params(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); - linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void audio_call_with_ice_with_video_policy_enabled(void){ - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneVideoPolicy vpol; - - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, TRUE); - vpol.automatically_accept = vpol.automatically_initiate = TRUE; - linphone_core_set_video_policy(marie->lc, &vpol); - vpol.automatically_accept = vpol.automatically_initiate = FALSE; - linphone_core_set_video_policy(pauline->lc, &vpol); - - linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); - linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); - - linphone_core_invite_address(pauline->lc, marie->identity); - if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end; - linphone_core_accept_call(marie->lc, linphone_core_get_current_call(marie->lc)); - /* - LinphoneCallParams *params; - params = linphone_core_create_call_params(marie->lc, linphone_core_get_current_call(marie->lc)); - linphone_call_params_enable_video(params, TRUE); - linphone_core_accept_call_with_params(marie->lc, linphone_core_get_current_call(marie->lc), params); - linphone_call_params_destroy(params);*/ - - /*wait for call to be established and ICE reINVITEs to be done */ - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); - - linphone_core_pause_call(marie->lc, linphone_core_get_current_call(marie->lc)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallPausedByRemote, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPaused, 1)); - - end_call(marie, pauline); -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - - -static void classic_video_entry_phone_setup(void) { - LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCallParams *early_media_params = NULL; - LinphoneCallParams *in_call_params = NULL; - LinphoneCall *callee_call = NULL; - LinphoneVideoPolicy vpol = { TRUE, TRUE }; - MSList *lcs = NULL; - int retry = 0; - bool_t ok; - - lcs = ms_list_append(lcs, caller_mgr->lc); - lcs = ms_list_append(lcs, callee_mgr->lc); - - linphone_core_enable_video_capture(caller_mgr->lc, TRUE); - linphone_core_enable_video_display(caller_mgr->lc, TRUE); - linphone_core_enable_video_capture(callee_mgr->lc, TRUE); - linphone_core_enable_video_display(callee_mgr->lc, TRUE); - linphone_core_set_avpf_mode(caller_mgr->lc, LinphoneAVPFEnabled); - linphone_core_set_avpf_mode(callee_mgr->lc, LinphoneAVPFEnabled); - linphone_core_set_video_policy(caller_mgr->lc, &vpol); - linphone_core_set_video_policy(callee_mgr->lc, &vpol); - - // important: VP8 has really poor performances with the mire camera, at least - // on iOS - so when ever h264 is available, let's use it instead - if (linphone_core_find_payload_type(caller_mgr->lc,"h264", -1, -1)!=NULL) { - disable_all_video_codecs_except_one(caller_mgr->lc,"h264"); - disable_all_video_codecs_except_one(callee_mgr->lc,"h264"); - } - - linphone_core_set_video_device(caller_mgr->lc, liblinphone_tester_mire_id); - linphone_core_set_video_device(callee_mgr->lc, liblinphone_tester_mire_id); - - BC_ASSERT_PTR_NOT_NULL(linphone_core_invite_address(caller_mgr->lc, callee_mgr->identity)); - - ok = wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1); - BC_ASSERT_TRUE(ok); - if (!ok) goto end; - BC_ASSERT_TRUE(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress == 1); - - callee_call = linphone_core_get_call_by_remote_address2(callee_mgr->lc, caller_mgr->identity); - early_media_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); - linphone_call_params_set_audio_direction(early_media_params, LinphoneMediaDirectionInactive); - linphone_call_params_set_video_direction(early_media_params, LinphoneMediaDirectionRecvOnly); - linphone_core_accept_early_media_with_params(callee_mgr->lc, callee_call, early_media_params); - linphone_call_params_destroy(early_media_params); - - while ((caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia != 1) && (retry++ < 100)) { - linphone_core_iterate(caller_mgr->lc); - linphone_core_iterate(callee_mgr->lc); - ms_usleep(20000); - } - BC_ASSERT_TRUE(caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia == 1); - BC_ASSERT_TRUE(callee_mgr->stat.number_of_LinphoneCallIncomingEarlyMedia == 1); - - check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionRecvOnly); - callee_call = linphone_core_get_call_by_remote_address2(callee_mgr->lc, caller_mgr->identity); - in_call_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); - linphone_call_params_set_audio_direction(in_call_params, LinphoneMediaDirectionSendRecv); - linphone_call_params_set_video_direction(in_call_params, LinphoneMediaDirectionSendRecv); - linphone_core_accept_call_with_params(callee_mgr->lc, callee_call, in_call_params); - linphone_call_params_destroy(in_call_params); - - BC_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallConnected, 1)); - BC_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallConnected, 1)); - - ok = wait_for_until(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) - && wait_for_until(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallStreamsRunning, 1, 2000); - BC_ASSERT_TRUE(ok); - if (!ok) goto end; - check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionSendRecv); - - callee_call = linphone_core_get_current_call(callee_mgr->lc); - in_call_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); - linphone_call_params_set_audio_direction(in_call_params, LinphoneMediaDirectionRecvOnly); - linphone_call_params_set_video_direction(in_call_params, LinphoneMediaDirectionSendOnly); - linphone_core_update_call(callee_mgr->lc, callee_call, in_call_params); - linphone_call_params_destroy(in_call_params); - - ok = wait_for_until(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 2, 2000) - && wait_for_until(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallStreamsRunning, 2, 2000); - BC_ASSERT_TRUE(ok); - if (!ok) goto end; - callee_call = linphone_core_get_current_call(callee_mgr->lc); - check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionRecvOnly, LinphoneMediaDirectionSendOnly); - - end_call(caller_mgr, callee_mgr); - -end: - linphone_core_manager_destroy(callee_mgr); - linphone_core_manager_destroy(caller_mgr); - ms_list_free(lcs); -} -#endif #if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(ANDROID) static void completion_cb(void *user_data, int percentage){ @@ -5368,7 +3651,7 @@ static void call_with_rtp_io_mode(void) { LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphonePlayer *player; char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav"); - char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_rtp_io_mode", "wav"); + char *recordpath = bc_tester_file("record-call_with_rtp_io_mode.wav"); bool_t call_ok; int attempts; double similar=1; @@ -5627,7 +3910,7 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { // The following are only used for the record test LinphonePlayer *player; char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav"); // File to be played - char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_file_player", "wav"); // File to record the received sound + char *recordpath = bc_tester_file("record-call_with_file_player.wav"); // File to record the received sound double similar = 1; // The factor of similarity between the played file and the one recorded const double threshold = 0.85; // Minimum similarity value to consider the record file equal to the one sent @@ -6012,7 +4295,7 @@ static void call_logs_if_no_db_set(void) { static void call_logs_migrate(void) { LinphoneCoreManager* laure = linphone_core_manager_new("laure_call_logs_rc"); - char *logs_db = create_filepath(bc_tester_get_writable_dir_prefix(), "call_logs", "db"); + char *logs_db = bc_tester_file("call_logs.db"); int i = 0; int incoming_count = 0, outgoing_count = 0, missed_count = 0, aborted_count = 0, decline_count = 0, video_enabled_count = 0; @@ -6074,7 +4357,7 @@ static void call_logs_migrate(void) { static void call_logs_sqlite_storage(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - char *logs_db = create_filepath(bc_tester_get_writable_dir_prefix(), "call_logs", "db"); + char *logs_db = bc_tester_file("call_logs.db"); MSList *logs = NULL; LinphoneCallLog *call_log = NULL; LinphoneAddress *laure = NULL; @@ -6500,13 +4783,6 @@ test_t call_tests[] = { TEST_NO_TAG("Call without SDP and ACK without SDP", call_with_no_sdp_ack_without_sdp), TEST_NO_TAG("Call paused resumed", call_paused_resumed), TEST_NO_TAG("Call paused resumed with sip packets looses", call_paused_resumed_with_sip_packets_losses), -#ifdef VIDEO_ENABLED - TEST_NO_TAG("Call paused resumed with video", call_paused_resumed_with_video), - TEST_NO_TAG("Call paused resumed with video no sdp ack", call_paused_resumed_with_no_sdp_ack), - TEST_NO_TAG("Call paused resumed with video no sdk ack using video policy for resume offers", call_paused_resumed_with_no_sdp_ack_using_video_policy), - TEST_NO_TAG("Call paused, updated and resumed with video no sdk ack using video policy for resume offers", call_paused_updated_resumed_with_no_sdp_ack_using_video_policy), - TEST_NO_TAG("Call paused, updated and resumed with video no sdk ack using video policy for resume offers with accept call update", call_paused_updated_resumed_with_no_sdp_ack_using_video_policy_and_accept_call_update), -#endif TEST_NO_TAG("Call paused by both parties", call_paused_by_both), TEST_NO_TAG("Call paused resumed with loss", call_paused_resumed_with_loss), TEST_NO_TAG("Call paused resumed from callee", call_paused_resumed_from_callee), @@ -6516,67 +4792,11 @@ test_t call_tests[] = { TEST_NO_TAG("ZRTP Cipher call", zrtp_cipher_call), TEST_NO_TAG("DTLS SRTP call", dtls_srtp_call), TEST_NO_TAG("DTLS SRTP call with media relay", dtls_srtp_call_with_media_realy), - TEST_NO_TAG("ZRTP video call", zrtp_video_call), TEST_NO_TAG("SRTP call with declined srtp", call_with_declined_srtp), TEST_NO_TAG("SRTP call paused and resumed", call_srtp_paused_and_resumed), TEST_NO_TAG("Call with file player", call_with_file_player), TEST_NO_TAG("Call with mkv file player", call_with_mkv_file_player), TEST_ONE_TAG("Audio call with ICE no matching audio codecs", audio_call_with_ice_no_matching_audio_codecs, "ICE"), -#ifdef VIDEO_ENABLED - TEST_NO_TAG("Simple video call AVPF", video_call_avpf), - TEST_NO_TAG("Simple video call implicit AVPF both", video_call_using_policy_AVPF_implicit_caller_and_callee), - TEST_NO_TAG("Simple video call disable implicit AVPF on callee", video_call_disable_implicit_AVPF_on_callee), - TEST_NO_TAG("Simple video call disable implicit AVPF on caller", video_call_disable_implicit_AVPF_on_caller), - TEST_NO_TAG("Simple video call AVPF to implicit AVPF", video_call_AVPF_to_implicit_AVPF), - TEST_NO_TAG("Simple video call implicit AVPF to AVPF", video_call_implicit_AVPF_to_AVPF), - TEST_NO_TAG("Simple video call", video_call), - TEST_NO_TAG("Simple video call without rtcp",video_call_without_rtcp), - TEST_NO_TAG("Simple ZRTP video call", video_call_zrtp), - TEST_NO_TAG("Simple DTLS video call", video_call_dtls), - TEST_NO_TAG("Simple video call using policy", video_call_using_policy), - TEST_NO_TAG("Video call using policy with callee video disabled", video_call_using_policy_with_callee_video_disabled), - TEST_NO_TAG("Video call using policy with caller video disabled", video_call_using_policy_with_caller_video_disabled), - TEST_NO_TAG("Video call without SDP", video_call_no_sdp), - TEST_ONE_TAG("SRTP ice video call", srtp_video_ice_call, "ICE"), - TEST_ONE_TAG("ZRTP ice video call", zrtp_video_ice_call, "ICE"), - TEST_NO_TAG("Call with video added", call_with_video_added), - TEST_NO_TAG("Call with video added 2", call_with_video_added_2), - TEST_NO_TAG("Call with video added (random ports)", call_with_video_added_random_ports), - TEST_NO_TAG("Call with several video switches", call_with_several_video_switches), - TEST_NO_TAG("SRTP call with several video switches", srtp_call_with_several_video_switches), - TEST_NO_TAG("Call with video declined", call_with_declined_video), - TEST_NO_TAG("Call with video declined despite policy", call_with_declined_video_despite_policy), - TEST_NO_TAG("Call with video declined using policy", call_with_declined_video_using_policy), - TEST_NO_TAG("Video early-media call", video_early_media_call), - TEST_NO_TAG("Call with multiple early media", multiple_early_media), - TEST_ONE_TAG("Call with ICE from video to non-video", call_with_ice_video_to_novideo, "ICE"), - TEST_ONE_TAG("Call with ICE and video added", call_with_ice_video_added, "ICE"), - TEST_ONE_TAG("Call with ICE and video added 2", call_with_ice_video_added_2, "ICE"), - TEST_ONE_TAG("Call with ICE and video added 3", call_with_ice_video_added_3, "ICE"), - TEST_ONE_TAG("Call with ICE and video added and refused", call_with_ice_video_added_and_refused, "ICE"), - TEST_ONE_TAG("Call with ICE and video added with video policies to false", call_with_ice_video_added_with_video_policies_to_false, "ICE"), -#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT - TEST_ONE_TAG("Call with ICE, video and realtime text", call_with_ice_video_and_rtt, "ICE"), -#endif - TEST_ONE_TAG("Video call with ICE accepted using call params", video_call_ice_params, "ICE"), - TEST_ONE_TAG("Audio call with ICE paused with caller video policy enabled", audio_call_with_ice_with_video_policy_enabled, "ICE"), - TEST_NO_TAG("Video call recording (H264)", video_call_recording_h264_test), - TEST_NO_TAG("Video call recording (VP8)", video_call_recording_vp8_test), - TEST_NO_TAG("Snapshot", video_call_snapshot), - TEST_NO_TAG("Video call with early media and no matching audio codecs", video_call_with_early_media_no_matching_audio_codecs), - TEST_NO_TAG("DTLS SRTP video call", dtls_srtp_video_call), - TEST_ONE_TAG("DTLS SRTP ice video call", dtls_srtp_ice_video_call, "ICE"), - TEST_ONE_TAG("DTLS SRTP ice video call with relay", dtls_srtp_ice_video_call_with_relay, "ICE"), - TEST_NO_TAG("Video call with limited bandwidth", video_call_limited_bandwidth), - TEST_NO_TAG("Video call accepted in send only", accept_call_in_send_only), - TEST_ONE_TAG("Video call accepted in send only with ice", accept_call_in_send_only_with_ice, "ICE"), - TEST_NO_TAG("2 Video call accepted in send only", two_accepted_call_in_send_only), - TEST_NO_TAG("Video call with re-invite(inactive) followed by re-invite", video_call_with_re_invite_inactive_followed_by_re_invite), - TEST_NO_TAG("Video call with re-invite(inactive) followed by re-invite(no sdp)", video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp), - TEST_NO_TAG("SRTP Video call with re-invite(inactive) followed by re-invite", srtp_video_call_with_re_invite_inactive_followed_by_re_invite), - TEST_NO_TAG("SRTP Video call with re-invite(inactive) followed by re-invite(no sdp)", srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp), - TEST_NO_TAG("Classic video entry phone setup", classic_video_entry_phone_setup), -#endif TEST_ONE_TAG("SRTP ice call", srtp_ice_call, "ICE"), TEST_ONE_TAG("ZRTP ice call", zrtp_ice_call, "ICE"), TEST_ONE_TAG("ZRTP ice call with relay", zrtp_ice_call_with_relay, "ICE"), @@ -6605,21 +4825,17 @@ test_t call_tests[] = { TEST_NO_TAG("Call redirected by callee", call_redirect), TEST_NO_TAG("Call with specified codec bitrate", call_with_specified_codec_bitrate), TEST_NO_TAG("Call with no audio codec", call_with_no_audio_codec), - TEST_NO_TAG("Video call with no audio and no video codec", video_call_with_no_audio_and_no_video_codec), TEST_NO_TAG("Call with in-dialog UPDATE request", call_with_in_dialog_update), TEST_NO_TAG("Call with in-dialog very early call request", call_with_very_early_call_update), TEST_NO_TAG("Call with in-dialog codec change", call_with_in_dialog_codec_change), TEST_NO_TAG("Call with in-dialog codec change no sdp", call_with_in_dialog_codec_change_no_sdp), TEST_NO_TAG("Call with pause no SDP on resume", call_with_paused_no_sdp_on_resume), TEST_NO_TAG("Call with early media and no SDP in 200 Ok", call_with_early_media_and_no_sdp_in_200), - TEST_NO_TAG("Call with early media and no SDP in 200 Ok with video", call_with_early_media_and_no_sdp_in_200_with_video), TEST_ONE_TAG("Call with ICE and no SDP in 200 OK", call_with_early_media_ice_and_no_sdp_in_200, "ICE"), TEST_NO_TAG("Call with custom supported tags", call_with_custom_supported_tags), TEST_NO_TAG("Call log from taken from asserted id", call_log_from_taken_from_p_asserted_id), TEST_NO_TAG("Incoming INVITE with invalid SDP", incoming_invite_with_invalid_sdp), TEST_NO_TAG("Outgoing INVITE with invalid ACK SDP", outgoing_invite_with_invalid_sdp), - TEST_NO_TAG("Incoming REINVITE with invalid SDP in ACK", incoming_reinvite_with_invalid_ack_sdp), - TEST_NO_TAG("Outgoing REINVITE with invalid SDP in ACK", outgoing_reinvite_with_invalid_ack_sdp), TEST_NO_TAG("Call with generic CN", call_with_generic_cn), TEST_NO_TAG("Call with transport change after released", call_with_transport_change_after_released), TEST_NO_TAG("Unsuccessful call with transport change after released", unsucessfull_call_with_transport_change_after_released), diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c new file mode 100644 index 000000000..ea4cfb5ca --- /dev/null +++ b/tester/call_video_tester.c @@ -0,0 +1,1782 @@ +/* + liblinphone_tester - liblinphone test suite + Copyright (C) 2013 Belledonne Communications SARL + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "linphonecore.h" +#include "liblinphone_tester.h" +#include "private.h" + +#ifdef VIDEO_ENABLED +static void call_paused_resumed_with_video_base_call_cb(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message) { + if (cstate == LinphoneCallUpdatedByRemote) { + LinphoneCallParams *params = linphone_core_create_call_params(lc, call); + linphone_call_params_enable_video(params, TRUE); + ms_message (" New state LinphoneCallUpdatedByRemote on call [%p], accepting with video on",call); + BC_ASSERT_NOT_EQUAL(linphone_core_accept_call_update(lc, call, params), 0, int, "%i"); + linphone_call_params_destroy(params); + } +} +/*this test makes sure that pause/resume will not bring up video by accident*/ +static void call_paused_resumed_with_video_base(bool_t sdp_200_ack + ,bool_t use_video_policy_for_re_invite_sdp_200 + ,bool_t resume_in_audio_send_only_video_inactive_first + ,bool_t with_call_accept){ + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall* call_pauline, *call_marie; + MSList *lcs = NULL; + LinphoneVideoPolicy vpol; + bool_t call_ok; + LinphoneCoreVTable *vtable = linphone_core_v_table_new(); + vtable->call_state_changed = call_paused_resumed_with_video_base_call_cb; + lcs = ms_list_append(lcs, pauline->lc); + lcs = ms_list_append(lcs, marie->lc); + + vpol.automatically_accept = FALSE; + vpol.automatically_initiate = TRUE; /* needed to present a video mline*/ + + linphone_core_set_video_policy(marie->lc, &vpol); + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + + vpol.automatically_accept = FALSE; + vpol.automatically_initiate = TRUE; + + linphone_core_set_video_policy(pauline->lc, &vpol); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); + + BC_ASSERT_TRUE((call_ok=call(marie, pauline))); + + if (!call_ok) goto end; + + call_pauline = linphone_core_get_current_call(pauline->lc); + call_marie = linphone_core_get_current_call(marie->lc); + + wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); + + linphone_core_pause_call(pauline->lc,call_pauline); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1)); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_remote_params(call_marie))); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1)); + + /*stay in pause a little while in order to generate traffic*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); + + /*check if video stream is still offered even if disabled*/ + + BC_ASSERT_EQUAL(call_pauline->localdesc->nb_streams, 2, int, "%i"); + BC_ASSERT_EQUAL(call_marie->localdesc->nb_streams, 2, int, "%i"); + + linphone_core_enable_sdp_200_ack(pauline->lc,sdp_200_ack); + + if (use_video_policy_for_re_invite_sdp_200) { + LpConfig *marie_lp; + marie_lp = linphone_core_get_config(marie->lc); + lp_config_set_int(marie_lp,"sip","sdp_200_ack_follow_video_policy",1); + } + /*now pauline wants to resume*/ + if (resume_in_audio_send_only_video_inactive_first) { + LinphoneCallParams *params = linphone_core_create_call_params(pauline->lc, call_pauline); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly); + linphone_core_update_call(pauline->lc,call_pauline,params); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,2)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdating,1)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv); + if (with_call_accept) { + linphone_core_add_listener(marie->lc, vtable); + } + linphone_core_update_call(pauline->lc,call_pauline,params); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3)); + linphone_call_params_destroy(params); + } else { + linphone_core_resume_call(pauline->lc, call_pauline); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallResuming,1)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + } + + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); + + if (use_video_policy_for_re_invite_sdp_200) { + /*make sure video was offered*/ + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_remote_params(call_pauline))); + } else { + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_marie))); + } + end_call(marie, pauline); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + ms_list_free(lcs); +} +static void call_paused_resumed_with_video(void){ + call_paused_resumed_with_video_base(FALSE, FALSE,FALSE,FALSE); +} + +static void call_paused_resumed_with_no_sdp_ack(void){ + call_paused_resumed_with_video_base(TRUE, FALSE,FALSE,FALSE); +} +static void call_paused_resumed_with_no_sdp_ack_using_video_policy(void){ + call_paused_resumed_with_video_base(TRUE, TRUE,FALSE,FALSE); +} +static void call_paused_updated_resumed_with_no_sdp_ack_using_video_policy(void){ + call_paused_resumed_with_video_base(TRUE, TRUE,TRUE,FALSE); +} +static void call_paused_updated_resumed_with_no_sdp_ack_using_video_policy_and_accept_call_update(void){ + call_paused_resumed_with_video_base(TRUE, TRUE,TRUE,TRUE); +} + +static void zrtp_video_call(void) { + call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyNoFirewall,FALSE); +} + +static LinphoneCall* setup_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy) { + LinphoneVideoPolicy caller_policy; + LinphoneCallParams* callee_params; + LinphoneCall* call_obj; + + if (!linphone_core_get_current_call(callee->lc) || linphone_call_get_state(linphone_core_get_current_call(callee->lc)) != LinphoneCallStreamsRunning + || !linphone_core_get_current_call(caller->lc) || linphone_call_get_state(linphone_core_get_current_call(caller->lc)) != LinphoneCallStreamsRunning ) { + ms_warning("bad state for adding video"); + return NULL; + } + + if (change_video_policy) { + caller_policy.automatically_accept=TRUE; + caller_policy.automatically_initiate=TRUE; + linphone_core_set_video_policy(caller->lc,&caller_policy); + } + linphone_core_enable_video_capture(callee->lc, TRUE); + linphone_core_enable_video_display(callee->lc, TRUE); + linphone_core_enable_video_capture(caller->lc, TRUE); + linphone_core_enable_video_display(caller->lc, FALSE); + + if ((call_obj = linphone_core_get_current_call(callee->lc))) { + callee_params = linphone_core_create_call_params(callee->lc, call_obj); + /*add video*/ + linphone_call_params_enable_video(callee_params,TRUE); + linphone_core_update_call(callee->lc,call_obj,callee_params); + linphone_call_params_destroy(callee_params); + } + return call_obj; +} + +bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy) { + stats initial_caller_stat=caller->stat; + stats initial_callee_stat=callee->stat; + const LinphoneVideoPolicy *video_policy; + LinphoneCall *call_obj; + if ((call_obj=setup_video(caller, callee, change_video_policy))){ + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning+1)); + + video_policy = linphone_core_get_video_policy(caller->lc); + if (video_policy->automatically_accept) { + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); + } else { + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); + } + if (linphone_core_get_media_encryption(caller->lc) != LinphoneMediaEncryptionNone + && linphone_core_get_media_encryption(callee->lc) != LinphoneMediaEncryptionNone) { + const LinphoneCallParams* call_param; + + switch (linphone_core_get_media_encryption(caller->lc)) { + case LinphoneMediaEncryptionZRTP: + case LinphoneMediaEncryptionDTLS: + /*wait for encryption to be on, in case of zrtp/dtls, it can take a few seconds*/ + wait_for(callee->lc,caller->lc,&caller->stat.number_of_LinphoneCallEncryptedOn,initial_caller_stat.number_of_LinphoneCallEncryptedOn+1); + break; + case LinphoneMediaEncryptionNone: + case LinphoneMediaEncryptionSRTP: + break; + } + switch (linphone_core_get_media_encryption(callee->lc)) { + case LinphoneMediaEncryptionZRTP: + case LinphoneMediaEncryptionDTLS: + wait_for(callee->lc,caller->lc,&callee->stat.number_of_LinphoneCallEncryptedOn,initial_callee_stat.number_of_LinphoneCallEncryptedOn+1); + break; + case LinphoneMediaEncryptionNone: + case LinphoneMediaEncryptionSRTP: + break; + } + + call_param = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); + call_param = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); + + } + + if (video_policy->automatically_accept) { + linphone_call_set_next_video_frame_decoded_callback(call_obj,linphone_call_iframe_decoded_cb,callee->lc); + /*send vfu*/ + linphone_call_send_vfu_request(call_obj); + return wait_for(caller->lc,callee->lc,&callee->stat.number_of_IframeDecoded,initial_callee_stat.number_of_IframeDecoded+1); + } else { + return TRUE; + } + } + return FALSE; +} + +static bool_t remove_video(LinphoneCoreManager *caller, LinphoneCoreManager *callee) { + LinphoneCallParams *callee_params; + LinphoneCall *call_obj; + stats initial_caller_stat = caller->stat; + stats initial_callee_stat = callee->stat; + + if (!linphone_core_get_current_call(callee->lc) + || (linphone_call_get_state(linphone_core_get_current_call(callee->lc)) != LinphoneCallStreamsRunning) + || !linphone_core_get_current_call(caller->lc) + || (linphone_call_get_state(linphone_core_get_current_call(caller->lc)) != LinphoneCallStreamsRunning)) { + ms_warning("bad state for removing video"); + return FALSE; + } + + if ((call_obj = linphone_core_get_current_call(callee->lc))) { + callee_params = linphone_core_create_call_params(callee->lc, call_obj); + /* Remove video. */ + linphone_call_params_enable_video(callee_params, FALSE); + linphone_core_update_call(callee->lc, call_obj, callee_params); + linphone_call_params_destroy(callee_params); + + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallUpdatedByRemote, initial_caller_stat.number_of_LinphoneCallUpdatedByRemote + 1)); + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallUpdating, initial_callee_stat.number_of_LinphoneCallUpdating + 1)); + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, initial_callee_stat.number_of_LinphoneCallStreamsRunning + 1)); + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, initial_caller_stat.number_of_LinphoneCallStreamsRunning + 1)); + + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); + + return TRUE; + } + return FALSE; +} + +static void call_with_video_added(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + + BC_ASSERT_TRUE((call_ok=call(pauline,marie))); + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + + end_call(pauline, marie); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_video_added_2(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + /*in this variant marie is already in automatically accept*/ + LinphoneVideoPolicy marie_policy; + marie_policy.automatically_accept=TRUE; + + + linphone_core_set_video_policy(marie->lc,&marie_policy); + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, FALSE); + + BC_ASSERT_TRUE(call_ok=call(pauline,marie)); + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(marie,pauline, TRUE)); + + end_call(pauline, marie); +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_video_added_random_ports(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + + linphone_core_set_audio_port(marie->lc,-1); + linphone_core_set_video_port(marie->lc,-1); + linphone_core_set_audio_port(pauline->lc,-1); + linphone_core_set_video_port(pauline->lc,-1); + + BC_ASSERT_TRUE(call_ok=call(pauline,marie)); + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + end_call(pauline, marie); +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_several_video_switches(void) { + int dummy = 0; + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + BC_ASSERT_TRUE(call_ok=call(pauline,marie)); + + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ + BC_ASSERT_TRUE(remove_video(pauline,marie)); + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ + BC_ASSERT_TRUE(remove_video(pauline,marie)); + /**/ + end_call(pauline, marie); +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void srtp_call_with_several_video_switches(void) { + int dummy = 0; + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + + if (linphone_core_media_encryption_supported(marie->lc, LinphoneMediaEncryptionSRTP)) { + linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionSRTP); + linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionSRTP); + + BC_ASSERT_TRUE(call_ok=call(pauline,marie)); + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ + BC_ASSERT_TRUE(remove_video(pauline,marie)); + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ + BC_ASSERT_TRUE(remove_video(pauline,marie)); + /**/ + end_call(pauline, marie); + } else { + ms_warning("Not tested because SRTP is not available."); + } +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_declined_video_base(bool_t using_policy) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall* marie_call; + LinphoneCall* pauline_call; + LinphoneVideoPolicy marie_policy, pauline_policy; + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + bool_t call_ok; + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); + + if (using_policy) { + pauline_policy.automatically_initiate=TRUE; + pauline_policy.automatically_accept=FALSE; + marie_policy.automatically_initiate=FALSE; + marie_policy.automatically_accept=FALSE; + + linphone_core_set_video_policy(marie->lc,&marie_policy); + linphone_core_set_video_policy(pauline->lc,&pauline_policy); + } + + caller_test_params.base=linphone_core_create_call_params(pauline->lc, NULL); + if (!using_policy) + linphone_call_params_enable_video(caller_test_params.base,TRUE); + + if (!using_policy){ + callee_test_params.base=linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_video(callee_test_params.base,FALSE); + } + + BC_ASSERT_TRUE((call_ok=call_with_params2(pauline,marie,&caller_test_params,&callee_test_params,using_policy))); + if (!call_ok) goto end; + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + marie_call=linphone_core_get_current_call(marie->lc); + pauline_call=linphone_core_get_current_call(pauline->lc); + + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call))); + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call))); + + end_call(pauline, marie); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} +static void call_with_declined_video(void) { + call_with_declined_video_base(FALSE); +} + +static void call_with_declined_video_despite_policy(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall* marie_call; + LinphoneCall* pauline_call; + LinphoneVideoPolicy marie_policy, pauline_policy; + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + bool_t call_ok; + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); + + pauline_policy.automatically_initiate=TRUE; + pauline_policy.automatically_accept=TRUE; + marie_policy.automatically_initiate=TRUE; + marie_policy.automatically_accept=TRUE; + + linphone_core_set_video_policy(marie->lc,&marie_policy); + linphone_core_set_video_policy(pauline->lc,&pauline_policy); + + caller_test_params.base=linphone_core_create_call_params(pauline->lc, NULL); + + callee_test_params.base=linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_video(callee_test_params.base,FALSE); + + BC_ASSERT_TRUE((call_ok=call_with_params2(pauline,marie,&caller_test_params,&callee_test_params,FALSE))); + if (!call_ok) goto end; + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + marie_call=linphone_core_get_current_call(marie->lc); + pauline_call=linphone_core_get_current_call(pauline->lc); + + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call))); + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call))); + + end_call(pauline, marie); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_declined_video_using_policy(void) { + call_with_declined_video_base(TRUE); +} + + +void video_call_base_2(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + LinphoneCall* callee_call; + LinphoneCall* caller_call; + LinphoneVideoPolicy callee_policy, caller_policy; + + if (using_policy) { + callee_policy.automatically_initiate=FALSE; + callee_policy.automatically_accept=TRUE; + caller_policy.automatically_initiate=TRUE; + caller_policy.automatically_accept=FALSE; + + linphone_core_set_video_policy(callee->lc,&callee_policy); + linphone_core_set_video_policy(caller->lc,&caller_policy); + } + + linphone_core_enable_video_display(callee->lc, callee_video_enabled); + linphone_core_enable_video_capture(callee->lc, callee_video_enabled); + + linphone_core_enable_video_display(caller->lc, caller_video_enabled); + linphone_core_enable_video_capture(caller->lc, caller_video_enabled); + + if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */ + char *path = bc_tester_file("certificates-marie"); + callee->lc->user_certificates_path = ms_strdup(path); + bc_free(path); + path = bc_tester_file("certificates-pauline"); + caller->lc->user_certificates_path = ms_strdup(path); + bc_free(path); + belle_sip_mkdir(callee->lc->user_certificates_path); + belle_sip_mkdir(caller->lc->user_certificates_path); + } + + linphone_core_set_media_encryption(callee->lc,mode); + linphone_core_set_media_encryption(caller->lc,mode); + + caller_test_params.base=linphone_core_create_call_params(caller->lc, NULL); + if (!using_policy) + linphone_call_params_enable_video(caller_test_params.base,TRUE); + + if (!using_policy){ + callee_test_params.base=linphone_core_create_call_params(callee->lc, NULL); + linphone_call_params_enable_video(callee_test_params.base,TRUE); + } + + BC_ASSERT_TRUE(call_with_params2(caller,callee,&caller_test_params,&callee_test_params,using_policy)); + callee_call=linphone_core_get_current_call(callee->lc); + caller_call=linphone_core_get_current_call(caller->lc); + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + + if (callee_call && caller_call ) { + if (callee_video_enabled && caller_video_enabled) { + BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); + BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); + + /*check video path*/ + linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); + linphone_call_send_vfu_request(callee_call); + BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); + } else { + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); + } + liblinphone_tester_check_rtcp(callee,caller); + } +} + + +static void check_fir(LinphoneCoreManager* caller,LinphoneCoreManager* callee ){ + LinphoneCall* callee_call; + LinphoneCall* caller_call; + + callee_call=linphone_core_get_current_call(callee->lc); + caller_call=linphone_core_get_current_call(caller->lc); + + /*check video path is established in both directions. + Indeed, FIR are ignored until the first RTP packet is received, because SSRC is not known.*/ + linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); + linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); + + BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); + BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); + + linphone_call_send_vfu_request(callee_call); + + if (rtp_session_avpf_enabled(callee_call->sessions->rtp_session)){ + BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&caller_call->videostream->ms_video_stat.counter_rcvd_fir, 1)); + }else{ + BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&caller_call->videostream->ms_video_stat.counter_rcvd_fir, 0)); + } + ms_message ("check_fir : [%p] received %d FIR ",&caller_call ,caller_call->videostream->ms_video_stat.counter_rcvd_fir); + ms_message ("check_fir : [%p] stat number of iframe decoded %d ",&callee_call, callee->stat.number_of_IframeDecoded); + + linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); + linphone_call_send_vfu_request(caller_call); + BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); + + if (rtp_session_avpf_enabled(caller_call->sessions->rtp_session)) { + if (rtp_session_avpf_enabled(callee_call->sessions->rtp_session)){ + BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&callee_call->videostream->ms_video_stat.counter_rcvd_fir, 1)); + } + }else{ + BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&callee_call->videostream->ms_video_stat.counter_rcvd_fir, 0)); + } + ms_message ("check_fir : [%p] received %d FIR ",&callee_call ,callee_call->videostream->ms_video_stat.counter_rcvd_fir); + ms_message ("check_fir : [%p] stat number of iframe decoded %d ",&caller_call, caller->stat.number_of_IframeDecoded); + +} + +void video_call_base_3(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + + LinphoneCall* callee_call; + LinphoneCall* caller_call; + LinphoneVideoPolicy callee_policy, caller_policy; + + if (using_policy) { + callee_policy.automatically_initiate=FALSE; + callee_policy.automatically_accept=TRUE; + caller_policy.automatically_initiate=TRUE; + caller_policy.automatically_accept=FALSE; + + linphone_core_set_video_policy(callee->lc,&callee_policy); + linphone_core_set_video_policy(caller->lc,&caller_policy); + } + + linphone_core_enable_video_display(callee->lc, callee_video_enabled); + linphone_core_enable_video_capture(callee->lc, callee_video_enabled); + + linphone_core_enable_video_display(caller->lc, caller_video_enabled); + linphone_core_enable_video_capture(caller->lc, caller_video_enabled); + + if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */ + char *path = bc_tester_file("certificates-marie"); + callee->lc->user_certificates_path = ms_strdup(path); + bc_free(path); + path = bc_tester_file("certificates-pauline"); + caller->lc->user_certificates_path = ms_strdup(path); + bc_free(path); + belle_sip_mkdir(callee->lc->user_certificates_path); + belle_sip_mkdir(caller->lc->user_certificates_path); + } + + linphone_core_set_media_encryption(callee->lc,mode); + linphone_core_set_media_encryption(caller->lc,mode); + /* Create call params */ + caller_test_params.base=linphone_core_create_call_params(caller->lc, NULL); + + if (!using_policy) + linphone_call_params_enable_video(caller_test_params.base,TRUE); + + if (!using_policy){ + callee_test_params.base=linphone_core_create_call_params(callee->lc, NULL); + linphone_call_params_enable_video(callee_test_params.base,TRUE); + } + + BC_ASSERT_TRUE(call_with_params2(caller,callee,&caller_test_params,&callee_test_params,using_policy)); + callee_call=linphone_core_get_current_call(callee->lc); + caller_call=linphone_core_get_current_call(caller->lc); + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + + if (callee_call && caller_call ) { + if (callee_video_enabled && caller_video_enabled) { + check_fir(caller,callee); + } else { + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); + } + liblinphone_tester_check_rtcp(callee,caller); + } +} + + + +static void video_call_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { + video_call_base_2(pauline,marie,using_policy,mode,callee_video_enabled,caller_video_enabled); + end_call(pauline, marie); +} + +static void video_call(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_without_rtcp(void) { + LpConfig *lp; + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + lp = linphone_core_get_config(marie->lc); + lp_config_set_int(lp,"rtp","rtcp_enabled",0); + + lp = linphone_core_get_config(pauline->lc); + lp_config_set_int(lp,"rtp","rtcp_enabled",0); + + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_disable_implicit_AVPF_on_callee(void) { + LinphoneCoreManager* callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + LpConfig *callee_lp; + const LinphoneCallParams *params, *params2; + + callee_lp = linphone_core_get_config(callee->lc); + lp_config_set_int(callee_lp,"rtp","rtcp_fb_implicit_rtcp_fb",0); + + video_call_base_3(caller,callee,TRUE,LinphoneMediaEncryptionNone,TRUE,TRUE); + if(BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(callee->lc))) { + params = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); + BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), "RTP/AVP"); + } + if(BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(caller->lc))) { + params2 =linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); + BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params2), "RTP/AVP"); + } + end_call(caller, callee); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + + +static void video_call_disable_implicit_AVPF_on_caller(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + LpConfig *caller_lp; + const LinphoneCallParams *params, *params2; + + caller_lp = linphone_core_get_config(caller->lc); + lp_config_set_int(caller_lp, "rtp", "rtcp_fb_implicit_rtcp_fb", 0); + + video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); + params = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); + BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), "RTP/AVP"); + params2 = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); + BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params2), "RTP/AVP"); + end_call(caller, callee); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); + +} + +static void video_call_AVPF_to_implicit_AVPF(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_avpf_mode(caller->lc, LinphoneAVPFEnabled); + video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); + end_call(caller, callee); + + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); + +} + +static void video_call_implicit_AVPF_to_AVPF(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_avpf_mode(callee->lc, LinphoneAVPFEnabled); + video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); + end_call(caller, callee); + + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); + +} + +static void video_call_using_policy_AVPF_implicit_caller_and_callee(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base_3(caller, callee, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); + end_call(caller, callee); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + +static void video_call_base_avpf(LinphoneCoreManager *caller, LinphoneCoreManager *callee, bool_t using_policy, LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { + linphone_core_set_avpf_mode(caller->lc, LinphoneAVPFEnabled); + linphone_core_set_avpf_mode(callee->lc, LinphoneAVPFEnabled); + video_call_base_3(caller, callee, using_policy, mode, callee_video_enabled, caller_video_enabled); + end_call(caller, callee); +} + +static void video_call_avpf(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + video_call_base_avpf(caller, callee, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); + +} + +static void video_call_zrtp(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + if (linphone_core_media_encryption_supported(marie->lc,LinphoneMediaEncryptionZRTP)) { + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionZRTP,TRUE,TRUE); + } else + ms_message("Skipping video_call_zrtp"); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_dtls(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + if (linphone_core_media_encryption_supported(pauline->lc,LinphoneMediaEncryptionDTLS)) { + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionDTLS,TRUE,TRUE); + } else + ms_message("Skipping video_call_dtls"); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + +} + + + +static void video_call_using_policy(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base(pauline,marie,TRUE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_using_policy_with_callee_video_disabled(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base(marie,pauline,TRUE,LinphoneMediaEncryptionNone,FALSE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_using_policy_with_caller_video_disabled(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base(marie,pauline,TRUE,LinphoneMediaEncryptionNone,TRUE,FALSE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_no_sdp(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + linphone_core_enable_sdp_200_ack(pauline->lc,TRUE); + video_call_base(pauline,marie,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_ice_video_to_novideo(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneVideoPolicy vpol={0}; + vpol.automatically_initiate=TRUE; + linphone_core_set_video_policy(pauline->lc,&vpol); + vpol.automatically_initiate=FALSE; + linphone_core_set_video_policy(marie->lc,&vpol); + _call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void _call_with_ice_video(LinphoneVideoPolicy caller_policy, LinphoneVideoPolicy callee_policy, + bool_t video_added_by_caller, bool_t video_added_by_callee, bool_t video_removed_by_caller, bool_t video_removed_by_callee) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + unsigned int nb_media_starts = 1; + + linphone_core_set_video_policy(pauline->lc, &caller_policy); + linphone_core_set_video_policy(marie->lc, &callee_policy); + linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); + linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + + linphone_core_set_audio_port(marie->lc, -1); + linphone_core_set_video_port(marie->lc, -1); + linphone_core_set_audio_port(pauline->lc, -1); + linphone_core_set_video_port(pauline->lc, -1); + + BC_ASSERT_TRUE(call_ok = call(pauline, marie)); + if (!call_ok) goto end; + BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); + + /* Wait for ICE reINVITEs to complete. */ + BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2) + && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); + check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); + nb_media_starts++; + + if (video_added_by_caller) { + BC_ASSERT_TRUE(add_video(marie, pauline, FALSE)); + } else if (video_added_by_callee) { + BC_ASSERT_TRUE(add_video(pauline, marie, FALSE)); + } + if (video_added_by_caller || video_added_by_callee) { + BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); + if (linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)))){ + /* Wait for ICE reINVITEs to complete if video was really added */ + BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 4) + && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 4)); + check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); + nb_media_starts++; + } + } + + if (video_removed_by_caller) { + BC_ASSERT_TRUE(remove_video(marie, pauline)); + } else if (video_removed_by_callee) { + BC_ASSERT_TRUE(remove_video(pauline, marie)); + } + if (video_removed_by_caller || video_removed_by_callee) { + BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); + check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); + nb_media_starts++; + } + + end_call(pauline, marie); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_ice_video_added(void) { + LinphoneVideoPolicy vpol = { TRUE, TRUE }; + _call_with_ice_video(vpol, vpol, TRUE, FALSE, TRUE, FALSE); +} + +static void call_with_ice_video_added_2(void) { + LinphoneVideoPolicy vpol = { TRUE, TRUE }; + _call_with_ice_video(vpol, vpol, TRUE, FALSE, FALSE, TRUE); +} + +static void call_with_ice_video_added_3(void) { + LinphoneVideoPolicy vpol = { TRUE, TRUE }; + _call_with_ice_video(vpol, vpol, FALSE, TRUE, TRUE, FALSE); +} + +static void call_with_ice_video_added_and_refused(void) { + LinphoneVideoPolicy caller_policy = { TRUE, TRUE }; + LinphoneVideoPolicy callee_policy = { FALSE, FALSE }; + _call_with_ice_video(caller_policy, callee_policy, TRUE, FALSE, FALSE, FALSE); +} + +static void call_with_ice_video_added_with_video_policies_to_false(void) { + LinphoneVideoPolicy vpol = { FALSE, FALSE }; + _call_with_ice_video(vpol, vpol, FALSE, TRUE, FALSE, FALSE); +} + +#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT /*which is not the case at the moment*/ + +static void call_with_ice_video_and_rtt(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + LinphoneVideoPolicy policy = { TRUE, TRUE }; + LinphoneCallParams *params = NULL; + LinphoneCall *marie_call = NULL; + + linphone_core_set_video_policy(pauline->lc, &policy); + linphone_core_set_video_policy(marie->lc, &policy); + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, FALSE); + linphone_core_enable_video_capture(pauline->lc, FALSE); + linphone_core_enable_video_display(pauline->lc, TRUE); + linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); + linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + + linphone_core_set_audio_port(marie->lc, -1); + linphone_core_set_video_port(marie->lc, -1); + linphone_core_set_text_port(marie->lc, -1); + linphone_core_set_audio_port(pauline->lc, -1); + linphone_core_set_video_port(pauline->lc, -1); + linphone_core_set_text_port(pauline->lc, -1); + + params = linphone_core_create_default_call_parameters(pauline->lc); + linphone_call_params_enable_realtime_text(params, TRUE); + BC_ASSERT_TRUE(call_ok = call_with_caller_params(pauline, marie, params)); + if (!call_ok) goto end; + BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); + + marie_call = linphone_core_get_current_call(marie->lc); + BC_ASSERT_TRUE(linphone_call_params_audio_enabled(linphone_call_get_current_params(marie_call))); + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marie_call))); + BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(marie_call))); + + end_call(pauline, marie); +end: + linphone_call_params_destroy(params); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +#endif + +static void video_call_with_early_media_no_matching_audio_codecs(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall *out_call, *pauline_call; + LinphoneVideoPolicy vpol={0}; + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); + + vpol.automatically_initiate=TRUE; + vpol.automatically_accept=TRUE; + linphone_core_set_video_policy(pauline->lc,&vpol); + linphone_core_set_video_policy(marie->lc,&vpol); + + linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMU", 8000, 1), FALSE); /* Disable PCMU */ + linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMA", 8000, 1), TRUE); /* Enable PCMA */ + + out_call = linphone_core_invite_address(marie->lc, pauline->identity); + linphone_call_ref(out_call); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingInit, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1)); + + pauline_call = linphone_core_get_current_call(pauline->lc); + if (!pauline_call) goto end; + + linphone_core_accept_early_media(pauline->lc, pauline_call); + + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia, 1)); + /*audio stream shall not have been requested to start*/ + BC_ASSERT_PTR_NULL(pauline_call->audiostream->soundread); + + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(out_call))); + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(pauline_call))); + + linphone_core_accept_call(pauline->lc, pauline_call); + + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); + + end_call(marie, pauline); + +end: + linphone_call_unref(out_call); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_limited_bandwidth(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_download_bandwidth(pauline->lc, 100); + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void dtls_srtp_video_call(void) { + call_base(LinphoneMediaEncryptionDTLS,TRUE,FALSE,LinphonePolicyNoFirewall,FALSE); +} + +static void dtls_srtp_ice_video_call(void) { + call_base(LinphoneMediaEncryptionDTLS,TRUE,FALSE,LinphonePolicyUseIce,FALSE); +} +static void dtls_srtp_ice_video_call_with_relay(void) { + call_base(LinphoneMediaEncryptionDTLS,TRUE,TRUE,LinphonePolicyUseIce,FALSE); +} +static void srtp_video_ice_call(void) { + call_base(LinphoneMediaEncryptionSRTP,TRUE,FALSE,LinphonePolicyUseIce,FALSE); +} +static void zrtp_video_ice_call(void) { + call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyUseIce,FALSE); +} + +static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, LinphoneCoreManager *marie, MSList *lcs) { +#define DEFAULT_WAIT_FOR 10000 + LinphoneCallParams *params; + LinphoneVideoPolicy pol; + LinphoneCall *call; + pol.automatically_accept=1; + pol.automatically_initiate=1; + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); + linphone_core_set_video_policy(pauline->lc,&pol); + linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_set_video_policy(marie->lc,&pol); + linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); + + linphone_call_set_next_video_frame_decoded_callback(linphone_core_invite_address(pauline->lc,marie->identity) + ,linphone_call_iframe_decoded_cb + ,pauline->lc); + + + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallIncomingReceived,1,DEFAULT_WAIT_FOR)); + + { + char* remote_uri = linphone_address_as_string_uri_only(pauline->identity); + call = linphone_core_find_call_from_uri(marie->lc,remote_uri); + ms_free(remote_uri); + } + + if (call) { + params=linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendOnly); + linphone_core_accept_call_with_params(marie->lc,call,params); + linphone_call_params_destroy(params); + + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning,1,DEFAULT_WAIT_FOR)); + BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallPausedByRemote,1,DEFAULT_WAIT_FOR)); + + check_media_direction(marie,call,lcs,LinphoneMediaDirectionSendOnly,LinphoneMediaDirectionSendOnly); + } + + + call=linphone_core_get_current_call(pauline->lc); + if (call) { + check_media_direction(pauline,call,lcs,LinphoneMediaDirectionRecvOnly,LinphoneMediaDirectionRecvOnly); + } + +} +static void accept_call_in_send_base(bool_t caller_has_ice) { + LinphoneCoreManager *pauline, *marie; + MSList *lcs=NULL;; + + marie = linphone_core_manager_new("marie_rc"); + pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + if (caller_has_ice) { + linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); + } + + lcs=ms_list_append(lcs,pauline->lc); + lcs=ms_list_append(lcs,marie->lc); + + accept_call_in_send_only_base(pauline,marie,lcs); + + + end_call(marie,pauline); + ms_list_free(lcs); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void accept_call_in_send_only(void) { + accept_call_in_send_base(FALSE); +} + +static void accept_call_in_send_only_with_ice(void) { + accept_call_in_send_base(TRUE); +} + +void two_accepted_call_in_send_only(void) { + LinphoneCoreManager *pauline, *marie, *laure; + MSList *lcs=NULL; + + marie = linphone_core_manager_new("marie_rc"); + linphone_core_use_files(marie->lc, TRUE); + pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + laure = linphone_core_manager_new("laure_rc_udp"); + + lcs=ms_list_append(lcs,pauline->lc); + lcs=ms_list_append(lcs,marie->lc); + lcs=ms_list_append(lcs,laure->lc); + + accept_call_in_send_only_base(pauline,marie,lcs); + + reset_counters(&marie->stat); + accept_call_in_send_only_base(laure,marie,lcs); + + end_call(pauline, marie); + end_call(laure, marie); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(laure); + ms_list_free(lcs); +} + +static void video_early_media_call(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_early_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); + LinphoneCall *pauline_to_marie; + + linphone_core_set_video_device(pauline->lc, "Mire: Mire (synthetic moving picture)"); + + video_call_base_3(pauline, marie, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); + + BC_ASSERT_PTR_NOT_NULL(pauline_to_marie = linphone_core_get_current_call(pauline->lc)); + if(pauline_to_marie) { + BC_ASSERT_EQUAL(pauline_to_marie->videostream->source->desc->id, MS_MIRE_ID, int, "%d"); + } + + end_call(pauline, marie); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +/*this is call forking with early media managed at client side (not by flexisip server)*/ +static void multiple_early_media(void) { + LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCoreManager* marie1 = linphone_core_manager_new("marie_early_rc"); + LinphoneCoreManager* marie2 = linphone_core_manager_new("marie_early_rc"); + MSList *lcs=NULL; + LinphoneCallParams *params=linphone_core_create_call_params(pauline->lc, NULL); + LinphoneVideoPolicy pol; + LinphoneCall *marie1_call; + LinphoneCall *marie2_call; + LinphoneCall *pauline_call; + LinphoneInfoMessage *info; + int dummy=0; + pol.automatically_accept=1; + pol.automatically_initiate=1; + + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); + + linphone_core_enable_video_capture(marie1->lc, TRUE); + linphone_core_enable_video_display(marie1->lc, TRUE); + linphone_core_set_video_policy(marie1->lc,&pol); + + linphone_core_enable_video_capture(marie2->lc, TRUE); + linphone_core_enable_video_display(marie2->lc, TRUE); + linphone_core_set_video_policy(marie2->lc,&pol); + linphone_core_set_audio_port_range(marie2->lc,40200,40300); + linphone_core_set_video_port_range(marie2->lc,40400,40500); + + lcs=ms_list_append(lcs,marie1->lc); + lcs=ms_list_append(lcs,marie2->lc); + lcs=ms_list_append(lcs,pauline->lc); + + linphone_call_params_enable_early_media_sending(params,TRUE); + linphone_call_params_enable_video(params,TRUE); + + linphone_core_invite_address_with_params(pauline->lc,marie1->identity,params); + linphone_call_params_destroy(params); + + BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,3000)); + + pauline_call=linphone_core_get_current_call(pauline->lc); + marie1_call=linphone_core_get_current_call(marie1->lc); + marie2_call=linphone_core_get_current_call(marie2->lc); + + BC_ASSERT_PTR_NOT_NULL(pauline_call); + BC_ASSERT_PTR_NOT_NULL(marie1_call); + BC_ASSERT_PTR_NOT_NULL(marie2_call); + + if (pauline_call && marie1_call && marie2_call){ + + /*wait a bit that streams are established*/ + wait_for_list(lcs,&dummy,1,6000); + BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline),70,int,"%i"); + BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie1), 70, int, "%i"); + BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie2), 70, int, "%i"); + + linphone_core_accept_call(marie1->lc,linphone_core_get_current_call(marie1->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallStreamsRunning,1,3000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,3000)); + + /*marie2 should get her call terminated*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); + + /*wait a bit that streams are established*/ + wait_for_list(lcs,&dummy,1,3000); + BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(pauline), 71, int, "%i"); + BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie1), 71, int, "%i"); + + /*send an INFO in reverse side to check that dialogs are properly established*/ + info=linphone_core_create_info_message(marie1->lc); + linphone_call_send_info_message(marie1_call,info); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_inforeceived,1,3000)); + } + + end_call(pauline, marie1); + + ms_list_free(lcs); + linphone_core_manager_destroy(marie1); + linphone_core_manager_destroy(marie2); + linphone_core_manager_destroy(pauline); +} +static void video_call_ice_params(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); + linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void audio_call_with_ice_with_video_policy_enabled(void){ + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneVideoPolicy vpol; + + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); + vpol.automatically_accept = vpol.automatically_initiate = TRUE; + linphone_core_set_video_policy(marie->lc, &vpol); + vpol.automatically_accept = vpol.automatically_initiate = FALSE; + linphone_core_set_video_policy(pauline->lc, &vpol); + + linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); + linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + + linphone_core_invite_address(pauline->lc, marie->identity); + if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end; + linphone_core_accept_call(marie->lc, linphone_core_get_current_call(marie->lc)); + /* + LinphoneCallParams *params; + params = linphone_core_create_call_params(marie->lc, linphone_core_get_current_call(marie->lc)); + linphone_call_params_enable_video(params, TRUE); + linphone_core_accept_call_with_params(marie->lc, linphone_core_get_current_call(marie->lc), params); + linphone_call_params_destroy(params);*/ + + /*wait for call to be established and ICE reINVITEs to be done */ + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); + + linphone_core_pause_call(marie->lc, linphone_core_get_current_call(marie->lc)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallPausedByRemote, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPaused, 1)); + + end_call(marie, pauline); +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + + +static void classic_video_entry_phone_setup(void) { + LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCallParams *early_media_params = NULL; + LinphoneCallParams *in_call_params = NULL; + LinphoneCall *callee_call = NULL; + LinphoneVideoPolicy vpol = { TRUE, TRUE }; + MSList *lcs = NULL; + int retry = 0; + bool_t ok; + + lcs = ms_list_append(lcs, caller_mgr->lc); + lcs = ms_list_append(lcs, callee_mgr->lc); + + linphone_core_enable_video_capture(caller_mgr->lc, TRUE); + linphone_core_enable_video_display(caller_mgr->lc, TRUE); + linphone_core_enable_video_capture(callee_mgr->lc, TRUE); + linphone_core_enable_video_display(callee_mgr->lc, TRUE); + linphone_core_set_avpf_mode(caller_mgr->lc, LinphoneAVPFEnabled); + linphone_core_set_avpf_mode(callee_mgr->lc, LinphoneAVPFEnabled); + linphone_core_set_video_policy(caller_mgr->lc, &vpol); + linphone_core_set_video_policy(callee_mgr->lc, &vpol); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(caller_mgr->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(caller_mgr->lc,"h264"); + disable_all_video_codecs_except_one(callee_mgr->lc,"h264"); + } + + linphone_core_set_video_device(caller_mgr->lc, liblinphone_tester_mire_id); + linphone_core_set_video_device(callee_mgr->lc, liblinphone_tester_mire_id); + + BC_ASSERT_PTR_NOT_NULL(linphone_core_invite_address(caller_mgr->lc, callee_mgr->identity)); + + ok = wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1); + BC_ASSERT_TRUE(ok); + if (!ok) goto end; + BC_ASSERT_TRUE(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress == 1); + + callee_call = linphone_core_get_call_by_remote_address2(callee_mgr->lc, caller_mgr->identity); + early_media_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); + linphone_call_params_set_audio_direction(early_media_params, LinphoneMediaDirectionInactive); + linphone_call_params_set_video_direction(early_media_params, LinphoneMediaDirectionRecvOnly); + linphone_core_accept_early_media_with_params(callee_mgr->lc, callee_call, early_media_params); + linphone_call_params_destroy(early_media_params); + + while ((caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia != 1) && (retry++ < 100)) { + linphone_core_iterate(caller_mgr->lc); + linphone_core_iterate(callee_mgr->lc); + ms_usleep(20000); + } + BC_ASSERT_TRUE(caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia == 1); + BC_ASSERT_TRUE(callee_mgr->stat.number_of_LinphoneCallIncomingEarlyMedia == 1); + + check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionRecvOnly); + callee_call = linphone_core_get_call_by_remote_address2(callee_mgr->lc, caller_mgr->identity); + in_call_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); + linphone_call_params_set_audio_direction(in_call_params, LinphoneMediaDirectionSendRecv); + linphone_call_params_set_video_direction(in_call_params, LinphoneMediaDirectionSendRecv); + linphone_core_accept_call_with_params(callee_mgr->lc, callee_call, in_call_params); + linphone_call_params_destroy(in_call_params); + + BC_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallConnected, 1)); + BC_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallConnected, 1)); + + ok = wait_for_until(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) + && wait_for_until(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallStreamsRunning, 1, 2000); + BC_ASSERT_TRUE(ok); + if (!ok) goto end; + check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionSendRecv); + + callee_call = linphone_core_get_current_call(callee_mgr->lc); + in_call_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); + linphone_call_params_set_audio_direction(in_call_params, LinphoneMediaDirectionRecvOnly); + linphone_call_params_set_video_direction(in_call_params, LinphoneMediaDirectionSendOnly); + linphone_core_update_call(callee_mgr->lc, callee_call, in_call_params); + linphone_call_params_destroy(in_call_params); + + ok = wait_for_until(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 2, 2000) + && wait_for_until(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallStreamsRunning, 2, 2000); + BC_ASSERT_TRUE(ok); + if (!ok) goto end; + callee_call = linphone_core_get_current_call(callee_mgr->lc); + check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionRecvOnly, LinphoneMediaDirectionSendOnly); + + end_call(caller_mgr, callee_mgr); + +end: + linphone_core_manager_destroy(callee_mgr); + linphone_core_manager_destroy(caller_mgr); + ms_list_free(lcs); +} +static void video_call_recording_h264_test(void) { + record_call("recording", TRUE, "H264"); +} + +static void video_call_recording_vp8_test(void) { + record_call("recording", TRUE, "VP8"); +} + +static void video_call_snapshot(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCallParams *marieParams = linphone_core_create_call_params(marie->lc, NULL); + LinphoneCallParams *paulineParams = linphone_core_create_call_params(pauline->lc, NULL); + LinphoneCall *callInst = NULL; + char *filename = bc_tester_file("snapshot.jpeg"); + int dummy = 0; + bool_t call_succeeded = FALSE; + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); + linphone_call_params_enable_video(marieParams, TRUE); + linphone_call_params_enable_video(paulineParams, TRUE); + + BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams)); + BC_ASSERT_PTR_NOT_NULL(callInst = linphone_core_get_current_call(marie->lc)); + if((call_succeeded == TRUE) && (callInst != NULL)) { + int jpeg_support = linphone_call_take_video_snapshot(callInst, filename); + if (jpeg_support < 0) { + ms_warning("No jpegwriter support!"); + } else { + wait_for_until(marie->lc, pauline->lc, &dummy, 1, 5000); + BC_ASSERT_EQUAL(ortp_file_exist(filename), 0, int, "%d"); + remove(filename); + } + end_call(marie, pauline); + } + ms_free(filename); + linphone_call_params_unref(marieParams); + linphone_call_params_unref(paulineParams); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryption mode, bool_t no_sdp) { + LinphoneCoreManager* marie; + LinphoneCoreManager* pauline; + LinphoneCallParams *params; + const LinphoneCallParams *current_params; + MSList *lcs=NULL; + bool_t calls_ok; + + marie = linphone_core_manager_new( "marie_rc"); + pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_avpf_mode(pauline->lc,TRUE); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); + linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); + linphone_core_set_avpf_mode(marie->lc,TRUE); + lcs=ms_list_append(lcs,pauline->lc); + lcs=ms_list_append(lcs,marie->lc); + + video_call_base_2(marie,pauline,TRUE,mode,TRUE,TRUE); + + calls_ok = linphone_core_get_current_call(marie->lc) != NULL && linphone_core_get_current_call(pauline->lc) != NULL; + BC_ASSERT_TRUE(calls_ok); + + if (calls_ok) { + params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc)); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionInactive); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); + + linphone_core_update_call(marie->lc, linphone_core_get_current_call(marie->lc),params); + linphone_call_params_destroy(params); + + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,1)); + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1)); + + check_media_direction(marie,linphone_core_get_current_call(marie->lc),lcs,LinphoneMediaDirectionInactive,LinphoneMediaDirectionInactive); + check_media_direction(pauline,linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionInactive); + + if (no_sdp) { + linphone_core_enable_sdp_200_ack(marie->lc,TRUE); + } + + params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc)); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv); + linphone_core_update_call(marie->lc,linphone_core_get_current_call(marie->lc),params); + linphone_call_params_destroy(params); + + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + + check_media_direction(marie,linphone_core_get_current_call(marie->lc),lcs,LinphoneMediaDirectionSendRecv,LinphoneMediaDirectionSendRecv); + check_media_direction(pauline,linphone_core_get_current_call(pauline->lc),lcs,LinphoneMediaDirectionSendRecv,LinphoneMediaDirectionSendRecv); + + /*assert that after pause and resume, SRTP is still being used*/ + current_params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(current_params) , mode, int, "%d"); + current_params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(current_params) , mode, int, "%d"); + + } + end_call(marie,pauline); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_with_re_invite_inactive_followed_by_re_invite(void) { + video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionNone,FALSE); +} + +static void video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp(void) { + video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionNone, TRUE); +} + +static void srtp_video_call_with_re_invite_inactive_followed_by_re_invite(void) { + if (ms_srtp_supported()) + video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionSRTP,FALSE); + else + ms_message("srtp_video_call_with_re_invite_inactive_followed_by_re_invite skipped, missing srtp support"); +} + +static void srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp(void) { + if (ms_srtp_supported()) + video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionSRTP, TRUE); + else + ms_message("srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp skipped, missing srtp support"); +} + +static void incoming_reinvite_with_invalid_ack_sdp(void){ + LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc"); + LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc"); + LinphoneCall * inc_call; + BC_ASSERT_TRUE(call(caller,callee)); + inc_call = linphone_core_get_current_call(callee->lc); + + BC_ASSERT_PTR_NOT_NULL(inc_call); + if (inc_call) { + const LinphoneCallParams *caller_params; + stats initial_caller_stat=caller->stat; + stats initial_callee_stat=callee->stat; + sal_call_set_sdp_handling(inc_call->op, SalOpSDPSimulateError); /* will force a parse error for the ACK SDP*/ + BC_ASSERT_PTR_NOT_NULL(setup_video(caller, callee, TRUE)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning)); + /*Basically the negotiation failed but since the call was already running, we expect it to restore to + the previous state so error stats should not be changed*/ + BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallError,initial_callee_stat.number_of_LinphoneCallError, int, "%d"); + /*and remote should have received an update notification*/ + BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote+1, int, "%d"); + + + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + caller_params = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,(int*)&caller_params->has_video,FALSE)); + + sal_call_set_sdp_handling(inc_call->op, SalOpSDPNormal); + } + end_call(caller, callee); + + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + +static void outgoing_reinvite_with_invalid_ack_sdp(void) { + LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc"); + LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc"); + LinphoneCall * out_call; + BC_ASSERT_TRUE(call(caller,callee)); + out_call = linphone_core_get_current_call(caller->lc); + + BC_ASSERT_PTR_NOT_NULL(out_call); + if (out_call) { + stats initial_caller_stat=caller->stat; + stats initial_callee_stat=callee->stat; + sal_call_set_sdp_handling(out_call->op, SalOpSDPSimulateError); /* will force a parse error for the ACK SDP*/ + BC_ASSERT_PTR_NOT_NULL(setup_video(caller, callee, TRUE)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning)); + /*Basically the negotiation failed but since the call was already running, we expect it to restore to + the previous state so error stats should not be changed*/ + BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallError,initial_callee_stat.number_of_LinphoneCallError, int, "%d"); + /*and remote should not have received any update notification*/ + BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote, int, "%d"); + + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); + + sal_call_set_sdp_handling(out_call->op, SalOpSDPNormal); + } + end_call(caller, callee); + + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + +#endif +static void video_call_with_no_audio_and_no_video_codec(void){ + LinphoneCoreManager* callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall* out_call ; + LinphoneVideoPolicy callee_policy, caller_policy; + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + + const MSList* elem_video =linphone_core_get_video_codecs(caller->lc); + + const MSList* elem_audio =linphone_core_get_audio_codecs(caller->lc); + + disable_all_codecs(elem_audio, caller); + disable_all_codecs(elem_video, caller); + + callee_policy.automatically_initiate=FALSE; + callee_policy.automatically_accept=TRUE; + caller_policy.automatically_initiate=TRUE; + caller_policy.automatically_accept=FALSE; + + linphone_core_set_video_policy(callee->lc,&callee_policy); + linphone_core_set_video_policy(caller->lc,&caller_policy); + + + linphone_core_enable_video_display(callee->lc, TRUE); + linphone_core_enable_video_capture(callee->lc, TRUE); + + linphone_core_enable_video_display(caller->lc, TRUE); + linphone_core_enable_video_capture(caller->lc, TRUE); + + /* Create call params */ + caller_test_params.base = linphone_core_create_call_params(caller->lc, NULL); + + + out_call = linphone_core_invite_address_with_params(caller->lc, callee->identity,caller_test_params.base); + linphone_call_ref(out_call); + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + + + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallOutgoingInit, 1)); + + BC_ASSERT_TRUE(wait_for_until(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallError, 1, 6000)); + BC_ASSERT_EQUAL(linphone_call_get_reason(out_call), LinphoneReasonNotAcceptable, int, "%d"); + BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallIncomingReceived, 0, int, "%d"); + + linphone_call_unref(out_call); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + +static void call_with_early_media_and_no_sdp_in_200_with_video(void){ + early_media_without_sdp_in_200_base(TRUE, FALSE); +} + +test_t call_video_tests[] = { +#ifdef VIDEO_ENABLED + TEST_NO_TAG("Call paused resumed with video", call_paused_resumed_with_video), + TEST_NO_TAG("Call paused resumed with video no sdp ack", call_paused_resumed_with_no_sdp_ack), + TEST_NO_TAG("Call paused resumed with video no sdk ack using video policy for resume offers", call_paused_resumed_with_no_sdp_ack_using_video_policy), + TEST_NO_TAG("Call paused, updated and resumed with video no sdk ack using video policy for resume offers", call_paused_updated_resumed_with_no_sdp_ack_using_video_policy), + TEST_NO_TAG("Call paused, updated and resumed with video no sdk ack using video policy for resume offers with accept call update", call_paused_updated_resumed_with_no_sdp_ack_using_video_policy_and_accept_call_update), + TEST_NO_TAG("ZRTP video call", zrtp_video_call), + TEST_NO_TAG("Simple video call AVPF", video_call_avpf), + TEST_NO_TAG("Simple video call implicit AVPF both", video_call_using_policy_AVPF_implicit_caller_and_callee), + TEST_NO_TAG("Simple video call disable implicit AVPF on callee", video_call_disable_implicit_AVPF_on_callee), + TEST_NO_TAG("Simple video call disable implicit AVPF on caller", video_call_disable_implicit_AVPF_on_caller), + TEST_NO_TAG("Simple video call AVPF to implicit AVPF", video_call_AVPF_to_implicit_AVPF), + TEST_NO_TAG("Simple video call implicit AVPF to AVPF", video_call_implicit_AVPF_to_AVPF), + TEST_NO_TAG("Simple video call", video_call), + TEST_NO_TAG("Simple video call without rtcp",video_call_without_rtcp), + TEST_NO_TAG("Simple ZRTP video call", video_call_zrtp), + TEST_NO_TAG("Simple DTLS video call", video_call_dtls), + TEST_NO_TAG("Simple video call using policy", video_call_using_policy), + TEST_NO_TAG("Video call using policy with callee video disabled", video_call_using_policy_with_callee_video_disabled), + TEST_NO_TAG("Video call using policy with caller video disabled", video_call_using_policy_with_caller_video_disabled), + TEST_NO_TAG("Video call without SDP", video_call_no_sdp), + TEST_ONE_TAG("SRTP ice video call", srtp_video_ice_call, "ICE"), + TEST_ONE_TAG("ZRTP ice video call", zrtp_video_ice_call, "ICE"), + TEST_NO_TAG("Call with video added", call_with_video_added), + TEST_NO_TAG("Call with video added 2", call_with_video_added_2), + TEST_NO_TAG("Call with video added (random ports)", call_with_video_added_random_ports), + TEST_NO_TAG("Call with several video switches", call_with_several_video_switches), + TEST_NO_TAG("SRTP call with several video switches", srtp_call_with_several_video_switches), + TEST_NO_TAG("Call with video declined", call_with_declined_video), + TEST_NO_TAG("Call with video declined despite policy", call_with_declined_video_despite_policy), + TEST_NO_TAG("Call with video declined using policy", call_with_declined_video_using_policy), + TEST_NO_TAG("Video early-media call", video_early_media_call), + TEST_NO_TAG("Call with multiple early media", multiple_early_media), + TEST_ONE_TAG("Call with ICE from video to non-video", call_with_ice_video_to_novideo, "ICE"), + TEST_ONE_TAG("Call with ICE and video added", call_with_ice_video_added, "ICE"), + TEST_ONE_TAG("Call with ICE and video added 2", call_with_ice_video_added_2, "ICE"), + TEST_ONE_TAG("Call with ICE and video added 3", call_with_ice_video_added_3, "ICE"), + TEST_ONE_TAG("Call with ICE and video added and refused", call_with_ice_video_added_and_refused, "ICE"), + TEST_ONE_TAG("Call with ICE and video added with video policies to false", call_with_ice_video_added_with_video_policies_to_false, "ICE"), +#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT + TEST_ONE_TAG("Call with ICE, video and realtime text", call_with_ice_video_and_rtt, "ICE"), +#endif + TEST_ONE_TAG("Video call with ICE accepted using call params", video_call_ice_params, "ICE"), + TEST_ONE_TAG("Audio call with ICE paused with caller video policy enabled", audio_call_with_ice_with_video_policy_enabled, "ICE"), + TEST_NO_TAG("Video call recording (H264)", video_call_recording_h264_test), + TEST_NO_TAG("Video call recording (VP8)", video_call_recording_vp8_test), + TEST_NO_TAG("Snapshot", video_call_snapshot), + TEST_NO_TAG("Video call with early media and no matching audio codecs", video_call_with_early_media_no_matching_audio_codecs), + TEST_NO_TAG("DTLS SRTP video call", dtls_srtp_video_call), + TEST_ONE_TAG("DTLS SRTP ice video call", dtls_srtp_ice_video_call, "ICE"), + TEST_ONE_TAG("DTLS SRTP ice video call with relay", dtls_srtp_ice_video_call_with_relay, "ICE"), + TEST_NO_TAG("Video call with limited bandwidth", video_call_limited_bandwidth), + TEST_NO_TAG("Video call accepted in send only", accept_call_in_send_only), + TEST_ONE_TAG("Video call accepted in send only with ice", accept_call_in_send_only_with_ice, "ICE"), + TEST_NO_TAG("2 Video call accepted in send only", two_accepted_call_in_send_only), + TEST_NO_TAG("Video call with re-invite(inactive) followed by re-invite", video_call_with_re_invite_inactive_followed_by_re_invite), + TEST_NO_TAG("Video call with re-invite(inactive) followed by re-invite(no sdp)", video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp), + TEST_NO_TAG("SRTP Video call with re-invite(inactive) followed by re-invite", srtp_video_call_with_re_invite_inactive_followed_by_re_invite), + TEST_NO_TAG("SRTP Video call with re-invite(inactive) followed by re-invite(no sdp)", srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp), + TEST_NO_TAG("Classic video entry phone setup", classic_video_entry_phone_setup), + TEST_NO_TAG("Incoming REINVITE with invalid SDP in ACK", incoming_reinvite_with_invalid_ack_sdp), + TEST_NO_TAG("Outgoing REINVITE with invalid SDP in ACK", outgoing_reinvite_with_invalid_ack_sdp), +#endif + TEST_NO_TAG("Video call with no audio and no video codec", video_call_with_no_audio_and_no_video_codec), + TEST_NO_TAG("Call with early media and no SDP in 200 Ok with video", call_with_early_media_and_no_sdp_in_200_with_video), +}; + +test_suite_t call_video_test_suite = {"Video Call", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, + sizeof(call_video_tests) / sizeof(call_video_tests[0]), call_video_tests}; diff --git a/tester/complex_sip_call_tester.c b/tester/complex_sip_case_tester.c similarity index 99% rename from tester/complex_sip_call_tester.c rename to tester/complex_sip_case_tester.c index b446592a7..1e524bb2c 100644 --- a/tester/complex_sip_call_tester.c +++ b/tester/complex_sip_case_tester.c @@ -361,7 +361,7 @@ static test_t tests[] = { }; test_suite_t complex_sip_call_test_suite = { - "Complex SIP Call", + "Complex SIP Case", NULL, NULL, liblinphone_tester_before_each, diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 7dea47ed1..8e0db4b00 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -42,6 +42,7 @@ extern "C" { extern test_suite_t setup_test_suite; extern test_suite_t register_test_suite; extern test_suite_t call_test_suite; +extern test_suite_t call_video_test_suite; extern test_suite_t message_test_suite; extern test_suite_t presence_test_suite; extern test_suite_t presence_server_test_suite; @@ -323,12 +324,18 @@ bool_t call_with_test_params(LinphoneCoreManager* caller_mgr ,LinphoneCoreManager* callee_mgr ,const LinphoneCallTestParams *caller_test_params ,const LinphoneCallTestParams *callee_test_params); +bool_t call_with_params2(LinphoneCoreManager* caller_mgr + ,LinphoneCoreManager* callee_mgr + , const LinphoneCallTestParams *caller_test_params + , const LinphoneCallTestParams *callee_test_params + , bool_t build_callee_params); bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_mgr); bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy); void end_call(LinphoneCoreManager *m1, LinphoneCoreManager *m2); void disable_all_audio_codecs_except_one(LinphoneCore *lc, const char *mime, int rate); void disable_all_video_codecs_except_one(LinphoneCore *lc, const char *mime); +void disable_all_codecs(const MSList* elem, LinphoneCoreManager* call); stats * get_stats(LinphoneCore *lc); bool_t transport_supported(LinphoneTransportType transport); LinphoneCoreManager *get_manager(LinphoneCore *lc); @@ -352,6 +359,9 @@ bool_t call_with_caller_params(LinphoneCoreManager* caller_mgr,LinphoneCoreManag bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,LinphoneCoreManager* mgr_2,LinphoneCall* call_2); void compare_files(const char *path1, const char *path2); void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList* lcs,LinphoneMediaDirection audio_dir, LinphoneMediaDirection video_dir); +void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay); +void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts); +void record_call(const char *filename, bool_t enableVideo, const char *video_codec); extern const MSAudioDiffParams audio_cmp_params; @@ -379,6 +389,7 @@ extern const char *liblinphone_tester_mire_id; LinphoneAddress * linphone_core_manager_resolve(LinphoneCoreManager *mgr, const LinphoneAddress *source); FILE *sip_start(const char *senario, const char* dest_username, const char *passwd, LinphoneAddress* dest_addres); +void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ); #ifdef __cplusplus diff --git a/tester/tester.c b/tester/tester.c index e6d472918..b9bd42f5e 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -136,7 +136,7 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c nowebcampath = ms_strdup_printf("%s/images/nowebcamCIF.jpg", path); rootcapath = ms_strdup_printf("%s/certificates/cn/cafile.pem", path); dnsuserhostspath = ms_strdup_printf("%s/%s", path, userhostsfile); - + if( config != NULL ) { lp_config_set_string(config, "sound", "remote_ring", ringbackpath); @@ -151,7 +151,7 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c linphone_core_set_root_ca(lc,rootcapath); } chatdb = ms_strdup_printf("%s/messages-%p.db",bc_tester_get_writable_dir_prefix(),lc); - + linphone_core_enable_ipv6(lc, liblinphonetester_ipv6); sal_enable_test_features(lc->sal,TRUE); @@ -159,7 +159,7 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c linphone_core_set_static_picture(lc,nowebcampath); linphone_core_set_chat_database_path(lc, chatdb); - + ms_free(ringpath); ms_free(ringbackpath); ms_free(nowebcampath); @@ -502,6 +502,7 @@ void liblinphone_tester_add_suites() { bc_tester_add_suite(&tunnel_test_suite); bc_tester_add_suite(&offeranswer_test_suite); bc_tester_add_suite(&call_test_suite); + bc_tester_add_suite(&call_video_test_suite); bc_tester_add_suite(&audio_bypass_suite); bc_tester_add_suite(&multi_call_test_suite); bc_tester_add_suite(&message_test_suite); From 1002fdcdb9ea2d25eccf3826ecd3adbb435fde09 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 15 Jun 2016 16:01:39 +0200 Subject: [PATCH 084/124] tester: split simple call tests in two suites: video calls and other calls and minor files reorganization --- tester/CMakeLists.txt | 31 +- tester/Makefile.am | 17 +- ...ulti_call_tester.c => call_multi_tester.c} | 0 ..._call_tester.c => call_multicast_tester.c} | 0 .../{call_tester.c => call_single_tester.c} | 1812 +---------------- tester/call_video_tester.c | 1782 ++++++++++++++++ ...all_tester.c => complex_sip_case_tester.c} | 2 +- tester/liblinphone_tester.h | 11 + tester/tester.c | 3 +- 9 files changed, 1821 insertions(+), 1837 deletions(-) rename tester/{multi_call_tester.c => call_multi_tester.c} (100%) rename tester/{multicast_call_tester.c => call_multicast_tester.c} (100%) rename tester/{call_tester.c => call_single_tester.c} (72%) create mode 100644 tester/call_video_tester.c rename tester/{complex_sip_call_tester.c => complex_sip_case_tester.c} (99%) diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 39643bfba..1483bc703 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -20,35 +20,8 @@ # ############################################################################ -set(SOURCE_FILES - accountmanager.c - audio_bypass_tester.c - call_tester.c - complex_sip_call_tester.c - dtmf_tester.c - eventapi_tester.c - flexisip_tester.c - liblinphone_tester.c - log_collection_tester.c - message_tester.c - multi_call_tester.c - multicast_call_tester.c - offeranswer_tester.c - player_tester.c - presence_tester.c - presence_server_tester.c - proxy_config_tester.c - quality_reporting_tester.c - register_tester.c - remote_provisioning_tester.c - setup_tester.c - stun_tester.c - tester.c - tunnel_tester.c - upnp_tester.c - video_tester.c - vcard_tester.c -) +file(GLOB SOURCE_FILES "*_tester.c") +list(APPEND SOURCE_FILES accountmanager.c tester.c) apply_compile_flags(SOURCE_FILES "CPP" "C") diff --git a/tester/Makefile.am b/tester/Makefile.am index 59b61fd66..75bc3ce2c 100644 --- a/tester/Makefile.am +++ b/tester/Makefile.am @@ -116,30 +116,31 @@ liblinphonetester_la_HEADERS = audio_bypass_wav_header.h liblinphonetester_la_SOURCES = \ accountmanager.c \ audio_bypass_tester.c \ - call_tester.c \ - complex_sip_call_tester.c \ + call_multi_tester.c \ + call_multicast_tester.c \ + call_single_tester.c \ + call_video_tester.c \ + complex_sip_case_tester.c \ dtmf_tester.c \ eventapi_tester.c \ flexisip_tester.c \ log_collection_tester.c \ message_tester.c \ - multi_call_tester.c \ - multicast_call_tester.c \ offeranswer_tester.c \ player_tester.c \ - presence_tester.c \ presence_server_tester.c \ + presence_tester.c \ proxy_config_tester.c \ quality_reporting_tester.c \ register_tester.c \ remote_provisioning_tester.c \ setup_tester.c \ stun_tester.c \ - tunnel_tester.c \ tester.c \ + tunnel_tester.c \ upnp_tester.c \ - video_tester.c \ - vcard_tester.c + vcard_tester.c \ + video_tester.c liblinphonetester_ladir = $(includedir)/linphone diff --git a/tester/multi_call_tester.c b/tester/call_multi_tester.c similarity index 100% rename from tester/multi_call_tester.c rename to tester/call_multi_tester.c diff --git a/tester/multicast_call_tester.c b/tester/call_multicast_tester.c similarity index 100% rename from tester/multicast_call_tester.c rename to tester/call_multicast_tester.c diff --git a/tester/call_tester.c b/tester/call_single_tester.c similarity index 72% rename from tester/call_tester.c rename to tester/call_single_tester.c index c48dd5f85..3bc9596c5 100644 --- a/tester/call_tester.c +++ b/tester/call_single_tester.c @@ -34,7 +34,6 @@ #endif static void srtp_call(void); -static char *create_filepath(const char *dir, const char *filename, const char *ext); // prototype definition for call_recording() #ifdef ANDROID @@ -838,7 +837,7 @@ end: } -static void disable_all_codecs(const MSList* elem, LinphoneCoreManager* call){ +void disable_all_codecs(const MSList* elem, LinphoneCoreManager* call){ PayloadType *pt; @@ -877,59 +876,6 @@ static void call_with_no_audio_codec(void){ } -static void video_call_with_no_audio_and_no_video_codec(void){ - - LinphoneCoreManager* callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall* out_call ; - LinphoneVideoPolicy callee_policy, caller_policy; - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - - const MSList* elem_video =linphone_core_get_video_codecs(caller->lc); - - const MSList* elem_audio =linphone_core_get_audio_codecs(caller->lc); - - disable_all_codecs(elem_audio, caller); - disable_all_codecs(elem_video, caller); - - callee_policy.automatically_initiate=FALSE; - callee_policy.automatically_accept=TRUE; - caller_policy.automatically_initiate=TRUE; - caller_policy.automatically_accept=FALSE; - - linphone_core_set_video_policy(callee->lc,&callee_policy); - linphone_core_set_video_policy(caller->lc,&caller_policy); - - - linphone_core_enable_video_display(callee->lc, TRUE); - linphone_core_enable_video_capture(callee->lc, TRUE); - - linphone_core_enable_video_display(caller->lc, TRUE); - linphone_core_enable_video_capture(caller->lc, TRUE); - - /* Create call params */ - caller_test_params.base = linphone_core_create_call_params(caller->lc, NULL); - - - out_call = linphone_core_invite_address_with_params(caller->lc, callee->identity,caller_test_params.base); - linphone_call_ref(out_call); - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - - - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallOutgoingInit, 1)); - - BC_ASSERT_TRUE(wait_for_until(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallError, 1, 6000)); - BC_ASSERT_EQUAL(linphone_call_get_reason(out_call), LinphoneReasonNotAcceptable, int, "%d"); - BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallIncomingReceived, 0, int, "%d"); - - linphone_call_unref(out_call); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - static void simple_call_compatibility_mode(void) { char route[256]; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); @@ -1235,7 +1181,7 @@ void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *cal } } -static void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay) { +void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay) { linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL); linphone_core_set_user_agent(marie->lc, "Natted Linphone", NULL); @@ -1663,132 +1609,6 @@ end: ms_list_free(lcs); } -#ifdef VIDEO_ENABLED -static void call_paused_resumed_with_video_base_call_cb(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message) { - if (cstate == LinphoneCallUpdatedByRemote) { - LinphoneCallParams *params = linphone_core_create_call_params(lc, call); - linphone_call_params_enable_video(params, TRUE); - ms_message (" New state LinphoneCallUpdatedByRemote on call [%p], accepting with video on",call); - BC_ASSERT_NOT_EQUAL(linphone_core_accept_call_update(lc, call, params), 0, int, "%i"); - linphone_call_params_destroy(params); - } -} -/*this test makes sure that pause/resume will not bring up video by accident*/ -static void call_paused_resumed_with_video_base(bool_t sdp_200_ack - ,bool_t use_video_policy_for_re_invite_sdp_200 - ,bool_t resume_in_audio_send_only_video_inactive_first - ,bool_t with_call_accept){ - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall* call_pauline, *call_marie; - MSList *lcs = NULL; - LinphoneVideoPolicy vpol; - bool_t call_ok; - LinphoneCoreVTable *vtable = linphone_core_v_table_new(); - vtable->call_state_changed = call_paused_resumed_with_video_base_call_cb; - lcs = ms_list_append(lcs, pauline->lc); - lcs = ms_list_append(lcs, marie->lc); - - vpol.automatically_accept = FALSE; - vpol.automatically_initiate = TRUE; /* needed to present a video mline*/ - - linphone_core_set_video_policy(marie->lc, &vpol); - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - - vpol.automatically_accept = FALSE; - vpol.automatically_initiate = TRUE; - - linphone_core_set_video_policy(pauline->lc, &vpol); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, TRUE); - - BC_ASSERT_TRUE((call_ok=call(marie, pauline))); - - if (!call_ok) goto end; - - call_pauline = linphone_core_get_current_call(pauline->lc); - call_marie = linphone_core_get_current_call(marie->lc); - - wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); - - linphone_core_pause_call(pauline->lc,call_pauline); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1)); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_remote_params(call_marie))); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1)); - - /*stay in pause a little while in order to generate traffic*/ - wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); - - /*check if video stream is still offered even if disabled*/ - - BC_ASSERT_EQUAL(call_pauline->localdesc->nb_streams, 2, int, "%i"); - BC_ASSERT_EQUAL(call_marie->localdesc->nb_streams, 2, int, "%i"); - - linphone_core_enable_sdp_200_ack(pauline->lc,sdp_200_ack); - - if (use_video_policy_for_re_invite_sdp_200) { - LpConfig *marie_lp; - marie_lp = linphone_core_get_config(marie->lc); - lp_config_set_int(marie_lp,"sip","sdp_200_ack_follow_video_policy",1); - } - /*now pauline wants to resume*/ - if (resume_in_audio_send_only_video_inactive_first) { - LinphoneCallParams *params = linphone_core_create_call_params(pauline->lc, call_pauline); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly); - linphone_core_update_call(pauline->lc,call_pauline,params); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,2)); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdating,1)); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv); - if (with_call_accept) { - linphone_core_add_listener(marie->lc, vtable); - } - linphone_core_update_call(pauline->lc,call_pauline,params); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3)); - linphone_call_params_destroy(params); - } else { - linphone_core_resume_call(pauline->lc, call_pauline); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallResuming,1)); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); - } - - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); - - if (use_video_policy_for_re_invite_sdp_200) { - /*make sure video was offered*/ - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_remote_params(call_pauline))); - } else { - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_marie))); - } - end_call(marie, pauline); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); - ms_list_free(lcs); -} -static void call_paused_resumed_with_video(void){ - call_paused_resumed_with_video_base(FALSE, FALSE,FALSE,FALSE); -} - -static void call_paused_resumed_with_no_sdp_ack(void){ - call_paused_resumed_with_video_base(TRUE, FALSE,FALSE,FALSE); -} -static void call_paused_resumed_with_no_sdp_ack_using_video_policy(void){ - call_paused_resumed_with_video_base(TRUE, TRUE,FALSE,FALSE); -} -static void call_paused_updated_resumed_with_no_sdp_ack_using_video_policy(void){ - call_paused_resumed_with_video_base(TRUE, TRUE,TRUE,FALSE); -} -static void call_paused_updated_resumed_with_no_sdp_ack_using_video_policy_and_accept_call_update(void){ - call_paused_resumed_with_video_base(TRUE, TRUE,TRUE,TRUE); -} -#endif #define CHECK_CURRENT_LOSS_RATE() \ rtcp_count_current = pauline->stat.number_of_rtcp_sent; \ /*wait for an RTCP packet to have an accurate cumulative lost value*/ \ @@ -1959,921 +1779,6 @@ static void audio_call_with_ice_no_matching_audio_codecs(void) { linphone_core_manager_destroy(pauline); } -#ifdef VIDEO_ENABLED -static LinphoneCall* setup_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy) { - LinphoneVideoPolicy caller_policy; - LinphoneCallParams* callee_params; - LinphoneCall* call_obj; - - if (!linphone_core_get_current_call(callee->lc) || linphone_call_get_state(linphone_core_get_current_call(callee->lc)) != LinphoneCallStreamsRunning - || !linphone_core_get_current_call(caller->lc) || linphone_call_get_state(linphone_core_get_current_call(caller->lc)) != LinphoneCallStreamsRunning ) { - ms_warning("bad state for adding video"); - return NULL; - } - - if (change_video_policy) { - caller_policy.automatically_accept=TRUE; - caller_policy.automatically_initiate=TRUE; - linphone_core_set_video_policy(caller->lc,&caller_policy); - } - linphone_core_enable_video_capture(callee->lc, TRUE); - linphone_core_enable_video_display(callee->lc, TRUE); - linphone_core_enable_video_capture(caller->lc, TRUE); - linphone_core_enable_video_display(caller->lc, FALSE); - - if ((call_obj = linphone_core_get_current_call(callee->lc))) { - callee_params = linphone_core_create_call_params(callee->lc, call_obj); - /*add video*/ - linphone_call_params_enable_video(callee_params,TRUE); - linphone_core_update_call(callee->lc,call_obj,callee_params); - linphone_call_params_destroy(callee_params); - } - return call_obj; -} - -bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy) { - stats initial_caller_stat=caller->stat; - stats initial_callee_stat=callee->stat; - const LinphoneVideoPolicy *video_policy; - LinphoneCall *call_obj; - if ((call_obj=setup_video(caller, callee, change_video_policy))){ - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning+1)); - - video_policy = linphone_core_get_video_policy(caller->lc); - if (video_policy->automatically_accept) { - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); - } else { - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); - } - if (linphone_core_get_media_encryption(caller->lc) != LinphoneMediaEncryptionNone - && linphone_core_get_media_encryption(callee->lc) != LinphoneMediaEncryptionNone) { - const LinphoneCallParams* call_param; - - switch (linphone_core_get_media_encryption(caller->lc)) { - case LinphoneMediaEncryptionZRTP: - case LinphoneMediaEncryptionDTLS: - /*wait for encryption to be on, in case of zrtp/dtls, it can take a few seconds*/ - wait_for(callee->lc,caller->lc,&caller->stat.number_of_LinphoneCallEncryptedOn,initial_caller_stat.number_of_LinphoneCallEncryptedOn+1); - break; - case LinphoneMediaEncryptionNone: - case LinphoneMediaEncryptionSRTP: - break; - } - switch (linphone_core_get_media_encryption(callee->lc)) { - case LinphoneMediaEncryptionZRTP: - case LinphoneMediaEncryptionDTLS: - wait_for(callee->lc,caller->lc,&callee->stat.number_of_LinphoneCallEncryptedOn,initial_callee_stat.number_of_LinphoneCallEncryptedOn+1); - break; - case LinphoneMediaEncryptionNone: - case LinphoneMediaEncryptionSRTP: - break; - } - - call_param = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); - call_param = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); - - } - - if (video_policy->automatically_accept) { - linphone_call_set_next_video_frame_decoded_callback(call_obj,linphone_call_iframe_decoded_cb,callee->lc); - /*send vfu*/ - linphone_call_send_vfu_request(call_obj); - return wait_for(caller->lc,callee->lc,&callee->stat.number_of_IframeDecoded,initial_callee_stat.number_of_IframeDecoded+1); - } else { - return TRUE; - } - } - return FALSE; -} - -static bool_t remove_video(LinphoneCoreManager *caller, LinphoneCoreManager *callee) { - LinphoneCallParams *callee_params; - LinphoneCall *call_obj; - stats initial_caller_stat = caller->stat; - stats initial_callee_stat = callee->stat; - - if (!linphone_core_get_current_call(callee->lc) - || (linphone_call_get_state(linphone_core_get_current_call(callee->lc)) != LinphoneCallStreamsRunning) - || !linphone_core_get_current_call(caller->lc) - || (linphone_call_get_state(linphone_core_get_current_call(caller->lc)) != LinphoneCallStreamsRunning)) { - ms_warning("bad state for removing video"); - return FALSE; - } - - if ((call_obj = linphone_core_get_current_call(callee->lc))) { - callee_params = linphone_core_create_call_params(callee->lc, call_obj); - /* Remove video. */ - linphone_call_params_enable_video(callee_params, FALSE); - linphone_core_update_call(callee->lc, call_obj, callee_params); - linphone_call_params_destroy(callee_params); - - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallUpdatedByRemote, initial_caller_stat.number_of_LinphoneCallUpdatedByRemote + 1)); - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallUpdating, initial_callee_stat.number_of_LinphoneCallUpdating + 1)); - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, initial_callee_stat.number_of_LinphoneCallStreamsRunning + 1)); - BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, initial_caller_stat.number_of_LinphoneCallStreamsRunning + 1)); - - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); - - return TRUE; - } - return FALSE; -} - -static void call_with_video_added(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - - BC_ASSERT_TRUE((call_ok=call(pauline,marie))); - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - - end_call(pauline, marie); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_video_added_2(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - /*in this variant marie is already in automatically accept*/ - LinphoneVideoPolicy marie_policy; - marie_policy.automatically_accept=TRUE; - - - linphone_core_set_video_policy(marie->lc,&marie_policy); - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, FALSE); - - BC_ASSERT_TRUE(call_ok=call(pauline,marie)); - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(marie,pauline, TRUE)); - - end_call(pauline, marie); -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_video_added_random_ports(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - - linphone_core_set_audio_port(marie->lc,-1); - linphone_core_set_video_port(marie->lc,-1); - linphone_core_set_audio_port(pauline->lc,-1); - linphone_core_set_video_port(pauline->lc,-1); - - BC_ASSERT_TRUE(call_ok=call(pauline,marie)); - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - end_call(pauline, marie); -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_several_video_switches(void) { - int dummy = 0; - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - BC_ASSERT_TRUE(call_ok=call(pauline,marie)); - - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ - BC_ASSERT_TRUE(remove_video(pauline,marie)); - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ - BC_ASSERT_TRUE(remove_video(pauline,marie)); - /**/ - end_call(pauline, marie); -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void srtp_call_with_several_video_switches(void) { - int dummy = 0; - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - - if (linphone_core_media_encryption_supported(marie->lc, LinphoneMediaEncryptionSRTP)) { - linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionSRTP); - linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionSRTP); - - BC_ASSERT_TRUE(call_ok=call(pauline,marie)); - if (!call_ok) goto end; - - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ - BC_ASSERT_TRUE(remove_video(pauline,marie)); - BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); - wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ - BC_ASSERT_TRUE(remove_video(pauline,marie)); - /**/ - end_call(pauline, marie); - } else { - ms_warning("Not tested because SRTP is not available."); - } -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_declined_video_base(bool_t using_policy) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall* marie_call; - LinphoneCall* pauline_call; - LinphoneVideoPolicy marie_policy, pauline_policy; - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - bool_t call_ok; - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, FALSE); - - if (using_policy) { - pauline_policy.automatically_initiate=TRUE; - pauline_policy.automatically_accept=FALSE; - marie_policy.automatically_initiate=FALSE; - marie_policy.automatically_accept=FALSE; - - linphone_core_set_video_policy(marie->lc,&marie_policy); - linphone_core_set_video_policy(pauline->lc,&pauline_policy); - } - - caller_test_params.base=linphone_core_create_call_params(pauline->lc, NULL); - if (!using_policy) - linphone_call_params_enable_video(caller_test_params.base,TRUE); - - if (!using_policy){ - callee_test_params.base=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_video(callee_test_params.base,FALSE); - } - - BC_ASSERT_TRUE((call_ok=call_with_params2(pauline,marie,&caller_test_params,&callee_test_params,using_policy))); - if (!call_ok) goto end; - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - marie_call=linphone_core_get_current_call(marie->lc); - pauline_call=linphone_core_get_current_call(pauline->lc); - - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call))); - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call))); - - end_call(pauline, marie); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} -static void call_with_declined_video(void) { - call_with_declined_video_base(FALSE); -} - -static void call_with_declined_video_despite_policy(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall* marie_call; - LinphoneCall* pauline_call; - LinphoneVideoPolicy marie_policy, pauline_policy; - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - bool_t call_ok; - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, FALSE); - - pauline_policy.automatically_initiate=TRUE; - pauline_policy.automatically_accept=TRUE; - marie_policy.automatically_initiate=TRUE; - marie_policy.automatically_accept=TRUE; - - linphone_core_set_video_policy(marie->lc,&marie_policy); - linphone_core_set_video_policy(pauline->lc,&pauline_policy); - - caller_test_params.base=linphone_core_create_call_params(pauline->lc, NULL); - - callee_test_params.base=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_enable_video(callee_test_params.base,FALSE); - - BC_ASSERT_TRUE((call_ok=call_with_params2(pauline,marie,&caller_test_params,&callee_test_params,FALSE))); - if (!call_ok) goto end; - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - marie_call=linphone_core_get_current_call(marie->lc); - pauline_call=linphone_core_get_current_call(pauline->lc); - - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call))); - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call))); - - end_call(pauline, marie); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_declined_video_using_policy(void) { - call_with_declined_video_base(TRUE); -} - - -void video_call_base_2(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - LinphoneCall* callee_call; - LinphoneCall* caller_call; - LinphoneVideoPolicy callee_policy, caller_policy; - - if (using_policy) { - callee_policy.automatically_initiate=FALSE; - callee_policy.automatically_accept=TRUE; - caller_policy.automatically_initiate=TRUE; - caller_policy.automatically_accept=FALSE; - - linphone_core_set_video_policy(callee->lc,&callee_policy); - linphone_core_set_video_policy(caller->lc,&caller_policy); - } - - linphone_core_enable_video_display(callee->lc, callee_video_enabled); - linphone_core_enable_video_capture(callee->lc, callee_video_enabled); - - linphone_core_enable_video_display(caller->lc, caller_video_enabled); - linphone_core_enable_video_capture(caller->lc, caller_video_enabled); - - if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */ - char *path = bc_tester_file("certificates-marie"); - callee->lc->user_certificates_path = ms_strdup(path); - bc_free(path); - path = bc_tester_file("certificates-pauline"); - caller->lc->user_certificates_path = ms_strdup(path); - bc_free(path); - belle_sip_mkdir(callee->lc->user_certificates_path); - belle_sip_mkdir(caller->lc->user_certificates_path); - } - - linphone_core_set_media_encryption(callee->lc,mode); - linphone_core_set_media_encryption(caller->lc,mode); - - caller_test_params.base=linphone_core_create_call_params(caller->lc, NULL); - if (!using_policy) - linphone_call_params_enable_video(caller_test_params.base,TRUE); - - if (!using_policy){ - callee_test_params.base=linphone_core_create_call_params(callee->lc, NULL); - linphone_call_params_enable_video(callee_test_params.base,TRUE); - } - - BC_ASSERT_TRUE(call_with_params2(caller,callee,&caller_test_params,&callee_test_params,using_policy)); - callee_call=linphone_core_get_current_call(callee->lc); - caller_call=linphone_core_get_current_call(caller->lc); - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - - if (callee_call && caller_call ) { - if (callee_video_enabled && caller_video_enabled) { - BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); - BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); - - /*check video path*/ - linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); - linphone_call_send_vfu_request(callee_call); - BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); - } else { - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); - } - liblinphone_tester_check_rtcp(callee,caller); - } -} - - -static void check_fir(LinphoneCoreManager* caller,LinphoneCoreManager* callee ){ - LinphoneCall* callee_call; - LinphoneCall* caller_call; - - callee_call=linphone_core_get_current_call(callee->lc); - caller_call=linphone_core_get_current_call(caller->lc); - - /*check video path is established in both directions. - Indeed, FIR are ignored until the first RTP packet is received, because SSRC is not known.*/ - linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); - linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); - - BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); - BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); - - linphone_call_send_vfu_request(callee_call); - - if (rtp_session_avpf_enabled(callee_call->sessions->rtp_session)){ - BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&caller_call->videostream->ms_video_stat.counter_rcvd_fir, 1)); - }else{ - BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&caller_call->videostream->ms_video_stat.counter_rcvd_fir, 0)); - } - ms_message ("check_fir : [%p] received %d FIR ",&caller_call ,caller_call->videostream->ms_video_stat.counter_rcvd_fir); - ms_message ("check_fir : [%p] stat number of iframe decoded %d ",&callee_call, callee->stat.number_of_IframeDecoded); - - linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); - linphone_call_send_vfu_request(caller_call); - BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); - - if (rtp_session_avpf_enabled(caller_call->sessions->rtp_session)) { - if (rtp_session_avpf_enabled(callee_call->sessions->rtp_session)){ - BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&callee_call->videostream->ms_video_stat.counter_rcvd_fir, 1)); - } - }else{ - BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&callee_call->videostream->ms_video_stat.counter_rcvd_fir, 0)); - } - ms_message ("check_fir : [%p] received %d FIR ",&callee_call ,callee_call->videostream->ms_video_stat.counter_rcvd_fir); - ms_message ("check_fir : [%p] stat number of iframe decoded %d ",&caller_call, caller->stat.number_of_IframeDecoded); - -} - -void video_call_base_3(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { - LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - - LinphoneCall* callee_call; - LinphoneCall* caller_call; - LinphoneVideoPolicy callee_policy, caller_policy; - - if (using_policy) { - callee_policy.automatically_initiate=FALSE; - callee_policy.automatically_accept=TRUE; - caller_policy.automatically_initiate=TRUE; - caller_policy.automatically_accept=FALSE; - - linphone_core_set_video_policy(callee->lc,&callee_policy); - linphone_core_set_video_policy(caller->lc,&caller_policy); - } - - linphone_core_enable_video_display(callee->lc, callee_video_enabled); - linphone_core_enable_video_capture(callee->lc, callee_video_enabled); - - linphone_core_enable_video_display(caller->lc, caller_video_enabled); - linphone_core_enable_video_capture(caller->lc, caller_video_enabled); - - if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */ - char *path = bc_tester_file("certificates-marie"); - callee->lc->user_certificates_path = ms_strdup(path); - bc_free(path); - path = bc_tester_file("certificates-pauline"); - caller->lc->user_certificates_path = ms_strdup(path); - bc_free(path); - belle_sip_mkdir(callee->lc->user_certificates_path); - belle_sip_mkdir(caller->lc->user_certificates_path); - } - - linphone_core_set_media_encryption(callee->lc,mode); - linphone_core_set_media_encryption(caller->lc,mode); - /* Create call params */ - caller_test_params.base=linphone_core_create_call_params(caller->lc, NULL); - - if (!using_policy) - linphone_call_params_enable_video(caller_test_params.base,TRUE); - - if (!using_policy){ - callee_test_params.base=linphone_core_create_call_params(callee->lc, NULL); - linphone_call_params_enable_video(callee_test_params.base,TRUE); - } - - BC_ASSERT_TRUE(call_with_params2(caller,callee,&caller_test_params,&callee_test_params,using_policy)); - callee_call=linphone_core_get_current_call(callee->lc); - caller_call=linphone_core_get_current_call(caller->lc); - - linphone_call_params_destroy(caller_test_params.base); - if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); - - if (callee_call && caller_call ) { - if (callee_video_enabled && caller_video_enabled) { - check_fir(caller,callee); - } else { - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); - BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); - } - liblinphone_tester_check_rtcp(callee,caller); - } -} - - - -static void video_call_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { - video_call_base_2(pauline,marie,using_policy,mode,callee_video_enabled,caller_video_enabled); - end_call(pauline, marie); -} - -static void video_call(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_without_rtcp(void) { - LpConfig *lp; - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - lp = linphone_core_get_config(marie->lc); - lp_config_set_int(lp,"rtp","rtcp_enabled",0); - - lp = linphone_core_get_config(pauline->lc); - lp_config_set_int(lp,"rtp","rtcp_enabled",0); - - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_disable_implicit_AVPF_on_callee(void) { - LinphoneCoreManager* callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - LpConfig *callee_lp; - const LinphoneCallParams *params, *params2; - - callee_lp = linphone_core_get_config(callee->lc); - lp_config_set_int(callee_lp,"rtp","rtcp_fb_implicit_rtcp_fb",0); - - video_call_base_3(caller,callee,TRUE,LinphoneMediaEncryptionNone,TRUE,TRUE); - if(BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(callee->lc))) { - params = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); - BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), "RTP/AVP"); - } - if(BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(caller->lc))) { - params2 =linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); - BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params2), "RTP/AVP"); - } - end_call(caller, callee); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); -} - - -static void video_call_disable_implicit_AVPF_on_caller(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - LpConfig *caller_lp; - const LinphoneCallParams *params, *params2; - - caller_lp = linphone_core_get_config(caller->lc); - lp_config_set_int(caller_lp, "rtp", "rtcp_fb_implicit_rtcp_fb", 0); - - video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); - params = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); - BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), "RTP/AVP"); - params2 = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); - BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params2), "RTP/AVP"); - end_call(caller, callee); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - -static void video_call_AVPF_to_implicit_AVPF(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_avpf_mode(caller->lc, LinphoneAVPFEnabled); - video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); - end_call(caller, callee); - - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - -static void video_call_implicit_AVPF_to_AVPF(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_avpf_mode(callee->lc, LinphoneAVPFEnabled); - video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); - end_call(caller, callee); - - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - -static void video_call_using_policy_AVPF_implicit_caller_and_callee(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base_3(caller, callee, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); - end_call(caller, callee); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); -} - -static void video_call_base_avpf(LinphoneCoreManager *caller, LinphoneCoreManager *callee, bool_t using_policy, LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { - linphone_core_set_avpf_mode(caller->lc, LinphoneAVPFEnabled); - linphone_core_set_avpf_mode(callee->lc, LinphoneAVPFEnabled); - video_call_base_3(caller, callee, using_policy, mode, callee_video_enabled, caller_video_enabled); - end_call(caller, callee); -} - -static void video_call_avpf(void) { - LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - video_call_base_avpf(caller, callee, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); - -} - -static void video_call_zrtp(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - if (linphone_core_media_encryption_supported(marie->lc,LinphoneMediaEncryptionZRTP)) { - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionZRTP,TRUE,TRUE); - } else - ms_message("Skipping video_call_zrtp"); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_dtls(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - if (linphone_core_media_encryption_supported(pauline->lc,LinphoneMediaEncryptionDTLS)) { - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionDTLS,TRUE,TRUE); - } else - ms_message("Skipping video_call_dtls"); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); - -} - - - -static void video_call_using_policy(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base(pauline,marie,TRUE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_using_policy_with_callee_video_disabled(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base(marie,pauline,TRUE,LinphoneMediaEncryptionNone,FALSE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_using_policy_with_caller_video_disabled(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - video_call_base(marie,pauline,TRUE,LinphoneMediaEncryptionNone,TRUE,FALSE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_no_sdp(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - linphone_core_enable_sdp_200_ack(pauline->lc,TRUE); - video_call_base(pauline,marie,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_ice_video_to_novideo(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneVideoPolicy vpol={0}; - vpol.automatically_initiate=TRUE; - linphone_core_set_video_policy(pauline->lc,&vpol); - vpol.automatically_initiate=FALSE; - linphone_core_set_video_policy(marie->lc,&vpol); - _call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void _call_with_ice_video(LinphoneVideoPolicy caller_policy, LinphoneVideoPolicy callee_policy, - bool_t video_added_by_caller, bool_t video_added_by_callee, bool_t video_removed_by_caller, bool_t video_removed_by_callee) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - unsigned int nb_media_starts = 1; - - linphone_core_set_video_policy(pauline->lc, &caller_policy); - linphone_core_set_video_policy(marie->lc, &callee_policy); - linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); - linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); - - linphone_core_set_audio_port(marie->lc, -1); - linphone_core_set_video_port(marie->lc, -1); - linphone_core_set_audio_port(pauline->lc, -1); - linphone_core_set_video_port(pauline->lc, -1); - - BC_ASSERT_TRUE(call_ok = call(pauline, marie)); - if (!call_ok) goto end; - BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); - - /* Wait for ICE reINVITEs to complete. */ - BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2) - && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); - check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); - nb_media_starts++; - - if (video_added_by_caller) { - BC_ASSERT_TRUE(add_video(marie, pauline, FALSE)); - } else if (video_added_by_callee) { - BC_ASSERT_TRUE(add_video(pauline, marie, FALSE)); - } - if (video_added_by_caller || video_added_by_callee) { - BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); - if (linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)))){ - /* Wait for ICE reINVITEs to complete if video was really added */ - BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 4) - && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 4)); - check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); - nb_media_starts++; - } - } - - if (video_removed_by_caller) { - BC_ASSERT_TRUE(remove_video(marie, pauline)); - } else if (video_removed_by_callee) { - BC_ASSERT_TRUE(remove_video(pauline, marie)); - } - if (video_removed_by_caller || video_removed_by_callee) { - BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); - check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); - nb_media_starts++; - } - - end_call(pauline, marie); - -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void call_with_ice_video_added(void) { - LinphoneVideoPolicy vpol = { TRUE, TRUE }; - _call_with_ice_video(vpol, vpol, TRUE, FALSE, TRUE, FALSE); -} - -static void call_with_ice_video_added_2(void) { - LinphoneVideoPolicy vpol = { TRUE, TRUE }; - _call_with_ice_video(vpol, vpol, TRUE, FALSE, FALSE, TRUE); -} - -static void call_with_ice_video_added_3(void) { - LinphoneVideoPolicy vpol = { TRUE, TRUE }; - _call_with_ice_video(vpol, vpol, FALSE, TRUE, TRUE, FALSE); -} - -static void call_with_ice_video_added_and_refused(void) { - LinphoneVideoPolicy caller_policy = { TRUE, TRUE }; - LinphoneVideoPolicy callee_policy = { FALSE, FALSE }; - _call_with_ice_video(caller_policy, callee_policy, TRUE, FALSE, FALSE, FALSE); -} - -static void call_with_ice_video_added_with_video_policies_to_false(void) { - LinphoneVideoPolicy vpol = { FALSE, FALSE }; - _call_with_ice_video(vpol, vpol, FALSE, TRUE, FALSE, FALSE); -} - -#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT /*which is not the case at the moment*/ - -static void call_with_ice_video_and_rtt(void) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - bool_t call_ok; - LinphoneVideoPolicy policy = { TRUE, TRUE }; - LinphoneCallParams *params = NULL; - LinphoneCall *marie_call = NULL; - - linphone_core_set_video_policy(pauline->lc, &policy); - linphone_core_set_video_policy(marie->lc, &policy); - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, FALSE); - linphone_core_enable_video_capture(pauline->lc, FALSE); - linphone_core_enable_video_display(pauline->lc, TRUE); - linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); - linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); - - linphone_core_set_audio_port(marie->lc, -1); - linphone_core_set_video_port(marie->lc, -1); - linphone_core_set_text_port(marie->lc, -1); - linphone_core_set_audio_port(pauline->lc, -1); - linphone_core_set_video_port(pauline->lc, -1); - linphone_core_set_text_port(pauline->lc, -1); - - params = linphone_core_create_default_call_parameters(pauline->lc); - linphone_call_params_enable_realtime_text(params, TRUE); - BC_ASSERT_TRUE(call_ok = call_with_caller_params(pauline, marie, params)); - if (!call_ok) goto end; - BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); - - marie_call = linphone_core_get_current_call(marie->lc); - BC_ASSERT_TRUE(linphone_call_params_audio_enabled(linphone_call_get_current_params(marie_call))); - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marie_call))); - BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(marie_call))); - - end_call(pauline, marie); -end: - linphone_call_params_destroy(params); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -#endif - -static void video_call_with_early_media_no_matching_audio_codecs(void) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCall *out_call, *pauline_call; - LinphoneVideoPolicy vpol={0}; - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, FALSE); - - vpol.automatically_initiate=TRUE; - vpol.automatically_accept=TRUE; - linphone_core_set_video_policy(pauline->lc,&vpol); - linphone_core_set_video_policy(marie->lc,&vpol); - - linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMU", 8000, 1), FALSE); /* Disable PCMU */ - linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMA", 8000, 1), TRUE); /* Enable PCMA */ - - out_call = linphone_core_invite_address(marie->lc, pauline->identity); - linphone_call_ref(out_call); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingInit, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1)); - - pauline_call = linphone_core_get_current_call(pauline->lc); - if (!pauline_call) goto end; - - linphone_core_accept_early_media(pauline->lc, pauline_call); - - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia, 1)); - /*audio stream shall not have been requested to start*/ - BC_ASSERT_PTR_NULL(pauline_call->audiostream->soundread); - - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(out_call))); - BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(pauline_call))); - - linphone_core_accept_call(pauline->lc, pauline_call); - - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); - - end_call(marie, pauline); - -end: - linphone_call_unref(out_call); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_limited_bandwidth(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_download_bandwidth(pauline->lc, 100); - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -#endif /*VIDEO_ENABLED*/ - static void _call_with_media_relay(bool_t random_ports) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -3040,9 +1945,7 @@ static void zrtp_cipher_call(void) { call_base_with_configfile(LinphoneMediaEncryptionZRTP,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE, "marie_zrtp_aes256_rc", "pauline_tcp_rc"); } -static void zrtp_video_call(void) { - call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyNoFirewall,FALSE); -} + static void dtls_srtp_call(void) { call_base(LinphoneMediaEncryptionDTLS,FALSE,FALSE,LinphonePolicyNoFirewall,FALSE); @@ -3055,18 +1958,7 @@ static void dtls_srtp_call_with_media_realy(void) { static void dtls_srtp_ice_call(void) { call_base(LinphoneMediaEncryptionDTLS,FALSE,FALSE,LinphonePolicyUseIce,FALSE); } -#ifdef VIDEO_ENABLED -static void dtls_srtp_video_call(void) { - call_base(LinphoneMediaEncryptionDTLS,TRUE,FALSE,LinphonePolicyNoFirewall,FALSE); -} -static void dtls_srtp_ice_video_call(void) { - call_base(LinphoneMediaEncryptionDTLS,TRUE,FALSE,LinphonePolicyUseIce,FALSE); -} -static void dtls_srtp_ice_video_call_with_relay(void) { - call_base(LinphoneMediaEncryptionDTLS,TRUE,TRUE,LinphonePolicyUseIce,FALSE); -} -#endif static void call_with_declined_srtp(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -3136,7 +2028,7 @@ static void call_with_file_player(void) { LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphonePlayer *player; char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav"); - char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_file_player", "wav"); + char *recordpath = bc_tester_file("record-call_with_file_player.wav"); bool_t call_ok; int attempts; double similar=1; @@ -3211,7 +2103,7 @@ static void call_with_mkv_file_player(void) { ms_warning("Test skipped, no mkv support."); goto end; } - recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_mkv_file_player", "wav"); + recordpath = bc_tester_file("record-call_with_mkv_file_player.wav"); /*make sure the record file doesn't already exists, otherwise this test will append new samples to it*/ unlink(recordpath); @@ -3383,15 +2275,6 @@ void call_base(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_r call_base_with_configfile(mode, enable_video, enable_relay, policy, enable_tunnel, "marie_rc", "pauline_tcp_rc"); } -#ifdef VIDEO_ENABLED -static void srtp_video_ice_call(void) { - call_base(LinphoneMediaEncryptionSRTP,TRUE,FALSE,LinphonePolicyUseIce,FALSE); -} -static void zrtp_video_ice_call(void) { - call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyUseIce,FALSE); -} -#endif - static void srtp_ice_call(void) { call_base(LinphoneMediaEncryptionSRTP,FALSE,FALSE,LinphonePolicyUseIce,FALSE); } @@ -3981,113 +2864,6 @@ static void call_rejected_without_403_because_wrong_credentials_no_auth_req_cb(v call_rejected_because_wrong_credentials_with_params("tester-no-403",FALSE); } -#ifdef VIDEO_ENABLED -static void video_early_media_call(void) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_early_rc"); - LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); - LinphoneCall *pauline_to_marie; - - linphone_core_set_video_device(pauline->lc, "Mire: Mire (synthetic moving picture)"); - - video_call_base_3(pauline, marie, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); - - BC_ASSERT_PTR_NOT_NULL(pauline_to_marie = linphone_core_get_current_call(pauline->lc)); - if(pauline_to_marie) { - BC_ASSERT_EQUAL(pauline_to_marie->videostream->source->desc->id, MS_MIRE_ID, int, "%d"); - } - - end_call(pauline, marie); - - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -/*this is call forking with early media managed at client side (not by flexisip server)*/ -static void multiple_early_media(void) { - LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc"); - LinphoneCoreManager* marie1 = linphone_core_manager_new("marie_early_rc"); - LinphoneCoreManager* marie2 = linphone_core_manager_new("marie_early_rc"); - MSList *lcs=NULL; - LinphoneCallParams *params=linphone_core_create_call_params(pauline->lc, NULL); - LinphoneVideoPolicy pol; - LinphoneCall *marie1_call; - LinphoneCall *marie2_call; - LinphoneCall *pauline_call; - LinphoneInfoMessage *info; - int dummy=0; - pol.automatically_accept=1; - pol.automatically_initiate=1; - - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, TRUE); - - linphone_core_enable_video_capture(marie1->lc, TRUE); - linphone_core_enable_video_display(marie1->lc, TRUE); - linphone_core_set_video_policy(marie1->lc,&pol); - - linphone_core_enable_video_capture(marie2->lc, TRUE); - linphone_core_enable_video_display(marie2->lc, TRUE); - linphone_core_set_video_policy(marie2->lc,&pol); - linphone_core_set_audio_port_range(marie2->lc,40200,40300); - linphone_core_set_video_port_range(marie2->lc,40400,40500); - - lcs=ms_list_append(lcs,marie1->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,pauline->lc); - - linphone_call_params_enable_early_media_sending(params,TRUE); - linphone_call_params_enable_video(params,TRUE); - - linphone_core_invite_address_with_params(pauline->lc,marie1->identity,params); - linphone_call_params_destroy(params); - - BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000)); - BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000)); - BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,3000)); - - pauline_call=linphone_core_get_current_call(pauline->lc); - marie1_call=linphone_core_get_current_call(marie1->lc); - marie2_call=linphone_core_get_current_call(marie2->lc); - - BC_ASSERT_PTR_NOT_NULL(pauline_call); - BC_ASSERT_PTR_NOT_NULL(marie1_call); - BC_ASSERT_PTR_NOT_NULL(marie2_call); - - if (pauline_call && marie1_call && marie2_call){ - - /*wait a bit that streams are established*/ - wait_for_list(lcs,&dummy,1,6000); - BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline),70,int,"%i"); - BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie1), 70, int, "%i"); - BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie2), 70, int, "%i"); - - linphone_core_accept_call(marie1->lc,linphone_core_get_current_call(marie1->lc)); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallStreamsRunning,1,3000)); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,3000)); - - /*marie2 should get her call terminated*/ - BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); - - /*wait a bit that streams are established*/ - wait_for_list(lcs,&dummy,1,3000); - BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(pauline), 71, int, "%i"); - BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie1), 71, int, "%i"); - - /*send an INFO in reverse side to check that dialogs are properly established*/ - info=linphone_core_create_info_message(marie1->lc); - linphone_call_send_info_message(marie1_call,info); - BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_inforeceived,1,3000)); - } - - end_call(pauline, marie1); - - ms_list_free(lcs); - linphone_core_manager_destroy(marie1); - linphone_core_manager_destroy(marie2); - linphone_core_manager_destroy(pauline); -} -#endif - void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList* lcs,LinphoneMediaDirection audio_dir, LinphoneMediaDirection video_dir) { BC_ASSERT_PTR_NOT_NULL(call); if (call) { @@ -4150,128 +2926,8 @@ void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList* } } -#ifdef VIDEO_ENABLED -static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, LinphoneCoreManager *marie, MSList *lcs) { -#define DEFAULT_WAIT_FOR 10000 - LinphoneCallParams *params; - LinphoneVideoPolicy pol; - LinphoneCall *call; - pol.automatically_accept=1; - pol.automatically_initiate=1; - // important: VP8 has really poor performances with the mire camera, at least - // on iOS - so when ever h264 is available, let's use it instead - if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { - disable_all_video_codecs_except_one(pauline->lc,"h264"); - disable_all_video_codecs_except_one(marie->lc,"h264"); - } - - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, TRUE); - linphone_core_set_video_policy(pauline->lc,&pol); - linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_set_video_policy(marie->lc,&pol); - linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); - - linphone_call_set_next_video_frame_decoded_callback(linphone_core_invite_address(pauline->lc,marie->identity) - ,linphone_call_iframe_decoded_cb - ,pauline->lc); - - - BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallIncomingReceived,1,DEFAULT_WAIT_FOR)); - - { - char* remote_uri = linphone_address_as_string_uri_only(pauline->identity); - call = linphone_core_find_call_from_uri(marie->lc,remote_uri); - ms_free(remote_uri); - } - - if (call) { - params=linphone_core_create_call_params(marie->lc, NULL); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendOnly); - linphone_core_accept_call_with_params(marie->lc,call,params); - linphone_call_params_destroy(params); - - BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning,1,DEFAULT_WAIT_FOR)); - BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallPausedByRemote,1,DEFAULT_WAIT_FOR)); - - check_media_direction(marie,call,lcs,LinphoneMediaDirectionSendOnly,LinphoneMediaDirectionSendOnly); - } - - - call=linphone_core_get_current_call(pauline->lc); - if (call) { - check_media_direction(pauline,call,lcs,LinphoneMediaDirectionRecvOnly,LinphoneMediaDirectionRecvOnly); - } - -} -static void accept_call_in_send_base(bool_t caller_has_ice) { - LinphoneCoreManager *pauline, *marie; - MSList *lcs=NULL;; - - marie = linphone_core_manager_new("marie_rc"); - pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - if (caller_has_ice) { - linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); - } - - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - - accept_call_in_send_only_base(pauline,marie,lcs); - - - end_call(marie,pauline); - ms_list_free(lcs); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void accept_call_in_send_only(void) { - accept_call_in_send_base(FALSE); -} - -static void accept_call_in_send_only_with_ice(void) { - accept_call_in_send_base(TRUE); -} - -void two_accepted_call_in_send_only(void) { - LinphoneCoreManager *pauline, *marie, *laure; - MSList *lcs=NULL; - - marie = linphone_core_manager_new("marie_rc"); - linphone_core_use_files(marie->lc, TRUE); - pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - laure = linphone_core_manager_new("laure_rc_udp"); - - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,laure->lc); - - accept_call_in_send_only_base(pauline,marie,lcs); - - reset_counters(&marie->stat); - accept_call_in_send_only_base(laure,marie,lcs); - - end_call(pauline, marie); - end_call(laure, marie); - - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); - linphone_core_manager_destroy(laure); - ms_list_free(lcs); -} -#endif - -static char *create_filepath(const char *dir, const char *filename, const char *ext) { - return ms_strdup_printf("%s/%s.%s",dir,filename,ext); -} - -static void record_call(const char *filename, bool_t enableVideo, const char *video_codec) { +void record_call(const char *filename, bool_t enableVideo, const char *video_codec) { LinphoneCoreManager *marie = NULL; LinphoneCoreManager *pauline = NULL; LinphoneCallParams *marieParams = NULL; @@ -4319,7 +2975,9 @@ static void record_call(const char *filename, bool_t enableVideo, const char *vi formats = linphone_core_get_supported_file_formats(marie->lc); for(i=0, format = formats[0]; format != NULL; i++, format = formats[i]) { - filepath = create_filepath(bc_tester_get_writable_dir_prefix(), filename, format); + char* totalname = ms_strdup_printf("%s.%s", filename, format); + filepath = bc_tester_file(totalname); + ms_free(totalname); remove(filepath); linphone_call_params_set_record_file(marieParams, filepath); BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams)); @@ -4345,54 +3003,6 @@ static void audio_call_recording_test(void) { record_call("recording", FALSE, NULL); } -#ifdef VIDEO_ENABLED -static void video_call_recording_h264_test(void) { - record_call("recording", TRUE, "H264"); -} - -static void video_call_recording_vp8_test(void) { - record_call("recording", TRUE, "VP8"); -} - -static void video_call_snapshot(void) { - LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCallParams *marieParams = linphone_core_create_call_params(marie->lc, NULL); - LinphoneCallParams *paulineParams = linphone_core_create_call_params(pauline->lc, NULL); - LinphoneCall *callInst = NULL; - char *filename = create_filepath(bc_tester_get_writable_dir_prefix(), "snapshot", "jpeg"); - int dummy = 0; - bool_t call_succeeded = FALSE; - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, FALSE); - linphone_call_params_enable_video(marieParams, TRUE); - linphone_call_params_enable_video(paulineParams, TRUE); - - BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams)); - BC_ASSERT_PTR_NOT_NULL(callInst = linphone_core_get_current_call(marie->lc)); - if((call_succeeded == TRUE) && (callInst != NULL)) { - int jpeg_support = linphone_call_take_video_snapshot(callInst, filename); - if (jpeg_support < 0) { - ms_warning("No jpegwriter support!"); - } else { - wait_for_until(marie->lc, pauline->lc, &dummy, 1, 5000); - BC_ASSERT_EQUAL(ortp_file_exist(filename), 0, int, "%d"); - remove(filename); - } - end_call(marie, pauline); - } - ms_free(filename); - linphone_call_params_unref(marieParams); - linphone_call_params_unref(paulineParams); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -#endif - static void call_with_in_dialog_update(void) { LinphoneCoreManager* marie; LinphoneCoreManager* pauline; @@ -4609,84 +3219,6 @@ static void outgoing_invite_with_invalid_sdp(void) { linphone_core_manager_destroy(caller); } -static void incoming_reinvite_with_invalid_ack_sdp(void){ -#ifdef VIDEO_ENABLED - LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc"); - LinphoneCall * inc_call; - BC_ASSERT_TRUE(call(caller,callee)); - inc_call = linphone_core_get_current_call(callee->lc); - - BC_ASSERT_PTR_NOT_NULL(inc_call); - if (inc_call) { - const LinphoneCallParams *caller_params; - stats initial_caller_stat=caller->stat; - stats initial_callee_stat=callee->stat; - sal_call_set_sdp_handling(inc_call->op, SalOpSDPSimulateError); /* will force a parse error for the ACK SDP*/ - BC_ASSERT_PTR_NOT_NULL(setup_video(caller, callee, TRUE)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning)); - /*Basically the negotiation failed but since the call was already running, we expect it to restore to - the previous state so error stats should not be changed*/ - BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallError,initial_callee_stat.number_of_LinphoneCallError, int, "%d"); - /*and remote should have received an update notification*/ - BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote+1, int, "%d"); - - - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - caller_params = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,(int*)&caller_params->has_video,FALSE)); - - sal_call_set_sdp_handling(inc_call->op, SalOpSDPNormal); - } - end_call(caller, callee); - - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); -#else - ms_warning("not tested because video not available"); -#endif -} - -static void outgoing_reinvite_with_invalid_ack_sdp(void) { -#ifdef VIDEO_ENABLED - LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc"); - LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc"); - LinphoneCall * out_call; - BC_ASSERT_TRUE(call(caller,callee)); - out_call = linphone_core_get_current_call(caller->lc); - - BC_ASSERT_PTR_NOT_NULL(out_call); - if (out_call) { - stats initial_caller_stat=caller->stat; - stats initial_callee_stat=callee->stat; - sal_call_set_sdp_handling(out_call->op, SalOpSDPSimulateError); /* will force a parse error for the ACK SDP*/ - BC_ASSERT_PTR_NOT_NULL(setup_video(caller, callee, TRUE)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); - BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning)); - /*Basically the negotiation failed but since the call was already running, we expect it to restore to - the previous state so error stats should not be changed*/ - BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallError,initial_callee_stat.number_of_LinphoneCallError, int, "%d"); - /*and remote should not have received any update notification*/ - BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote, int, "%d"); - - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); - BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); - - sal_call_set_sdp_handling(out_call->op, SalOpSDPNormal); - } - end_call(caller, callee); - - linphone_core_manager_destroy(callee); - linphone_core_manager_destroy(caller); -#else - ms_warning("not tested because video not available"); -#endif -} - - static void call_with_paused_no_sdp_on_resume(void) { int dummy=0; LinphoneCoreManager* marie; @@ -4737,7 +3269,7 @@ end: linphone_core_manager_destroy(pauline); } -static void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ){ +void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); MSList* lcs = NULL; @@ -4809,10 +3341,6 @@ static void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ic linphone_core_manager_destroy(pauline); } -static void call_with_early_media_and_no_sdp_in_200_with_video(void){ - early_media_without_sdp_in_200_base(TRUE, FALSE); -} - static void call_with_early_media_and_no_sdp_in_200(void){ early_media_without_sdp_in_200_base(FALSE, FALSE); } @@ -4934,251 +3462,6 @@ static void call_with_transport_change_after_released(void) { static void unsucessfull_call_with_transport_change_after_released(void) { call_with_transport_change_base(FALSE); } -#ifdef VIDEO_ENABLED - -static void video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryption mode, bool_t no_sdp) { - LinphoneCoreManager* marie; - LinphoneCoreManager* pauline; - LinphoneCallParams *params; - const LinphoneCallParams *current_params; - MSList *lcs=NULL; - bool_t calls_ok; - - marie = linphone_core_manager_new( "marie_rc"); - pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_avpf_mode(pauline->lc,TRUE); - - // important: VP8 has really poor performances with the mire camera, at least - // on iOS - so when ever h264 is available, let's use it instead - if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { - disable_all_video_codecs_except_one(pauline->lc,"h264"); - disable_all_video_codecs_except_one(marie->lc,"h264"); - } - linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); - linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); - linphone_core_set_avpf_mode(marie->lc,TRUE); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - - video_call_base_2(marie,pauline,TRUE,mode,TRUE,TRUE); - - calls_ok = linphone_core_get_current_call(marie->lc) != NULL && linphone_core_get_current_call(pauline->lc) != NULL; - BC_ASSERT_TRUE(calls_ok); - - if (calls_ok) { - params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc)); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionInactive); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); - - linphone_core_update_call(marie->lc, linphone_core_get_current_call(marie->lc),params); - linphone_call_params_destroy(params); - - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,1)); - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1)); - - check_media_direction(marie,linphone_core_get_current_call(marie->lc),lcs,LinphoneMediaDirectionInactive,LinphoneMediaDirectionInactive); - check_media_direction(pauline,linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionInactive); - - if (no_sdp) { - linphone_core_enable_sdp_200_ack(marie->lc,TRUE); - } - - params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc)); - linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv); - linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv); - linphone_core_update_call(marie->lc,linphone_core_get_current_call(marie->lc),params); - linphone_call_params_destroy(params); - - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); - BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); - - check_media_direction(marie,linphone_core_get_current_call(marie->lc),lcs,LinphoneMediaDirectionSendRecv,LinphoneMediaDirectionSendRecv); - check_media_direction(pauline,linphone_core_get_current_call(pauline->lc),lcs,LinphoneMediaDirectionSendRecv,LinphoneMediaDirectionSendRecv); - - /*assert that after pause and resume, SRTP is still being used*/ - current_params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(current_params) , mode, int, "%d"); - current_params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)); - BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(current_params) , mode, int, "%d"); - - } - end_call(marie,pauline); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void video_call_with_re_invite_inactive_followed_by_re_invite(void) { - video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionNone,FALSE); -} - -static void video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp(void) { - video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionNone, TRUE); -} - -static void srtp_video_call_with_re_invite_inactive_followed_by_re_invite(void) { - if (ms_srtp_supported()) - video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionSRTP,FALSE); - else - ms_message("srtp_video_call_with_re_invite_inactive_followed_by_re_invite skipped, missing srtp support"); -} - -static void srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp(void) { - if (ms_srtp_supported()) - video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionSRTP, TRUE); - else - ms_message("srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp skipped, missing srtp support"); -} - -static void video_call_ice_params(void) { - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - - linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); - linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); - video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - -static void audio_call_with_ice_with_video_policy_enabled(void){ - LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneVideoPolicy vpol; - - - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, TRUE); - vpol.automatically_accept = vpol.automatically_initiate = TRUE; - linphone_core_set_video_policy(marie->lc, &vpol); - vpol.automatically_accept = vpol.automatically_initiate = FALSE; - linphone_core_set_video_policy(pauline->lc, &vpol); - - linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); - linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); - - linphone_core_invite_address(pauline->lc, marie->identity); - if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end; - linphone_core_accept_call(marie->lc, linphone_core_get_current_call(marie->lc)); - /* - LinphoneCallParams *params; - params = linphone_core_create_call_params(marie->lc, linphone_core_get_current_call(marie->lc)); - linphone_call_params_enable_video(params, TRUE); - linphone_core_accept_call_with_params(marie->lc, linphone_core_get_current_call(marie->lc), params); - linphone_call_params_destroy(params);*/ - - /*wait for call to be established and ICE reINVITEs to be done */ - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); - - linphone_core_pause_call(marie->lc, linphone_core_get_current_call(marie->lc)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallPausedByRemote, 1)); - BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPaused, 1)); - - end_call(marie, pauline); -end: - linphone_core_manager_destroy(marie); - linphone_core_manager_destroy(pauline); -} - - -static void classic_video_entry_phone_setup(void) { - LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc"); - LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - LinphoneCallParams *early_media_params = NULL; - LinphoneCallParams *in_call_params = NULL; - LinphoneCall *callee_call = NULL; - LinphoneVideoPolicy vpol = { TRUE, TRUE }; - MSList *lcs = NULL; - int retry = 0; - bool_t ok; - - lcs = ms_list_append(lcs, caller_mgr->lc); - lcs = ms_list_append(lcs, callee_mgr->lc); - - linphone_core_enable_video_capture(caller_mgr->lc, TRUE); - linphone_core_enable_video_display(caller_mgr->lc, TRUE); - linphone_core_enable_video_capture(callee_mgr->lc, TRUE); - linphone_core_enable_video_display(callee_mgr->lc, TRUE); - linphone_core_set_avpf_mode(caller_mgr->lc, LinphoneAVPFEnabled); - linphone_core_set_avpf_mode(callee_mgr->lc, LinphoneAVPFEnabled); - linphone_core_set_video_policy(caller_mgr->lc, &vpol); - linphone_core_set_video_policy(callee_mgr->lc, &vpol); - - // important: VP8 has really poor performances with the mire camera, at least - // on iOS - so when ever h264 is available, let's use it instead - if (linphone_core_find_payload_type(caller_mgr->lc,"h264", -1, -1)!=NULL) { - disable_all_video_codecs_except_one(caller_mgr->lc,"h264"); - disable_all_video_codecs_except_one(callee_mgr->lc,"h264"); - } - - linphone_core_set_video_device(caller_mgr->lc, liblinphone_tester_mire_id); - linphone_core_set_video_device(callee_mgr->lc, liblinphone_tester_mire_id); - - BC_ASSERT_PTR_NOT_NULL(linphone_core_invite_address(caller_mgr->lc, callee_mgr->identity)); - - ok = wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1); - BC_ASSERT_TRUE(ok); - if (!ok) goto end; - BC_ASSERT_TRUE(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress == 1); - - callee_call = linphone_core_get_call_by_remote_address2(callee_mgr->lc, caller_mgr->identity); - early_media_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); - linphone_call_params_set_audio_direction(early_media_params, LinphoneMediaDirectionInactive); - linphone_call_params_set_video_direction(early_media_params, LinphoneMediaDirectionRecvOnly); - linphone_core_accept_early_media_with_params(callee_mgr->lc, callee_call, early_media_params); - linphone_call_params_destroy(early_media_params); - - while ((caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia != 1) && (retry++ < 100)) { - linphone_core_iterate(caller_mgr->lc); - linphone_core_iterate(callee_mgr->lc); - ms_usleep(20000); - } - BC_ASSERT_TRUE(caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia == 1); - BC_ASSERT_TRUE(callee_mgr->stat.number_of_LinphoneCallIncomingEarlyMedia == 1); - - check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionRecvOnly); - callee_call = linphone_core_get_call_by_remote_address2(callee_mgr->lc, caller_mgr->identity); - in_call_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); - linphone_call_params_set_audio_direction(in_call_params, LinphoneMediaDirectionSendRecv); - linphone_call_params_set_video_direction(in_call_params, LinphoneMediaDirectionSendRecv); - linphone_core_accept_call_with_params(callee_mgr->lc, callee_call, in_call_params); - linphone_call_params_destroy(in_call_params); - - BC_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallConnected, 1)); - BC_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallConnected, 1)); - - ok = wait_for_until(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) - && wait_for_until(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallStreamsRunning, 1, 2000); - BC_ASSERT_TRUE(ok); - if (!ok) goto end; - check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionSendRecv); - - callee_call = linphone_core_get_current_call(callee_mgr->lc); - in_call_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); - linphone_call_params_set_audio_direction(in_call_params, LinphoneMediaDirectionRecvOnly); - linphone_call_params_set_video_direction(in_call_params, LinphoneMediaDirectionSendOnly); - linphone_core_update_call(callee_mgr->lc, callee_call, in_call_params); - linphone_call_params_destroy(in_call_params); - - ok = wait_for_until(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 2, 2000) - && wait_for_until(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallStreamsRunning, 2, 2000); - BC_ASSERT_TRUE(ok); - if (!ok) goto end; - callee_call = linphone_core_get_current_call(callee_mgr->lc); - check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionRecvOnly, LinphoneMediaDirectionSendOnly); - - end_call(caller_mgr, callee_mgr); - -end: - linphone_core_manager_destroy(callee_mgr); - linphone_core_manager_destroy(caller_mgr); - ms_list_free(lcs); -} -#endif #if !defined(__arm__) && !defined(__arm64__) && !TARGET_IPHONE_SIMULATOR && !defined(ANDROID) static void completion_cb(void *user_data, int percentage){ @@ -5417,7 +3700,7 @@ static void call_with_rtp_io_mode(void) { LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphonePlayer *player; char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav"); - char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_rtp_io_mode", "wav"); + char *recordpath = bc_tester_file("record-call_with_rtp_io_mode.wav"); bool_t call_ok; int attempts; double similar=1; @@ -5676,7 +3959,7 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { // The following are only used for the record test LinphonePlayer *player; char *hellopath = bc_tester_res("sounds/ahbahouaismaisbon.wav"); // File to be played - char *recordpath = create_filepath(bc_tester_get_writable_dir_prefix(), "record-call_with_file_player", "wav"); // File to record the received sound + char *recordpath = bc_tester_file("record-call_with_file_player.wav"); // File to record the received sound double similar = 1; // The factor of similarity between the played file and the one recorded const double threshold = 0.85; // Minimum similarity value to consider the record file equal to the one sent @@ -6061,7 +4344,7 @@ static void call_logs_if_no_db_set(void) { static void call_logs_migrate(void) { LinphoneCoreManager* laure = linphone_core_manager_new("laure_call_logs_rc"); - char *logs_db = create_filepath(bc_tester_get_writable_dir_prefix(), "call_logs", "db"); + char *logs_db = bc_tester_file("call_logs.db"); int i = 0; int incoming_count = 0, outgoing_count = 0, missed_count = 0, aborted_count = 0, decline_count = 0, video_enabled_count = 0; @@ -6123,7 +4406,7 @@ static void call_logs_migrate(void) { static void call_logs_sqlite_storage(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - char *logs_db = create_filepath(bc_tester_get_writable_dir_prefix(), "call_logs", "db"); + char *logs_db = bc_tester_file("call_logs.db"); MSList *logs = NULL; LinphoneCallLog *call_log = NULL; LinphoneAddress *laure = NULL; @@ -6546,13 +4829,6 @@ test_t call_tests[] = { TEST_NO_TAG("Call without SDP and ACK without SDP", call_with_no_sdp_ack_without_sdp), TEST_NO_TAG("Call paused resumed", call_paused_resumed), TEST_NO_TAG("Call paused resumed with sip packets looses", call_paused_resumed_with_sip_packets_losses), -#ifdef VIDEO_ENABLED - TEST_NO_TAG("Call paused resumed with video", call_paused_resumed_with_video), - TEST_NO_TAG("Call paused resumed with video no sdp ack", call_paused_resumed_with_no_sdp_ack), - TEST_NO_TAG("Call paused resumed with video no sdk ack using video policy for resume offers", call_paused_resumed_with_no_sdp_ack_using_video_policy), - TEST_NO_TAG("Call paused, updated and resumed with video no sdk ack using video policy for resume offers", call_paused_updated_resumed_with_no_sdp_ack_using_video_policy), - TEST_NO_TAG("Call paused, updated and resumed with video no sdk ack using video policy for resume offers with accept call update", call_paused_updated_resumed_with_no_sdp_ack_using_video_policy_and_accept_call_update), -#endif TEST_NO_TAG("Call paused by both parties", call_paused_by_both), TEST_NO_TAG("Call paused resumed with loss", call_paused_resumed_with_loss), TEST_NO_TAG("Call paused resumed from callee", call_paused_resumed_from_callee), @@ -6562,67 +4838,11 @@ test_t call_tests[] = { TEST_NO_TAG("ZRTP Cipher call", zrtp_cipher_call), TEST_NO_TAG("DTLS SRTP call", dtls_srtp_call), TEST_NO_TAG("DTLS SRTP call with media relay", dtls_srtp_call_with_media_realy), - TEST_NO_TAG("ZRTP video call", zrtp_video_call), TEST_NO_TAG("SRTP call with declined srtp", call_with_declined_srtp), TEST_NO_TAG("SRTP call paused and resumed", call_srtp_paused_and_resumed), TEST_NO_TAG("Call with file player", call_with_file_player), TEST_NO_TAG("Call with mkv file player", call_with_mkv_file_player), TEST_ONE_TAG("Audio call with ICE no matching audio codecs", audio_call_with_ice_no_matching_audio_codecs, "ICE"), -#ifdef VIDEO_ENABLED - TEST_NO_TAG("Simple video call AVPF", video_call_avpf), - TEST_NO_TAG("Simple video call implicit AVPF both", video_call_using_policy_AVPF_implicit_caller_and_callee), - TEST_NO_TAG("Simple video call disable implicit AVPF on callee", video_call_disable_implicit_AVPF_on_callee), - TEST_NO_TAG("Simple video call disable implicit AVPF on caller", video_call_disable_implicit_AVPF_on_caller), - TEST_NO_TAG("Simple video call AVPF to implicit AVPF", video_call_AVPF_to_implicit_AVPF), - TEST_NO_TAG("Simple video call implicit AVPF to AVPF", video_call_implicit_AVPF_to_AVPF), - TEST_NO_TAG("Simple video call", video_call), - TEST_NO_TAG("Simple video call without rtcp",video_call_without_rtcp), - TEST_NO_TAG("Simple ZRTP video call", video_call_zrtp), - TEST_NO_TAG("Simple DTLS video call", video_call_dtls), - TEST_NO_TAG("Simple video call using policy", video_call_using_policy), - TEST_NO_TAG("Video call using policy with callee video disabled", video_call_using_policy_with_callee_video_disabled), - TEST_NO_TAG("Video call using policy with caller video disabled", video_call_using_policy_with_caller_video_disabled), - TEST_NO_TAG("Video call without SDP", video_call_no_sdp), - TEST_ONE_TAG("SRTP ice video call", srtp_video_ice_call, "ICE"), - TEST_ONE_TAG("ZRTP ice video call", zrtp_video_ice_call, "ICE"), - TEST_NO_TAG("Call with video added", call_with_video_added), - TEST_NO_TAG("Call with video added 2", call_with_video_added_2), - TEST_NO_TAG("Call with video added (random ports)", call_with_video_added_random_ports), - TEST_NO_TAG("Call with several video switches", call_with_several_video_switches), - TEST_NO_TAG("SRTP call with several video switches", srtp_call_with_several_video_switches), - TEST_NO_TAG("Call with video declined", call_with_declined_video), - TEST_NO_TAG("Call with video declined despite policy", call_with_declined_video_despite_policy), - TEST_NO_TAG("Call with video declined using policy", call_with_declined_video_using_policy), - TEST_NO_TAG("Video early-media call", video_early_media_call), - TEST_NO_TAG("Call with multiple early media", multiple_early_media), - TEST_ONE_TAG("Call with ICE from video to non-video", call_with_ice_video_to_novideo, "ICE"), - TEST_ONE_TAG("Call with ICE and video added", call_with_ice_video_added, "ICE"), - TEST_ONE_TAG("Call with ICE and video added 2", call_with_ice_video_added_2, "ICE"), - TEST_ONE_TAG("Call with ICE and video added 3", call_with_ice_video_added_3, "ICE"), - TEST_ONE_TAG("Call with ICE and video added and refused", call_with_ice_video_added_and_refused, "ICE"), - TEST_ONE_TAG("Call with ICE and video added with video policies to false", call_with_ice_video_added_with_video_policies_to_false, "ICE"), -#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT - TEST_ONE_TAG("Call with ICE, video and realtime text", call_with_ice_video_and_rtt, "ICE"), -#endif - TEST_ONE_TAG("Video call with ICE accepted using call params", video_call_ice_params, "ICE"), - TEST_ONE_TAG("Audio call with ICE paused with caller video policy enabled", audio_call_with_ice_with_video_policy_enabled, "ICE"), - TEST_NO_TAG("Video call recording (H264)", video_call_recording_h264_test), - TEST_NO_TAG("Video call recording (VP8)", video_call_recording_vp8_test), - TEST_NO_TAG("Snapshot", video_call_snapshot), - TEST_NO_TAG("Video call with early media and no matching audio codecs", video_call_with_early_media_no_matching_audio_codecs), - TEST_NO_TAG("DTLS SRTP video call", dtls_srtp_video_call), - TEST_ONE_TAG("DTLS SRTP ice video call", dtls_srtp_ice_video_call, "ICE"), - TEST_ONE_TAG("DTLS SRTP ice video call with relay", dtls_srtp_ice_video_call_with_relay, "ICE"), - TEST_NO_TAG("Video call with limited bandwidth", video_call_limited_bandwidth), - TEST_NO_TAG("Video call accepted in send only", accept_call_in_send_only), - TEST_ONE_TAG("Video call accepted in send only with ice", accept_call_in_send_only_with_ice, "ICE"), - TEST_NO_TAG("2 Video call accepted in send only", two_accepted_call_in_send_only), - TEST_NO_TAG("Video call with re-invite(inactive) followed by re-invite", video_call_with_re_invite_inactive_followed_by_re_invite), - TEST_NO_TAG("Video call with re-invite(inactive) followed by re-invite(no sdp)", video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp), - TEST_NO_TAG("SRTP Video call with re-invite(inactive) followed by re-invite", srtp_video_call_with_re_invite_inactive_followed_by_re_invite), - TEST_NO_TAG("SRTP Video call with re-invite(inactive) followed by re-invite(no sdp)", srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp), - TEST_NO_TAG("Classic video entry phone setup", classic_video_entry_phone_setup), -#endif TEST_ONE_TAG("SRTP ice call", srtp_ice_call, "ICE"), TEST_ONE_TAG("ZRTP ice call", zrtp_ice_call, "ICE"), TEST_ONE_TAG("ZRTP ice call with relay", zrtp_ice_call_with_relay, "ICE"), @@ -6652,21 +4872,17 @@ test_t call_tests[] = { TEST_NO_TAG("Call redirected by callee", call_redirect), TEST_NO_TAG("Call with specified codec bitrate", call_with_specified_codec_bitrate), TEST_NO_TAG("Call with no audio codec", call_with_no_audio_codec), - TEST_NO_TAG("Video call with no audio and no video codec", video_call_with_no_audio_and_no_video_codec), TEST_NO_TAG("Call with in-dialog UPDATE request", call_with_in_dialog_update), TEST_NO_TAG("Call with in-dialog very early call request", call_with_very_early_call_update), TEST_NO_TAG("Call with in-dialog codec change", call_with_in_dialog_codec_change), TEST_NO_TAG("Call with in-dialog codec change no sdp", call_with_in_dialog_codec_change_no_sdp), TEST_NO_TAG("Call with pause no SDP on resume", call_with_paused_no_sdp_on_resume), TEST_NO_TAG("Call with early media and no SDP in 200 Ok", call_with_early_media_and_no_sdp_in_200), - TEST_NO_TAG("Call with early media and no SDP in 200 Ok with video", call_with_early_media_and_no_sdp_in_200_with_video), TEST_ONE_TAG("Call with ICE and no SDP in 200 OK", call_with_early_media_ice_and_no_sdp_in_200, "ICE"), TEST_NO_TAG("Call with custom supported tags", call_with_custom_supported_tags), TEST_NO_TAG("Call log from taken from asserted id", call_log_from_taken_from_p_asserted_id), TEST_NO_TAG("Incoming INVITE with invalid SDP", incoming_invite_with_invalid_sdp), TEST_NO_TAG("Outgoing INVITE with invalid ACK SDP", outgoing_invite_with_invalid_sdp), - TEST_NO_TAG("Incoming REINVITE with invalid SDP in ACK", incoming_reinvite_with_invalid_ack_sdp), - TEST_NO_TAG("Outgoing REINVITE with invalid SDP in ACK", outgoing_reinvite_with_invalid_ack_sdp), TEST_NO_TAG("Call with generic CN", call_with_generic_cn), TEST_NO_TAG("Call with transport change after released", call_with_transport_change_after_released), TEST_NO_TAG("Unsuccessful call with transport change after released", unsucessfull_call_with_transport_change_after_released), diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c new file mode 100644 index 000000000..ea4cfb5ca --- /dev/null +++ b/tester/call_video_tester.c @@ -0,0 +1,1782 @@ +/* + liblinphone_tester - liblinphone test suite + Copyright (C) 2013 Belledonne Communications SARL + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "linphonecore.h" +#include "liblinphone_tester.h" +#include "private.h" + +#ifdef VIDEO_ENABLED +static void call_paused_resumed_with_video_base_call_cb(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *message) { + if (cstate == LinphoneCallUpdatedByRemote) { + LinphoneCallParams *params = linphone_core_create_call_params(lc, call); + linphone_call_params_enable_video(params, TRUE); + ms_message (" New state LinphoneCallUpdatedByRemote on call [%p], accepting with video on",call); + BC_ASSERT_NOT_EQUAL(linphone_core_accept_call_update(lc, call, params), 0, int, "%i"); + linphone_call_params_destroy(params); + } +} +/*this test makes sure that pause/resume will not bring up video by accident*/ +static void call_paused_resumed_with_video_base(bool_t sdp_200_ack + ,bool_t use_video_policy_for_re_invite_sdp_200 + ,bool_t resume_in_audio_send_only_video_inactive_first + ,bool_t with_call_accept){ + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall* call_pauline, *call_marie; + MSList *lcs = NULL; + LinphoneVideoPolicy vpol; + bool_t call_ok; + LinphoneCoreVTable *vtable = linphone_core_v_table_new(); + vtable->call_state_changed = call_paused_resumed_with_video_base_call_cb; + lcs = ms_list_append(lcs, pauline->lc); + lcs = ms_list_append(lcs, marie->lc); + + vpol.automatically_accept = FALSE; + vpol.automatically_initiate = TRUE; /* needed to present a video mline*/ + + linphone_core_set_video_policy(marie->lc, &vpol); + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + + vpol.automatically_accept = FALSE; + vpol.automatically_initiate = TRUE; + + linphone_core_set_video_policy(pauline->lc, &vpol); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); + + BC_ASSERT_TRUE((call_ok=call(marie, pauline))); + + if (!call_ok) goto end; + + call_pauline = linphone_core_get_current_call(pauline->lc); + call_marie = linphone_core_get_current_call(marie->lc); + + wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); + + linphone_core_pause_call(pauline->lc,call_pauline); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1)); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_remote_params(call_marie))); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1)); + + /*stay in pause a little while in order to generate traffic*/ + wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000); + + /*check if video stream is still offered even if disabled*/ + + BC_ASSERT_EQUAL(call_pauline->localdesc->nb_streams, 2, int, "%i"); + BC_ASSERT_EQUAL(call_marie->localdesc->nb_streams, 2, int, "%i"); + + linphone_core_enable_sdp_200_ack(pauline->lc,sdp_200_ack); + + if (use_video_policy_for_re_invite_sdp_200) { + LpConfig *marie_lp; + marie_lp = linphone_core_get_config(marie->lc); + lp_config_set_int(marie_lp,"sip","sdp_200_ack_follow_video_policy",1); + } + /*now pauline wants to resume*/ + if (resume_in_audio_send_only_video_inactive_first) { + LinphoneCallParams *params = linphone_core_create_call_params(pauline->lc, call_pauline); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly); + linphone_core_update_call(pauline->lc,call_pauline,params); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,2)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdating,1)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv); + if (with_call_accept) { + linphone_core_add_listener(marie->lc, vtable); + } + linphone_core_update_call(pauline->lc,call_pauline,params); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3)); + linphone_call_params_destroy(params); + } else { + linphone_core_resume_call(pauline->lc, call_pauline); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallResuming,1)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + } + + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); + + if (use_video_policy_for_re_invite_sdp_200) { + /*make sure video was offered*/ + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_remote_params(call_pauline))); + } else { + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_pauline))); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(call_marie))); + } + end_call(marie, pauline); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + ms_list_free(lcs); +} +static void call_paused_resumed_with_video(void){ + call_paused_resumed_with_video_base(FALSE, FALSE,FALSE,FALSE); +} + +static void call_paused_resumed_with_no_sdp_ack(void){ + call_paused_resumed_with_video_base(TRUE, FALSE,FALSE,FALSE); +} +static void call_paused_resumed_with_no_sdp_ack_using_video_policy(void){ + call_paused_resumed_with_video_base(TRUE, TRUE,FALSE,FALSE); +} +static void call_paused_updated_resumed_with_no_sdp_ack_using_video_policy(void){ + call_paused_resumed_with_video_base(TRUE, TRUE,TRUE,FALSE); +} +static void call_paused_updated_resumed_with_no_sdp_ack_using_video_policy_and_accept_call_update(void){ + call_paused_resumed_with_video_base(TRUE, TRUE,TRUE,TRUE); +} + +static void zrtp_video_call(void) { + call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyNoFirewall,FALSE); +} + +static LinphoneCall* setup_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy) { + LinphoneVideoPolicy caller_policy; + LinphoneCallParams* callee_params; + LinphoneCall* call_obj; + + if (!linphone_core_get_current_call(callee->lc) || linphone_call_get_state(linphone_core_get_current_call(callee->lc)) != LinphoneCallStreamsRunning + || !linphone_core_get_current_call(caller->lc) || linphone_call_get_state(linphone_core_get_current_call(caller->lc)) != LinphoneCallStreamsRunning ) { + ms_warning("bad state for adding video"); + return NULL; + } + + if (change_video_policy) { + caller_policy.automatically_accept=TRUE; + caller_policy.automatically_initiate=TRUE; + linphone_core_set_video_policy(caller->lc,&caller_policy); + } + linphone_core_enable_video_capture(callee->lc, TRUE); + linphone_core_enable_video_display(callee->lc, TRUE); + linphone_core_enable_video_capture(caller->lc, TRUE); + linphone_core_enable_video_display(caller->lc, FALSE); + + if ((call_obj = linphone_core_get_current_call(callee->lc))) { + callee_params = linphone_core_create_call_params(callee->lc, call_obj); + /*add video*/ + linphone_call_params_enable_video(callee_params,TRUE); + linphone_core_update_call(callee->lc,call_obj,callee_params); + linphone_call_params_destroy(callee_params); + } + return call_obj; +} + +bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy) { + stats initial_caller_stat=caller->stat; + stats initial_callee_stat=callee->stat; + const LinphoneVideoPolicy *video_policy; + LinphoneCall *call_obj; + if ((call_obj=setup_video(caller, callee, change_video_policy))){ + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning+1)); + + video_policy = linphone_core_get_video_policy(caller->lc); + if (video_policy->automatically_accept) { + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); + } else { + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); + } + if (linphone_core_get_media_encryption(caller->lc) != LinphoneMediaEncryptionNone + && linphone_core_get_media_encryption(callee->lc) != LinphoneMediaEncryptionNone) { + const LinphoneCallParams* call_param; + + switch (linphone_core_get_media_encryption(caller->lc)) { + case LinphoneMediaEncryptionZRTP: + case LinphoneMediaEncryptionDTLS: + /*wait for encryption to be on, in case of zrtp/dtls, it can take a few seconds*/ + wait_for(callee->lc,caller->lc,&caller->stat.number_of_LinphoneCallEncryptedOn,initial_caller_stat.number_of_LinphoneCallEncryptedOn+1); + break; + case LinphoneMediaEncryptionNone: + case LinphoneMediaEncryptionSRTP: + break; + } + switch (linphone_core_get_media_encryption(callee->lc)) { + case LinphoneMediaEncryptionZRTP: + case LinphoneMediaEncryptionDTLS: + wait_for(callee->lc,caller->lc,&callee->stat.number_of_LinphoneCallEncryptedOn,initial_callee_stat.number_of_LinphoneCallEncryptedOn+1); + break; + case LinphoneMediaEncryptionNone: + case LinphoneMediaEncryptionSRTP: + break; + } + + call_param = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); + call_param = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); + + } + + if (video_policy->automatically_accept) { + linphone_call_set_next_video_frame_decoded_callback(call_obj,linphone_call_iframe_decoded_cb,callee->lc); + /*send vfu*/ + linphone_call_send_vfu_request(call_obj); + return wait_for(caller->lc,callee->lc,&callee->stat.number_of_IframeDecoded,initial_callee_stat.number_of_IframeDecoded+1); + } else { + return TRUE; + } + } + return FALSE; +} + +static bool_t remove_video(LinphoneCoreManager *caller, LinphoneCoreManager *callee) { + LinphoneCallParams *callee_params; + LinphoneCall *call_obj; + stats initial_caller_stat = caller->stat; + stats initial_callee_stat = callee->stat; + + if (!linphone_core_get_current_call(callee->lc) + || (linphone_call_get_state(linphone_core_get_current_call(callee->lc)) != LinphoneCallStreamsRunning) + || !linphone_core_get_current_call(caller->lc) + || (linphone_call_get_state(linphone_core_get_current_call(caller->lc)) != LinphoneCallStreamsRunning)) { + ms_warning("bad state for removing video"); + return FALSE; + } + + if ((call_obj = linphone_core_get_current_call(callee->lc))) { + callee_params = linphone_core_create_call_params(callee->lc, call_obj); + /* Remove video. */ + linphone_call_params_enable_video(callee_params, FALSE); + linphone_core_update_call(callee->lc, call_obj, callee_params); + linphone_call_params_destroy(callee_params); + + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallUpdatedByRemote, initial_caller_stat.number_of_LinphoneCallUpdatedByRemote + 1)); + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallUpdating, initial_callee_stat.number_of_LinphoneCallUpdating + 1)); + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &callee->stat.number_of_LinphoneCallStreamsRunning, initial_callee_stat.number_of_LinphoneCallStreamsRunning + 1)); + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallStreamsRunning, initial_caller_stat.number_of_LinphoneCallStreamsRunning + 1)); + + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); + + return TRUE; + } + return FALSE; +} + +static void call_with_video_added(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + + BC_ASSERT_TRUE((call_ok=call(pauline,marie))); + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + + end_call(pauline, marie); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_video_added_2(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + /*in this variant marie is already in automatically accept*/ + LinphoneVideoPolicy marie_policy; + marie_policy.automatically_accept=TRUE; + + + linphone_core_set_video_policy(marie->lc,&marie_policy); + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, FALSE); + + BC_ASSERT_TRUE(call_ok=call(pauline,marie)); + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(marie,pauline, TRUE)); + + end_call(pauline, marie); +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_video_added_random_ports(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + + linphone_core_set_audio_port(marie->lc,-1); + linphone_core_set_video_port(marie->lc,-1); + linphone_core_set_audio_port(pauline->lc,-1); + linphone_core_set_video_port(pauline->lc,-1); + + BC_ASSERT_TRUE(call_ok=call(pauline,marie)); + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + end_call(pauline, marie); +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_several_video_switches(void) { + int dummy = 0; + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + BC_ASSERT_TRUE(call_ok=call(pauline,marie)); + + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ + BC_ASSERT_TRUE(remove_video(pauline,marie)); + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ + BC_ASSERT_TRUE(remove_video(pauline,marie)); + /**/ + end_call(pauline, marie); +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void srtp_call_with_several_video_switches(void) { + int dummy = 0; + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + + if (linphone_core_media_encryption_supported(marie->lc, LinphoneMediaEncryptionSRTP)) { + linphone_core_set_media_encryption(marie->lc, LinphoneMediaEncryptionSRTP); + linphone_core_set_media_encryption(pauline->lc, LinphoneMediaEncryptionSRTP); + + BC_ASSERT_TRUE(call_ok=call(pauline,marie)); + if (!call_ok) goto end; + + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ + BC_ASSERT_TRUE(remove_video(pauline,marie)); + BC_ASSERT_TRUE(add_video(pauline,marie, TRUE)); + wait_for_until(pauline->lc,marie->lc,&dummy,1,1000); /* Wait for VFU request exchanges to be finished. */ + BC_ASSERT_TRUE(remove_video(pauline,marie)); + /**/ + end_call(pauline, marie); + } else { + ms_warning("Not tested because SRTP is not available."); + } +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_declined_video_base(bool_t using_policy) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall* marie_call; + LinphoneCall* pauline_call; + LinphoneVideoPolicy marie_policy, pauline_policy; + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + bool_t call_ok; + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); + + if (using_policy) { + pauline_policy.automatically_initiate=TRUE; + pauline_policy.automatically_accept=FALSE; + marie_policy.automatically_initiate=FALSE; + marie_policy.automatically_accept=FALSE; + + linphone_core_set_video_policy(marie->lc,&marie_policy); + linphone_core_set_video_policy(pauline->lc,&pauline_policy); + } + + caller_test_params.base=linphone_core_create_call_params(pauline->lc, NULL); + if (!using_policy) + linphone_call_params_enable_video(caller_test_params.base,TRUE); + + if (!using_policy){ + callee_test_params.base=linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_video(callee_test_params.base,FALSE); + } + + BC_ASSERT_TRUE((call_ok=call_with_params2(pauline,marie,&caller_test_params,&callee_test_params,using_policy))); + if (!call_ok) goto end; + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + marie_call=linphone_core_get_current_call(marie->lc); + pauline_call=linphone_core_get_current_call(pauline->lc); + + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call))); + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call))); + + end_call(pauline, marie); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} +static void call_with_declined_video(void) { + call_with_declined_video_base(FALSE); +} + +static void call_with_declined_video_despite_policy(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall* marie_call; + LinphoneCall* pauline_call; + LinphoneVideoPolicy marie_policy, pauline_policy; + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + bool_t call_ok; + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); + + pauline_policy.automatically_initiate=TRUE; + pauline_policy.automatically_accept=TRUE; + marie_policy.automatically_initiate=TRUE; + marie_policy.automatically_accept=TRUE; + + linphone_core_set_video_policy(marie->lc,&marie_policy); + linphone_core_set_video_policy(pauline->lc,&pauline_policy); + + caller_test_params.base=linphone_core_create_call_params(pauline->lc, NULL); + + callee_test_params.base=linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_enable_video(callee_test_params.base,FALSE); + + BC_ASSERT_TRUE((call_ok=call_with_params2(pauline,marie,&caller_test_params,&callee_test_params,FALSE))); + if (!call_ok) goto end; + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + marie_call=linphone_core_get_current_call(marie->lc); + pauline_call=linphone_core_get_current_call(pauline->lc); + + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call))); + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call))); + + end_call(pauline, marie); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_declined_video_using_policy(void) { + call_with_declined_video_base(TRUE); +} + + +void video_call_base_2(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + LinphoneCall* callee_call; + LinphoneCall* caller_call; + LinphoneVideoPolicy callee_policy, caller_policy; + + if (using_policy) { + callee_policy.automatically_initiate=FALSE; + callee_policy.automatically_accept=TRUE; + caller_policy.automatically_initiate=TRUE; + caller_policy.automatically_accept=FALSE; + + linphone_core_set_video_policy(callee->lc,&callee_policy); + linphone_core_set_video_policy(caller->lc,&caller_policy); + } + + linphone_core_enable_video_display(callee->lc, callee_video_enabled); + linphone_core_enable_video_capture(callee->lc, callee_video_enabled); + + linphone_core_enable_video_display(caller->lc, caller_video_enabled); + linphone_core_enable_video_capture(caller->lc, caller_video_enabled); + + if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */ + char *path = bc_tester_file("certificates-marie"); + callee->lc->user_certificates_path = ms_strdup(path); + bc_free(path); + path = bc_tester_file("certificates-pauline"); + caller->lc->user_certificates_path = ms_strdup(path); + bc_free(path); + belle_sip_mkdir(callee->lc->user_certificates_path); + belle_sip_mkdir(caller->lc->user_certificates_path); + } + + linphone_core_set_media_encryption(callee->lc,mode); + linphone_core_set_media_encryption(caller->lc,mode); + + caller_test_params.base=linphone_core_create_call_params(caller->lc, NULL); + if (!using_policy) + linphone_call_params_enable_video(caller_test_params.base,TRUE); + + if (!using_policy){ + callee_test_params.base=linphone_core_create_call_params(callee->lc, NULL); + linphone_call_params_enable_video(callee_test_params.base,TRUE); + } + + BC_ASSERT_TRUE(call_with_params2(caller,callee,&caller_test_params,&callee_test_params,using_policy)); + callee_call=linphone_core_get_current_call(callee->lc); + caller_call=linphone_core_get_current_call(caller->lc); + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + + if (callee_call && caller_call ) { + if (callee_video_enabled && caller_video_enabled) { + BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); + BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); + + /*check video path*/ + linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); + linphone_call_send_vfu_request(callee_call); + BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); + } else { + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); + } + liblinphone_tester_check_rtcp(callee,caller); + } +} + + +static void check_fir(LinphoneCoreManager* caller,LinphoneCoreManager* callee ){ + LinphoneCall* callee_call; + LinphoneCall* caller_call; + + callee_call=linphone_core_get_current_call(callee->lc); + caller_call=linphone_core_get_current_call(caller->lc); + + /*check video path is established in both directions. + Indeed, FIR are ignored until the first RTP packet is received, because SSRC is not known.*/ + linphone_call_set_next_video_frame_decoded_callback(callee_call,linphone_call_iframe_decoded_cb,callee->lc); + linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); + + BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&callee->stat.number_of_IframeDecoded,1)); + BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); + + linphone_call_send_vfu_request(callee_call); + + if (rtp_session_avpf_enabled(callee_call->sessions->rtp_session)){ + BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&caller_call->videostream->ms_video_stat.counter_rcvd_fir, 1)); + }else{ + BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&caller_call->videostream->ms_video_stat.counter_rcvd_fir, 0)); + } + ms_message ("check_fir : [%p] received %d FIR ",&caller_call ,caller_call->videostream->ms_video_stat.counter_rcvd_fir); + ms_message ("check_fir : [%p] stat number of iframe decoded %d ",&callee_call, callee->stat.number_of_IframeDecoded); + + linphone_call_set_next_video_frame_decoded_callback(caller_call,linphone_call_iframe_decoded_cb,caller->lc); + linphone_call_send_vfu_request(caller_call); + BC_ASSERT_TRUE( wait_for(callee->lc,caller->lc,&caller->stat.number_of_IframeDecoded,1)); + + if (rtp_session_avpf_enabled(caller_call->sessions->rtp_session)) { + if (rtp_session_avpf_enabled(callee_call->sessions->rtp_session)){ + BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&callee_call->videostream->ms_video_stat.counter_rcvd_fir, 1)); + } + }else{ + BC_ASSERT_TRUE(wait_for(callee->lc,caller->lc,&callee_call->videostream->ms_video_stat.counter_rcvd_fir, 0)); + } + ms_message ("check_fir : [%p] received %d FIR ",&callee_call ,callee_call->videostream->ms_video_stat.counter_rcvd_fir); + ms_message ("check_fir : [%p] stat number of iframe decoded %d ",&caller_call, caller->stat.number_of_IframeDecoded); + +} + +void video_call_base_3(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + + LinphoneCall* callee_call; + LinphoneCall* caller_call; + LinphoneVideoPolicy callee_policy, caller_policy; + + if (using_policy) { + callee_policy.automatically_initiate=FALSE; + callee_policy.automatically_accept=TRUE; + caller_policy.automatically_initiate=TRUE; + caller_policy.automatically_accept=FALSE; + + linphone_core_set_video_policy(callee->lc,&callee_policy); + linphone_core_set_video_policy(caller->lc,&caller_policy); + } + + linphone_core_enable_video_display(callee->lc, callee_video_enabled); + linphone_core_enable_video_capture(callee->lc, callee_video_enabled); + + linphone_core_enable_video_display(caller->lc, caller_video_enabled); + linphone_core_enable_video_capture(caller->lc, caller_video_enabled); + + if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */ + char *path = bc_tester_file("certificates-marie"); + callee->lc->user_certificates_path = ms_strdup(path); + bc_free(path); + path = bc_tester_file("certificates-pauline"); + caller->lc->user_certificates_path = ms_strdup(path); + bc_free(path); + belle_sip_mkdir(callee->lc->user_certificates_path); + belle_sip_mkdir(caller->lc->user_certificates_path); + } + + linphone_core_set_media_encryption(callee->lc,mode); + linphone_core_set_media_encryption(caller->lc,mode); + /* Create call params */ + caller_test_params.base=linphone_core_create_call_params(caller->lc, NULL); + + if (!using_policy) + linphone_call_params_enable_video(caller_test_params.base,TRUE); + + if (!using_policy){ + callee_test_params.base=linphone_core_create_call_params(callee->lc, NULL); + linphone_call_params_enable_video(callee_test_params.base,TRUE); + } + + BC_ASSERT_TRUE(call_with_params2(caller,callee,&caller_test_params,&callee_test_params,using_policy)); + callee_call=linphone_core_get_current_call(callee->lc); + caller_call=linphone_core_get_current_call(caller->lc); + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + + if (callee_call && caller_call ) { + if (callee_video_enabled && caller_video_enabled) { + check_fir(caller,callee); + } else { + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(callee_call))); + BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(caller_call))); + } + liblinphone_tester_check_rtcp(callee,caller); + } +} + + + +static void video_call_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { + video_call_base_2(pauline,marie,using_policy,mode,callee_video_enabled,caller_video_enabled); + end_call(pauline, marie); +} + +static void video_call(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_without_rtcp(void) { + LpConfig *lp; + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + lp = linphone_core_get_config(marie->lc); + lp_config_set_int(lp,"rtp","rtcp_enabled",0); + + lp = linphone_core_get_config(pauline->lc); + lp_config_set_int(lp,"rtp","rtcp_enabled",0); + + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_disable_implicit_AVPF_on_callee(void) { + LinphoneCoreManager* callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + LpConfig *callee_lp; + const LinphoneCallParams *params, *params2; + + callee_lp = linphone_core_get_config(callee->lc); + lp_config_set_int(callee_lp,"rtp","rtcp_fb_implicit_rtcp_fb",0); + + video_call_base_3(caller,callee,TRUE,LinphoneMediaEncryptionNone,TRUE,TRUE); + if(BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(callee->lc))) { + params = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); + BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), "RTP/AVP"); + } + if(BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(caller->lc))) { + params2 =linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); + BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params2), "RTP/AVP"); + } + end_call(caller, callee); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + + +static void video_call_disable_implicit_AVPF_on_caller(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + LpConfig *caller_lp; + const LinphoneCallParams *params, *params2; + + caller_lp = linphone_core_get_config(caller->lc); + lp_config_set_int(caller_lp, "rtp", "rtcp_fb_implicit_rtcp_fb", 0); + + video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); + params = linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)); + BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), "RTP/AVP"); + params2 = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); + BC_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params2), "RTP/AVP"); + end_call(caller, callee); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); + +} + +static void video_call_AVPF_to_implicit_AVPF(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_avpf_mode(caller->lc, LinphoneAVPFEnabled); + video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); + end_call(caller, callee); + + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); + +} + +static void video_call_implicit_AVPF_to_AVPF(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_avpf_mode(callee->lc, LinphoneAVPFEnabled); + video_call_base_3(caller, callee, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); + end_call(caller, callee); + + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); + +} + +static void video_call_using_policy_AVPF_implicit_caller_and_callee(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base_3(caller, callee, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); + end_call(caller, callee); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + +static void video_call_base_avpf(LinphoneCoreManager *caller, LinphoneCoreManager *callee, bool_t using_policy, LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { + linphone_core_set_avpf_mode(caller->lc, LinphoneAVPFEnabled); + linphone_core_set_avpf_mode(callee->lc, LinphoneAVPFEnabled); + video_call_base_3(caller, callee, using_policy, mode, callee_video_enabled, caller_video_enabled); + end_call(caller, callee); +} + +static void video_call_avpf(void) { + LinphoneCoreManager *callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + video_call_base_avpf(caller, callee, FALSE, LinphoneMediaEncryptionNone, TRUE, TRUE); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); + +} + +static void video_call_zrtp(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + if (linphone_core_media_encryption_supported(marie->lc,LinphoneMediaEncryptionZRTP)) { + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionZRTP,TRUE,TRUE); + } else + ms_message("Skipping video_call_zrtp"); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_dtls(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + if (linphone_core_media_encryption_supported(pauline->lc,LinphoneMediaEncryptionDTLS)) { + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionDTLS,TRUE,TRUE); + } else + ms_message("Skipping video_call_dtls"); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + +} + + + +static void video_call_using_policy(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base(pauline,marie,TRUE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_using_policy_with_callee_video_disabled(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base(marie,pauline,TRUE,LinphoneMediaEncryptionNone,FALSE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_using_policy_with_caller_video_disabled(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + video_call_base(marie,pauline,TRUE,LinphoneMediaEncryptionNone,TRUE,FALSE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_no_sdp(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + linphone_core_enable_sdp_200_ack(pauline->lc,TRUE); + video_call_base(pauline,marie,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_ice_video_to_novideo(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneVideoPolicy vpol={0}; + vpol.automatically_initiate=TRUE; + linphone_core_set_video_policy(pauline->lc,&vpol); + vpol.automatically_initiate=FALSE; + linphone_core_set_video_policy(marie->lc,&vpol); + _call_with_ice_base(pauline,marie,TRUE,TRUE,TRUE,FALSE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void _call_with_ice_video(LinphoneVideoPolicy caller_policy, LinphoneVideoPolicy callee_policy, + bool_t video_added_by_caller, bool_t video_added_by_callee, bool_t video_removed_by_caller, bool_t video_removed_by_callee) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + unsigned int nb_media_starts = 1; + + linphone_core_set_video_policy(pauline->lc, &caller_policy); + linphone_core_set_video_policy(marie->lc, &callee_policy); + linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); + linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + + linphone_core_set_audio_port(marie->lc, -1); + linphone_core_set_video_port(marie->lc, -1); + linphone_core_set_audio_port(pauline->lc, -1); + linphone_core_set_video_port(pauline->lc, -1); + + BC_ASSERT_TRUE(call_ok = call(pauline, marie)); + if (!call_ok) goto end; + BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); + + /* Wait for ICE reINVITEs to complete. */ + BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2) + && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); + check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); + nb_media_starts++; + + if (video_added_by_caller) { + BC_ASSERT_TRUE(add_video(marie, pauline, FALSE)); + } else if (video_added_by_callee) { + BC_ASSERT_TRUE(add_video(pauline, marie, FALSE)); + } + if (video_added_by_caller || video_added_by_callee) { + BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); + if (linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)))){ + /* Wait for ICE reINVITEs to complete if video was really added */ + BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 4) + && wait_for(pauline->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 4)); + check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); + nb_media_starts++; + } + } + + if (video_removed_by_caller) { + BC_ASSERT_TRUE(remove_video(marie, pauline)); + } else if (video_removed_by_callee) { + BC_ASSERT_TRUE(remove_video(pauline, marie)); + } + if (video_removed_by_caller || video_removed_by_callee) { + BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); + check_nb_media_starts(pauline, marie, nb_media_starts, nb_media_starts); + nb_media_starts++; + } + + end_call(pauline, marie); + +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void call_with_ice_video_added(void) { + LinphoneVideoPolicy vpol = { TRUE, TRUE }; + _call_with_ice_video(vpol, vpol, TRUE, FALSE, TRUE, FALSE); +} + +static void call_with_ice_video_added_2(void) { + LinphoneVideoPolicy vpol = { TRUE, TRUE }; + _call_with_ice_video(vpol, vpol, TRUE, FALSE, FALSE, TRUE); +} + +static void call_with_ice_video_added_3(void) { + LinphoneVideoPolicy vpol = { TRUE, TRUE }; + _call_with_ice_video(vpol, vpol, FALSE, TRUE, TRUE, FALSE); +} + +static void call_with_ice_video_added_and_refused(void) { + LinphoneVideoPolicy caller_policy = { TRUE, TRUE }; + LinphoneVideoPolicy callee_policy = { FALSE, FALSE }; + _call_with_ice_video(caller_policy, callee_policy, TRUE, FALSE, FALSE, FALSE); +} + +static void call_with_ice_video_added_with_video_policies_to_false(void) { + LinphoneVideoPolicy vpol = { FALSE, FALSE }; + _call_with_ice_video(vpol, vpol, FALSE, TRUE, FALSE, FALSE); +} + +#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT /*which is not the case at the moment*/ + +static void call_with_ice_video_and_rtt(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + bool_t call_ok; + LinphoneVideoPolicy policy = { TRUE, TRUE }; + LinphoneCallParams *params = NULL; + LinphoneCall *marie_call = NULL; + + linphone_core_set_video_policy(pauline->lc, &policy); + linphone_core_set_video_policy(marie->lc, &policy); + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, FALSE); + linphone_core_enable_video_capture(pauline->lc, FALSE); + linphone_core_enable_video_display(pauline->lc, TRUE); + linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); + linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + + linphone_core_set_audio_port(marie->lc, -1); + linphone_core_set_video_port(marie->lc, -1); + linphone_core_set_text_port(marie->lc, -1); + linphone_core_set_audio_port(pauline->lc, -1); + linphone_core_set_video_port(pauline->lc, -1); + linphone_core_set_text_port(pauline->lc, -1); + + params = linphone_core_create_default_call_parameters(pauline->lc); + linphone_call_params_enable_realtime_text(params, TRUE); + BC_ASSERT_TRUE(call_ok = call_with_caller_params(pauline, marie, params)); + if (!call_ok) goto end; + BC_ASSERT_TRUE(check_ice(pauline, marie, LinphoneIceStateHostConnection)); + + marie_call = linphone_core_get_current_call(marie->lc); + BC_ASSERT_TRUE(linphone_call_params_audio_enabled(linphone_call_get_current_params(marie_call))); + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(marie_call))); + BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(marie_call))); + + end_call(pauline, marie); +end: + linphone_call_params_destroy(params); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +#endif + +static void video_call_with_early_media_no_matching_audio_codecs(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall *out_call, *pauline_call; + LinphoneVideoPolicy vpol={0}; + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); + + vpol.automatically_initiate=TRUE; + vpol.automatically_accept=TRUE; + linphone_core_set_video_policy(pauline->lc,&vpol); + linphone_core_set_video_policy(marie->lc,&vpol); + + linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMU", 8000, 1), FALSE); /* Disable PCMU */ + linphone_core_enable_payload_type(marie->lc, linphone_core_find_payload_type(marie->lc, "PCMA", 8000, 1), TRUE); /* Enable PCMA */ + + out_call = linphone_core_invite_address(marie->lc, pauline->identity); + linphone_call_ref(out_call); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingInit, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingReceived, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingRinging, 1)); + + pauline_call = linphone_core_get_current_call(pauline->lc); + if (!pauline_call) goto end; + + linphone_core_accept_early_media(pauline->lc, pauline_call); + + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallIncomingEarlyMedia, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingEarlyMedia, 1)); + /*audio stream shall not have been requested to start*/ + BC_ASSERT_PTR_NULL(pauline_call->audiostream->soundread); + + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(out_call))); + BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(pauline_call))); + + linphone_core_accept_call(pauline->lc, pauline_call); + + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1)); + + end_call(marie, pauline); + +end: + linphone_call_unref(out_call); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_limited_bandwidth(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_download_bandwidth(pauline->lc, 100); + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void dtls_srtp_video_call(void) { + call_base(LinphoneMediaEncryptionDTLS,TRUE,FALSE,LinphonePolicyNoFirewall,FALSE); +} + +static void dtls_srtp_ice_video_call(void) { + call_base(LinphoneMediaEncryptionDTLS,TRUE,FALSE,LinphonePolicyUseIce,FALSE); +} +static void dtls_srtp_ice_video_call_with_relay(void) { + call_base(LinphoneMediaEncryptionDTLS,TRUE,TRUE,LinphonePolicyUseIce,FALSE); +} +static void srtp_video_ice_call(void) { + call_base(LinphoneMediaEncryptionSRTP,TRUE,FALSE,LinphonePolicyUseIce,FALSE); +} +static void zrtp_video_ice_call(void) { + call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyUseIce,FALSE); +} + +static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, LinphoneCoreManager *marie, MSList *lcs) { +#define DEFAULT_WAIT_FOR 10000 + LinphoneCallParams *params; + LinphoneVideoPolicy pol; + LinphoneCall *call; + pol.automatically_accept=1; + pol.automatically_initiate=1; + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); + linphone_core_set_video_policy(pauline->lc,&pol); + linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_set_video_policy(marie->lc,&pol); + linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); + + linphone_call_set_next_video_frame_decoded_callback(linphone_core_invite_address(pauline->lc,marie->identity) + ,linphone_call_iframe_decoded_cb + ,pauline->lc); + + + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallIncomingReceived,1,DEFAULT_WAIT_FOR)); + + { + char* remote_uri = linphone_address_as_string_uri_only(pauline->identity); + call = linphone_core_find_call_from_uri(marie->lc,remote_uri); + ms_free(remote_uri); + } + + if (call) { + params=linphone_core_create_call_params(marie->lc, NULL); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendOnly); + linphone_core_accept_call_with_params(marie->lc,call,params); + linphone_call_params_destroy(params); + + BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning,1,DEFAULT_WAIT_FOR)); + BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallPausedByRemote,1,DEFAULT_WAIT_FOR)); + + check_media_direction(marie,call,lcs,LinphoneMediaDirectionSendOnly,LinphoneMediaDirectionSendOnly); + } + + + call=linphone_core_get_current_call(pauline->lc); + if (call) { + check_media_direction(pauline,call,lcs,LinphoneMediaDirectionRecvOnly,LinphoneMediaDirectionRecvOnly); + } + +} +static void accept_call_in_send_base(bool_t caller_has_ice) { + LinphoneCoreManager *pauline, *marie; + MSList *lcs=NULL;; + + marie = linphone_core_manager_new("marie_rc"); + pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + if (caller_has_ice) { + linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); + } + + lcs=ms_list_append(lcs,pauline->lc); + lcs=ms_list_append(lcs,marie->lc); + + accept_call_in_send_only_base(pauline,marie,lcs); + + + end_call(marie,pauline); + ms_list_free(lcs); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void accept_call_in_send_only(void) { + accept_call_in_send_base(FALSE); +} + +static void accept_call_in_send_only_with_ice(void) { + accept_call_in_send_base(TRUE); +} + +void two_accepted_call_in_send_only(void) { + LinphoneCoreManager *pauline, *marie, *laure; + MSList *lcs=NULL; + + marie = linphone_core_manager_new("marie_rc"); + linphone_core_use_files(marie->lc, TRUE); + pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + laure = linphone_core_manager_new("laure_rc_udp"); + + lcs=ms_list_append(lcs,pauline->lc); + lcs=ms_list_append(lcs,marie->lc); + lcs=ms_list_append(lcs,laure->lc); + + accept_call_in_send_only_base(pauline,marie,lcs); + + reset_counters(&marie->stat); + accept_call_in_send_only_base(laure,marie,lcs); + + end_call(pauline, marie); + end_call(laure, marie); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); + linphone_core_manager_destroy(laure); + ms_list_free(lcs); +} + +static void video_early_media_call(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_early_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_rc"); + LinphoneCall *pauline_to_marie; + + linphone_core_set_video_device(pauline->lc, "Mire: Mire (synthetic moving picture)"); + + video_call_base_3(pauline, marie, TRUE, LinphoneMediaEncryptionNone, TRUE, TRUE); + + BC_ASSERT_PTR_NOT_NULL(pauline_to_marie = linphone_core_get_current_call(pauline->lc)); + if(pauline_to_marie) { + BC_ASSERT_EQUAL(pauline_to_marie->videostream->source->desc->id, MS_MIRE_ID, int, "%d"); + } + + end_call(pauline, marie); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +/*this is call forking with early media managed at client side (not by flexisip server)*/ +static void multiple_early_media(void) { + LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc"); + LinphoneCoreManager* marie1 = linphone_core_manager_new("marie_early_rc"); + LinphoneCoreManager* marie2 = linphone_core_manager_new("marie_early_rc"); + MSList *lcs=NULL; + LinphoneCallParams *params=linphone_core_create_call_params(pauline->lc, NULL); + LinphoneVideoPolicy pol; + LinphoneCall *marie1_call; + LinphoneCall *marie2_call; + LinphoneCall *pauline_call; + LinphoneInfoMessage *info; + int dummy=0; + pol.automatically_accept=1; + pol.automatically_initiate=1; + + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); + + linphone_core_enable_video_capture(marie1->lc, TRUE); + linphone_core_enable_video_display(marie1->lc, TRUE); + linphone_core_set_video_policy(marie1->lc,&pol); + + linphone_core_enable_video_capture(marie2->lc, TRUE); + linphone_core_enable_video_display(marie2->lc, TRUE); + linphone_core_set_video_policy(marie2->lc,&pol); + linphone_core_set_audio_port_range(marie2->lc,40200,40300); + linphone_core_set_video_port_range(marie2->lc,40400,40500); + + lcs=ms_list_append(lcs,marie1->lc); + lcs=ms_list_append(lcs,marie2->lc); + lcs=ms_list_append(lcs,pauline->lc); + + linphone_call_params_enable_early_media_sending(params,TRUE); + linphone_call_params_enable_video(params,TRUE); + + linphone_core_invite_address_with_params(pauline->lc,marie1->identity,params); + linphone_call_params_destroy(params); + + BC_ASSERT_TRUE(wait_for_list(lcs, &marie1->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &marie2->stat.number_of_LinphoneCallIncomingEarlyMedia,1,3000)); + BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallOutgoingEarlyMedia,1,3000)); + + pauline_call=linphone_core_get_current_call(pauline->lc); + marie1_call=linphone_core_get_current_call(marie1->lc); + marie2_call=linphone_core_get_current_call(marie2->lc); + + BC_ASSERT_PTR_NOT_NULL(pauline_call); + BC_ASSERT_PTR_NOT_NULL(marie1_call); + BC_ASSERT_PTR_NOT_NULL(marie2_call); + + if (pauline_call && marie1_call && marie2_call){ + + /*wait a bit that streams are established*/ + wait_for_list(lcs,&dummy,1,6000); + BC_ASSERT_GREATER(linphone_core_manager_get_max_audio_down_bw(pauline),70,int,"%i"); + BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie1), 70, int, "%i"); + BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie2), 70, int, "%i"); + + linphone_core_accept_call(marie1->lc,linphone_core_get_current_call(marie1->lc)); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie1->stat.number_of_LinphoneCallStreamsRunning,1,3000)); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,3000)); + + /*marie2 should get her call terminated*/ + BC_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); + + /*wait a bit that streams are established*/ + wait_for_list(lcs,&dummy,1,3000); + BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(pauline), 71, int, "%i"); + BC_ASSERT_GREATER(linphone_core_manager_get_mean_audio_down_bw(marie1), 71, int, "%i"); + + /*send an INFO in reverse side to check that dialogs are properly established*/ + info=linphone_core_create_info_message(marie1->lc); + linphone_call_send_info_message(marie1_call,info); + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_inforeceived,1,3000)); + } + + end_call(pauline, marie1); + + ms_list_free(lcs); + linphone_core_manager_destroy(marie1); + linphone_core_manager_destroy(marie2); + linphone_core_manager_destroy(pauline); +} +static void video_call_ice_params(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); + linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); + video_call_base(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void audio_call_with_ice_with_video_policy_enabled(void){ + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneVideoPolicy vpol; + + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, TRUE); + vpol.automatically_accept = vpol.automatically_initiate = TRUE; + linphone_core_set_video_policy(marie->lc, &vpol); + vpol.automatically_accept = vpol.automatically_initiate = FALSE; + linphone_core_set_video_policy(pauline->lc, &vpol); + + linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); + linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + + linphone_core_invite_address(pauline->lc, marie->identity); + if (!BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallIncomingReceived, 1))) goto end; + linphone_core_accept_call(marie->lc, linphone_core_get_current_call(marie->lc)); + /* + LinphoneCallParams *params; + params = linphone_core_create_call_params(marie->lc, linphone_core_get_current_call(marie->lc)); + linphone_call_params_enable_video(params, TRUE); + linphone_core_accept_call_with_params(marie->lc, linphone_core_get_current_call(marie->lc), params); + linphone_call_params_destroy(params);*/ + + /*wait for call to be established and ICE reINVITEs to be done */ + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 2)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 2)); + + linphone_core_pause_call(marie->lc, linphone_core_get_current_call(marie->lc)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallPausedByRemote, 1)); + BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallPaused, 1)); + + end_call(marie, pauline); +end: + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + + +static void classic_video_entry_phone_setup(void) { + LinphoneCoreManager *callee_mgr = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *caller_mgr = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCallParams *early_media_params = NULL; + LinphoneCallParams *in_call_params = NULL; + LinphoneCall *callee_call = NULL; + LinphoneVideoPolicy vpol = { TRUE, TRUE }; + MSList *lcs = NULL; + int retry = 0; + bool_t ok; + + lcs = ms_list_append(lcs, caller_mgr->lc); + lcs = ms_list_append(lcs, callee_mgr->lc); + + linphone_core_enable_video_capture(caller_mgr->lc, TRUE); + linphone_core_enable_video_display(caller_mgr->lc, TRUE); + linphone_core_enable_video_capture(callee_mgr->lc, TRUE); + linphone_core_enable_video_display(callee_mgr->lc, TRUE); + linphone_core_set_avpf_mode(caller_mgr->lc, LinphoneAVPFEnabled); + linphone_core_set_avpf_mode(callee_mgr->lc, LinphoneAVPFEnabled); + linphone_core_set_video_policy(caller_mgr->lc, &vpol); + linphone_core_set_video_policy(callee_mgr->lc, &vpol); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(caller_mgr->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(caller_mgr->lc,"h264"); + disable_all_video_codecs_except_one(callee_mgr->lc,"h264"); + } + + linphone_core_set_video_device(caller_mgr->lc, liblinphone_tester_mire_id); + linphone_core_set_video_device(callee_mgr->lc, liblinphone_tester_mire_id); + + BC_ASSERT_PTR_NOT_NULL(linphone_core_invite_address(caller_mgr->lc, callee_mgr->identity)); + + ok = wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, 1); + BC_ASSERT_TRUE(ok); + if (!ok) goto end; + BC_ASSERT_TRUE(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress == 1); + + callee_call = linphone_core_get_call_by_remote_address2(callee_mgr->lc, caller_mgr->identity); + early_media_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); + linphone_call_params_set_audio_direction(early_media_params, LinphoneMediaDirectionInactive); + linphone_call_params_set_video_direction(early_media_params, LinphoneMediaDirectionRecvOnly); + linphone_core_accept_early_media_with_params(callee_mgr->lc, callee_call, early_media_params); + linphone_call_params_destroy(early_media_params); + + while ((caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia != 1) && (retry++ < 100)) { + linphone_core_iterate(caller_mgr->lc); + linphone_core_iterate(callee_mgr->lc); + ms_usleep(20000); + } + BC_ASSERT_TRUE(caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia == 1); + BC_ASSERT_TRUE(callee_mgr->stat.number_of_LinphoneCallIncomingEarlyMedia == 1); + + check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionRecvOnly); + callee_call = linphone_core_get_call_by_remote_address2(callee_mgr->lc, caller_mgr->identity); + in_call_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); + linphone_call_params_set_audio_direction(in_call_params, LinphoneMediaDirectionSendRecv); + linphone_call_params_set_video_direction(in_call_params, LinphoneMediaDirectionSendRecv); + linphone_core_accept_call_with_params(callee_mgr->lc, callee_call, in_call_params); + linphone_call_params_destroy(in_call_params); + + BC_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallConnected, 1)); + BC_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallConnected, 1)); + + ok = wait_for_until(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 1, 2000) + && wait_for_until(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallStreamsRunning, 1, 2000); + BC_ASSERT_TRUE(ok); + if (!ok) goto end; + check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionSendRecv, LinphoneMediaDirectionSendRecv); + + callee_call = linphone_core_get_current_call(callee_mgr->lc); + in_call_params = linphone_core_create_call_params(callee_mgr->lc, callee_call); + linphone_call_params_set_audio_direction(in_call_params, LinphoneMediaDirectionRecvOnly); + linphone_call_params_set_video_direction(in_call_params, LinphoneMediaDirectionSendOnly); + linphone_core_update_call(callee_mgr->lc, callee_call, in_call_params); + linphone_call_params_destroy(in_call_params); + + ok = wait_for_until(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, 2, 2000) + && wait_for_until(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallStreamsRunning, 2, 2000); + BC_ASSERT_TRUE(ok); + if (!ok) goto end; + callee_call = linphone_core_get_current_call(callee_mgr->lc); + check_media_direction(callee_mgr, callee_call, lcs, LinphoneMediaDirectionRecvOnly, LinphoneMediaDirectionSendOnly); + + end_call(caller_mgr, callee_mgr); + +end: + linphone_core_manager_destroy(callee_mgr); + linphone_core_manager_destroy(caller_mgr); + ms_list_free(lcs); +} +static void video_call_recording_h264_test(void) { + record_call("recording", TRUE, "H264"); +} + +static void video_call_recording_vp8_test(void) { + record_call("recording", TRUE, "VP8"); +} + +static void video_call_snapshot(void) { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCallParams *marieParams = linphone_core_create_call_params(marie->lc, NULL); + LinphoneCallParams *paulineParams = linphone_core_create_call_params(pauline->lc, NULL); + LinphoneCall *callInst = NULL; + char *filename = bc_tester_file("snapshot.jpeg"); + int dummy = 0; + bool_t call_succeeded = FALSE; + + linphone_core_enable_video_capture(marie->lc, TRUE); + linphone_core_enable_video_display(marie->lc, TRUE); + linphone_core_enable_video_capture(pauline->lc, TRUE); + linphone_core_enable_video_display(pauline->lc, FALSE); + linphone_call_params_enable_video(marieParams, TRUE); + linphone_call_params_enable_video(paulineParams, TRUE); + + BC_ASSERT_TRUE(call_succeeded = call_with_params(marie, pauline, marieParams, paulineParams)); + BC_ASSERT_PTR_NOT_NULL(callInst = linphone_core_get_current_call(marie->lc)); + if((call_succeeded == TRUE) && (callInst != NULL)) { + int jpeg_support = linphone_call_take_video_snapshot(callInst, filename); + if (jpeg_support < 0) { + ms_warning("No jpegwriter support!"); + } else { + wait_for_until(marie->lc, pauline->lc, &dummy, 1, 5000); + BC_ASSERT_EQUAL(ortp_file_exist(filename), 0, int, "%d"); + remove(filename); + } + end_call(marie, pauline); + } + ms_free(filename); + linphone_call_params_unref(marieParams); + linphone_call_params_unref(paulineParams); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryption mode, bool_t no_sdp) { + LinphoneCoreManager* marie; + LinphoneCoreManager* pauline; + LinphoneCallParams *params; + const LinphoneCallParams *current_params; + MSList *lcs=NULL; + bool_t calls_ok; + + marie = linphone_core_manager_new( "marie_rc"); + pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + + linphone_core_set_avpf_mode(pauline->lc,TRUE); + + // important: VP8 has really poor performances with the mire camera, at least + // on iOS - so when ever h264 is available, let's use it instead + if (linphone_core_find_payload_type(pauline->lc,"h264", -1, -1)!=NULL) { + disable_all_video_codecs_except_one(pauline->lc,"h264"); + disable_all_video_codecs_except_one(marie->lc,"h264"); + } + linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); + linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); + linphone_core_set_avpf_mode(marie->lc,TRUE); + lcs=ms_list_append(lcs,pauline->lc); + lcs=ms_list_append(lcs,marie->lc); + + video_call_base_2(marie,pauline,TRUE,mode,TRUE,TRUE); + + calls_ok = linphone_core_get_current_call(marie->lc) != NULL && linphone_core_get_current_call(pauline->lc) != NULL; + BC_ASSERT_TRUE(calls_ok); + + if (calls_ok) { + params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc)); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionInactive); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); + + linphone_core_update_call(marie->lc, linphone_core_get_current_call(marie->lc),params); + linphone_call_params_destroy(params); + + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallUpdating,1)); + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2)); + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallPausedByRemote,1)); + + check_media_direction(marie,linphone_core_get_current_call(marie->lc),lcs,LinphoneMediaDirectionInactive,LinphoneMediaDirectionInactive); + check_media_direction(pauline,linphone_core_get_current_call(pauline->lc), lcs, LinphoneMediaDirectionInactive, LinphoneMediaDirectionInactive); + + if (no_sdp) { + linphone_core_enable_sdp_200_ack(marie->lc,TRUE); + } + + params=linphone_core_create_call_params(marie->lc,linphone_core_get_current_call(marie->lc)); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionSendRecv); + linphone_core_update_call(marie->lc,linphone_core_get_current_call(marie->lc),params); + linphone_call_params_destroy(params); + + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); + BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + + check_media_direction(marie,linphone_core_get_current_call(marie->lc),lcs,LinphoneMediaDirectionSendRecv,LinphoneMediaDirectionSendRecv); + check_media_direction(pauline,linphone_core_get_current_call(pauline->lc),lcs,LinphoneMediaDirectionSendRecv,LinphoneMediaDirectionSendRecv); + + /*assert that after pause and resume, SRTP is still being used*/ + current_params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc)); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(current_params) , mode, int, "%d"); + current_params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc)); + BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(current_params) , mode, int, "%d"); + + } + end_call(marie,pauline); + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + +static void video_call_with_re_invite_inactive_followed_by_re_invite(void) { + video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionNone,FALSE); +} + +static void video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp(void) { + video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionNone, TRUE); +} + +static void srtp_video_call_with_re_invite_inactive_followed_by_re_invite(void) { + if (ms_srtp_supported()) + video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionSRTP,FALSE); + else + ms_message("srtp_video_call_with_re_invite_inactive_followed_by_re_invite skipped, missing srtp support"); +} + +static void srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp(void) { + if (ms_srtp_supported()) + video_call_with_re_invite_inactive_followed_by_re_invite_base(LinphoneMediaEncryptionSRTP, TRUE); + else + ms_message("srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp skipped, missing srtp support"); +} + +static void incoming_reinvite_with_invalid_ack_sdp(void){ + LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc"); + LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc"); + LinphoneCall * inc_call; + BC_ASSERT_TRUE(call(caller,callee)); + inc_call = linphone_core_get_current_call(callee->lc); + + BC_ASSERT_PTR_NOT_NULL(inc_call); + if (inc_call) { + const LinphoneCallParams *caller_params; + stats initial_caller_stat=caller->stat; + stats initial_callee_stat=callee->stat; + sal_call_set_sdp_handling(inc_call->op, SalOpSDPSimulateError); /* will force a parse error for the ACK SDP*/ + BC_ASSERT_PTR_NOT_NULL(setup_video(caller, callee, TRUE)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning)); + /*Basically the negotiation failed but since the call was already running, we expect it to restore to + the previous state so error stats should not be changed*/ + BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallError,initial_callee_stat.number_of_LinphoneCallError, int, "%d"); + /*and remote should have received an update notification*/ + BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote+1, int, "%d"); + + + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + caller_params = linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,(int*)&caller_params->has_video,FALSE)); + + sal_call_set_sdp_handling(inc_call->op, SalOpSDPNormal); + } + end_call(caller, callee); + + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + +static void outgoing_reinvite_with_invalid_ack_sdp(void) { + LinphoneCoreManager* caller = linphone_core_manager_new( "pauline_tcp_rc"); + LinphoneCoreManager* callee = linphone_core_manager_new( "marie_rc"); + LinphoneCall * out_call; + BC_ASSERT_TRUE(call(caller,callee)); + out_call = linphone_core_get_current_call(caller->lc); + + BC_ASSERT_PTR_NOT_NULL(out_call); + if (out_call) { + stats initial_caller_stat=caller->stat; + stats initial_callee_stat=callee->stat; + sal_call_set_sdp_handling(out_call->op, SalOpSDPSimulateError); /* will force a parse error for the ACK SDP*/ + BC_ASSERT_PTR_NOT_NULL(setup_video(caller, callee, TRUE)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallUpdating,initial_callee_stat.number_of_LinphoneCallUpdating+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1)); + BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning)); + /*Basically the negotiation failed but since the call was already running, we expect it to restore to + the previous state so error stats should not be changed*/ + BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallError,initial_callee_stat.number_of_LinphoneCallError, int, "%d"); + /*and remote should not have received any update notification*/ + BC_ASSERT_EQUAL(caller->stat.number_of_LinphoneCallUpdatedByRemote,initial_caller_stat.number_of_LinphoneCallUpdatedByRemote, int, "%d"); + + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc)))); + BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc)))); + + sal_call_set_sdp_handling(out_call->op, SalOpSDPNormal); + } + end_call(caller, callee); + + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + +#endif +static void video_call_with_no_audio_and_no_video_codec(void){ + LinphoneCoreManager* callee = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); + LinphoneCall* out_call ; + LinphoneVideoPolicy callee_policy, caller_policy; + LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; + + const MSList* elem_video =linphone_core_get_video_codecs(caller->lc); + + const MSList* elem_audio =linphone_core_get_audio_codecs(caller->lc); + + disable_all_codecs(elem_audio, caller); + disable_all_codecs(elem_video, caller); + + callee_policy.automatically_initiate=FALSE; + callee_policy.automatically_accept=TRUE; + caller_policy.automatically_initiate=TRUE; + caller_policy.automatically_accept=FALSE; + + linphone_core_set_video_policy(callee->lc,&callee_policy); + linphone_core_set_video_policy(caller->lc,&caller_policy); + + + linphone_core_enable_video_display(callee->lc, TRUE); + linphone_core_enable_video_capture(callee->lc, TRUE); + + linphone_core_enable_video_display(caller->lc, TRUE); + linphone_core_enable_video_capture(caller->lc, TRUE); + + /* Create call params */ + caller_test_params.base = linphone_core_create_call_params(caller->lc, NULL); + + + out_call = linphone_core_invite_address_with_params(caller->lc, callee->identity,caller_test_params.base); + linphone_call_ref(out_call); + + linphone_call_params_destroy(caller_test_params.base); + if (callee_test_params.base) linphone_call_params_destroy(callee_test_params.base); + + + BC_ASSERT_TRUE(wait_for(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallOutgoingInit, 1)); + + BC_ASSERT_TRUE(wait_for_until(caller->lc, callee->lc, &caller->stat.number_of_LinphoneCallError, 1, 6000)); + BC_ASSERT_EQUAL(linphone_call_get_reason(out_call), LinphoneReasonNotAcceptable, int, "%d"); + BC_ASSERT_EQUAL(callee->stat.number_of_LinphoneCallIncomingReceived, 0, int, "%d"); + + linphone_call_unref(out_call); + linphone_core_manager_destroy(callee); + linphone_core_manager_destroy(caller); +} + +static void call_with_early_media_and_no_sdp_in_200_with_video(void){ + early_media_without_sdp_in_200_base(TRUE, FALSE); +} + +test_t call_video_tests[] = { +#ifdef VIDEO_ENABLED + TEST_NO_TAG("Call paused resumed with video", call_paused_resumed_with_video), + TEST_NO_TAG("Call paused resumed with video no sdp ack", call_paused_resumed_with_no_sdp_ack), + TEST_NO_TAG("Call paused resumed with video no sdk ack using video policy for resume offers", call_paused_resumed_with_no_sdp_ack_using_video_policy), + TEST_NO_TAG("Call paused, updated and resumed with video no sdk ack using video policy for resume offers", call_paused_updated_resumed_with_no_sdp_ack_using_video_policy), + TEST_NO_TAG("Call paused, updated and resumed with video no sdk ack using video policy for resume offers with accept call update", call_paused_updated_resumed_with_no_sdp_ack_using_video_policy_and_accept_call_update), + TEST_NO_TAG("ZRTP video call", zrtp_video_call), + TEST_NO_TAG("Simple video call AVPF", video_call_avpf), + TEST_NO_TAG("Simple video call implicit AVPF both", video_call_using_policy_AVPF_implicit_caller_and_callee), + TEST_NO_TAG("Simple video call disable implicit AVPF on callee", video_call_disable_implicit_AVPF_on_callee), + TEST_NO_TAG("Simple video call disable implicit AVPF on caller", video_call_disable_implicit_AVPF_on_caller), + TEST_NO_TAG("Simple video call AVPF to implicit AVPF", video_call_AVPF_to_implicit_AVPF), + TEST_NO_TAG("Simple video call implicit AVPF to AVPF", video_call_implicit_AVPF_to_AVPF), + TEST_NO_TAG("Simple video call", video_call), + TEST_NO_TAG("Simple video call without rtcp",video_call_without_rtcp), + TEST_NO_TAG("Simple ZRTP video call", video_call_zrtp), + TEST_NO_TAG("Simple DTLS video call", video_call_dtls), + TEST_NO_TAG("Simple video call using policy", video_call_using_policy), + TEST_NO_TAG("Video call using policy with callee video disabled", video_call_using_policy_with_callee_video_disabled), + TEST_NO_TAG("Video call using policy with caller video disabled", video_call_using_policy_with_caller_video_disabled), + TEST_NO_TAG("Video call without SDP", video_call_no_sdp), + TEST_ONE_TAG("SRTP ice video call", srtp_video_ice_call, "ICE"), + TEST_ONE_TAG("ZRTP ice video call", zrtp_video_ice_call, "ICE"), + TEST_NO_TAG("Call with video added", call_with_video_added), + TEST_NO_TAG("Call with video added 2", call_with_video_added_2), + TEST_NO_TAG("Call with video added (random ports)", call_with_video_added_random_ports), + TEST_NO_TAG("Call with several video switches", call_with_several_video_switches), + TEST_NO_TAG("SRTP call with several video switches", srtp_call_with_several_video_switches), + TEST_NO_TAG("Call with video declined", call_with_declined_video), + TEST_NO_TAG("Call with video declined despite policy", call_with_declined_video_despite_policy), + TEST_NO_TAG("Call with video declined using policy", call_with_declined_video_using_policy), + TEST_NO_TAG("Video early-media call", video_early_media_call), + TEST_NO_TAG("Call with multiple early media", multiple_early_media), + TEST_ONE_TAG("Call with ICE from video to non-video", call_with_ice_video_to_novideo, "ICE"), + TEST_ONE_TAG("Call with ICE and video added", call_with_ice_video_added, "ICE"), + TEST_ONE_TAG("Call with ICE and video added 2", call_with_ice_video_added_2, "ICE"), + TEST_ONE_TAG("Call with ICE and video added 3", call_with_ice_video_added_3, "ICE"), + TEST_ONE_TAG("Call with ICE and video added and refused", call_with_ice_video_added_and_refused, "ICE"), + TEST_ONE_TAG("Call with ICE and video added with video policies to false", call_with_ice_video_added_with_video_policies_to_false, "ICE"), +#if ICE_WAS_WORKING_WITH_REAL_TIME_TEXT + TEST_ONE_TAG("Call with ICE, video and realtime text", call_with_ice_video_and_rtt, "ICE"), +#endif + TEST_ONE_TAG("Video call with ICE accepted using call params", video_call_ice_params, "ICE"), + TEST_ONE_TAG("Audio call with ICE paused with caller video policy enabled", audio_call_with_ice_with_video_policy_enabled, "ICE"), + TEST_NO_TAG("Video call recording (H264)", video_call_recording_h264_test), + TEST_NO_TAG("Video call recording (VP8)", video_call_recording_vp8_test), + TEST_NO_TAG("Snapshot", video_call_snapshot), + TEST_NO_TAG("Video call with early media and no matching audio codecs", video_call_with_early_media_no_matching_audio_codecs), + TEST_NO_TAG("DTLS SRTP video call", dtls_srtp_video_call), + TEST_ONE_TAG("DTLS SRTP ice video call", dtls_srtp_ice_video_call, "ICE"), + TEST_ONE_TAG("DTLS SRTP ice video call with relay", dtls_srtp_ice_video_call_with_relay, "ICE"), + TEST_NO_TAG("Video call with limited bandwidth", video_call_limited_bandwidth), + TEST_NO_TAG("Video call accepted in send only", accept_call_in_send_only), + TEST_ONE_TAG("Video call accepted in send only with ice", accept_call_in_send_only_with_ice, "ICE"), + TEST_NO_TAG("2 Video call accepted in send only", two_accepted_call_in_send_only), + TEST_NO_TAG("Video call with re-invite(inactive) followed by re-invite", video_call_with_re_invite_inactive_followed_by_re_invite), + TEST_NO_TAG("Video call with re-invite(inactive) followed by re-invite(no sdp)", video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp), + TEST_NO_TAG("SRTP Video call with re-invite(inactive) followed by re-invite", srtp_video_call_with_re_invite_inactive_followed_by_re_invite), + TEST_NO_TAG("SRTP Video call with re-invite(inactive) followed by re-invite(no sdp)", srtp_video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp), + TEST_NO_TAG("Classic video entry phone setup", classic_video_entry_phone_setup), + TEST_NO_TAG("Incoming REINVITE with invalid SDP in ACK", incoming_reinvite_with_invalid_ack_sdp), + TEST_NO_TAG("Outgoing REINVITE with invalid SDP in ACK", outgoing_reinvite_with_invalid_ack_sdp), +#endif + TEST_NO_TAG("Video call with no audio and no video codec", video_call_with_no_audio_and_no_video_codec), + TEST_NO_TAG("Call with early media and no SDP in 200 Ok with video", call_with_early_media_and_no_sdp_in_200_with_video), +}; + +test_suite_t call_video_test_suite = {"Video Call", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each, + sizeof(call_video_tests) / sizeof(call_video_tests[0]), call_video_tests}; diff --git a/tester/complex_sip_call_tester.c b/tester/complex_sip_case_tester.c similarity index 99% rename from tester/complex_sip_call_tester.c rename to tester/complex_sip_case_tester.c index b446592a7..1e524bb2c 100644 --- a/tester/complex_sip_call_tester.c +++ b/tester/complex_sip_case_tester.c @@ -361,7 +361,7 @@ static test_t tests[] = { }; test_suite_t complex_sip_call_test_suite = { - "Complex SIP Call", + "Complex SIP Case", NULL, NULL, liblinphone_tester_before_each, diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 242bc339d..898c0ed24 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -42,6 +42,7 @@ extern "C" { extern test_suite_t setup_test_suite; extern test_suite_t register_test_suite; extern test_suite_t call_test_suite; +extern test_suite_t call_video_test_suite; extern test_suite_t message_test_suite; extern test_suite_t presence_test_suite; extern test_suite_t presence_server_test_suite; @@ -323,12 +324,18 @@ bool_t call_with_test_params(LinphoneCoreManager* caller_mgr ,LinphoneCoreManager* callee_mgr ,const LinphoneCallTestParams *caller_test_params ,const LinphoneCallTestParams *callee_test_params); +bool_t call_with_params2(LinphoneCoreManager* caller_mgr + ,LinphoneCoreManager* callee_mgr + , const LinphoneCallTestParams *caller_test_params + , const LinphoneCallTestParams *callee_test_params + , bool_t build_callee_params); bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_mgr); bool_t add_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t change_video_policy); void end_call(LinphoneCoreManager *m1, LinphoneCoreManager *m2); void disable_all_audio_codecs_except_one(LinphoneCore *lc, const char *mime, int rate); void disable_all_video_codecs_except_one(LinphoneCore *lc, const char *mime); +void disable_all_codecs(const MSList* elem, LinphoneCoreManager* call); stats * get_stats(LinphoneCore *lc); bool_t transport_supported(LinphoneTransportType transport); LinphoneCoreManager *get_manager(LinphoneCore *lc); @@ -352,6 +359,9 @@ bool_t call_with_caller_params(LinphoneCoreManager* caller_mgr,LinphoneCoreManag bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,LinphoneCoreManager* mgr_2,LinphoneCall* call_2); void compare_files(const char *path1, const char *path2); void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList* lcs,LinphoneMediaDirection audio_dir, LinphoneMediaDirection video_dir); +void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports, bool_t forced_relay); +void check_nb_media_starts(LinphoneCoreManager *caller, LinphoneCoreManager *callee, unsigned int caller_nb_media_starts, unsigned int callee_nb_media_starts); +void record_call(const char *filename, bool_t enableVideo, const char *video_codec); extern const MSAudioDiffParams audio_cmp_params; @@ -380,6 +390,7 @@ extern const char *liblinphone_tester_mire_id; LinphoneAddress * linphone_core_manager_resolve(LinphoneCoreManager *mgr, const LinphoneAddress *source); FILE *sip_start(const char *senario, const char* dest_username, const char *passwd, LinphoneAddress* dest_addres); +void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ); #ifdef __cplusplus diff --git a/tester/tester.c b/tester/tester.c index 57d4cc851..cb00b9abe 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -134,7 +134,7 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c ringbackpath = ms_strdup_printf("%s/sounds/ringback.wav", path); nowebcampath = ms_strdup_printf("%s/images/nowebcamCIF.jpg", path); rootcapath = ms_strdup_printf("%s/certificates/cn/cafile.pem", path); - dnsuserhostspath = ms_strdup_printf( "%s/%s", path, userhostsfile); + dnsuserhostspath = ms_strdup_printf("%s/%s", path, userhostsfile); if( config != NULL ) { @@ -498,6 +498,7 @@ void liblinphone_tester_add_suites() { bc_tester_add_suite(&tunnel_test_suite); bc_tester_add_suite(&offeranswer_test_suite); bc_tester_add_suite(&call_test_suite); + bc_tester_add_suite(&call_video_test_suite); bc_tester_add_suite(&audio_bypass_suite); bc_tester_add_suite(&multi_call_test_suite); bc_tester_add_suite(&message_test_suite); From 409bec2da23d4c6948709cfc8791905c7bd1ca44 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 15 Jun 2016 16:38:15 +0200 Subject: [PATCH 085/124] Update ortp and ms2 submodules. --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 1f7339920..2b7e5dfa5 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 1f7339920c9156b4f05ef34b5d83a79891f6f142 +Subproject commit 2b7e5dfa522338d2280b0332fb34a955ee6684cc diff --git a/oRTP b/oRTP index d134dae12..95c23d211 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit d134dae12ec433142ab5266e22f3bb7db91f624f +Subproject commit 95c23d2115020786ed790d480d501b2ddffdc22d From 0e082f1a409a5a7d9500b45fac5e0f6bab2784fa Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 16 Jun 2016 11:25:32 +0200 Subject: [PATCH 086/124] chat: improve message_tester suites and fix memory leaks --- coreapi/chat.c | 12 +++++-- coreapi/chat_file_transfer.c | 8 +++-- tester/message_tester.c | 66 +++++++++++++++++++++--------------- 3 files changed, 52 insertions(+), 34 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index ac2e6e291..73d76191a 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -376,18 +376,24 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage msg->dir = LinphoneChatMessageOutgoing; - // add to transient list - cr->transient_messages = ms_list_append(cr->transient_messages, linphone_chat_message_ref(msg)); /* Check if we shall upload a file to a server */ if (msg->file_transfer_information != NULL && msg->content_type == NULL) { /* open a transaction with the server and send an empty request(RCS5.1 section 3.5.4.8.3.1) */ - linphone_chat_room_upload_file(msg); + if (linphone_chat_room_upload_file(msg) == 0) { + // add to transient list only if message is going out + cr->transient_messages = ms_list_append(cr->transient_messages, linphone_chat_message_ref(msg)); + } else { + linphone_chat_message_unref(msg); + return; + } } else { SalOp *op = NULL; LinphoneCall *call; char *content_type; const char *identity = NULL; + // add to transient list + cr->transient_messages = ms_list_append(cr->transient_messages, linphone_chat_message_ref(msg)); msg->time = ms_time(0); if (lp_config_get_int(cr->lc->config, "sip", "chat_use_call_dialogs", 0) != 0) { if ((call = linphone_core_get_call_by_remote_address(cr->lc, cr->peer)) != NULL) { diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 21d003450..1d6eade51 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -291,20 +291,22 @@ static void linphone_chat_message_process_response_from_post_file(void *data, msg->message = ms_strdup(body); } msg->content_type = ms_strdup("application/vnd.gsma.rcs-ft-http+xml"); - linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone); linphone_chat_message_ref(msg); + linphone_chat_message_set_state(msg, LinphoneChatMessageStateFileTransferDone); _release_http_request(msg); _linphone_chat_room_send_message(msg->chat_room, msg); linphone_chat_message_unref(msg); } else { ms_warning("Received empty response from server, file transfer failed"); - linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered); + linphone_chat_message_update_state(msg, LinphoneChatMessageStateNotDelivered); _release_http_request(msg); + linphone_chat_message_unref(msg); } } else { ms_warning("Unhandled HTTP code response %d for file transfer", code); - linphone_chat_message_set_state(msg, LinphoneChatMessageStateNotDelivered); + linphone_chat_message_update_state(msg, LinphoneChatMessageStateNotDelivered); _release_http_request(msg); + linphone_chat_message_unref(msg); } } } diff --git a/tester/message_tester.c b/tester/message_tester.c index 984f0dfab..84ba9750c 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -31,6 +31,7 @@ #pragma GCC diagnostic push #endif #pragma GCC diagnostic ignored "-Wstrict-prototypes" +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" static char* message_external_body_url=NULL; @@ -1331,7 +1332,15 @@ void file_transfer_io_error_base(char *server_url, bool_t destroy_room) { } static void file_transfer_not_sent_if_invalid_url(void) { - file_transfer_io_error_base("INVALID URL", FALSE); + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneChatRoom *chatroom = linphone_core_get_chat_room_from_uri(marie->lc, ""); + LinphoneChatMessage *msg = create_message_from_nowebcam(chatroom); + LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg); + linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); + linphone_core_set_file_transfer_server(marie->lc, "INVALID URL"); + linphone_chat_room_send_chat_message(chatroom, msg); + BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneMessageNotDelivered, 1, 1000)); + linphone_core_manager_destroy(marie); } static void file_transfer_not_sent_if_host_not_found(void) { @@ -1404,8 +1413,8 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo linphone_call_params_enable_realtime_text(marie_params,TRUE); if (!audio_stream_enabled) { linphone_call_params_enable_audio(marie_params,FALSE); - linphone_core_set_nortp_timeout(marie->lc, 10); - linphone_core_set_nortp_timeout(pauline->lc, 10); + linphone_core_set_nortp_timeout(marie->lc, 5); + linphone_core_set_nortp_timeout(pauline->lc, 5); } BC_ASSERT_TRUE(call_with_caller_params(marie, pauline, marie_params)); @@ -1420,7 +1429,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo pauline_chat_room = linphone_call_get_chat_room(pauline_call); BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); if (pauline_chat_room) { - const char* message = "Lorem Ipsum Belledonnum Communicatum"; + const char* message = "Be l3l"; int i; LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call); @@ -1459,7 +1468,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo if (!audio_stream_enabled) { int dummy = 0; - wait_for_until(pauline->lc, marie->lc, &dummy, 1, 13000); /* Wait to see if call is dropped after the nortp_timeout */ + wait_for_until(pauline->lc, marie->lc, &dummy, 1, 7000); /* Wait to see if call is dropped after the nortp_timeout */ BC_ASSERT_FALSE(marie->stat.number_of_LinphoneCallEnd > 0); BC_ASSERT_FALSE(pauline->stat.number_of_LinphoneCallEnd > 0); } @@ -1510,10 +1519,10 @@ static void real_time_text_conversation(void) { marie_chat_room = linphone_call_get_chat_room(marie_call); BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); if (pauline_chat_room && marie_chat_room) { - const char* message1_1 = "Lorem Ipsum"; - const char* message1_2 = "Muspi Merol"; - const char* message2_1 = "Belledonnum Communicatum"; - const char* message2_2 = "Mutacinummoc Munnodelleb"; + const char* message1_1 = "Lorem"; + const char* message1_2 = "Ipsum"; + const char* message2_1 = "Be lle Com"; + const char* message2_2 = "eB ell moC"; int i; LinphoneChatMessage* pauline_rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatMessage* marie_rtt_message = linphone_chat_room_create_message(marie_chat_room,NULL); @@ -1622,7 +1631,7 @@ static void real_time_text_message_compat(bool_t end_with_crlf, bool_t end_with_ pauline_chat_room = linphone_call_get_chat_room(pauline_call); BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); if (pauline_chat_room) { - const char* message = "Lorem Ipsum Belledonnum Communicatum"; + const char* message = "Be l3l"; int i; LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call); @@ -1642,6 +1651,7 @@ static void real_time_text_message_compat(bool_t end_with_crlf, bool_t end_with_ } BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, strlen(message), 1000)); BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); + linphone_chat_message_unref(rtt_message); } end_call(marie, pauline); } @@ -1735,7 +1745,7 @@ static void real_time_text_copy_paste(void) { pauline_chat_room = linphone_call_get_chat_room(pauline_call); BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); if (pauline_chat_room) { - const char* message = "Lorem Ipsum Belledonnum Communicatum"; + const char* message = "Be l3l"; int i; LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call); @@ -1806,23 +1816,23 @@ test_t message_tests[] = { TEST_NO_TAG("History count", history_count), #endif TEST_NO_TAG("Text status after destroying chat room", text_status_after_destroying_chat_room), - TEST_ONE_TAG("Transfer not sent if invalid url", file_transfer_not_sent_if_invalid_url, "LeaksMemory"), - TEST_ONE_TAG("Transfer not sent if host not found", file_transfer_not_sent_if_host_not_found, "LeaksMemory"), - TEST_ONE_TAG("Transfer not sent if url moved permanently", file_transfer_not_sent_if_url_moved_permanently, "LeaksMemory"), - TEST_ONE_TAG("Transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom, "LeaksMemory"), - TEST_NO_TAG("Real Time Text message", real_time_text_message), - TEST_NO_TAG("Real Time Text SQL storage", real_time_text_sql_storage), - TEST_NO_TAG("Real Time Text SQL storage with RTT messages not stored", real_time_text_sql_storage_rtt_disabled), - TEST_NO_TAG("Real Time Text conversation", real_time_text_conversation), - TEST_NO_TAG("Real Time Text without audio", real_time_text_without_audio), - TEST_NO_TAG("Real Time Text with srtp", real_time_text_srtp), - TEST_NO_TAG("Real Time Text with ice", real_time_text_ice), - TEST_ONE_TAG("Real Time Text message compatibility crlf", real_time_text_message_compat_crlf, "LeaksMemory"), - TEST_ONE_TAG("Real Time Text message compatibility lf", real_time_text_message_compat_lf, "LeaksMemory"), - TEST_NO_TAG("Real Time Text message with accented characters", real_time_text_message_accented_chars), - TEST_NO_TAG("Real Time Text offer answer with different payload numbers (sender side)", real_time_text_message_different_text_codecs_payload_numbers_sender_side), - TEST_NO_TAG("Real Time Text offer answer with different payload numbers (receiver side)", real_time_text_message_different_text_codecs_payload_numbers_receiver_side), - TEST_NO_TAG("Real Time Text copy paste", real_time_text_copy_paste), + TEST_NO_TAG("Transfer not sent if invalid url", file_transfer_not_sent_if_invalid_url), + TEST_NO_TAG("Transfer not sent if host not found", file_transfer_not_sent_if_host_not_found), + TEST_NO_TAG("Transfer not sent if url moved permanently", file_transfer_not_sent_if_url_moved_permanently), + TEST_NO_TAG("Transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom), + TEST_ONE_TAG("Real Time Text message", real_time_text_message, "RTT"), + TEST_ONE_TAG("Real Time Text SQL storage", real_time_text_sql_storage, "RTT"), + TEST_ONE_TAG("Real Time Text SQL storage with RTT messages not stored", real_time_text_sql_storage_rtt_disabled, "RTT"), + TEST_ONE_TAG("Real Time Text conversation", real_time_text_conversation, "RTT"), + TEST_ONE_TAG("Real Time Text without audio", real_time_text_without_audio, "RTT"), + TEST_ONE_TAG("Real Time Text with srtp", real_time_text_srtp, "RTT"), + TEST_ONE_TAG("Real Time Text with ice", real_time_text_ice, "RTT"), + TEST_ONE_TAG("Real Time Text message compatibility crlf", real_time_text_message_compat_crlf, "RTT"), + TEST_ONE_TAG("Real Time Text message compatibility lf", real_time_text_message_compat_lf, "RTT"), + TEST_ONE_TAG("Real Time Text message with accented characters", real_time_text_message_accented_chars, "RTT"), + TEST_ONE_TAG("Real Time Text offer answer with different payload numbers (sender side)", real_time_text_message_different_text_codecs_payload_numbers_sender_side, "RTT"), + TEST_ONE_TAG("Real Time Text offer answer with different payload numbers (receiver side)", real_time_text_message_different_text_codecs_payload_numbers_receiver_side, "RTT"), + TEST_ONE_TAG("Real Time Text copy paste", real_time_text_copy_paste, "RTT"), }; test_suite_t message_test_suite = { From c13647f8bd426b4a160faec30dc36690c1699429 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 16 Jun 2016 12:23:53 +0200 Subject: [PATCH 087/124] Treat warnings as errors on Windows. --- CMakeLists.txt | 7 ++++- console/CMakeLists.txt | 6 +++++ console/commands.c | 4 +-- console/linphonec.c | 11 ++++---- coreapi/account_creator.c | 10 +++---- coreapi/bellesip_sal/sal_impl.c | 2 +- coreapi/call_log.c | 12 ++++----- coreapi/friend.c | 43 ++++++++++++++++++++++++------- coreapi/lime.c | 2 +- coreapi/linphonecall.c | 2 +- coreapi/linphonecore.c | 20 +++++++------- coreapi/linphonecore.h | 4 +-- coreapi/message_storage.c | 10 +++---- coreapi/misc.c | 3 ++- coreapi/private.h | 2 +- coreapi/sqlite3_bctbx_vfs.c | 39 ++++++++++++---------------- coreapi/vtables.c | 12 +++++++++ gtk/calllogs.c | 3 ++- gtk/chat.c | 9 ++++--- gtk/friendlist.c | 9 ++++--- gtk/incall_view.c | 6 ++--- gtk/linphone.h | 2 ++ gtk/logging.c | 10 ++++++- gtk/main.c | 12 ++++----- gtk/propertybox.c | 38 +++++++++++++-------------- gtk/status_icon.h | 2 ++ mediastreamer2 | 2 +- oRTP | 2 +- tester/CMakeLists.txt | 8 ++++++ tester/call_single_tester.c | 28 ++++++++++---------- tester/liblinphone_tester.c | 4 +++ tester/message_tester.c | 16 +++++++----- tester/presence_tester.c | 2 +- tester/quality_reporting_tester.c | 2 +- tester/tester.c | 6 +++++ tester/vcard_tester.c | 8 +++--- tester/video_tester.c | 2 ++ 37 files changed, 220 insertions(+), 140 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6144be09..bc9ae5917 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,7 +228,12 @@ set(STRICT_OPTIONS_CPP ) set(STRICT_OPTIONS_C ) set(STRICT_OPTIONS_CXX ) set(STRICT_OPTIONS_OBJC ) -if(NOT MSVC) +if(MSVC) + list(APPEND STRICT_OPTIONS_CPP "/wd4995") # Disable "name was marked as #pragma deprecated" warnings + if(ENABLE_STRICT) + list(APPEND STRICT_OPTIONS_CPP "/WX") + endif() +else() list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations") list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Wno-error=strict-prototypes") if(CMAKE_C_COMPILER_ID STREQUAL "Clang") diff --git a/console/CMakeLists.txt b/console/CMakeLists.txt index 3ec2b9e44..078b4ee40 100644 --- a/console/CMakeLists.txt +++ b/console/CMakeLists.txt @@ -30,6 +30,12 @@ set(LINPHONECSH_SOURCE_FILES ) apply_compile_flags(LINPHONEC_SOURCE_FILES "CPP" "C") +if(MSVC) + get_source_file_property(COMMANDS_C_COMPILE_FLAGS commands.c COMPILE_FLAGS) + set(COMMANDS_C_COMPILE_FLAGS "${COMMANDS_C_COMPILE_FLAGS} /wd4996") # Disable "was declared deprecated" warnings + set_source_files_properties(commands.c PROPERTY COMPILE_FLAGS "${COMMANDS_C_COMPILE_FLAGS}") +endif() + add_executable(linphonec ${LINPHONEC_SOURCE_FILES}) target_link_libraries(linphonec linphone) diff --git a/console/commands.c b/console/commands.c index 095ab3f18..c3324d3df 100644 --- a/console/commands.c +++ b/console/commands.c @@ -1432,7 +1432,7 @@ lpc_cmd_staticpic(LinphoneCore *lc, char *args) if (strcmp(arg1, "fps")==0) { if (arg2) { - float fps = atof(arg2); /* FIXME: Handle not-a-float */ + float fps = (float)atof(arg2); /* FIXME: Handle not-a-float */ linphone_core_set_static_picture_fps(lc, fps); return 1; } else { @@ -2375,7 +2375,7 @@ static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args){ static int lpc_cmd_playback_gain(LinphoneCore *lc, char *args) { if (args){ - linphone_core_set_playback_gain_db(lc, atof(args)); + linphone_core_set_playback_gain_db(lc, (float)atof(args)); return 1; } return 0; diff --git a/console/linphonec.c b/console/linphonec.c index 07ac95729..899ffe61c 100644 --- a/console/linphonec.c +++ b/console/linphonec.c @@ -37,6 +37,7 @@ #include #include "linphonec.h" +#include #ifdef _WIN32 #include @@ -1206,7 +1207,7 @@ linphonec_parse_cmdline(int argc, char **argv) if (strcmp(argv[arg_num], "NUL") != 0) { #endif #if !defined(_WIN32_WCE) - if (access(argv[arg_num], F_OK) != 0) + if (bctbx_file_exist(argv[arg_num]) != 0) { fprintf(stderr, "Cannot open config file %s.\n", @@ -1223,7 +1224,7 @@ linphonec_parse_cmdline(int argc, char **argv) { if ( ++arg_num >= argc ) print_usage(EXIT_FAILURE); #if !defined(_WIN32_WCE) - if (access(argv[arg_num],F_OK)!=0 ) + if (bctbx_file_exist(argv[arg_num])!=0 ) { fprintf (stderr, "Cannot open config file %s.\n", @@ -1331,7 +1332,7 @@ handle_configfile_migration() * If the *NEW* configuration already exists * do nothing. */ - if (access(new_cfg,F_OK)==0) + if (bctbx_file_exist(new_cfg)==0) { free(new_cfg); return 0; @@ -1343,7 +1344,7 @@ handle_configfile_migration() * If the *OLD* CLI configurations exist copy it to * the new file and make it a symlink. */ - if (access(old_cfg_cli, F_OK)==0) + if (bctbx_file_exist(old_cfg_cli)==0) { if ( ! copy_file(old_cfg_cli, new_cfg) ) { @@ -1364,7 +1365,7 @@ handle_configfile_migration() * If the *OLD* GUI configurations exist copy it to * the new file and make it a symlink. */ - if (access(old_cfg_gui, F_OK)==0) + if (bctbx_file_exist(old_cfg_gui)==0) { if ( ! copy_file(old_cfg_gui, new_cfg) ) { diff --git a/coreapi/account_creator.c b/coreapi/account_creator.c index 1ea4aabb5..4469bc7d1 100644 --- a/coreapi/account_creator.c +++ b/coreapi/account_creator.c @@ -210,11 +210,11 @@ LinphoneAccountCreatorStatus linphone_account_creator_set_username(LinphoneAccou bool_t use_phone_number = lp_config_get_int(creator->core->config, "assistant", "use_phone_number", 0); const char* regex = lp_config_get_string(creator->core->config, "assistant", "username_regex", 0); LinphoneAccountCreatorStatus status; - if (min_length > 0 && strlen(username) < min_length) { + if (min_length > 0 && strlen(username) < (size_t)min_length) { return LinphoneAccountCreatorUsernameTooShort; - } else if (max_length > 0 && strlen(username) > max_length) { + } else if (max_length > 0 && strlen(username) > (size_t)max_length) { return LinphoneAccountCreatorUsernameTooLong; - } else if (fixed_length > 0 && strlen(username) != fixed_length) { + } else if (fixed_length > 0 && strlen(username) != (size_t)fixed_length) { return LinphoneAccountCreatorUsernameInvalidSize; } else if (use_phone_number && !linphone_proxy_config_is_phone_number(NULL, username)) { return LinphoneAccountCreatorUsernameInvalid; @@ -236,9 +236,9 @@ const char * linphone_account_creator_get_username(const LinphoneAccountCreator LinphoneAccountCreatorStatus linphone_account_creator_set_password(LinphoneAccountCreator *creator, const char *password){ int min_length = lp_config_get_int(creator->core->config, "assistant", "password_min_length", -1); int max_length = lp_config_get_int(creator->core->config, "assistant", "password_max_length", -1); - if (min_length > 0 && strlen(password) < min_length) { + if (min_length > 0 && strlen(password) < (size_t)min_length) { return LinphoneAccountCreatorPasswordTooShort; - } else if (max_length > 0 && strlen(password) > max_length) { + } else if (max_length > 0 && strlen(password) > (size_t)max_length) { return LinphoneAccountCreatorPasswordTooLong; } set_string(&creator->password, password, FALSE); diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index acaaf6c0a..2c256d29d 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -1036,7 +1036,7 @@ int sal_generate_uuid(char *uuid, size_t len) { written=snprintf(uuid,len,"%8.8x-%4.4x-%4.4x-%2.2x%2.2x-", uuid_struct.time_low, uuid_struct.time_mid, uuid_struct.time_hi_and_version, uuid_struct.clock_seq_hi_and_reserved, uuid_struct.clock_seq_low); - if (written>len+13){ + if ((written < 0) || ((size_t)written > (len +13))) { ms_error("sal_create_uuid(): buffer is too short !"); return -1; } diff --git a/coreapi/call_log.c b/coreapi/call_log.c index 1e8a3786c..91e7eb5dd 100644 --- a/coreapi/call_log.c +++ b/coreapi/call_log.c @@ -76,7 +76,7 @@ static void set_call_log_date(LinphoneCallLog *cl, time_t start_time){ void call_logs_write_to_config_file(LinphoneCore *lc){ MSList *elem; char logsection[32]; - int i; + unsigned int i; char *tmp; LpConfig *cfg=lc->config; @@ -420,7 +420,7 @@ static int create_call_log(void *data, int argc, char **argv, char **colName) { LinphoneCallDir dir; LinphoneCallLog *log; - unsigned int storage_id = atoi(argv[0]); + unsigned int storage_id = (unsigned int)atoi(argv[0]); from = linphone_address_new(argv[1]); to = linphone_address_new(argv[2]); @@ -436,7 +436,7 @@ static int create_call_log(void *data, int argc, char **argv, char **colName) { log->connected_date_time = (time_t)atol(argv[6]); log->status = (LinphoneCallStatus) atoi(argv[7]); log->video_enabled = atoi(argv[8]) == 1; - log->quality = atof(argv[9]); + log->quality = (float)atof(argv[9]); if (argc > 10) { if (argv[10] != NULL) { @@ -507,7 +507,7 @@ void linphone_core_store_call_log(LinphoneCore *lc, LinphoneCallLog *log) { ms_free(from); ms_free(to); - log->storage_id = sqlite3_last_insert_rowid(lc->logs_db); + log->storage_id = (unsigned int)sqlite3_last_insert_rowid(lc->logs_db); } if (lc) { @@ -541,7 +541,7 @@ const MSList *linphone_core_get_call_history(LinphoneCore *lc) { if (!lc || lc->logs_db == NULL) return NULL; - buf = sqlite3_mprintf("SELECT * FROM call_history ORDER BY id DESC LIMIT %i", lc->max_call_logs); + buf = sqlite3_mprintf("SELECT * FROM call_history ORDER BY id DESC LIMIT %u", lc->max_call_logs); begin = ortp_get_cur_time_ms(); linphone_sql_request_call_log(lc->logs_db, buf, &result); @@ -574,7 +574,7 @@ void linphone_core_delete_call_log(LinphoneCore *lc, LinphoneCallLog *log) { if (!lc || lc->logs_db == NULL) return ; - buf = sqlite3_mprintf("DELETE FROM call_history WHERE id = %i", log->storage_id); + buf = sqlite3_mprintf("DELETE FROM call_history WHERE id = %u", log->storage_id); linphone_sql_request_generic(lc->logs_db, buf); sqlite3_free(buf); } diff --git a/coreapi/friend.c b/coreapi/friend.c index 2251b370c..32e840579 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -133,6 +133,14 @@ LinphoneFriend * linphone_friend_new(void){ return obj; } +#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#pragma GCC diagnostic push +#endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif LinphoneFriend *linphone_friend_new_with_address(const char *addr){ LinphoneAddress* linphone_address = linphone_address_new(addr); LinphoneFriend *fr; @@ -146,6 +154,9 @@ LinphoneFriend *linphone_friend_new_with_address(const char *addr){ linphone_address_unref(linphone_address); return fr; } +#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#pragma GCC diagnostic pop +#endif void linphone_friend_set_user_data(LinphoneFriend *lf, void *data){ lf->user_data=data; @@ -674,7 +685,11 @@ void linphone_friend_done(LinphoneFriend *fr) { #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif LinphoneFriend * linphone_core_create_friend(LinphoneCore *lc) { LinphoneFriend * lf = linphone_friend_new(); lf->lc = lc; @@ -1033,7 +1048,11 @@ bool_t linphone_friend_create_vcard(LinphoneFriend *fr, const char *name) { #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVcard *vcard) { LinphoneAddress* linphone_address = NULL; LinphoneFriend *fr; @@ -1183,7 +1202,7 @@ void linphone_core_friends_storage_close(LinphoneCore *lc) { */ static int create_friend_list(void *data, int argc, char **argv, char **colName) { MSList **list = (MSList **)data; - unsigned int storage_id = atoi(argv[0]); + unsigned int storage_id = (unsigned int)atoi(argv[0]); LinphoneFriendList *lfl = linphone_core_create_friend_list(NULL); lfl->storage_id = storage_id; @@ -1200,7 +1219,11 @@ static int create_friend_list(void *data, int argc, char **argv, char **colName) #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif /* DB layout: * | 0 | storage_id * | 1 | friend_list_id @@ -1217,7 +1240,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) { MSList **list = (MSList **)data; LinphoneFriend *lf = NULL; LinphoneVcard *vcard = NULL; - unsigned int storage_id = atoi(argv[0]); + unsigned int storage_id = (unsigned int)atoi(argv[0]); vcard = linphone_vcard_new_from_vcard4_buffer(argv[6]); if (vcard) { @@ -1299,7 +1322,7 @@ void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf) { } if (lf->storage_id > 0) { - buf = sqlite3_mprintf("UPDATE friends SET friend_list_id=%i,sip_uri=%Q,subscribe_policy=%i,send_subscribe=%i,ref_key=%Q,vCard=%Q,vCard_etag=%Q,vCard_url=%Q,presence_received=%i WHERE (id = %i);", + buf = sqlite3_mprintf("UPDATE friends SET friend_list_id=%u,sip_uri=%Q,subscribe_policy=%i,send_subscribe=%i,ref_key=%Q,vCard=%Q,vCard_etag=%Q,vCard_url=%Q,presence_received=%i WHERE (id = %u);", lf->friend_list->storage_id, linphone_address_as_string(linphone_friend_get_address(lf)), lf->pol, @@ -1312,7 +1335,7 @@ void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf) { lf->storage_id ); } else { - buf = sqlite3_mprintf("INSERT INTO friends VALUES(NULL,%i,%Q,%i,%i,%Q,%Q,%Q,%Q,%i);", + buf = sqlite3_mprintf("INSERT INTO friends VALUES(NULL,%u,%Q,%i,%i,%Q,%Q,%Q,%Q,%i);", lf->friend_list->storage_id, linphone_address_as_string(linphone_friend_get_address(lf)), lf->pol, @@ -1328,7 +1351,7 @@ void linphone_core_store_friend_in_db(LinphoneCore *lc, LinphoneFriend *lf) { sqlite3_free(buf); if (lf->storage_id == 0) { - lf->storage_id = sqlite3_last_insert_rowid(lc->friends_db); + lf->storage_id = (unsigned int)sqlite3_last_insert_rowid(lc->friends_db); } } } @@ -1343,7 +1366,7 @@ void linphone_core_store_friends_list_in_db(LinphoneCore *lc, LinphoneFriendList } if (list->storage_id > 0) { - buf = sqlite3_mprintf("UPDATE friends_lists SET display_name=%Q,rls_uri=%Q,uri=%Q,revision=%i WHERE (id = %i);", + buf = sqlite3_mprintf("UPDATE friends_lists SET display_name=%Q,rls_uri=%Q,uri=%Q,revision=%i WHERE (id = %u);", list->display_name, list->rls_uri, list->uri, @@ -1362,7 +1385,7 @@ void linphone_core_store_friends_list_in_db(LinphoneCore *lc, LinphoneFriendList sqlite3_free(buf); if (list->storage_id == 0) { - list->storage_id = sqlite3_last_insert_rowid(lc->friends_db); + list->storage_id = (unsigned int)sqlite3_last_insert_rowid(lc->friends_db); } } } @@ -1375,7 +1398,7 @@ void linphone_core_remove_friend_from_db(LinphoneCore *lc, LinphoneFriend *lf) { return; } - buf = sqlite3_mprintf("DELETE FROM friends WHERE id = %i", lf->storage_id); + buf = sqlite3_mprintf("DELETE FROM friends WHERE id = %u", lf->storage_id); linphone_sql_request_generic(lc->friends_db, buf); sqlite3_free(buf); @@ -1391,7 +1414,7 @@ void linphone_core_remove_friends_list_from_db(LinphoneCore *lc, LinphoneFriendL return; } - buf = sqlite3_mprintf("DELETE FROM friends_lists WHERE id = %i", list->storage_id); + buf = sqlite3_mprintf("DELETE FROM friends_lists WHERE id = %u", list->storage_id); linphone_sql_request_generic(lc->friends_db, buf); sqlite3_free(buf); @@ -1410,7 +1433,7 @@ MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList return NULL; } - buf = sqlite3_mprintf("SELECT * FROM friends WHERE friend_list_id = %i ORDER BY id", list->storage_id); + buf = sqlite3_mprintf("SELECT * FROM friends WHERE friend_list_id = %u ORDER BY id", list->storage_id); begin = ortp_get_cur_time_ms(); linphone_sql_request_friend(lc->friends_db, buf, &result); diff --git a/coreapi/lime.c b/coreapi/lime.c index 0ce71921d..e182d7f40 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -713,7 +713,7 @@ int lime_decryptMultipartMessage(xmlDocPtr cacheBuffer, uint8_t *message, uint8_ if ((!xmlStrcmp(cur->name, (const xmlChar *)"ZID"))){ /* sender ZID found, extract it */ peerZidHex = xmlNodeListGetString(xmlEncryptedMessage, cur->xmlChildrenNode, 1); /* convert it from hexa string to bytes string and set the result in the associatedKey structure */ - lime_strToUint8(associatedKey.peerZID, peerZidHex, strlen((char *)peerZidHex)); + lime_strToUint8(associatedKey.peerZID, peerZidHex, (uint16_t)strlen((char *)peerZidHex)); cur = cur->next; } } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index f6da6e656..376c9a1d0 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -4641,7 +4641,7 @@ void linphone_call_log_completed(LinphoneCall *call){ #endif if (!call_logs_sqlite_db_found) { lc->call_logs=ms_list_prepend(lc->call_logs,linphone_call_log_ref(call->log)); - if (ms_list_size(lc->call_logs)>lc->max_call_logs){ + if (ms_list_size(lc->call_logs)>(size_t)lc->max_call_logs){ MSList *elem,*prevelem=NULL; /*find the last element*/ for(elem=lc->call_logs;elem!=NULL;elem=elem->next){ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e7a7274f3..40ade3d72 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -102,7 +102,7 @@ static OrtpLogFunc liblinphone_log_func = NULL; static LinphoneLogCollectionState liblinphone_log_collection_state = LinphoneLogCollectionDisabled; static char * liblinphone_log_collection_path = NULL; static char * liblinphone_log_collection_prefix = NULL; -static int liblinphone_log_collection_max_file_size = LOG_COLLECTION_DEFAULT_MAX_FILE_SIZE; +static size_t liblinphone_log_collection_max_file_size = LOG_COLLECTION_DEFAULT_MAX_FILE_SIZE; static ortp_mutex_t liblinphone_log_collection_mutex; static FILE * liblinphone_log_collection_file = NULL; static size_t liblinphone_log_collection_file_size = 0; @@ -230,7 +230,7 @@ static int _open_log_collection_file_with_idx(int idx) { if (liblinphone_log_collection_file == NULL) return -1; fstat(fileno(liblinphone_log_collection_file), &statbuf); - if (statbuf.st_size > liblinphone_log_collection_max_file_size) { + if ((size_t)statbuf.st_size > liblinphone_log_collection_max_file_size) { fclose(liblinphone_log_collection_file); return -1; } @@ -369,11 +369,11 @@ void linphone_core_set_log_collection_prefix(const char *prefix) { } } -int linphone_core_get_log_collection_max_file_size(void) { +size_t linphone_core_get_log_collection_max_file_size(void) { return liblinphone_log_collection_max_file_size; } -void linphone_core_set_log_collection_max_file_size(int size) { +void linphone_core_set_log_collection_max_file_size(size_t size) { liblinphone_log_collection_max_file_size = size; } @@ -810,7 +810,7 @@ static void build_sound_devices_table(LinphoneCore *lc){ devices[ndev]=NULL; old=lc->sound_conf.cards; lc->sound_conf.cards=devices; - if (old!=NULL) ms_free(old); + if (old!=NULL) ms_free((void *)old); } static const char *get_default_local_ring(LinphoneCore * lc){ @@ -1373,7 +1373,7 @@ static void build_video_devices_table(LinphoneCore *lc){ int ndev; const char **devices; if (lc->video_conf.cams) - ms_free(lc->video_conf.cams); + ms_free((void *)lc->video_conf.cams); /* retrieve all video devices */ elem=ms_web_cam_manager_get_list(ms_factory_get_web_cam_manager(lc->factory)); ndev=ms_list_size(elem); @@ -1604,7 +1604,7 @@ static void misc_config_read(LinphoneCore *lc) { LpConfig *config=lc->config; const char *uuid; - lc->max_call_logs=lp_config_get_int(config,"misc","history_max_size",30); + lc->max_call_logs=(unsigned int)lp_config_get_int(config,"misc","history_max_size",30); lc->max_calls=lp_config_get_int(config,"misc","max_calls",NB_MAX_CALLS); uuid=lp_config_get_string(config,"misc","uuid",NULL); @@ -6545,7 +6545,7 @@ void rtp_config_uninit(LinphoneCore *lc) static void sound_config_uninit(LinphoneCore *lc) { sound_config_t *config=&lc->sound_conf; - ms_free(config->cards); + ms_free((void *)config->cards); lp_config_set_string(lc->config,"sound","remote_ring",config->remote_ring); lp_config_set_float(lc->config,"sound","playback_gain_db",config->soft_play_lev); @@ -6562,7 +6562,7 @@ static void video_config_uninit(LinphoneCore *lc) lp_config_set_int(lc->config,"video","display",lc->video_conf.display); lp_config_set_int(lc->config,"video","capture",lc->video_conf.capture); if (lc->video_conf.cams) - ms_free(lc->video_conf.cams); + ms_free((void *)lc->video_conf.cams); } void _linphone_core_codec_config_write(LinphoneCore *lc){ @@ -6731,7 +6731,7 @@ static void linphone_core_uninit(LinphoneCore *lc) } linphone_core_free_payload_types(lc); - if (lc->supported_formats) ms_free(lc->supported_formats); + if (lc->supported_formats) ms_free((void *)lc->supported_formats); linphone_core_message_storage_close(lc); linphone_core_call_log_storage_close(lc); linphone_core_friends_storage_close(lc); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index e43c25c9f..15af0ccdf 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -2261,7 +2261,7 @@ LINPHONE_PUBLIC void linphone_core_set_log_collection_prefix(const char *prefix) * Get the max file size in bytes of the files used for log collection. * @return The max file size in bytes of the files used for log collection. */ -LINPHONE_PUBLIC int linphone_core_get_log_collection_max_file_size(void); +LINPHONE_PUBLIC size_t linphone_core_get_log_collection_max_file_size(void); /** * Set the max file size in bytes of the files used for log collection. @@ -2271,7 +2271,7 @@ LINPHONE_PUBLIC int linphone_core_get_log_collection_max_file_size(void); * on runtime, logs chronological order COULD be broken. * @param[in] size The max file size in bytes of the files used for log collection. */ -LINPHONE_PUBLIC void linphone_core_set_log_collection_max_file_size(int size); +LINPHONE_PUBLIC void linphone_core_set_log_collection_max_file_size(size_t size); /** * Set the url of the server where to upload the collected log files. diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 18867674d..126b265ab 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -198,7 +198,7 @@ static int callback_all(void *data, int argc, char **argv, char **colName){ */ static int create_chat_message(void *data, int argc, char **argv, char **colName){ LinphoneChatRoom *cr = (LinphoneChatRoom *)data; - unsigned int storage_id = atoi(argv[0]); + unsigned int storage_id = (unsigned int)atoi(argv[0]); // check if the message exists in the transient list, in which case we should return that one. LinphoneChatMessage* new_message = get_transient_message(cr, storage_id); @@ -329,7 +329,7 @@ unsigned int linphone_chat_message_store(LinphoneChatMessage *msg){ void linphone_chat_message_store_state(LinphoneChatMessage *msg){ LinphoneCore *lc=msg->chat_room->lc; if (lc->db){ - char *buf=sqlite3_mprintf("UPDATE history SET status=%i WHERE (id = %i);", + char *buf=sqlite3_mprintf("UPDATE history SET status=%i WHERE (id = %u);", msg->state,msg->storage_id); linphone_sql_request(lc->db,buf); sqlite3_free(buf); @@ -339,7 +339,7 @@ void linphone_chat_message_store_state(LinphoneChatMessage *msg){ void linphone_chat_message_store_appdata(LinphoneChatMessage* msg){ LinphoneCore *lc=msg->chat_room->lc; if (lc->db){ - char *buf=sqlite3_mprintf("UPDATE history SET appdata=%Q WHERE id=%i;", + char *buf=sqlite3_mprintf("UPDATE history SET appdata=%Q WHERE id=%u;", msg->appdata,msg->storage_id); linphone_sql_request(lc->db,buf); sqlite3_free(buf); @@ -373,7 +373,7 @@ void linphone_chat_room_update_url(LinphoneChatRoom *cr, LinphoneChatMessage *ms if (lc->db==NULL) return ; - buf=sqlite3_mprintf("UPDATE history SET url=%Q WHERE id=%i;",msg->external_body_url,msg->storage_id); + buf=sqlite3_mprintf("UPDATE history SET url=%Q WHERE id=%u;",msg->external_body_url,msg->storage_id); linphone_sql_request(lc->db,buf); sqlite3_free(buf); } @@ -424,7 +424,7 @@ void linphone_chat_room_delete_message(LinphoneChatRoom *cr, LinphoneChatMessage if (lc->db==NULL) return ; - buf=sqlite3_mprintf("DELETE FROM history WHERE id = %i;", msg->storage_id); + buf=sqlite3_mprintf("DELETE FROM history WHERE id = %u;", msg->storage_id); linphone_sql_request(lc->db,buf); sqlite3_free(buf); diff --git a/coreapi/misc.c b/coreapi/misc.c index d7233c977..cb373eb56 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -903,7 +903,8 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess IceCandidate *rtcp_candidate = NULL; IceSessionState session_state = ice_session_state(session); int nb_candidates; - int i, j; + int i; + size_t j; bool_t result; if (session_state == IS_Completed) { diff --git a/coreapi/private.h b/coreapi/private.h index 7351cfbc5..67fa3ea4f 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -940,7 +940,7 @@ struct _LinphoneCore MSList *queued_calls; /* used by the autoreplier */ MSList *call_logs; MSList *chatrooms; - int max_call_logs; + unsigned int max_call_logs; int missed_calls; VideoPreview *previewstream; struct _MSEventQueue *msevq; diff --git a/coreapi/sqlite3_bctbx_vfs.c b/coreapi/sqlite3_bctbx_vfs.c index 2796be7e9..316c1db8c 100755 --- a/coreapi/sqlite3_bctbx_vfs.c +++ b/coreapi/sqlite3_bctbx_vfs.c @@ -77,7 +77,7 @@ static int sqlite3bctbx_Read(sqlite3_file *p, void *buf, int count, sqlite_int64 int ret; sqlite3_bctbx_file_t *pFile = (sqlite3_bctbx_file_t*) p; if (pFile){ - ret = bctbx_file_read(pFile->pbctbx_file, buf, count, offset); + ret = bctbx_file_read(pFile->pbctbx_file, buf, count, (off_t)offset); if( ret==count ){ return SQLITE_OK; } @@ -106,7 +106,7 @@ static int sqlite3bctbx_Write(sqlite3_file *p, const void *buf, int count, sqlit sqlite3_bctbx_file_t *pFile = (sqlite3_bctbx_file_t*) p; int ret; if (pFile ){ - ret = bctbx_file_write(pFile->pbctbx_file, buf, count, offset); + ret = bctbx_file_write(pFile->pbctbx_file, buf, count, (off_t)offset); if(ret > 0 ) return SQLITE_OK; else { return SQLITE_IOERR_WRITE; @@ -239,31 +239,21 @@ static char* ConvertFromUtf8Filename(const char* fName){ LPWSTR wideFilename; nChar = MultiByteToWideChar(CP_UTF8, 0, fName, -1, NULL, 0); - if (nChar == 0){ - return BCTBX_VFS_ERROR; - } + if (nChar == 0) return NULL; wideFilename = bctbx_malloc(nChar*sizeof(wideFilename[0])); - if (wideFilename == 0){ - return 0; - } - nChar = MultiByteToWideChar(CP_UTF8, 0, fName, -1, wideFilename, - nChar); - if (nChar == 0){ + if (wideFilename == NULL) return NULL; + nChar = MultiByteToWideChar(CP_UTF8, 0, fName, -1, wideFilename, nChar); + if (nChar == 0) { bctbx_free(wideFilename); wideFilename = 0; } nb_byte = WideCharToMultiByte(CP_ACP, 0, wideFilename, -1, 0, 0, 0, 0); - if (nb_byte == 0){ - return 0; - } + if (nb_byte == 0) return NULL; convertedFilename = bctbx_malloc(nb_byte); - if (convertedFilename == 0){ - return 0; - } - nb_byte = WideCharToMultiByte(CP_ACP, 0, wideFilename, -1, convertedFilename, - nb_byte, 0, 0); - if (nb_byte == 0){ + if (convertedFilename == NULL) return NULL; + nb_byte = WideCharToMultiByte(CP_ACP, 0, wideFilename, -1, convertedFilename, nb_byte, 0, 0); + if (nb_byte == 0) { bctbx_free(convertedFilename); convertedFilename = 0; } @@ -286,7 +276,6 @@ static char* ConvertFromUtf8Filename(const char* fName){ iconv_close(cb); } return bctbx_strdup(db_file_locale); - #endif @@ -341,8 +330,12 @@ static int sqlite3bctbx_Open(sqlite3_vfs *pVfs, const char *fName, sqlite3_file openFlags |= O_BINARY; #endif wFname = ConvertFromUtf8Filename(fName); - pFile->pbctbx_file = bctbx_file_open2(bctbx_vfs_get_default(), wFname, openFlags); - bctbx_free(wFname); + if (wFname != NULL) { + pFile->pbctbx_file = bctbx_file_open2(bctbx_vfs_get_default(), wFname, openFlags); + bctbx_free(wFname); + } else { + pFile->pbctbx_file = NULL; + } if( pFile->pbctbx_file == NULL){ return SQLITE_CANTOPEN; diff --git a/coreapi/vtables.c b/coreapi/vtables.c index 292d698d9..50a850ee8 100644 --- a/coreapi/vtables.c +++ b/coreapi/vtables.c @@ -99,7 +99,11 @@ void linphone_core_notify_registration_state_changed(LinphoneCore *lc, LinphoneP #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif void linphone_core_notify_show_interface(LinphoneCore *lc){ NOTIFY_IF_EXIST(show, lc); cleanup_dead_vtable_refs(lc); @@ -149,7 +153,11 @@ void linphone_core_notify_call_log_updated(LinphoneCore *lc, LinphoneCallLog *ne #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif void linphone_core_notify_text_message_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message){ NOTIFY_IF_EXIST(text_received, lc,room,from,message); @@ -166,7 +174,11 @@ void linphone_core_notify_message_received(LinphoneCore *lc, LinphoneChatRoom *r #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif void linphone_core_notify_file_transfer_recv(LinphoneCore *lc, LinphoneChatMessage *message, const LinphoneContent* content, const char* buff, size_t size) { NOTIFY_IF_EXIST(file_transfer_recv, lc,message,content,buff,size); cleanup_dead_vtable_refs(lc); diff --git a/gtk/calllogs.c b/gtk/calllogs.c index bd87a61dc..6705b6cff 100644 --- a/gtk/calllogs.c +++ b/gtk/calllogs.c @@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "linphone.h" +#include #define CONFIG_FILE ".linphone-call-history.db" @@ -28,7 +29,7 @@ char *linphone_gtk_call_logs_storage_get_db_file(const char *filename){ db_file=(char *)g_malloc(path_max*sizeof(char)); if (filename==NULL) filename=CONFIG_FILE; /*try accessing a local file first if exists*/ - if (access(CONFIG_FILE,F_OK)==0){ + if (bctbx_file_exist(CONFIG_FILE)==0){ snprintf(db_file,path_max,"%s",filename); }else{ #ifdef _WIN32 diff --git a/gtk/chat.c b/gtk/chat.c index 2a2287b2c..8cae184ed 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "linphone.h" +#include #ifdef HAVE_GTK_OSX #include @@ -62,7 +63,7 @@ char *linphone_gtk_message_storage_get_db_file(const char *filename){ db_file=(char *)g_malloc(path_max*sizeof(char)); if (filename==NULL) filename=CONFIG_FILE; /*try accessing a local file first if exists*/ - if (access(CONFIG_FILE,F_OK)==0){ + if (bctbx_file_exist(CONFIG_FILE)==0){ snprintf(db_file,path_max,"%s",filename); }else{ #ifdef _WIN32 @@ -196,7 +197,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, pos = end; g_match_info_next(match_info, NULL); } - if(pos < strlen(message)) write_body(buffer, &iter, &message[pos], -1, me, FALSE); + if((size_t)pos < strlen(message)) write_body(buffer, &iter, &message[pos], -1, me, FALSE); gtk_text_buffer_insert(buffer,&iter,"\n",-1); g_match_info_free(match_info); } @@ -441,8 +442,8 @@ static gboolean chatroom_event(GtkWidget *widget, GdkEvent *event, gpointer user GtkTextIter iter; if(event->type == GDK_MOTION_NOTIFY) { GdkEventMotion *motion_ev = (GdkEventMotion *)event; - wx = motion_ev->x; - wy = motion_ev->y; + wx = (gint)motion_ev->x; + wy = (gint)motion_ev->y; gtk_text_view_window_to_buffer_coords(chatroom, GTK_TEXT_WINDOW_TEXT, wx, wy, &bx, &by); gtk_text_view_get_iter_at_location(chatroom, &iter, bx, by); if(gtk_text_iter_has_tag(&iter, link_tag)) { diff --git a/gtk/friendlist.c b/gtk/friendlist.c index d722f8389..ec134f88f 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "linphone.h" +#include static GtkWidget *linphone_gtk_create_contact_menu(GtkWidget *contact_list); @@ -919,7 +920,7 @@ gboolean linphone_gtk_contact_list_button_pressed(GtkTreeView *friendlist, GdkEv GtkTreeViewColumn *column; GtkTreeSelection *selection = gtk_tree_view_get_selection(friendlist); - gtk_tree_view_convert_widget_to_bin_window_coords(friendlist, event->x, event->y, &x_bin, &y_bin); + gtk_tree_view_convert_widget_to_bin_window_coords(friendlist, (gint)event->x, (gint)event->y, &x_bin, &y_bin); gtk_tree_view_get_path_at_pos(friendlist, x_bin, y_bin, &path, &column, NULL, NULL); if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { @@ -964,7 +965,7 @@ static gboolean update_hovered_row_path(GtkTreeView *friendlist, int x_window, i } gboolean linphone_gtk_friend_list_enter_event_handler(GtkTreeView *friendlist, GdkEventCrossing *event) { - gboolean path_has_changed = update_hovered_row_path(friendlist, event->x, event->y); + gboolean path_has_changed = update_hovered_row_path(friendlist, (int)event->x, (int)event->y); if(path_has_changed) linphone_gtk_friend_list_update_button_display(friendlist); return FALSE; } @@ -979,7 +980,7 @@ gboolean linphone_gtk_friend_list_leave_event_handler(GtkTreeView *friendlist, G } gboolean linphone_gtk_friend_list_motion_event_handler(GtkTreeView *friendlist, GdkEventMotion *event) { - gboolean path_has_changed = update_hovered_row_path(friendlist, event->x, event->y); + gboolean path_has_changed = update_hovered_row_path(friendlist, (int)event->x, (int)event->y); if(path_has_changed) linphone_gtk_friend_list_update_button_display(friendlist); return FALSE; } @@ -993,7 +994,7 @@ char *linphone_gtk_friends_storage_get_db_file(const char *filename){ db_file=(char *)g_malloc(path_max*sizeof(char)); if (filename==NULL) filename=CONFIG_FILE; /*try accessing a local file first if exists*/ - if (access(CONFIG_FILE,F_OK)==0){ + if (bctbx_file_exist(CONFIG_FILE)==0){ snprintf(db_file,path_max,"%s",filename); }else{ #ifdef _WIN32 diff --git a/gtk/incall_view.c b/gtk/incall_view.c index ba90f7560..b495308d1 100644 --- a/gtk/incall_view.c +++ b/gtk/incall_view.c @@ -359,9 +359,9 @@ static void volume_control_value_changed(GtkScaleButton *button, gdouble value, VolumeControlType type = (VolumeControlType)GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "type")); if(type == VOLUME_CTRL_PLAYBACK) { - linphone_call_set_speaker_volume_gain(call, value); + linphone_call_set_speaker_volume_gain(call, (float)value); } else if(type == VOLUME_CTRL_RECORD) { - linphone_call_set_microphone_volume_gain(call, value); + linphone_call_set_microphone_volume_gain(call, (float)value); } } @@ -641,7 +641,7 @@ static gboolean linphone_gtk_in_call_view_refresh(LinphoneCall *call){ } #define UNSIGNIFICANT_VOLUME (-23) -#define SMOOTH 0.15 +#define SMOOTH 0.15f static gboolean update_audio_meter(volume_ctx_t *ctx){ float volume_db=ctx->get_volume(ctx->data); diff --git a/gtk/linphone.h b/gtk/linphone.h index 8be2e47f3..9692af836 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -24,7 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifndef _MSC_VER #pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif #include diff --git a/gtk/logging.c b/gtk/logging.c index e97ca75f8..c702e437d 100644 --- a/gtk/logging.c +++ b/gtk/logging.c @@ -19,11 +19,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphone.h" -#ifndef _WIN32 +#ifdef _WIN32 +#include +#define mkdir _mkdir +#else #include #include #endif + +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif extern gchar *linphone_logfile; diff --git a/gtk/main.c b/gtk/main.c index 1eba60ed3..4cb67d727 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphone.h" #include "lpconfig.h" #include "liblinphone_gitversion.h" - +#include #include #include @@ -36,8 +36,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #ifdef _WIN32 -#define chdir _chdir #include "direct.h" +#define chdir _chdir #ifndef F_OK #define F_OK 00 /*visual studio does not define F_OK*/ #endif @@ -186,7 +186,7 @@ static char _factory_config_file[1024]; static const char *linphone_gtk_get_factory_config_file(void){ char* path = NULL; /*try accessing a local file first if exists*/ - if (access(FACTORY_CONFIG_FILE,F_OK)==0){ + if (bctbx_file_exist(FACTORY_CONFIG_FILE)==0){ path = ms_strdup(FACTORY_CONFIG_FILE); } else { char *progdir; @@ -216,7 +216,7 @@ static const char *linphone_gtk_get_factory_config_file(void){ } if (path) { //use factory file only if it exists - if (access(path,F_OK)==0){ + if (bctbx_file_exist(path)==0){ snprintf(_factory_config_file, sizeof(_factory_config_file), "%s", path); ms_free(path); return _factory_config_file; @@ -332,9 +332,9 @@ static void linphone_gtk_configure_window(GtkWidget *w, const char *window_name) static int get_ui_file(const char *name, char *path, int pathsize){ snprintf(path,pathsize,"%s/%s.ui",BUILD_TREE_XML_DIR,name); - if (access(path,F_OK)!=0){ + if (bctbx_file_exist(path)!=0){ snprintf(path,pathsize,"%s/%s.ui",INSTALLED_XML_DIR,name); - if (access(path,F_OK)!=0){ + if (bctbx_file_exist(path)!=0){ g_error("Could not locate neither %s/%s.ui nor %s/%s.ui",BUILD_TREE_XML_DIR,name, INSTALLED_XML_DIR,name); return -1; diff --git a/gtk/propertybox.c b/gtk/propertybox.c index e3271cf2a..9ae0864bd 100644 --- a/gtk/propertybox.c +++ b/gtk/propertybox.c @@ -228,10 +228,10 @@ void linphone_gtk_ldap_save(GtkWidget *button) linphone_dictionary_set_int(dict, "deref_aliases", gtk_toggle_button_get_active(toggle)); spin = GTK_SPIN_BUTTON(linphone_gtk_get_widget(ldap_widget,"ldap_max_results")); - linphone_dictionary_set_int(dict, "max_results", gtk_spin_button_get_value(spin) ); + linphone_dictionary_set_int(dict, "max_results", (int)gtk_spin_button_get_value(spin) ); spin = GTK_SPIN_BUTTON(linphone_gtk_get_widget(ldap_widget,"ldap_timeout")); - linphone_dictionary_set_int(dict, "timeout", gtk_spin_button_get_value(spin) ); + linphone_dictionary_set_int(dict, "timeout", (int)gtk_spin_button_get_value(spin) ); ms_message("Create LDAP from config"); // create new LDAP according to the validated config @@ -324,8 +324,8 @@ void linphone_gtk_min_audio_port_changed(GtkWidget *w){ linphone_core_set_audio_port(linphone_gtk_get_core(), (gint) gtk_spin_button_get_value(min_button)); gtk_spin_button_set_value(max_button, gtk_spin_button_get_value(min_button)); } else { - gint min_port = gtk_spin_button_get_value(min_button); - gint max_port = gtk_spin_button_get_value(max_button); + gint min_port = (gint)gtk_spin_button_get_value(min_button); + gint max_port = (gint)gtk_spin_button_get_value(max_button); if (min_port > max_port) { gtk_spin_button_set_value(max_button, min_port); max_port = min_port; @@ -339,8 +339,8 @@ void linphone_gtk_max_audio_port_changed(GtkWidget *w){ GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); GtkSpinButton *min_button = GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_min_rtp_port")); GtkSpinButton *max_button = GTK_SPIN_BUTTON(w); - gint min_port = gtk_spin_button_get_value(min_button); - gint max_port = gtk_spin_button_get_value(max_button); + gint min_port = (gint)gtk_spin_button_get_value(min_button); + gint max_port = (gint)gtk_spin_button_get_value(max_button); if (max_port < min_port) { gtk_spin_button_set_value(min_button, max_port); min_port = max_port; @@ -359,8 +359,8 @@ void linphone_gtk_min_video_port_changed(GtkWidget *w){ linphone_core_set_video_port(linphone_gtk_get_core(), (gint) gtk_spin_button_get_value(min_button)); gtk_spin_button_set_value(max_button, gtk_spin_button_get_value(min_button)); } else { - gint min_port = gtk_spin_button_get_value(min_button); - gint max_port = gtk_spin_button_get_value(max_button); + gint min_port = (gint)gtk_spin_button_get_value(min_button); + gint max_port = (gint)gtk_spin_button_get_value(max_button); if (min_port > max_port) { gtk_spin_button_set_value(max_button, min_port); max_port = min_port; @@ -374,8 +374,8 @@ void linphone_gtk_max_video_port_changed(GtkWidget *w){ GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); GtkSpinButton *min_button = GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_min_rtp_port")); GtkSpinButton *max_button = GTK_SPIN_BUTTON(w); - gint min_port = gtk_spin_button_get_value(min_button); - gint max_port = gtk_spin_button_get_value(max_button); + gint min_port = (gint)gtk_spin_button_get_value(min_button); + gint max_port = (gint)gtk_spin_button_get_value(max_button); if (max_port < min_port) { gtk_spin_button_set_value(min_button, max_port); min_port = max_port; @@ -420,7 +420,7 @@ void linphone_gtk_use_upnp_toggled(GtkWidget *w){ void linphone_gtk_mtu_changed(GtkWidget *w){ if (GTK_WIDGET_SENSITIVE(w)) - linphone_core_set_mtu(linphone_gtk_get_core(),gtk_spin_button_get_value(GTK_SPIN_BUTTON(w))); + linphone_core_set_mtu(linphone_gtk_get_core(),(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(w))); } void linphone_gtk_use_sip_info_dtmf_toggled(GtkWidget *w){ @@ -673,7 +673,7 @@ static void linphone_gtk_show_codecs(GtkTreeView *listview, const MSList *codecl } /* get an iterator */ gtk_list_store_append(store,&iter); - bitrate=linphone_core_get_payload_type_bitrate(linphone_gtk_get_core(),pt); + bitrate=(gfloat)linphone_core_get_payload_type_bitrate(linphone_gtk_get_core(),pt); rate=payload_type_get_rate(pt); if (pt->recv_fmtp!=NULL) params=pt->recv_fmtp; gtk_list_store_set(store,&iter, CODEC_NAME,payload_type_get_mime(pt), @@ -709,7 +709,7 @@ static void linphone_gtk_check_codec_bandwidth(GtkTreeView *v){ gfloat bitrate; gtk_tree_model_get(model,&iter,CODEC_PRIVDATA,&pt,-1); - bitrate=linphone_core_get_payload_type_bitrate(linphone_gtk_get_core(),pt); + bitrate=(gfloat)linphone_core_get_payload_type_bitrate(linphone_gtk_get_core(),pt); gtk_list_store_set(GTK_LIST_STORE(model),&iter,CODEC_COLOR, (gpointer)get_codec_color(linphone_gtk_get_core(),pt), CODEC_BITRATE, bitrate,-1); }while(gtk_tree_model_iter_next(model,&iter)); @@ -759,7 +759,7 @@ void linphone_gtk_upload_bw_changed(GtkWidget *w){ void linphone_gtk_video_framerate_changed(GtkWidget *w) { linphone_core_set_preferred_framerate(linphone_gtk_get_core(), - (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(w))); + (float)(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(w))); } void linphone_gtk_adaptive_rate_control_toggled(GtkToggleButton *button){ @@ -1748,8 +1748,8 @@ void linphone_gtk_fixed_audio_port_toggle(void) { GtkWidget *mw = linphone_gtk_get_main_window(); GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); gboolean fixed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb, "fixed_audio_port"))); - gint min_port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_min_rtp_port"))); - gint max_port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_max_rtp_port"))); + gint min_port = (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_min_rtp_port"))); + gint max_port = (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "audio_max_rtp_port"))); gtk_widget_set_sensitive(GTK_WIDGET(linphone_gtk_get_widget(pb, "audio_max_rtp_port")), !fixed); if (fixed) { linphone_core_set_audio_port(linphone_gtk_get_core(), min_port); @@ -1763,8 +1763,8 @@ void linphone_gtk_fixed_video_port_toggle(void) { GtkWidget *mw = linphone_gtk_get_main_window(); GtkWidget *pb = (GtkWidget *) g_object_get_data(G_OBJECT(mw), "parameters"); gboolean fixed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(pb, "fixed_video_port"))); - gint min_port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_min_rtp_port"))); - gint max_port = gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_max_rtp_port"))); + gint min_port = (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_min_rtp_port"))); + gint max_port = (gint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(linphone_gtk_get_widget(pb, "video_max_rtp_port"))); gtk_widget_set_sensitive(GTK_WIDGET(linphone_gtk_get_widget(pb, "video_max_rtp_port")), !fixed); if (fixed) { linphone_core_set_video_port(linphone_gtk_get_core(), min_port); @@ -1916,7 +1916,7 @@ gboolean linphone_gtk_auto_answer_enabled(void) { } void linphone_gtk_auto_answer_delay_changed(GtkSpinButton *spinbutton, gpointer user_data) { - int delay = gtk_spin_button_get_value(spinbutton); + int delay = (int)gtk_spin_button_get_value(spinbutton); linphone_gtk_set_ui_config_int("auto_answer_delay", delay); } diff --git a/gtk/status_icon.h b/gtk/status_icon.h index 2e4455659..edaa8794a 100644 --- a/gtk/status_icon.h +++ b/gtk/status_icon.h @@ -25,7 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifndef _MSC_VER #pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif #include #include diff --git a/mediastreamer2 b/mediastreamer2 index 2b7e5dfa5..1df9f8504 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 2b7e5dfa522338d2280b0332fb34a955ee6684cc +Subproject commit 1df9f8504b6681979542702fed26874b66dddf53 diff --git a/oRTP b/oRTP index 95c23d211..084abf711 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 95c23d2115020786ed790d480d501b2ddffdc22d +Subproject commit 084abf711cd7105314f50440e0d96ccd756822de diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 1483bc703..992ec309d 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -24,6 +24,14 @@ file(GLOB SOURCE_FILES "*_tester.c") list(APPEND SOURCE_FILES accountmanager.c tester.c) apply_compile_flags(SOURCE_FILES "CPP" "C") +if(MSVC) + get_source_file_property(MESSAGE_TESTER_C_COMPILE_FLAGS message_tester.c COMPILE_FLAGS) + set(MESSAGE_TESTER_C_COMPILE_FLAGS "${MESSAGE_TESTER_C_COMPILE_FLAGS} /wd4996") # Disable "was declared deprecated" warnings + set_source_files_properties(message_tester.c PROPERTY COMPILE_FLAGS "${MESSAGE_TESTER_C_COMPILE_FLAGS}") + get_source_file_property(VCARD_TESTER_C_COMPILE_FLAGS vcard_tester.c COMPILE_FLAGS) + set(VCARD_TESTER_C_COMPILE_FLAGS "${VCARD_TESTER_C_COMPILE_FLAGS} /wd4996") # Disable "was declared deprecated" warnings + set_source_files_properties(vcard_tester.c PROPERTY COMPILE_FLAGS "${VCARD_TESTER_C_COMPILE_FLAGS}") +endif() if(NOT IOS OR NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") # Executable must be available on root path, not host one diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 3bc9596c5..7275078a6 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -201,23 +201,23 @@ void liblinphone_tester_check_rtcp(LinphoneCoreManager* caller, LinphoneCoreMana } } else { if (linphone_core_rtcp_enabled(caller->lc)) { - BC_ASSERT_EQUAL(linphone_call_get_audio_stats(c1)->rtp_stats.sent_rtcp_packets, 0, int, "%i"); - BC_ASSERT_EQUAL(linphone_call_get_audio_stats(c2)->rtp_stats.recv_rtcp_packets, 0, int, "%i"); + BC_ASSERT_EQUAL(linphone_call_get_audio_stats(c1)->rtp_stats.sent_rtcp_packets, 0, unsigned long long, "%llu"); + BC_ASSERT_EQUAL(linphone_call_get_audio_stats(c2)->rtp_stats.recv_rtcp_packets, 0, unsigned long long, "%llu"); if (linphone_call_log_video_enabled(linphone_call_get_call_log(c1))) { - BC_ASSERT_EQUAL(linphone_call_get_video_stats(c1)->rtp_stats.sent_rtcp_packets, 0, int, "%i"); + BC_ASSERT_EQUAL(linphone_call_get_video_stats(c1)->rtp_stats.sent_rtcp_packets, 0, unsigned long long, "%llu"); } if (linphone_call_log_video_enabled(linphone_call_get_call_log(c2))) { - BC_ASSERT_EQUAL(linphone_call_get_video_stats(c2)->rtp_stats.recv_rtcp_packets, 0, int, "%i"); + BC_ASSERT_EQUAL(linphone_call_get_video_stats(c2)->rtp_stats.recv_rtcp_packets, 0, unsigned long long, "%llu"); } } if (linphone_core_rtcp_enabled(callee->lc)) { - BC_ASSERT_EQUAL(linphone_call_get_audio_stats(c2)->rtp_stats.sent_rtcp_packets, 0, int, "%i"); - BC_ASSERT_EQUAL(linphone_call_get_audio_stats(c1)->rtp_stats.recv_rtcp_packets, 0, int, "%i"); + BC_ASSERT_EQUAL(linphone_call_get_audio_stats(c2)->rtp_stats.sent_rtcp_packets, 0, unsigned long long, "%llu"); + BC_ASSERT_EQUAL(linphone_call_get_audio_stats(c1)->rtp_stats.recv_rtcp_packets, 0, unsigned long long, "%llu"); if (linphone_call_log_video_enabled(linphone_call_get_call_log(c1))) { - BC_ASSERT_EQUAL(linphone_call_get_video_stats(c1)->rtp_stats.recv_rtcp_packets, 0, int, "%i"); + BC_ASSERT_EQUAL(linphone_call_get_video_stats(c1)->rtp_stats.recv_rtcp_packets, 0, unsigned long long, "%llu"); } if (linphone_call_log_video_enabled(linphone_call_get_call_log(c2))) { - BC_ASSERT_EQUAL(linphone_call_get_video_stats(c2)->rtp_stats.sent_rtcp_packets, 0, int, "%i"); + BC_ASSERT_EQUAL(linphone_call_get_video_stats(c2)->rtp_stats.sent_rtcp_packets, 0, unsigned long long, "%llu"); } } @@ -4076,8 +4076,8 @@ static void custom_rtp_modifier(bool_t pauseResumeTest, bool_t recordTest) { rtp_stats_t pauline_rtp_stats = linphone_call_stats_get_rtp_stats(pauline_stats); ms_message("Marie sent %i RTP packets and received %i (for real)", (int)marie_rtp_stats.packet_sent, (int)marie_rtp_stats.packet_recv); ms_message("Pauline sent %i RTP packets and received %i (for real)", (int)pauline_rtp_stats.packet_sent, (int)pauline_rtp_stats.packet_recv); - BC_ASSERT_EQUAL(data_marie->packetReceivedCount, marie_rtp_stats.packet_recv, int, "%i"); - BC_ASSERT_EQUAL(data_marie->packetSentCount, marie_rtp_stats.packet_sent, int, "%i"); + BC_ASSERT_EQUAL(data_marie->packetReceivedCount, marie_rtp_stats.packet_recv, unsigned long long, "%llu"); + BC_ASSERT_EQUAL(data_marie->packetSentCount, marie_rtp_stats.packet_sent, unsigned long long, "%llu"); // There can be a small difference between the number of packets received in the modifier and the number processed in reception because the processing is asynchronous BC_ASSERT_TRUE(data_pauline->packetReceivedCount - pauline_rtp_stats.packet_recv < 20); BC_ASSERT_TRUE(data_pauline->packetSentCount == pauline_rtp_stats.packet_sent); @@ -4345,7 +4345,7 @@ static void call_logs_if_no_db_set(void) { static void call_logs_migrate(void) { LinphoneCoreManager* laure = linphone_core_manager_new("laure_call_logs_rc"); char *logs_db = bc_tester_file("call_logs.db"); - int i = 0; + size_t i = 0; int incoming_count = 0, outgoing_count = 0, missed_count = 0, aborted_count = 0, decline_count = 0, video_enabled_count = 0; unlink(logs_db); @@ -4441,7 +4441,7 @@ static void call_logs_sqlite_storage(void) { const char *ref_key = linphone_call_log_get_ref_key(call_log); call_log = logs->data; BC_ASSERT_EQUAL(linphone_call_log_get_dir(call_log), LinphoneCallOutgoing, int, "%d"); - BC_ASSERT_LOWER(linphone_call_log_get_duration(call_log), 2, float, "%.1f"); + BC_ASSERT_LOWER(linphone_call_log_get_duration(call_log), 2, int, "%d"); BC_ASSERT_TRUE(linphone_address_equal( linphone_call_log_get_from_address(call_log), linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(marie->lc)))); @@ -4449,7 +4449,7 @@ static void call_logs_sqlite_storage(void) { linphone_call_log_get_to_address(call_log), linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc)))); BC_ASSERT_PTR_NOT_NULL(linphone_call_log_get_local_stats(call_log)); - BC_ASSERT_GREATER(linphone_call_log_get_quality(call_log), -1, int, "%d"); + BC_ASSERT_GREATER(linphone_call_log_get_quality(call_log), -1, float, "%.1f"); BC_ASSERT_PTR_NOT_NULL(ref_key); if (ref_key) { BC_ASSERT_STRING_EQUAL(ref_key, "ref_key"); @@ -4469,7 +4469,7 @@ static void call_logs_sqlite_storage(void) { linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc)))); BC_ASSERT_PTR_NOT_NULL(linphone_call_log_get_remote_stats(call_log)); - BC_ASSERT_EQUAL(linphone_call_log_get_start_date(call_log), start_time, int, "%d"); + BC_ASSERT_EQUAL(linphone_call_log_get_start_date(call_log), start_time, unsigned long long, "%llu"); BC_ASSERT_EQUAL(linphone_call_log_get_status(call_log), LinphoneCallSuccess, int, "%d"); } diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index e16c78301..d487a4fd5 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -24,7 +24,11 @@ #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif #ifdef HAVE_GTK #include diff --git a/tester/message_tester.c b/tester/message_tester.c index 84ba9750c..27ed406d3 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -30,8 +30,12 @@ #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wstrict-prototypes" #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif static char* message_external_body_url=NULL; @@ -911,8 +915,8 @@ static void lime_transfer_message_without_encryption(void) { lime_transfer_message_base(FALSE); } -static void printHex(char *title, uint8_t *data, uint32_t length) { - int i; +static void printHex(char *title, uint8_t *data, size_t length) { + size_t i; char debug_string_buffer[2048]; char *debug_string = debug_string_buffer; sprintf (debug_string, "%s : ", title); @@ -1430,7 +1434,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); if (pauline_chat_room) { const char* message = "Be l3l"; - int i; + size_t i; LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call); @@ -1523,7 +1527,7 @@ static void real_time_text_conversation(void) { const char* message1_2 = "Ipsum"; const char* message2_1 = "Be lle Com"; const char* message2_2 = "eB ell moC"; - int i; + size_t i; LinphoneChatMessage* pauline_rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatMessage* marie_rtt_message = linphone_chat_room_create_message(marie_chat_room,NULL); @@ -1632,7 +1636,7 @@ static void real_time_text_message_compat(bool_t end_with_crlf, bool_t end_with_ BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); if (pauline_chat_room) { const char* message = "Be l3l"; - int i; + size_t i; LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call); uint32_t crlf = 0x0D0A; @@ -1746,7 +1750,7 @@ static void real_time_text_copy_paste(void) { BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); if (pauline_chat_room) { const char* message = "Be l3l"; - int i; + size_t i; LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call); diff --git a/tester/presence_tester.c b/tester/presence_tester.c index b14914800..6aca492ab 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -49,7 +49,7 @@ void new_subscription_requested(LinphoneCore *lc, LinphoneFriend *lf, const char void notify_presence_received(LinphoneCore *lc, LinphoneFriend * lf) { stats* counters; - int i; + unsigned int i; char* from=linphone_address_as_string(linphone_friend_get_address(lf)); ms_message("New Notify request from [%s] ",from); ms_free(from); diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index ec321b2dd..62f126f6f 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -400,7 +400,7 @@ static void quality_reporting_interval_report_video_and_rtt(void) { BC_ASSERT_PTR_NOT_NULL(pauline_chat_room); if (pauline_chat_room) { const char* message = "Lorem Ipsum Belledonnum Communicatum"; - int i; + size_t i; LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL); LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(call_marie); diff --git a/tester/tester.c b/tester/tester.c index cb00b9abe..c8a896ea6 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -25,7 +25,9 @@ #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifndef _MSC_VER #pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif #ifdef HAVE_GTK #include @@ -263,7 +265,11 @@ bool_t transport_supported(LinphoneTransportType transport) { #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file) { char *rc_path = NULL; char *hellopath = bc_tester_res("sounds/hello8000.wav"); diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index bbe135e77..e98730f6d 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -287,8 +287,8 @@ static void friends_sqlite_storage(void) { linphone_friend_list_set_display_name(lfl, "Test"); BC_ASSERT_EQUAL(linphone_friend_list_add_friend(lfl, lf), LinphoneFriendListOK, int, "%i"); linphone_friend_unref(lf); - BC_ASSERT_EQUAL(lfl->storage_id, 1, int, "%d"); - BC_ASSERT_EQUAL(lf->storage_id, 1, int, "%d"); + BC_ASSERT_EQUAL(lfl->storage_id, 1, unsigned int, "%u"); + BC_ASSERT_EQUAL(lf->storage_id, 1, unsigned int, "%u"); friends = linphone_friend_list_get_friends(linphone_core_get_default_friend_list(lc)); BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d"); @@ -309,7 +309,7 @@ static void friends_sqlite_storage(void) { } lf2 = (LinphoneFriend *)friends_from_db->data; BC_ASSERT_STRING_EQUAL(linphone_friend_get_name(lf2), linphone_friend_get_name(lf)); - BC_ASSERT_EQUAL(lf2->storage_id, lf->storage_id, int, "%i"); + BC_ASSERT_EQUAL(lf2->storage_id, lf->storage_id, unsigned int, "%u"); BC_ASSERT_STRING_EQUAL(linphone_vcard_get_etag(linphone_friend_get_vcard(lf2)), linphone_vcard_get_etag(linphone_friend_get_vcard(lf))); BC_ASSERT_STRING_EQUAL(linphone_vcard_get_url(linphone_friend_get_vcard(lf2)), linphone_vcard_get_url(linphone_friend_get_vcard(lf))); BC_ASSERT_STRING_EQUAL(linphone_address_as_string(linphone_friend_get_address(lf2)), linphone_address_as_string(linphone_friend_get_address(lf))); @@ -611,7 +611,7 @@ static void carddav_integration(void) { BC_ASSERT_EQUAL(ms_list_size(lfl->friends), 1, int, "%i"); lf = (LinphoneFriend *)lfl->friends->data; BC_ASSERT_STRING_EQUAL(lf->refkey, refkey); - BC_ASSERT_EQUAL(lf->storage_id, lf2->storage_id, int, "%i"); + BC_ASSERT_EQUAL(lf->storage_id, lf2->storage_id, unsigned int, "%u"); linphone_friend_unref(lf2); BC_ASSERT_STRING_EQUAL(linphone_address_as_string_uri_only(lf->uri), "sip:sylvain@sip.linphone.org"); diff --git a/tester/video_tester.c b/tester/video_tester.c index d1be16593..2b4df2a28 100644 --- a/tester/video_tester.c +++ b/tester/video_tester.c @@ -27,7 +27,9 @@ #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic push #endif +#ifndef _MSC_VER #pragma GCC diagnostic ignored "-Wstrict-prototypes" +#endif #if HAVE_GTK #include From b5b0abfdf35571c7868ee386324bf0f46e28b3af Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Thu, 16 Jun 2016 14:01:18 +0200 Subject: [PATCH 088/124] Fixing size_t error on Mac OS. --- coreapi/friend.c | 4 ++-- gtk/buddylookup.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coreapi/friend.c b/coreapi/friend.c index 32e840579..6012645d2 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -1438,7 +1438,7 @@ MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList begin = ortp_get_cur_time_ms(); linphone_sql_request_friend(lc->friends_db, buf, &result); end = ortp_get_cur_time_ms(); - ms_message("%s(): %i results fetched, completed in %i ms",__FUNCTION__, ms_list_size(result), (int)(end-begin)); + ms_message("%s(): %u results fetched, completed in %i ms",__FUNCTION__, (unsigned int)ms_list_size(result), (int)(end-begin)); sqlite3_free(buf); for(elem = result; elem != NULL; elem = elem->next) { @@ -1466,7 +1466,7 @@ MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc) { begin = ortp_get_cur_time_ms(); linphone_sql_request_friends_list(lc->friends_db, buf, &result); end = ortp_get_cur_time_ms(); - ms_message("%s(): %i results fetched, completed in %i ms",__FUNCTION__, ms_list_size(result), (int)(end-begin)); + ms_message("%s(): %u results fetched, completed in %i ms",__FUNCTION__, (unsigned int)ms_list_size(result), (int)(end-begin)); sqlite3_free(buf); for(elem = result; elem != NULL; elem = elem->next) { diff --git a/gtk/buddylookup.c b/gtk/buddylookup.c index ef3044a1d..33f3f2594 100644 --- a/gtk/buddylookup.c +++ b/gtk/buddylookup.c @@ -178,8 +178,8 @@ static gboolean linphone_gtk_process_buddy_lookup(GtkWidget *w){ results); gtk_progress_bar_set_fraction(pb,1); tmp=g_strdup_printf(ngettext("Found %i contact", - "Found %i contacts", ms_list_size(results)), - ms_list_size(results)); + "Found %u contacts", ms_list_size(results)), + (unsigned int)ms_list_size(results)); gtk_progress_bar_set_text(pb,tmp); g_free(tmp); sip_setup_context_buddy_lookup_free(ctx,req); From 8812a5818c64e57aca36c69105d4d5486cb84bd2 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Thu, 16 Jun 2016 14:23:48 +0200 Subject: [PATCH 089/124] mediastreamer2 update --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 1df9f8504..2e517ea18 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 1df9f8504b6681979542702fed26874b66dddf53 +Subproject commit 2e517ea188181b008700e6f164666a37ac0d986a From 13a451c5d50f40934ef50970945da6763dc97c10 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Thu, 16 Jun 2016 14:48:23 +0200 Subject: [PATCH 090/124] Update media streamer --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 2e517ea18..e73957fb9 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 2e517ea188181b008700e6f164666a37ac0d986a +Subproject commit e73957fb97179ecc660384dd304708d5db24f4b8 From 2f5e6f894be929f2f2a9a92afcc2467aca3d8dec Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Thu, 16 Jun 2016 14:58:27 +0200 Subject: [PATCH 091/124] Fixing size_t printing error format. --- tools/auto_answer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/auto_answer.c b/tools/auto_answer.c index c150f24e9..8c1a890f5 100644 --- a/tools/auto_answer.c +++ b/tools/auto_answer.c @@ -189,8 +189,8 @@ int main(int argc, char *argv[]){ ms_usleep(50000); if (print_stats) { ms_message("*********************************"); - ms_message("*Current number of calls [%10i] *",ms_list_size(linphone_core_get_calls(lc))); - ms_message("*Number of calls until now [%10i] *",ms_list_size(linphone_core_get_call_logs(lc))); + ms_message("*Current number of calls [%10u] *",(unsigned int)ms_list_size(linphone_core_get_calls(lc))); + ms_message("*Number of calls until now [%10u] *",(unsigned int)ms_list_size(linphone_core_get_call_logs(lc))); ms_message("*********************************"); print_stats=FALSE; } From a82a1acaa2a9aa44eefe48e53cb69067593741d9 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Thu, 16 Jun 2016 15:27:36 +0200 Subject: [PATCH 092/124] size_t warning. --- coreapi/linphonecore.c | 2 +- tester/vcard_tester.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 40ade3d72..d30f5f49f 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -5435,7 +5435,7 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { migrated_logs_count = ms_list_size(lc->call_logs); if (original_logs_count == migrated_logs_count) { int i = 0; - ms_debug("call logs migration successful: %i logs migrated", ms_list_size(lc->call_logs)); + ms_debug("call logs migration successful: %u logs migrated", (unsigned int)ms_list_size(lc->call_logs)); lp_config_set_int(lpc, "misc", "call_logs_migration_done", 1); for (; i < original_logs_count; i++) { diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index e98730f6d..9bb23efa8 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -75,7 +75,7 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) { BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI elapsed = (double)(end - start); - ms_error("Imported a thousand of vCards from file (only %i friends with SIP address found) in %f seconds", ms_list_size(friends), elapsed / CLOCKS_PER_SEC); + ms_error("Imported a thousand of vCards from file (only %u friends with SIP address found) in %f seconds", (unsigned int)ms_list_size(friends), elapsed / CLOCKS_PER_SEC); lfl = linphone_core_create_friend_list(manager->lc); infile = fopen(import_filepath, "rb"); @@ -98,7 +98,7 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) { BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI elapsed = (double)(end - start); - ms_error("Imported a thousand of vCards from buffer (only %i friends with SIP address found) in %f seconds", ms_list_size(friends), elapsed / CLOCKS_PER_SEC); + ms_error("Imported a thousand of vCards from buffer (only %u friends with SIP address found) in %f seconds", (unsigned int)ms_list_size(friends), elapsed / CLOCKS_PER_SEC); linphone_friend_list_unref(lfl); From 9f01da42b9f1bb3b0d095de023a32ee25fefd953 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Thu, 16 Jun 2016 16:02:44 +0200 Subject: [PATCH 093/124] fix warning on centOs --- daemon/daemon.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 47f820ab0..3ac3efa30 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -385,7 +385,7 @@ LinphoneProxyConfig *Daemon::findProxy(int id) { LinphoneAuthInfo *Daemon::findAuthInfo(int id) { const MSList *elem = linphone_core_get_auth_info_list(mLc); - if (elem == NULL || id < 1 || id > ms_list_size(elem)) { + if (elem == NULL || id < 1 || (unsigned int)id > ms_list_size(elem)) { return NULL; } while (id > 1) { From b535d1f15309531724834099595153722f9328f9 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 16 Jun 2016 17:42:33 +0200 Subject: [PATCH 094/124] Use bctbx_list_t instead of MSList that has been deprecated. --- coreapi/authentication.c | 32 +-- coreapi/bellesip_sal/sal_impl.c | 32 +-- coreapi/bellesip_sal/sal_sdp.c | 12 +- coreapi/call_log.c | 38 +-- coreapi/callbacks.c | 20 +- coreapi/carddav.c | 70 +++--- coreapi/chat.c | 34 +-- coreapi/conference.cc | 10 +- coreapi/friend.c | 126 +++++----- coreapi/friendlist.c | 76 +++--- coreapi/ldap/ldapprovider.c | 24 +- coreapi/linphone_tunnel.cc | 18 +- coreapi/linphonecall.c | 82 +++---- coreapi/linphonecore.c | 288 +++++++++++------------ coreapi/linphonecore.h | 48 ++-- coreapi/lpconfig.c | 70 +++--- coreapi/message_storage.c | 14 +- coreapi/misc.c | 32 +-- coreapi/nat_policy.c | 16 +- coreapi/offeranswer.c | 34 +-- coreapi/plugins/buddylookup/src/lookup.c | 6 +- coreapi/presence.c | 198 ++++++++-------- coreapi/proxy.c | 28 +-- coreapi/sal.c | 22 +- coreapi/sipsetup.c | 16 +- coreapi/upnp.c | 98 ++++---- coreapi/vcard.cc | 24 +- coreapi/vtables.c | 14 +- gtk/buddylookup.c | 5 +- mediastreamer2 | 2 +- tools/auto_answer.c | 4 +- 31 files changed, 746 insertions(+), 747 deletions(-) diff --git a/coreapi/authentication.c b/coreapi/authentication.c index 5382347ad..b1bfc09cc 100644 --- a/coreapi/authentication.c +++ b/coreapi/authentication.c @@ -231,7 +231,7 @@ static bool_t realm_match(const char *realm1, const char *realm2){ } static const LinphoneAuthInfo *find_auth_info(LinphoneCore *lc, const char *username, const char *realm, const char *domain, bool_t ignore_realm){ - MSList *elem; + bctbx_list_t *elem; const LinphoneAuthInfo *ret=NULL; for (elem=lc->auth_info;elem!=NULL;elem=elem->next) { @@ -286,7 +286,7 @@ const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const cha /*the auth info is expected to be in the core's list*/ void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai){ int i; - MSList *elem = lc->auth_info; + bctbx_list_t *elem = lc->auth_info; if (!lc->sip_conf.save_auth_info) return; @@ -298,12 +298,12 @@ void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai){ } static void write_auth_infos(LinphoneCore *lc){ - MSList *elem; + bctbx_list_t *elem; int i; if (!linphone_core_ready(lc)) return; if (!lc->sip_conf.save_auth_info) return; - for(elem=lc->auth_info,i=0;elem!=NULL;elem=ms_list_next(elem),i++){ + for(elem=lc->auth_info,i=0;elem!=NULL;elem=bctbx_list_next(elem),i++){ LinphoneAuthInfo *ai=(LinphoneAuthInfo*)(elem->data); linphone_auth_info_write_config(lc->config,ai,i); } @@ -321,8 +321,8 @@ LinphoneAuthInfo * linphone_core_create_auth_info(LinphoneCore *lc, const char * **/ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info){ LinphoneAuthInfo *ai; - MSList *elem; - MSList *l; + bctbx_list_t *elem; + bctbx_list_t *l; int restarted_op_count=0; bool_t updating=FALSE; @@ -333,11 +333,11 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info) /* find if we are attempting to modify an existing auth info */ ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username,info->domain); if (ai!=NULL && ai->domain && info->domain && strcmp(ai->domain, info->domain)==0){ - lc->auth_info=ms_list_remove(lc->auth_info,ai); + lc->auth_info=bctbx_list_remove(lc->auth_info,ai); linphone_auth_info_destroy(ai); updating=TRUE; } - lc->auth_info=ms_list_append(lc->auth_info,linphone_auth_info_clone(info)); + lc->auth_info=bctbx_list_append(lc->auth_info,linphone_auth_info_clone(info)); /* retry pending authentication operations */ for(l=elem=sal_get_pending_auths(lc->sal);elem!=NULL;elem=elem->next){ @@ -347,14 +347,14 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info) ai=(LinphoneAuthInfo*)_linphone_core_find_auth_info(lc,req_sai->realm,req_sai->username,req_sai->domain, FALSE); if (ai){ SalAuthInfo sai; - MSList* proxy; + bctbx_list_t* proxy; sai.username=ai->username; sai.userid=ai->userid; sai.realm=ai->realm; sai.password=ai->passwd; sai.ha1=ai->ha1; /*proxy case*/ - for (proxy=(MSList*)linphone_core_get_proxy_config_list(lc);proxy!=NULL;proxy=proxy->next) { + for (proxy=(bctbx_list_t*)linphone_core_get_proxy_config_list(lc);proxy!=NULL;proxy=proxy->next) { if (proxy->data == sal_op_get_user_pointer(op)) { linphone_proxy_config_set_state((LinphoneProxyConfig*)(proxy->data),LinphoneRegistrationProgress,"Authentication..."); break; @@ -375,7 +375,7 @@ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info) info->realm ? info->realm : "", info->domain ? info->domain : ""); } - ms_list_free(l); + bctbx_list_free(l); write_auth_infos(lc); } @@ -394,7 +394,7 @@ void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *in LinphoneAuthInfo *r; r=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username,info->domain); if (r){ - lc->auth_info=ms_list_remove(lc->auth_info,r); + lc->auth_info=bctbx_list_remove(lc->auth_info,r); linphone_auth_info_destroy(r); write_auth_infos(lc); } @@ -405,7 +405,7 @@ void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *in * @param[in] lc The LinphoneCore object * @return \mslist{LinphoneAuthInfo} **/ -const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc){ +const bctbx_list_t *linphone_core_get_auth_info_list(const LinphoneCore *lc){ return lc->auth_info; } @@ -413,14 +413,14 @@ const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc){ * Clear all authentication information. **/ void linphone_core_clear_all_auth_info(LinphoneCore *lc){ - MSList *elem; + bctbx_list_t *elem; int i; - for(i=0,elem=lc->auth_info;elem!=NULL;elem=ms_list_next(elem),i++){ + for(i=0,elem=lc->auth_info;elem!=NULL;elem=bctbx_list_next(elem),i++){ LinphoneAuthInfo *info=(LinphoneAuthInfo*)elem->data; linphone_auth_info_destroy(info); linphone_auth_info_write_config(lc->config,NULL,i); } - ms_list_free(lc->auth_info); + bctbx_list_free(lc->auth_info); lc->auth_info=NULL; } diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 2c256d29d..aabee27f7 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -115,8 +115,8 @@ void sal_set_log_level(OrtpLogLevel level) { } void sal_add_pending_auth(Sal *sal, SalOp *op){ - if (ms_list_find(sal->pending_auths,op)==NULL){ - sal->pending_auths=ms_list_append(sal->pending_auths,op); + if (bctbx_list_find(sal->pending_auths,op)==NULL){ + sal->pending_auths=bctbx_list_append(sal->pending_auths,op); op->has_auth_pending=TRUE; } } @@ -124,8 +124,8 @@ void sal_add_pending_auth(Sal *sal, SalOp *op){ void sal_remove_pending_auth(Sal *sal, SalOp *op){ if (op->has_auth_pending){ op->has_auth_pending=FALSE; - if (ms_list_find(sal->pending_auths,op)){ - sal->pending_auths=ms_list_remove(sal->pending_auths,op); + if (bctbx_list_find(sal->pending_auths,op)){ + sal->pending_auths=bctbx_list_remove(sal->pending_auths,op); } } } @@ -593,7 +593,7 @@ void sal_uninit(Sal* sal){ belle_sip_object_unref(sal->stack); belle_sip_object_unref(sal->listener); if (sal->supported) belle_sip_object_unref(sal->supported); - ms_list_free_with_data(sal->supported_tags,ms_free); + bctbx_list_free_with_data(sal->supported_tags,ms_free); if (sal->uuid) ms_free(sal->uuid); if (sal->root_ca) ms_free(sal->root_ca); ms_free(sal); @@ -804,8 +804,8 @@ int sal_iterate(Sal *sal){ belle_sip_stack_sleep(sal->stack,0); return 0; } -MSList * sal_get_pending_auths(Sal *sal){ - return ms_list_copy(sal->pending_auths); +bctbx_list_t * sal_get_pending_auths(Sal *sal){ + return bctbx_list_copy(sal->pending_auths); } /*misc*/ @@ -858,10 +858,10 @@ int sal_get_transport_timeout(const Sal* sal) { return belle_sip_stack_get_transport_timeout(sal->stack); } -void sal_set_dns_servers(Sal *sal, const MSList *servers){ +void sal_set_dns_servers(Sal *sal, const bctbx_list_t *servers){ belle_sip_list_t *l = NULL; - /*we have to convert the MSList into a belle_sip_list_t first*/ + /*we have to convert the bctbx_list_t into a belle_sip_list_t first*/ for (; servers != NULL; servers = servers->next){ l = belle_sip_list_append(l, servers->data); } @@ -1055,7 +1055,7 @@ int sal_create_uuid(Sal*ctx, char *uuid, size_t len) { } static void make_supported_header(Sal *sal){ - MSList *it; + bctbx_list_t *it; char *alltags=NULL; size_t buflen=64; size_t written=0; @@ -1080,7 +1080,7 @@ static void make_supported_header(Sal *sal){ } void sal_set_supported_tags(Sal *ctx, const char* tags){ - ctx->supported_tags=ms_list_free_with_data(ctx->supported_tags,ms_free); + ctx->supported_tags=bctbx_list_free_with_data(ctx->supported_tags,ms_free); if (tags){ char *iter; char *buffer=ms_strdup(tags); @@ -1089,7 +1089,7 @@ void sal_set_supported_tags(Sal *ctx, const char* tags){ iter=buffer; while((tag=strtok_r(iter,", ",&context))!=NULL){ iter=NULL; - ctx->supported_tags=ms_list_append(ctx->supported_tags,ms_strdup(tag)); + ctx->supported_tags=bctbx_list_append(ctx->supported_tags,ms_strdup(tag)); } ms_free(buffer); } @@ -1104,19 +1104,19 @@ const char *sal_get_supported_tags(Sal *ctx){ } void sal_add_supported_tag(Sal *ctx, const char* tag){ - MSList *elem=ms_list_find_custom(ctx->supported_tags,(MSCompareFunc)strcasecmp,tag); + bctbx_list_t *elem=bctbx_list_find_custom(ctx->supported_tags,(bctbx_compare_func)strcasecmp,tag); if (!elem){ - ctx->supported_tags=ms_list_append(ctx->supported_tags,ms_strdup(tag)); + ctx->supported_tags=bctbx_list_append(ctx->supported_tags,ms_strdup(tag)); make_supported_header(ctx); } } void sal_remove_supported_tag(Sal *ctx, const char* tag){ - MSList *elem=ms_list_find_custom(ctx->supported_tags,(MSCompareFunc)strcasecmp,tag); + bctbx_list_t *elem=bctbx_list_find_custom(ctx->supported_tags,(bctbx_compare_func)strcasecmp,tag); if (elem){ ms_free(elem->data); - ctx->supported_tags=ms_list_remove_link(ctx->supported_tags,elem); + ctx->supported_tags=bctbx_list_remove_link(ctx->supported_tags,elem); make_supported_header(ctx); } } diff --git a/coreapi/bellesip_sal/sal_sdp.c b/coreapi/bellesip_sal/sal_sdp.c index 177c813ab..896c6004b 100644 --- a/coreapi/bellesip_sal/sal_sdp.c +++ b/coreapi/bellesip_sal/sal_sdp.c @@ -70,7 +70,7 @@ static void add_ice_remote_candidates(belle_sdp_media_description_t *md, const S } static bool_t is_rtcp_fb_trr_int_the_same_for_all_payloads(const SalStreamDescription *stream, uint16_t *trr_int) { - MSList *pt_it; + bctbx_list_t *pt_it; bool_t first = TRUE; for (pt_it = stream->payloads; pt_it != NULL; pt_it = pt_it->next) { PayloadType *pt = (PayloadType *)pt_it->data; @@ -119,7 +119,7 @@ static void add_rtcp_fb_ccm_attribute(belle_sdp_media_description_t *media_desc, } static void add_rtcp_fb_attributes(belle_sdp_media_description_t *media_desc, const SalMediaDescription *md, const SalStreamDescription *stream) { - MSList *pt_it; + bctbx_list_t *pt_it; PayloadType *pt; PayloadTypeAvpfParams avpf_params; bool_t general_trr_int; @@ -191,7 +191,7 @@ static void stream_description_to_sdp ( belle_sdp_session_description_t *session belle_sdp_mime_parameter_t* mime_param; belle_sdp_media_description_t* media_desc; int j; - MSList* pt_it; + bctbx_list_t* pt_it; PayloadType* pt; char buffer[1024]; char* dir=NULL; @@ -470,7 +470,7 @@ static void sdp_parse_payload_types(belle_sdp_media_description_t *media_desc, S pt->channels=belle_sdp_mime_parameter_get_channel_count ( mime_param ); payload_type_set_send_fmtp ( pt,belle_sdp_mime_parameter_get_parameters ( mime_param ) ); payload_type_set_avpf_params(pt, avpf_params); - stream->payloads=ms_list_append ( stream->payloads,pt ); + stream->payloads=bctbx_list_append ( stream->payloads,pt ); stream->ptime=belle_sdp_mime_parameter_get_ptime ( mime_param ); ms_message ( "Found payload %s/%i fmtp=%s",pt->mime_type,pt->clock_rate, pt->send_fmtp ? pt->send_fmtp : "" ); @@ -577,7 +577,7 @@ static void sdp_parse_media_ice_parameters(belle_sdp_media_description_t *media_ } static void enable_avpf_for_stream(SalStreamDescription *stream) { - MSList *pt_it; + bctbx_list_t *pt_it; for (pt_it = stream->payloads; pt_it != NULL; pt_it = pt_it->next) { PayloadType *pt = (PayloadType *)pt_it->data; payload_type_set_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); @@ -639,7 +639,7 @@ static bool_t sdp_parse_rtcp_fb_parameters(belle_sdp_media_description_t *media_ belle_sip_list_t *it; belle_sdp_attribute_t *attribute; belle_sdp_rtcp_fb_attribute_t *fb_attribute; - MSList *pt_it; + bctbx_list_t *pt_it; PayloadType *pt; int8_t pt_num; bool_t retval = FALSE; diff --git a/coreapi/call_log.c b/coreapi/call_log.c index 91e7eb5dd..2c9572c40 100644 --- a/coreapi/call_log.c +++ b/coreapi/call_log.c @@ -74,7 +74,7 @@ static void set_call_log_date(LinphoneCallLog *cl, time_t start_time){ ******************************************************************************/ void call_logs_write_to_config_file(LinphoneCore *lc){ - MSList *elem; + bctbx_list_t *elem; char logsection[32]; unsigned int i; char *tmp; @@ -147,7 +147,7 @@ void call_logs_read_from_config_file(LinphoneCore *lc){ cl->video_enabled=lp_config_get_int(cfg,logsection,"video_enabled",0); tmp=lp_config_get_string(cfg,logsection,"call_id",NULL); if (tmp) cl->call_id=ms_strdup(tmp); - lc->call_logs=ms_list_append(lc->call_logs,cl); + lc->call_logs=bctbx_list_append(lc->call_logs,cl); }else break; } } @@ -414,7 +414,7 @@ void linphone_core_call_log_storage_close(LinphoneCore *lc) { * | 11 | refkey */ static int create_call_log(void *data, int argc, char **argv, char **colName) { - MSList **list = (MSList **)data; + bctbx_list_t **list = (bctbx_list_t **)data; LinphoneAddress *from; LinphoneAddress *to; LinphoneCallDir dir; @@ -447,7 +447,7 @@ static int create_call_log(void *data, int argc, char **argv, char **colName) { } } - *list = ms_list_append(*list, log); + *list = bctbx_list_append(*list, log); return 0; error: @@ -461,7 +461,7 @@ error: return 0; } -static void linphone_sql_request_call_log(sqlite3 *db, const char *stmt, MSList **list) { +static void linphone_sql_request_call_log(sqlite3 *db, const char *stmt, bctbx_list_t **list) { char* errmsg = NULL; int ret; ret = sqlite3_exec(db, stmt, create_call_log, list, &errmsg); @@ -511,33 +511,33 @@ void linphone_core_store_call_log(LinphoneCore *lc, LinphoneCallLog *log) { } if (lc) { - lc->call_logs = ms_list_prepend(lc->call_logs, linphone_call_log_ref(log)); + lc->call_logs = bctbx_list_prepend(lc->call_logs, linphone_call_log_ref(log)); } } -static void copy_user_data_from_existing_log(MSList *existing_logs, LinphoneCallLog *log) { +static void copy_user_data_from_existing_log(bctbx_list_t *existing_logs, LinphoneCallLog *log) { while (existing_logs) { LinphoneCallLog *existing_log = (LinphoneCallLog *)existing_logs->data; if (existing_log->storage_id == log->storage_id) { log->user_data = existing_log->user_data; break; } - existing_logs = ms_list_next(existing_logs); + existing_logs = bctbx_list_next(existing_logs); } } -static void copy_user_data_from_existing_logs(MSList *existing_logs, MSList *new_logs) { +static void copy_user_data_from_existing_logs(bctbx_list_t *existing_logs, bctbx_list_t *new_logs) { while (new_logs) { LinphoneCallLog *new_log = (LinphoneCallLog *)new_logs->data; copy_user_data_from_existing_log(existing_logs, new_log); - new_logs = ms_list_next(new_logs); + new_logs = bctbx_list_next(new_logs); } } -const MSList *linphone_core_get_call_history(LinphoneCore *lc) { +const bctbx_list_t *linphone_core_get_call_history(LinphoneCore *lc) { char *buf; uint64_t begin,end; - MSList *result = NULL; + bctbx_list_t *result = NULL; if (!lc || lc->logs_db == NULL) return NULL; @@ -553,7 +553,7 @@ const MSList *linphone_core_get_call_history(LinphoneCore *lc) { copy_user_data_from_existing_logs(lc->call_logs, result); } - lc->call_logs = ms_list_free_with_data(lc->call_logs, (void (*)(void*))linphone_call_log_unref); + lc->call_logs = bctbx_list_free_with_data(lc->call_logs, (void (*)(void*))linphone_call_log_unref); lc->call_logs = result; return lc->call_logs; @@ -600,11 +600,11 @@ int linphone_core_get_call_history_size(LinphoneCore *lc) { return numrows; } -MSList * linphone_core_get_call_history_for_address(LinphoneCore *lc, const LinphoneAddress *addr) { +bctbx_list_t * linphone_core_get_call_history_for_address(LinphoneCore *lc, const LinphoneAddress *addr) { char *buf; char *sipAddress; uint64_t begin,end; - MSList *result = NULL; + bctbx_list_t *result = NULL; if (!lc || lc->logs_db == NULL || addr == NULL) return NULL; @@ -629,7 +629,7 @@ MSList * linphone_core_get_call_history_for_address(LinphoneCore *lc, const Linp LinphoneCallLog * linphone_core_get_last_outgoing_call_log(LinphoneCore *lc) { char *buf; uint64_t begin,end; - MSList *list = NULL; + bctbx_list_t *list = NULL; LinphoneCallLog* result = NULL; if (!lc || lc->logs_db == NULL) return NULL; @@ -657,7 +657,7 @@ LinphoneCallLog * linphone_core_get_last_outgoing_call_log(LinphoneCore *lc) { LinphoneCallLog * linphone_core_find_call_log_from_call_id(LinphoneCore *lc, const char *call_id) { char *buf; uint64_t begin,end; - MSList *list = NULL; + bctbx_list_t *list = NULL; LinphoneCallLog* result = NULL; if (!lc || lc->logs_db == NULL) return NULL; @@ -693,7 +693,7 @@ void linphone_core_call_log_storage_close(LinphoneCore *lc) { void linphone_core_store_call_log(LinphoneCore *lc, LinphoneCallLog *log) { } -const MSList *linphone_core_get_call_history(LinphoneCore *lc) { +const bctbx_list_t *linphone_core_get_call_history(LinphoneCore *lc) { return NULL; } @@ -707,7 +707,7 @@ int linphone_core_get_call_history_size(LinphoneCore *lc) { return 0; } -MSList * linphone_core_get_call_history_for_address(LinphoneCore *lc, const LinphoneAddress *addr) { +bctbx_list_t * linphone_core_get_call_history_for_address(LinphoneCore *lc, const LinphoneAddress *addr) { return NULL; } diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 9cb4572e6..c2d1ae557 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -111,12 +111,12 @@ void linphone_call_update_frozen_payloads(LinphoneCall *call, SalMediaDescriptio SalMediaDescription *local=call->localdesc; int i; for(i=0;inb_streams;++i){ - MSList *elem; + bctbx_list_t *elem; for (elem=result_desc->streams[i].payloads;elem!=NULL;elem=elem->next){ PayloadType *pt=(PayloadType*)elem->data; if (is_payload_type_number_available(local->streams[i].already_assigned_payloads, payload_type_get_number(pt), NULL)){ /*new codec, needs to be added to the list*/ - local->streams[i].already_assigned_payloads=ms_list_append(local->streams[i].already_assigned_payloads, payload_type_clone(pt)); + local->streams[i].already_assigned_payloads=bctbx_list_append(local->streams[i].already_assigned_payloads, payload_type_clone(pt)); ms_message("LinphoneCall[%p] : payload type %i %s/%i fmtp=%s added to frozen list.", call, payload_type_get_number(pt), pt->mime_type, pt->clock_rate, pt->recv_fmtp ? pt->recv_fmtp : ""); } @@ -201,7 +201,7 @@ void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMedia prepare_early_media_forking(call); } linphone_call_start_media_streams(call, target_state); - if (call->state==LinphoneCallPausing && call->paused_by_app && ms_list_size(lc->calls)==1){ + if (call->state==LinphoneCallPausing && call->paused_by_app && bctbx_list_size(lc->calls)==1){ linphone_core_play_named_tone(lc,LinphoneToneCallOnHold); } linphone_call_update_frozen_payloads(call, new_md); @@ -212,7 +212,7 @@ void linphone_core_update_streams(LinphoneCore *lc, LinphoneCall *call, SalMedia } #if 0 static bool_t is_duplicate_call(LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to){ - MSList *elem; + bctbx_list_t *elem; for(elem=lc->calls;elem!=NULL;elem=elem->next){ LinphoneCall *call=(LinphoneCall*)elem->data; if (linphone_address_weak_equal(call->log->from,from) && @@ -225,7 +225,7 @@ static bool_t is_duplicate_call(LinphoneCore *lc, const LinphoneAddress *from, c #endif static bool_t already_a_call_with_remote_address(const LinphoneCore *lc, const LinphoneAddress *remote) { - MSList *elem; + bctbx_list_t *elem; ms_message("Searching for already_a_call_with_remote_address."); for(elem=lc->calls;elem!=NULL;elem=elem->next){ @@ -786,7 +786,7 @@ static void call_terminated(SalOp *op, const char *from){ linphone_core_start_refered_call(lc,call,NULL); } //we stop the call only if we have this current call or if we are in call - if ((ms_list_size(lc->calls) == 1) || linphone_core_in_call(lc)) { + if ((bctbx_list_size(lc->calls) == 1) || linphone_core_in_call(lc)) { linphone_core_stop_ringing(lc); } linphone_call_stop_media_streams(call); @@ -1088,8 +1088,8 @@ static void refer_received(Sal *sal, SalOp *op, const char *referto){ } static bool_t is_duplicate_msg(LinphoneCore *lc, const char *msg_id){ - MSList *elem=lc->last_recv_msg_ids; - MSList *tail=NULL; + bctbx_list_t *elem=lc->last_recv_msg_ids; + bctbx_list_t *tail=NULL; int i; bool_t is_duplicate=FALSE; for(i=0;elem!=NULL;elem=elem->next,i++){ @@ -1099,11 +1099,11 @@ static bool_t is_duplicate_msg(LinphoneCore *lc, const char *msg_id){ tail=elem; } if (!is_duplicate){ - lc->last_recv_msg_ids=ms_list_prepend(lc->last_recv_msg_ids,ms_strdup(msg_id)); + lc->last_recv_msg_ids=bctbx_list_prepend(lc->last_recv_msg_ids,ms_strdup(msg_id)); } if (i>=10){ ms_free(tail->data); - lc->last_recv_msg_ids=ms_list_remove_link(lc->last_recv_msg_ids,tail); + lc->last_recv_msg_ids=bctbx_list_remove_link(lc->last_recv_msg_ids,tail); } return is_duplicate; } diff --git a/coreapi/carddav.c b/coreapi/carddav.c index 60ac8ed69..cac882fc5 100644 --- a/coreapi/carddav.c +++ b/coreapi/carddav.c @@ -105,15 +105,15 @@ static void linphone_carddav_response_free(LinphoneCardDavResponse *response) { ms_free(response); } -static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, MSList *vCards) { - if (vCards != NULL && ms_list_size(vCards) > 0) { - MSList *friends = cdc->friend_list->friends; +static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, bctbx_list_t *vCards) { + if (vCards != NULL && bctbx_list_size(vCards) > 0) { + bctbx_list_t *friends = cdc->friend_list->friends; while (vCards) { LinphoneCardDavResponse *vCard = (LinphoneCardDavResponse *)vCards->data; if (vCard) { LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer(vCard->vcard); LinphoneFriend *lf = NULL; - MSList *local_friend = NULL; + bctbx_list_t *local_friend = NULL; if (lvc) { // Compute downloaded vCards' URL and save it (+ eTag) @@ -126,7 +126,7 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, MSList * lf = linphone_friend_new_from_vcard(lvc); if (lf) { - local_friend = ms_list_find_custom(friends, (int (*)(const void*, const void*))find_matching_friend, lf); + local_friend = bctbx_list_find_custom(friends, (int (*)(const void*, const void*))find_matching_friend, lf); if (local_friend) { LinphoneFriend *lf2 = (LinphoneFriend *)local_friend->data; @@ -156,15 +156,15 @@ static void linphone_carddav_vcards_pulled(LinphoneCardDavContext *cdc, MSList * ms_error("[carddav] Couldn't parse vCard %s", vCard->vcard); } } - vCards = ms_list_next(vCards); + vCards = bctbx_list_next(vCards); } - ms_list_free_with_data(vCards, (void (*)(void *))linphone_carddav_response_free); + bctbx_list_free_with_data(vCards, (void (*)(void *))linphone_carddav_response_free); } linphone_carddav_server_to_client_sync_done(cdc, TRUE, NULL); } -static MSList* parse_vcards_from_xml_response(const char *body) { - MSList *result = NULL; +static bctbx_list_t* parse_vcards_from_xml_response(const char *body) { + bctbx_list_t *result = NULL; xmlparsing_context_t *xml_ctx = linphone_xmlparsing_context_new(); xmlSetGenericErrorFunc(xml_ctx, linphone_xmlparsing_genericxml_error); xml_ctx->doc = xmlReadDoc((const unsigned char*)body, 0, NULL, 0); @@ -188,7 +188,7 @@ static MSList* parse_vcards_from_xml_response(const char *body) { response->etag = ms_strdup(etag); response->url = ms_strdup(url); response->vcard = ms_strdup(vcard); - result = ms_list_append(result, response); + result = bctbx_list_append(result, response); ms_debug("Added vCard object with eTag %s, URL %s and vCard %s", etag, url, vcard); } } @@ -209,19 +209,19 @@ static int find_matching_vcard(LinphoneCardDavResponse *response, LinphoneFriend return strcmp(response->url, linphone_vcard_get_url(lf->vcard)); } -static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, MSList *vCards) { - if (vCards != NULL && ms_list_size(vCards) > 0) { - MSList *friends = cdc->friend_list->friends; - MSList *friends_to_remove = NULL; - MSList *temp_list = NULL; +static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, bctbx_list_t *vCards) { + if (vCards != NULL && bctbx_list_size(vCards) > 0) { + bctbx_list_t *friends = cdc->friend_list->friends; + bctbx_list_t *friends_to_remove = NULL; + bctbx_list_t *temp_list = NULL; while (friends) { LinphoneFriend *lf = (LinphoneFriend *)friends->data; if (lf) { - MSList *vCard = ms_list_find_custom(vCards, (int (*)(const void*, const void*))find_matching_vcard, lf); + bctbx_list_t *vCard = bctbx_list_find_custom(vCards, (int (*)(const void*, const void*))find_matching_vcard, lf); if (!vCard) { ms_debug("Local friend %s isn't in the remote vCard list, delete it", linphone_friend_get_name(lf)); - temp_list = ms_list_append(temp_list, linphone_friend_ref(lf)); + temp_list = bctbx_list_append(temp_list, linphone_friend_ref(lf)); } else { LinphoneCardDavResponse *response = (LinphoneCardDavResponse *)vCard->data; ms_debug("Local friend %s is in the remote vCard list, check eTag", linphone_friend_get_name(lf)); @@ -230,13 +230,13 @@ static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, MSList const char *etag = linphone_vcard_get_etag(lvc); ms_debug("Local friend eTag is %s, remote vCard eTag is %s", etag, response->etag); if (lvc && etag && strcmp(etag, response->etag) == 0) { - ms_list_remove(vCards, vCard); + bctbx_list_remove(vCards, vCard); linphone_carddav_response_free(response); } } } } - friends = ms_list_next(friends); + friends = bctbx_list_next(friends); } friends_to_remove = temp_list; while(friends_to_remove) { @@ -247,17 +247,17 @@ static void linphone_carddav_vcards_fetched(LinphoneCardDavContext *cdc, MSList cdc->contact_removed_cb(cdc, lf); } } - friends_to_remove = ms_list_next(friends_to_remove); + friends_to_remove = bctbx_list_next(friends_to_remove); } - temp_list = ms_list_free_with_data(temp_list, (void (*)(void *))linphone_friend_unref); + temp_list = bctbx_list_free_with_data(temp_list, (void (*)(void *))linphone_friend_unref); linphone_carddav_pull_vcards(cdc, vCards); - ms_list_free_with_data(vCards, (void (*)(void *))linphone_carddav_response_free); + bctbx_list_free_with_data(vCards, (void (*)(void *))linphone_carddav_response_free); } } -static MSList* parse_vcards_etags_from_xml_response(const char *body) { - MSList *result = NULL; +static bctbx_list_t* parse_vcards_etags_from_xml_response(const char *body) { + bctbx_list_t *result = NULL; xmlparsing_context_t *xml_ctx = linphone_xmlparsing_context_new(); xmlSetGenericErrorFunc(xml_ctx, linphone_xmlparsing_genericxml_error); xml_ctx->doc = xmlReadDoc((const unsigned char*)body, 0, NULL, 0); @@ -279,7 +279,7 @@ static MSList* parse_vcards_etags_from_xml_response(const char *body) { LinphoneCardDavResponse *response = ms_new0(LinphoneCardDavResponse, 1); response->etag = ms_strdup(etag); response->url = ms_strdup(url); - result = ms_list_append(result, response); + result = bctbx_list_append(result, response); ms_debug("Added vCard object with eTag %s and URL %s", etag, url); } } @@ -396,12 +396,12 @@ static void process_response_from_carddav_request(void *data, const belle_http_r } else { // For some reason, server didn't return the eTag of the updated/created vCard // We need to do a GET on the vCard to get the correct one - MSList *vcard = NULL; + bctbx_list_t *vcard = NULL; LinphoneCardDavResponse *response = (LinphoneCardDavResponse *)ms_new0(LinphoneCardDavResponse, 1); response->url = linphone_vcard_get_url(lvc); - vcard = ms_list_append(vcard, response); + vcard = bctbx_list_append(vcard, response); linphone_carddav_pull_vcards(query->context, vcard); - ms_list_free_with_data(vcard, (void (*)(void *))linphone_carddav_response_free); + bctbx_list_free_with_data(vcard, (void (*)(void *))linphone_carddav_response_free); } } else { @@ -459,7 +459,7 @@ static void process_auth_requested_from_carddav_request(void *data, belle_sip_au belle_sip_auth_event_set_ha1(event, cdc->auth_info->ha1); } else { LinphoneCore *lc = cdc->friend_list->lc; - const MSList *auth_infos = linphone_core_get_auth_info_list(lc); + const bctbx_list_t *auth_infos = linphone_core_get_auth_info_list(lc); ms_debug("Looking for auth info for domain %s and realm %s", domain, realm); while (auth_infos) { @@ -473,7 +473,7 @@ static void process_auth_requested_from_carddav_request(void *data, belle_sip_au break; } } - auth_infos = ms_list_next(auth_infos); + auth_infos = bctbx_list_next(auth_infos); } if (!auth_infos) { @@ -716,10 +716,10 @@ void linphone_carddav_fetch_vcards(LinphoneCardDavContext *cdc) { linphone_carddav_send_query(query); } -static LinphoneCardDavQuery* linphone_carddav_create_addressbook_multiget_query(LinphoneCardDavContext *cdc, MSList *vcards) { +static LinphoneCardDavQuery* linphone_carddav_create_addressbook_multiget_query(LinphoneCardDavContext *cdc, bctbx_list_t *vcards) { LinphoneCardDavQuery *query = (LinphoneCardDavQuery *)ms_new0(LinphoneCardDavQuery, 1); - char *body = (char *)ms_malloc((ms_list_size(vcards) + 1) * 300 * sizeof(char)); - MSList *iterator = vcards; + char *body = (char *)ms_malloc((bctbx_list_size(vcards) + 1) * 300 * sizeof(char)); + bctbx_list_t *iterator = vcards; query->context = cdc; query->depth = "1"; @@ -735,7 +735,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_addressbook_multiget_query( char temp_body[300]; snprintf(temp_body, sizeof(temp_body), "%s", response->url); sprintf(body, "%s%s", body, temp_body); - iterator = ms_list_next(iterator); + iterator = bctbx_list_next(iterator); } } sprintf(body, "%s%s", body, ""); @@ -745,7 +745,7 @@ static LinphoneCardDavQuery* linphone_carddav_create_addressbook_multiget_query( return query; } -void linphone_carddav_pull_vcards(LinphoneCardDavContext *cdc, MSList *vcards_to_pull) { +void linphone_carddav_pull_vcards(LinphoneCardDavContext *cdc, bctbx_list_t *vcards_to_pull) { LinphoneCardDavQuery *query = linphone_carddav_create_addressbook_multiget_query(cdc, vcards_to_pull); linphone_carddav_send_query(query); } \ No newline at end of file diff --git a/coreapi/chat.c b/coreapi/chat.c index 73d76191a..02dad2da0 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -114,18 +114,18 @@ void linphone_chat_message_cbs_set_file_transfer_progress_indication( BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneChatMessage); static void _linphone_chat_room_destroy(LinphoneChatRoom *cr) { - ms_list_free_with_data(cr->transient_messages, (void (*)(void *))linphone_chat_message_release); + bctbx_list_free_with_data(cr->transient_messages, (void (*)(void *))linphone_chat_message_release); linphone_chat_room_delete_composing_idle_timer(cr); linphone_chat_room_delete_composing_refresh_timer(cr); linphone_chat_room_delete_remote_composing_refresh_timer(cr); if (cr->lc != NULL) { - if (ms_list_find(cr->lc->chatrooms, cr)) { + if (bctbx_list_find(cr->lc->chatrooms, cr)) { ms_error("LinphoneChatRoom[%p] is destroyed while still being used by the LinphoneCore. This is abnormal." " linphone_core_get_chat_room() doesn't give a reference, there is no need to call " "linphone_chat_room_unref(). " "In order to remove a chat room from the core, use linphone_core_delete_chat_room().", cr); - cr->lc->chatrooms = ms_list_remove(cr->lc->chatrooms, cr); + cr->lc->chatrooms = bctbx_list_remove(cr->lc->chatrooms, cr); } } linphone_address_destroy(cr->peer_url); @@ -167,7 +167,7 @@ bool_t linphone_core_chat_enabled(const LinphoneCore *lc) { return lc->chat_deny_code != LinphoneReasonNone; } -const MSList *linphone_core_get_chat_rooms(LinphoneCore *lc) { +const bctbx_list_t *linphone_core_get_chat_rooms(LinphoneCore *lc) { return lc->chatrooms; } @@ -195,7 +195,7 @@ static LinphoneChatRoom *_linphone_core_create_chat_room_base(LinphoneCore *lc, static LinphoneChatRoom *_linphone_core_create_chat_room(LinphoneCore *lc, LinphoneAddress *addr) { LinphoneChatRoom *cr = _linphone_core_create_chat_room_base(lc, addr); - lc->chatrooms = ms_list_append(lc->chatrooms, (void *)cr); + lc->chatrooms = bctbx_list_append(lc->chatrooms, (void *)cr); return cr; } @@ -216,8 +216,8 @@ static LinphoneChatRoom *_linphone_core_create_chat_room_from_url(LinphoneCore * LinphoneChatRoom *_linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAddress *addr) { LinphoneChatRoom *cr = NULL; - MSList *elem; - for (elem = lc->chatrooms; elem != NULL; elem = ms_list_next(elem)) { + bctbx_list_t *elem; + for (elem = lc->chatrooms; elem != NULL; elem = bctbx_list_next(elem)) { cr = (LinphoneChatRoom *)elem->data; if (linphone_chat_room_matches(cr, addr)) { break; @@ -252,8 +252,8 @@ LinphoneChatRoom *linphone_core_get_chat_room(LinphoneCore *lc, const LinphoneAd } void linphone_core_delete_chat_room(LinphoneCore *lc, LinphoneChatRoom *cr) { - if (ms_list_find(lc->chatrooms, cr)) { - lc->chatrooms = ms_list_remove(cr->lc->chatrooms, cr); + if (bctbx_list_find(lc->chatrooms, cr)) { + lc->chatrooms = bctbx_list_remove(cr->lc->chatrooms, cr); linphone_chat_room_delete_history(cr); linphone_chat_room_unref(cr); } else { @@ -338,7 +338,7 @@ static void linphone_chat_room_delete_remote_composing_refresh_timer(LinphoneCha void linphone_chat_room_destroy(LinphoneChatRoom *cr) { if (cr->received_rtt_characters) { - cr->received_rtt_characters = ms_list_free(cr->received_rtt_characters); + cr->received_rtt_characters = bctbx_list_free(cr->received_rtt_characters); } linphone_chat_room_unref(cr); } @@ -382,7 +382,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage /* open a transaction with the server and send an empty request(RCS5.1 section 3.5.4.8.3.1) */ if (linphone_chat_room_upload_file(msg) == 0) { // add to transient list only if message is going out - cr->transient_messages = ms_list_append(cr->transient_messages, linphone_chat_message_ref(msg)); + cr->transient_messages = bctbx_list_append(cr->transient_messages, linphone_chat_message_ref(msg)); } else { linphone_chat_message_unref(msg); return; @@ -393,7 +393,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage char *content_type; const char *identity = NULL; // add to transient list - cr->transient_messages = ms_list_append(cr->transient_messages, linphone_chat_message_ref(msg)); + cr->transient_messages = bctbx_list_append(cr->transient_messages, linphone_chat_message_ref(msg)); msg->time = ms_time(0); if (lp_config_get_int(cr->lc->config, "sip", "chat_use_call_dialogs", 0) != 0) { if ((call = linphone_core_get_call_by_remote_address(cr->lc, cr->peer)) != NULL) { @@ -480,7 +480,7 @@ void linphone_chat_message_update_state(LinphoneChatMessage *msg, LinphoneChatMe if (msg->state == LinphoneChatMessageStateDelivered || msg->state == LinphoneChatMessageStateNotDelivered) { // msg is not transient anymore, we can remove it from our transient list and unref it - msg->chat_room->transient_messages = ms_list_remove(msg->chat_room->transient_messages, msg); + msg->chat_room->transient_messages = bctbx_list_remove(msg->chat_room->transient_messages, msg); linphone_chat_message_unref(msg); } } @@ -905,7 +905,7 @@ void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *c cmc->value = character; cmc->has_been_read = FALSE; - cr->received_rtt_characters = ms_list_append(cr->received_rtt_characters, (void *)cmc); + cr->received_rtt_characters = bctbx_list_append(cr->received_rtt_characters, (void *)cmc); cr->remote_is_composing = LinphoneIsComposingActive; linphone_core_notify_is_composing_received(cr->lc, cr); @@ -935,7 +935,7 @@ void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *c linphone_chat_room_message_received(cr, lc, msg); linphone_chat_message_unref(msg); cr->pending_message = NULL; - cr->received_rtt_characters = ms_list_free(cr->received_rtt_characters); + cr->received_rtt_characters = bctbx_list_free(cr->received_rtt_characters); } else { char *value = utf8_to_char(character); cr->pending_message->message = ms_strcat_printf(cr->pending_message->message, value); @@ -947,14 +947,14 @@ void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *c uint32_t linphone_chat_room_get_char(const LinphoneChatRoom *cr) { if (cr && cr->received_rtt_characters) { - MSList *characters = cr->received_rtt_characters; + bctbx_list_t *characters = cr->received_rtt_characters; while (characters != NULL) { LinphoneChatMessageCharacter *cmc = (LinphoneChatMessageCharacter *)characters->data; if (!cmc->has_been_read) { cmc->has_been_read = TRUE; return cmc->value; } - characters = ms_list_next(characters); + characters = bctbx_list_next(characters); } } return 0; diff --git a/coreapi/conference.cc b/coreapi/conference.cc index bd5660840..db5930713 100644 --- a/coreapi/conference.cc +++ b/coreapi/conference.cc @@ -458,7 +458,7 @@ int LocalConference::remoteParticipantsCount() { int LocalConference::convertConferenceToCall(){ int err=0; - MSList *calls=m_core->calls; + bctbx_list_t *calls=m_core->calls; if (remoteParticipantsCount()!=1){ ms_error("No unique call remaining in conference."); @@ -506,7 +506,7 @@ int LocalConference::removeParticipant(const LinphoneAddress *uri) { } int LocalConference::terminate() { - MSList *calls=m_core->calls; + bctbx_list_t *calls=m_core->calls; m_terminating =TRUE; while (calls) { @@ -1009,12 +1009,12 @@ int linphone_conference_get_size(const LinphoneConference *obj) { return ((Conference *)obj)->getSize(); } -MSList *linphone_conference_get_participants(const LinphoneConference *obj) { +bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *obj) { const list &participants = ((Conference *)obj)->getParticipants(); - MSList *participants_list = NULL; + bctbx_list_t *participants_list = NULL; for(list::const_iterator it=participants.begin();it!=participants.end();it++) { LinphoneAddress *uri = linphone_address_clone((*it)->getUri()); - participants_list = ms_list_append(participants_list, uri); + participants_list = bctbx_list_append(participants_list, uri); } return participants_list; } diff --git a/coreapi/friend.c b/coreapi/friend.c index 6012645d2..f08ef3b6f 100644 --- a/coreapi/friend.c +++ b/coreapi/friend.c @@ -93,12 +93,12 @@ static int friend_compare(const void * a, const void * b){ } -MSList *linphone_find_friend_by_address(MSList *fl, const LinphoneAddress *addr, LinphoneFriend **lf){ - MSList *res=NULL; +bctbx_list_t *linphone_find_friend_by_address(bctbx_list_t *fl, const LinphoneAddress *addr, LinphoneFriend **lf){ + bctbx_list_t *res=NULL; LinphoneFriend dummy; if (lf!=NULL) *lf=NULL; dummy.uri=(LinphoneAddress*)addr; - res=ms_list_find_custom(fl,friend_compare,&dummy); + res=bctbx_list_find_custom(fl,friend_compare,&dummy); if (lf!=NULL && res!=NULL) *lf=(LinphoneFriend*)res->data; return res; } @@ -245,11 +245,11 @@ void linphone_friend_add_address(LinphoneFriend *lf, const LinphoneAddress *addr linphone_vcard_add_sip_address(vcard, linphone_address_as_string_uri_only(addr)); } -MSList* linphone_friend_get_addresses(LinphoneFriend *lf) { +bctbx_list_t* linphone_friend_get_addresses(LinphoneFriend *lf) { LinphoneVcard *vcard = NULL; - MSList *sipAddresses = NULL; - MSList *addresses = NULL; - MSList *iterator = NULL; + bctbx_list_t *sipAddresses = NULL; + bctbx_list_t *addresses = NULL; + bctbx_list_t *iterator = NULL; if (!lf) { return NULL; @@ -257,7 +257,7 @@ MSList* linphone_friend_get_addresses(LinphoneFriend *lf) { vcard = linphone_friend_get_vcard(lf); if (!vcard) { - return lf->uri ? ms_list_append(addresses, lf->uri) : NULL; + return lf->uri ? bctbx_list_append(addresses, lf->uri) : NULL; } sipAddresses = linphone_vcard_get_sip_addresses(vcard); @@ -266,11 +266,11 @@ MSList* linphone_friend_get_addresses(LinphoneFriend *lf) { const char *sipAddress = (const char *)iterator->data; LinphoneAddress *addr = linphone_address_new(sipAddress); if (addr) { - addresses = ms_list_append(addresses, addr); + addresses = bctbx_list_append(addresses, addr); } - iterator = ms_list_next(iterator); + iterator = bctbx_list_next(iterator); } - if (sipAddresses) ms_list_free(sipAddresses); + if (sipAddresses) bctbx_list_free(sipAddresses); return addresses; } @@ -302,7 +302,7 @@ void linphone_friend_add_phone_number(LinphoneFriend *lf, const char *phone) { linphone_vcard_add_phone_number(vcard, phone); } -MSList* linphone_friend_get_phone_numbers(LinphoneFriend *lf) { +bctbx_list_t* linphone_friend_get_phone_numbers(LinphoneFriend *lf) { LinphoneVcard *vcard = NULL; if (!lf) { @@ -370,7 +370,7 @@ int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscri } void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence){ - MSList *elem; + bctbx_list_t *elem; if (lf->insubs){ char *addr=linphone_address_as_string(linphone_friend_get_address(lf)); ms_message("Want to notify %s",addr); @@ -384,13 +384,13 @@ void linphone_friend_notify(LinphoneFriend *lf, LinphonePresenceModel *presence) void linphone_friend_add_incoming_subscription(LinphoneFriend *lf, SalOp *op){ /*ownership of the op is transfered from sal to the LinphoneFriend*/ - lf->insubs = ms_list_append(lf->insubs, op); + lf->insubs = bctbx_list_append(lf->insubs, op); } void linphone_friend_remove_incoming_subscription(LinphoneFriend *lf, SalOp *op){ - if (ms_list_find(lf->insubs, op)){ + if (bctbx_list_find(lf->insubs, op)){ sal_op_release(op); - lf->insubs = ms_list_remove(lf->insubs, op); + lf->insubs = bctbx_list_remove(lf->insubs, op); } } @@ -424,12 +424,12 @@ void linphone_friend_invalidate_subscription(LinphoneFriend *lf){ void linphone_friend_close_subscriptions(LinphoneFriend *lf){ linphone_friend_unsubscribe(lf); - ms_list_for_each(lf->insubs, (MSIterateFunc) sal_notify_presence_close); - lf->insubs = ms_list_free_with_data(lf->insubs, (MSIterateFunc)sal_op_release); + bctbx_list_for_each(lf->insubs, (MSIterateFunc) sal_notify_presence_close); + lf->insubs = bctbx_list_free_with_data(lf->insubs, (MSIterateFunc)sal_op_release); } static void _linphone_friend_release_ops(LinphoneFriend *lf){ - lf->insubs = ms_list_free_with_data(lf->insubs, (MSIterateFunc) sal_op_release); + lf->insubs = bctbx_list_free_with_data(lf->insubs, (MSIterateFunc) sal_op_release); if (lf->outsub){ sal_op_release(lf->outsub); lf->outsub=NULL; @@ -677,7 +677,7 @@ void linphone_friend_done(LinphoneFriend *fr) { if (fr && fr->vcard) { if (linphone_vcard_compare_md5_hash(fr->vcard) != 0) { ms_debug("vCard's md5 has changed, mark friend as dirty"); - fr->friend_list->dirty_friends_to_update = ms_list_append(fr->friend_list->dirty_friends_to_update, linphone_friend_ref(fr)); + fr->friend_list->dirty_friends_to_update = bctbx_list_append(fr->friend_list->dirty_friends_to_update, linphone_friend_ref(fr)); } } } @@ -708,9 +708,9 @@ LinphoneFriend * linphone_core_create_friend_with_address(LinphoneCore *lc, cons void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *lf) { if (linphone_friend_list_add_friend(linphone_core_get_default_friend_list(lc), lf) != LinphoneFriendListOK) return; - if (ms_list_find(lc->subscribers, lf)) { + if (bctbx_list_find(lc->subscribers, lf)) { /*if this friend was in the pending subscriber list, now remove it from this list*/ - lc->subscribers = ms_list_remove(lc->subscribers, lf); + lc->subscribers = bctbx_list_remove(lc->subscribers, lf); linphone_friend_unref(lf); } } @@ -724,11 +724,11 @@ void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *lf) { } void linphone_core_update_friends_subscriptions(LinphoneCore *lc, LinphoneProxyConfig *cfg, bool_t only_when_registered) { - MSList *lists = lc->friends_lists; + bctbx_list_t *lists = lc->friends_lists; while (lists) { LinphoneFriendList *list = (LinphoneFriendList *)lists->data; linphone_friend_list_update_subscriptions(list, cfg, only_when_registered); - lists = ms_list_next(lists); + lists = bctbx_list_next(lists); } } @@ -737,10 +737,10 @@ bool_t linphone_core_should_subscribe_friends_only_when_registered(const Linphon } void linphone_core_send_initial_subscribes(LinphoneCore *lc) { - MSList *lists = lc->friends_lists; + bctbx_list_t *lists = lc->friends_lists; bool_t proxy_config_for_rls_presence_uri_domain = FALSE; LinphoneAddress *rls_address = NULL; - const MSList *elem; + const bctbx_list_t *elem; if (lc->initial_subscribes_sent) return; lc->initial_subscribes_sent=TRUE; @@ -768,16 +768,16 @@ void linphone_core_send_initial_subscribes(LinphoneCore *lc) { } else { linphone_core_update_friends_subscriptions(lc,NULL,linphone_core_should_subscribe_friends_only_when_registered(lc)); } - lists = ms_list_next(lists); + lists = bctbx_list_next(lists); } } void linphone_core_invalidate_friend_subscriptions(LinphoneCore *lc) { - MSList *lists = lc->friends_lists; + bctbx_list_t *lists = lc->friends_lists; while (lists) { LinphoneFriendList *list = (LinphoneFriendList *)lists->data; linphone_friend_list_invalidate_subscriptions(list); - lists = ms_list_next(lists); + lists = bctbx_list_next(lists); } lc->initial_subscribes_sent=FALSE; } @@ -800,56 +800,56 @@ const char *linphone_friend_get_ref_key(const LinphoneFriend *lf){ } LinphoneFriend *linphone_core_find_friend(const LinphoneCore *lc, const LinphoneAddress *addr) { - MSList *lists = lc->friends_lists; + bctbx_list_t *lists = lc->friends_lists; LinphoneFriend *lf = NULL; while (lists && !lf) { LinphoneFriendList *list = (LinphoneFriendList *)lists->data; lf = linphone_friend_list_find_friend_by_address(list, addr); - lists = ms_list_next(lists); + lists = bctbx_list_next(lists); } return lf; } LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *uri) { - MSList *lists = lc->friends_lists; + bctbx_list_t *lists = lc->friends_lists; LinphoneFriend *lf = NULL; while (lists && !lf) { LinphoneFriendList *list = (LinphoneFriendList *)lists->data; lf = linphone_friend_list_find_friend_by_uri(list, uri); - lists = ms_list_next(lists); + lists = bctbx_list_next(lists); } return lf; } LinphoneFriend *linphone_core_get_friend_by_ref_key(const LinphoneCore *lc, const char *key) { - MSList *lists = lc->friends_lists; + bctbx_list_t *lists = lc->friends_lists; LinphoneFriend *lf = NULL; while (lists && !lf) { LinphoneFriendList *list = (LinphoneFriendList *)lists->data; lf = linphone_friend_list_find_friend_by_ref_key(list, key); - lists = ms_list_next(lists); + lists = bctbx_list_next(lists); } return lf; } LinphoneFriend *linphone_core_find_friend_by_out_subscribe(const LinphoneCore *lc, SalOp *op) { - MSList *lists = lc->friends_lists; + bctbx_list_t *lists = lc->friends_lists; LinphoneFriend *lf = NULL; while (lists && !lf) { LinphoneFriendList *list = (LinphoneFriendList *)lists->data; lf = linphone_friend_list_find_friend_by_out_subscribe(list, op); - lists = ms_list_next(lists); + lists = bctbx_list_next(lists); } return lf; } LinphoneFriend *linphone_core_find_friend_by_inc_subscribe(const LinphoneCore *lc, SalOp *op) { - MSList *lists = lc->friends_lists; + bctbx_list_t *lists = lc->friends_lists; LinphoneFriend *lf = NULL; while (lists && !lf) { LinphoneFriendList *list = (LinphoneFriendList *)lists->data; lf = linphone_friend_list_find_friend_by_inc_subscribe(list, op); - lists = ms_list_next(lists); + lists = bctbx_list_next(lists); } return lf; } @@ -871,7 +871,7 @@ LinphoneSubscribePolicy __policy_str_to_enum(const char* pol){ } LinphoneProxyConfig *__index_to_proxy(LinphoneCore *lc, int index){ - if (index>=0) return (LinphoneProxyConfig*)ms_list_nth_data(lc->sip_conf.proxies,index); + if (index>=0) return (LinphoneProxyConfig*)bctbx_list_nth_data(lc->sip_conf.proxies,index); else return NULL; } @@ -956,14 +956,14 @@ void linphone_friend_write_to_config_file(LpConfig *config, LinphoneFriend *lf, } void linphone_core_write_friends_config(LinphoneCore* lc) { - MSList *elem; + bctbx_list_t *elem; int i; int store_friends; if (! linphone_core_ready(lc)) return; /*dont write config when reading it !*/ store_friends = lp_config_get_int(lc->config, "misc", "store_friends", 1); if (store_friends) { - for (elem=linphone_core_get_default_friend_list(lc)->friends,i=0; elem!=NULL; elem=ms_list_next(elem),i++){ + for (elem=linphone_core_get_default_friend_list(lc)->friends,i=0; elem!=NULL; elem=bctbx_list_next(elem),i++){ linphone_friend_write_to_config_file(lc->config,(LinphoneFriend*)elem->data,i); } linphone_friend_write_to_config_file(lc->config,NULL,i); /* set the end */ @@ -1057,7 +1057,7 @@ LinphoneFriend *linphone_friend_new_from_vcard(LinphoneVcard *vcard) { LinphoneAddress* linphone_address = NULL; LinphoneFriend *fr; const char *name = NULL; - MSList *sipAddresses = NULL; + bctbx_list_t *sipAddresses = NULL; if (vcard == NULL) { ms_error("Cannot create friend from null vcard"); @@ -1156,7 +1156,7 @@ void linphone_core_friends_storage_init(LinphoneCore *lc) { int ret; const char *errmsg; sqlite3 *db; - const MSList *friends_lists = NULL; + const bctbx_list_t *friends_lists = NULL; linphone_core_friends_storage_close(lc); @@ -1175,13 +1175,13 @@ void linphone_core_friends_storage_init(LinphoneCore *lc) { friends_lists = linphone_core_fetch_friends_lists_from_db(lc); if (friends_lists) { ms_warning("Replacing current default friend list by the one(s) from the database"); - lc->friends_lists = ms_list_free_with_data(lc->friends_lists, (void (*)(void*))linphone_friend_list_unref); + lc->friends_lists = bctbx_list_free_with_data(lc->friends_lists, (void (*)(void*))linphone_friend_list_unref); lc->friends_lists = NULL; while (friends_lists) { LinphoneFriendList *list = (LinphoneFriendList *)friends_lists->data; linphone_core_add_friend_list(lc, list); - friends_lists = ms_list_next(friends_lists); + friends_lists = bctbx_list_next(friends_lists); } } } @@ -1201,7 +1201,7 @@ void linphone_core_friends_storage_close(LinphoneCore *lc) { * | 4 | revision */ static int create_friend_list(void *data, int argc, char **argv, char **colName) { - MSList **list = (MSList **)data; + bctbx_list_t **list = (bctbx_list_t **)data; unsigned int storage_id = (unsigned int)atoi(argv[0]); LinphoneFriendList *lfl = linphone_core_create_friend_list(NULL); @@ -1211,7 +1211,7 @@ static int create_friend_list(void *data, int argc, char **argv, char **colName) linphone_friend_list_set_uri(lfl, argv[3]); lfl->revision = atoi(argv[4]); - *list = ms_list_append(*list, linphone_friend_list_ref(lfl)); + *list = bctbx_list_append(*list, linphone_friend_list_ref(lfl)); linphone_friend_list_unref(lfl); return 0; } @@ -1237,7 +1237,7 @@ static int create_friend_list(void *data, int argc, char **argv, char **colName) * | 9 | presence_received */ static int create_friend(void *data, int argc, char **argv, char **colName) { - MSList **list = (MSList **)data; + bctbx_list_t **list = (bctbx_list_t **)data; LinphoneFriend *lf = NULL; LinphoneVcard *vcard = NULL; unsigned int storage_id = (unsigned int)atoi(argv[0]); @@ -1260,7 +1260,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) { lf->presence_received = atoi(argv[9]); lf->storage_id = storage_id; - *list = ms_list_append(*list, linphone_friend_ref(lf)); + *list = bctbx_list_append(*list, linphone_friend_ref(lf)); linphone_friend_unref(lf); return 0; } @@ -1268,7 +1268,7 @@ static int create_friend(void *data, int argc, char **argv, char **colName) { #pragma GCC diagnostic pop #endif -static int linphone_sql_request_friend(sqlite3* db, const char *stmt, MSList **list) { +static int linphone_sql_request_friend(sqlite3* db, const char *stmt, bctbx_list_t **list) { char* errmsg = NULL; int ret; ret = sqlite3_exec(db, stmt, create_friend, list, &errmsg); @@ -1279,7 +1279,7 @@ static int linphone_sql_request_friend(sqlite3* db, const char *stmt, MSList **l return ret; } -static int linphone_sql_request_friends_list(sqlite3* db, const char *stmt, MSList **list) { +static int linphone_sql_request_friends_list(sqlite3* db, const char *stmt, bctbx_list_t **list) { char* errmsg = NULL; int ret; ret = sqlite3_exec(db, stmt, create_friend_list, list, &errmsg); @@ -1422,11 +1422,11 @@ void linphone_core_remove_friends_list_from_db(LinphoneCore *lc, LinphoneFriendL } } -MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list) { +bctbx_list_t* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list) { char *buf; uint64_t begin,end; - MSList *result = NULL; - MSList *elem = NULL; + bctbx_list_t *result = NULL; + bctbx_list_t *elem = NULL; if (!lc || lc->friends_db == NULL || list == NULL) { ms_warning("Either lc (or list) is NULL or friends database wasn't initialized with linphone_core_friends_storage_init() yet"); @@ -1438,7 +1438,7 @@ MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList begin = ortp_get_cur_time_ms(); linphone_sql_request_friend(lc->friends_db, buf, &result); end = ortp_get_cur_time_ms(); - ms_message("%s(): %u results fetched, completed in %i ms",__FUNCTION__, (unsigned int)ms_list_size(result), (int)(end-begin)); + ms_message("%s(): %u results fetched, completed in %i ms",__FUNCTION__, (unsigned int)bctbx_list_size(result), (int)(end-begin)); sqlite3_free(buf); for(elem = result; elem != NULL; elem = elem->next) { @@ -1450,11 +1450,11 @@ MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList return result; } -MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc) { +bctbx_list_t* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc) { char *buf; uint64_t begin,end; - MSList *result = NULL; - MSList *elem = NULL; + bctbx_list_t *result = NULL; + bctbx_list_t *elem = NULL; if (!lc || lc->friends_db == NULL) { ms_warning("Either lc is NULL or friends database wasn't initialized with linphone_core_friends_storage_init() yet"); @@ -1466,7 +1466,7 @@ MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc) { begin = ortp_get_cur_time_ms(); linphone_sql_request_friends_list(lc->friends_db, buf, &result); end = ortp_get_cur_time_ms(); - ms_message("%s(): %u results fetched, completed in %i ms",__FUNCTION__, (unsigned int)ms_list_size(result), (int)(end-begin)); + ms_message("%s(): %u results fetched, completed in %i ms",__FUNCTION__, (unsigned int)bctbx_list_size(result), (int)(end-begin)); sqlite3_free(buf); for(elem = result; elem != NULL; elem = elem->next) { @@ -1498,11 +1498,11 @@ void linphone_core_remove_friend_from_db(LinphoneCore *lc, LinphoneFriend *lf) { void linphone_core_remove_friends_list_from_db(LinphoneCore *lc, LinphoneFriendList *list) { } -MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list) { +bctbx_list_t* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list) { return NULL; } -MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc) { +bctbx_list_t* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc) { return NULL; } @@ -1544,7 +1544,7 @@ void linphone_core_migrate_friends_from_rc_to_db(LinphoneCore *lc) { return; } - if (ms_list_size(linphone_friend_list_get_friends(lfl)) > 0 && lfl->storage_id == 0) { + if (bctbx_list_size(linphone_friend_list_get_friends(lfl)) > 0 && lfl->storage_id == 0) { linphone_core_remove_friend_list(lc, lfl); lfl = linphone_core_create_friend_list(lc); linphone_core_add_friend_list(lc, lfl); diff --git a/coreapi/friendlist.c b/coreapi/friendlist.c index 9aeeff24a..b28af36de 100644 --- a/coreapi/friendlist.c +++ b/coreapi/friendlist.c @@ -90,12 +90,12 @@ void linphone_friend_list_cbs_set_sync_status_changed(LinphoneFriendListCbs *cbs static char * create_resource_list_xml(const LinphoneFriendList *list) { char *xml_content = NULL; - MSList *elem; + bctbx_list_t *elem; xmlBufferPtr buf; xmlTextWriterPtr writer; int err; - if (ms_list_size(list->friends) <= 0) return NULL; + if (bctbx_list_size(list->friends) <= 0) return NULL; buf = xmlBufferCreate(); if (buf == NULL) { @@ -196,7 +196,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList goto end; } if ((strcmp(full_state_str, "true") == 0) || (strcmp(full_state_str, "1") == 0)) { - MSList *l = list->friends; + bctbx_list_t *l = list->friends; for (; l != NULL; l = l->next) { lf = (LinphoneFriend *)l->data; linphone_friend_set_presence_model(lf, NULL); @@ -253,7 +253,7 @@ static void linphone_friend_list_parse_multipart_related_body(LinphoneFriendList if (resource_object != NULL) xmlXPathFreeObject(resource_object); if (full_state == TRUE) { - MSList *l = list->friends; + bctbx_list_t *l = list->friends; for (; l != NULL; l = l->next) { lf = (LinphoneFriend *)l->data; if (linphone_friend_is_presence_received(lf) == TRUE) { @@ -270,7 +270,7 @@ end: } static bool_t linphone_friend_list_has_subscribe_inactive(const LinphoneFriendList *list) { - MSList *l = list->friends; + bctbx_list_t *l = list->friends; bool_t has_subscribe_inactive = FALSE; for (; l != NULL; l = l->next) { LinphoneFriend *lf = (LinphoneFriend *)l->data; @@ -301,8 +301,8 @@ static void linphone_friend_list_destroy(LinphoneFriendList *list) { } if (list->uri != NULL) ms_free(list->uri); if (list->cbs) linphone_friend_list_cbs_unref(list->cbs); - if (list->dirty_friends_to_update) list->dirty_friends_to_update = ms_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))linphone_friend_unref); - if (list->friends) list->friends = ms_list_free_with_data(list->friends, (void (*)(void *))_linphone_friend_release); + if (list->dirty_friends_to_update) list->dirty_friends_to_update = bctbx_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))linphone_friend_unref); + if (list->friends) list->friends = bctbx_list_free_with_data(list->friends, (void (*)(void *))_linphone_friend_release); } BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneFriendList); @@ -338,10 +338,10 @@ void _linphone_friend_list_release(LinphoneFriendList *list){ list->cbs = NULL; } if (list->dirty_friends_to_update) { - list->dirty_friends_to_update = ms_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))linphone_friend_unref); + list->dirty_friends_to_update = bctbx_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))linphone_friend_unref); } if (list->friends) { - list->friends = ms_list_free_with_data(list->friends, (void (*)(void *))_linphone_friend_release); + list->friends = bctbx_list_free_with_data(list->friends, (void (*)(void *))_linphone_friend_release); } linphone_friend_list_unref(list); } @@ -400,7 +400,7 @@ static LinphoneFriendListStatus _linphone_friend_list_add_friend(LinphoneFriendL ms_error("linphone_friend_list_add_friend(): invalid friend, already in list"); return status; } - if (ms_list_find(list->friends, lf) != NULL) { + if (bctbx_list_find(list->friends, lf) != NULL) { char *tmp = NULL; const LinphoneAddress *addr = linphone_friend_get_address(lf); if (addr) tmp = linphone_address_as_string(addr); @@ -435,9 +435,9 @@ LinphoneFriendListStatus linphone_friend_list_import_friend(LinphoneFriendList * } lf->friend_list = list; lf->lc = list->lc; - list->friends = ms_list_append(list->friends, linphone_friend_ref(lf)); + list->friends = bctbx_list_append(list->friends, linphone_friend_ref(lf)); if (synchronize) { - list->dirty_friends_to_update = ms_list_append(list->dirty_friends_to_update, linphone_friend_ref(lf)); + list->dirty_friends_to_update = bctbx_list_append(list->dirty_friends_to_update, linphone_friend_ref(lf)); } return LinphoneFriendListOK; } @@ -450,7 +450,7 @@ static void carddav_done(LinphoneCardDavContext *cdc, bool_t success, const char } static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFriendList *list, LinphoneFriend *lf, bool_t remove_from_server) { - MSList *elem = ms_list_find(list->friends, lf); + bctbx_list_t *elem = bctbx_list_find(list->friends, lf); if (elem == NULL) return LinphoneFriendListNonExistentFriend; #ifdef SQLITE_STORAGE_ENABLED @@ -477,7 +477,7 @@ static LinphoneFriendListStatus _linphone_friend_list_remove_friend(LinphoneFrie lf->friend_list = NULL; linphone_friend_unref(lf); - list->friends = ms_list_remove_link(list->friends, elem); + list->friends = bctbx_list_remove_link(list->friends, elem); return LinphoneFriendListOK; } @@ -485,12 +485,12 @@ LinphoneFriendListStatus linphone_friend_list_remove_friend(LinphoneFriendList * return _linphone_friend_list_remove_friend(list, lf, TRUE); } -const MSList * linphone_friend_list_get_friends(const LinphoneFriendList *list) { +const bctbx_list_t * linphone_friend_list_get_friends(const LinphoneFriendList *list) { return list->friends; } void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) { - MSList *dirty_friends = list->dirty_friends_to_update; + bctbx_list_t *dirty_friends = list->dirty_friends_to_update; while (dirty_friends) { LinphoneCardDavContext *cdc = linphone_carddav_context_new(list); @@ -504,9 +504,9 @@ void linphone_friend_list_update_dirty_friends(LinphoneFriendList *list) { linphone_carddav_put_vcard(cdc, lf); } } - dirty_friends = ms_list_next(dirty_friends); + dirty_friends = bctbx_list_next(dirty_friends); } - list->dirty_friends_to_update = ms_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))linphone_friend_unref); + list->dirty_friends_to_update = bctbx_list_free_with_data(list->dirty_friends_to_update, (void (*)(void *))linphone_friend_unref); } static void carddav_created(LinphoneCardDavContext *cdc, LinphoneFriend *lf) { @@ -532,7 +532,7 @@ static void carddav_removed(LinphoneCardDavContext *cdc, LinphoneFriend *lf) { static void carddav_updated(LinphoneCardDavContext *cdc, LinphoneFriend *lf_new, LinphoneFriend *lf_old) { if (cdc) { LinphoneFriendList *lfl = cdc->friend_list; - MSList *elem = ms_list_find(lfl->friends, lf_old); + bctbx_list_t *elem = bctbx_list_find(lfl->friends, lf_old); if (elem) { elem->data = linphone_friend_ref(lf_new); } @@ -568,7 +568,7 @@ void linphone_friend_list_synchronize_friends_from_server(LinphoneFriendList *li LinphoneFriend * linphone_friend_list_find_friend_by_address(const LinphoneFriendList *list, const LinphoneAddress *address) { LinphoneFriend *lf = NULL; - const MSList *elem; + const bctbx_list_t *elem; for (elem = list->friends; elem != NULL; elem = elem->next) { lf = (LinphoneFriend *)elem->data; if (linphone_address_weak_equal(lf->uri, address)) @@ -585,7 +585,7 @@ LinphoneFriend * linphone_friend_list_find_friend_by_uri(const LinphoneFriendLis } LinphoneFriend * linphone_friend_list_find_friend_by_ref_key(const LinphoneFriendList *list, const char *ref_key) { - const MSList *elem; + const bctbx_list_t *elem; if (ref_key == NULL) return NULL; for (elem = list->friends; elem != NULL; elem = elem->next) { LinphoneFriend *lf = (LinphoneFriend *)elem->data; @@ -595,16 +595,16 @@ LinphoneFriend * linphone_friend_list_find_friend_by_ref_key(const LinphoneFrien } LinphoneFriend * linphone_friend_list_find_friend_by_inc_subscribe(const LinphoneFriendList *list, SalOp *op) { - const MSList *elem; + const bctbx_list_t *elem; for (elem = list->friends; elem != NULL; elem = elem->next) { LinphoneFriend *lf = (LinphoneFriend *)elem->data; - if (ms_list_find(lf->insubs, op)) return lf; + if (bctbx_list_find(lf->insubs, op)) return lf; } return NULL; } LinphoneFriend * linphone_friend_list_find_friend_by_out_subscribe(const LinphoneFriendList *list, SalOp *op) { - const MSList *elem; + const bctbx_list_t *elem; for (elem = list->friends; elem != NULL; elem = elem->next) { LinphoneFriend *lf = (LinphoneFriend *)elem->data; if (lf->outsub && ((lf->outsub == op) || sal_op_is_forked_of(lf->outsub, op))) return lf; @@ -619,11 +619,11 @@ static void linphone_friend_list_close_subscriptions(LinphoneFriendList *list) { linphone_event_unref(list->event); list->event = NULL; } - ms_list_for_each(list->friends, (void (*)(void *))linphone_friend_close_subscriptions); + bctbx_list_for_each(list->friends, (void (*)(void *))linphone_friend_close_subscriptions); } void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, LinphoneProxyConfig *cfg, bool_t only_when_registered) { - const MSList *elem; + const bctbx_list_t *elem; if (list->rls_uri != NULL) { if (list->enable_subscriptions) { LinphoneAddress *address = linphone_address_new(list->rls_uri); @@ -679,7 +679,7 @@ void linphone_friend_list_update_subscriptions(LinphoneFriendList *list, Linphon } void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list) { - const MSList *elem; + const bctbx_list_t *elem; for (elem = list->friends; elem != NULL; elem = elem->next) { LinphoneFriend *lf = (LinphoneFriend *)elem->data; linphone_friend_invalidate_subscription(lf); @@ -687,7 +687,7 @@ void linphone_friend_list_invalidate_subscriptions(LinphoneFriendList *list) { } void linphone_friend_list_notify_presence(LinphoneFriendList *list, LinphonePresenceModel *presence) { - const MSList *elem; + const bctbx_list_t *elem; for(elem = list->friends; elem != NULL; elem = elem->next) { LinphoneFriend *lf = (LinphoneFriend *)elem->data; linphone_friend_notify(lf, presence); @@ -768,8 +768,8 @@ LinphoneCore* linphone_friend_list_get_core(LinphoneFriendList *list) { } int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *list, const char *vcard_file) { - MSList *vcards = NULL; - MSList *vcards_iterator = NULL; + bctbx_list_t *vcards = NULL; + bctbx_list_t *vcards_iterator = NULL; int count = 0; #ifndef VCARD_ENABLED @@ -799,16 +799,16 @@ int linphone_friend_list_import_friends_from_vcard4_file(LinphoneFriendList *lis } else { linphone_vcard_free(vcard); } - vcards_iterator = ms_list_next(vcards_iterator); + vcards_iterator = bctbx_list_next(vcards_iterator); } - ms_list_free(vcards); + bctbx_list_free(vcards); linphone_core_store_friends_list_in_db(list->lc, list); return count; } int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *list, const char *vcard_buffer) { - MSList *vcards = NULL; - MSList *vcards_iterator = NULL; + bctbx_list_t *vcards = NULL; + bctbx_list_t *vcards_iterator = NULL; int count = 0; #ifndef VCARD_ENABLED @@ -838,16 +838,16 @@ int linphone_friend_list_import_friends_from_vcard4_buffer(LinphoneFriendList *l } else { linphone_vcard_free(vcard); } - vcards_iterator = ms_list_next(vcards_iterator); + vcards_iterator = bctbx_list_next(vcards_iterator); } - ms_list_free(vcards); + bctbx_list_free(vcards); linphone_core_store_friends_list_in_db(list->lc, list); return count; } void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list, const char *vcard_file) { FILE *file = NULL; - const MSList *friends = linphone_friend_list_get_friends(list); + const bctbx_list_t *friends = linphone_friend_list_get_friends(list); file = fopen(vcard_file, "wb"); if (file == NULL) { @@ -867,7 +867,7 @@ void linphone_friend_list_export_friends_as_vcard4_file(LinphoneFriendList *list } else { ms_warning("Couldn't export friend %s because it doesn't have a vCard attached", linphone_address_as_string(linphone_friend_get_address(lf))); } - friends = ms_list_next(friends); + friends = bctbx_list_next(friends); } fclose(file); diff --git a/coreapi/ldap/ldapprovider.c b/coreapi/ldap/ldapprovider.c index 75b6b19a1..34460e1f4 100644 --- a/coreapi/ldap/ldapprovider.c +++ b/coreapi/ldap/ldapprovider.c @@ -40,7 +40,7 @@ struct _LinphoneLDAPContactProvider LinphoneDictionary* config; LDAP* ld; - MSList* requests; + bctbx_list_t* requests; unsigned int req_count; // bind transaction @@ -78,7 +78,7 @@ struct _LinphoneLDAPContactSearch int msgid; char* filter; bool_t complete; - MSList* found_entries; + bctbx_list_t* found_entries; unsigned int found_count; }; @@ -116,8 +116,8 @@ unsigned int linphone_ldap_contact_search_result_count(LinphoneLDAPContactSearch static void linphone_ldap_contact_search_destroy( LinphoneLDAPContactSearch* obj ) { //ms_message("~LinphoneLDAPContactSearch(%p)", obj); - ms_list_for_each(obj->found_entries, linphone_ldap_contact_search_destroy_friend); - obj->found_entries = ms_list_free(obj->found_entries); + bctbx_list_for_each(obj->found_entries, linphone_ldap_contact_search_destroy_friend); + obj->found_entries = bctbx_list_free(obj->found_entries); if( obj->filter ) ms_free(obj->filter); } @@ -152,7 +152,7 @@ static void linphone_ldap_contact_provider_destroy( LinphoneLDAPContactProvider* linphone_core_remove_iterate_hook(LINPHONE_CONTACT_PROVIDER(obj)->lc, linphone_ldap_contact_provider_iterate,obj); // clean pending requests - ms_list_for_each(obj->requests, linphone_ldap_contact_provider_destroy_request_cb); + bctbx_list_for_each(obj->requests, linphone_ldap_contact_provider_destroy_request_cb); if (obj->ld) ldap_unbind_ext(obj->ld, NULL, NULL); obj->ld = NULL; @@ -223,7 +223,7 @@ static void linphone_ldap_contact_provider_handle_search_result( LinphoneLDAPCon LinphoneFriend* lf = linphone_core_create_friend(lc); linphone_friend_set_address(lf, la); linphone_friend_set_name(lf, ldap_data.name); - req->found_entries = ms_list_append(req->found_entries, lf); + req->found_entries = bctbx_list_append(req->found_entries, lf); req->found_count++; //ms_message("Added friend %s / %s", ldap_data.name, ldap_data.sip); ms_free(ldap_data.sip); @@ -313,7 +313,7 @@ static bool_t linphone_ldap_contact_provider_iterate(void *data) unsigned int i; for( i=0; ireq_count; i++){ - LinphoneLDAPContactSearch* search = (LinphoneLDAPContactSearch*)ms_list_nth_data( obj->requests, i ); + LinphoneLDAPContactSearch* search = (LinphoneLDAPContactSearch*)bctbx_list_nth_data( obj->requests, i ); if( search && search->msgid == 0){ int ret; ms_message("Found pending search %p (for %s), launching...", search, search->filter); @@ -618,10 +618,10 @@ static int linphone_ldap_request_entry_compare_strong(const void*a, const void* static inline LinphoneLDAPContactSearch* linphone_ldap_contact_provider_request_search( LinphoneLDAPContactProvider* obj, int msgid ) { LinphoneLDAPContactSearch dummy = {}; - MSList* list_entry; + bctbx_list_t* list_entry; dummy.msgid = msgid; - list_entry = ms_list_find_custom(obj->requests, linphone_ldap_request_entry_compare_weak, &dummy); + list_entry = bctbx_list_find_custom(obj->requests, linphone_ldap_request_entry_compare_weak, &dummy); if( list_entry ) return list_entry->data; else return NULL; } @@ -632,10 +632,10 @@ static unsigned int linphone_ldap_contact_provider_cancel_search(LinphoneContact LinphoneLDAPContactProvider* ldap_cp = LINPHONE_LDAP_CONTACT_PROVIDER(obj); int ret = 1; - MSList* list_entry = ms_list_find_custom(ldap_cp->requests, linphone_ldap_request_entry_compare_strong, req); + bctbx_list_t* list_entry = bctbx_list_find_custom(ldap_cp->requests, linphone_ldap_request_entry_compare_strong, req); if( list_entry ) { ms_message("Delete search %p", req); - ldap_cp->requests = ms_list_remove_link(ldap_cp->requests, list_entry); + ldap_cp->requests = bctbx_list_remove_link(ldap_cp->requests, list_entry); ldap_cp->req_count--; ret = 0; // return OK if we found it in the monitored requests } else { @@ -703,7 +703,7 @@ static LinphoneLDAPContactSearch* linphone_ldap_contact_provider_begin_search ( } if( request != NULL ) { - obj->requests = ms_list_append ( obj->requests, request ); + obj->requests = bctbx_list_append ( obj->requests, request ); obj->req_count++; } diff --git a/coreapi/linphone_tunnel.cc b/coreapi/linphone_tunnel.cc index 827de9fdc..c2ea6ee10 100644 --- a/coreapi/linphone_tunnel.cc +++ b/coreapi/linphone_tunnel.cc @@ -35,7 +35,7 @@ LinphoneTunnel* linphone_core_get_tunnel(const LinphoneCore *lc){ struct _LinphoneTunnel { belledonnecomm::TunnelManager *manager; - MSList *config_list; + bctbx_list_t *config_list; }; extern "C" LinphoneTunnel* linphone_core_tunnel_new(LinphoneCore *lc){ @@ -55,7 +55,7 @@ static inline _LpConfig *config(const LinphoneTunnel *tunnel){ void linphone_tunnel_destroy(LinphoneTunnel *tunnel){ delete tunnel->manager; - ms_list_free_with_data(tunnel->config_list, (void (*)(void *))linphone_tunnel_config_destroy); + bctbx_list_free_with_data(tunnel->config_list, (void (*)(void *))linphone_tunnel_config_destroy); ms_free(tunnel); } @@ -129,7 +129,7 @@ static LinphoneTunnelConfig *linphone_tunnel_config_from_string(const char *str) static void linphone_tunnel_save_config(const LinphoneTunnel *tunnel) { - MSList *elem = NULL; + bctbx_list_t *elem = NULL; char *tmp = NULL, *old_tmp = NULL, *tc_str = NULL; for(elem = tunnel->config_list; elem != NULL; elem = elem->next) { LinphoneTunnelConfig *tunnel_config = (LinphoneTunnelConfig *)elem->data; @@ -162,7 +162,7 @@ static void linphone_tunnel_add_server_intern(LinphoneTunnel *tunnel, LinphoneTu linphone_tunnel_config_get_remote_udp_mirror_port(tunnel_config), linphone_tunnel_config_get_delay(tunnel_config)); } - tunnel->config_list = ms_list_append(tunnel->config_list, linphone_tunnel_config_ref(tunnel_config)); + tunnel->config_list = bctbx_list_append(tunnel->config_list, linphone_tunnel_config_ref(tunnel_config)); } @@ -192,7 +192,7 @@ static void linphone_tunnel_load_config(LinphoneTunnel *tunnel){ } static void linphone_tunnel_refresh_config(LinphoneTunnel *tunnel) { - MSList *old_list = tunnel->config_list; + bctbx_list_t *old_list = tunnel->config_list; tunnel->config_list = NULL; bcTunnel(tunnel)->cleanServers(); while(old_list != NULL) { @@ -209,16 +209,16 @@ void linphone_tunnel_add_server(LinphoneTunnel *tunnel, LinphoneTunnelConfig *tu } void linphone_tunnel_remove_server(LinphoneTunnel *tunnel, LinphoneTunnelConfig *tunnel_config) { - MSList *elem = ms_list_find(tunnel->config_list, tunnel_config); + bctbx_list_t *elem = bctbx_list_find(tunnel->config_list, tunnel_config); if(elem != NULL) { - tunnel->config_list = ms_list_remove(tunnel->config_list, tunnel_config); + tunnel->config_list = bctbx_list_remove(tunnel->config_list, tunnel_config); linphone_tunnel_config_unref(tunnel_config); linphone_tunnel_refresh_config(tunnel); linphone_tunnel_save_config(tunnel); } } -const MSList *linphone_tunnel_get_servers(const LinphoneTunnel *tunnel){ +const bctbx_list_t *linphone_tunnel_get_servers(const LinphoneTunnel *tunnel){ return tunnel->config_list; } @@ -226,7 +226,7 @@ void linphone_tunnel_clean_servers(LinphoneTunnel *tunnel){ bcTunnel(tunnel)->cleanServers(); /* Free the list */ - ms_list_free_with_data(tunnel->config_list, (void (*)(void *))linphone_tunnel_config_destroy); + bctbx_list_free_with_data(tunnel->config_list, (void (*)(void *))linphone_tunnel_config_destroy); tunnel->config_list = NULL; linphone_tunnel_save_config(tunnel); diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 376c9a1d0..78c119d83 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -258,9 +258,9 @@ void linphone_call_set_authentication_token_verified(LinphoneCall *call, bool_t propagate_encryption_changed(call); } -static int get_max_codec_sample_rate(const MSList *codecs){ +static int get_max_codec_sample_rate(const bctbx_list_t *codecs){ int max_sample_rate=0; - const MSList *it; + const bctbx_list_t *it; for(it=codecs;it!=NULL;it=it->next){ PayloadType *pt=(PayloadType*)it->data; int sample_rate; @@ -274,8 +274,8 @@ static int get_max_codec_sample_rate(const MSList *codecs){ return max_sample_rate; } -static int find_payload_type_number(const MSList *assigned, const PayloadType *pt){ - const MSList *elem; +static int find_payload_type_number(const bctbx_list_t *assigned, const PayloadType *pt){ + const bctbx_list_t *elem; const PayloadType *candidate=NULL; for(elem=assigned;elem!=NULL;elem=elem->next){ const PayloadType *it=(const PayloadType*)elem->data; @@ -292,8 +292,8 @@ static int find_payload_type_number(const MSList *assigned, const PayloadType *p return candidate ? payload_type_get_number(candidate) : -1; } -bool_t is_payload_type_number_available(const MSList *l, int number, const PayloadType *ignore){ - const MSList *elem; +bool_t is_payload_type_number_available(const bctbx_list_t *l, int number, const PayloadType *ignore){ + const bctbx_list_t *elem; for (elem=l; elem!=NULL; elem=elem->next){ const PayloadType *pt=(PayloadType*)elem->data; if (pt!=ignore && payload_type_get_number(pt)==number) return FALSE; @@ -301,8 +301,8 @@ bool_t is_payload_type_number_available(const MSList *l, int number, const Paylo return TRUE; } -static void linphone_core_assign_payload_type_numbers(LinphoneCore *lc, MSList *codecs){ - MSList *elem; +static void linphone_core_assign_payload_type_numbers(LinphoneCore *lc, bctbx_list_t *codecs){ + bctbx_list_t *elem; int dyn_number=lc->codecs_conf.dyn_pt; PayloadType *red = NULL, *t140 = NULL; @@ -347,8 +347,8 @@ static void linphone_core_assign_payload_type_numbers(LinphoneCore *lc, MSList * } } -static bool_t has_telephone_event_at_rate(const MSList *tev, int rate){ - const MSList *it; +static bool_t has_telephone_event_at_rate(const bctbx_list_t *tev, int rate){ + const bctbx_list_t *it; for(it=tev;it!=NULL;it=it->next){ const PayloadType *pt=(PayloadType*)it->data; if (pt->clock_rate==rate) return TRUE; @@ -356,9 +356,9 @@ static bool_t has_telephone_event_at_rate(const MSList *tev, int rate){ return FALSE; } -static MSList * create_telephone_events(LinphoneCore *lc, const MSList *codecs){ - const MSList *it; - MSList *ret=NULL; +static bctbx_list_t * create_telephone_events(LinphoneCore *lc, const bctbx_list_t *codecs){ + const bctbx_list_t *it; + bctbx_list_t *ret=NULL; for(it=codecs;it!=NULL;it=it->next){ const PayloadType *pt=(PayloadType*)it->data; if (!has_telephone_event_at_rate(ret,pt->clock_rate)){ @@ -372,18 +372,18 @@ static MSList * create_telephone_events(LinphoneCore *lc, const MSList *codecs){ payload_type_set_number(tev, lc->codecs_conf.telephone_event_pt); } } - ret=ms_list_append(ret,tev); + ret=bctbx_list_append(ret,tev); } } return ret; } -static MSList *create_special_payload_types(LinphoneCore *lc, const MSList *codecs){ - MSList *ret=create_telephone_events(lc, codecs); +static bctbx_list_t *create_special_payload_types(LinphoneCore *lc, const bctbx_list_t *codecs){ + bctbx_list_t *ret=create_telephone_events(lc, codecs); if (linphone_core_generic_confort_noise_enabled(lc)){ PayloadType *cn=payload_type_clone(&payload_type_cn); payload_type_set_number(cn, 13); - ret=ms_list_append(ret, cn); + ret=bctbx_list_append(ret, cn); } return ret; } @@ -391,12 +391,12 @@ static MSList *create_special_payload_types(LinphoneCore *lc, const MSList *code typedef struct _CodecConstraints{ int bandwidth_limit; int max_codecs; - MSList *previously_used; + bctbx_list_t *previously_used; }CodecConstraints; -static MSList *make_codec_list(LinphoneCore *lc, CodecConstraints * hints, SalStreamType stype, const MSList *codecs){ - MSList *l=NULL; - const MSList *it; +static bctbx_list_t *make_codec_list(LinphoneCore *lc, CodecConstraints * hints, SalStreamType stype, const bctbx_list_t *codecs){ + bctbx_list_t *l=NULL; + const bctbx_list_t *it; int nb = 0; for(it=codecs;it!=NULL;it=it->next){ @@ -423,13 +423,13 @@ static MSList *make_codec_list(LinphoneCore *lc, CodecConstraints * hints, SalSt payload_type_set_flag(pt, PAYLOAD_TYPE_FROZEN_NUMBER); } - l=ms_list_append(l, pt); + l=bctbx_list_append(l, pt); nb++; if ((hints->max_codecs > 0) && (nb >= hints->max_codecs)) break; } if (stype==SalAudio){ - MSList *specials=create_special_payload_types(lc,l); - l=ms_list_concat(l,specials); + bctbx_list_t *specials=create_special_payload_types(lc,l); + l=bctbx_list_concat(l,specials); } linphone_core_assign_payload_type_numbers(lc, l); return l; @@ -542,7 +542,7 @@ static void setup_zrtp_hash(LinphoneCall *call, SalMediaDescription *md) { } static void setup_rtcp_fb(LinphoneCall *call, SalMediaDescription *md) { - MSList *pt_it; + bctbx_list_t *pt_it; PayloadType *pt; PayloadTypeAvpfParams avpf_params; LinphoneCore *lc = call->core; @@ -683,7 +683,7 @@ static void force_streams_dir_according_to_state(LinphoneCall *call, SalMediaDes } void linphone_call_make_local_media_description(LinphoneCall *call) { - MSList *l; + bctbx_list_t *l; SalMediaDescription *old_md=call->localdesc; int i; int max_index = 0; @@ -770,7 +770,7 @@ void linphone_call_make_local_media_description(LinphoneCall *call) { } else { ms_message("Don't put audio stream on local offer for call [%p]",call); md->streams[call->main_audio_stream_index].dir = SalStreamInactive; - if(l) l=ms_list_free_with_data(l, (void (*)(void *))payload_type_destroy); + if(l) l=bctbx_list_free_with_data(l, (void (*)(void *))payload_type_destroy); } if (params->custom_sdp_media_attributes[LinphoneStreamTypeAudio]) md->streams[call->main_audio_stream_index].custom_sdp_attributes = sal_custom_sdp_attribute_clone(params->custom_sdp_media_attributes[LinphoneStreamTypeAudio]); @@ -805,7 +805,7 @@ void linphone_call_make_local_media_description(LinphoneCall *call) { } else { ms_message("Don't put video stream on local offer for call [%p]",call); md->streams[call->main_video_stream_index].dir = SalStreamInactive; - if(l) l=ms_list_free_with_data(l, (void (*)(void *))payload_type_destroy); + if(l) l=bctbx_list_free_with_data(l, (void (*)(void *))payload_type_destroy); } if (params->custom_sdp_media_attributes[LinphoneStreamTypeVideo]) md->streams[call->main_video_stream_index].custom_sdp_attributes = sal_custom_sdp_attribute_clone(params->custom_sdp_media_attributes[LinphoneStreamTypeVideo]); @@ -877,7 +877,7 @@ void linphone_call_make_local_media_description(LinphoneCall *call) { static int find_port_offset(LinphoneCore *lc, int stream_index, int base_port){ int offset; - MSList *elem; + bctbx_list_t *elem; int tried_port; int existing_port; bool_t already_used=FALSE; @@ -903,7 +903,7 @@ static int find_port_offset(LinphoneCore *lc, int stream_index, int base_port){ } static int select_random_port(LinphoneCore *lc, int stream_index, int min_port, int max_port) { - MSList *elem; + bctbx_list_t *elem; int nb_tries; int tried_port = 0; int existing_port = 0; @@ -2708,14 +2708,14 @@ static void parametrize_equalizer(LinphoneCore *lc, AudioStream *st){ const char *gains=lp_config_get_string(lc->config,"sound","mic_eq_gains",NULL); ms_filter_call_method(f,MS_EQUALIZER_SET_ACTIVE,&enabled); if (enabled && gains){ - MSList *gains_list = ms_parse_equalizer_string(gains); - MSList *it; + bctbx_list_t *gains_list = ms_parse_equalizer_string(gains); + bctbx_list_t *it; for(it=gains_list; it; it=it->next) { MSEqualizerGain *g = (MSEqualizerGain *)it->data; ms_message("Read microphone equalizer gains: %f(~%f) --> %f",g->frequency,g->width,g->gain); ms_filter_call_method(f,MS_EQUALIZER_SET_GAIN, g); } - if(gains_list) ms_list_free_with_data(gains_list, ms_free); + if(gains_list) bctbx_list_free_with_data(gains_list, ms_free); } } if (st->spk_equalizer){ @@ -2724,14 +2724,14 @@ static void parametrize_equalizer(LinphoneCore *lc, AudioStream *st){ const char *gains=lp_config_get_string(lc->config,"sound","spk_eq_gains",NULL); ms_filter_call_method(f,MS_EQUALIZER_SET_ACTIVE,&enabled); if (enabled && gains){ - MSList *gains_list = ms_parse_equalizer_string(gains); - MSList *it; + bctbx_list_t *gains_list = ms_parse_equalizer_string(gains); + bctbx_list_t *it; for(it=gains_list; it; it=it->next) { MSEqualizerGain *g = (MSEqualizerGain *)it->data; ms_message("Read speaker equalizer gains: %f(~%f) --> %f",g->frequency,g->width,g->gain); ms_filter_call_method(f,MS_EQUALIZER_SET_GAIN, g); } - if(gains_list) ms_list_free_with_data(gains_list, ms_free); + if(gains_list) bctbx_list_free_with_data(gains_list, ms_free); } } } @@ -2864,7 +2864,7 @@ static int get_video_bw(LinphoneCall *call, const SalMediaDescription *md, const static RtpProfile *make_profile(LinphoneCall *call, const SalMediaDescription *md, const SalStreamDescription *desc, int *used_pt){ int bw=0; - const MSList *elem; + const bctbx_list_t *elem; RtpProfile *prof=rtp_profile_new("Call profile"); bool_t first=TRUE; LinphoneCore *lc=call->core; @@ -4640,16 +4640,16 @@ void linphone_call_log_completed(LinphoneCall *call){ } #endif if (!call_logs_sqlite_db_found) { - lc->call_logs=ms_list_prepend(lc->call_logs,linphone_call_log_ref(call->log)); - if (ms_list_size(lc->call_logs)>(size_t)lc->max_call_logs){ - MSList *elem,*prevelem=NULL; + lc->call_logs=bctbx_list_prepend(lc->call_logs,linphone_call_log_ref(call->log)); + if (bctbx_list_size(lc->call_logs)>(size_t)lc->max_call_logs){ + bctbx_list_t *elem,*prevelem=NULL; /*find the last element*/ for(elem=lc->call_logs;elem!=NULL;elem=elem->next){ prevelem=elem; } elem=prevelem; linphone_call_log_unref((LinphoneCallLog*)elem->data); - lc->call_logs=ms_list_remove_link(lc->call_logs,elem); + lc->call_logs=bctbx_list_remove_link(lc->call_logs,elem); } call_logs_write_to_config_file(lc); } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index d30f5f49f..1c5bf1f9d 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -801,8 +801,8 @@ static void build_sound_devices_table(LinphoneCore *lc){ const char **old; int ndev; int i; - const MSList *elem=ms_snd_card_manager_get_list(ms_factory_get_snd_card_manager(lc->factory)); - ndev=ms_list_size(elem); + const bctbx_list_t *elem=ms_snd_card_manager_get_list(ms_factory_get_snd_card_manager(lc->factory)); + ndev=bctbx_list_size(elem); devices=ms_malloc((ndev+1)*sizeof(const char *)); for (i=0;elem!=NULL;elem=elem->next,i++){ devices[i]=ms_snd_card_get_string_id((MSSndCard *)elem->data); @@ -1142,10 +1142,10 @@ static void rtp_config_read(LinphoneCore *lc) linphone_core_enable_video_multicast(lc,tmp_int); } -static PayloadType * find_payload(const MSList *default_list, const char *mime_type, int clock_rate, int channels, const char *recv_fmtp){ +static PayloadType * find_payload(const bctbx_list_t *default_list, const char *mime_type, int clock_rate, int channels, const char *recv_fmtp){ PayloadType *candidate=NULL; PayloadType *it; - const MSList *elem; + const bctbx_list_t *elem; for(elem=default_list;elem!=NULL;elem=elem->next){ it=(PayloadType*)elem->data; @@ -1170,8 +1170,8 @@ static PayloadType * find_payload(const MSList *default_list, const char *mime_t return candidate; } -static PayloadType* find_payload_type_from_list(const char* type, int rate, int channels, const MSList* from) { - const MSList *elem; +static PayloadType* find_payload_type_from_list(const char* type, int rate, int channels, const bctbx_list_t* from) { + const bctbx_list_t *elem; for(elem=from;elem!=NULL;elem=elem->next){ PayloadType *pt=(PayloadType*)elem->data; if ((strcasecmp(type, payload_type_get_mime(pt)) == 0) @@ -1215,7 +1215,7 @@ static bool_t get_codec(LinphoneCore *lc, SalStreamType type, int index, Payload } pt = find_payload(type == SalAudio ? lc->default_audio_codecs : type == SalVideo ? lc->default_video_codecs : lc->default_text_codecs ,mime,rate,channels,fmtp); if (!pt){ - MSList **default_list = (type==SalAudio) ? &lc->default_audio_codecs : type == SalVideo ? &lc->default_video_codecs : &lc->default_text_codecs; + bctbx_list_t **default_list = (type==SalAudio) ? &lc->default_audio_codecs : type == SalVideo ? &lc->default_video_codecs : &lc->default_text_codecs; if (type == SalAudio) ms_warning("Codec %s/%i/%i read from conf is not in the default list.",mime,rate,channels); else if (type == SalVideo) @@ -1229,7 +1229,7 @@ static bool_t get_codec(LinphoneCore *lc, SalStreamType type, int index, Payload pt->channels=channels; payload_type_set_number(pt,-1); /*dynamic assignment*/ payload_type_set_recv_fmtp(pt,fmtp); - *default_list=ms_list_append(*default_list, pt); + *default_list=bctbx_list_append(*default_list, pt); } if (enabled ) pt->flags|=PAYLOAD_TYPE_ENABLED; else pt->flags&=~PAYLOAD_TYPE_ENABLED; @@ -1256,23 +1256,23 @@ static SalStreamType payload_type_get_stream_type(const PayloadType *pt){ /*this function merges the payload types from the codec default list with the list read from configuration file. * If a new codec becomes supported in Liblinphone or if the list from configuration file is empty or incomplete, all the supported codecs are added * automatically. This 'l' list is entirely destroyed and rewritten.*/ -static MSList *add_missing_supported_codecs(LinphoneCore *lc, const MSList *default_list, MSList *l){ - const MSList *elem; - MSList *newlist; +static bctbx_list_t *add_missing_supported_codecs(LinphoneCore *lc, const bctbx_list_t *default_list, bctbx_list_t *l){ + const bctbx_list_t *elem; + bctbx_list_t *newlist; PayloadType *last_seen = NULL; for(elem=default_list; elem!=NULL; elem=elem->next){ - MSList *elem2=ms_list_find(l,elem->data); + bctbx_list_t *elem2=bctbx_list_find(l,elem->data); if (!elem2){ PayloadType *pt=(PayloadType*)elem->data; /*this codec from default list should be inserted in the list, with respect to the default_list order*/ if (!linphone_core_codec_supported(lc, payload_type_get_stream_type(pt), pt->mime_type)) continue; if (!last_seen){ - l=ms_list_prepend(l,pt); + l=bctbx_list_prepend(l,pt); }else{ - const MSList *after=ms_list_find(l,last_seen); - l=ms_list_insert(l, after->next, pt); + const bctbx_list_t *after=bctbx_list_find(l,last_seen); + l=bctbx_list_insert(l, after->next, pt); } last_seen = pt; ms_message("Supported codec %s/%i fmtp=%s automatically added to codec list.", pt->mime_type, @@ -1281,8 +1281,8 @@ static MSList *add_missing_supported_codecs(LinphoneCore *lc, const MSList *defa last_seen = (PayloadType*)elem2->data; } } - newlist=ms_list_copy_with_data(l,(void *(*)(void*))payload_type_clone); - ms_list_free(l); + newlist=bctbx_list_copy_with_data(l,(void *(*)(void*))payload_type_clone); + bctbx_list_free(l); return newlist; } @@ -1290,10 +1290,10 @@ static MSList *add_missing_supported_codecs(LinphoneCore *lc, const MSList *defa * This function adds missing codecs, if required by configuration. * This 'l' list is entirely destroyed and a new list is returned. */ -static MSList *handle_missing_codecs(LinphoneCore *lc, const MSList *default_list, MSList *l, MSFormatType ft){ +static bctbx_list_t *handle_missing_codecs(LinphoneCore *lc, const bctbx_list_t *default_list, bctbx_list_t *l, MSFormatType ft){ const char *name = "unknown"; int add_missing; - MSList *ret; + bctbx_list_t *ret; switch(ft){ case MSAudio: @@ -1312,29 +1312,29 @@ static MSList *handle_missing_codecs(LinphoneCore *lc, const MSList *default_lis if (add_missing){ ret = add_missing_supported_codecs(lc, default_list, l); }else{ - ret = ms_list_copy_with_data(l,(void *(*)(void*))payload_type_clone); - ms_list_free(l); + ret = bctbx_list_copy_with_data(l,(void *(*)(void*))payload_type_clone); + bctbx_list_free(l); } return ret; } -static MSList *codec_append_if_new(MSList *l, PayloadType *pt){ - MSList *elem; +static bctbx_list_t *codec_append_if_new(bctbx_list_t *l, PayloadType *pt){ + bctbx_list_t *elem; for (elem=l;elem!=NULL;elem=elem->next){ PayloadType *ept=(PayloadType*)elem->data; if (pt==ept) return l; } - l=ms_list_append(l,pt); + l=bctbx_list_append(l,pt); return l; } static void codecs_config_read(LinphoneCore *lc){ int i; PayloadType *pt; - MSList *audio_codecs=NULL; - MSList *video_codecs=NULL; - MSList *text_codecs=NULL; + bctbx_list_t *audio_codecs=NULL; + bctbx_list_t *video_codecs=NULL; + bctbx_list_t *text_codecs=NULL; lc->codecs_conf.dyn_pt=96; lc->codecs_conf.telephone_event_pt=lp_config_get_int(lc->config,"misc","telephone_event_pt",101); @@ -1368,7 +1368,7 @@ static void codecs_config_read(LinphoneCore *lc){ } static void build_video_devices_table(LinphoneCore *lc){ - const MSList *elem; + const bctbx_list_t *elem; int i; int ndev; const char **devices; @@ -1376,7 +1376,7 @@ static void build_video_devices_table(LinphoneCore *lc){ ms_free((void *)lc->video_conf.cams); /* retrieve all video devices */ elem=ms_web_cam_manager_get_list(ms_factory_get_web_cam_manager(lc->factory)); - ndev=ms_list_size(elem); + ndev=bctbx_list_size(elem); devices=ms_malloc((ndev+1)*sizeof(const char *)); for (i=0;elem!=NULL;elem=elem->next,i++){ devices[i]=ms_web_cam_get_string_id((MSWebCam *)elem->data); @@ -1514,7 +1514,7 @@ int linphone_core_get_sip_transport_timeout(LinphoneCore *lc) { return sal_get_transport_timeout(lc->sal); } -void linphone_core_set_dns_servers(LinphoneCore *lc, const MSList *servers){ +void linphone_core_set_dns_servers(LinphoneCore *lc, const bctbx_list_t *servers){ sal_set_dns_servers(lc->sal, servers); } @@ -1556,7 +1556,7 @@ const char * linphone_core_get_version(void){ } static void linphone_core_register_payload_type(LinphoneCore *lc, const PayloadType *const_pt, const char *recv_fmtp, bool_t enabled){ - MSList **codec_list = const_pt->type==PAYLOAD_VIDEO ? &lc->default_video_codecs : const_pt->type==PAYLOAD_TEXT ? &lc->default_text_codecs : &lc->default_audio_codecs; + bctbx_list_t **codec_list = const_pt->type==PAYLOAD_VIDEO ? &lc->default_video_codecs : const_pt->type==PAYLOAD_TEXT ? &lc->default_text_codecs : &lc->default_audio_codecs; PayloadType *pt=payload_type_clone(const_pt); int number=-1; payload_type_set_enable(pt,enabled); @@ -1568,7 +1568,7 @@ static void linphone_core_register_payload_type(LinphoneCore *lc, const PayloadT ); ms_message("Codec %s/%i fmtp=[%s] number=%i, enabled=%i) added to the list of possible codecs.", pt->mime_type, pt->clock_rate, pt->recv_fmtp ? pt->recv_fmtp : "", number, (int)payload_type_enabled(pt)); - *codec_list=ms_list_append(*codec_list,pt); + *codec_list=bctbx_list_append(*codec_list,pt); } static void linphone_core_register_static_payloads(LinphoneCore *lc){ @@ -1590,9 +1590,9 @@ static void linphone_core_register_static_payloads(LinphoneCore *lc){ } static void linphone_core_free_payload_types(LinphoneCore *lc){ - ms_list_free_with_data(lc->default_audio_codecs, (void (*)(void*))payload_type_destroy); - ms_list_free_with_data(lc->default_video_codecs, (void (*)(void*))payload_type_destroy); - ms_list_free_with_data(lc->default_text_codecs, (void (*)(void*))payload_type_destroy); + bctbx_list_free_with_data(lc->default_audio_codecs, (void (*)(void*))payload_type_destroy); + bctbx_list_free_with_data(lc->default_video_codecs, (void (*)(void*))payload_type_destroy); + bctbx_list_free_with_data(lc->default_text_codecs, (void (*)(void*))payload_type_destroy); } void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const char *message){ @@ -1756,7 +1756,7 @@ static void linphone_core_register_default_codecs(LinphoneCore *lc){ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *notified_event, const LinphoneContent *body) { if (strcmp(notified_event, "Presence") == 0) { - const MSList* friendLists = linphone_core_get_friends_lists(lc); + const bctbx_list_t* friendLists = linphone_core_get_friends_lists(lc); while( friendLists != NULL ){ LinphoneFriendList* list = friendLists->data; ms_message("notify presence for list %p", list); @@ -1854,17 +1854,17 @@ LinphoneCore *linphone_core_new_with_config(const LinphoneCoreVTable *vtable, st return core; } -const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc) +const bctbx_list_t *linphone_core_get_audio_codecs(const LinphoneCore *lc) { return lc->codecs_conf.audio_codecs; } -const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc) +const bctbx_list_t *linphone_core_get_video_codecs(const LinphoneCore *lc) { return lc->codecs_conf.video_codecs; } -const MSList *linphone_core_get_text_codecs(const LinphoneCore *lc) +const bctbx_list_t *linphone_core_get_text_codecs(const LinphoneCore *lc) { return lc->codecs_conf.text_codecs; } @@ -1981,8 +1981,8 @@ LinphoneAddress *linphone_core_get_primary_contact_parsed(LinphoneCore *lc){ * The list is taken by the LinphoneCore thus the application should not free it. * This list is made of struct PayloadType describing the codec parameters. **/ -int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs){ - if (lc->codecs_conf.audio_codecs!=NULL) ms_list_free(lc->codecs_conf.audio_codecs); +int linphone_core_set_audio_codecs(LinphoneCore *lc, bctbx_list_t *codecs){ + if (lc->codecs_conf.audio_codecs!=NULL) bctbx_list_free(lc->codecs_conf.audio_codecs); lc->codecs_conf.audio_codecs=codecs; _linphone_core_codec_config_write(lc); linphone_core_update_allocated_audio_bandwidth(lc); @@ -1999,16 +1999,16 @@ int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs){ * The list is taken by the LinphoneCore thus the application should not free it. * This list is made of struct PayloadType describing the codec parameters. **/ -int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs){ - if (lc->codecs_conf.video_codecs!=NULL) ms_list_free(lc->codecs_conf.video_codecs); +int linphone_core_set_video_codecs(LinphoneCore *lc, bctbx_list_t *codecs){ + if (lc->codecs_conf.video_codecs!=NULL) bctbx_list_free(lc->codecs_conf.video_codecs); lc->codecs_conf.video_codecs=codecs; _linphone_core_codec_config_write(lc); return 0; } -int linphone_core_set_text_codecs(LinphoneCore *lc, MSList *codecs) { +int linphone_core_set_text_codecs(LinphoneCore *lc, bctbx_list_t *codecs) { if (lc->codecs_conf.text_codecs != NULL) - ms_list_free(lc->codecs_conf.text_codecs); + bctbx_list_free(lc->codecs_conf.text_codecs); lc->codecs_conf.text_codecs = codecs; _linphone_core_codec_config_write(lc); @@ -2034,8 +2034,8 @@ bool_t linphone_core_generic_confort_noise_enabled(const LinphoneCore *lc){ return lp_config_get_int(lc->config, "misc", "use_cn", FALSE); } -const MSList* linphone_core_get_friend_list(const LinphoneCore *lc) { - MSList *lists = lc->friends_lists; +const bctbx_list_t* linphone_core_get_friend_list(const LinphoneCore *lc) { + bctbx_list_t *lists = lc->friends_lists; if (lists) { LinphoneFriendList *list = (LinphoneFriendList *)lists->data; if (list) { @@ -2045,7 +2045,7 @@ const MSList* linphone_core_get_friend_list(const LinphoneCore *lc) { return NULL; } -const MSList* linphone_core_get_friends_lists(const LinphoneCore *lc) { +const bctbx_list_t* linphone_core_get_friends_lists(const LinphoneCore *lc) { return lc->friends_lists; } @@ -2057,7 +2057,7 @@ LinphoneFriendList* linphone_core_get_default_friend_list(const LinphoneCore *lc } void linphone_core_remove_friend_list(LinphoneCore *lc, LinphoneFriendList *list) { - MSList *elem = ms_list_find(lc->friends_lists, list); + bctbx_list_t *elem = bctbx_list_find(lc->friends_lists, list); if (elem == NULL) return; #ifdef SQLITE_STORAGE_ENABLED linphone_core_remove_friends_list_from_db(lc, list); @@ -2065,7 +2065,7 @@ void linphone_core_remove_friend_list(LinphoneCore *lc, LinphoneFriendList *list linphone_core_notify_friend_list_removed(lc, list); list->lc = NULL; linphone_friend_list_unref(list); - lc->friends_lists = ms_list_remove_link(lc->friends_lists, elem); + lc->friends_lists = bctbx_list_remove_link(lc->friends_lists, elem); } void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFriendList *list) { @@ -2073,7 +2073,7 @@ void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFriendList *list) { if (!list->lc) { list->lc = lc; } - lc->friends_lists = ms_list_append(lc->friends_lists, linphone_friend_list_ref(list)); + lc->friends_lists = bctbx_list_append(lc->friends_lists, linphone_friend_list_ref(list)); #ifdef SQLITE_STORAGE_ENABLED linphone_core_store_friends_list_in_db(lc, list); #endif @@ -2085,7 +2085,7 @@ void linphone_core_add_friend_list(LinphoneCore *lc, LinphoneFriendList *list) { if (rls_uri && lp_config_get_int(lc->config, "sip", "use_rls_presence", 0)) { linphone_friend_list_set_rls_uri(list, rls_uri); } - lc->friends_lists = ms_list_append(lc->friends_lists, linphone_friend_list_ref(list)); + lc->friends_lists = bctbx_list_append(lc->friends_lists, linphone_friend_list_ref(list)); linphone_friend_list_unref(list); } } @@ -2209,7 +2209,7 @@ bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc){ static void apply_jitter_value(LinphoneCore *lc, int value, MSFormatType stype){ LinphoneCall *call; - MSList *it; + bctbx_list_t *it; for (it=lc->calls;it!=NULL;it=it->next){ MediaStream *ms; call=(LinphoneCall*)it->data; @@ -2620,13 +2620,13 @@ static void monitor_network_state(LinphoneCore *lc, time_t curtime){ } static void proxy_update(LinphoneCore *lc){ - MSList *elem,*next; - ms_list_for_each(lc->sip_conf.proxies,(void (*)(void*))&linphone_proxy_config_update); + bctbx_list_t *elem,*next; + bctbx_list_for_each(lc->sip_conf.proxies,(void (*)(void*))&linphone_proxy_config_update); for(elem=lc->sip_conf.deleted_proxies;elem!=NULL;elem=next){ LinphoneProxyConfig* cfg = (LinphoneProxyConfig*)elem->data; next=elem->next; if (ms_time(NULL) - cfg->deletion_date > 32) { - lc->sip_conf.deleted_proxies =ms_list_remove_link(lc->sip_conf.deleted_proxies,elem); + lc->sip_conf.deleted_proxies =bctbx_list_remove_link(lc->sip_conf.deleted_proxies,elem); ms_message("Proxy config for [%s] is definitely removed from core.",linphone_proxy_config_get_addr(cfg)); _linphone_proxy_config_release_ops(cfg); linphone_proxy_config_unref(cfg); @@ -2646,14 +2646,14 @@ static void assign_buddy_info(LinphoneCore *lc, BuddyInfo *info){ } static void analyze_buddy_lookup_results(LinphoneCore *lc, LinphoneProxyConfig *cfg){ - MSList *elem; + bctbx_list_t *elem; SipSetupContext *ctx=linphone_proxy_config_get_sip_setup_context(cfg); - for (elem=lc->bl_reqs;elem!=NULL;elem=ms_list_next(elem)){ + for (elem=lc->bl_reqs;elem!=NULL;elem=bctbx_list_next(elem)){ BuddyLookupRequest *req=(BuddyLookupRequest *)elem->data; if (req->status==BuddyLookupDone || req->status==BuddyLookupFailure){ if (req->results!=NULL){ BuddyInfo *i=(BuddyInfo*)req->results->data; - ms_list_free(req->results); + bctbx_list_free(req->results); req->results=NULL; assign_buddy_info(lc,i); } @@ -2662,13 +2662,13 @@ static void analyze_buddy_lookup_results(LinphoneCore *lc, LinphoneProxyConfig * } } /*purge completed requests */ - while((elem=ms_list_find(lc->bl_reqs,NULL))!=NULL){ - lc->bl_reqs=ms_list_remove_link(lc->bl_reqs,elem); + while((elem=bctbx_list_find(lc->bl_reqs,NULL))!=NULL){ + lc->bl_reqs=bctbx_list_remove_link(lc->bl_reqs,elem); } } static void linphone_core_grab_buddy_infos(LinphoneCore *lc, LinphoneProxyConfig *cfg){ - const MSList *elem; + const bctbx_list_t *elem; SipSetupContext *ctx=linphone_proxy_config_get_sip_setup_context(cfg); for(elem=linphone_core_get_friend_list(lc);elem!=NULL;elem=elem->next){ LinphoneFriend *lf=(LinphoneFriend*)elem->data; @@ -2681,7 +2681,7 @@ static void linphone_core_grab_buddy_infos(LinphoneCore *lc, LinphoneProxyConfig buddy_lookup_request_set_key(req,tmp); buddy_lookup_request_set_max_results(req,1); sip_setup_context_buddy_lookup_submit(ctx,req); - lc->bl_reqs=ms_list_append(lc->bl_reqs,req); + lc->bl_reqs=bctbx_list_append(lc->bl_reqs,req); ms_free(tmp); } } @@ -2718,7 +2718,7 @@ static void linphone_core_do_plugin_tasks(LinphoneCore *lc){ * serialized with a mutex. **/ void linphone_core_iterate(LinphoneCore *lc){ - MSList *calls; + bctbx_list_t *calls; LinphoneCall *call; uint64_t curtime_ms = ms_get_cur_time_ms(); /*monotonic time*/ int elapsed; @@ -2873,11 +2873,11 @@ void linphone_core_iterate(LinphoneCore *lc){ } if (one_second_elapsed) { - MSList *elem = NULL; + bctbx_list_t *elem = NULL; if (lp_config_needs_commit(lc->config)) { lp_config_sync(lc->config); } - for (elem = lc->friends_lists; elem != NULL; elem = ms_list_next(elem)) { + for (elem = lc->friends_lists; elem != NULL; elem = bctbx_list_next(elem)) { LinphoneFriendList *list = (LinphoneFriendList *)elem->data; if (list->dirty_friends_to_update) { linphone_friend_list_update_dirty_friends(list); @@ -2984,29 +2984,29 @@ void linphone_core_notify_refer_state(LinphoneCore *lc, LinphoneCall *referer, L system. */ -static MSList *make_routes_for_proxy(LinphoneProxyConfig *proxy, const LinphoneAddress *dest){ - MSList *ret=NULL; +static bctbx_list_t *make_routes_for_proxy(LinphoneProxyConfig *proxy, const LinphoneAddress *dest){ + bctbx_list_t *ret=NULL; const char *local_route=linphone_proxy_config_get_route(proxy); const LinphoneAddress *srv_route=linphone_proxy_config_get_service_route(proxy); if (local_route){ - ret=ms_list_append(ret,sal_address_new(local_route)); + ret=bctbx_list_append(ret,sal_address_new(local_route)); } if (srv_route){ - ret=ms_list_append(ret,sal_address_clone((SalAddress*)srv_route)); + ret=bctbx_list_append(ret,sal_address_clone((SalAddress*)srv_route)); } if (ret==NULL){ /*if the proxy address matches the domain part of the destination, then use the same transport * as the one used for registration. This is done by forcing a route to this proxy.*/ SalAddress *proxy_addr=sal_address_new(linphone_proxy_config_get_addr(proxy)); if (strcmp(sal_address_get_domain(proxy_addr),linphone_address_get_domain(dest))==0){ - ret=ms_list_append(ret,proxy_addr); + ret=bctbx_list_append(ret,proxy_addr); }else sal_address_destroy(proxy_addr); } return ret; } LinphoneProxyConfig * linphone_core_lookup_known_proxy(LinphoneCore *lc, const LinphoneAddress *uri){ - const MSList *elem; + const bctbx_list_t *elem; LinphoneProxyConfig *found_cfg=NULL; LinphoneProxyConfig *found_reg_cfg=NULL; LinphoneProxyConfig *found_noreg_cfg=NULL; @@ -3221,18 +3221,18 @@ LinphoneCall * linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddr return call; } -static void linphone_transfer_routes_to_op(MSList *routes, SalOp *op){ - MSList *it; +static void linphone_transfer_routes_to_op(bctbx_list_t *routes, SalOp *op){ + bctbx_list_t *it; for(it=routes;it!=NULL;it=it->next){ SalAddress *addr=(SalAddress*)it->data; sal_op_add_route_address(op,addr); sal_address_destroy(addr); } - ms_list_free(routes); + bctbx_list_free(routes); } void linphone_configure_op(LinphoneCore *lc, SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact){ - MSList *routes=NULL; + bctbx_list_t *routes=NULL; LinphoneProxyConfig *proxy=linphone_core_lookup_known_proxy(lc,dest); const char *identity; if (proxy){ @@ -3446,7 +3446,7 @@ void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call){ linphone_core_notify_display_status(lc,barmesg); /* play the ring if this is the only call*/ - if (ms_list_size(lc->calls)==1){ + if (bctbx_list_size(lc->calls)==1){ MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard; lc->current_call=call; if (lc->ringstream && lc->dmfs_playing_start_time!=0){ @@ -3858,7 +3858,7 @@ int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, SalOp *replaced; SalMediaDescription *new_md; bool_t was_ringing=FALSE; - MSList * iterator, *copy; + bctbx_list_t * iterator, *copy; if (call==NULL){ //if just one call is present answer the only one ... @@ -3880,7 +3880,7 @@ int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, } - for (iterator=copy=ms_list_copy(linphone_core_get_calls(lc));iterator!=NULL;iterator=iterator->next) { + for (iterator=copy=bctbx_list_copy(linphone_core_get_calls(lc));iterator!=NULL;iterator=iterator->next) { LinphoneCall *a_call=(LinphoneCall*)iterator->data; if (a_call==call) continue; switch(a_call->state){ @@ -3897,7 +3897,7 @@ int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call, break; /*nothing to do*/ } } - ms_list_free(copy); + bctbx_list_free(copy); /* check if this call is supposed to replace an already running one*/ replaced=sal_call_get_replaces(call->op); @@ -4035,7 +4035,7 @@ int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *the_call) LinphoneCall *call; if (the_call == NULL){ call = linphone_core_get_current_call(lc); - if (ms_list_size(lc->calls)==1){ + if (bctbx_list_size(lc->calls)==1){ call=(LinphoneCall*)lc->calls->data; }else{ ms_warning("No unique call to terminate !"); @@ -4097,7 +4097,7 @@ int linphone_core_decline_call(LinphoneCore *lc, LinphoneCall * call, LinphoneRe * @param lc The LinphoneCore **/ int linphone_core_terminate_all_calls(LinphoneCore *lc){ - MSList *calls=lc->calls; + bctbx_list_t *calls=lc->calls; while(calls) { LinphoneCall *c=(LinphoneCall*)calls->data; calls=calls->next; @@ -4117,7 +4117,7 @@ int linphone_core_terminate_all_calls(LinphoneCore *lc){ * * @ingroup call_control **/ -const MSList *linphone_core_get_calls(LinphoneCore *lc) +const bctbx_list_t *linphone_core_get_calls(LinphoneCore *lc) { return lc->calls; } @@ -4193,7 +4193,7 @@ int _linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call){ * @ingroup call_control **/ int linphone_core_pause_all_calls(LinphoneCore *lc){ - const MSList *elem; + const bctbx_list_t *elem; for(elem=lc->calls;elem!=NULL;elem=elem->next){ LinphoneCall *call=(LinphoneCall *)elem->data; LinphoneCallState cs=linphone_call_get_state(call); @@ -4308,7 +4308,7 @@ LinphoneCall *linphone_core_get_call_by_remote_address(LinphoneCore *lc, const c return call; } LinphoneCall *linphone_core_get_call_by_remote_address2(LinphoneCore *lc, const LinphoneAddress *raddr){ - MSList *elem=ms_list_find_custom(lc->calls,(int (*)(const void*,const void *))remote_address_compare,raddr); + bctbx_list_t *elem=bctbx_list_find_custom(lc->calls,(int (*)(const void*,const void *))remote_address_compare,raddr); if (elem) return (LinphoneCall*) elem->data; return NULL; @@ -4317,8 +4317,8 @@ LinphoneCall *linphone_core_get_call_by_remote_address2(LinphoneCore *lc, const int linphone_core_send_publish(LinphoneCore *lc, LinphonePresenceModel *presence) { - const MSList *elem; - for (elem=linphone_core_get_proxy_config_list(lc);elem!=NULL;elem=ms_list_next(elem)){ + const bctbx_list_t *elem; + for (elem=linphone_core_get_proxy_config_list(lc);elem!=NULL;elem=bctbx_list_next(elem)){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; if (cfg->publish) linphone_proxy_config_send_publish(cfg,presence); } @@ -4671,7 +4671,7 @@ static MSSndCard *get_card_from_string_id(const char *devid, unsigned int cap, M sndcard=ms_snd_card_manager_get_default_playback_card(ms_factory_get_snd_card_manager(f)); } if (sndcard==NULL){/*looks like a bug! take the first one !*/ - const MSList *elem=ms_snd_card_manager_get_list(ms_factory_get_snd_card_manager(f)); + const bctbx_list_t *elem=ms_snd_card_manager_get_list(ms_factory_get_snd_card_manager(f)); if (elem) sndcard=(MSSndCard*)elem->data; } } @@ -5065,8 +5065,8 @@ bool_t linphone_core_is_mic_muted(LinphoneCore *lc) { void linphone_core_enable_mic(LinphoneCore *lc, bool_t enable) { LinphoneCall *call; - const MSList *list; - const MSList *elem; + const bctbx_list_t *list; + const bctbx_list_t *elem; if (linphone_core_is_in_conference(lc)){ linphone_conference_mute_microphone(lc->conf_ctx, !enable); @@ -5342,7 +5342,7 @@ void linphone_core_set_call_logs_database_path(LinphoneCore *lc, const char *pat } } -const MSList* linphone_core_get_call_logs(LinphoneCore *lc) { +const bctbx_list_t* linphone_core_get_call_logs(LinphoneCore *lc) { #ifdef SQLITE_STORAGE_ENABLED if (lc->logs_db) { linphone_core_get_call_history(lc); @@ -5361,8 +5361,8 @@ void linphone_core_clear_call_logs(LinphoneCore *lc) { } #endif if (!call_logs_sqlite_db_found) { - ms_list_for_each(lc->call_logs, (void (*)(void*))linphone_call_log_unref); - lc->call_logs = ms_list_free(lc->call_logs); + bctbx_list_for_each(lc->call_logs, (void (*)(void*))linphone_call_log_unref); + lc->call_logs = bctbx_list_free(lc->call_logs); call_logs_write_to_config_file(lc); } } @@ -5384,14 +5384,14 @@ void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *cl) { } #endif if (!call_logs_sqlite_db_found) { - lc->call_logs = ms_list_remove(lc->call_logs, cl); + lc->call_logs = bctbx_list_remove(lc->call_logs, cl); call_logs_write_to_config_file(lc); linphone_call_log_unref(cl); } } void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { - MSList *logs_to_migrate = NULL; + bctbx_list_t *logs_to_migrate = NULL; LpConfig *lpc = NULL; int original_logs_count, migrated_logs_count; int i; @@ -5415,7 +5415,7 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { } // This is because there must have been a call previously to linphone_core_call_log_storage_init - lc->call_logs = ms_list_free_with_data(lc->call_logs, (void (*)(void*))linphone_call_log_unref); + lc->call_logs = bctbx_list_free_with_data(lc->call_logs, (void (*)(void*))linphone_call_log_unref); call_logs_read_from_config_file(lc); if (!lc->call_logs) { @@ -5425,17 +5425,17 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { logs_to_migrate = lc->call_logs; lc->call_logs = NULL; - // We can't use ms_list_for_each because logs_to_migrate are listed in the wrong order (latest first), and we want to store the logs latest last - for (i = ms_list_size(logs_to_migrate) - 1; i >= 0; i--) { - LinphoneCallLog *log = (LinphoneCallLog *) ms_list_nth_data(logs_to_migrate, i); + // We can't use bctbx_list_for_each because logs_to_migrate are listed in the wrong order (latest first), and we want to store the logs latest last + for (i = bctbx_list_size(logs_to_migrate) - 1; i >= 0; i--) { + LinphoneCallLog *log = (LinphoneCallLog *) bctbx_list_nth_data(logs_to_migrate, i); linphone_core_store_call_log(lc, log); } - original_logs_count = ms_list_size(logs_to_migrate); - migrated_logs_count = ms_list_size(lc->call_logs); + original_logs_count = bctbx_list_size(logs_to_migrate); + migrated_logs_count = bctbx_list_size(lc->call_logs); if (original_logs_count == migrated_logs_count) { int i = 0; - ms_debug("call logs migration successful: %u logs migrated", (unsigned int)ms_list_size(lc->call_logs)); + ms_debug("call logs migration successful: %u logs migrated", (unsigned int)bctbx_list_size(lc->call_logs)); lp_config_set_int(lpc, "misc", "call_logs_migration_done", 1); for (; i < original_logs_count; i++) { @@ -5447,7 +5447,7 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) { ms_error("not as many logs saved in db has logs read from rc (%i in rc against %i in db)!", original_logs_count, migrated_logs_count); } - ms_list_free_with_data(logs_to_migrate, (void (*)(void*))linphone_call_log_unref); + bctbx_list_free_with_data(logs_to_migrate, (void (*)(void*))linphone_call_log_unref); } @@ -5823,7 +5823,7 @@ void * linphone_core_get_native_video_window_id(const LinphoneCore *lc){ static void unset_video_window_id(LinphoneCore *lc, bool_t preview, void *id){ #ifdef VIDEO_ENABLED LinphoneCall *call; - MSList *elem; + bctbx_list_t *elem; #endif if ((id != NULL) @@ -6442,7 +6442,7 @@ void net_config_uninit(LinphoneCore *lc) void sip_config_uninit(LinphoneCore *lc) { - MSList *elem; + bctbx_list_t *elem; int i; sip_config_t *config=&lc->sip_conf; bool_t still_registered=TRUE; @@ -6456,7 +6456,7 @@ void sip_config_uninit(LinphoneCore *lc) lp_config_set_int(lc->config,"sip","register_only_when_upnp_is_ok",config->register_only_when_upnp_is_ok); if (lc->sip_network_reachable) { - for(elem=config->proxies;elem!=NULL;elem=ms_list_next(elem)){ + for(elem=config->proxies;elem!=NULL;elem=bctbx_list_next(elem)){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)(elem->data); _linphone_proxy_config_unpublish(cfg); /* to unpublish without changing the stored flag enable_publish */ _linphone_proxy_config_unregister(cfg); /* to unregister without changing the stored flag enable_register */ @@ -6467,7 +6467,7 @@ void sip_config_uninit(LinphoneCore *lc) for (i=0;i<20&&still_registered;i++){ still_registered=FALSE; sal_iterate(lc->sal); - for(elem=config->proxies;elem!=NULL;elem=ms_list_next(elem)){ + for(elem=config->proxies;elem!=NULL;elem=bctbx_list_next(elem)){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)(elem->data); LinphoneRegistrationState state = linphone_proxy_config_get_state(cfg); still_registered|=(state==LinphoneRegistrationOk||state==LinphoneRegistrationProgress); @@ -6476,13 +6476,13 @@ void sip_config_uninit(LinphoneCore *lc) } if (i>=20) ms_warning("Cannot complete unregistration, giving up"); } - config->proxies=ms_list_free_with_data(config->proxies,(void (*)(void*)) _linphone_proxy_config_release); + config->proxies=bctbx_list_free_with_data(config->proxies,(void (*)(void*)) _linphone_proxy_config_release); - config->deleted_proxies=ms_list_free_with_data(config->deleted_proxies,(void (*)(void*)) _linphone_proxy_config_release); + config->deleted_proxies=bctbx_list_free_with_data(config->deleted_proxies,(void (*)(void*)) _linphone_proxy_config_release); /*no longuer need to write proxy config if not changedlinphone_proxy_config_write_to_config_file(lc->config,NULL,i);*/ /*mark the end */ - lc->auth_info=ms_list_free_with_data(lc->auth_info,(void (*)(void*))linphone_auth_info_destroy); + lc->auth_info=bctbx_list_free_with_data(lc->auth_info,(void (*)(void*))linphone_auth_info_destroy); /*now that we are unregisted, we no longer need the tunnel.*/ #ifdef TUNNEL_ENABLED @@ -6553,7 +6553,7 @@ static void sound_config_uninit(LinphoneCore *lc) if (config->local_ring) ms_free(config->local_ring); if (config->remote_ring) ms_free(config->remote_ring); - lc->tones=ms_list_free_with_data(lc->tones, (void (*)(void*))linphone_tone_description_destroy); + lc->tones=bctbx_list_free_with_data(lc->tones, (void (*)(void*))linphone_tone_description_destroy); } static void video_config_uninit(LinphoneCore *lc) @@ -6569,11 +6569,11 @@ void _linphone_core_codec_config_write(LinphoneCore *lc){ if (linphone_core_ready(lc)){ PayloadType *pt; codecs_config_t *config=&lc->codecs_conf; - MSList *node; + bctbx_list_t *node; char key[50]; int index; index=0; - for(node=config->audio_codecs;node!=NULL;node=ms_list_next(node)){ + for(node=config->audio_codecs;node!=NULL;node=bctbx_list_next(node)){ pt=(PayloadType*)(node->data); sprintf(key,"audio_codec_%i",index); lp_config_set_string(lc->config,key,"mime",pt->mime_type); @@ -6586,7 +6586,7 @@ void _linphone_core_codec_config_write(LinphoneCore *lc){ lp_config_clean_section (lc->config,key); index=0; - for(node=config->video_codecs;node!=NULL;node=ms_list_next(node)){ + for(node=config->video_codecs;node!=NULL;node=bctbx_list_next(node)){ pt=(PayloadType*)(node->data); sprintf(key,"video_codec_%i",index); lp_config_set_string(lc->config,key,"mime",pt->mime_type); @@ -6603,17 +6603,17 @@ void _linphone_core_codec_config_write(LinphoneCore *lc){ static void codecs_config_uninit(LinphoneCore *lc) { _linphone_core_codec_config_write(lc); - ms_list_free_with_data(lc->codecs_conf.audio_codecs, (void (*)(void*))payload_type_destroy); - ms_list_free_with_data(lc->codecs_conf.video_codecs, (void (*)(void*))payload_type_destroy); - ms_list_free_with_data(lc->codecs_conf.text_codecs, (void (*)(void*))payload_type_destroy); + bctbx_list_free_with_data(lc->codecs_conf.audio_codecs, (void (*)(void*))payload_type_destroy); + bctbx_list_free_with_data(lc->codecs_conf.video_codecs, (void (*)(void*))payload_type_destroy); + bctbx_list_free_with_data(lc->codecs_conf.text_codecs, (void (*)(void*))payload_type_destroy); } void friends_config_uninit(LinphoneCore* lc) { ms_message("Destroying friends."); - lc->friends_lists = ms_list_free_with_data(lc->friends_lists, (void (*)(void*))_linphone_friend_list_release); + lc->friends_lists = bctbx_list_free_with_data(lc->friends_lists, (void (*)(void*))_linphone_friend_list_release); if (lc->subscribers) { - lc->subscribers = ms_list_free_with_data(lc->subscribers, (void (*)(void *))_linphone_friend_release); + lc->subscribers = bctbx_list_free_with_data(lc->subscribers, (void (*)(void *))_linphone_friend_release); } if (lc->presence_model) { linphone_presence_model_unref(lc->presence_model); @@ -6640,7 +6640,7 @@ LpConfig * linphone_core_create_lp_config(LinphoneCore *lc, const char *filename static void linphone_core_uninit(LinphoneCore *lc) { - MSList *elem = NULL; + bctbx_list_t *elem = NULL; int i=0; bool_t wait_until_unsubscribe = FALSE; linphone_task_list_free(&lc->hooks); @@ -6653,7 +6653,7 @@ static void linphone_core_uninit(LinphoneCore *lc) ms_usleep(10000); } - for (elem = lc->friends_lists; elem != NULL; elem = ms_list_next(elem)) { + for (elem = lc->friends_lists; elem != NULL; elem = bctbx_list_next(elem)) { LinphoneFriendList *list = (LinphoneFriendList *)elem->data; linphone_friend_list_enable_subscriptions(list,FALSE); if (list->event) @@ -6665,7 +6665,7 @@ static void linphone_core_uninit(LinphoneCore *lc) ms_usleep(10000); } - lc->chatrooms = ms_list_free_with_data(lc->chatrooms, (MSIterateFunc)linphone_chat_room_release); + lc->chatrooms = bctbx_list_free_with_data(lc->chatrooms, (MSIterateFunc)linphone_chat_room_release); linphone_core_set_state(lc,LinphoneGlobalShutdown,"Shutting down"); #ifdef VIDEO_ENABLED @@ -6699,11 +6699,11 @@ static void linphone_core_uninit(LinphoneCore *lc) lp_config_destroy(lc->config); lc->config = NULL; /* Mark the config as NULL to block further calls */ - ms_list_for_each(lc->call_logs,(void (*)(void*))linphone_call_log_unref); - lc->call_logs=ms_list_free(lc->call_logs); + bctbx_list_for_each(lc->call_logs,(void (*)(void*))linphone_call_log_unref); + lc->call_logs=bctbx_list_free(lc->call_logs); - ms_list_for_each(lc->last_recv_msg_ids,ms_free); - lc->last_recv_msg_ids=ms_list_free(lc->last_recv_msg_ids); + bctbx_list_for_each(lc->last_recv_msg_ids,ms_free); + lc->last_recv_msg_ids=bctbx_list_free(lc->last_recv_msg_ids); if(lc->zrtp_secrets_cache != NULL) { ms_free(lc->zrtp_secrets_cache); @@ -6738,7 +6738,7 @@ static void linphone_core_uninit(LinphoneCore *lc) linphone_core_set_state(lc,LinphoneGlobalOff,"Off"); linphone_core_deactivate_log_serialization_if_needed(); - ms_list_free_with_data(lc->vtable_refs,(void (*)(void *))v_table_reference_destroy); + bctbx_list_free_with_data(lc->vtable_refs,(void (*)(void *))v_table_reference_destroy); ms_factory_destroy(lc->factory); } @@ -6755,7 +6755,7 @@ static void stop_refreshing_proxy_config(bool_t is_sip_reachable, LinphoneProxyC } static void set_sip_network_reachable(LinphoneCore* lc,bool_t is_sip_reachable, time_t curtime){ // second get the list of available proxies - const MSList *elem = NULL; + const bctbx_list_t *elem = NULL; if (lc->sip_network_reachable==is_sip_reachable) return; // no change, ignore. lc->network_reachable_to_be_notified=TRUE; @@ -6779,7 +6779,7 @@ static void set_sip_network_reachable(LinphoneCore* lc,bool_t is_sip_reachable, linphone_core_invalidate_friend_subscriptions(lc); sal_reset_transports(lc->sal); /*mark all calls as broken, so that they can be either dropped immediately or restaured when network will be back*/ - ms_list_for_each(lc->calls, (MSIterateFunc) linphone_call_set_broken); + bctbx_list_for_each(lc->calls, (MSIterateFunc) linphone_call_set_broken); }else{ linphone_core_resolve_stun_server(lc); } @@ -6800,7 +6800,7 @@ static void set_sip_network_reachable(LinphoneCore* lc,bool_t is_sip_reachable, void linphone_core_repair_calls(LinphoneCore *lc){ if (lc->calls && lp_config_get_int(lc->config, "sip", "repair_broken_calls", 1) && lc->media_network_reachable){ /*if we are registered and there were broken calls due to a past network disconnection, attempt to repair them*/ - ms_list_for_each(lc->calls, (MSIterateFunc) linphone_call_repair_if_broken); + bctbx_list_for_each(lc->calls, (MSIterateFunc) linphone_call_repair_if_broken); } } @@ -6811,10 +6811,10 @@ static void set_media_network_reachable(LinphoneCore* lc, bool_t is_media_reacha if (!lc->media_network_reachable){ /*mark all calls as broken, so that they can be either dropped immediately or restaured when network will be back*/ - ms_list_for_each(lc->calls, (MSIterateFunc) linphone_call_set_broken); + bctbx_list_for_each(lc->calls, (MSIterateFunc) linphone_call_set_broken); }else{ if (lp_config_get_int(lc->config, "net", "recreate_sockets_when_network_is_up", 0)){ - ms_list_for_each(lc->calls, (MSIterateFunc)linphone_call_refresh_sockets); + bctbx_list_for_each(lc->calls, (MSIterateFunc)linphone_call_refresh_sockets); } linphone_core_repair_calls(lc); } @@ -6826,7 +6826,7 @@ static void set_network_reachable(LinphoneCore *lc, bool_t is_network_reachable, } void linphone_core_refresh_registers(LinphoneCore* lc) { - const MSList *elem; + const bctbx_list_t *elem; if (!lc->sip_network_reachable) { ms_warning("Refresh register operation not available (network unreachable)"); return; @@ -6841,7 +6841,7 @@ void linphone_core_refresh_registers(LinphoneCore* lc) { } void __linphone_core_invalidate_registers(LinphoneCore* lc){ - const MSList *elem=linphone_core_get_proxy_config_list(lc); + const bctbx_list_t *elem=linphone_core_get_proxy_config_list(lc); for(;elem!=NULL;elem=elem->next){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; if (linphone_proxy_config_register_enabled(cfg)) { @@ -6894,7 +6894,7 @@ void linphone_core_destroy(LinphoneCore *lc){ * @ingroup call_control **/ int linphone_core_get_calls_nb(const LinphoneCore *lc){ - return ms_list_size(lc->calls);; + return bctbx_list_size(lc->calls);; } /** @@ -6918,7 +6918,7 @@ static void notify_soundcard_usage(LinphoneCore *lc, bool_t used){ } void linphone_core_soundcard_hint_check( LinphoneCore* lc){ - MSList* the_calls = lc->calls; + bctbx_list_t* the_calls = lc->calls; LinphoneCall* call = NULL; bool_t dont_need_sound = TRUE; bool_t use_rtp_io = lp_config_get_int(lc->config, "sound", "rtp_io", FALSE); @@ -6944,7 +6944,7 @@ int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call) { if (linphone_core_can_we_add_call(lc)){ if (lc->calls==NULL) notify_soundcard_usage(lc,TRUE); - lc->calls = ms_list_append(lc->calls,call); + lc->calls = bctbx_list_append(lc->calls,call); return 0; } return -1; @@ -6952,13 +6952,13 @@ int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call) int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call) { - MSList *it; - MSList *the_calls = lc->calls; + bctbx_list_t *it; + bctbx_list_t *the_calls = lc->calls; - it=ms_list_find(the_calls,call); + it=bctbx_list_find(the_calls,call); if (it) { - the_calls = ms_list_remove_link(the_calls,it); + the_calls = bctbx_list_remove_link(the_calls,it); } else { @@ -7230,7 +7230,7 @@ const char *linphone_core_get_user_certificates_path(LinphoneCore *lc){ } LinphoneCall* linphone_core_find_call_from_uri(const LinphoneCore *lc, const char *uri) { - MSList *calls; + bctbx_list_t *calls; LinphoneCall *c; const LinphoneAddress *address; char *current_uri; @@ -7265,7 +7265,7 @@ LinphoneCall* linphone_core_find_call_from_uri(const LinphoneCore *lc, const cha * @param lc The LinphoneCore **/ bool_t linphone_core_sound_resources_locked(LinphoneCore *lc){ - MSList *elem; + bctbx_list_t *elem; for(elem=lc->calls;elem!=NULL;elem=elem->next) { LinphoneCall *c=(LinphoneCall*)elem->data; @@ -7832,7 +7832,7 @@ int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call) { } int linphone_core_add_all_to_conference(LinphoneCore *lc) { - MSList *calls=lc->calls; + bctbx_list_t *calls=lc->calls; while (calls) { LinphoneCall *call=(LinphoneCall*)calls->data; calls=calls->next; diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 15af0ccdf..9b100e572 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1470,7 +1470,7 @@ LINPHONE_PUBLIC int linphone_chat_room_get_history_size(LinphoneChatRoom *cr); * @param[in] nb_message Number of message to retrieve. 0 means everything. * @return \mslist{LinphoneChatMessage} */ -LINPHONE_PUBLIC MSList *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message); +LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message); /** * Gets the partial list of messages in the given range, sorted from oldest to most recent. @@ -1479,7 +1479,7 @@ LINPHONE_PUBLIC MSList *linphone_chat_room_get_history(LinphoneChatRoom *cr,int * @param[in] end The last message of the range to be retrieved. History oldest message has index of history size - 1 (use #linphone_chat_room_get_history_size to retrieve history size) * @return \mslist{LinphoneChatMessage} */ -LINPHONE_PUBLIC MSList *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end); +LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end); /** * Notifies the destination of the chat message being composed that the user is typing a new message. @@ -1530,7 +1530,7 @@ LINPHONE_PUBLIC uint32_t linphone_chat_room_get_char(const LinphoneChatRoom *cr) * @param[in] lc #LinphoneCore object * @return \mslist{LinphoneChatRoom} **/ -LINPHONE_PUBLIC const MSList* linphone_core_get_chat_rooms(LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t* linphone_core_get_chat_rooms(LinphoneCore *lc); LINPHONE_PUBLIC unsigned int linphone_chat_message_store(LinphoneChatMessage *msg); /** @@ -2751,58 +2751,58 @@ LINPHONE_PUBLIC bool_t linphone_core_dns_srv_enabled(const LinphoneCore *lc); /** * Forces liblinphone to use the supplied list of dns servers, instead of system's ones. * @param[in] lc #LinphoneCore object. - * @param[in] servers A #MSList of strings containing the IP addresses of DNS servers to be used. + * @param[in] servers A #bctbx_list_t of strings containing the IP addresses of DNS servers to be used. * Setting to NULL restores default behaviour, which is to use the DNS server list provided by the system. * The list is copied internally. * @ingroup media_parameters */ -LINPHONE_PUBLIC void linphone_core_set_dns_servers(LinphoneCore *lc, const MSList *servers); +LINPHONE_PUBLIC void linphone_core_set_dns_servers(LinphoneCore *lc, const bctbx_list_t *servers); /** * Returns the list of available audio codecs. * @param[in] lc The LinphoneCore object * @return \mslist{PayloadType} * - * This list is unmodifiable. The ->data field of the MSList points a PayloadType + * This list is unmodifiable. The ->data field of the bctbx_list_t points a PayloadType * structure holding the codec information. - * It is possible to make copy of the list with ms_list_copy() in order to modify it + * It is possible to make copy of the list with bctbx_list_copy() in order to modify it * (such as the order of codecs). * @ingroup media_parameters **/ -LINPHONE_PUBLIC const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t *linphone_core_get_audio_codecs(const LinphoneCore *lc); -LINPHONE_PUBLIC int linphone_core_set_audio_codecs(LinphoneCore *lc, MSList *codecs); +LINPHONE_PUBLIC int linphone_core_set_audio_codecs(LinphoneCore *lc, bctbx_list_t *codecs); /** * Returns the list of available video codecs. * @param[in] lc The LinphoneCore object * @return \mslist{PayloadType} * - * This list is unmodifiable. The ->data field of the MSList points a PayloadType + * This list is unmodifiable. The ->data field of the bctbx_list_t points a PayloadType * structure holding the codec information. - * It is possible to make copy of the list with ms_list_copy() in order to modify it + * It is possible to make copy of the list with bctbx_list_copy() in order to modify it * (such as the order of codecs). * @ingroup media_parameters **/ -LINPHONE_PUBLIC const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t *linphone_core_get_video_codecs(const LinphoneCore *lc); -LINPHONE_PUBLIC int linphone_core_set_video_codecs(LinphoneCore *lc, MSList *codecs); +LINPHONE_PUBLIC int linphone_core_set_video_codecs(LinphoneCore *lc, bctbx_list_t *codecs); /** * Returns the list of available text codecs. * @param[in] lc The LinphoneCore object * @return \mslist{PayloadType} * - * This list is unmodifiable. The ->data field of the MSList points a PayloadType + * This list is unmodifiable. The ->data field of the bctbx_list_t points a PayloadType * structure holding the codec information. - * It is possible to make copy of the list with ms_list_copy() in order to modify it + * It is possible to make copy of the list with bctbx_list_copy() in order to modify it * (such as the order of codecs). * @ingroup media_parameters **/ -LINPHONE_PUBLIC const MSList *linphone_core_get_text_codecs(const LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t *linphone_core_get_text_codecs(const LinphoneCore *lc); -LINPHONE_PUBLIC int linphone_core_set_text_codecs(LinphoneCore *lc, MSList *codecs); +LINPHONE_PUBLIC int linphone_core_set_text_codecs(LinphoneCore *lc, bctbx_list_t *codecs); LINPHONE_PUBLIC void linphone_core_enable_generic_confort_noise(LinphoneCore *lc, bool_t enabled); @@ -2929,7 +2929,7 @@ LINPHONE_PUBLIC void linphone_core_remove_proxy_config(LinphoneCore *lc, Linphon * @param[in] lc The LinphoneCore object * @return \mslist{LinphoneProxyConfig} **/ -LINPHONE_PUBLIC const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t *linphone_core_get_proxy_config_list(const LinphoneCore *lc); /** @deprecated Use linphone_core_set_default_proxy_config() instead. */ #define linphone_core_set_default_proxy(lc, config) linphone_core_set_default_proxy_config(lc, config) @@ -2982,7 +2982,7 @@ LINPHONE_PUBLIC void linphone_core_add_auth_info(LinphoneCore *lc, const Linphon LINPHONE_PUBLIC void linphone_core_remove_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info); -LINPHONE_PUBLIC const MSList *linphone_core_get_auth_info_list(const LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t *linphone_core_get_auth_info_list(const LinphoneCore *lc); /** * Find authentication info matching realm, username, domain criteria. @@ -3384,7 +3384,7 @@ LINPHONE_PUBLIC void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *l * @param[in] lc LinphoneCore object * @return \mslist{LinphoneCallLog} **/ -LINPHONE_PUBLIC const MSList * linphone_core_get_call_logs(LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_call_logs(LinphoneCore *lc); /** * Get the list of call logs (past calls) that matches the given #LinphoneAddress. @@ -3393,7 +3393,7 @@ LINPHONE_PUBLIC const MSList * linphone_core_get_call_logs(LinphoneCore *lc); * @param[in] addr LinphoneAddress object * @return \mslist{LinphoneCallLog} **/ -LINPHONE_PUBLIC MSList * linphone_core_get_call_history_for_address(LinphoneCore *lc, const LinphoneAddress *addr); +LINPHONE_PUBLIC bctbx_list_t * linphone_core_get_call_history_for_address(LinphoneCore *lc, const LinphoneAddress *addr); /** * Get the latest outgoing call log. @@ -3881,7 +3881,7 @@ LINPHONE_PUBLIC LpConfig * linphone_core_create_lp_config(LinphoneCore *lc, cons LINPHONE_PUBLIC void linphone_core_set_waiting_callback(LinphoneCore *lc, LinphoneCoreWaitingCallback cb, void *user_context); /*returns the list of registered SipSetup (linphonecore plugins) */ -LINPHONE_PUBLIC const MSList * linphone_core_get_sip_setups(LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_sip_setups(LinphoneCore *lc); LINPHONE_PUBLIC void linphone_core_destroy(LinphoneCore *lc); @@ -3905,7 +3905,7 @@ int linphone_core_get_current_call_stats(LinphoneCore *lc, rtp_stats_t *local, r LINPHONE_PUBLIC int linphone_core_get_calls_nb(const LinphoneCore *lc); -LINPHONE_PUBLIC const MSList *linphone_core_get_calls(LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t *linphone_core_get_calls(LinphoneCore *lc); LINPHONE_PUBLIC LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc); /** @@ -4181,7 +4181,7 @@ typedef unsigned int ContactSearchID; typedef struct _LinphoneContactSearch LinphoneContactSearch; typedef struct _LinphoneContactProvider LinphoneContactProvider; -typedef void (*ContactSearchCallback)( LinphoneContactSearch* id, MSList* friends, void* data ); +typedef void (*ContactSearchCallback)( LinphoneContactSearch* id, bctbx_list_t* friends, void* data ); /* * Remote provisioning diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index 2f410e7b3..7b13a0c67 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -74,8 +74,8 @@ typedef struct _LpSectionParam{ typedef struct _LpSection{ char *name; - MSList *items; - MSList *params; + bctbx_list_t *items; + bctbx_list_t *params; bool_t overwrite; // If set to true, will add overwrite=true to all items of this section when converted to xml bool_t skip; // If set to true, won't be dumped when converted to xml } LpSection; @@ -85,7 +85,7 @@ struct _LpConfig{ bctbx_vfs_file_t* pFile; char *filename; char *tmpfilename; - MSList *sections; + bctbx_list_t *sections; int modified; int readonly; bctbx_vfs_t* g_bctbx_vfs; @@ -156,31 +156,31 @@ void lp_section_param_destroy(void *section_param){ void lp_section_destroy(LpSection *sec){ ortp_free(sec->name); - ms_list_for_each(sec->items,lp_item_destroy); - ms_list_for_each(sec->params,lp_section_param_destroy); - ms_list_free(sec->items); + bctbx_list_for_each(sec->items,lp_item_destroy); + bctbx_list_for_each(sec->params,lp_section_param_destroy); + bctbx_list_free(sec->items); free(sec); } void lp_section_add_item(LpSection *sec,LpItem *item){ - sec->items=ms_list_append(sec->items,(void *)item); + sec->items=bctbx_list_append(sec->items,(void *)item); } void lp_config_add_section(LpConfig *lpconfig, LpSection *section){ - lpconfig->sections=ms_list_append(lpconfig->sections,(void *)section); + lpconfig->sections=bctbx_list_append(lpconfig->sections,(void *)section); } void lp_config_add_section_param(LpSection *section, LpSectionParam *param){ - section->params = ms_list_append(section->params, (void *)param); + section->params = bctbx_list_append(section->params, (void *)param); } void lp_config_remove_section(LpConfig *lpconfig, LpSection *section){ - lpconfig->sections=ms_list_remove(lpconfig->sections,(void *)section); + lpconfig->sections=bctbx_list_remove(lpconfig->sections,(void *)section); lp_section_destroy(section); } void lp_section_remove_item(LpSection *sec, LpItem *item){ - sec->items=ms_list_remove(sec->items,(void *)item); + sec->items=bctbx_list_remove(sec->items,(void *)item); lp_item_destroy(item); } @@ -202,9 +202,9 @@ static int is_a_comment(const char *str){ LpSection *lp_config_find_section(const LpConfig *lpconfig, const char *name){ LpSection *sec; - MSList *elem; + bctbx_list_t *elem; /*printf("Looking for section %s\n",name);*/ - for (elem=lpconfig->sections;elem!=NULL;elem=ms_list_next(elem)){ + for (elem=lpconfig->sections;elem!=NULL;elem=bctbx_list_next(elem)){ sec=(LpSection*)elem->data; if (strcmp(sec->name,name)==0){ /*printf("Section %s found\n",name);*/ @@ -215,9 +215,9 @@ LpSection *lp_config_find_section(const LpConfig *lpconfig, const char *name){ } LpSectionParam *lp_section_find_param(const LpSection *sec, const char *key){ - MSList *elem; + bctbx_list_t *elem; LpSectionParam *param; - for (elem = sec->params; elem != NULL; elem = ms_list_next(elem)){ + for (elem = sec->params; elem != NULL; elem = bctbx_list_next(elem)){ param = (LpSectionParam*)elem->data; if (strcmp(param->key, key) == 0) { return param; @@ -227,10 +227,10 @@ LpSectionParam *lp_section_find_param(const LpSection *sec, const char *key){ } LpItem *lp_section_find_comment(const LpSection *sec, const char *comment){ - MSList *elem; + bctbx_list_t *elem; LpItem *item; /*printf("Looking for item %s\n",name);*/ - for (elem=sec->items;elem!=NULL;elem=ms_list_next(elem)){ + for (elem=sec->items;elem!=NULL;elem=bctbx_list_next(elem)){ item=(LpItem*)elem->data; if (item->is_comment && strcmp(item->value,comment)==0) { /*printf("Item %s found\n",name);*/ @@ -241,10 +241,10 @@ LpItem *lp_section_find_comment(const LpSection *sec, const char *comment){ } LpItem *lp_section_find_item(const LpSection *sec, const char *name){ - MSList *elem; + bctbx_list_t *elem; LpItem *item; /*printf("Looking for item %s\n",name);*/ - for (elem=sec->items;elem!=NULL;elem=ms_list_next(elem)){ + for (elem=sec->items;elem!=NULL;elem=bctbx_list_next(elem)){ item=(LpItem*)elem->data; if (!item->is_comment && strcmp(item->key,name)==0) { /*printf("Item %s found\n",name);*/ @@ -488,8 +488,8 @@ void lp_item_set_value(LpItem *item, const char *value){ static void _lp_config_destroy(LpConfig *lpconfig){ if (lpconfig->filename!=NULL) ortp_free(lpconfig->filename); if (lpconfig->tmpfilename) ortp_free(lpconfig->tmpfilename); - ms_list_for_each(lpconfig->sections,(void (*)(void*))lp_section_destroy); - ms_list_free(lpconfig->sections); + bctbx_list_for_each(lpconfig->sections,(void (*)(void*))lp_section_destroy); + bctbx_list_free(lpconfig->sections); free(lpconfig); } @@ -530,13 +530,13 @@ const char *lp_config_get_string(const LpConfig *lpconfig, const char *section, return default_string; } -MSList * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, MSList *default_list) { +bctbx_list_t * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, bctbx_list_t *default_list) { LpItem *item; LpSection *sec = lp_config_find_section(lpconfig, section); if (sec != NULL) { item = lp_section_find_item(sec, key); if (item != NULL) { - MSList *l = NULL; + bctbx_list_t *l = NULL; char *str; char *ptr; str = ptr = ms_strdup(item->value); @@ -545,7 +545,7 @@ MSList * lp_config_get_string_list(const LpConfig *lpconfig, const char *section if (next != NULL) { *(next++) = '\0'; } - l = ms_list_append(l, ms_strdup(ptr)); + l = bctbx_list_append(l, ms_strdup(ptr)); ptr = next; } ms_free(str); @@ -670,10 +670,10 @@ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *ke lpconfig->modified++; } -void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const MSList *value) { +void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const bctbx_list_t *value) { char *strvalue = NULL; char *tmp = NULL; - const MSList *elem; + const bctbx_list_t *elem; for (elem = value; elem != NULL; elem = elem->next) { if (strvalue) { tmp = ms_strdup_printf("%s,%s", strvalue, (const char *)elem->data); @@ -783,10 +783,10 @@ void lp_section_param_write(LpSectionParam *param, LpConfig *lpconfig){ void lp_section_write(LpSection *sec,LpConfig *lpconfig){ if (bctbx_file_fprintf(lpconfig->pFile, 0, "[%s",sec->name) < 0) ms_error("lp_section_write : write error on %s", sec->name); - ms_list_for_each2(sec->params, (void (*)(void*, void*))lp_section_param_write, (void *)lpconfig); + bctbx_list_for_each2(sec->params, (void (*)(void*, void*))lp_section_param_write, (void *)lpconfig); if (bctbx_file_fprintf(lpconfig->pFile, 0, "]\n")< 0) ms_error("lp_section_write : write error "); - ms_list_for_each2(sec->items, (void (*)(void*, void*))lp_item_write, (void *)lpconfig); + bctbx_list_for_each2(sec->items, (void (*)(void*, void*))lp_item_write, (void *)lpconfig); if (bctbx_file_fprintf(lpconfig->pFile, 0, "\n")< 0) ms_error("lp_section_write : write error"); @@ -811,7 +811,7 @@ int lp_config_sync(LpConfig *lpconfig){ return -1; } - ms_list_for_each2(lpconfig->sections,(void (*)(void *,void*))lp_section_write,(void *)lpconfig); + bctbx_list_for_each2(lpconfig->sections,(void (*)(void *,void*))lp_section_write,(void *)lpconfig); bctbx_file_close(pFile); #ifdef RENAME_REQUIRES_NONEXISTENT_NEW_PATH @@ -835,8 +835,8 @@ int lp_config_has_section(const LpConfig *lpconfig, const char *section){ void lp_config_for_each_section(const LpConfig *lpconfig, void (*callback)(const char *section, void *ctx), void *ctx) { LpSection *sec; - MSList *elem; - for (elem=lpconfig->sections;elem!=NULL;elem=ms_list_next(elem)){ + bctbx_list_t *elem; + for (elem=lpconfig->sections;elem!=NULL;elem=bctbx_list_next(elem)){ sec=(LpSection*)elem->data; callback(sec->name, ctx); } @@ -844,10 +844,10 @@ void lp_config_for_each_section(const LpConfig *lpconfig, void (*callback)(const void lp_config_for_each_entry(const LpConfig *lpconfig, const char *section, void (*callback)(const char *entry, void *ctx), void *ctx) { LpItem *item; - MSList *elem; + bctbx_list_t *elem; LpSection *sec=lp_config_find_section(lpconfig,section); if (sec!=NULL){ - for (elem=sec->items;elem!=NULL;elem=ms_list_next(elem)){ + for (elem=sec->items;elem!=NULL;elem=bctbx_list_next(elem)){ item=(LpItem*)elem->data; if (!item->is_comment) callback(item->key, ctx); @@ -1044,11 +1044,11 @@ err: const char** lp_config_get_sections_names(LpConfig *lpconfig) { const char **sections_names; - const MSList *sections = lpconfig->sections; + const bctbx_list_t *sections = lpconfig->sections; int ndev; int i; - ndev = ms_list_size(sections); + ndev = bctbx_list_size(sections); sections_names = ms_malloc((ndev + 1) * sizeof(const char *)); for (i = 0; sections != NULL; sections = sections->next, i++) { diff --git a/coreapi/message_storage.c b/coreapi/message_storage.c index 126b265ab..a55cdd634 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -112,7 +112,7 @@ int _linphone_sqlite3_open(const char *db_file, sqlite3 **db) { static ORTP_INLINE LinphoneChatMessage* get_transient_message(LinphoneChatRoom* cr, unsigned int storage_id){ - MSList* transients = cr->transient_messages; + bctbx_list_t* transients = cr->transient_messages; LinphoneChatMessage* chat; while( transients ){ chat = (LinphoneChatMessage*)transients->data; @@ -230,7 +230,7 @@ static int create_chat_message(void *data, int argc, char **argv, char **colName } } } - cr->messages_hist=ms_list_prepend(cr->messages_hist,new_message); + cr->messages_hist=bctbx_list_prepend(cr->messages_hist,new_message); return 0; } @@ -449,9 +449,9 @@ void linphone_chat_room_delete_history(LinphoneChatRoom *cr){ if(cr->unread_count > 0) cr->unread_count = 0; } -MSList *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int startm, int endm){ +bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int startm, int endm){ LinphoneCore *lc=linphone_chat_room_get_core(cr); - MSList *ret; + bctbx_list_t *ret; char *buf,*buf2; char *peer; uint64_t begin,end; @@ -501,7 +501,7 @@ MSList *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int startm, i return ret; } -MSList *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message){ +bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message){ return linphone_chat_room_get_history_range(cr, 0, nb_message-1); } @@ -738,11 +738,11 @@ void linphone_chat_message_store_appdata(LinphoneChatMessage *msg){ void linphone_chat_room_mark_as_read(LinphoneChatRoom *cr){ } -MSList *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message){ +bctbx_list_t *linphone_chat_room_get_history(LinphoneChatRoom *cr,int nb_message){ return NULL; } -LINPHONE_PUBLIC MSList *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end){ +LINPHONE_PUBLIC bctbx_list_t *linphone_chat_room_get_history_range(LinphoneChatRoom *cr, int begin, int end){ return NULL; } diff --git a/coreapi/misc.c b/coreapi/misc.c index cb373eb56..111a1828d 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -62,7 +62,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void clear_ice_check_list(LinphoneCall *call, IceCheckList *removed); bool_t linphone_core_payload_type_enabled(LinphoneCore *lc, const LinphonePayloadType *pt){ - if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt) || ms_list_find(lc->codecs_conf.text_codecs, (PayloadType*)pt)){ + if (bctbx_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || bctbx_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt) || bctbx_list_find(lc->codecs_conf.text_codecs, (PayloadType*)pt)){ return payload_type_enabled(pt); } ms_error("Getting enablement status of codec not in audio or video list of PayloadType !"); @@ -75,7 +75,7 @@ bool_t linphone_core_payload_type_is_vbr(LinphoneCore *lc, const LinphonePayload } int linphone_core_enable_payload_type(LinphoneCore *lc, LinphonePayloadType *pt, bool_t enabled){ - if (ms_list_find(lc->codecs_conf.audio_codecs,pt) || ms_list_find(lc->codecs_conf.video_codecs,pt) || ms_list_find(lc->codecs_conf.text_codecs,pt)){ + if (bctbx_list_find(lc->codecs_conf.audio_codecs,pt) || bctbx_list_find(lc->codecs_conf.video_codecs,pt) || bctbx_list_find(lc->codecs_conf.text_codecs,pt)){ payload_type_set_enable(pt,enabled); _linphone_core_codec_config_write(lc); linphone_core_update_allocated_audio_bandwidth(lc); @@ -107,7 +107,7 @@ const char *linphone_core_get_payload_type_description(LinphoneCore *lc, Payload } void linphone_core_set_payload_type_bitrate(LinphoneCore *lc, LinphonePayloadType *pt, int bitrate){ - if (ms_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || ms_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt) || ms_list_find(lc->codecs_conf.text_codecs, (PayloadType*)pt)){ + if (bctbx_list_find(lc->codecs_conf.audio_codecs, (PayloadType*) pt) || bctbx_list_find(lc->codecs_conf.video_codecs, (PayloadType*)pt) || bctbx_list_find(lc->codecs_conf.text_codecs, (PayloadType*)pt)){ if (pt->type==PAYLOAD_VIDEO || pt->flags & PAYLOAD_TYPE_IS_VBR){ pt->normal_bitrate=bitrate*1000; pt->flags|=PAYLOAD_TYPE_BITRATE_OVERRIDE; @@ -204,7 +204,7 @@ void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, } void linphone_core_update_allocated_audio_bandwidth(LinphoneCore *lc){ - const MSList *elem; + const bctbx_list_t *elem; int maxbw=get_min_bandwidth(linphone_core_get_download_bandwidth(lc), linphone_core_get_upload_bandwidth(lc)); int max_codec_bitrate=0; @@ -954,9 +954,9 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess stream->ice_mismatch = ice_check_list_is_mismatch(cl); if ((ice_check_list_state(cl) == ICL_Running) || (ice_check_list_state(cl) == ICL_Completed)) { memset(stream->ice_candidates, 0, sizeof(stream->ice_candidates)); - for (j = 0; j < MIN(ms_list_size(cl->local_candidates), SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES); j++) { + for (j = 0; j < MIN(bctbx_list_size(cl->local_candidates), SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES); j++) { SalIceCandidate *sal_candidate = &stream->ice_candidates[nb_candidates]; - IceCandidate *ice_candidate = ms_list_nth_data(cl->local_candidates, j); + IceCandidate *ice_candidate = bctbx_list_nth_data(cl->local_candidates, j); const char *default_addr = NULL; int default_port = 0; if (ice_candidate->componentID == 1) { @@ -1625,7 +1625,7 @@ static int get_unique_transport(LinphoneCore *lc, LinphoneTransportType *type, i } static void linphone_core_migrate_proxy_config(LinphoneCore *lc, LinphoneTransportType type){ - const MSList *elem; + const bctbx_list_t *elem; for(elem=linphone_core_get_proxy_config_list(lc);elem!=NULL;elem=elem->next){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; const char *proxy=linphone_proxy_config_get_addr(cfg); @@ -1697,7 +1697,7 @@ void linphone_tone_description_destroy(LinphoneToneDescription *obj){ } LinphoneToneDescription *linphone_core_get_call_error_tone(const LinphoneCore *lc, LinphoneReason reason){ - const MSList *elem; + const bctbx_list_t *elem; for (elem=lc->tones;elem!=NULL;elem=elem->next){ LinphoneToneDescription *tone=(LinphoneToneDescription*)elem->data; if (tone->reason==reason) return tone; @@ -1706,7 +1706,7 @@ LinphoneToneDescription *linphone_core_get_call_error_tone(const LinphoneCore *l } const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID id){ - const MSList *elem; + const bctbx_list_t *elem; for (elem=lc->tones;elem!=NULL;elem=elem->next){ LinphoneToneDescription *tone=(LinphoneToneDescription*)elem->data; if (tone->toneid==id && tone->reason==LinphoneReasonNone && tone->audiofile!=NULL) return tone->audiofile; @@ -1717,11 +1717,11 @@ const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID i void _linphone_core_set_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile){ LinphoneToneDescription *tone=linphone_core_get_call_error_tone(lc,reason); if (tone){ - lc->tones=ms_list_remove(lc->tones,tone); + lc->tones=bctbx_list_remove(lc->tones,tone); linphone_tone_description_destroy(tone); } tone=linphone_tone_description_new(reason,id,audiofile); - lc->tones=ms_list_append(lc->tones,tone); + lc->tones=bctbx_list_append(lc->tones,tone); } /** @@ -2010,15 +2010,15 @@ static void hook_invoke(Hook *h){ } void linphone_task_list_add(LinphoneTaskList *t, LinphoneCoreIterateHook hook, void *hook_data){ - t->hooks = ms_list_append(t->hooks,hook_new(hook,hook_data)); + t->hooks = bctbx_list_append(t->hooks,hook_new(hook,hook_data)); } void linphone_task_list_remove(LinphoneTaskList *t, LinphoneCoreIterateHook hook, void *hook_data){ - MSList *elem; + bctbx_list_t *elem; for(elem=t->hooks;elem!=NULL;elem=elem->next){ Hook *h=(Hook*)elem->data; if (h->fun==hook && h->data==hook_data){ - t->hooks = ms_list_remove_link(t->hooks,elem); + t->hooks = bctbx_list_remove_link(t->hooks,elem); ms_free(h); return; } @@ -2027,9 +2027,9 @@ void linphone_task_list_remove(LinphoneTaskList *t, LinphoneCoreIterateHook hook } void linphone_task_list_run(LinphoneTaskList *t){ - ms_list_for_each(t->hooks,(void (*)(void*))hook_invoke); + bctbx_list_for_each(t->hooks,(void (*)(void*))hook_invoke); } void linphone_task_list_free(LinphoneTaskList *t){ - t->hooks = ms_list_free_with_data(t->hooks, (void (*)(void*))ms_free); + t->hooks = bctbx_list_free_with_data(t->hooks, (void (*)(void*))ms_free); } diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index c41bd96e5..6690c4751 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -63,22 +63,22 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneNatPolicy, belle_sip_object_t, static void _linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy, LpConfig *config, int index) { char *section; - MSList *l = NULL; + bctbx_list_t *l = NULL; section = belle_sip_strdup_printf("nat_policy_%i", index); lp_config_set_string(config, section, "ref", policy->ref); lp_config_set_string(config, section, "stun_server", policy->stun_server); lp_config_set_string(config, section, "stun_server_username", policy->stun_server_username); if (linphone_nat_policy_upnp_enabled(policy)) { - l = ms_list_append(l, "upnp"); + l = bctbx_list_append(l, "upnp"); } else { - if (linphone_nat_policy_stun_enabled(policy)) l = ms_list_append(l, "stun"); - if (linphone_nat_policy_turn_enabled(policy)) l = ms_list_append(l, "turn"); - if (linphone_nat_policy_ice_enabled(policy)) l = ms_list_append(l, "ice"); + if (linphone_nat_policy_stun_enabled(policy)) l = bctbx_list_append(l, "stun"); + if (linphone_nat_policy_turn_enabled(policy)) l = bctbx_list_append(l, "turn"); + if (linphone_nat_policy_ice_enabled(policy)) l = bctbx_list_append(l, "ice"); } lp_config_set_string_list(config, section, "protocols", l); belle_sip_free(section); - ms_list_free(l); + bctbx_list_free(l); } void linphone_nat_policy_save_to_config(const LinphoneNatPolicy *policy) { @@ -279,13 +279,13 @@ LinphoneNatPolicy * linphone_core_create_nat_policy_from_config(LinphoneCore *lc if ((config_ref != NULL) && (strcmp(config_ref, ref) == 0)) { const char *server = lp_config_get_string(config, section, "stun_server", NULL); const char *username = lp_config_get_string(config, section, "stun_server_username", NULL); - MSList *l = lp_config_get_string_list(config, section, "protocols", NULL); + bctbx_list_t *l = lp_config_get_string_list(config, section, "protocols", NULL); policy = _linphone_nat_policy_new_with_ref(lc, ref); if (server != NULL) linphone_nat_policy_set_stun_server(policy, server); if (username != NULL) linphone_nat_policy_set_stun_server_username(policy, username); if (l != NULL) { bool_t upnp_enabled = FALSE; - MSList *elem; + bctbx_list_t *elem; for (elem = l; elem != NULL; elem = elem->next) { const char *value = (const char *)elem->data; if (strcmp(value, "stun") == 0) linphone_nat_policy_enable_stun(policy, TRUE); diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index 08f3505d5..ede4f99e9 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "offeranswer.h" #include "private.h" -static bool_t only_telephone_event(const MSList *l){ +static bool_t only_telephone_event(const bctbx_list_t *l){ for(;l!=NULL;l=l->next){ PayloadType *p=(PayloadType*)l->data; if (strcasecmp(p->mime_type,"telephone-event")!=0){ @@ -32,9 +32,9 @@ static bool_t only_telephone_event(const MSList *l){ } -static PayloadType * opus_match(MSOfferAnswerContext *ctx, const MSList *local_payloads, const PayloadType *refpt, const MSList *remote_payloads, bool_t reading_response){ +static PayloadType * opus_match(MSOfferAnswerContext *ctx, const bctbx_list_t *local_payloads, const PayloadType *refpt, const bctbx_list_t *remote_payloads, bool_t reading_response){ PayloadType *pt; - const MSList *elem; + const bctbx_list_t *elem; PayloadType *legacy_opus=NULL; for (elem=local_payloads;elem!=NULL;elem=elem->next){ @@ -68,9 +68,9 @@ MSOfferAnswerProvider opus_offer_answer_provider={ }; /* the reason for this matcher is for some stupid uncompliant phone that offer G729a mime type !*/ -static PayloadType * g729A_match(MSOfferAnswerContext *ctx, const MSList *local_payloads, const PayloadType *refpt, const MSList *remote_payloads, bool_t reading_response){ +static PayloadType * g729A_match(MSOfferAnswerContext *ctx, const bctbx_list_t *local_payloads, const PayloadType *refpt, const bctbx_list_t *remote_payloads, bool_t reading_response){ PayloadType *pt; - const MSList *elem; + const bctbx_list_t *elem; PayloadType *candidate=NULL; for (elem=local_payloads;elem!=NULL;elem=elem->next){ @@ -93,8 +93,8 @@ MSOfferAnswerProvider g729a_offer_answer_provider={ g729a_offer_answer_create_context }; -static PayloadType * red_match(MSOfferAnswerContext *ctx, const MSList *local_payloads, const PayloadType *refpt, const MSList *remote_payloads, bool_t reading_response) { - const MSList *elem_local, *elem_remote; +static PayloadType * red_match(MSOfferAnswerContext *ctx, const bctbx_list_t *local_payloads, const PayloadType *refpt, const bctbx_list_t *remote_payloads, bool_t reading_response) { + const bctbx_list_t *elem_local, *elem_remote; PayloadType *red = NULL; for (elem_local = local_payloads; elem_local != NULL; elem_local = elem_local->next) { @@ -131,9 +131,9 @@ MSOfferAnswerProvider red_offer_answer_provider={ red_offer_answer_create_context }; -static PayloadType * generic_match(const MSList *local_payloads, const PayloadType *refpt, const MSList *remote_payloads){ +static PayloadType * generic_match(const bctbx_list_t *local_payloads, const PayloadType *refpt, const bctbx_list_t *remote_payloads){ PayloadType *pt; - const MSList *elem; + const bctbx_list_t *elem; for (elem=local_payloads;elem!=NULL;elem=elem->next){ pt=(PayloadType*)elem->data; @@ -158,8 +158,8 @@ void linphone_core_register_offer_answer_providers(LinphoneCore *lc){ /* * Returns a PayloadType from the local list that matches a PayloadType offered or answered in the remote list */ -static PayloadType * find_payload_type_best_match(MSFactory *factory, const MSList *local_payloads, const PayloadType *refpt, - const MSList *remote_payloads, bool_t reading_response){ +static PayloadType * find_payload_type_best_match(MSFactory *factory, const bctbx_list_t *local_payloads, const PayloadType *refpt, + const bctbx_list_t *remote_payloads, bool_t reading_response){ PayloadType *ret = NULL; MSOfferAnswerContext *ctx = NULL; @@ -174,9 +174,9 @@ static PayloadType * find_payload_type_best_match(MSFactory *factory, const MSLi } -static MSList *match_payloads(MSFactory *factory, const MSList *local, const MSList *remote, bool_t reading_response, bool_t one_matching_codec){ - const MSList *e2,*e1; - MSList *res=NULL; +static bctbx_list_t *match_payloads(MSFactory *factory, const bctbx_list_t *local, const bctbx_list_t *remote, bool_t reading_response, bool_t one_matching_codec){ + const bctbx_list_t *e2,*e1; + bctbx_list_t *res=NULL; PayloadType *matched; bool_t found_codec=FALSE; @@ -211,7 +211,7 @@ static MSList *match_payloads(MSFactory *factory, const MSList *local, const MSL }else{ payload_type_unset_flag(matched, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); } - res=ms_list_append(res,matched); + res=bctbx_list_append(res,matched); /* we should use the remote numbering even when parsing a response */ payload_type_set_number(matched,remote_number); payload_type_set_flag(matched, PAYLOAD_TYPE_FROZEN_NUMBER); @@ -227,7 +227,7 @@ static MSList *match_payloads(MSFactory *factory, const MSList *local, const MSL payload_type_set_number(matched,local_number); payload_type_set_flag(matched, PAYLOAD_TYPE_FLAG_CAN_RECV); payload_type_set_flag(matched, PAYLOAD_TYPE_FROZEN_NUMBER); - res=ms_list_append(res,matched); + res=bctbx_list_append(res,matched); } }else{ if (p2->channels>0) @@ -252,7 +252,7 @@ static MSList *match_payloads(MSFactory *factory, const MSList *local, const MSL p1=payload_type_clone(p1); payload_type_set_flag(p1, PAYLOAD_TYPE_FLAG_CAN_RECV); payload_type_set_flag(p1, PAYLOAD_TYPE_FROZEN_NUMBER); - res=ms_list_append(res,p1); + res=bctbx_list_append(res,p1); } } } diff --git a/coreapi/plugins/buddylookup/src/lookup.c b/coreapi/plugins/buddylookup/src/lookup.c index 736e7aa35..094da0dce 100644 --- a/coreapi/plugins/buddylookup/src/lookup.c +++ b/coreapi/plugins/buddylookup/src/lookup.c @@ -108,8 +108,8 @@ static void fill_buddy_info(BLReq *blreq, BuddyInfo *bi, GHashTable *ht){ } -static MSList * make_buddy_list(BLReq *blreq, GValue *retval){ - MSList *ret=NULL; +static bctbx_list_t * make_buddy_list(BLReq *blreq, GValue *retval){ + bctbx_list_t *ret=NULL; if (G_VALUE_TYPE(retval)==G_TYPE_VALUE_ARRAY){ GValueArray *array=(GValueArray*)g_value_get_boxed(retval); GValue *gelem; @@ -120,7 +120,7 @@ static MSList * make_buddy_list(BLReq *blreq, GValue *retval){ GHashTable *ht=(GHashTable*)g_value_get_boxed(gelem); BuddyInfo *bi=buddy_info_new(); fill_buddy_info(blreq,bi,ht); - ret=ms_list_append(ret,bi); + ret=bctbx_list_append(ret,bi); }else{ ms_error("Element is not a hash table"); } diff --git a/coreapi/presence.c b/coreapi/presence.c index d4b93f7ff..306fc9a1f 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -41,7 +41,7 @@ struct _LinphonePresenceService { char *id; LinphonePresenceBasicStatus status; char *contact; - MSList *notes; /**< A list of _LinphonePresenceNote structures. */ + bctbx_list_t *notes; /**< A list of _LinphonePresenceNote structures. */ time_t timestamp; }; @@ -56,9 +56,9 @@ struct _LinphonePresencePerson { void *user_data; int refcnt; char *id; - MSList *activities; /**< A list of _LinphonePresenceActivity structures. */ - MSList *activities_notes; /**< A list of _LinphonePresenceNote structures. */ - MSList *notes; /**< A list of _LinphonePresenceNote structures. */ + bctbx_list_t *activities; /**< A list of _LinphonePresenceActivity structures. */ + bctbx_list_t *activities_notes; /**< A list of _LinphonePresenceNote structures. */ + bctbx_list_t *notes; /**< A list of _LinphonePresenceNote structures. */ time_t timestamp; }; @@ -70,9 +70,9 @@ struct _LinphonePresenceModel { LinphoneAddress *presentity; /* "The model seeks to describe the presentity, identified by a presentity URI.*/ void *user_data; int refcnt; - MSList *services; /**< A list of _LinphonePresenceService structures. Also named tuples in the RFC. */ - MSList *persons; /**< A list of _LinphonePresencePerson structures. */ - MSList *notes; /**< A list of _LinphonePresenceNote structures. */ + bctbx_list_t *services; /**< A list of _LinphonePresenceService structures. Also named tuples in the RFC. */ + bctbx_list_t *persons; /**< A list of _LinphonePresencePerson structures. */ + bctbx_list_t *notes; /**< A list of _LinphonePresenceNote structures. */ }; @@ -137,8 +137,8 @@ static void presence_service_delete(LinphonePresenceService *service) { if (service->contact != NULL) { ms_free(service->contact); } - ms_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(service->notes); + bctbx_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(service->notes); ms_free(service); }; @@ -147,7 +147,7 @@ static void presence_service_set_timestamp(LinphonePresenceService *service, tim } static void presence_service_add_note(LinphonePresenceService *service, LinphonePresenceNote *note) { - service->notes = ms_list_append(service->notes, note); + service->notes = bctbx_list_append(service->notes, note); } static void presence_activity_delete(LinphonePresenceActivity *activity) { @@ -216,21 +216,21 @@ static void presence_person_delete(LinphonePresencePerson *person) { if (person->id != NULL) { ms_free(person->id); } - ms_list_for_each(person->activities, (MSIterateFunc)linphone_presence_activity_unref); - ms_list_free(person->activities); - ms_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(person->activities_notes); - ms_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(person->notes); + bctbx_list_for_each(person->activities, (MSIterateFunc)linphone_presence_activity_unref); + bctbx_list_free(person->activities); + bctbx_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(person->activities_notes); + bctbx_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(person->notes); ms_free(person); } static void presence_person_add_activities_note(LinphonePresencePerson *person, LinphonePresenceNote *note) { - person->activities_notes = ms_list_append(person->activities_notes, note); + person->activities_notes = bctbx_list_append(person->activities_notes, note); } static void presence_person_add_note(LinphonePresencePerson *person, LinphonePresenceNote *note) { - person->notes = ms_list_append(person->notes, note); + person->notes = bctbx_list_append(person->notes, note); } static int presence_model_insert_person_by_timestamp(LinphonePresencePerson *current, LinphonePresencePerson *to_insert) { @@ -238,11 +238,11 @@ static int presence_model_insert_person_by_timestamp(LinphonePresencePerson *cur } static void presence_model_add_person(LinphonePresenceModel *model, LinphonePresencePerson *person) { - model->persons = ms_list_insert_sorted(model->persons, linphone_presence_person_ref(person), (MSCompareFunc)presence_model_insert_person_by_timestamp); + model->persons = bctbx_list_insert_sorted(model->persons, linphone_presence_person_ref(person), (bctbx_compare_func)presence_model_insert_person_by_timestamp); } static void presence_model_add_note(LinphonePresenceModel *model, LinphonePresenceNote *note) { - model->notes = ms_list_append(model->notes, note); + model->notes = bctbx_list_append(model->notes, note); } static void presence_model_find_open_basic_status(LinphonePresenceService *service, LinphonePresenceBasicStatus *status) { @@ -255,12 +255,12 @@ static void presence_model_delete(LinphonePresenceModel *model) { if (model == NULL) return; if (model->presentity) linphone_address_unref(model->presentity); - ms_list_for_each(model->services, (MSIterateFunc)linphone_presence_service_unref); - ms_list_free(model->services); - ms_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_unref); - ms_list_free(model->persons); - ms_list_for_each(model->notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(model->notes); + bctbx_list_for_each(model->services, (MSIterateFunc)linphone_presence_service_unref); + bctbx_list_free(model->services); + bctbx_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_unref); + bctbx_list_free(model->persons); + bctbx_list_for_each(model->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(model->notes); ms_free(model); } @@ -291,7 +291,7 @@ LinphonePresenceModel * linphone_presence_model_new_with_activity_and_note(Linph LinphonePresenceBasicStatus linphone_presence_model_get_basic_status(const LinphonePresenceModel *model) { LinphonePresenceBasicStatus status = LinphonePresenceBasicStatusClosed; if (model != NULL) { - ms_list_for_each2(model->services, (MSIterate2Func)presence_model_find_open_basic_status, &status); + bctbx_list_for_each2(model->services, (MSIterate2Func)presence_model_find_open_basic_status, &status); } return status; } @@ -327,8 +327,8 @@ time_t linphone_presence_model_get_timestamp(const LinphonePresenceModel *model) if (model == NULL) return timestamp; - ms_list_for_each2(model->services, (MSIterate2Func)presence_service_find_newer_timestamp, ×tamp); - ms_list_for_each2(model->persons, (MSIterate2Func)presence_person_find_newer_timestamp, ×tamp); + bctbx_list_for_each2(model->services, (MSIterate2Func)presence_service_find_newer_timestamp, ×tamp); + bctbx_list_for_each2(model->persons, (MSIterate2Func)presence_person_find_newer_timestamp, ×tamp); return timestamp; } @@ -340,7 +340,7 @@ static void presence_model_find_contact(LinphonePresenceService *service, char * char * linphone_presence_model_get_contact(const LinphonePresenceModel *model) { char *contact = NULL; - ms_list_for_each2(model->services, (MSIterate2Func)presence_model_find_contact, &contact); + bctbx_list_for_each2(model->services, (MSIterate2Func)presence_model_find_contact, &contact); if (contact == NULL) return NULL; return ms_strdup(contact); } @@ -360,7 +360,7 @@ int linphone_presence_model_set_contact(LinphonePresenceModel *model, const char } static void presence_model_count_activities(const LinphonePresencePerson *person, unsigned int *nb) { - *nb += ms_list_size(person->activities); + *nb += bctbx_list_size(person->activities); } struct _get_activity_st { @@ -371,9 +371,9 @@ struct _get_activity_st { static void presence_model_get_activity(const LinphonePresencePerson *person, struct _get_activity_st *st) { if (st->current_idx != (unsigned)-1) { - unsigned int size = ms_list_size(person->activities); + unsigned int size = bctbx_list_size(person->activities); if (st->requested_idx < (st->current_idx + size)) { - st->activity = (LinphonePresenceActivity *)ms_list_nth_data(person->activities, st->requested_idx - st->current_idx); + st->activity = (LinphonePresenceActivity *)bctbx_list_nth_data(person->activities, st->requested_idx - st->current_idx); st->current_idx = (unsigned)-1; } else { st->current_idx += size; @@ -416,7 +416,7 @@ int linphone_presence_model_set_activity(LinphonePresenceModel *model, LinphoneP unsigned int linphone_presence_model_get_nb_activities(const LinphonePresenceModel *model) { unsigned int nb = 0; - ms_list_for_each2(model->persons, (MSIterate2Func)presence_model_count_activities, &nb); + bctbx_list_for_each2(model->persons, (MSIterate2Func)presence_model_count_activities, &nb); return nb; } @@ -428,7 +428,7 @@ LinphonePresenceActivity * linphone_presence_model_get_nth_activity(const Linpho memset(&st, 0, sizeof(st)); st.requested_idx = idx; - ms_list_for_each2(model->persons, (MSIterate2Func)presence_model_get_activity, &st); + bctbx_list_for_each2(model->persons, (MSIterate2Func)presence_model_get_activity, &st); return st.activity; } @@ -439,7 +439,7 @@ int linphone_presence_model_add_activity(LinphonePresenceModel *model, LinphoneP if ((model == NULL) || (activity == NULL)) return -1; - if (ms_list_size(model->persons) == 0) { + if (bctbx_list_size(model->persons) == 0) { /* There is no person in the presence model, add one. */ id = generate_presence_id(); person = presence_person_new(id, time(NULL)); @@ -451,7 +451,7 @@ int linphone_presence_model_add_activity(LinphonePresenceModel *model, LinphoneP linphone_presence_person_unref(person); } else { /* Add the activity to the first person in the model. */ - person = (LinphonePresencePerson *)ms_list_nth_data(model->persons, 0); + person = (LinphonePresencePerson *)bctbx_list_nth_data(model->persons, 0); } linphone_presence_person_add_activity(person, activity); @@ -461,7 +461,7 @@ int linphone_presence_model_add_activity(LinphonePresenceModel *model, LinphoneP int linphone_presence_model_clear_activities(LinphonePresenceModel *model) { if (model == NULL) return -1; - ms_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_clear_activities); + bctbx_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_clear_activities); return 0; } @@ -470,13 +470,13 @@ struct _find_note_st { LinphonePresenceNote *note; }; -static LinphonePresenceNote * find_presence_note_in_list(MSList *list, const char *lang) { +static LinphonePresenceNote * find_presence_note_in_list(bctbx_list_t *list, const char *lang) { int nb; int i; - nb = ms_list_size(list); + nb = bctbx_list_size(list); for (i = 0; i < nb; i++) { - LinphonePresenceNote *note = (LinphonePresenceNote *)ms_list_nth_data(list, i); + LinphonePresenceNote *note = (LinphonePresenceNote *)bctbx_list_nth_data(list, i); if (lang == NULL) { if (note->lang == NULL) { return note; @@ -504,8 +504,8 @@ static void find_presence_service_note(LinphonePresenceService *service, struct st->note = find_presence_note_in_list(service->notes, st->lang); } -static LinphonePresenceNote * get_first_presence_note_in_list(MSList *list) { - return (LinphonePresenceNote *)ms_list_nth_data(list, 0); +static LinphonePresenceNote * get_first_presence_note_in_list(bctbx_list_t *list) { + return (LinphonePresenceNote *)bctbx_list_nth_data(list, 0); } static void get_first_presence_person_note(LinphonePresencePerson *person, struct _find_note_st *st) { @@ -527,9 +527,9 @@ LinphonePresenceNote * linphone_presence_model_get_note(const LinphonePresenceMo if (lang != NULL) { /* First try to find a note in the specified language exactly. */ st.lang = lang; - ms_list_for_each2(model->persons, (MSIterate2Func)find_presence_person_note, &st); + bctbx_list_for_each2(model->persons, (MSIterate2Func)find_presence_person_note, &st); if (st.note == NULL) { - ms_list_for_each2(model->services, (MSIterate2Func)find_presence_service_note, &st); + bctbx_list_for_each2(model->services, (MSIterate2Func)find_presence_service_note, &st); } if (st.note == NULL) { st.note = find_presence_note_in_list(model->notes, lang); @@ -539,9 +539,9 @@ LinphonePresenceNote * linphone_presence_model_get_note(const LinphonePresenceMo if (st.note == NULL) { /* No notes in the specified language has been found, try to find one without language. */ st.lang = NULL; - ms_list_for_each2(model->persons, (MSIterate2Func)find_presence_person_note, &st); + bctbx_list_for_each2(model->persons, (MSIterate2Func)find_presence_person_note, &st); if (st.note == NULL) { - ms_list_for_each2(model->services, (MSIterate2Func)find_presence_service_note, &st); + bctbx_list_for_each2(model->services, (MSIterate2Func)find_presence_service_note, &st); } if (st.note == NULL) { st.note = find_presence_note_in_list(model->notes, NULL); @@ -550,9 +550,9 @@ LinphonePresenceNote * linphone_presence_model_get_note(const LinphonePresenceMo if (st.note == NULL) { /* Still no result, so get the first note even if it is not in the specified language. */ - ms_list_for_each2(model->persons, (MSIterate2Func)get_first_presence_person_note, &st); + bctbx_list_for_each2(model->persons, (MSIterate2Func)get_first_presence_person_note, &st); if (st.note == NULL) { - ms_list_for_each2(model->services, (MSIterate2Func)get_first_presence_service_note, &st); + bctbx_list_for_each2(model->services, (MSIterate2Func)get_first_presence_service_note, &st); } if (st.note == NULL) { st.note = get_first_presence_note_in_list(model->notes); @@ -570,7 +570,7 @@ int linphone_presence_model_add_note(LinphonePresenceModel *model, const char *n return -1; /* Will put the note in the first service. */ - service = ms_list_nth_data(model->services, 0); + service = bctbx_list_nth_data(model->services, 0); if (service == NULL) { /* If no service exists, create one. */ service = presence_service_new(generate_presence_id(), LinphonePresenceBasicStatusClosed); @@ -594,17 +594,17 @@ int linphone_presence_model_add_note(LinphonePresenceModel *model, const char *n } static void clear_presence_person_notes(LinphonePresencePerson *person) { - ms_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(person->activities_notes); + bctbx_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(person->activities_notes); person->activities_notes = NULL; - ms_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(person->notes); + bctbx_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(person->notes); person->notes = NULL; } static void clear_presence_service_notes(LinphonePresenceService *service) { - ms_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(service->notes); + bctbx_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(service->notes); service->notes = NULL; } @@ -612,10 +612,10 @@ int linphone_presence_model_clear_notes(LinphonePresenceModel *model) { if (model == NULL) return -1; - ms_list_for_each(model->persons, (MSIterateFunc)clear_presence_person_notes); - ms_list_for_each(model->services, (MSIterateFunc)clear_presence_service_notes); - ms_list_for_each(model->notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(model->notes); + bctbx_list_for_each(model->persons, (MSIterateFunc)clear_presence_person_notes); + bctbx_list_for_each(model->services, (MSIterateFunc)clear_presence_service_notes); + bctbx_list_for_each(model->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(model->notes); model->notes = NULL; return 0; @@ -632,40 +632,40 @@ LinphonePresenceModel * linphone_presence_model_new(void) { } unsigned int linphone_presence_model_get_nb_services(const LinphonePresenceModel *model) { - return ms_list_size(model->services); + return bctbx_list_size(model->services); } LinphonePresenceService * linphone_presence_model_get_nth_service(const LinphonePresenceModel *model, unsigned int idx) { if ((model == NULL) || (idx >= linphone_presence_model_get_nb_services(model))) return NULL; - return (LinphonePresenceService *)ms_list_nth_data(model->services, idx); + return (LinphonePresenceService *)bctbx_list_nth_data(model->services, idx); } int linphone_presence_model_add_service(LinphonePresenceModel *model, LinphonePresenceService *service) { if ((model == NULL) || (service == NULL)) return -1; - model->services = ms_list_append(model->services, linphone_presence_service_ref(service)); + model->services = bctbx_list_append(model->services, linphone_presence_service_ref(service)); return 0; } int linphone_presence_model_clear_services(LinphonePresenceModel *model) { if (model == NULL) return -1; - ms_list_for_each(model->services, (MSIterateFunc)linphone_presence_service_unref); - ms_list_free(model->services); + bctbx_list_for_each(model->services, (MSIterateFunc)linphone_presence_service_unref); + bctbx_list_free(model->services); model->services = NULL; return 0; } unsigned int linphone_presence_model_get_nb_persons(const LinphonePresenceModel *model) { - return ms_list_size(model->persons); + return bctbx_list_size(model->persons); } LinphonePresencePerson * linphone_presence_model_get_nth_person(const LinphonePresenceModel *model, unsigned int idx) { if ((model == NULL) || (idx >= linphone_presence_model_get_nb_persons(model))) return NULL; - return (LinphonePresencePerson *)ms_list_nth_data(model->persons, idx); + return (LinphonePresencePerson *)bctbx_list_nth_data(model->persons, idx); } int linphone_presence_model_add_person(LinphonePresenceModel *model, LinphonePresencePerson *person) { @@ -677,8 +677,8 @@ int linphone_presence_model_add_person(LinphonePresenceModel *model, LinphonePre int linphone_presence_model_clear_persons(LinphonePresenceModel *model) { if (model == NULL) return -1; - ms_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_unref); - ms_list_free(model->persons); + bctbx_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_unref); + bctbx_list_free(model->persons); model->persons = NULL; return 0; } @@ -762,27 +762,27 @@ int linphone_presence_service_set_contact(LinphonePresenceService *service, cons } unsigned int linphone_presence_service_get_nb_notes(const LinphonePresenceService *service) { - return ms_list_size(service->notes); + return bctbx_list_size(service->notes); } LinphonePresenceNote * linphone_presence_service_get_nth_note(const LinphonePresenceService *service, unsigned int idx) { if ((service == NULL) || (idx >= linphone_presence_service_get_nb_notes(service))) return NULL; - return (LinphonePresenceNote *)ms_list_nth_data(service->notes, idx); + return (LinphonePresenceNote *)bctbx_list_nth_data(service->notes, idx); } int linphone_presence_service_add_note(LinphonePresenceService *service, LinphonePresenceNote *note) { if ((service == NULL) || (note == NULL)) return -1; - service->notes = ms_list_append(service->notes, linphone_presence_note_ref(note)); + service->notes = bctbx_list_append(service->notes, linphone_presence_note_ref(note)); return 0; } int linphone_presence_service_clear_notes(LinphonePresenceService *service) { if (service == NULL) return -1; - ms_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(service->notes); + bctbx_list_for_each(service->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(service->notes); service->notes = NULL; return 0; } @@ -815,76 +815,76 @@ int linphone_presence_person_set_id(LinphonePresencePerson *person, const char * unsigned int linphone_presence_person_get_nb_activities(const LinphonePresencePerson *person) { if (person == NULL) return 0; - return ms_list_size(person->activities); + return bctbx_list_size(person->activities); } LinphonePresenceActivity * linphone_presence_person_get_nth_activity(const LinphonePresencePerson *person, unsigned int idx) { if ((person == NULL) || (idx >= linphone_presence_person_get_nb_activities(person))) return NULL; - return (LinphonePresenceActivity *)ms_list_nth_data(person->activities, idx); + return (LinphonePresenceActivity *)bctbx_list_nth_data(person->activities, idx); } int linphone_presence_person_add_activity(LinphonePresencePerson *person, LinphonePresenceActivity *activity) { if ((person == NULL) || (activity == NULL)) return -1; // insert in first position since its the most recent activity! - person->activities = ms_list_prepend(person->activities, linphone_presence_activity_ref(activity)); + person->activities = bctbx_list_prepend(person->activities, linphone_presence_activity_ref(activity)); return 0; } int linphone_presence_person_clear_activities(LinphonePresencePerson *person) { if (person == NULL) return -1; - ms_list_for_each(person->activities, (MSIterateFunc)linphone_presence_activity_unref); - ms_list_free(person->activities); + bctbx_list_for_each(person->activities, (MSIterateFunc)linphone_presence_activity_unref); + bctbx_list_free(person->activities); person->activities = NULL; return 0; } unsigned int linphone_presence_person_get_nb_notes(const LinphonePresencePerson *person) { if (person == NULL) return 0; - return ms_list_size(person->notes); + return bctbx_list_size(person->notes); } LinphonePresenceNote * linphone_presence_person_get_nth_note(const LinphonePresencePerson *person, unsigned int idx) { if ((person == NULL) || (idx >= linphone_presence_person_get_nb_notes(person))) return NULL; - return (LinphonePresenceNote *)ms_list_nth_data(person->notes, idx); + return (LinphonePresenceNote *)bctbx_list_nth_data(person->notes, idx); } int linphone_presence_person_add_note(LinphonePresencePerson *person, LinphonePresenceNote *note) { if ((person == NULL) || (note == NULL)) return -1; - person->notes = ms_list_append(person->notes, linphone_presence_note_ref(note)); + person->notes = bctbx_list_append(person->notes, linphone_presence_note_ref(note)); return 0; } int linphone_presence_person_clear_notes(LinphonePresencePerson *person) { if (person == NULL) return -1; - ms_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(person->notes); + bctbx_list_for_each(person->notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(person->notes); person->notes = NULL; return 0; } unsigned int linphone_presence_person_get_nb_activities_notes(const LinphonePresencePerson *person) { if (person == NULL) return 0; - return ms_list_size(person->activities_notes); + return bctbx_list_size(person->activities_notes); } LinphonePresenceNote * linphone_presence_person_get_nth_activities_note(const LinphonePresencePerson *person, unsigned int idx) { if ((person == NULL) || (idx >= linphone_presence_person_get_nb_activities_notes(person))) return NULL; - return (LinphonePresenceNote *)ms_list_nth_data(person->activities_notes, idx); + return (LinphonePresenceNote *)bctbx_list_nth_data(person->activities_notes, idx); } int linphone_presence_person_add_activities_note(LinphonePresencePerson *person, LinphonePresenceNote *note) { if ((person == NULL) || (note == NULL)) return -1; - person->notes = ms_list_append(person->activities_notes, linphone_presence_note_ref(note)); + person->notes = bctbx_list_append(person->activities_notes, linphone_presence_note_ref(note)); return 0; } int linphone_presence_person_clear_activities_notes(LinphonePresencePerson *person) { if (person == NULL) return -1; - ms_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref); - ms_list_free(person->activities_notes); + bctbx_list_for_each(person->activities_notes, (MSIterateFunc)linphone_presence_note_unref); + bctbx_list_free(person->activities_notes); person->activities_notes = NULL; return 0; } @@ -1408,7 +1408,7 @@ static int process_pidf_xml_presence_persons(xmlparsing_context_t *xml_ctx, Linp if (err < 0) { /* Remove all the persons added since there was an error. */ - ms_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_unref); + bctbx_list_for_each(model->persons, (MSIterateFunc)linphone_presence_person_unref); } return err; } @@ -1481,7 +1481,7 @@ void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalO linphone_friend_set_inc_subscribe_policy(fl,LinphoneSPAccept); fl->inc_subscribe_pending=TRUE; /* the newly created "not yet" friend ownership is transfered to the lc->subscribers list*/ - lc->subscribers=ms_list_append(lc->subscribers,fl); + lc->subscribers=bctbx_list_append(lc->subscribers,fl); tmp = linphone_address_as_string(fl->uri); linphone_core_notify_new_subscription_requested(lc,fl,tmp); @@ -1694,7 +1694,7 @@ static int write_xml_presence_service(xmlTextWriterPtr writer, LinphonePresenceS st.writer = writer; st.ns = NULL; st.err = &err; - ms_list_for_each2(service->notes, (MSIterate2Func)write_xml_presence_note_obj, &st); + bctbx_list_for_each2(service->notes, (MSIterate2Func)write_xml_presence_note_obj, &st); } if (err >= 0) { if (service == NULL) @@ -1742,7 +1742,7 @@ static void person_has_valid_activity(LinphonePresenceActivity *activity, bool_t static bool_t person_has_valid_activities(LinphonePresencePerson *person) { bool_t has_valid_activities = FALSE; - ms_list_for_each2(person->activities, (MSIterate2Func)person_has_valid_activity, &has_valid_activities); + bctbx_list_for_each2(person->activities, (MSIterate2Func)person_has_valid_activity, &has_valid_activities); return has_valid_activities; } @@ -1768,13 +1768,13 @@ static int write_xml_presence_person(xmlTextWriterPtr writer, LinphonePresencePe st.writer = writer; st.ns = "rpid"; st.err = &err; - ms_list_for_each2(person->activities_notes, (MSIterate2Func)write_xml_presence_note_obj, &st); + bctbx_list_for_each2(person->activities_notes, (MSIterate2Func)write_xml_presence_note_obj, &st); } if ((err >= 0) && (person->activities != NULL)) { struct _presence_activity_obj_st st; st.writer = writer; st.err = &err; - ms_list_for_each2(person->activities, (MSIterate2Func)write_xml_presence_activity_obj, &st); + bctbx_list_for_each2(person->activities, (MSIterate2Func)write_xml_presence_activity_obj, &st); } if (err >= 0) { /* Close the "activities" element. */ @@ -1786,7 +1786,7 @@ static int write_xml_presence_person(xmlTextWriterPtr writer, LinphonePresencePe st.writer = writer; st.ns = "dm"; st.err = &err; - ms_list_for_each2(person->notes, (MSIterate2Func)write_xml_presence_note_obj, &st); + bctbx_list_for_each2(person->notes, (MSIterate2Func)write_xml_presence_note_obj, &st); } if (err >= 0) { write_xml_presence_timestamp(writer, person->timestamp); @@ -1857,21 +1857,21 @@ char *linphone_presence_model_to_xml(LinphonePresenceModel *model) { st.writer = writer; st.contact = contact; /*default value*/ st.err = &err; - ms_list_for_each2(model->services, (MSIterate2Func)write_xml_presence_service_obj, &st); + bctbx_list_for_each2(model->services, (MSIterate2Func)write_xml_presence_service_obj, &st); } } if ((err >= 0) && (model != NULL)) { struct _presence_person_obj_st st={0}; st.writer = writer; st.err = &err; - ms_list_for_each2(model->persons, (MSIterate2Func)write_xml_presence_person_obj, &st); + bctbx_list_for_each2(model->persons, (MSIterate2Func)write_xml_presence_person_obj, &st); } if ((err >= 0) && (model != NULL)) { struct _presence_note_obj_st st={0}; st.writer = writer; st.ns = NULL; st.err = &err; - ms_list_for_each2(model->notes, (MSIterate2Func)write_xml_presence_note_obj, &st); + bctbx_list_for_each2(model->notes, (MSIterate2Func)write_xml_presence_note_obj, &st); } if (err >= 0) { /* Close the "presence" element. */ diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 1a8f964c4..4c39c24a7 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -83,11 +83,11 @@ LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_is_server_confi } void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){ - MSList *elem; + bctbx_list_t *elem; int i; if (!linphone_core_ready(lc)) return; - for(elem=lc->sip_conf.proxies,i=0;elem!=NULL;elem=ms_list_next(elem),i++){ + for(elem=lc->sip_conf.proxies,i=0;elem!=NULL;elem=bctbx_list_next(elem),i++){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; linphone_proxy_config_write_to_config_file(lc->config,cfg,i); } @@ -1227,24 +1227,24 @@ int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cfg){ if (!linphone_proxy_config_check(lc,cfg)) { return -1; } - if (ms_list_find(lc->sip_conf.proxies,cfg)!=NULL){ + if (bctbx_list_find(lc->sip_conf.proxies,cfg)!=NULL){ ms_warning("ProxyConfig already entered, ignored."); return 0; } - lc->sip_conf.proxies=ms_list_append(lc->sip_conf.proxies,(void *)linphone_proxy_config_ref(cfg)); + lc->sip_conf.proxies=bctbx_list_append(lc->sip_conf.proxies,(void *)linphone_proxy_config_ref(cfg)); linphone_proxy_config_apply(cfg,lc); return 0; } void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cfg){ /* check this proxy config is in the list before doing more*/ - if (ms_list_find(lc->sip_conf.proxies,cfg)==NULL){ + if (bctbx_list_find(lc->sip_conf.proxies,cfg)==NULL){ ms_error("linphone_core_remove_proxy_config: LinphoneProxyConfig [%p] is not known by LinphoneCore (programming error?)",cfg); return; } - lc->sip_conf.proxies=ms_list_remove(lc->sip_conf.proxies,cfg); + lc->sip_conf.proxies=bctbx_list_remove(lc->sip_conf.proxies,cfg); /* add to the list of destroyed proxies, so that the possible unREGISTER request can succeed authentication */ - lc->sip_conf.deleted_proxies=ms_list_append(lc->sip_conf.deleted_proxies,cfg); + lc->sip_conf.deleted_proxies=bctbx_list_append(lc->sip_conf.deleted_proxies,cfg); if (lc->default_proxy==cfg){ lc->default_proxy=NULL; @@ -1264,19 +1264,19 @@ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cf } void linphone_core_clear_proxy_config(LinphoneCore *lc){ - MSList* list=ms_list_copy(linphone_core_get_proxy_config_list((const LinphoneCore*)lc)); - MSList* copy=list; + bctbx_list_t* list=bctbx_list_copy(linphone_core_get_proxy_config_list((const LinphoneCore*)lc)); + bctbx_list_t* copy=list; for(;list!=NULL;list=list->next){ linphone_core_remove_proxy_config(lc,(LinphoneProxyConfig *)list->data); } - ms_list_free(copy); + bctbx_list_free(copy); linphone_proxy_config_write_all_to_config_file(lc); } int linphone_core_get_default_proxy_config_index(LinphoneCore *lc) { int pos = -1; if (lc->default_proxy != NULL) { - pos = ms_list_position(lc->sip_conf.proxies, ms_list_find(lc->sip_conf.proxies, (void *)lc->default_proxy)); + pos = bctbx_list_position(lc->sip_conf.proxies, bctbx_list_find(lc->sip_conf.proxies, (void *)lc->default_proxy)); } return pos; } @@ -1284,7 +1284,7 @@ int linphone_core_get_default_proxy_config_index(LinphoneCore *lc) { void linphone_core_set_default_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config){ /* check if this proxy is in our list */ if (config!=NULL){ - if (ms_list_find(lc->sip_conf.proxies,config)==NULL){ + if (bctbx_list_find(lc->sip_conf.proxies,config)==NULL){ ms_warning("Bad proxy address: it is not in the list !"); lc->default_proxy=NULL; return ; @@ -1297,7 +1297,7 @@ void linphone_core_set_default_proxy_config(LinphoneCore *lc, LinphoneProxyConfi void linphone_core_set_default_proxy_index(LinphoneCore *lc, int index){ if (index<0) linphone_core_set_default_proxy(lc,NULL); - else linphone_core_set_default_proxy(lc,ms_list_nth_data(lc->sip_conf.proxies,index)); + else linphone_core_set_default_proxy(lc,bctbx_list_nth_data(lc->sip_conf.proxies,index)); } int linphone_core_get_default_proxy(LinphoneCore *lc, LinphoneProxyConfig **config){ @@ -1309,7 +1309,7 @@ LinphoneProxyConfig * linphone_core_get_default_proxy_config(LinphoneCore *lc) { return lc->default_proxy; } -const MSList *linphone_core_get_proxy_config_list(const LinphoneCore *lc){ +const bctbx_list_t *linphone_core_get_proxy_config_list(const LinphoneCore *lc){ return lc->sip_conf.proxies; } diff --git a/coreapi/sal.c b/coreapi/sal.c index 0f43d1a1d..a54df1611 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -69,8 +69,8 @@ SalMediaDescription *sal_media_description_new(){ static void sal_media_description_destroy(SalMediaDescription *md){ int i; for(i=0;istreams[i].payloads,(void (*)(void *))payload_type_destroy); - ms_list_free_with_data(md->streams[i].already_assigned_payloads,(void (*)(void *))payload_type_destroy); + bctbx_list_free_with_data(md->streams[i].payloads,(void (*)(void *))payload_type_destroy); + bctbx_list_free_with_data(md->streams[i].already_assigned_payloads,(void (*)(void *))payload_type_destroy); md->streams[i].payloads=NULL; md->streams[i].already_assigned_payloads=NULL; sal_custom_sdp_attribute_free(md->streams[i].custom_sdp_attributes); @@ -356,8 +356,8 @@ static bool_t is_recv_only(PayloadType *p){ return (p->flags & PAYLOAD_TYPE_FLAG_CAN_RECV) && ! (p->flags & PAYLOAD_TYPE_FLAG_CAN_SEND); } -static bool_t payload_list_equals(const MSList *l1, const MSList *l2){ - const MSList *e1,*e2; +static bool_t payload_list_equals(const bctbx_list_t *l1, const bctbx_list_t *l2){ + const bctbx_list_t *e1,*e2; for(e1=l1,e2=l2;e1!=NULL && e2!=NULL; e1=e1->next,e2=e2->next){ PayloadType *p1=(PayloadType*)e1->data; PayloadType *p2=(PayloadType*)e2->data; @@ -527,18 +527,18 @@ void sal_op_set_route(SalOp *op, const char *route){ char* route_string=(void *)0; SalOpBase* op_base = (SalOpBase*)op; if (op_base->route_addresses) { - ms_list_for_each(op_base->route_addresses,(void (*)(void *))sal_address_destroy); - op_base->route_addresses=ms_list_free(op_base->route_addresses); + bctbx_list_for_each(op_base->route_addresses,(void (*)(void *))sal_address_destroy); + op_base->route_addresses=bctbx_list_free(op_base->route_addresses); } if (route) { - op_base->route_addresses=ms_list_append(NULL,NULL); + op_base->route_addresses=bctbx_list_append(NULL,NULL); assign_address((SalAddress**)&(op_base->route_addresses->data),route); route_string=sal_address_as_string((SalAddress*)op_base->route_addresses->data); \ } assign_string(&op_base->route,route_string); \ if(route_string) ms_free(route_string); } -const MSList* sal_op_get_route_addresses(const SalOp *op) { +const bctbx_list_t* sal_op_get_route_addresses(const SalOp *op) { return ((SalOpBase*)op)->route_addresses; } void sal_op_set_route_address(SalOp *op, const SalAddress *address){ @@ -549,7 +549,7 @@ void sal_op_set_route_address(SalOp *op, const SalAddress *address){ void sal_op_add_route_address(SalOp *op, const SalAddress *address){ SalOpBase* op_base = (SalOpBase*)op; if (op_base->route_addresses) { - op_base->route_addresses=ms_list_append(op_base->route_addresses,(void*)sal_address_clone(address)); + op_base->route_addresses=bctbx_list_append(op_base->route_addresses,(void*)sal_address_clone(address)); } else { sal_op_set_route_address(op,address); } @@ -713,8 +713,8 @@ void __sal_op_free(SalOp *op){ sal_address_destroy(b->service_route); } if (b->route_addresses){ - ms_list_for_each(b->route_addresses,(void (*)(void*)) sal_address_destroy); - b->route_addresses=ms_list_free(b->route_addresses); + bctbx_list_for_each(b->route_addresses,(void (*)(void*)) sal_address_destroy); + b->route_addresses=bctbx_list_free(b->route_addresses); } if (b->recv_custom_headers) sal_custom_header_free(b->recv_custom_headers); diff --git a/coreapi/sipsetup.c b/coreapi/sipsetup.c index 8a5aea58c..cb9a6fddf 100644 --- a/coreapi/sipsetup.c +++ b/coreapi/sipsetup.c @@ -29,10 +29,10 @@ static SipSetup *all_sip_setups[]={ NULL }; -static MSList *registered_sip_setups=NULL; +static bctbx_list_t *registered_sip_setups=NULL; void sip_setup_register(SipSetup *ss){ - registered_sip_setups=ms_list_append(registered_sip_setups,ss); + registered_sip_setups=bctbx_list_append(registered_sip_setups,ss); } void sip_setup_register_all(MSFactory *factory){ @@ -45,12 +45,12 @@ void sip_setup_register_all(MSFactory *factory){ } } -const MSList * linphone_core_get_sip_setups(LinphoneCore *lc){ +const bctbx_list_t * linphone_core_get_sip_setups(LinphoneCore *lc){ return registered_sip_setups; } SipSetup *sip_setup_lookup(const char *type_name){ - MSList *elem; + bctbx_list_t *elem; for(elem=registered_sip_setups;elem!=NULL;elem=elem->next){ SipSetup *ss=(SipSetup*)elem->data; if ( strcasecmp(ss->name,type_name)==0){ @@ -69,7 +69,7 @@ SipSetup *sip_setup_lookup(const char *type_name){ } void sip_setup_unregister_all(void){ - MSList *elem; + bctbx_list_t *elem; for(elem=registered_sip_setups;elem!=NULL;elem=elem->next){ SipSetup *ss=(SipSetup*)elem->data; if (ss->initialized){ @@ -77,7 +77,7 @@ void sip_setup_unregister_all(void){ ss->initialized=FALSE; } } - registered_sip_setups = ms_list_free(registered_sip_setups); + registered_sip_setups = bctbx_list_free(registered_sip_setups); } void buddy_lookup_request_set_key(BuddyLookupRequest *req, const char *key){ @@ -95,8 +95,8 @@ void buddy_lookup_request_set_max_results(BuddyLookupRequest *req, int ncount){ void buddy_lookup_request_free(BuddyLookupRequest *req){ if (req->key) ms_free(req->key); if (req->results){ - ms_list_for_each(req->results,(void (*)(void*))buddy_info_free); - ms_list_free(req->results); + bctbx_list_for_each(req->results,(void (*)(void*))buddy_info_free); + bctbx_list_free(req->results); } ms_free(req); } diff --git a/coreapi/upnp.c b/coreapi/upnp.c index b41b8292c..35397ba96 100644 --- a/coreapi/upnp.c +++ b/coreapi/upnp.c @@ -73,9 +73,9 @@ struct _UpnpContext { UpnpPortBinding *sip_tls; UpnpPortBinding *sip_udp; LinphoneUpnpState state; - MSList *removing_configs; - MSList *adding_configs; - MSList *pending_bindings; + bctbx_list_t *removing_configs; + bctbx_list_t *adding_configs; + bctbx_list_t *pending_bindings; ms_mutex_t mutex; ms_cond_t empty_cond; @@ -91,11 +91,11 @@ bool_t linphone_upnp_is_blacklisted(UpnpContext *ctx); UpnpPortBinding *linphone_upnp_port_binding_new(void); UpnpPortBinding *linphone_upnp_port_binding_new_with_parameters(upnp_igd_ip_protocol protocol, int local_port, int external_port); -UpnpPortBinding *linphone_upnp_port_binding_new_or_collect(MSList *list, upnp_igd_ip_protocol protocol, int local_port, int external_port); +UpnpPortBinding *linphone_upnp_port_binding_new_or_collect(bctbx_list_t *list, upnp_igd_ip_protocol protocol, int local_port, int external_port); UpnpPortBinding *linphone_upnp_port_binding_copy(const UpnpPortBinding *port); void linphone_upnp_port_binding_set_device_id(UpnpPortBinding *port, const char * device_id); bool_t linphone_upnp_port_binding_equal(const UpnpPortBinding *port1, const UpnpPortBinding *port2); -UpnpPortBinding *linphone_upnp_port_binding_equivalent_in_list(MSList *list, const UpnpPortBinding *port); +UpnpPortBinding *linphone_upnp_port_binding_equivalent_in_list(bctbx_list_t *list, const UpnpPortBinding *port); UpnpPortBinding *linphone_upnp_port_binding_retain(UpnpPortBinding *port); void linphone_upnp_update_port_binding(UpnpContext *lupnp, UpnpPortBinding **port_mapping, upnp_igd_ip_protocol protocol, int port, int retry_delay); void linphone_upnp_port_binding_log(int level, const char *msg, const UpnpPortBinding *port); @@ -104,7 +104,7 @@ void linphone_upnp_update_config(UpnpContext *lupnp); void linphone_upnp_update_proxy(UpnpContext *lupnp, bool_t force); // Configuration -MSList *linphone_upnp_config_list_port_bindings(struct _LpConfig *lpc, const char *device_id); +bctbx_list_t *linphone_upnp_config_list_port_bindings(struct _LpConfig *lpc, const char *device_id); void linphone_upnp_config_add_port_binding(UpnpContext *lupnp, const UpnpPortBinding *port); void linphone_upnp_config_remove_port_binding(UpnpContext *lupnp, const UpnpPortBinding *port); @@ -302,7 +302,7 @@ void linphone_upnp_igd_callback(void *cookie, upnp_igd_event event, void *arg) { } } - lupnp->pending_bindings = ms_list_remove(lupnp->pending_bindings, port_mapping); + lupnp->pending_bindings = bctbx_list_remove(lupnp->pending_bindings, port_mapping); linphone_upnp_port_binding_release(port_mapping); } @@ -413,12 +413,12 @@ void linphone_upnp_context_destroy(UpnpContext *lupnp) { } /* Release lists */ - ms_list_for_each(lupnp->adding_configs,(void (*)(void*))linphone_upnp_port_binding_release); - lupnp->adding_configs = ms_list_free(lupnp->adding_configs); - ms_list_for_each(lupnp->removing_configs,(void (*)(void*))linphone_upnp_port_binding_release); - lupnp->removing_configs = ms_list_free(lupnp->removing_configs); - ms_list_for_each(lupnp->pending_bindings,(void (*)(void*))linphone_upnp_port_binding_release); - lupnp->pending_bindings = ms_list_free(lupnp->pending_bindings); + bctbx_list_for_each(lupnp->adding_configs,(void (*)(void*))linphone_upnp_port_binding_release); + lupnp->adding_configs = bctbx_list_free(lupnp->adding_configs); + bctbx_list_for_each(lupnp->removing_configs,(void (*)(void*))linphone_upnp_port_binding_release); + lupnp->removing_configs = bctbx_list_free(lupnp->removing_configs); + bctbx_list_for_each(lupnp->pending_bindings,(void (*)(void*))linphone_upnp_port_binding_release); + lupnp->pending_bindings = bctbx_list_free(lupnp->pending_bindings); ms_mutex_destroy(&lupnp->mutex); ms_cond_destroy(&lupnp->empty_cond); @@ -598,7 +598,7 @@ int linphone_upnp_context_send_add_port_binding(UpnpContext *lupnp, UpnpPortBind } else { linphone_upnp_port_binding_set_device_id(port, upnp_igd_get_device_id(lupnp->upnp_igd_ctxt)); mapping.cookie = linphone_upnp_port_binding_retain(port); - lupnp->pending_bindings = ms_list_append(lupnp->pending_bindings, mapping.cookie); + lupnp->pending_bindings = bctbx_list_append(lupnp->pending_bindings, mapping.cookie); mapping.local_port = port->local_port; mapping.local_host = port->local_addr; @@ -660,7 +660,7 @@ int linphone_upnp_context_send_remove_port_binding(UpnpContext *lupnp, UpnpPortB } else { linphone_upnp_port_binding_set_device_id(port, upnp_igd_get_device_id(lupnp->upnp_igd_ctxt)); mapping.cookie = linphone_upnp_port_binding_retain(port); - lupnp->pending_bindings = ms_list_append(lupnp->pending_bindings, mapping.cookie); + lupnp->pending_bindings = bctbx_list_append(lupnp->pending_bindings, mapping.cookie); mapping.remote_port = port->external_port; mapping.remote_host = ""; @@ -861,9 +861,9 @@ static const char *linphone_core_upnp_get_charptr_null(const char *str) { } void linphone_upnp_update(UpnpContext *lupnp) { - MSList *global_list = NULL; - MSList *list = NULL; - MSList *item; + bctbx_list_t *global_list = NULL; + bctbx_list_t *list = NULL; + bctbx_list_t *item; LinphoneCall *call; UpnpPortBinding *port_mapping, *port_mapping2; @@ -874,13 +874,13 @@ void linphone_upnp_update(UpnpContext *lupnp) { ms_message("uPnP IGD: Refresh mappings"); if(lupnp->sip_udp != NULL) { - global_list = ms_list_append(global_list, lupnp->sip_udp); + global_list = bctbx_list_append(global_list, lupnp->sip_udp); } if(lupnp->sip_tcp != NULL) { - global_list = ms_list_append(global_list, lupnp->sip_tcp); + global_list = bctbx_list_append(global_list, lupnp->sip_tcp); } if(lupnp->sip_tls != NULL) { - global_list = ms_list_append(global_list, lupnp->sip_tls); + global_list = bctbx_list_append(global_list, lupnp->sip_tls); } list = lupnp->lc->calls; @@ -888,16 +888,16 @@ void linphone_upnp_update(UpnpContext *lupnp) { call = (LinphoneCall *)list->data; if(call->upnp_session != NULL) { if(call->upnp_session->audio->rtp != NULL) { - global_list = ms_list_append(global_list, call->upnp_session->audio->rtp); + global_list = bctbx_list_append(global_list, call->upnp_session->audio->rtp); } if(call->upnp_session->audio->rtcp != NULL) { - global_list = ms_list_append(global_list, call->upnp_session->audio->rtcp); + global_list = bctbx_list_append(global_list, call->upnp_session->audio->rtcp); } if(call->upnp_session->video->rtp != NULL) { - global_list = ms_list_append(global_list, call->upnp_session->video->rtp); + global_list = bctbx_list_append(global_list, call->upnp_session->video->rtp); } if(call->upnp_session->video->rtcp != NULL) { - global_list = ms_list_append(global_list, call->upnp_session->video->rtcp); + global_list = bctbx_list_append(global_list, call->upnp_session->video->rtcp); } } list = list->next; @@ -914,8 +914,8 @@ void linphone_upnp_update(UpnpContext *lupnp) { port_mapping2->state = LinphoneUpnpStateOk; } } - ms_list_for_each(list, (void (*)(void*))linphone_upnp_port_binding_release); - list = ms_list_free(list); + bctbx_list_for_each(list, (void (*)(void*))linphone_upnp_port_binding_release); + list = bctbx_list_free(list); // (Re)Add removed port bindings @@ -926,7 +926,7 @@ void linphone_upnp_update(UpnpContext *lupnp) { linphone_upnp_context_send_add_port_binding(lupnp, port_mapping, TRUE); list = list->next; } - global_list = ms_list_free(global_list); + global_list = bctbx_list_free(global_list); } void linphone_upnp_update_port_binding(UpnpContext *lupnp, UpnpPortBinding **port_mapping, upnp_igd_ip_protocol protocol, int port, int retry_delay) { @@ -973,7 +973,7 @@ void linphone_upnp_update_port_binding(UpnpContext *lupnp, UpnpPortBinding **por void linphone_upnp_update_config(UpnpContext* lupnp) { char key[64]; - const MSList *item; + const bctbx_list_t *item; UpnpPortBinding *port_mapping; /* Add configs */ @@ -987,8 +987,8 @@ void linphone_upnp_update_config(UpnpContext* lupnp) { lp_config_set_string(lupnp->lc->config, UPNP_SECTION_NAME, key, "uPnP"); linphone_upnp_port_binding_log(ORTP_DEBUG, "Configuration: Added port binding", port_mapping); } - ms_list_for_each(lupnp->adding_configs,(void (*)(void*))linphone_upnp_port_binding_release); - lupnp->adding_configs = ms_list_free(lupnp->adding_configs); + bctbx_list_for_each(lupnp->adding_configs,(void (*)(void*))linphone_upnp_port_binding_release); + lupnp->adding_configs = bctbx_list_free(lupnp->adding_configs); /* Remove configs */ for(item = lupnp->removing_configs;item!=NULL;item=item->next) { @@ -1001,13 +1001,13 @@ void linphone_upnp_update_config(UpnpContext* lupnp) { lp_config_set_string(lupnp->lc->config, UPNP_SECTION_NAME, key, NULL); linphone_upnp_port_binding_log(ORTP_DEBUG, "Configuration: Removed port binding", port_mapping); } - ms_list_for_each(lupnp->removing_configs,(void (*)(void*))linphone_upnp_port_binding_release); - lupnp->removing_configs = ms_list_free(lupnp->removing_configs); + bctbx_list_for_each(lupnp->removing_configs,(void (*)(void*))linphone_upnp_port_binding_release); + lupnp->removing_configs = bctbx_list_free(lupnp->removing_configs); } void linphone_upnp_update_proxy(UpnpContext* lupnp, bool_t force) { LinphoneUpnpState ready_state; - const MSList *item; + const bctbx_list_t *item; time_t now = (force)? (lupnp->last_ready_check + UPNP_CORE_READY_CHECK) : time(NULL); /* Refresh registers if we are ready */ @@ -1115,7 +1115,7 @@ UpnpPortBinding *linphone_upnp_port_binding_new_with_parameters(upnp_igd_ip_prot return port_binding; } -UpnpPortBinding *linphone_upnp_port_binding_new_or_collect(MSList *list, upnp_igd_ip_protocol protocol, int local_port, int external_port) { +UpnpPortBinding *linphone_upnp_port_binding_new_or_collect(bctbx_list_t *list, upnp_igd_ip_protocol protocol, int local_port, int external_port) { UpnpPortBinding *tmp_binding; UpnpPortBinding *end_binding; @@ -1182,7 +1182,7 @@ bool_t linphone_upnp_port_binding_equal(const UpnpPortBinding *port1, const Upnp (port1->external_port == -1 || port2->external_port == -1 || port1->external_port == port2->external_port); } -UpnpPortBinding *linphone_upnp_port_binding_equivalent_in_list(MSList *list, const UpnpPortBinding *port) { +UpnpPortBinding *linphone_upnp_port_binding_equivalent_in_list(bctbx_list_t *list, const UpnpPortBinding *port) { UpnpPortBinding *port_mapping; while(list != NULL) { port_mapping = (UpnpPortBinding *)list->data; @@ -1293,7 +1293,7 @@ LinphoneUpnpState linphone_upnp_session_get_state(UpnpSession *session) { struct linphone_upnp_config_list_port_bindings_struct { struct _LpConfig *lpc; - MSList *retList; + bctbx_list_t *retList; const char *device_id; }; @@ -1327,7 +1327,7 @@ static void linphone_upnp_config_list_port_bindings_cb(const char *entry, struct port->protocol = protocol; port->external_port = external_port; port->local_port = local_port; - cookie->retList = ms_list_append(cookie->retList, port); + cookie->retList = bctbx_list_append(cookie->retList, port); } } else { valid = FALSE; @@ -1337,7 +1337,7 @@ static void linphone_upnp_config_list_port_bindings_cb(const char *entry, struct } } -MSList *linphone_upnp_config_list_port_bindings(struct _LpConfig *lpc, const char *device_id) { +bctbx_list_t *linphone_upnp_config_list_port_bindings(struct _LpConfig *lpc, const char *device_id) { char *formated_device_id = linphone_upnp_format_device_id(device_id); struct linphone_upnp_config_list_port_bindings_struct cookie = {lpc, NULL, formated_device_id}; lp_config_for_each_entry(lpc, UPNP_SECTION_NAME, (void(*)(const char *, void*))linphone_upnp_config_list_port_bindings_cb, &cookie); @@ -1346,7 +1346,7 @@ MSList *linphone_upnp_config_list_port_bindings(struct _LpConfig *lpc, const cha } void linphone_upnp_config_add_port_binding(UpnpContext *lupnp, const UpnpPortBinding *port) { - MSList *list; + bctbx_list_t *list; UpnpPortBinding *list_port; if(port->device_id == NULL) { @@ -1358,11 +1358,11 @@ void linphone_upnp_config_add_port_binding(UpnpContext *lupnp, const UpnpPortBin while(list != NULL) { list_port = (UpnpPortBinding *)list->data; if(linphone_upnp_port_binding_equal(list_port, port) == TRUE) { - lupnp->removing_configs = ms_list_remove(lupnp->removing_configs, list_port); + lupnp->removing_configs = bctbx_list_remove(lupnp->removing_configs, list_port); linphone_upnp_port_binding_release(list_port); return; } - list = ms_list_next(list); + list = bctbx_list_next(list); } list = lupnp->adding_configs; @@ -1371,15 +1371,15 @@ void linphone_upnp_config_add_port_binding(UpnpContext *lupnp, const UpnpPortBin if(linphone_upnp_port_binding_equal(list_port, port) == TRUE) { return; } - list = ms_list_next(list); + list = bctbx_list_next(list); } list_port = linphone_upnp_port_binding_copy(port); - lupnp->adding_configs = ms_list_append(lupnp->adding_configs, list_port); + lupnp->adding_configs = bctbx_list_append(lupnp->adding_configs, list_port); } void linphone_upnp_config_remove_port_binding(UpnpContext *lupnp, const UpnpPortBinding *port) { - MSList *list; + bctbx_list_t *list; UpnpPortBinding *list_port; if(port->device_id == NULL) { @@ -1391,11 +1391,11 @@ void linphone_upnp_config_remove_port_binding(UpnpContext *lupnp, const UpnpPort while(list != NULL) { list_port = (UpnpPortBinding *)list->data; if(linphone_upnp_port_binding_equal(list_port, port) == TRUE) { - lupnp->adding_configs = ms_list_remove(lupnp->adding_configs, list_port); + lupnp->adding_configs = bctbx_list_remove(lupnp->adding_configs, list_port); linphone_upnp_port_binding_release(list_port); return; } - list = ms_list_next(list); + list = bctbx_list_next(list); } list = lupnp->removing_configs; @@ -1404,9 +1404,9 @@ void linphone_upnp_config_remove_port_binding(UpnpContext *lupnp, const UpnpPort if(linphone_upnp_port_binding_equal(list_port, port) == TRUE) { return; } - list = ms_list_next(list); + list = bctbx_list_next(list); } list_port = linphone_upnp_port_binding_copy(port); - lupnp->removing_configs = ms_list_append(lupnp->removing_configs, list_port); + lupnp->removing_configs = bctbx_list_append(lupnp->removing_configs, list_port); } diff --git a/coreapi/vcard.cc b/coreapi/vcard.cc index 16fb04191..cb0f88381 100644 --- a/coreapi/vcard.cc +++ b/coreapi/vcard.cc @@ -53,8 +53,8 @@ void linphone_vcard_free(LinphoneVcard *vCard) { ms_free(vCard); } -MSList* linphone_vcard_list_from_vcard4_file(const char *filename) { - MSList *result = NULL; +bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *filename) { + bctbx_list_t *result = NULL; if (filename) { belcard::BelCardParser parser = belcard::BelCardParser::getInstance(); shared_ptr belCards = parser.parseFile(filename); @@ -62,15 +62,15 @@ MSList* linphone_vcard_list_from_vcard4_file(const char *filename) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { shared_ptr belCard = (*it); LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard); - result = ms_list_append(result, vCard); + result = bctbx_list_append(result, vCard); } } } return result; } -MSList* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { - MSList *result = NULL; +bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { + bctbx_list_t *result = NULL; if (buffer) { belcard::BelCardParser parser = belcard::BelCardParser::getInstance(); shared_ptr belCards = parser.parse(buffer); @@ -78,7 +78,7 @@ MSList* linphone_vcard_list_from_vcard4_buffer(const char *buffer) { for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { shared_ptr belCard = (*it); LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard); - result = ms_list_append(result, vCard); + result = bctbx_list_append(result, vCard); } } } @@ -153,14 +153,14 @@ void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_ } } -MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) { - MSList *result = NULL; +bctbx_list_t* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard) { + bctbx_list_t *result = NULL; if (!vCard) return NULL; for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) { const char *value = (*it)->getValue().c_str(); if (strncmp(value, "sip:", 4) == 0) { - result = ms_list_append(result, (char *)value); + result = bctbx_list_append(result, (char *)value); } } return result; @@ -186,13 +186,13 @@ void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) } } -MSList* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) { - MSList *result = NULL; +bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) { + bctbx_list_t *result = NULL; if (!vCard) return NULL; for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) { const char *value = (*it)->getValue().c_str(); - result = ms_list_append(result, (char *)value); + result = bctbx_list_append(result, (char *)value); } return result; } diff --git a/coreapi/vtables.c b/coreapi/vtables.c index 50a850ee8..6ba451918 100644 --- a/coreapi/vtables.c +++ b/coreapi/vtables.c @@ -42,13 +42,13 @@ LinphoneCoreVTable *linphone_core_get_current_vtable(LinphoneCore *lc) { } static void cleanup_dead_vtable_refs(LinphoneCore *lc){ - MSList *it,*next_it; + bctbx_list_t *it,*next_it; for(it=lc->vtable_refs; it!=NULL; ){ VTableReference *ref=(VTableReference*)it->data; next_it=it->next; if (ref->valid==0){ ref->valid=0; - lc->vtable_refs=ms_list_remove_link(lc->vtable_refs, it); + lc->vtable_refs=bctbx_list_remove_link(lc->vtable_refs, it); ms_free(ref); } it=next_it; @@ -56,7 +56,7 @@ static void cleanup_dead_vtable_refs(LinphoneCore *lc){ } #define NOTIFY_IF_EXIST(function_name, ...) \ - MSList* iterator; \ + bctbx_list_t* iterator; \ VTableReference *ref; \ bool_t has_cb = FALSE; \ for (iterator=lc->vtable_refs; iterator!=NULL; iterator=iterator->next)\ @@ -67,7 +67,7 @@ static void cleanup_dead_vtable_refs(LinphoneCore *lc){ if (has_cb) ms_message("Linphone core [%p] notifying [%s]",lc,#function_name) #define NOTIFY_IF_EXIST_INTERNAL(function_name, internal_val, ...) \ - MSList* iterator; \ + bctbx_list_t* iterator; \ VTableReference *ref; \ bool_t has_cb = FALSE; \ for (iterator=lc->vtable_refs; iterator!=NULL; iterator=iterator->next)\ @@ -207,7 +207,7 @@ void linphone_core_notify_dtmf_received(LinphoneCore* lc, LinphoneCall *call, in } bool_t linphone_core_dtmf_received_has_listener(const LinphoneCore* lc) { - MSList* iterator; + bctbx_list_t* iterator; for (iterator=lc->vtable_refs; iterator!=NULL; iterator=iterator->next){ VTableReference *ref=(VTableReference*)iterator->data; if (ref->valid && ref->vtable->dtmf_received) @@ -302,7 +302,7 @@ void v_table_reference_destroy(VTableReference *ref){ void _linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable, bool_t autorelease, bool_t internal) { ms_message("Vtable [%p] registered on core [%p]",vtable, lc); - lc->vtable_refs=ms_list_append(lc->vtable_refs,v_table_reference_new(vtable, autorelease, internal)); + lc->vtable_refs=bctbx_list_append(lc->vtable_refs,v_table_reference_new(vtable, autorelease, internal)); } void linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable){ @@ -310,7 +310,7 @@ void linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable){ } void linphone_core_remove_listener(LinphoneCore *lc, const LinphoneCoreVTable *vtable) { - MSList *it; + bctbx_list_t *it; ms_message("Vtable [%p] unregistered on core [%p]",lc,vtable); for(it=lc->vtable_refs; it!=NULL; it=it->next){ VTableReference *ref=(VTableReference*)it->data; diff --git a/gtk/buddylookup.c b/gtk/buddylookup.c index 33f3f2594..eea85aee1 100644 --- a/gtk/buddylookup.c +++ b/gtk/buddylookup.c @@ -177,9 +177,8 @@ static gboolean linphone_gtk_process_buddy_lookup(GtkWidget *w){ linphone_gtk_get_widget(w,"search_results"), results); gtk_progress_bar_set_fraction(pb,1); - tmp=g_strdup_printf(ngettext("Found %i contact", - "Found %u contacts", ms_list_size(results)), - (unsigned int)ms_list_size(results)); + tmp=g_strdup_printf(ngettext("Found %u contact", "Found %u contacts", + (unsigned int)ms_list_size(results)), (unsigned int)ms_list_size(results)); gtk_progress_bar_set_text(pb,tmp); g_free(tmp); sip_setup_context_buddy_lookup_free(ctx,req); diff --git a/mediastreamer2 b/mediastreamer2 index e73957fb9..5d1efd574 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit e73957fb97179ecc660384dd304708d5db24f4b8 +Subproject commit 5d1efd57449513d402b52bcd646004a20b87a744 diff --git a/tools/auto_answer.c b/tools/auto_answer.c index 8c1a890f5..daf0f7946 100644 --- a/tools/auto_answer.c +++ b/tools/auto_answer.c @@ -189,8 +189,8 @@ int main(int argc, char *argv[]){ ms_usleep(50000); if (print_stats) { ms_message("*********************************"); - ms_message("*Current number of calls [%10u] *",(unsigned int)ms_list_size(linphone_core_get_calls(lc))); - ms_message("*Number of calls until now [%10u] *",(unsigned int)ms_list_size(linphone_core_get_call_logs(lc))); + ms_message("*Current number of calls [%10u] *", (unsigned int)ms_list_size(linphone_core_get_calls(lc))); + ms_message("*Number of calls until now [%10u] *", (unsigned int)ms_list_size(linphone_core_get_call_logs(lc))); ms_message("*********************************"); print_stats=FALSE; } From 16bb8d78c1a9a948bc27d769dd156c962e9960ac Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 16 Jun 2016 18:32:13 +0200 Subject: [PATCH 095/124] Update ortp submodule. --- oRTP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oRTP b/oRTP index 084abf711..3d4de2044 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 084abf711cd7105314f50440e0d96ccd756822de +Subproject commit 3d4de2044c3a08e5eefe7e945e82b5e321a6eea1 From 400404fc2ab9bc7cd4d83ad8723aa5f5c29bfab5 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 16 Jun 2016 18:32:21 +0200 Subject: [PATCH 096/124] Replace MSList by bctbx_list_t in tools and tester. --- tester/accountmanager.c | 10 +-- tester/call_multi_tester.c | 116 ++++++++++++------------ tester/call_multicast_tester.c | 8 +- tester/call_single_tester.c | 130 +++++++++++++-------------- tester/call_video_tester.c | 56 ++++++------ tester/eventapi_tester.c | 20 ++--- tester/flexisip_tester.c | 132 +++++++++++++-------------- tester/message_tester.c | 82 ++++++++--------- tester/presence_server_tester.c | 36 ++++---- tester/presence_tester.c | 22 ++--- tester/quality_reporting_tester.c | 2 +- tester/register_tester.c | 22 ++--- tester/setup_tester.c | 8 +- tester/stun_tester.c | 8 +- tester/tester.c | 22 ++--- tester/vcard_tester.c | 142 +++++++++++++++--------------- tester/video_tester.c | 24 ++--- tools/auto_answer.c | 6 +- 18 files changed, 423 insertions(+), 423 deletions(-) diff --git a/tester/accountmanager.c b/tester/accountmanager.c index 90704d9ee..06ca07ee2 100644 --- a/tester/accountmanager.c +++ b/tester/accountmanager.c @@ -55,7 +55,7 @@ void account_destroy(Account *obj){ struct _AccountManager{ char *unique_id; - MSList *accounts; + bctbx_list_t *accounts; }; typedef struct _AccountManager AccountManager; @@ -73,7 +73,7 @@ AccountManager *account_manager_get(void){ void account_manager_destroy(void){ if (the_am){ ms_free(the_am->unique_id); - ms_list_free_with_data(the_am->accounts,(void(*)(void*))account_destroy); + bctbx_list_free_with_data(the_am->accounts,(void(*)(void*))account_destroy); ms_free(the_am); } the_am=NULL; @@ -81,7 +81,7 @@ void account_manager_destroy(void){ } Account *account_manager_get_account(AccountManager *m, const LinphoneAddress *identity){ - MSList *it; + bctbx_list_t *it; for(it=m->accounts;it!=NULL;it=it->next){ Account *a=(Account*)it->data; @@ -208,7 +208,7 @@ LinphoneAddress *account_manager_check_account(AccountManager *m, LinphoneProxyC account=account_new(id_addr,m->unique_id); ms_message("No account for %s exists, going to create one.",identity); create_account=TRUE; - m->accounts=ms_list_append(m->accounts,account); + m->accounts=bctbx_list_append(m->accounts,account); } /*modify the username of the identity of the proxy config*/ linphone_address_set_username(id_addr, linphone_address_get_username(account->modified_identity)); @@ -235,7 +235,7 @@ LinphoneAddress *account_manager_check_account(AccountManager *m, LinphoneProxyC } void linphone_core_manager_check_accounts(LinphoneCoreManager *m){ - const MSList *it; + const bctbx_list_t *it; AccountManager *am=account_manager_get(); for(it=linphone_core_get_proxy_config_list(m->lc);it!=NULL;it=it->next){ diff --git a/tester/call_multi_tester.c b/tester/call_multi_tester.c index e1f2ebef3..fbece53c6 100644 --- a/tester/call_multi_tester.c +++ b/tester/call_multi_tester.c @@ -35,8 +35,8 @@ static void call_waiting_indication_with_param(bool_t enable_caller_privacy) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); - MSList *iterator; - MSList* lcs; + bctbx_list_t *iterator; + bctbx_list_t* lcs; LinphoneCall* pauline_called_by_marie; LinphoneCall* pauline_called_by_laure=NULL; LinphoneCallParams *laure_params=linphone_core_create_call_params(laure->lc, NULL); @@ -45,9 +45,9 @@ static void call_waiting_indication_with_param(bool_t enable_caller_privacy) { if (enable_caller_privacy) linphone_call_params_set_privacy(marie_params,LinphonePrivacyId); - lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,laure->lc); + lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); BC_ASSERT_TRUE(call_with_caller_params(marie,pauline,marie_params)); linphone_call_params_destroy(marie_params); @@ -72,7 +72,7 @@ static void call_waiting_indication_with_param(bool_t enable_caller_privacy) { ,&laure->stat.number_of_LinphoneCallOutgoingRinging ,1)); - for (iterator=(MSList *)linphone_core_get_calls(pauline->lc);iterator!=NULL;iterator=iterator->next) { + for (iterator=(bctbx_list_t *)linphone_core_get_calls(pauline->lc);iterator!=NULL;iterator=iterator->next) { LinphoneCall *call=(LinphoneCall *)iterator->data; if (call != pauline_called_by_marie) { /*fine, this is the call waiting*/ @@ -104,7 +104,7 @@ static void call_waiting_indication_with_param(bool_t enable_caller_privacy) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(laure); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void call_waiting_indication(void) { call_waiting_indication_with_param(FALSE); @@ -177,13 +177,13 @@ static void incoming_call_accepted_when_outgoing_call_in_state(LinphoneCallState LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCoreManager* laure = linphone_core_manager_new( "laure_rc_udp"); - MSList* lcs; + bctbx_list_t* lcs; LinphoneCallParams *laure_params=linphone_core_create_call_params(laure->lc, NULL); LinphoneCallParams *marie_params=linphone_core_create_call_params(marie->lc, NULL); - lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,laure->lc); + lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); if (state==LinphoneCallOutgoingRinging || state==LinphoneCallOutgoingEarlyMedia) { @@ -229,7 +229,7 @@ static void incoming_call_accepted_when_outgoing_call_in_state(LinphoneCallState linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(laure); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void incoming_call_accepted_when_outgoing_call_in_progress(void) { incoming_call_accepted_when_outgoing_call_in_state(LinphoneCallOutgoingProgress); @@ -250,13 +250,13 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag LinphoneCall* pauline_called_by_marie; LinphoneCall* marie_call_laure; LinphoneConference *conference; - const MSList* calls; + const bctbx_list_t* calls; bool_t is_remote_conf; bool_t focus_is_up = (focus && ((LinphoneConferenceServer *)focus)->reg_state == LinphoneRegistrationOk); - MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,laure->lc); - if(focus) lcs=ms_list_append(lcs,focus->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); + if(focus) lcs=bctbx_list_append(lcs,focus->lc); is_remote_conf = (strcmp(lp_config_get_string(marie->lc->config, "misc", "conference_type", "local"), "remote") == 0); if(is_remote_conf) BC_ASSERT_PTR_NOT_NULL(focus); @@ -341,9 +341,9 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag BC_ASSERT_PTR_NOT_NULL(conference = linphone_core_get_conference(marie->lc)); if(conference) { - MSList *participants = linphone_conference_get_participants(conference); - BC_ASSERT_EQUAL(ms_list_size(participants), 2, int, "%d"); - ms_list_free_with_data(participants, (void(*)(void *))linphone_address_destroy); + bctbx_list_t *participants = linphone_conference_get_participants(conference); + BC_ASSERT_EQUAL(bctbx_list_size(participants), 2, int, "%d"); + bctbx_list_free_with_data(participants, (void(*)(void *))linphone_address_destroy); } linphone_core_terminate_conference(marie->lc); @@ -358,7 +358,7 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag if(is_remote_conf) BC_ASSERT_TRUE(wait_for_list(lcs,&focus->stat.number_of_LinphoneCallReleased,3,10000)); end: - ms_list_free(lcs); + bctbx_list_free(lcs); } static void simple_conference(void) { @@ -415,9 +415,9 @@ static void simple_call_transfer(void) { LinphoneCall *marie_calling_laure; char* laure_identity=linphone_address_as_string(laure->identity); - MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,laure->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); BC_ASSERT_TRUE(call(marie,pauline)); @@ -467,7 +467,7 @@ end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(laure); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void unattended_call_transfer(void) { @@ -477,9 +477,9 @@ static void unattended_call_transfer(void) { LinphoneCall* pauline_called_by_marie; char* laure_identity=linphone_address_as_string(laure->identity); - MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,laure->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); BC_ASSERT_TRUE(call(marie,pauline)); @@ -514,7 +514,7 @@ static void unattended_call_transfer(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(laure); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void unattended_call_transfer_with_error(void) { @@ -522,9 +522,9 @@ static void unattended_call_transfer_with_error(void) { LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCall* pauline_called_by_marie; bool_t call_ok=TRUE; - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,pauline->lc); BC_ASSERT_TRUE((call_ok=call(marie,pauline))); if (call_ok){ @@ -555,7 +555,7 @@ static void unattended_call_transfer_with_error(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); - ms_list_free(lcs); + bctbx_list_free(lcs); } @@ -569,10 +569,10 @@ static void call_transfer_existing_call_outgoing_call(void) { LinphoneCall* laure_called_by_marie; LinphoneCall* lcall; bool_t call_ok=TRUE; - const MSList* calls; - MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,laure->lc); + const bctbx_list_t* calls; + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); /*marie call pauline*/ BC_ASSERT_TRUE((call_ok=call(marie,pauline))); @@ -639,7 +639,7 @@ end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(laure); linphone_core_manager_destroy(pauline); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void eject_from_3_participants_conference(LinphoneCoreManager *marie, LinphoneCoreManager *pauline, LinphoneCoreManager *laure, LinphoneCoreManager *focus) { @@ -651,10 +651,10 @@ static void eject_from_3_participants_conference(LinphoneCoreManager *marie, Lin LinphoneCall* pauline_called_by_marie; LinphoneCall* marie_call_laure; bool_t is_remote_conf; - MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,laure->lc); - if(focus) lcs=ms_list_append(lcs,focus->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); + if(focus) lcs=bctbx_list_append(lcs,focus->lc); is_remote_conf = (strcmp(lp_config_get_string(marie->lc->config, "misc", "conference_type", "local"), "remote") == 0); if(is_remote_conf) BC_ASSERT_PTR_NOT_NULL(focus); @@ -716,7 +716,7 @@ static void eject_from_3_participants_conference(LinphoneCoreManager *marie, Lin BC_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallStreamsRunning,3,10000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,5,10000)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(marie->lc)); - BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_calls(marie->lc)), 2, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_calls(marie->lc)), 2, int, "%d"); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(laure->lc)); } else { @@ -736,7 +736,7 @@ static void eject_from_3_participants_conference(LinphoneCoreManager *marie, Lin BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,initial_marie_stat.number_of_LinphoneCallEnd+3,3000)); } end: - ms_list_free(lcs); + bctbx_list_free(lcs); } static void eject_from_3_participants_local_conference(void) { @@ -765,10 +765,10 @@ static void eject_from_4_participants_conference(void) { LinphoneCall* marie_call_laure; LinphoneCall* marie_call_michelle; LinphoneCall* michelle_called_by_marie; - MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,laure->lc); - lcs=ms_list_append(lcs,michelle->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); + lcs=bctbx_list_append(lcs,michelle->lc); BC_ASSERT_TRUE(call(marie,pauline)); marie_call_pauline=linphone_core_get_current_call(marie->lc); @@ -811,7 +811,7 @@ static void eject_from_4_participants_conference(void) { BC_ASSERT_PTR_NULL(linphone_core_get_current_call(marie->lc)); BC_ASSERT_TRUE(linphone_core_is_in_conference(marie->lc)); BC_ASSERT_EQUAL(linphone_core_get_conference_size(marie->lc),3, int, "%d"); - BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_calls(marie->lc)), 3, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_calls(marie->lc)), 3, int, "%d"); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(pauline->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(laure->lc)); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call(michelle->lc)); @@ -837,7 +837,7 @@ end: linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(laure); linphone_core_manager_destroy(michelle); - ms_list_free(lcs); + bctbx_list_free(lcs); } @@ -852,7 +852,7 @@ void simple_remote_conference(void) { const char *laure_proxy_uri = linphone_proxy_config_get_server_addr(laure_proxy_config); const char *focus_uri = linphone_proxy_config_get_identity(focus_proxy_config); int laure_n_register = laure->stat.number_of_LinphoneRegistrationOk; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; lp_config_set_string(marie_config, "misc", "conference_type", "remote"); lp_config_set_string(marie_config, "misc", "conference_focus_addr", focus_uri); @@ -860,9 +860,9 @@ void simple_remote_conference(void) { linphone_proxy_config_edit(laure_proxy_config); linphone_proxy_config_set_route(laure_proxy_config, laure_proxy_uri); linphone_proxy_config_done(laure_proxy_config); - lcs = ms_list_append(lcs, laure->lc); + lcs = bctbx_list_append(lcs, laure->lc); BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphoneRegistrationOk, laure_n_register+1, 5000)); - ms_list_free(lcs); + bctbx_list_free(lcs); simple_conference_base(marie, pauline, laure, (LinphoneCoreManager *)focus); @@ -883,7 +883,7 @@ void simple_remote_conference_shut_down_focus(void) { const char *laure_proxy_uri = linphone_proxy_config_get_server_addr(laure_proxy_config); const char *focus_uri = linphone_proxy_config_get_identity(focus_proxy_config); int laure_n_register = laure->stat.number_of_LinphoneRegistrationOk; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; lp_config_set_string(marie_config, "misc", "conference_type", "remote"); lp_config_set_string(marie_config, "misc", "conference_focus_addr", focus_uri); @@ -891,9 +891,9 @@ void simple_remote_conference_shut_down_focus(void) { linphone_proxy_config_edit(laure_proxy_config); linphone_proxy_config_set_route(laure_proxy_config, laure_proxy_uri); linphone_proxy_config_done(laure_proxy_config); - lcs = ms_list_append(lcs, laure->lc); + lcs = bctbx_list_append(lcs, laure->lc); BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphoneRegistrationOk, laure_n_register+1, 5000)); - ms_list_free(lcs); + bctbx_list_free(lcs); simple_conference_base(marie, pauline, laure, (LinphoneCoreManager *)focus); @@ -914,7 +914,7 @@ void eject_from_3_participants_remote_conference(void) { const char *laure_proxy_uri = linphone_proxy_config_get_server_addr(laure_proxy_config); const char *focus_uri = linphone_proxy_config_get_identity(focus_proxy_config); int laure_n_register = laure->stat.number_of_LinphoneRegistrationOk; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; lp_config_set_string(marie_config, "misc", "conference_type", "remote"); lp_config_set_string(marie_config, "misc", "conference_focus_addr", focus_uri); @@ -922,9 +922,9 @@ void eject_from_3_participants_remote_conference(void) { linphone_proxy_config_edit(laure_proxy_config); linphone_proxy_config_set_route(laure_proxy_config, laure_proxy_uri); linphone_proxy_config_done(laure_proxy_config); - lcs = ms_list_append(lcs, laure->lc); + lcs = bctbx_list_append(lcs, laure->lc); BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphoneRegistrationOk, laure_n_register+1, 5000)); - ms_list_free(lcs); + bctbx_list_free(lcs); eject_from_3_participants_conference(marie, pauline, laure, (LinphoneCoreManager *)focus); diff --git a/tester/call_multicast_tester.c b/tester/call_multicast_tester.c index 818ebbff3..566256ab9 100644 --- a/tester/call_multicast_tester.c +++ b/tester/call_multicast_tester.c @@ -78,7 +78,7 @@ static void call_multicast_video(void) { #endif static void early_media_with_multicast_base(bool_t video) { LinphoneCoreManager *marie, *pauline, *pauline2; - MSList* lcs = NULL; + bctbx_list_t* lcs = NULL; int dummy=0; LinphoneVideoPolicy marie_policy, pauline_policy; LpConfig *marie_lp; @@ -130,9 +130,9 @@ static void early_media_with_multicast_base(bool_t video) { linphone_core_enable_audio_multicast(marie->lc,TRUE); - lcs = ms_list_append(lcs,marie->lc); - lcs = ms_list_append(lcs,pauline->lc); - lcs = ms_list_append(lcs,pauline2->lc); + lcs = bctbx_list_append(lcs,marie->lc); + lcs = bctbx_list_append(lcs,pauline->lc); + lcs = bctbx_list_append(lcs,pauline2->lc); /* Marie calls Pauline, and after the call has rung, transitions to an early_media session */ diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 7275078a6..b56e94d43 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -695,9 +695,9 @@ static void multiple_answers_call(void) { LinphoneCall* call1, *call2; - MSList* lcs = ms_list_append(NULL,pauline->lc); - lcs = ms_list_append(lcs,marie1->lc); - lcs = ms_list_append(lcs,marie2->lc); + bctbx_list_t* lcs = bctbx_list_append(NULL,pauline->lc); + lcs = bctbx_list_append(lcs,marie1->lc); + lcs = bctbx_list_append(lcs,marie2->lc); BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneRegistrationOk, 1, 2000)); @@ -740,9 +740,9 @@ static void multiple_answers_call_with_media_relay(void) { LinphoneCall* call1, *call2; - MSList* lcs = ms_list_append(NULL,pauline->lc); - lcs = ms_list_append(lcs,marie1->lc); - lcs = ms_list_append(lcs,marie2->lc); + bctbx_list_t* lcs = bctbx_list_append(NULL,pauline->lc); + lcs = bctbx_list_append(lcs,marie1->lc); + lcs = bctbx_list_append(lcs,marie2->lc); linphone_core_set_user_agent(pauline->lc, "Natted Linphone", NULL); linphone_core_set_user_agent(marie1->lc, "Natted Linphone", NULL); @@ -776,7 +776,7 @@ static void multiple_answers_call_with_media_relay(void) { linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie1); linphone_core_manager_destroy(marie2); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void call_with_specified_codec_bitrate(void) { @@ -837,7 +837,7 @@ end: } -void disable_all_codecs(const MSList* elem, LinphoneCoreManager* call){ +void disable_all_codecs(const bctbx_list_t* elem, LinphoneCoreManager* call){ PayloadType *pt; @@ -856,7 +856,7 @@ static void call_with_no_audio_codec(void){ LinphoneCoreManager* caller = linphone_core_manager_new(transport_supported(LinphoneTransportTcp) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCall* out_call ; - const MSList* elem =linphone_core_get_audio_codecs(caller->lc); + const bctbx_list_t* elem =linphone_core_get_audio_codecs(caller->lc); disable_all_codecs(elem, caller); @@ -961,7 +961,7 @@ static void cancelled_call(void) { } void disable_all_audio_codecs_except_one(LinphoneCore *lc, const char *mime, int rate){ - const MSList *elem=linphone_core_get_audio_codecs(lc); + const bctbx_list_t *elem=linphone_core_get_audio_codecs(lc); PayloadType *pt; for(;elem!=NULL;elem=elem->next){ @@ -976,8 +976,8 @@ void disable_all_audio_codecs_except_one(LinphoneCore *lc, const char *mime, int void disable_all_video_codecs_except_one(LinphoneCore *lc, const char *mime) { #ifdef VIDEO_ENABLED - const MSList *codecs = linphone_core_get_video_codecs(lc); - const MSList *it = NULL; + const bctbx_list_t *codecs = linphone_core_get_video_codecs(lc); + const bctbx_list_t *it = NULL; PayloadType *pt = NULL; for(it = codecs; it != NULL; it = it->next) { @@ -1072,7 +1072,7 @@ static void early_declined_call(void) { BC_ASSERT_EQUAL(linphone_call_get_reason(out_call),LinphoneReasonBusy, int, "%d"); */ - if (ms_list_size(linphone_core_get_call_logs(pauline->lc))>0) { + if (bctbx_list_size(linphone_core_get_call_logs(pauline->lc))>0) { BC_ASSERT_PTR_NOT_NULL(out_call_log=(LinphoneCallLog*)(linphone_core_get_call_logs(pauline->lc)->data)); BC_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log),LinphoneCallAborted, int, "%d"); } @@ -1548,11 +1548,11 @@ static void call_paused_by_both(void) { LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCall* call_pauline, *call_marie; const rtp_stats_t * stats; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; bool_t call_ok; - lcs = ms_list_append(lcs, pauline->lc); - lcs = ms_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, marie->lc); BC_ASSERT_TRUE((call_ok=call(pauline,marie))); if (!call_ok) goto end; @@ -1606,7 +1606,7 @@ static void call_paused_by_both(void) { end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); - ms_list_free(lcs); + bctbx_list_free(lcs); } #define CHECK_CURRENT_LOSS_RATE() \ @@ -2316,10 +2316,10 @@ static void early_media_call_with_ice(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_early_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCall *marie_call; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; - lcs = ms_list_append(lcs, marie->lc); - lcs = ms_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline->lc); /*in this test, pauline has ICE activated, marie not, but marie proposes early media. * We want to check that ICE processing is not disturbing early media*/ @@ -2345,7 +2345,7 @@ static void early_media_call_with_ice(void) { end_call(marie, pauline); end: - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -2353,15 +2353,15 @@ end: static void early_media_call_with_ringing(void){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc"); - MSList* lcs = NULL; + bctbx_list_t* lcs = NULL; LinphoneCall* marie_call; LinphoneCallLog *marie_call_log; uint64_t connected_time=0; uint64_t ended_time=0; int dummy=0; - lcs = ms_list_append(lcs,marie->lc); - lcs = ms_list_append(lcs,pauline->lc); + lcs = bctbx_list_append(lcs,marie->lc); + lcs = bctbx_list_append(lcs,pauline->lc); /* Marie calls Pauline, and after the call has rung, transitions to an early_media session */ @@ -2398,7 +2398,7 @@ static void early_media_call_with_ringing(void){ end_call(pauline, marie); ended_time=ms_get_cur_time_ms(); BC_ASSERT_LOWER( labs((long)((linphone_call_log_get_duration(marie_call_log)*1000) - (int64_t)(ended_time - connected_time))), 1000, long, "%ld"); - ms_list_free(lcs); + bctbx_list_free(lcs); } linphone_core_manager_destroy(marie); @@ -2408,12 +2408,12 @@ static void early_media_call_with_ringing(void){ static void early_media_call_with_update_base(bool_t media_change){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - MSList* lcs = NULL; + bctbx_list_t* lcs = NULL; LinphoneCall *marie_call, *pauline_call; LinphoneCallParams *pauline_params; - lcs = ms_list_append(lcs,marie->lc); - lcs = ms_list_append(lcs,pauline->lc); + lcs = bctbx_list_append(lcs,marie->lc); + lcs = bctbx_list_append(lcs,pauline->lc); if (media_change) { disable_all_audio_codecs_except_one(marie->lc,"pcmu",-1); disable_all_audio_codecs_except_one(pauline->lc,"pcmu",-1); @@ -2470,7 +2470,7 @@ static void early_media_call_with_update_base(bool_t media_change){ end: - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -2714,13 +2714,13 @@ static void call_redirect(void){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* laure = linphone_core_manager_new("laure_rc_udp"); - MSList* lcs = NULL; + bctbx_list_t* lcs = NULL; char *laure_url = NULL; LinphoneCall* marie_call; - lcs = ms_list_append(lcs,marie->lc); - lcs = ms_list_append(lcs,pauline->lc); - lcs = ms_list_append(lcs,laure->lc); + lcs = bctbx_list_append(lcs,marie->lc); + lcs = bctbx_list_append(lcs,pauline->lc); + lcs = bctbx_list_append(lcs,laure->lc); /* Marie calls Pauline, which will redirect the call to Laure via a 302 */ @@ -2753,7 +2753,7 @@ static void call_redirect(void){ end_call(laure, marie); } - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); @@ -2864,7 +2864,7 @@ static void call_rejected_without_403_because_wrong_credentials_no_auth_req_cb(v call_rejected_because_wrong_credentials_with_params("tester-no-403",FALSE); } -void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, MSList* lcs,LinphoneMediaDirection audio_dir, LinphoneMediaDirection video_dir) { +void check_media_direction(LinphoneCoreManager* mgr, LinphoneCall *call, bctbx_list_t* lcs,LinphoneMediaDirection audio_dir, LinphoneMediaDirection video_dir) { BC_ASSERT_PTR_NOT_NULL(call); if (call) { const LinphoneCallParams *params; @@ -3272,7 +3272,7 @@ end: void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - MSList* lcs = NULL; + bctbx_list_t* lcs = NULL; LinphoneCall* marie_call; LinphoneCallParams* params = NULL; LinphoneCallLog *marie_call_log; @@ -3280,8 +3280,8 @@ void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ){ uint64_t ended_time=0; int dummy=0; - lcs = ms_list_append(lcs,marie->lc); - lcs = ms_list_append(lcs,pauline->lc); + lcs = bctbx_list_append(lcs,marie->lc); + lcs = bctbx_list_append(lcs,pauline->lc); if (use_ice){ linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); } @@ -3336,7 +3336,7 @@ void early_media_without_sdp_in_200_base( bool_t use_video, bool_t use_ice ){ ended_time=ms_get_cur_time_ms(); BC_ASSERT_LOWER(labs((long)((linphone_call_log_get_duration(marie_call_log)*1000) - (int64_t)(ended_time - connected_time))), 1000, long, "%ld"); } - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -4161,11 +4161,11 @@ static void _call_with_network_switch(bool_t use_ice, bool_t with_socket_refresh LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCallParams *pauline_params = NULL; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; bool_t call_ok; - lcs = ms_list_append(lcs, marie->lc); - lcs = ms_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline->lc); if (use_ice){ linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); @@ -4227,7 +4227,7 @@ end: if (pauline_params) { linphone_call_params_unref(pauline_params); } - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -4251,13 +4251,13 @@ static void call_with_network_switch_and_socket_refresh(void){ static void call_with_sip_and_rtp_independant_switches(void){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; bool_t call_ok; bool_t use_ice = TRUE; bool_t with_socket_refresh = TRUE; - lcs = ms_list_append(lcs, marie->lc); - lcs = ms_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline->lc); if (use_ice){ linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce); @@ -4320,7 +4320,7 @@ static void call_with_sip_and_rtp_independant_switches(void){ /*pauline shall be able to end the call without problem now*/ end_call(pauline, marie); end: - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -4331,13 +4331,13 @@ end: static void call_logs_if_no_db_set(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* laure = linphone_core_manager_new("laure_call_logs_rc"); - BC_ASSERT_TRUE(ms_list_size(laure->lc->call_logs) == 10); + BC_ASSERT_TRUE(bctbx_list_size(laure->lc->call_logs) == 10); BC_ASSERT_TRUE(call(marie, laure)); wait_for_until(marie->lc, laure->lc, NULL, 5, 1000); end_call(marie, laure); - BC_ASSERT_TRUE(ms_list_size(laure->lc->call_logs) == 11); + BC_ASSERT_TRUE(bctbx_list_size(laure->lc->call_logs) == 11); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(laure); } @@ -4349,13 +4349,13 @@ static void call_logs_migrate(void) { int incoming_count = 0, outgoing_count = 0, missed_count = 0, aborted_count = 0, decline_count = 0, video_enabled_count = 0; unlink(logs_db); - BC_ASSERT_TRUE(ms_list_size(laure->lc->call_logs) == 10); + BC_ASSERT_TRUE(bctbx_list_size(laure->lc->call_logs) == 10); linphone_core_set_call_logs_database_path(laure->lc, logs_db); BC_ASSERT_TRUE(linphone_core_get_call_history_size(laure->lc) == 10); - for (; i < ms_list_size(laure->lc->call_logs); i++) { - LinphoneCallLog *log = ms_list_nth_data(laure->lc->call_logs, i); + for (; i < bctbx_list_size(laure->lc->call_logs); i++) { + LinphoneCallLog *log = bctbx_list_nth_data(laure->lc->call_logs, i); LinphoneCallStatus state = linphone_call_log_get_status(log); LinphoneCallDir direction = linphone_call_log_get_dir(log); @@ -4394,9 +4394,9 @@ static void call_logs_migrate(void) { } } - laure->lc->call_logs = ms_list_free_with_data(laure->lc->call_logs, (void (*)(void*))linphone_call_log_unref); + laure->lc->call_logs = bctbx_list_free_with_data(laure->lc->call_logs, (void (*)(void*))linphone_call_log_unref); call_logs_read_from_config_file(laure->lc); - BC_ASSERT_TRUE(ms_list_size(laure->lc->call_logs) == 0); + BC_ASSERT_TRUE(bctbx_list_size(laure->lc->call_logs) == 0); unlink(logs_db); ms_free(logs_db); @@ -4407,7 +4407,7 @@ static void call_logs_sqlite_storage(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); char *logs_db = bc_tester_file("call_logs.db"); - MSList *logs = NULL; + bctbx_list_t *logs = NULL; LinphoneCallLog *call_log = NULL; LinphoneAddress *laure = NULL; time_t user_data_time = time(NULL); @@ -4427,16 +4427,16 @@ static void call_logs_sqlite_storage(void) { BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 1); logs = linphone_core_get_call_history_for_address(marie->lc, linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc))); - BC_ASSERT_TRUE(ms_list_size(logs) == 1); - ms_list_free_with_data(logs, (void (*)(void*))linphone_call_log_unref); + BC_ASSERT_TRUE(bctbx_list_size(logs) == 1); + bctbx_list_free_with_data(logs, (void (*)(void*))linphone_call_log_unref); laure = linphone_address_new("\"Laure\" "); logs = linphone_core_get_call_history_for_address(marie->lc, laure); - BC_ASSERT_TRUE(ms_list_size(logs) == 0); + BC_ASSERT_TRUE(bctbx_list_size(logs) == 0); linphone_address_destroy(laure); logs = linphone_core_get_call_history_for_address(marie->lc, linphone_proxy_config_get_identity_address(linphone_core_get_default_proxy_config(pauline->lc))); - if (BC_ASSERT_TRUE(ms_list_size(logs) == 1)) { + if (BC_ASSERT_TRUE(bctbx_list_size(logs) == 1)) { const char *call_id; const char *ref_key = linphone_call_log_get_ref_key(call_log); call_log = logs->data; @@ -4473,8 +4473,8 @@ static void call_logs_sqlite_storage(void) { BC_ASSERT_EQUAL(linphone_call_log_get_status(call_log), LinphoneCallSuccess, int, "%d"); } - linphone_core_delete_call_log(marie->lc, (LinphoneCallLog *)ms_list_nth_data(logs, 0)); - ms_list_free_with_data(logs, (void (*)(void*))linphone_call_log_unref); + linphone_core_delete_call_log(marie->lc, (LinphoneCallLog *)bctbx_list_nth_data(logs, 0)); + bctbx_list_free_with_data(logs, (void (*)(void*))linphone_call_log_unref); BC_ASSERT_TRUE(linphone_core_get_call_history_size(marie->lc) == 0); reset_counters(&marie->stat); @@ -4554,10 +4554,10 @@ static void _call_with_rtcp_mux(bool_t caller_rtcp_mux, bool_t callee_rtcp_mux, 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; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; - lcs = ms_list_append(lcs, marie->lc); - lcs = ms_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline->lc); if (caller_rtcp_mux){ lp_config_set_int(linphone_core_get_config(marie->lc), "rtp", "rtcp_mux", 1); @@ -4604,7 +4604,7 @@ static void _call_with_rtcp_mux(bool_t caller_rtcp_mux, bool_t callee_rtcp_mux, end_call(marie,pauline); end: - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); } diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index ea4cfb5ca..2f8abfaaf 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -38,13 +38,13 @@ static void call_paused_resumed_with_video_base(bool_t sdp_200_ack LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCall* call_pauline, *call_marie; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; LinphoneVideoPolicy vpol; bool_t call_ok; LinphoneCoreVTable *vtable = linphone_core_v_table_new(); vtable->call_state_changed = call_paused_resumed_with_video_base_call_cb; - lcs = ms_list_append(lcs, pauline->lc); - lcs = ms_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, marie->lc); vpol.automatically_accept = FALSE; vpol.automatically_initiate = TRUE; /* needed to present a video mline*/ @@ -127,7 +127,7 @@ static void call_paused_resumed_with_video_base(bool_t sdp_200_ack end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void call_paused_resumed_with_video(void){ call_paused_resumed_with_video_base(FALSE, FALSE,FALSE,FALSE); @@ -1079,7 +1079,7 @@ static void zrtp_video_ice_call(void) { call_base(LinphoneMediaEncryptionZRTP,TRUE,FALSE,LinphonePolicyUseIce,FALSE); } -static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, LinphoneCoreManager *marie, MSList *lcs) { +static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, LinphoneCoreManager *marie, bctbx_list_t *lcs) { #define DEFAULT_WAIT_FOR 10000 LinphoneCallParams *params; LinphoneVideoPolicy pol; @@ -1139,7 +1139,7 @@ static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, Linphone } static void accept_call_in_send_base(bool_t caller_has_ice) { LinphoneCoreManager *pauline, *marie; - MSList *lcs=NULL;; + bctbx_list_t *lcs=NULL;; marie = linphone_core_manager_new("marie_rc"); pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -1147,14 +1147,14 @@ static void accept_call_in_send_base(bool_t caller_has_ice) { linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce); } - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); accept_call_in_send_only_base(pauline,marie,lcs); end_call(marie,pauline); - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -1169,16 +1169,16 @@ static void accept_call_in_send_only_with_ice(void) { void two_accepted_call_in_send_only(void) { LinphoneCoreManager *pauline, *marie, *laure; - MSList *lcs=NULL; + bctbx_list_t *lcs=NULL; marie = linphone_core_manager_new("marie_rc"); linphone_core_use_files(marie->lc, TRUE); pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); laure = linphone_core_manager_new("laure_rc_udp"); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,laure->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,laure->lc); accept_call_in_send_only_base(pauline,marie,lcs); @@ -1191,7 +1191,7 @@ void two_accepted_call_in_send_only(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(laure); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void video_early_media_call(void) { @@ -1219,7 +1219,7 @@ static void multiple_early_media(void) { LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc"); LinphoneCoreManager* marie1 = linphone_core_manager_new("marie_early_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new("marie_early_rc"); - MSList *lcs=NULL; + bctbx_list_t *lcs=NULL; LinphoneCallParams *params=linphone_core_create_call_params(pauline->lc, NULL); LinphoneVideoPolicy pol; LinphoneCall *marie1_call; @@ -1243,9 +1243,9 @@ static void multiple_early_media(void) { linphone_core_set_audio_port_range(marie2->lc,40200,40300); linphone_core_set_video_port_range(marie2->lc,40400,40500); - lcs=ms_list_append(lcs,marie1->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,marie1->lc); + lcs=bctbx_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,pauline->lc); linphone_call_params_enable_early_media_sending(params,TRUE); linphone_call_params_enable_video(params,TRUE); @@ -1293,7 +1293,7 @@ static void multiple_early_media(void) { end_call(pauline, marie1); - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie1); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(pauline); @@ -1359,12 +1359,12 @@ static void classic_video_entry_phone_setup(void) { LinphoneCallParams *in_call_params = NULL; LinphoneCall *callee_call = NULL; LinphoneVideoPolicy vpol = { TRUE, TRUE }; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; int retry = 0; bool_t ok; - lcs = ms_list_append(lcs, caller_mgr->lc); - lcs = ms_list_append(lcs, callee_mgr->lc); + lcs = bctbx_list_append(lcs, caller_mgr->lc); + lcs = bctbx_list_append(lcs, callee_mgr->lc); linphone_core_enable_video_capture(caller_mgr->lc, TRUE); linphone_core_enable_video_display(caller_mgr->lc, TRUE); @@ -1443,7 +1443,7 @@ static void classic_video_entry_phone_setup(void) { end: linphone_core_manager_destroy(callee_mgr); linphone_core_manager_destroy(caller_mgr); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void video_call_recording_h264_test(void) { record_call("recording", TRUE, "H264"); @@ -1495,7 +1495,7 @@ static void video_call_with_re_invite_inactive_followed_by_re_invite_base(Linpho LinphoneCoreManager* pauline; LinphoneCallParams *params; const LinphoneCallParams *current_params; - MSList *lcs=NULL; + bctbx_list_t *lcs=NULL; bool_t calls_ok; marie = linphone_core_manager_new( "marie_rc"); @@ -1512,8 +1512,8 @@ static void video_call_with_re_invite_inactive_followed_by_re_invite_base(Linpho linphone_core_set_video_device(pauline->lc,liblinphone_tester_mire_id); linphone_core_set_video_device(marie->lc,liblinphone_tester_mire_id); linphone_core_set_avpf_mode(marie->lc,TRUE); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); video_call_base_2(marie,pauline,TRUE,mode,TRUE,TRUE); @@ -1662,9 +1662,9 @@ static void video_call_with_no_audio_and_no_video_codec(void){ LinphoneVideoPolicy callee_policy, caller_policy; LinphoneCallTestParams caller_test_params = {0}, callee_test_params = {0}; - const MSList* elem_video =linphone_core_get_video_codecs(caller->lc); + const bctbx_list_t* elem_video =linphone_core_get_video_codecs(caller->lc); - const MSList* elem_audio =linphone_core_get_audio_codecs(caller->lc); + const bctbx_list_t* elem_audio =linphone_core_get_audio_codecs(caller->lc); disable_all_codecs(elem_audio, caller); disable_all_codecs(elem_video, caller); diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index 9ddf99ff6..6baf10504 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -129,8 +129,8 @@ static void subscribe_test_declined(void) { LinphoneContent* content; LinphoneEvent *lev; const LinphoneErrorInfo *ei; - MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); @@ -171,9 +171,9 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes LinphoneContent* content; LinphoneEvent *lev; int expires= refresh_type!=NoRefresh ? 4 : 600; - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,pauline->lc); if (refresh_type==ManualRefresh){ lp_config_set_int(marie->lc->config,"sip","refresh_generic_subscribe",0); @@ -224,9 +224,9 @@ static void subscribe_test_with_args2(bool_t terminated_by_subscriber, RefreshTe LinphoneContent* content; LinphoneEvent *lev; int expires= refresh_type!=NoRefresh ? 4 : 600; - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,pauline->lc); if (refresh_type==ManualRefresh){ lp_config_set_int(marie->lc->config,"sip","refresh_generic_subscribe",0); @@ -308,8 +308,8 @@ static void publish_test_with_args(bool_t refresh, int expires){ LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneContent* content; LinphoneEvent *lev; - MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); @@ -363,8 +363,8 @@ static void out_of_dialog_notify(void){ LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneContent* content; LinphoneEvent *lev; - MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); + lcs=bctbx_list_append(lcs,pauline->lc); content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index 96cf74252..1310aab47 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -29,10 +29,10 @@ static void subscribe_forking(void) { LinphoneContent* content; LinphoneEvent *lev; int expires= 600; - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,pauline2->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,pauline2->lc); content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); @@ -55,20 +55,20 @@ static void subscribe_forking(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline2); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void message_forking(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); LinphoneChatRoom* chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu"); LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(message); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,marie2->lc); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); linphone_chat_room_send_chat_message(chat_room, message); @@ -84,7 +84,7 @@ static void message_forking(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(pauline); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void message_forking_with_unreachable_recipients(void) { @@ -92,14 +92,14 @@ static void message_forking_with_unreachable_recipients(void) { LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); LinphoneChatRoom* chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu"); LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(message); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,marie3->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,marie3->lc); /*the following lines are to workaround a problem with messages sent by a previous test (Message forking) that arrive together with REGISTER responses, * because the ForkMessageContext is not terminated at flexisip side if Message forking test is passing fast*/ @@ -134,7 +134,7 @@ static void message_forking_with_unreachable_recipients(void) { linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); linphone_core_manager_destroy(pauline); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void message_forking_with_all_recipients_unreachable(void) { @@ -142,14 +142,14 @@ static void message_forking_with_all_recipients_unreachable(void) { LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); LinphoneChatRoom* chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu"); LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(message); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,marie3->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,marie3->lc); /*the following lines are to workaround a problem with messages sent by a previous test (Message forking) that arrive together with REGISTER responses, * because the ForkMessageContext is not terminated at flexisip side if Message forking test is passing fast*/ @@ -193,7 +193,7 @@ static void message_forking_with_all_recipients_unreachable(void) { linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); linphone_core_manager_destroy(pauline); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void call_forking(void){ @@ -201,11 +201,11 @@ static void call_forking(void){ LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); - MSList* lcs=ms_list_append(NULL,pauline->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,marie3->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,marie3->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); @@ -239,7 +239,7 @@ static void call_forking(void){ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void call_forking_with_urgent_reply(void){ @@ -247,10 +247,10 @@ static void call_forking_with_urgent_reply(void){ LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); - MSList* lcs=ms_list_append(NULL,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,marie3->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,marie3->lc); if (linphone_core_media_encryption_supported(pauline->lc,LinphoneMediaEncryptionSRTP)) { linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); @@ -284,7 +284,7 @@ static void call_forking_with_urgent_reply(void){ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void call_forking_cancelled(void){ @@ -292,11 +292,11 @@ static void call_forking_cancelled(void){ LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); - MSList* lcs=ms_list_append(NULL,pauline->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,marie3->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,marie3->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); @@ -324,7 +324,7 @@ static void call_forking_cancelled(void){ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void call_forking_declined(bool_t declined_globaly){ @@ -332,11 +332,11 @@ static void call_forking_declined(bool_t declined_globaly){ LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); - MSList* lcs=ms_list_append(NULL,pauline->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,marie3->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,marie3->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); @@ -379,7 +379,7 @@ static void call_forking_declined(bool_t declined_globaly){ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void call_forking_declined_globaly(void){ @@ -391,7 +391,7 @@ static void call_forking_declined_localy(void){ } static void call_forking_with_push_notification_single(void){ - MSList* lcs; + bctbx_list_t* lcs; LinphoneCoreManager* marie = linphone_core_manager_new2( "marie_rc", FALSE); LinphoneCoreManager* pauline = linphone_core_manager_new2( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc",FALSE); int dummy=0; @@ -402,8 +402,8 @@ static void call_forking_with_push_notification_single(void){ linphone_core_get_default_proxy_config(marie->lc), "app-id=org.linphonetester;pn-tok=aaabbb;pn-type=apple;pn-msg-str=33;pn-call-str=34;"); - lcs=ms_list_append(NULL,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); + lcs=bctbx_list_append(NULL,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneRegistrationOk,1,5000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneRegistrationOk,1,5000)); @@ -437,7 +437,7 @@ static void call_forking_with_push_notification_single(void){ linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void call_forking_with_push_notification_multiple(void){ @@ -445,10 +445,10 @@ static void call_forking_with_push_notification_multiple(void){ LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); - MSList* lcs=ms_list_append(NULL,pauline->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,marie2->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); @@ -497,11 +497,11 @@ static void call_forking_not_responded(void){ LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); - MSList* lcs=ms_list_append(NULL,pauline->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,marie3->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,marie3->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); @@ -527,14 +527,14 @@ static void call_forking_not_responded(void){ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void early_media_call_forking(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_early_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new("marie_early_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - MSList *lcs=NULL; + bctbx_list_t *lcs=NULL; LinphoneCallParams *params=linphone_core_create_call_params(pauline->lc, NULL); LinphoneVideoPolicy pol; int dummy=0; @@ -560,9 +560,9 @@ static void early_media_call_forking(void) { linphone_core_set_audio_port_range(marie2->lc,40200,40300); linphone_core_set_video_port_range(marie2->lc,40400,40500); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,marie2->lc); - lcs=ms_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,marie2->lc); + lcs=bctbx_list_append(lcs,pauline->lc); linphone_call_params_enable_early_media_sending(params,TRUE); linphone_call_params_enable_video(params,TRUE); @@ -600,7 +600,7 @@ static void early_media_call_forking(void) { end_call(pauline, marie); - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie); @@ -611,10 +611,10 @@ static void call_with_sips(void){ LinphoneCoreManager* marie = linphone_core_manager_new( "marie_sips_rc"); LinphoneCoreManager* pauline1 = linphone_core_manager_new( "pauline_sips_rc"); LinphoneCoreManager* pauline2 = linphone_core_manager_new( "pauline_tcp_rc"); - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline1->lc); - lcs=ms_list_append(lcs,pauline2->lc); + lcs=bctbx_list_append(lcs,pauline1->lc); + lcs=bctbx_list_append(lcs,pauline2->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(pauline1->lc,"Natted Linphone",NULL); @@ -644,7 +644,7 @@ static void call_with_sips(void){ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline1); linphone_core_manager_destroy(pauline2); - ms_list_free(lcs); + bctbx_list_free(lcs); } } @@ -653,13 +653,13 @@ static void call_with_sips_not_achievable(void){ LinphoneCoreManager* pauline2 = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCoreManager* marie = linphone_core_manager_new( "marie_sips_rc"); LinphoneCoreManager* pauline1 = linphone_core_manager_new( "pauline_rc"); - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); LinphoneAddress *dest; LinphoneCall *call; const LinphoneErrorInfo *ei; - lcs=ms_list_append(lcs,pauline1->lc); - lcs=ms_list_append(lcs,pauline2->lc); + lcs=bctbx_list_append(lcs,pauline1->lc); + lcs=bctbx_list_append(lcs,pauline2->lc); dest=linphone_address_clone(pauline1->identity); @@ -679,7 +679,7 @@ static void call_with_sips_not_achievable(void){ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline1); linphone_core_manager_destroy(pauline2); - ms_list_free(lcs); + bctbx_list_free(lcs); } } @@ -1079,7 +1079,7 @@ static void test_list_subscribe (void) { LinphoneEvent *lev; - MSList* lcs=ms_list_append(NULL,marie->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,marie->lc); char * pauline_uri=linphone_address_as_string_uri_only(pauline->identity); char * laure_uri=linphone_address_as_string_uri_only(laure->identity); char * subscribe_content = ms_strdup_printf(list,pauline_uri,laure_uri); @@ -1091,8 +1091,8 @@ static void test_list_subscribe (void) { ms_free(pauline_uri); ms_free(laure_uri); - lcs=ms_list_append(lcs,pauline->lc); - lcs=ms_list_append(lcs,laure->lc); + lcs=bctbx_list_append(lcs,pauline->lc); + lcs=bctbx_list_append(lcs,laure->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"resource-lists+xml"); diff --git a/tester/message_tester.c b/tester/message_tester.c index 27ed406d3..f822600d4 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -362,15 +362,15 @@ static void text_message_with_send_error(void) { linphone_chat_room_send_chat_message(chat_room,msg); /* check transient msg list: the msg should be in it, and should be the only one */ - BC_ASSERT_EQUAL(ms_list_size(chat_room->transient_messages), 1, int, "%d"); - BC_ASSERT_PTR_EQUAL(ms_list_nth_data(chat_room->transient_messages,0), msg); + BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 1, int, "%d"); + BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(chat_room->transient_messages,0), msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageNotDelivered,1)); /*BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageInProgress,1, int, "%d");*/ BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageReceived,0, int, "%d"); /* the msg should have been discarded from transient list after an error */ - BC_ASSERT_EQUAL(ms_list_size(chat_room->transient_messages), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 0, int, "%d"); sal_set_send_error(marie->lc->sal, 0); @@ -396,8 +396,8 @@ static void text_message_with_external_body(void) { linphone_chat_room_send_chat_message(chat_room,msg); /* check transient msg list: the msg should be in it, and should be the only one */ - BC_ASSERT_EQUAL(ms_list_size(chat_room->transient_messages), 1, int, "%d"); - BC_ASSERT_PTR_EQUAL(ms_list_nth_data(chat_room->transient_messages,0), msg); + BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 1, int, "%d"); + BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(chat_room->transient_messages,0), msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived,1)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1)); @@ -405,7 +405,7 @@ static void text_message_with_external_body(void) { BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,1, int, "%d"); - BC_ASSERT_EQUAL(ms_list_size(chat_room->transient_messages), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(chat_room->transient_messages), 0, int, "%d"); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); @@ -615,17 +615,17 @@ static void file_transfer_2_messages_simultaneously(void) { cbs = linphone_chat_message_get_callbacks(msg2); linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); - BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_chat_rooms(marie->lc)), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 0, int, "%d"); linphone_chat_room_send_chat_message(pauline_room,msg); linphone_chat_room_send_chat_message(pauline_room,msg2); if (BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1))) { msg = linphone_chat_message_clone(marie->stat.last_received_chat_message); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,2)); msg2 = marie->stat.last_received_chat_message; - BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_chat_rooms(marie->lc)), 1, int, "%d"); - if (ms_list_size(linphone_core_get_chat_rooms(marie->lc)) != 1) { - char * buf = ms_strdup_printf("Found %d rooms instead of 1: ", ms_list_size(linphone_core_get_chat_rooms(marie->lc))); - const MSList *it = linphone_core_get_chat_rooms(marie->lc); + BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 1, int, "%d"); + if (bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)) != 1) { + char * buf = ms_strdup_printf("Found %d rooms instead of 1: ", bctbx_list_size(linphone_core_get_chat_rooms(marie->lc))); + const bctbx_list_t *it = linphone_core_get_chat_rooms(marie->lc); while (it) { const LinphoneAddress * peer = linphone_chat_room_get_peer_address(it->data); buf = ms_strcat_printf("%s, ", linphone_address_get_username(peer)); @@ -1155,16 +1155,16 @@ int check_no_strange_time(void* data,int argc, char** argv,char** cNames) { } void history_message_count_helper(LinphoneChatRoom* chatroom, int x, int y, int expected ){ - MSList* messages = linphone_chat_room_get_history_range(chatroom, x, y); - BC_ASSERT_EQUAL(ms_list_size(messages), expected, int, "%d"); - ms_list_free_with_data(messages, (void (*)(void *))linphone_chat_message_unref); + bctbx_list_t* messages = linphone_chat_room_get_history_range(chatroom, x, y); + BC_ASSERT_EQUAL(bctbx_list_size(messages), expected, int, "%d"); + bctbx_list_free_with_data(messages, (void (*)(void *))linphone_chat_message_unref); } static void database_migration(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); char *src_db = bc_tester_res("messages.db"); char *tmp_db = bc_tester_file("tmp.db"); - const MSList* chatrooms; + const bctbx_list_t* chatrooms; BC_ASSERT_EQUAL(message_tester_copy_file(src_db, tmp_db), 0, int, "%d"); @@ -1178,7 +1178,7 @@ static void database_migration(void) { if (!marie->lc->db) goto end; chatrooms = linphone_core_get_chat_rooms(marie->lc); - BC_ASSERT(ms_list_size(chatrooms) > 0); + BC_ASSERT(bctbx_list_size(chatrooms) > 0); // check that all messages have been migrated to the UTC time storage BC_ASSERT(sqlite3_exec(marie->lc->db, "SELECT COUNT(*) FROM history WHERE time != '-1';", check_no_strange_time, NULL, NULL) == SQLITE_OK ); @@ -1238,7 +1238,7 @@ static void history_count(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); LinphoneAddress *jehan_addr = linphone_address_new(""); LinphoneChatRoom *chatroom; - MSList *messages; + bctbx_list_t *messages; char *src_db = bc_tester_res("messages.db"); char *tmp_db = bc_tester_file("tmp.db"); @@ -1252,16 +1252,16 @@ static void history_count(void) { BC_ASSERT_PTR_NOT_NULL(chatroom); if (chatroom){ messages=linphone_chat_room_get_history(chatroom,10); - BC_ASSERT_EQUAL(ms_list_size(messages), 10, int, "%d"); - ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); + BC_ASSERT_EQUAL(bctbx_list_size(messages), 10, int, "%d"); + bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); messages=linphone_chat_room_get_history(chatroom,1); - BC_ASSERT_EQUAL(ms_list_size(messages), 1, int, "%d"); - ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); + BC_ASSERT_EQUAL(bctbx_list_size(messages), 1, int, "%d"); + bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); messages=linphone_chat_room_get_history(chatroom,0); BC_ASSERT_EQUAL(linphone_chat_room_get_history_size(chatroom), 1270, int, "%d"); - BC_ASSERT_EQUAL(ms_list_size(messages), 1270, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(messages), 1270, int, "%d"); /*check the second most recent msg*/ BC_ASSERT_PTR_NOT_NULL(messages); @@ -1272,28 +1272,28 @@ static void history_count(void) { } } - ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); + bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); /*test offset+limit: retrieve the 42th latest msg only and check its content*/ messages=linphone_chat_room_get_history_range(chatroom, 42, 42); - BC_ASSERT_EQUAL(ms_list_size(messages), 1, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(messages), 1, int, "%d"); BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text((LinphoneChatMessage *)messages->data), "If you open yourself to the Tao is intangible and evasive, yet prefers to keep us at the mercy of the kingdom, then all of the streams of hundreds of valleys because of its limitless possibilities."); - ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); + bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); /*test offset without limit*/ messages = linphone_chat_room_get_history_range(chatroom, 1265, -1); - BC_ASSERT_EQUAL(ms_list_size(messages), 1270-1265, int, "%d"); - ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); + BC_ASSERT_EQUAL(bctbx_list_size(messages), 1270-1265, int, "%d"); + bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); /*test limit without offset*/ messages = linphone_chat_room_get_history_range(chatroom, 0, 5); - BC_ASSERT_EQUAL(ms_list_size(messages), 6, int, "%d"); - ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); + BC_ASSERT_EQUAL(bctbx_list_size(messages), 6, int, "%d"); + bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); /*test invalid start*/ messages = linphone_chat_room_get_history_range(chatroom, 1265, 1260); - BC_ASSERT_EQUAL(ms_list_size(messages), 1270-1265, int, "%d"); - ms_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); + BC_ASSERT_EQUAL(bctbx_list_size(messages), 1270-1265, int, "%d"); + bctbx_list_free_with_data(messages, (void (*)(void*))linphone_chat_message_unref); } end: @@ -1381,7 +1381,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo } if (mess_with_marie_payload_number) { - MSList *elem; + bctbx_list_t *elem; for (elem = marie->lc->codecs_conf.text_codecs; elem != NULL; elem = elem->next) { PayloadType *pt = (PayloadType*)elem->data; if (strcasecmp(pt->mime_type, payload_type_t140.mime_type) == 0) { @@ -1390,7 +1390,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo } } } else if (mess_with_pauline_payload_number) { - MSList *elem; + bctbx_list_t *elem; for (elem = pauline->lc->codecs_conf.text_codecs; elem != NULL; elem = elem->next) { PayloadType *pt = (PayloadType*)elem->data; if (strcasecmp(pt->mime_type, payload_type_t140.mime_type) == 0) { @@ -1447,16 +1447,16 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1)); if (sql_storage) { - MSList *marie_messages = linphone_chat_room_get_history(marie_chat_room, 0); - MSList *pauline_messages = linphone_chat_room_get_history(pauline_chat_room, 0); + bctbx_list_t *marie_messages = linphone_chat_room_get_history(marie_chat_room, 0); + bctbx_list_t *pauline_messages = linphone_chat_room_get_history(pauline_chat_room, 0); LinphoneChatMessage *marie_msg = NULL; LinphoneChatMessage *pauline_msg = NULL; if (do_not_store_rtt_messages_in_sql_storage) { - BC_ASSERT_EQUAL(ms_list_size(marie_messages), 0, int , "%i"); - BC_ASSERT_EQUAL(ms_list_size(pauline_messages), 0, int , "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(marie_messages), 0, int , "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(pauline_messages), 0, int , "%i"); } else { - BC_ASSERT_EQUAL(ms_list_size(marie_messages), 1, int , "%i"); - BC_ASSERT_EQUAL(ms_list_size(pauline_messages), 1, int , "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(marie_messages), 1, int , "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(pauline_messages), 1, int , "%i"); if (!marie_messages || !pauline_messages) { goto end; } @@ -1464,8 +1464,8 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo pauline_msg = (LinphoneChatMessage *)pauline_messages->data; BC_ASSERT_STRING_EQUAL(marie_msg->message, message); BC_ASSERT_STRING_EQUAL(pauline_msg->message, message); - ms_list_free_with_data(marie_messages, (void (*)(void *))linphone_chat_message_unref); - ms_list_free_with_data(pauline_messages, (void (*)(void *))linphone_chat_message_unref); + bctbx_list_free_with_data(marie_messages, (void (*)(void *))linphone_chat_message_unref); + bctbx_list_free_with_data(pauline_messages, (void (*)(void *))linphone_chat_message_unref); } } } diff --git a/tester/presence_server_tester.c b/tester/presence_server_tester.c index a82f83898..25034f834 100644 --- a/tester/presence_server_tester.c +++ b/tester/presence_server_tester.c @@ -121,13 +121,13 @@ static void subscriber_no_longer_reachable(void){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline1 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneFriend *lf; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; LinphonePresenceModel * presence; int previous_number_of_LinphonePresenceActivityOnline=0; int previous_number_of_LinphonePresenceActivityOffline=0; - lcs = ms_list_append(lcs, marie->lc); - lcs = ms_list_append(lcs, pauline1->lc); + lcs = bctbx_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline1->lc); lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 40); linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL); @@ -176,7 +176,7 @@ static void subscriber_no_longer_reachable(void){ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline1); - ms_list_free(lcs); + bctbx_list_free(lcs); } @@ -265,10 +265,10 @@ static void test_forked_subscribe_notify_publish(void) { LpConfig *pauline_lp; char* lf_identity; LinphoneFriend *lf; - MSList* lcs=ms_list_append(NULL,pauline->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,marie->lc); - lcs=ms_list_append(lcs,marie2->lc); + bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,marie->lc); + lcs=bctbx_list_append(lcs,marie2->lc); linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL); linphone_core_set_user_agent(marie2->lc, "full-presence-support", NULL); linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL); @@ -334,7 +334,7 @@ static void test_presence_list_base(bool_t enable_compression) { const char *laure_identity; const char *marie_identity; const char *pauline_identity; - MSList* lcs = NULL; + bctbx_list_t* lcs = NULL; laure_identity = get_identity(laure); marie_identity = get_identity(marie); @@ -365,9 +365,9 @@ static void test_presence_list_base(bool_t enable_compression) { linphone_friend_list_unref(lfl); linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL)); - lcs = ms_list_append(lcs, laure->lc); - lcs = ms_list_append(lcs, marie->lc); - lcs = ms_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, laure->lc); + lcs = bctbx_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline->lc); wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 2, 4000); BC_ASSERT_EQUAL(laure->stat.number_of_NotifyPresenceReceived, 2, int, "%d"); @@ -497,7 +497,7 @@ static void test_presence_list_subscribe_before_publish(void) { LinphoneFriendList *lfl; LinphoneFriend *lf; const char *pauline_identity; - MSList* lcs = NULL; + bctbx_list_t* lcs = NULL; int dummy = 0; pauline_identity = get_identity(pauline); @@ -516,8 +516,8 @@ static void test_presence_list_subscribe_before_publish(void) { linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL)); linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(laure->lc), NULL, FALSE); - lcs = ms_list_append(lcs, laure->lc); - lcs = ms_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, laure->lc); + lcs = bctbx_list_append(lcs, pauline->lc); wait_for_list(lcs, &dummy, 1, 2000); /* Wait a little bit for the subscribe to happen */ @@ -572,7 +572,7 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { LinphoneFriendList *lfl; LinphoneFriend *lf; const char *pauline_identity; - MSList* lcs = NULL; + bctbx_list_t* lcs = NULL; int dummy = 0; lp_config_set_int(laure->lc->config, "sip", "rls_presence_expires", 5); @@ -594,8 +594,8 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { linphone_friend_list_unref(lfl); linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL)); linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(laure->lc), NULL, FALSE); - lcs = ms_list_append(lcs, laure->lc); - lcs = ms_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, laure->lc); + lcs = bctbx_list_append(lcs, pauline->lc); wait_for_list(lcs, &dummy, 1, 2000); /* Wait a little bit for the subscribe to happen */ diff --git a/tester/presence_tester.c b/tester/presence_tester.c index 6aca492ab..6bb1771bd 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -449,11 +449,11 @@ static void subscribe_presence_forked(void){ LinphoneCoreManager* pauline1 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_tcp_rc" : "pauline_tcp_rc"); LinphoneCoreManager* pauline2 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_tcp_rc" : "pauline_tcp_rc"); LinphoneFriend *lf; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; - lcs = ms_list_append(lcs, marie->lc); - lcs = ms_list_append(lcs, pauline1->lc); - lcs = ms_list_append(lcs, pauline2->lc); + lcs = bctbx_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline1->lc); + lcs = bctbx_list_append(lcs, pauline2->lc); lf = linphone_core_create_friend(marie->lc); linphone_friend_set_address(lf, pauline1->identity); @@ -480,17 +480,17 @@ static void subscribe_presence_forked(void){ linphone_core_manager_destroy(pauline1); linphone_core_manager_destroy(pauline2); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void subscribe_presence_expired(void){ LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline1 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneFriend *lf; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; - lcs = ms_list_append(lcs, marie->lc); - lcs = ms_list_append(lcs, pauline1->lc); + lcs = bctbx_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, pauline1->lc); lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 10); @@ -521,7 +521,7 @@ static void subscribe_presence_expired(void){ linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline1); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void simple_subscribe_with_friend_from_rc(void) { @@ -529,9 +529,9 @@ static void simple_subscribe_with_friend_from_rc(void) { LinphoneCoreManager *marie = presence_linphone_core_manager_new_with_rc_name("marie", "pauline_as_friend_rc"); LinphoneFriend *pauline_as_friend; - BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_friend_list(marie->lc)), 1, int , "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_friend_list(marie->lc)), 1, int , "%i"); - if (ms_list_size(linphone_core_get_friend_list(marie->lc))>0) { + if (bctbx_list_size(linphone_core_get_friend_list(marie->lc))>0) { pauline_as_friend = (LinphoneFriend*)linphone_core_get_friend_list(marie->lc)->data; linphone_friend_set_address(pauline_as_friend, pauline->identity); /*hack to update addr with port number*/ } diff --git a/tester/quality_reporting_tester.c b/tester/quality_reporting_tester.c index 62f126f6f..31ec4d7a5 100644 --- a/tester/quality_reporting_tester.c +++ b/tester/quality_reporting_tester.c @@ -165,7 +165,7 @@ static void quality_reporting_not_sent_if_call_not_started(void) { BC_ASSERT_TRUE(wait_for_until(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallError,1, 10000)); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1, int, "%d"); - if (ms_list_size(linphone_core_get_call_logs(marie->lc))>0) { + if (bctbx_list_size(linphone_core_get_call_logs(marie->lc))>0) { out_call_log=(LinphoneCallLog*)(linphone_core_get_call_logs(marie->lc)->data); BC_ASSERT_PTR_NOT_NULL(out_call_log); BC_ASSERT_EQUAL(linphone_call_log_get_status(out_call_log),LinphoneCallAborted, int, "%d"); diff --git a/tester/register_tester.c b/tester/register_tester.c index edcaf89d4..d9a33a4e2 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -505,7 +505,7 @@ static LinphoneCoreManager* configure_lcm(void) { if (transport_supported(LinphoneTransportTls)) { LinphoneCoreManager *lcm=linphone_core_manager_new2( "multi_account_rc", FALSE); stats *counters=&lcm->stat; - BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,ms_list_size(linphone_core_get_proxy_config_list(lcm->lc)))); + BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc)))); BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0, int, "%d"); return lcm; } @@ -541,7 +541,7 @@ static void network_state_change(void){ static int get_number_of_udp_proxy(const LinphoneCore* lc) { int number_of_udp_proxy=0; LinphoneProxyConfig* proxy_cfg; - const MSList* proxys; + const bctbx_list_t* proxys; for (proxys=linphone_core_get_proxy_config_list(lc);proxys!=NULL;proxys=proxys->next) { proxy_cfg=(LinphoneProxyConfig*)proxys->data; if (strcmp("udp",linphone_proxy_config_get_transport(proxy_cfg))==0) @@ -567,7 +567,7 @@ static void transport_change(void){ register_ok=counters->number_of_LinphoneRegistrationOk; number_of_udp_proxy=get_number_of_udp_proxy(lc); - total_number_of_proxies=ms_list_size(linphone_core_get_proxy_config_list(lc)); + total_number_of_proxies=bctbx_list_size(linphone_core_get_proxy_config_list(lc)); linphone_core_get_sip_transports(lc,&sip_tr_orig); sip_tr.udp_port=sip_tr_orig.udp_port; @@ -734,12 +734,12 @@ static void io_recv_error_late_recovery(void){ int register_ok; stats* counters ; int number_of_udp_proxy=0; - MSList* lcs; + bctbx_list_t* lcs; lcm=linphone_core_manager_new2( "multi_account_rc",FALSE); /*to make sure iterates are not call yet*/ lc=lcm->lc; sal_set_refresher_retry_after(lc->sal,1000); counters=&lcm->stat; - BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,ms_list_size(linphone_core_get_proxy_config_list(lcm->lc)))); + BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,bctbx_list_size(linphone_core_get_proxy_config_list(lcm->lc)))); counters = get_stats(lc); @@ -752,12 +752,12 @@ static void io_recv_error_late_recovery(void){ BC_ASSERT_TRUE(wait_for(lc,NULL,&counters->number_of_LinphoneRegistrationProgress,(register_ok-number_of_udp_proxy)+register_ok /*because 1 udp*/)); BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0,int,"%d"); - BC_ASSERT_TRUE(wait_for_list(lcs=ms_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationFailed,(register_ok-number_of_udp_proxy),sal_get_refresher_retry_after(lc->sal)+3000)); + BC_ASSERT_TRUE(wait_for_list(lcs=bctbx_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationFailed,(register_ok-number_of_udp_proxy),sal_get_refresher_retry_after(lc->sal)+3000)); sal_set_recv_error(lc->sal, 1); /*reset*/ sal_set_send_error(lc->sal, 0); - BC_ASSERT_TRUE(wait_for_list(lcs=ms_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationOk,register_ok-number_of_udp_proxy +register_ok,sal_get_refresher_retry_after(lc->sal)+3000)); + BC_ASSERT_TRUE(wait_for_list(lcs=bctbx_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationOk,register_ok-number_of_udp_proxy +register_ok,sal_get_refresher_retry_after(lc->sal)+3000)); linphone_core_manager_destroy(lcm); } } @@ -767,7 +767,7 @@ static void io_recv_error_without_active_register(void){ LinphoneCore* lc; int register_ok; stats* counters ; - MSList* proxys; + bctbx_list_t* proxys; int dummy=0; lcm=configure_lcm(); @@ -777,13 +777,13 @@ static void io_recv_error_without_active_register(void){ register_ok=counters->number_of_LinphoneRegistrationOk; - for (proxys=ms_list_copy(linphone_core_get_proxy_config_list(lc));proxys!=NULL;proxys=proxys->next) { + for (proxys=bctbx_list_copy(linphone_core_get_proxy_config_list(lc));proxys!=NULL;proxys=proxys->next) { LinphoneProxyConfig* proxy_cfg=(LinphoneProxyConfig*)proxys->data; linphone_proxy_config_edit(proxy_cfg); linphone_proxy_config_enableregister(proxy_cfg,FALSE); linphone_proxy_config_done(proxy_cfg); } - ms_list_free(proxys); + bctbx_list_free(proxys); /*wait for unregistrations*/ BC_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationCleared,register_ok /*because 1 udp*/)); @@ -791,7 +791,7 @@ static void io_recv_error_without_active_register(void){ /*nothing should happen because no active registration*/ wait_for_until(lc,lc, &dummy, 1, 3000); - BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress, ms_list_size(linphone_core_get_proxy_config_list(lc)), int, "%d"); + BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress, bctbx_list_size(linphone_core_get_proxy_config_list(lc)), int, "%d"); BC_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0,int,"%d"); diff --git a/tester/setup_tester.c b/tester/setup_tester.c index 160856f7c..cd1e9d142 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -338,7 +338,7 @@ end: static void codec_setup(void){ LinphoneCoreManager *mgr = linphone_core_manager_new2("empty_rc", FALSE); PayloadType *vp8, *h264; - const MSList *codecs; + const bctbx_list_t *codecs; if ((vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1)) == NULL || (h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1)) == NULL){ linphone_core_manager_destroy(mgr); @@ -347,7 +347,7 @@ static void codec_setup(void){ return; } codecs = linphone_core_get_video_codecs(mgr->lc); - BC_ASSERT_TRUE(ms_list_size(codecs)>=2); + BC_ASSERT_TRUE(bctbx_list_size(codecs)>=2); BC_ASSERT_TRUE(codecs->data == vp8); BC_ASSERT_TRUE(codecs->next->data == h264); linphone_core_manager_destroy(mgr); @@ -356,7 +356,7 @@ static void codec_setup(void){ vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1); h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1); codecs = linphone_core_get_video_codecs(mgr->lc); - BC_ASSERT_TRUE(ms_list_size(codecs)>=2); + BC_ASSERT_TRUE(bctbx_list_size(codecs)>=2); BC_ASSERT_PTR_NOT_NULL(vp8); BC_ASSERT_PTR_NOT_NULL(h264); BC_ASSERT_TRUE(codecs->data == vp8); @@ -367,7 +367,7 @@ static void codec_setup(void){ vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1); h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1); codecs = linphone_core_get_video_codecs(mgr->lc); - BC_ASSERT_TRUE(ms_list_size(codecs)>=2); + BC_ASSERT_TRUE(bctbx_list_size(codecs)>=2); BC_ASSERT_PTR_NOT_NULL(vp8); BC_ASSERT_PTR_NOT_NULL(h264); BC_ASSERT_TRUE(codecs->data == vp8); diff --git a/tester/stun_tester.c b/tester/stun_tester.c index b05471a49..3967ebb44 100644 --- a/tester/stun_tester.c +++ b/tester/stun_tester.c @@ -127,12 +127,12 @@ static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t LinphoneCall *lcall; LinphoneIceState expected_ice_state = LinphoneIceStateHostConnection; LinphoneMediaDirection expected_video_dir = LinphoneMediaDirectionInactive; - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; marie = linphone_core_manager_new("marie_rc"); - lcs = ms_list_append(lcs, marie->lc); + lcs = bctbx_list_append(lcs, marie->lc); pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); - lcs = ms_list_append(lcs, pauline->lc); + lcs = bctbx_list_append(lcs, pauline->lc); configure_nat_policy(marie->lc, caller_turn_enabled); configure_nat_policy(pauline->lc, callee_turn_enabled); @@ -180,7 +180,7 @@ static void ice_turn_call_base(bool_t video_enabled, bool_t forced_relay, bool_t linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); - ms_list_free(lcs); + bctbx_list_free(lcs); } static void basic_ice_turn_call(void) { diff --git a/tester/tester.c b/tester/tester.c index c8a896ea6..3861cf421 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -173,14 +173,14 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c bool_t wait_for_until(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value,int timout) { - MSList* lcs=NULL; + bctbx_list_t* lcs=NULL; bool_t result; if (lc_1) - lcs=ms_list_append(lcs,lc_1); + lcs=bctbx_list_append(lcs,lc_1); if (lc_2) - lcs=ms_list_append(lcs,lc_2); + lcs=bctbx_list_append(lcs,lc_2); result=wait_for_list(lcs,counter,value,timout); - ms_list_free(lcs); + bctbx_list_free(lcs); return result; } @@ -188,8 +188,8 @@ bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value) { return wait_for_until(lc_1, lc_2,counter,value,10000); } -bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) { - MSList* iterator; +bool_t wait_for_list(bctbx_list_t* lcs,int* counter,int value,int timeout_ms) { + bctbx_list_t* iterator; MSTimeSpec start; liblinphone_tester_clock_start(&start); @@ -229,8 +229,8 @@ bool_t wait_for_stun_resolution(LinphoneCoreManager *m) { } static void set_codec_enable(LinphoneCore* lc,const char* type,int rate,bool_t enable) { - MSList* codecs=ms_list_copy(linphone_core_get_audio_codecs(lc)); - MSList* codecs_it; + bctbx_list_t* codecs=bctbx_list_copy(linphone_core_get_audio_codecs(lc)); + bctbx_list_t* codecs_it; PayloadType* pt; for (codecs_it=codecs;codecs_it!=NULL;codecs_it=codecs_it->next) { linphone_core_enable_payload_type(lc,(PayloadType*)codecs_it->data,0); @@ -238,7 +238,7 @@ static void set_codec_enable(LinphoneCore* lc,const char* type,int rate,bool_t e if ((pt = linphone_core_find_payload_type(lc,type,rate,1))) { linphone_core_enable_payload_type(lc,pt, enable); } - ms_list_free(codecs); + bctbx_list_free(codecs); } static void enable_codec(LinphoneCore* lc,const char* type,int rate) { @@ -350,9 +350,9 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies LinphoneNatPolicy *nat_policy; int proxy_count; - /*BC_ASSERT_EQUAL(ms_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count, int, "%d");*/ + /*BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count, int, "%d");*/ if (check_for_proxies){ /**/ - proxy_count=ms_list_size(linphone_core_get_proxy_config_list(mgr->lc)); + proxy_count=bctbx_list_size(linphone_core_get_proxy_config_list(mgr->lc)); }else{ proxy_count=0; /*this is to prevent registration to go on*/ diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 9bb23efa8..bf08140fb 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -30,16 +30,16 @@ static void linphone_vcard_import_export_friends_test(void) { LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE); LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc); - const MSList *friends = linphone_friend_list_get_friends(lfl); + const bctbx_list_t *friends = linphone_friend_list_get_friends(lfl); char *import_filepath = bc_tester_res("vcards/vcards.vcf"); char *export_filepath = bc_tester_file("export_vcards.vcf"); int count = 0; - BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 0, int, "%d"); count = linphone_friend_list_import_friends_from_vcard4_file(lfl, import_filepath); BC_ASSERT_EQUAL(count, 3, int, "%d"); friends = linphone_friend_list_get_friends(lfl); - BC_ASSERT_EQUAL(ms_list_size(friends), 3, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 3, int, "%d"); linphone_friend_list_export_friends_as_vcard4_file(lfl, export_filepath); @@ -47,7 +47,7 @@ static void linphone_vcard_import_export_friends_test(void) { count = linphone_friend_list_import_friends_from_vcard4_file(lfl, export_filepath); BC_ASSERT_EQUAL(count, 3, int, "%d"); friends = linphone_friend_list_get_friends(lfl); - BC_ASSERT_EQUAL(ms_list_size(friends), 3, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 3, int, "%d"); linphone_friend_list_unref(lfl); remove(export_filepath); @@ -62,7 +62,7 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) { char *import_filepath = bc_tester_res("vcards/thousand_vcards.vcf"); clock_t start, end; double elapsed = 0; - const MSList *friends = NULL; + const bctbx_list_t *friends = NULL; FILE *infile = NULL; char *buffer = NULL; long numbytes = 0; @@ -72,10 +72,10 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) { end = clock(); friends = linphone_friend_list_get_friends(lfl); - BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI + BC_ASSERT_EQUAL(bctbx_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI elapsed = (double)(end - start); - ms_error("Imported a thousand of vCards from file (only %u friends with SIP address found) in %f seconds", (unsigned int)ms_list_size(friends), elapsed / CLOCKS_PER_SEC); + ms_error("Imported a thousand of vCards from file (only %u friends with SIP address found) in %f seconds", (unsigned int)bctbx_list_size(friends), elapsed / CLOCKS_PER_SEC); lfl = linphone_core_create_friend_list(manager->lc); infile = fopen(import_filepath, "rb"); @@ -95,10 +95,10 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) { } friends = linphone_friend_list_get_friends(lfl); - BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI + BC_ASSERT_EQUAL(bctbx_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI elapsed = (double)(end - start); - ms_error("Imported a thousand of vCards from buffer (only %u friends with SIP address found) in %f seconds", (unsigned int)ms_list_size(friends), elapsed / CLOCKS_PER_SEC); + ms_error("Imported a thousand of vCards from buffer (only %u friends with SIP address found) in %f seconds", (unsigned int)bctbx_list_size(friends), elapsed / CLOCKS_PER_SEC); linphone_friend_list_unref(lfl); @@ -125,14 +125,14 @@ static void linphone_vcard_update_existing_friends_test(void) { static void linphone_vcard_phone_numbers_and_sip_addresses(void) { LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nIMPP;TYPE=home:sip:sylvain@sip.linphone.org\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); - MSList *sip_addresses = linphone_friend_get_addresses(lf); - MSList *phone_numbers = linphone_friend_get_phone_numbers(lf); + bctbx_list_t *sip_addresses = linphone_friend_get_addresses(lf); + bctbx_list_t *phone_numbers = linphone_friend_get_phone_numbers(lf); LinphoneAddress *addr = NULL; - BC_ASSERT_EQUAL(ms_list_size(sip_addresses), 2, int, "%i"); - BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 1, int, "%i"); - if (sip_addresses) ms_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref); - if (phone_numbers) ms_list_free(phone_numbers); + BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 2, int, "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 1, int, "%i"); + if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref); + if (phone_numbers) bctbx_list_free(phone_numbers); linphone_friend_unref(lf); lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n"); @@ -140,39 +140,39 @@ static void linphone_vcard_phone_numbers_and_sip_addresses(void) { sip_addresses = linphone_friend_get_addresses(lf); phone_numbers = linphone_friend_get_phone_numbers(lf); - BC_ASSERT_EQUAL(ms_list_size(sip_addresses), 0, int, "%i"); - BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 2, int, "%i"); - if (sip_addresses) ms_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref); - if (phone_numbers) ms_list_free(phone_numbers); + BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 0, int, "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 2, int, "%i"); + if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref); + if (phone_numbers) bctbx_list_free(phone_numbers); addr = linphone_address_new("sip:sylvain@sip.linphone.org"); linphone_friend_add_address(lf, addr); linphone_address_unref(addr); sip_addresses = linphone_friend_get_addresses(lf); - BC_ASSERT_EQUAL(ms_list_size(sip_addresses), 1, int, "%i"); - if (sip_addresses) ms_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref); + BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 1, int, "%i"); + if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref); linphone_friend_remove_phone_number(lf, "0952636505"); phone_numbers = linphone_friend_get_phone_numbers(lf); - BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 1, int, "%i"); - if (phone_numbers) ms_list_free(phone_numbers); + BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 1, int, "%i"); + if (phone_numbers) bctbx_list_free(phone_numbers); linphone_friend_remove_phone_number(lf, "0476010203"); phone_numbers = linphone_friend_get_phone_numbers(lf); - BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 0, int, "%i"); - if (phone_numbers) ms_list_free(phone_numbers); + BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 0, int, "%i"); + if (phone_numbers) bctbx_list_free(phone_numbers); addr = linphone_address_new("sip:sylvain@sip.linphone.org"); linphone_friend_remove_address(lf, addr); linphone_address_unref(addr); sip_addresses = linphone_friend_get_addresses(lf); - BC_ASSERT_EQUAL(ms_list_size(sip_addresses), 0, int, "%i"); - if (sip_addresses) ms_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref); + BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 0, int, "%i"); + if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref); linphone_friend_add_phone_number(lf, "+33952636505"); phone_numbers = linphone_friend_get_phone_numbers(lf); - BC_ASSERT_EQUAL(ms_list_size(phone_numbers), 1, int, "%i"); - if (phone_numbers) ms_list_free(phone_numbers); + BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 1, int, "%i"); + if (phone_numbers) bctbx_list_free(phone_numbers); linphone_friend_unref(lf); lf = NULL; @@ -184,19 +184,19 @@ static void friends_if_no_db_set(void) { LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE); LinphoneFriend *lf = linphone_core_create_friend(manager->lc); LinphoneAddress *addr = linphone_address_new("sip:sylvain@sip.linphone.org"); - const MSList *friends = NULL; + const bctbx_list_t *friends = NULL; LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); linphone_friend_set_address(lf, addr); linphone_friend_set_name(lf, "Sylvain"); linphone_friend_list_add_friend(lfl, lf); friends = linphone_friend_list_get_friends(lfl); - BC_ASSERT_EQUAL(ms_list_size(friends), 1, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 1, int, "%d"); linphone_friend_list_remove_friend(lfl, lf); linphone_friend_unref(lf); friends = linphone_friend_list_get_friends(lfl); - BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 0, int, "%d"); linphone_friend_list_unref(lfl); linphone_address_unref(addr); @@ -207,22 +207,22 @@ static void friends_migration(void) { LinphoneCoreManager* manager = linphone_core_manager_new2("friends_rc", FALSE); LpConfig *lpc = linphone_core_get_config(manager->lc); LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc); - const MSList *friends = linphone_friend_list_get_friends(lfl); - MSList *friends_from_db = NULL; + const bctbx_list_t *friends = linphone_friend_list_get_friends(lfl); + bctbx_list_t *friends_from_db = NULL; char *friends_db = bc_tester_file("friends.db"); - BC_ASSERT_EQUAL(ms_list_size(friends), 3, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 3, int, "%d"); BC_ASSERT_EQUAL(lp_config_get_int(lpc, "misc", "friends_migration_done", 0), 0, int, "%i"); unlink(friends_db); linphone_core_set_friends_database_path(manager->lc, friends_db); lfl = linphone_core_get_default_friend_list(manager->lc); friends = linphone_friend_list_get_friends(lfl); - BC_ASSERT_EQUAL(ms_list_size(friends), 3, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 3, int, "%d"); friends_from_db = linphone_core_fetch_friends_from_db(manager->lc, lfl); - BC_ASSERT_EQUAL(ms_list_size(friends_from_db), 3, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 3, int, "%d"); BC_ASSERT_EQUAL(lp_config_get_int(lpc, "misc", "friends_migration_done", 0), 1, int, "%i"); - friends_from_db = ms_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); + friends_from_db = bctbx_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); unlink(friends_db); ms_free(friends_db); linphone_core_manager_destroy(manager); @@ -255,9 +255,9 @@ static void friends_sqlite_storage(void) { LinphoneFriend *lf2 = NULL; LinphoneVcard *lvc = linphone_vcard_new(); LinphoneAddress *addr = linphone_address_new("sip:sylvain@sip.linphone.org"); - const MSList *friends = NULL; - MSList *friends_from_db = NULL; - MSList *friends_lists_from_db = NULL; + const bctbx_list_t *friends = NULL; + bctbx_list_t *friends_from_db = NULL; + bctbx_list_t *friends_lists_from_db = NULL; char *friends_db = bc_tester_file("friends.db"); LinphoneFriendListStats *stats = (LinphoneFriendListStats *)ms_new0(LinphoneFriendListStats, 1); @@ -267,12 +267,12 @@ static void friends_sqlite_storage(void) { friends = linphone_friend_list_get_friends(linphone_core_get_default_friend_list(lc)); lfl = linphone_core_create_friend_list(lc); linphone_friend_list_set_user_data(lfl, stats); - BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 0, int, "%d"); unlink(friends_db); linphone_core_set_friends_database_path(lc, friends_db); friends_from_db = linphone_core_fetch_friends_from_db(lc, linphone_core_get_default_friend_list(lc)); - BC_ASSERT_EQUAL(ms_list_size(friends_from_db), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 0, int, "%d"); linphone_vcard_set_etag(lvc, "\"123-456789\""); linphone_vcard_set_url(lvc, "http://dav.somewhere.fr/addressbook/me/someone.vcf"); @@ -291,20 +291,20 @@ static void friends_sqlite_storage(void) { BC_ASSERT_EQUAL(lf->storage_id, 1, unsigned int, "%u"); friends = linphone_friend_list_get_friends(linphone_core_get_default_friend_list(lc)); - BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 0, int, "%d"); friends_lists_from_db = linphone_core_fetch_friends_lists_from_db(lc); - BC_ASSERT_EQUAL(ms_list_size(friends_lists_from_db), 1, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends_lists_from_db), 1, int, "%d"); friends_from_db = ((LinphoneFriendList *)friends_lists_from_db->data)->friends; - BC_ASSERT_EQUAL(ms_list_size(friends_from_db), 1, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 1, int, "%d"); lf2 = (LinphoneFriend *)friends_from_db->data; BC_ASSERT_PTR_NOT_NULL(lf2->lc); BC_ASSERT_PTR_NOT_NULL(lf2->friend_list); - friends_lists_from_db = ms_list_free_with_data(friends_lists_from_db, (void (*)(void *))linphone_friend_list_unref); + friends_lists_from_db = bctbx_list_free_with_data(friends_lists_from_db, (void (*)(void *))linphone_friend_list_unref); friends_from_db = linphone_core_fetch_friends_from_db(lc, lfl); - BC_ASSERT_EQUAL(ms_list_size(friends_from_db), 1, int, "%d"); - if (ms_list_size(friends_from_db) < 1) { + BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 1, int, "%d"); + if (bctbx_list_size(friends_from_db) < 1) { goto end; } lf2 = (LinphoneFriend *)friends_from_db->data; @@ -317,21 +317,21 @@ static void friends_sqlite_storage(void) { linphone_friend_edit(lf); linphone_friend_set_name(lf, "Margaux"); linphone_friend_done(lf); - friends_from_db = ms_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); + friends_from_db = bctbx_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); friends_from_db = linphone_core_fetch_friends_from_db(lc, lfl); - BC_ASSERT_EQUAL(ms_list_size(friends_from_db), 1, int, "%d"); - if (ms_list_size(friends_from_db) < 1) { + BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 1, int, "%d"); + if (bctbx_list_size(friends_from_db) < 1) { goto end; } lf2 = (LinphoneFriend *)friends_from_db->data; BC_ASSERT_STRING_EQUAL(linphone_friend_get_name(lf2), "Margaux"); - friends_from_db = ms_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); + friends_from_db = bctbx_list_free_with_data(friends_from_db, (void (*)(void *))linphone_friend_unref); linphone_friend_list_remove_friend(lfl, lf); friends = linphone_friend_list_get_friends(linphone_core_get_default_friend_list(lc)); - BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends), 0, int, "%d"); friends_from_db = linphone_core_fetch_friends_from_db(lc, lfl); - BC_ASSERT_EQUAL(ms_list_size(friends_from_db), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(friends_from_db), 0, int, "%d"); linphone_core_remove_friend_list(lc, lfl); wait_for_until(lc, NULL, &stats->removed_list_count, 1, 1000); @@ -571,15 +571,15 @@ static void carddav_integration(void) { linphone_core_add_friend_list(manager->lc, lfl); BC_ASSERT_PTR_NULL(linphone_vcard_get_uid(lvc)); - BC_ASSERT_EQUAL(ms_list_size(lfl->dirty_friends_to_update), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(lfl->dirty_friends_to_update), 0, int, "%d"); BC_ASSERT_EQUAL(linphone_friend_list_add_friend(lfl, lf), LinphoneFriendListOK, int, "%d"); - BC_ASSERT_EQUAL(ms_list_size(lfl->dirty_friends_to_update), 1, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(lfl->dirty_friends_to_update), 1, int, "%d"); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); - BC_ASSERT_EQUAL(ms_list_size(lfl->dirty_friends_to_update), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(lfl->dirty_friends_to_update), 0, int, "%d"); BC_ASSERT_PTR_NOT_NULL(linphone_vcard_get_uid(lvc)); linphone_friend_list_remove_friend(lfl, lf); - BC_ASSERT_EQUAL(ms_list_size(lfl->friends), 0, int, "%d"); + BC_ASSERT_EQUAL(bctbx_list_size(lfl->friends), 0, int, "%d"); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 2, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 2, int, "%i"); linphone_friend_unref(lf); @@ -608,7 +608,7 @@ static void carddav_integration(void) { wait_for_until(manager->lc, NULL, &stats->sync_done_count, 3, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 3, int, "%i"); - BC_ASSERT_EQUAL(ms_list_size(lfl->friends), 1, int, "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(lfl->friends), 1, int, "%i"); lf = (LinphoneFriend *)lfl->friends->data; BC_ASSERT_STRING_EQUAL(lf->refkey, refkey); BC_ASSERT_EQUAL(lf->storage_id, lf2->storage_id, unsigned int, "%u"); @@ -617,13 +617,13 @@ static void carddav_integration(void) { linphone_friend_edit(lf); linphone_friend_done(lf); - BC_ASSERT_EQUAL(ms_list_size(lf->friend_list->dirty_friends_to_update), 0, int, "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(lf->friend_list->dirty_friends_to_update), 0, int, "%i"); linphone_core_set_network_reachable(manager->lc, FALSE); //To prevent the CardDAV update linphone_friend_edit(lf); linphone_friend_set_name(lf, "François Grisez"); linphone_friend_done(lf); - BC_ASSERT_EQUAL(ms_list_size(lf->friend_list->dirty_friends_to_update), 1, int, "%i"); + BC_ASSERT_EQUAL(bctbx_list_size(lf->friend_list->dirty_friends_to_update), 1, int, "%i"); ms_free(stats); linphone_friend_list_unref(lfl); @@ -635,8 +635,8 @@ static void carddav_clean(void) { // This is to ensure the content of the test LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl); LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); - MSList *friends = NULL; - MSList *friends_iterator = NULL; + bctbx_list_t *friends = NULL; + bctbx_list_t *friends_iterator = NULL; LinphoneFriend *lf = NULL; LinphoneVcard *lvc = NULL; @@ -653,7 +653,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); stats->sync_done_count = 0; - friends = ms_list_copy(lfl->friends); + friends = bctbx_list_copy(lfl->friends); friends_iterator = friends; while (friends_iterator) { LinphoneFriend *lf = (LinphoneFriend *)friends_iterator->data; @@ -662,9 +662,9 @@ static void carddav_clean(void) { // This is to ensure the content of the test BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); stats->sync_done_count = 0; stats->removed_contact_count = 0; - friends_iterator = ms_list_next(friends_iterator); + friends_iterator = bctbx_list_next(friends_iterator); } - ms_list_free(friends); + bctbx_list_free(friends); lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sylvain@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n"); linphone_vcard_set_url(lvc, "http://dav.linphone.org/card.php/addressbooks/tester/default/me.vcf"); @@ -718,7 +718,7 @@ static void carddav_server_to_client_and_client_to_sever_sync(void) { LinphoneFriend *lf1 = linphone_friend_new_from_vcard(lvc1); LinphoneVcard *lvc2 = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:ghislain@sip.linphone.org\r\nEND:VCARD\r\n"); LinphoneFriend *lf2 = linphone_friend_new_from_vcard(lvc2); - MSList *friends = NULL, *friends_iterator = NULL; + bctbx_list_t *friends = NULL, *friends_iterator = NULL; linphone_friend_list_cbs_set_user_data(cbs, stats); linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created); @@ -737,7 +737,7 @@ static void carddav_server_to_client_and_client_to_sever_sync(void) { BC_ASSERT_EQUAL(stats->sync_done_count, 3, int, "%i"); stats->sync_done_count = 0; - friends = ms_list_copy(lfl->friends); + friends = bctbx_list_copy(lfl->friends); friends_iterator = friends; while (friends_iterator) { LinphoneFriend *lf = (LinphoneFriend *)friends_iterator->data; @@ -747,9 +747,9 @@ static void carddav_server_to_client_and_client_to_sever_sync(void) { BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); stats->sync_done_count = 0; } - friends_iterator = ms_list_next(friends_iterator); + friends_iterator = bctbx_list_next(friends_iterator); } - ms_list_free(friends); + bctbx_list_free(friends); ms_free(stats); linphone_friend_list_unref(lfl); diff --git a/tester/video_tester.c b/tester/video_tester.c index 2b4df2a28..6d2e4cce9 100644 --- a/tester/video_tester.c +++ b/tester/video_tester.c @@ -160,14 +160,14 @@ static void early_media_video_call_state_changed_with_inactive_audio(LinphoneCor } bool_t wait_for_three_cores(LinphoneCore *lc1, LinphoneCore *lc2, LinphoneCore *lc3, int timeout) { - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; bool_t result; int dummy = 0; - if (lc1) lcs = ms_list_append(lcs, lc1); - if (lc2) lcs = ms_list_append(lcs, lc2); - if (lc3) lcs = ms_list_append(lcs, lc3); + if (lc1) lcs = bctbx_list_append(lcs, lc1); + if (lc2) lcs = bctbx_list_append(lcs, lc2); + if (lc3) lcs = bctbx_list_append(lcs, lc3); result = wait_for_list(lcs, &dummy, 1, timeout); - ms_list_free(lcs); + bctbx_list_free(lcs); return result; } @@ -305,7 +305,7 @@ static void two_incoming_early_media_video_calls_test(void) { LinphoneCallParams *pauline_params; LinphoneCallParams *laure_params; LinphoneCall *call; - const MSList *calls_list; + const bctbx_list_t *calls_list; marie = linphone_core_manager_new("marie_rc"); pauline = linphone_core_manager_new("pauline_tcp_rc"); @@ -335,7 +335,7 @@ static void two_incoming_early_media_video_calls_test(void) { BC_ASSERT_EQUAL(linphone_core_get_calls_nb(marie->lc), 2, int, "%d"); if (linphone_core_get_calls_nb(marie->lc) == 2) { calls_list = linphone_core_get_calls(marie->lc); - call = (LinphoneCall *)ms_list_nth_data(calls_list, 0); + call = (LinphoneCall *)bctbx_list_nth_data(calls_list, 0); BC_ASSERT_PTR_NOT_NULL(call); if (call != NULL) { LinphoneCallParams *params = linphone_call_params_copy(linphone_call_get_current_params(call)); @@ -409,7 +409,7 @@ static void forked_outgoing_early_media_video_call_with_inactive_audio_test(void LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc"); LinphoneCoreManager *marie1 = linphone_core_manager_new("marie_early_rc"); LinphoneCoreManager *marie2 = linphone_core_manager_new("marie_early_rc"); - MSList *lcs = NULL; + bctbx_list_t *lcs = NULL; LinphoneCallParams *pauline_params; LinphoneCallParams *marie1_params; LinphoneCallParams *marie2_params; @@ -433,9 +433,9 @@ static void forked_outgoing_early_media_video_call_with_inactive_audio_test(void linphone_core_set_audio_port_range(marie2->lc, 40200, 40300); linphone_core_set_video_port_range(marie2->lc, 40400, 40500); - lcs = ms_list_append(lcs,marie1->lc); - lcs = ms_list_append(lcs,marie2->lc); - lcs = ms_list_append(lcs,pauline->lc); + lcs = bctbx_list_append(lcs,marie1->lc); + lcs = bctbx_list_append(lcs,marie2->lc); + lcs = bctbx_list_append(lcs,pauline->lc); pauline_params = linphone_core_create_call_params(pauline->lc, NULL); linphone_call_params_enable_early_media_sending(pauline_params, TRUE); @@ -511,7 +511,7 @@ static void forked_outgoing_early_media_video_call_with_inactive_audio_test(void linphone_call_params_destroy(marie1_params); linphone_call_params_destroy(marie2_params); - ms_list_free(lcs); + bctbx_list_free(lcs); linphone_core_manager_destroy(marie1); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(pauline); diff --git a/tools/auto_answer.c b/tools/auto_answer.c index daf0f7946..83ed77bcf 100644 --- a/tools/auto_answer.c +++ b/tools/auto_answer.c @@ -184,13 +184,13 @@ int main(int argc, char *argv[]){ /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ - const MSList * iterator; + const bctbx_list_t * iterator; linphone_core_iterate(lc); ms_usleep(50000); if (print_stats) { ms_message("*********************************"); - ms_message("*Current number of calls [%10u] *", (unsigned int)ms_list_size(linphone_core_get_calls(lc))); - ms_message("*Number of calls until now [%10u] *", (unsigned int)ms_list_size(linphone_core_get_call_logs(lc))); + ms_message("*Current number of calls [%10u] *", (unsigned int)bctbx_list_size(linphone_core_get_calls(lc))); + ms_message("*Number of calls until now [%10u] *", (unsigned int)bctbx_list_size(linphone_core_get_call_logs(lc))); ms_message("*********************************"); print_stats=FALSE; } From fb9c200a553a411497ab9cdbae7ad00f64282562 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 16 Jun 2016 18:41:41 +0200 Subject: [PATCH 097/124] Replace MSList by bctbx_list_t in console and gtk. --- console/commands.c | 62 ++++++++++++++++++++++----------------------- console/sipomatic.c | 18 ++++++------- gtk/buddylookup.c | 10 ++++---- gtk/chat.c | 14 +++++----- gtk/friendlist.c | 16 ++++++------ gtk/incall_view.c | 12 ++++----- gtk/main.c | 14 +++++----- gtk/propertybox.c | 34 ++++++++++++------------- 8 files changed, 90 insertions(+), 90 deletions(-) diff --git a/console/commands.c b/console/commands.c index c3324d3df..264dc3a35 100644 --- a/console/commands.c +++ b/console/commands.c @@ -600,7 +600,7 @@ lpc_cmd_call(LinphoneCore *lc, char *args) static int lpc_cmd_calls(LinphoneCore *lc, char *args){ - const MSList *calls = linphone_core_get_calls(lc); + const bctbx_list_t *calls = linphone_core_get_calls(lc); if(calls) { lpc_display_call_states(lc); @@ -665,7 +665,7 @@ lpc_cmd_transfer(LinphoneCore *lc, char *args) int n=sscanf(args,"%255s %265s %li",arg1,arg2,&id2); if (n==1 || isalpha(*arg1)){ call=linphone_core_get_current_call(lc); - if (call==NULL && ms_list_size(linphone_core_get_calls(lc))==1){ + if (call==NULL && bctbx_list_size(linphone_core_get_calls(lc))==1){ call=(LinphoneCall*)linphone_core_get_calls(lc)->data; } refer_to=args; @@ -734,7 +734,7 @@ lpc_cmd_terminate(LinphoneCore *lc, char *args) static int lpc_cmd_redirect(LinphoneCore *lc, char *args){ - const MSList *elem; + const bctbx_list_t *elem; int didit=0; if (!args) return 0; if ((elem=linphone_core_get_calls(lc))==NULL){ @@ -780,7 +780,7 @@ static int lpc_cmd_answer(LinphoneCore *lc, char *args){ if (!args) { - int nb=ms_list_size(linphone_core_get_calls(lc)); + int nb=bctbx_list_size(linphone_core_get_calls(lc)); if (nb==1){ //if just one call is present answer the only one in passing NULL to the linphone_core_accept_call ... if ( -1 == linphone_core_accept_call(lc, NULL) ) @@ -1176,8 +1176,8 @@ lpc_cmd_proxy(LinphoneCore *lc, char *args) static int lpc_cmd_call_logs(LinphoneCore *lc, char *args) { - const MSList *elem=linphone_core_get_call_logs(lc); - for (;elem!=NULL;elem=ms_list_next(elem)) + const bctbx_list_t *elem=linphone_core_get_call_logs(lc); + for (;elem!=NULL;elem=bctbx_list_next(elem)) { LinphoneCallLog *cl=(LinphoneCallLog*)elem->data; char *str=linphone_call_log_to_str(cl); @@ -1480,8 +1480,8 @@ static int lpc_cmd_resume(LinphoneCore *lc, char *args){ } else { - const MSList *calls = linphone_core_get_calls(lc); - int nbcalls=ms_list_size(calls); + const bctbx_list_t *calls = linphone_core_get_calls(lc); + int nbcalls=bctbx_list_size(calls); if( nbcalls == 1) { if(linphone_core_resume_call(lc,calls->data) < 0) @@ -1766,7 +1766,7 @@ linphonec_proxy_display(LinphoneProxyConfig *cfg) static void linphonec_proxy_show(LinphoneCore *lc, int index) { - const MSList *elem; + const bctbx_list_t *elem; int i; for(elem=linphone_core_get_proxy_config_list(lc),i=0;elem!=NULL;elem=elem->next,++i){ if (index==i){ @@ -1781,12 +1781,12 @@ static void linphonec_proxy_show(LinphoneCore *lc, int index) static void linphonec_proxy_list(LinphoneCore *lc) { - const MSList *proxies; + const bctbx_list_t *proxies; int n; int def=linphone_core_get_default_proxy(lc,NULL); proxies=linphone_core_get_proxy_config_list(lc); - for(n=0;proxies!=NULL;proxies=ms_list_next(proxies),n++){ + for(n=0;proxies!=NULL;proxies=bctbx_list_next(proxies),n++){ if (n==def) linphonec_out("****** Proxy %i - this is the default one - *******\n",n); else @@ -1799,10 +1799,10 @@ linphonec_proxy_list(LinphoneCore *lc) static void linphonec_proxy_remove(LinphoneCore *lc, int index) { - const MSList *proxies; + const bctbx_list_t *proxies; LinphoneProxyConfig *cfg; proxies=linphone_core_get_proxy_config_list(lc); - cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index); + cfg=(LinphoneProxyConfig*)bctbx_list_nth_data(proxies,index); if (cfg==NULL){ linphonec_out("No such proxy.\n"); return; @@ -1814,10 +1814,10 @@ linphonec_proxy_remove(LinphoneCore *lc, int index) static int linphonec_proxy_use(LinphoneCore *lc, int index) { - const MSList *proxies; + const bctbx_list_t *proxies; LinphoneProxyConfig *cfg; proxies=linphone_core_get_proxy_config_list(lc); - cfg=(LinphoneProxyConfig*)ms_list_nth_data(proxies,index); + cfg=(LinphoneProxyConfig*)bctbx_list_nth_data(proxies,index); if (cfg==NULL){ linphonec_out("No such proxy (try 'proxy list')."); return 0; @@ -1841,7 +1841,7 @@ linphonec_friend_display(LinphoneFriend *fr) static int linphonec_friend_list(LinphoneCore *lc, char *pat) { - const MSList *friend; + const bctbx_list_t *friend; int n; if (pat) { @@ -1850,7 +1850,7 @@ linphonec_friend_list(LinphoneCore *lc, char *pat) } friend = linphone_core_get_friend_list(lc); - for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n ) + for(n=0; friend!=NULL; friend=bctbx_list_next(friend), ++n ) { if ( pat ) { const char *name = linphone_address_get_display_name( @@ -1867,11 +1867,11 @@ linphonec_friend_list(LinphoneCore *lc, char *pat) static int linphonec_friend_call(LinphoneCore *lc, unsigned int num) { - const MSList *friend = linphone_core_get_friend_list(lc); + const bctbx_list_t *friend = linphone_core_get_friend_list(lc); unsigned int n; char *addr; - for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n ) + for(n=0; friend!=NULL; friend=bctbx_list_next(friend), ++n ) { if ( n == num ) { @@ -1904,10 +1904,10 @@ linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr) static int linphonec_friend_delete(LinphoneCore *lc, int num) { - const MSList *friend = linphone_core_get_friend_list(lc); + const bctbx_list_t *friend = linphone_core_get_friend_list(lc); unsigned int n; - for(n=0; friend!=NULL; friend=ms_list_next(friend), ++n ) + for(n=0; friend!=NULL; friend=bctbx_list_next(friend), ++n ) { if ( n == num ) { @@ -1941,7 +1941,7 @@ static int lpc_cmd_register(LinphoneCore *lc, char *args){ char proxy[512]; char passwd[512]; LinphoneProxyConfig *cfg; - const MSList *elem; + const bctbx_list_t *elem; if (!args) { @@ -2006,7 +2006,7 @@ static int lpc_cmd_unregister(LinphoneCore *lc, char *args){ static int lpc_cmd_duration(LinphoneCore *lc, char *args){ LinphoneCallLog *cl; - const MSList *elem=linphone_core_get_call_logs(lc); + const bctbx_list_t *elem=linphone_core_get_call_logs(lc); for(;elem!=NULL;elem=elem->next){ if (elem->next==NULL){ cl=(LinphoneCallLog*)elem->data; @@ -2234,7 +2234,7 @@ static int lpc_cmd_codec(int type, LinphoneCore *lc, char *args){ static void linphonec_codec_list(int type, LinphoneCore *lc){ PayloadType *pt; int index=0; - const MSList *node=NULL; + const bctbx_list_t *node=NULL; if (type == AUDIO) { node=linphone_core_get_audio_codecs(lc); @@ -2242,7 +2242,7 @@ static void linphonec_codec_list(int type, LinphoneCore *lc){ node=linphone_core_get_video_codecs(lc); } - for(;node!=NULL;node=ms_list_next(node)){ + for(;node!=NULL;node=bctbx_list_next(node)){ pt=(PayloadType*)(node->data); linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, linphone_core_payload_type_enabled(lc,pt) ? "enabled" : "disabled"); @@ -2253,7 +2253,7 @@ static void linphonec_codec_list(int type, LinphoneCore *lc){ static void linphonec_codec_enable(int type, LinphoneCore *lc, int sel_index){ PayloadType *pt; int index=0; - const MSList *node=NULL; + const bctbx_list_t *node=NULL; if (type == AUDIO) { node=linphone_core_get_audio_codecs(lc); @@ -2261,7 +2261,7 @@ static void linphonec_codec_enable(int type, LinphoneCore *lc, int sel_index){ node=linphone_core_get_video_codecs(lc); } - for(;node!=NULL;node=ms_list_next(node)){ + for(;node!=NULL;node=bctbx_list_next(node)){ if (index == sel_index || sel_index == -1) { pt=(PayloadType*)(node->data); linphone_core_enable_payload_type (lc,pt,TRUE); @@ -2274,7 +2274,7 @@ static void linphonec_codec_enable(int type, LinphoneCore *lc, int sel_index){ static void linphonec_codec_disable(int type, LinphoneCore *lc, int sel_index){ PayloadType *pt; int index=0; - const MSList *node=NULL; + const bctbx_list_t *node=NULL; if (type == AUDIO) { node=linphone_core_get_audio_codecs(lc); @@ -2282,7 +2282,7 @@ static void linphonec_codec_disable(int type, LinphoneCore *lc, int sel_index){ node=linphone_core_get_video_codecs(lc); } - for(;node!=NULL;node=ms_list_next(node)){ + for(;node!=NULL;node=bctbx_list_next(node)){ if (index == sel_index || sel_index == -1) { pt=(PayloadType*)(node->data); linphone_core_enable_payload_type (lc,pt,FALSE); @@ -2466,7 +2466,7 @@ static void lpc_display_global_state(LinphoneCore *lc){ static void lpc_display_call_states(LinphoneCore *lc){ LinphoneCall *call; - const MSList *elem; + const bctbx_list_t *elem; char *tmp; linphonec_out("Call states\n" "Id | Destination | State | Flags |\n" @@ -2491,7 +2491,7 @@ static void lpc_display_call_states(LinphoneCore *lc){ } static void lpc_display_proxy_states(LinphoneCore *lc){ - const MSList *elem; + const bctbx_list_t *elem; linphonec_out("Proxy registration states\n" " Identity | State\n" "------------------------------------------------------------\n"); diff --git a/console/sipomatic.c b/console/sipomatic.c index 92f4fe572..25afdbdb8 100644 --- a/console/sipomatic.c +++ b/console/sipomatic.c @@ -271,8 +271,8 @@ void sipomatic_uninit(Sipomatic *obj) void sipomatic_iterate(Sipomatic *obj) { - MSList *elem; - MSList *to_be_destroyed=NULL; + bctbx_list_t *elem; + bctbx_list_t *to_be_destroyed=NULL; Call *call; double elapsed; eXosip_event_t *ev; @@ -293,13 +293,13 @@ void sipomatic_iterate(Sipomatic *obj) case CALL_STATE_RUNNING: if (elapsed>obj->max_call_time || call->eof){ call_release(call); - to_be_destroyed=ms_list_append(to_be_destroyed,call); + to_be_destroyed=bctbx_list_append(to_be_destroyed,call); } break; } - elem=ms_list_next(elem); + elem=bctbx_list_next(elem); } - for(;to_be_destroyed!=NULL; to_be_destroyed=ms_list_next(to_be_destroyed)){ + for(;to_be_destroyed!=NULL; to_be_destroyed=bctbx_list_next(to_be_destroyed)){ call_destroy((Call*)to_be_destroyed->data); } } @@ -307,9 +307,9 @@ void sipomatic_iterate(Sipomatic *obj) Call* sipomatic_find_call(Sipomatic *obj,int did) { - MSList *it; + bctbx_list_t *it; Call *call=NULL; - for (it=obj->calls;it!=NULL;it=ms_list_next(it)){ + for (it=obj->calls;it!=NULL;it=bctbx_list_next(it)){ call=(Call*)it->data; if ( call->did==did) return call; } @@ -351,7 +351,7 @@ Call * call_new(Sipomatic *root, eXosip_event_t *ev) obj->state=CALL_STATE_INIT; obj->eof=0; obj->root=root; - root->calls=ms_list_append(root->calls,obj); + root->calls=bctbx_list_append(root->calls,obj); return obj; } @@ -367,7 +367,7 @@ void call_release(Call *call) void call_destroy(Call *obj) { - obj->root->calls=ms_list_remove(obj->root->calls,obj); + obj->root->calls=bctbx_list_remove(obj->root->calls,obj); rtp_profile_destroy(obj->profile); sdp_context_free(obj->sdpc); ms_free(obj); diff --git a/gtk/buddylookup.c b/gtk/buddylookup.c index eea85aee1..3ec5e2402 100644 --- a/gtk/buddylookup.c +++ b/gtk/buddylookup.c @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "linphone.h" #include "sipsetup.h" -static void linphone_gtk_display_lookup_results(GtkWidget *w, const MSList *results); +static void linphone_gtk_display_lookup_results(GtkWidget *w, const bctbx_list_t *results); enum { LOOKUP_RESULT_NAME, @@ -136,7 +136,7 @@ static gboolean linphone_gtk_process_buddy_lookup(GtkWidget *w){ SipSetupContext *ctx; int last_state; gchar *tmp; - MSList *results=NULL; + bctbx_list_t *results=NULL; GtkProgressBar *pb=GTK_PROGRESS_BAR(linphone_gtk_get_widget(w,"progressbar")); BuddyLookupRequest *req=(BuddyLookupRequest*)g_object_get_data(G_OBJECT(w),"buddylookup_request"); @@ -178,7 +178,7 @@ static gboolean linphone_gtk_process_buddy_lookup(GtkWidget *w){ results); gtk_progress_bar_set_fraction(pb,1); tmp=g_strdup_printf(ngettext("Found %u contact", "Found %u contacts", - (unsigned int)ms_list_size(results)), (unsigned int)ms_list_size(results)); + (unsigned int)bctbx_list_size(results)), (unsigned int)bctbx_list_size(results)); gtk_progress_bar_set_text(pb,tmp); g_free(tmp); sip_setup_context_buddy_lookup_free(ctx,req); @@ -227,11 +227,11 @@ void linphone_gtk_keyword_changed(GtkEditable *e){ g_object_set_data(G_OBJECT(w),"typing_timeout",GINT_TO_POINTER(tid)); } -static void linphone_gtk_display_lookup_results(GtkWidget *w, const MSList *results){ +static void linphone_gtk_display_lookup_results(GtkWidget *w, const bctbx_list_t *results){ GtkTreeStore *store; GtkTreeIter iter; gchar *tmp; - const MSList *elem; + const bctbx_list_t *elem; store=GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(w))); gtk_tree_store_clear(store); disable_add_buddy_button(gtk_widget_get_toplevel(w)); diff --git a/gtk/chat.c b/gtk/chat.c index 8cae184ed..820c656c6 100644 --- a/gtk/chat.c +++ b/gtk/chat.c @@ -328,14 +328,14 @@ static void linphone_gtk_chat_message_destroy(LinphoneChatMessage *msg){ linphone_chat_message_destroy(msg); } -void linphone_gtk_free_list(MSList *messages){ - ms_list_for_each(messages,(void (*)(void*))linphone_gtk_chat_message_destroy); - ms_list_free(messages); +void linphone_gtk_free_list(bctbx_list_t *messages){ + bctbx_list_for_each(messages,(void (*)(void*))linphone_gtk_chat_message_destroy); + bctbx_list_free(messages); } -void display_history_message(GtkWidget *chat_view,MSList *messages,const LinphoneAddress *with){ +void display_history_message(GtkWidget *chat_view,bctbx_list_t *messages,const LinphoneAddress *with){ if (messages != NULL){ - MSList *it; + bctbx_list_t *it; char *from_str; char *with_str; gchar *tmp; @@ -502,7 +502,7 @@ GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddres int idx; GtkWidget *button; GtkWidget *entry = linphone_gtk_get_widget(chat_view,"text_entry"); - MSList *messages; + bctbx_list_t *messages; GHashTable *table; GtkTextTag *tmp_tag; GtkWidget *link_ctx_menu = gtk_menu_new(); @@ -588,7 +588,7 @@ void linphone_gtk_load_chatroom(LinphoneChatRoom *cr,const LinphoneAddress *uri, char *from_str=linphone_address_as_string_uri_only(from); char *uri_str=linphone_address_as_string(uri); char *uri_only=linphone_address_as_string_uri_only(uri); - MSList *messages=NULL; + bctbx_list_t *messages=NULL; if(g_strcmp0(from_str,uri_only)!=0){ GtkTextView *text_view=GTK_TEXT_VIEW(linphone_gtk_get_widget(chat_view,"textview")); diff --git a/gtk/friendlist.c b/gtk/friendlist.c index ec134f88f..0ef089c6a 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -571,14 +571,14 @@ static int friend_compare_func(const LinphoneFriend *lf1, const LinphoneFriend * return w2-w1; } -static MSList *sort_friend_list(const MSList *friends){ - MSList *ret=NULL; - const MSList *elem; +static bctbx_list_t *sort_friend_list(const bctbx_list_t *friends){ + bctbx_list_t *ret=NULL; + const bctbx_list_t *elem; LinphoneFriend *lf; for(elem=friends;elem!=NULL;elem=elem->next){ lf=(LinphoneFriend*)elem->data; - ret=ms_list_insert_sorted(ret,lf,(MSCompareFunc)friend_compare_func); + ret=bctbx_list_insert_sorted(ret,lf,(bctbx_compare_func)friend_compare_func); } return ret; } @@ -669,9 +669,9 @@ void linphone_gtk_show_friends(void){ GtkWidget *friendlist=linphone_gtk_get_widget(mw,"contact_list"); GtkListStore *store=NULL; GtkTreeIter iter; - const MSList *itf; + const bctbx_list_t *itf; LinphoneCore *core=linphone_gtk_get_core(); - MSList *sorted; + bctbx_list_t *sorted; LinphoneChatRoom *cr=NULL; linphone_gtk_show_directory_search(); @@ -684,7 +684,7 @@ void linphone_gtk_show_friends(void){ sorted=sort_friend_list(linphone_core_get_friend_list(core)); - for(itf=sorted;itf!=NULL;itf=ms_list_next(itf)){ + for(itf=sorted;itf!=NULL;itf=bctbx_list_next(itf)){ LinphoneFriend *lf=(LinphoneFriend*)itf->data; const LinphoneAddress *f_uri=linphone_friend_get_address(lf); char *uri=linphone_address_as_string(f_uri); @@ -713,7 +713,7 @@ void linphone_gtk_show_friends(void){ g_free(escaped); ms_free(uri); } - ms_list_free(sorted); + bctbx_list_free(sorted); } void linphone_gtk_show_contact(LinphoneFriend *lf, GtkWidget *parent){ diff --git a/gtk/incall_view.c b/gtk/incall_view.c index b495308d1..34a90120e 100644 --- a/gtk/incall_view.c +++ b/gtk/incall_view.c @@ -39,9 +39,9 @@ LinphoneCall *linphone_gtk_get_currently_displayed_call(gboolean *is_conf){ LinphoneCore *lc=linphone_gtk_get_core(); GtkWidget *main_window=linphone_gtk_get_main_window (); GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch"); - const MSList *calls=linphone_core_get_calls(lc); + const bctbx_list_t *calls=linphone_core_get_calls(lc); if (is_conf) *is_conf=FALSE; - if (!linphone_gtk_use_in_call_view() || ms_list_size(calls)==1){ + if (!linphone_gtk_use_in_call_view() || bctbx_list_size(calls)==1){ if (calls) return (LinphoneCall*)calls->data; }else{ int idx=gtk_notebook_get_current_page (notebook); @@ -134,7 +134,7 @@ void transfer_button_clicked(GtkWidget *button, gpointer call_ref){ GtkWidget *menu=gtk_menu_new(); LinphoneCall *call=(LinphoneCall*)call_ref; LinphoneCore *lc=linphone_gtk_get_core(); - const MSList *elem=linphone_core_get_calls(lc); + const bctbx_list_t *elem=linphone_core_get_calls(lc); for(;elem!=NULL;elem=elem->next){ LinphoneCall *other_call=(LinphoneCall*)elem->data; @@ -158,7 +158,7 @@ void transfer_button_clicked(GtkWidget *button, gpointer call_ref){ } void linphone_gtk_enable_transfer_button(LinphoneCore *lc, gboolean value){ - const MSList *elem=linphone_core_get_calls(lc); + const bctbx_list_t *elem=linphone_core_get_calls(lc); for(;elem!=NULL;elem=elem->next){ LinphoneCall *call=(LinphoneCall*)elem->data; GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call); @@ -177,7 +177,7 @@ static void conference_button_clicked(GtkWidget *button, gpointer call_ref){ } void linphone_gtk_enable_conference_button(LinphoneCore *lc, gboolean value){ - const MSList *elem=linphone_core_get_calls(lc); + const bctbx_list_t *elem=linphone_core_get_calls(lc); for(;elem!=NULL;elem=elem->next){ LinphoneCall *call=(LinphoneCall*)elem->data; GtkWidget *call_view=(GtkWidget*)linphone_call_get_user_pointer(call); @@ -413,7 +413,7 @@ void linphone_gtk_create_in_call_view(LinphoneCall *call){ GtkWidget *button; GtkWidget *image; - if (ms_list_size(linphone_core_get_calls(linphone_gtk_get_core()))==1){ + if (bctbx_list_size(linphone_core_get_calls(linphone_gtk_get_core()))==1){ /*this is the only call at this time */ call_index=1; } diff --git a/gtk/main.c b/gtk/main.c index 4cb67d727..3fe532cd1 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -645,7 +645,7 @@ static void completion_add_text(GtkEntry *entry, const char *text){ save_uri_history(); } -void on_contact_provider_search_results( LinphoneContactSearch* req, MSList* friends, void* data ) +void on_contact_provider_search_results( LinphoneContactSearch* req, bctbx_list_t* friends, void* data ) { GtkTreeIter iter; GtkEntry* uribar = GTK_ENTRY(data); @@ -793,10 +793,10 @@ void linphone_gtk_call_terminated(LinphoneCall *call, const char *error){ static void linphone_gtk_update_call_buttons(LinphoneCall *call){ LinphoneCore *lc=linphone_gtk_get_core(); GtkWidget *mw=linphone_gtk_get_main_window(); - const MSList *calls=linphone_core_get_calls(lc); + const bctbx_list_t *calls=linphone_core_get_calls(lc); GtkWidget *button; bool_t add_call=(calls!=NULL); - int call_list_size=ms_list_size(calls); + int call_list_size=bctbx_list_size(calls); GtkWidget *conf_frame; button=linphone_gtk_get_widget(mw,"start_call"); @@ -1022,7 +1022,7 @@ void linphone_gtk_used_identity_changed(GtkWidget *w){ void on_proxy_refresh_button_clicked(GtkWidget *w){ LinphoneCore *lc=linphone_gtk_get_core(); - MSList const *item=linphone_core_get_proxy_config_list(lc); + bctbx_list_t const *item=linphone_core_get_proxy_config_list(lc); while (item != NULL) { LinphoneProxyConfig *lpc=(LinphoneProxyConfig*)item->data; linphone_proxy_config_edit(lpc); @@ -1605,7 +1605,7 @@ static void init_identity_combo(GtkComboBox *box){ } void linphone_gtk_load_identities(void){ - const MSList *elem; + const bctbx_list_t *elem; GtkComboBox *box=GTK_COMBO_BOX(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"identities")); char *def_identity; LinphoneProxyConfig *def=NULL; @@ -1627,7 +1627,7 @@ void linphone_gtk_load_identities(void){ g_free(def_identity); for(i=1,elem=linphone_core_get_proxy_config_list(linphone_gtk_get_core()); elem!=NULL; - elem=ms_list_next(elem),i++){ + elem=bctbx_list_next(elem),i++){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; gtk_list_store_append(store,&iter); gtk_list_store_set(store,&iter,0,linphone_proxy_config_get_identity(cfg),1, @@ -1679,7 +1679,7 @@ static void linphone_gtk_check_menu_items(void){ static gboolean linphone_gtk_can_manage_accounts(void){ LinphoneCore *lc=linphone_gtk_get_core(); - const MSList *elem; + const bctbx_list_t *elem; for(elem=linphone_core_get_sip_setups(lc);elem!=NULL;elem=elem->next){ SipSetup *ss=(SipSetup*)elem->data; if (sip_setup_get_capabilities(ss) & SIP_SETUP_CAP_ACCOUNT_MANAGER){ diff --git a/gtk/propertybox.c b/gtk/propertybox.c index 9ae0864bd..05512a4bb 100644 --- a/gtk/propertybox.c +++ b/gtk/propertybox.c @@ -648,9 +648,9 @@ const char *get_codec_color(LinphoneCore *lc, PayloadType *pt){ return color; } -static void linphone_gtk_show_codecs(GtkTreeView *listview, const MSList *codeclist) +static void linphone_gtk_show_codecs(GtkTreeView *listview, const bctbx_list_t *codeclist) { - const MSList *elem; + const bctbx_list_t *elem; GtkTreeIter iter; GtkListStore *store=GTK_LIST_STORE(gtk_tree_view_get_model(listview)); // GtkTreeSelection *selection; @@ -733,7 +733,7 @@ static void linphone_gtk_select_codec(GtkTreeView *v, PayloadType *ref){ } static void linphone_gtk_draw_codec_list(GtkTreeView *v, int type){ /* 0=audio, 1=video*/ - const MSList *list; + const bctbx_list_t *list; if (type==0) list=linphone_core_get_audio_codecs(linphone_gtk_get_core()); else list=linphone_core_get_video_codecs(linphone_gtk_get_core()); linphone_gtk_show_codecs(v,list); @@ -784,8 +784,8 @@ static void linphone_gtk_codec_move(GtkWidget *button, int dir, int type){ /* 0= else v=GTK_TREE_VIEW(linphone_gtk_get_widget(gtk_widget_get_toplevel(button),"video_codec_list")); sel=gtk_tree_view_get_selection(v); if (gtk_tree_selection_count_selected_rows(sel) == 1){ - MSList *sel_elem,*before; - MSList *codec_list; + bctbx_list_t *sel_elem,*before; + bctbx_list_t *codec_list; GList *selected_rows = gtk_tree_selection_get_selected_rows(sel, &mod); gtk_tree_model_get_iter(mod, &iter, (GtkTreePath *)g_list_nth_data(selected_rows, 0)); @@ -794,20 +794,20 @@ static void linphone_gtk_codec_move(GtkWidget *button, int dir, int type){ /* 0= g_list_free(selected_rows); if (pt->type==PAYLOAD_VIDEO) - codec_list=ms_list_copy(linphone_core_get_video_codecs(lc)); - else codec_list=ms_list_copy(linphone_core_get_audio_codecs(lc)); - sel_elem=ms_list_find(codec_list,pt); + codec_list=bctbx_list_copy(linphone_core_get_video_codecs(lc)); + else codec_list=bctbx_list_copy(linphone_core_get_audio_codecs(lc)); + sel_elem=bctbx_list_find(codec_list,pt); if (dir>0) { if (sel_elem->prev) before=sel_elem->prev; else before=sel_elem; - codec_list=ms_list_insert(codec_list,before,pt); + codec_list=bctbx_list_insert(codec_list,before,pt); } else{ if (sel_elem->next) before=sel_elem->next->next; else before=sel_elem; - codec_list=ms_list_insert(codec_list,before,pt); + codec_list=bctbx_list_insert(codec_list,before,pt); } - codec_list=ms_list_remove_link(codec_list,sel_elem); + codec_list=bctbx_list_remove_link(codec_list,sel_elem); if (pt->type==PAYLOAD_VIDEO) linphone_core_set_video_codecs(lc,codec_list); else linphone_core_set_audio_codecs(lc,codec_list); @@ -889,7 +889,7 @@ void linphone_gtk_show_sip_accounts(GtkWidget *w){ const LinphoneProxyConfig *default_pc = linphone_core_get_default_proxy_config(linphone_gtk_get_core()); GtkTreePath *default_pc_path = NULL; - const MSList *elem; + const bctbx_list_t *elem; if (!model){ GtkCellRenderer *renderer; GtkTreeViewColumn *column; @@ -912,7 +912,7 @@ void linphone_gtk_show_sip_accounts(GtkWidget *w){ store=GTK_LIST_STORE(model); } gtk_list_store_clear(store); - for(elem=linphone_core_get_proxy_config_list(linphone_gtk_get_core());elem!=NULL;elem=ms_list_next(elem)){ + for(elem=linphone_core_get_proxy_config_list(linphone_gtk_get_core());elem!=NULL;elem=bctbx_list_next(elem)){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; GtkTreeIter iter; gtk_list_store_append(store,&iter); @@ -1429,8 +1429,8 @@ void linphone_gtk_fill_video_renderers(GtkWidget *pb){ LinphoneCore *lc=linphone_gtk_get_core(); MSFactory *factory = linphone_core_get_ms_factory(lc); GtkWidget *combo=linphone_gtk_get_widget(pb,"renderers"); - MSList *l=ms_factory_lookup_filter_by_interface(factory, MSFilterVideoDisplayInterface); - MSList *elem; + bctbx_list_t *l=ms_factory_lookup_filter_by_interface(factory, MSFilterVideoDisplayInterface); + bctbx_list_t *elem; int i; int active=-1; const char *current_renderer=linphone_core_get_video_display_filter(lc); @@ -1460,7 +1460,7 @@ void linphone_gtk_fill_video_renderers(GtkWidget *pb){ i++; } - ms_list_free(l); + bctbx_list_free(l); if (active!=-1) gtk_combo_box_set_active(GTK_COMBO_BOX(combo),active); #endif } @@ -1783,7 +1783,7 @@ void linphone_gtk_edit_tunnel(GtkButton *button){ GtkWidget *w=linphone_gtk_create_window("tunnel_config", gtk_widget_get_toplevel(GTK_WIDGET(button))); LinphoneCore *lc=linphone_gtk_get_core(); LinphoneTunnel *tunnel=linphone_core_get_tunnel(lc); - const MSList *configs; + const bctbx_list_t *configs; const char *host = NULL; int port=0; From 026b8b85b473cb4081fb12387eaa3d1ec45451d1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 16 Jun 2016 18:41:58 +0200 Subject: [PATCH 098/124] Fix compilation warnings in testers. --- tester/liblinphone_tester.c | 1 + tester/vcard_tester.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/tester/liblinphone_tester.c b/tester/liblinphone_tester.c index d487a4fd5..8fc38cc53 100644 --- a/tester/liblinphone_tester.c +++ b/tester/liblinphone_tester.c @@ -28,6 +28,7 @@ #pragma warning(disable : 4996) #else #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic ignored "-Wstrict-prototypes" #endif #ifdef HAVE_GTK diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index bf08140fb..4a04fb9b5 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -106,6 +106,15 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) { linphone_core_manager_destroy(manager); } +#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#pragma GCC diagnostic push +#endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#else +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + static void linphone_vcard_update_existing_friends_test(void) { LinphoneFriend *lf = linphone_friend_new_with_addr("sip:oldfriend@sip.linphone.org"); @@ -122,6 +131,10 @@ static void linphone_vcard_update_existing_friends_test(void) { lf = NULL; } +#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) +#pragma GCC diagnostic pop +#endif + static void linphone_vcard_phone_numbers_and_sip_addresses(void) { LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nIMPP;TYPE=home:sip:sylvain@sip.linphone.org\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); From af2ecd8cb67845e904d803d008ced2703e45423e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 17 Jun 2016 10:59:12 +0200 Subject: [PATCH 099/124] Add CMakeLists.txt for daemon + use bctbx_list_t instead of MSList in the daemon. --- CMakeLists.txt | 4 + daemon/CMakeLists.txt | 129 ++++++++++++++++++++++++++ daemon/commands/audio-codec-get.cc | 2 +- daemon/commands/audio-codec-move.cc | 10 +- daemon/commands/audio-codec-set.cc | 2 +- daemon/commands/audio-codec-toggle.cc | 2 +- daemon/commands/dtmf.cc | 7 +- daemon/daemon-pipetest.c | 8 +- daemon/daemon.cc | 12 +-- daemon/daemon.h | 3 +- 10 files changed, 159 insertions(+), 20 deletions(-) create mode 100644 daemon/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index bc9ae5917..b9e2d1fbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ option(ENABLE_SHARED "Build shared library." YES) option(ENABLE_STATIC "Build static library." YES) option(ENABLE_CONSOLE_UI "Turn on or off compilation of console interface." YES) option(ENABLE_DATE "Use build date in internal version number." NO) +option(ENABLE_DAEMON "Enable the linphone daemon interface." YES) option(ENABLE_DOC "Enable documentation generation with Doxygen." YES) option(ENABLE_GTK_UI "Turn on or off compilation of gtk interface." YES) option(ENABLE_LDAP "Enable LDAP support." NO) @@ -295,6 +296,9 @@ add_subdirectory(share) if(ENABLE_CONSOLE_UI) add_subdirectory(console) endif() +if(ENABLE_DAEMON) + add_subdirectory(daemon) +endif() if(ENABLE_GTK_UI) add_subdirectory(gtk) add_subdirectory(pixmaps) diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt new file mode 100644 index 000000000..8d2fbc8df --- /dev/null +++ b/daemon/CMakeLists.txt @@ -0,0 +1,129 @@ +############################################################################ +# CMakeLists.txt +# Copyright (C) 2016 Belledonne Communications, Grenoble France +# +############################################################################ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################ + +set(DAEMON_SOURCE_FILES + commands/adaptive-jitter-compensation.cc + commands/adaptive-jitter-compensation.h + commands/answer.cc + commands/answer.h + commands/audio-codec-get.cc + commands/audio-codec-get.h + commands/audio-codec-move.cc + commands/audio-codec-move.h + commands/audio-codec-set.cc + commands/audio-codec-set.h + commands/audio-codec-toggle.cc + commands/audio-codec-toggle.h + commands/audio-stream-start.cc + commands/audio-stream-start.h + commands/audio-stream-stats.cc + commands/audio-stream-stats.h + commands/audio-stream-stop.cc + commands/audio-stream-stop.h + commands/auth-infos-clear.cc + commands/auth-infos-clear.h + commands/call.cc + commands/call.h + commands/call-mute.cc + commands/call-mute.h + commands/call-pause.cc + commands/call-pause.h + commands/call-resume.cc + commands/call-resume.h + commands/call-stats.cc + commands/call-stats.h + commands/call-status.cc + commands/call-status.h + commands/call-transfer.cc + commands/call-transfer.h + commands/cn.cc + commands/cn.h + commands/conference.cc + commands/conference.h + commands/config.cc + commands/configcommand.h + commands/contact.cc + commands/contact.h + commands/dtmf.cc + commands/dtmf.h + commands/firewall-policy.cc + commands/firewall-policy.h + commands/help.cc + commands/help.h + commands/ipv6.cc + commands/ipv6.h + commands/jitterbuffer.cc + commands/jitterbuffer.h + commands/media-encryption.cc + commands/media-encryption.h + commands/msfilter-add-fmtp.cc + commands/msfilter-add-fmtp.h + commands/netsim.cc + commands/netsim.h + commands/play-wav.cc + commands/play-wav.h + commands/pop-event.cc + commands/pop-event.h + commands/port.cc + commands/port.h + commands/ptime.cc + commands/ptime.h + commands/quit.cc + commands/quit.h + commands/register.cc + commands/register.h + commands/register-status.cc + commands/register-status.h + commands/terminate.cc + commands/terminate.h + commands/unregister.cc + commands/unregister.h + commands/version.cc + commands/version.h + commands/video.cc + commands/video.h + daemon.cc + daemon.h +) + +set(DAEMON_PIPETEST_SOURCE_FILES + daemon-pipetest.c +) + +apply_compile_flags(DAEMON_SOURCE_FILES "CPP" "CXX") +apply_compile_flags(DAEMON_PIPETEST_SOURCE_FILES "CPP" "C") + +add_executable(linphone-daemon ${DAEMON_SOURCE_FILES}) +target_include_directories(linphone-daemon PRIVATE ${CMAKE_CURRENT_LIST_DIR}) +target_link_libraries(linphone-daemon linphone) + +add_executable(linphone-daemon-pipetest ${DAEMON_PIPETEST_SOURCE_FILES}) +target_link_libraries(linphone-daemon-pipetest linphone) + +set(INSTALL_TARGETS linphone-daemon linphone-daemon-pipetest) + +install(TARGETS ${INSTALL_TARGETS} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE +) diff --git a/daemon/commands/audio-codec-get.cc b/daemon/commands/audio-codec-get.cc index 48bd25f05..357525b05 100644 --- a/daemon/commands/audio-codec-get.cc +++ b/daemon/commands/audio-codec-get.cc @@ -54,7 +54,7 @@ void AudioCodecGetCommand::exec(Daemon *app, const char *args) { } int index = 0; - for (const MSList *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = ms_list_next(node)) { + for (const bctbx_list_t *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = bctbx_list_next(node)) { PayloadType *payload = reinterpret_cast(node->data); if (list) { ost << PayloadTypeResponse(app->getCore(), payload, index).getBody() << "\n"; diff --git a/daemon/commands/audio-codec-move.cc b/daemon/commands/audio-codec-move.cc index 3d65f9113..82816ac90 100644 --- a/daemon/commands/audio-codec-move.cc +++ b/daemon/commands/audio-codec-move.cc @@ -65,21 +65,21 @@ void AudioCodecMoveCommand::exec(Daemon *app, const char *args) { } int i = 0; - MSList *mslist = NULL; - for (const MSList *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = ms_list_next(node)) { + bctbx_list_t *mslist = NULL; + for (const bctbx_list_t *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = bctbx_list_next(node)) { PayloadType *payload = reinterpret_cast(node->data); if (i == index) { - mslist = ms_list_append(mslist, selected_payload); + mslist = bctbx_list_append(mslist, selected_payload); ++i; } if (selected_payload != payload) { - mslist = ms_list_append(mslist, payload); + mslist = bctbx_list_append(mslist, payload); ++i; } } if (i <= index) { index = i; - mslist = ms_list_append(mslist, selected_payload); + mslist = bctbx_list_append(mslist, selected_payload); } linphone_core_set_audio_codecs(app->getCore(), mslist); diff --git a/daemon/commands/audio-codec-set.cc b/daemon/commands/audio-codec-set.cc index 5e9d2935a..2dffe2cd5 100644 --- a/daemon/commands/audio-codec-set.cc +++ b/daemon/commands/audio-codec-set.cc @@ -49,7 +49,7 @@ AudioCodecSetCommand::AudioCodecSetCommand() : static PayloadType *findPayload(LinphoneCore *lc, int payload_type, int *index){ if (index) *index=0; - for (const MSList *node = linphone_core_get_audio_codecs(lc); node != NULL; node = ms_list_next(node)) { + for (const bctbx_list_t *node = linphone_core_get_audio_codecs(lc); node != NULL; node = bctbx_list_next(node)) { PayloadType *payload = reinterpret_cast(node->data); if (index) (*index)++; if (payload_type == linphone_core_get_payload_type_number(lc, payload)) { diff --git a/daemon/commands/audio-codec-toggle.cc b/daemon/commands/audio-codec-toggle.cc index 4f782abe7..9b7b6beeb 100644 --- a/daemon/commands/audio-codec-toggle.cc +++ b/daemon/commands/audio-codec-toggle.cc @@ -24,7 +24,7 @@ void AudioCodecToggleCommand::exec(Daemon *app, const char *args) { if (!parser.all()) pt = parser.getPayloadType(); int index = 0; - for (const MSList *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = ms_list_next(node)) { + for (const bctbx_list_t *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = bctbx_list_next(node)) { PayloadType *payload = reinterpret_cast(node->data); if (parser.all()) { linphone_core_enable_payload_type(app->getCore(), payload, mEnable); diff --git a/daemon/commands/dtmf.cc b/daemon/commands/dtmf.cc index d5b0a9103..899ca8c5e 100644 --- a/daemon/commands/dtmf.cc +++ b/daemon/commands/dtmf.cc @@ -20,10 +20,13 @@ void DtmfCommand::exec(Daemon *app, const char *args) { if (ist.fail()) { app->sendResponse(Response("Missing digit parameter.", Response::Error)); } else { - digit = digit_str.at(0); + digit = digit_str.at(0); if (isdigit(digit) || (digit == 'A') || (digit == 'B') || (digit == 'C') || (digit == 'D') || (digit == '*') || (digit == '#')) { + LinphoneCall *call = linphone_core_get_current_call(app->getCore()); linphone_core_play_dtmf(app->getCore(), digit, 100); - linphone_core_send_dtmf(app->getCore(), digit); + if (call == NULL) { + linphone_call_send_dtmf(call, digit); + } app->sendResponse(Response()); } else { app->sendResponse(Response("Incorrect digit parameter.", Response::Error)); diff --git a/daemon/daemon-pipetest.c b/daemon/daemon-pipetest.c index dde0bb3b0..a67b8017f 100644 --- a/daemon/daemon-pipetest.c +++ b/daemon/daemon-pipetest.c @@ -10,15 +10,17 @@ static int running=1; int main(int argc, char *argv[]){ + struct pollfd pfds[2]={{0}}; + char buf[4096]; + int fd; + /* handle args */ if (argc < 2) { ortp_error("Usage: %s pipename", argv[0]); return 1; } - int fd=ortp_client_pipe_connect(argv[1]); - struct pollfd pfds[2]={{0}}; - char buf[4096]; + fd=ortp_client_pipe_connect(argv[1]); ortp_init(); ortp_set_log_level_mask(NULL,ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 3ac3efa30..500759887 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -251,9 +251,9 @@ PayloadTypeParser::PayloadTypeParser(LinphoneCore *core, const string &mime_type return; } mPayloadType = linphone_core_find_payload_type(core, type, rate, channels); - if (mPayloadType) mPosition=ms_list_index(linphone_core_get_audio_codecs(core), mPayloadType); + if (mPayloadType) mPosition=bctbx_list_index(linphone_core_get_audio_codecs(core), mPayloadType); }else if (number!=-1){ - const MSList *elem; + const bctbx_list_t *elem; for(elem=linphone_core_get_audio_codecs(core);elem!=NULL;elem=elem->next){ if (number==linphone_core_get_payload_type_number(core,(PayloadType*)elem->data)){ mPayloadType=(PayloadType*)elem->data; @@ -355,7 +355,7 @@ int Daemon::updateCallId(LinphoneCall *call) { } LinphoneCall *Daemon::findCall(int id) { - const MSList *elem = linphone_core_get_calls(mLc); + const bctbx_list_t *elem = linphone_core_get_calls(mLc); for (; elem != NULL; elem = elem->next) { LinphoneCall *call = (LinphoneCall *) elem->data; if (linphone_call_get_user_pointer(call) == (void*) (long) id) @@ -374,7 +374,7 @@ int Daemon::updateProxyId(LinphoneProxyConfig *cfg) { } LinphoneProxyConfig *Daemon::findProxy(int id) { - const MSList *elem = linphone_core_get_proxy_config_list(mLc); + const bctbx_list_t *elem = linphone_core_get_proxy_config_list(mLc); for (; elem != NULL; elem = elem->next) { LinphoneProxyConfig *proxy = (LinphoneProxyConfig *) elem->data; if (linphone_proxy_config_get_user_data(proxy) == (void*) (long) id) @@ -384,8 +384,8 @@ LinphoneProxyConfig *Daemon::findProxy(int id) { } LinphoneAuthInfo *Daemon::findAuthInfo(int id) { - const MSList *elem = linphone_core_get_auth_info_list(mLc); - if (elem == NULL || id < 1 || (unsigned int)id > ms_list_size(elem)) { + const bctbx_list_t *elem = linphone_core_get_auth_info_list(mLc); + if (elem == NULL || id < 1 || (unsigned int)id > bctbx_list_size(elem)) { return NULL; } while (id > 1) { diff --git a/daemon/daemon.h b/daemon/daemon.h index 564cb7994..416877fa1 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -212,7 +213,7 @@ public: int updateCallId(LinphoneCall *call); int updateProxyId(LinphoneProxyConfig *proxy); inline int maxProxyId() { return mProxyIds; } - inline int maxAuthInfoId() { return ms_list_size(linphone_core_get_auth_info_list(mLc)); } + inline int maxAuthInfoId() { return bctbx_list_size(linphone_core_get_auth_info_list(mLc)); } int updateAudioStreamId(AudioStream *audio_stream); void dumpCommandsHelp(); void dumpCommandsHelpHtml(); From 8d4c44e8cc5d0a91f371401ca6e49f1e9bc45c98 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 17 Jun 2016 14:19:43 +0200 Subject: [PATCH 100/124] Fix Python module automatic code generation. --- coreapi/conference.h | 4 ++-- coreapi/friendlist.h | 4 ++-- coreapi/linphone_tunnel.h | 2 +- coreapi/linphonefriend.h | 6 +++--- coreapi/lpconfig.h | 4 ++-- coreapi/vcard.h | 10 +++++----- tools/genapixml.py | 6 +++--- .../apixml2python/handwritten_declarations.mustache | 4 ++-- .../apixml2python/handwritten_definitions.mustache | 10 +++++----- tools/python/apixml2python/linphone.py | 4 ++-- tools/python/apixml2python/linphone_module.mustache | 10 +++++----- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/coreapi/conference.h b/coreapi/conference.h index 0de492b7e..b1867adee 100644 --- a/coreapi/conference.h +++ b/coreapi/conference.h @@ -97,12 +97,12 @@ LINPHONE_PUBLIC int linphone_conference_remove_participant(LinphoneConference *o /** * Get URIs of all participants of one conference - * The returned MSList contains URIs of all participant. That list must be + * The returned bctbx_list_t contains URIs of all participant. That list must be * freed after use and each URI must be unref with linphone_address_unref() * @param obj A #LinphoneConference * @return \mslist{LinphoneAddress} */ -LINPHONE_PUBLIC MSList *linphone_conference_get_participants(const LinphoneConference *obj); +LINPHONE_PUBLIC bctbx_list_t *linphone_conference_get_participants(const LinphoneConference *obj); /** * @} diff --git a/coreapi/friendlist.h b/coreapi/friendlist.h index 46bc711cd..1036acfbd 100644 --- a/coreapi/friendlist.h +++ b/coreapi/friendlist.h @@ -89,7 +89,7 @@ LINPHONE_PUBLIC void linphone_core_remove_friend_list(LinphoneCore *lc, Linphone * @param[in] lc LinphoneCore object * @return \mslist{LinphoneFriendList} a list of LinphoneFriendList */ -LINPHONE_PUBLIC const MSList * linphone_core_get_friends_lists(const LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_friends_lists(const LinphoneCore *lc); /** * Retrieves the first list of LinphoneFriend from the core. @@ -183,7 +183,7 @@ LINPHONE_PUBLIC LinphoneFriendListStatus linphone_friend_list_remove_friend(Linp * @param[in] list LinphoneFriendList object * @return \mslist{LinphoneFriend} a list of LinphoneFriend */ -LINPHONE_PUBLIC const MSList * linphone_friend_list_get_friends(const LinphoneFriendList *list); +LINPHONE_PUBLIC const bctbx_list_t * linphone_friend_list_get_friends(const LinphoneFriendList *list); /** * Find a friend in the friend list using a LinphoneAddress. diff --git a/coreapi/linphone_tunnel.h b/coreapi/linphone_tunnel.h index 6a52748c0..8b68651ea 100644 --- a/coreapi/linphone_tunnel.h +++ b/coreapi/linphone_tunnel.h @@ -229,7 +229,7 @@ LINPHONE_PUBLIC void linphone_tunnel_remove_server(LinphoneTunnel *tunnel, Linph * @param tunnel LinphoneTunnel object * @return \mslist{LinphoneTunnelConfig} */ -LINPHONE_PUBLIC const MSList *linphone_tunnel_get_servers(const LinphoneTunnel *tunnel); +LINPHONE_PUBLIC const bctbx_list_t *linphone_tunnel_get_servers(const LinphoneTunnel *tunnel); /** * Remove all tunnel server addresses previously entered with linphone_tunnel_add_server() diff --git a/coreapi/linphonefriend.h b/coreapi/linphonefriend.h index 1d52fc212..8067c8706 100644 --- a/coreapi/linphonefriend.h +++ b/coreapi/linphonefriend.h @@ -176,7 +176,7 @@ LINPHONE_PUBLIC void linphone_friend_add_address(LinphoneFriend *lf, const Linph * @param lf #LinphoneFriend object * @return \mslist{LinphoneAddress} */ -LINPHONE_PUBLIC MSList* linphone_friend_get_addresses(LinphoneFriend *lf); +LINPHONE_PUBLIC bctbx_list_t* linphone_friend_get_addresses(LinphoneFriend *lf); /** * Removes an address in this friend @@ -197,7 +197,7 @@ LINPHONE_PUBLIC void linphone_friend_add_phone_number(LinphoneFriend *lf, const * @param lf #LinphoneFriend object * @return \mslist{const char *} */ -LINPHONE_PUBLIC MSList* linphone_friend_get_phone_numbers(LinphoneFriend *lf); +LINPHONE_PUBLIC bctbx_list_t* linphone_friend_get_phone_numbers(LinphoneFriend *lf); /** * Removes a phone number in this friend @@ -430,7 +430,7 @@ LINPHONE_PUBLIC void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneF * @return \mslist{LinphoneFriend} * @deprecated use linphone_core_get_friends_lists() or linphone_friend_list_get_friends() instead. */ -LINPHONE_PUBLIC const MSList * linphone_core_get_friend_list(const LinphoneCore *lc); +LINPHONE_PUBLIC const bctbx_list_t * linphone_core_get_friend_list(const LinphoneCore *lc); /** * Notify all friends that have subscribed diff --git a/coreapi/lpconfig.h b/coreapi/lpconfig.h index c69f3d999..59269098e 100644 --- a/coreapi/lpconfig.h +++ b/coreapi/lpconfig.h @@ -114,7 +114,7 @@ LINPHONE_PUBLIC const char *lp_config_get_string(const LpConfig *lpconfig, const * @param[in] default_list \mslist{const char *} * @return \mslist{const char *} */ -LINPHONE_PUBLIC MSList * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, MSList *default_list); +LINPHONE_PUBLIC bctbx_list_t * lp_config_get_string_list(const LpConfig *lpconfig, const char *section, const char *key, bctbx_list_t *default_list); /** * Retrieves a configuration item as a range, given its section, key, and default min and max values. @@ -164,7 +164,7 @@ LINPHONE_PUBLIC void lp_config_set_string(LpConfig *lpconfig,const char *section * @param[in] key The name of the configuration item to set * @param[in] value \mslist{const char *} The value to set */ -LINPHONE_PUBLIC void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const MSList *value); +LINPHONE_PUBLIC void lp_config_set_string_list(LpConfig *lpconfig, const char *section, const char *key, const bctbx_list_t *value); /** * Sets a range config item diff --git a/coreapi/vcard.h b/coreapi/vcard.h index eb15ead51..dc0e6db3b 100644 --- a/coreapi/vcard.h +++ b/coreapi/vcard.h @@ -57,14 +57,14 @@ LINPHONE_PUBLIC void linphone_vcard_free(LinphoneVcard *vCard); * @param[in] file the path to the file to parse * @return \mslist{LinphoneVcard} */ -LINPHONE_PUBLIC MSList* linphone_vcard_list_from_vcard4_file(const char *file); +LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_file(const char *file); /** * Uses belcard to parse the content of a buffer and returns all the vcards it contains as LinphoneVcards, or NULL if it contains none. * @param[in] buffer the buffer to parse * @return \mslist{LinphoneVcard} */ -LINPHONE_PUBLIC MSList* linphone_vcard_list_from_vcard4_buffer(const char *buffer); +LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_list_from_vcard4_buffer(const char *buffer); /** * Uses belcard to parse the content of a buffer and returns one vCard if possible, or NULL otherwise. @@ -120,7 +120,7 @@ void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_ * @param[in] vCard the LinphoneVcard * @return \mslist{const char *} */ -LINPHONE_PUBLIC MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard); +LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard); /** * Adds a phone number in the vCard, using the TEL property @@ -141,14 +141,14 @@ void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) * @param[in] vCard the LinphoneVcard * @return \mslist{const char *} */ -LINPHONE_PUBLIC MSList* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard); +LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard); /** * Returns the list of SIP addresses (as string) in the vCard (all the IMPP attributes that has an URI value starting by "sip:") or NULL * @param[in] vCard the LinphoneVcard * @return \mslist{const char *} */ -LINPHONE_PUBLIC MSList* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard); +LINPHONE_PUBLIC bctbx_list_t* linphone_vcard_get_sip_addresses(const LinphoneVcard *vCard); /** * Fills the Organization field of the vCard diff --git a/tools/genapixml.py b/tools/genapixml.py index d03d96f54..f0bb2c51c 100755 --- a/tools/genapixml.py +++ b/tools/genapixml.py @@ -436,7 +436,7 @@ class Project: returnarg = CArgument(returntype, enums = self.enums, structs = self.__structs) returndesc = node.find("./detaileddescription/para/simplesect[@kind='return']") if returndesc is not None: - if returnarg.ctype == 'MSList': + if returnarg.ctype == 'MSList' or returnarg.ctype == 'bctbx_list_t': n = returndesc.find('.//mslist') if n is not None: returnarg.containedType = n.text @@ -507,7 +507,7 @@ class Project: returnarg = CArgument(t, enums = self.enums, structs = self.__structs) returndesc = node.find("./detaileddescription/para/simplesect[@kind='return']") if returndesc is not None: - if returnarg.ctype == 'MSList': + if returnarg.ctype == 'MSList' or returnarg.ctype == 'bctbx_list_t': n = returndesc.find('.//mslist') if n is not None: returnarg.containedType = n.text @@ -530,7 +530,7 @@ class Project: for arg in argslist.arguments: for paramdesc in paramdescs: if arg.name == paramdesc.find('./parameternamelist').find('./parametername').text: - if arg.ctype == 'MSList': + if arg.ctype == 'MSList' or arg.ctype == 'bctbx_list_t': n = paramdesc.find('.//mslist') if n is not None: arg.containedType = n.text diff --git a/tools/python/apixml2python/handwritten_declarations.mustache b/tools/python/apixml2python/handwritten_declarations.mustache index 0f694d6c3..ca7cfd1c4 100644 --- a/tools/python/apixml2python/handwritten_declarations.mustache +++ b/tools/python/apixml2python/handwritten_declarations.mustache @@ -24,8 +24,8 @@ typedef struct { LCSipTransports lcst; } pylinphone_SipTransportsObject; -PyObject * PyList_FromMSListOfString(const MSList *msl); -MSList * PyList_AsMSListOfString(PyObject *pyl); +PyObject * PyList_FromMSListOfString(const bctbx_list_t *msl); +bctbx_list_t * PyList_AsMSListOfString(PyObject *pyl); int PyLinphoneVideoSize_Check(PyObject *p); MSVideoSize PyLinphoneVideoSize_AsMSVideoSize(PyObject *obj); diff --git a/tools/python/apixml2python/handwritten_definitions.mustache b/tools/python/apixml2python/handwritten_definitions.mustache index e34c7f16b..f87dfe7f2 100644 --- a/tools/python/apixml2python/handwritten_definitions.mustache +++ b/tools/python/apixml2python/handwritten_definitions.mustache @@ -1,21 +1,21 @@ -PyObject * PyList_FromMSListOfString(const MSList *msl) { +PyObject * PyList_FromMSListOfString(const bctbx_list_t *msl) { PyObject *pyl = PyList_New(0); while (msl != NULL) { PyObject *item = Py_BuildValue("z", (const char *)msl->data); PyList_Append(pyl, item); - msl = ms_list_next(msl); + msl = bctbx_list_next(msl); } return pyl; } -MSList * PyList_AsMSListOfString(PyObject *pyl) { - MSList *msl = NULL; +bctbx_list_t * PyList_AsMSListOfString(PyObject *pyl) { + bctbx_list_t *msl = NULL; Py_ssize_t idx; Py_ssize_t size = PyList_Size(pyl); for (idx = 0; idx < size; idx++) { PyObject *item = PyList_GetItem(pyl, idx); char *citem = (char *)PyString_AsString(item); - msl = ms_list_append(msl, citem); + msl = bctbx_list_append(msl, citem); } return msl; } diff --git a/tools/python/apixml2python/linphone.py b/tools/python/apixml2python/linphone.py index a6456159b..0b3687129 100644 --- a/tools/python/apixml2python/linphone.py +++ b/tools/python/apixml2python/linphone.py @@ -101,7 +101,7 @@ class ArgumentType: self.use_native_pointer = False self.cast_convert_func_result = True self.__compute() - if self.basic_type == 'MSList' and self.contained_type is not None and self.contained_type != 'const char *': + if (self.basic_type == 'MSList' or self.basic_type == 'bctbx_list_t') and self.contained_type is not None and self.contained_type != 'const char *': self.linphone_module.mslist_types.add(self.contained_type) def __compute(self): @@ -214,7 +214,7 @@ class ArgumentType: self.fmt_str = 'O' self.cfmt_str = '%p' self.cnativefmt_str = '%ld' - elif self.basic_type == 'MSList': + elif self.basic_type == 'MSList' or self.basic_type == 'bctbx_list_t': if self.contained_type == 'const char *': self.type_str = 'list of string' self.convert_code = "{result_name}{result_suffix} = {cast}PyList_AsMSListOfString({arg_name});\n" diff --git a/tools/python/apixml2python/linphone_module.mustache b/tools/python/apixml2python/linphone_module.mustache index 9d5410979..7ee8443cb 100644 --- a/tools/python/apixml2python/linphone_module.mustache +++ b/tools/python/apixml2python/linphone_module.mustache @@ -72,25 +72,25 @@ static PyObject * pylinphone_{{class_name}}_instance_method_{{method_name}}(PyOb {{/classes}} {{#mslist_types}} -PyObject * PyList_FromMSListOf{{c_contained_type}}(const MSList *msl) { +PyObject * PyList_FromMSListOf{{c_contained_type}}(const bctbx_list_t *msl) { PyObject *pyl = PyList_New(0); while (msl != NULL) { {{c_contained_type}} *native_ptr = ({{c_contained_type}} *)msl->data; PyObject *item = pylinphone_{{python_contained_type}}_from_native_ptr(&pylinphone_{{python_contained_type}}Type, native_ptr); PyList_Append(pyl, item); - msl = ms_list_next(msl); + msl = bctbx_list_next(msl); } return pyl; } -MSList * PyList_AsMSListOf{{c_contained_type}}(PyObject *pyl) { - MSList *msl = NULL; +bctbx_list_t * PyList_AsMSListOf{{c_contained_type}}(PyObject *pyl) { + bctbx_list_t *msl = NULL; Py_ssize_t idx; Py_ssize_t size = PyList_Size(pyl); for (idx = 0; idx < size; idx++) { PyObject *item = PyList_GetItem(pyl, idx); {{c_contained_type}} *native_ptr = pylinphone_{{python_contained_type}}_get_native_ptr(item); - msl = ms_list_append(msl, native_ptr); + msl = bctbx_list_append(msl, native_ptr); } return msl; } From 9063a2e025c1125f82ac44fc06ddcdd4b2cba00a Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 17 Jun 2016 14:23:10 +0200 Subject: [PATCH 101/124] All calls to GetStringUTFChars and ReleaseStringUTFChars in JNI layer are now protected from NULL values --- coreapi/linphonecore_jni.cc | 736 ++++++++++++++++++------------------ 1 file changed, 368 insertions(+), 368 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 0c5a6fcfc..a96901c52 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -140,6 +140,14 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) return JNI_VERSION_1_2; } +static const char* GetStringUTFChars(JNIEnv* env, jstring string) { + const char *cstring = string ? env->GetStringUTFChars(string, NULL) : NULL; + return cstring; +} + +static void ReleaseStringUTFChars(JNIEnv* env, jstring string, const char *cstring) { + if (string) env->ReleaseStringUTFChars(string, cstring); +} //LinphoneFactory extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env @@ -147,7 +155,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIE ,jboolean isDebug ,jstring jdebugTag) { if (isDebug) { - LogDomain = env->GetStringUTFChars(jdebugTag, NULL); + LogDomain = GetStringUTFChars(env, jdebugTag); linphone_core_enable_logs_with_cb(linphone_android_ortp_log_handler); } else { linphone_core_disable_logs(); @@ -172,9 +180,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setLogCollectionP ,jobject thiz ,jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_log_collection_path(path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } // LinphoneCore @@ -1338,8 +1346,8 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* ,jstring jfactoryConfig ,jobject juserdata){ - const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL; - const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL; + const char* userConfig = GetStringUTFChars(env, juserConfig); + const char* factoryConfig = GetStringUTFChars(env, jfactoryConfig); LinphoneJavaBindings *ljb = new LinphoneJavaBindings(env); @@ -1353,8 +1361,8 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* LinphoneCore *lc = linphone_core_new(vTable, userConfig, factoryConfig, ljb); jlong nativePtr = (jlong)lc; - if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig); - if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig); + ReleaseStringUTFChars(env, juserConfig, userConfig); + ReleaseStringUTFChars(env, jfactoryConfig, factoryConfig); return nativePtr; } @@ -1444,26 +1452,26 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopRinging(JNIEnv* env, } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setChatDatabasePath(JNIEnv* env, jobject thiz, jlong lc, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_chat_database_path((LinphoneCore*)lc, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCallLogsDatabasePath( JNIEnv* env, jobject thiz, jlong lc, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_call_logs_database_path((LinphoneCore*)lc, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFriendsDatabasePath( JNIEnv* env, jobject thiz, jlong lc, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_friends_database_path((LinphoneCore*)lc, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact2(JNIEnv* env, jobject thiz, jlong lc, jstring jcontact) { - const char* contact = env->GetStringUTFChars(jcontact, NULL); + const char* contact = GetStringUTFChars(env, jcontact); linphone_core_set_primary_contact((LinphoneCore*)lc, contact); - env->ReleaseStringUTFChars(jcontact, contact); + ReleaseStringUTFChars(env, jcontact, contact); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getPrimaryContact(JNIEnv* env, jobject thiz, jlong lc) { @@ -1473,8 +1481,8 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getPrimaryContact(JNI extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv* env, jobject thiz, jlong lc, jstring jdisplayname, jstring jusername) { - const char* displayname = jdisplayname ? env->GetStringUTFChars(jdisplayname, NULL) : NULL; - const char* username = jusername ? env->GetStringUTFChars(jusername, NULL) : NULL; + const char* displayname = GetStringUTFChars(env, jdisplayname); + const char* username = GetStringUTFChars(env, jusername); LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed((LinphoneCore*)lc); if (parsed != NULL) { @@ -1484,8 +1492,8 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv linphone_core_set_primary_contact((LinphoneCore*)lc, contact); } - if (jdisplayname) env->ReleaseStringUTFChars(jdisplayname, displayname); - if (jusername) env->ReleaseStringUTFChars(jusername, username); + ReleaseStringUTFChars(env, jdisplayname, displayname); + ReleaseStringUTFChars(env, jusername, username); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getPrimaryContactUsername(JNIEnv* env, jobject thiz, jlong lc) { @@ -1575,16 +1583,14 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getAuthInfosList(J } extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findAuthInfos(JNIEnv* env, jobject thiz, jlong lc, jstring jusername, jstring jrealm, jstring jdomain) { - const char* username = env->GetStringUTFChars(jusername, NULL); - const char* realm = jrealm ? env->GetStringUTFChars(jrealm, NULL) : NULL; - const char* domain = jdomain ? env->GetStringUTFChars(jdomain, NULL) : NULL; + const char* username = GetStringUTFChars(env, jusername); + const char* realm = GetStringUTFChars(env, jrealm); + const char* domain = GetStringUTFChars(env, jdomain); const LinphoneAuthInfo *authInfo = linphone_core_find_auth_info((LinphoneCore*)lc, realm, username, domain); - if (realm) - env->ReleaseStringUTFChars(jrealm, realm); - if (domain) - env->ReleaseStringUTFChars(jdomain, domain); - env->ReleaseStringUTFChars(jusername, username); + ReleaseStringUTFChars(env, jrealm, realm); + ReleaseStringUTFChars(env, jdomain, domain); + ReleaseStringUTFChars(env, jusername, username); return (jlong) authInfo; } @@ -1612,9 +1618,9 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite(JNIEnv* env ,jobject thiz ,jlong lc ,jstring juri) { - const char* uri = env->GetStringUTFChars(juri, NULL); + const char* uri = GetStringUTFChars(env, juri); LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri); - env->ReleaseStringUTFChars(juri, uri); + ReleaseStringUTFChars(env, juri, uri); return getCall(env,lCall); } extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress(JNIEnv* env @@ -1797,9 +1803,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* ,jobject thiz ,jlong lc ,jstring jurl) { - const char* url = env->GetStringUTFChars(jurl, NULL); + const char* url = GetStringUTFChars(env, jurl); jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url); - env->ReleaseStringUTFChars(jurl, url); + ReleaseStringUTFChars(env, jurl, url); return result; } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env @@ -1855,9 +1861,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* ,jstring jmime ,jint rate ,jint channels) { - const char* mime = env->GetStringUTFChars(jmime, NULL); + const char* mime = GetStringUTFChars(env, jmime); jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels); - env->ReleaseStringUTFChars(jmime, mime); + ReleaseStringUTFChars(env, jmime, mime); return result; } @@ -2001,9 +2007,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAdaptiveRateAlgorithm ,jobject thiz ,jlong lc ,jstring jalg) { - const char* alg = jalg?env->GetStringUTFChars(jalg, NULL):NULL; + const char* alg = GetStringUTFChars(env, jalg); linphone_core_set_adaptive_rate_algorithm((LinphoneCore*)lc,alg); - if (alg) env->ReleaseStringUTFChars(jalg, alg); + ReleaseStringUTFChars(env, jalg, alg); } @@ -2050,23 +2056,23 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env } extern "C" jint Java_org_linphone_core_LinphoneFriendListImpl_importFriendsFromVCardFile(JNIEnv* env, jobject thiz, jlong list, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); int count = linphone_friend_list_import_friends_from_vcard4_file((LinphoneFriendList*)list, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); return count; } extern "C" jint Java_org_linphone_core_LinphoneFriendListImpl_importFriendsFromVCardBuffer(JNIEnv* env, jobject thiz, jlong list, jstring jbuffer) { - const char* buffer = env->GetStringUTFChars(jbuffer, NULL); + const char* buffer = GetStringUTFChars(env, jbuffer); int count = linphone_friend_list_import_friends_from_vcard4_buffer((LinphoneFriendList*)list, buffer); - env->ReleaseStringUTFChars(jbuffer, buffer); + ReleaseStringUTFChars(env, jbuffer, buffer); return count; } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_exportFriendsToVCardFile(JNIEnv* env, jobject thiz, jlong list, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_friend_list_export_friends_as_vcard4_file((LinphoneFriendList*)list, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_enableSubscriptions(JNIEnv* env, jobject thiz, jlong list, jboolean enable) { @@ -2144,9 +2150,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* ,jint minutes_away ,jstring jalternative_contact ,jint status) { - const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL; + const char* alternative_contact = GetStringUTFChars(env, jalternative_contact); linphone_core_set_presence_info((LinphoneCore*)lc,minutes_away,alternative_contact,(LinphoneOnlineStatus)status); - if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact); + ReleaseStringUTFChars(env, jalternative_contact, alternative_contact); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getPresenceInfo(JNIEnv *env, jobject thiz, jlong lc) { return (jint)linphone_core_get_presence_info((LinphoneCore *)lc); @@ -2180,9 +2186,9 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getOrCreateChatRoom(J ,jlong lc ,jstring jto) { - const char* to = env->GetStringUTFChars(jto, NULL); + const char* to = GetStringUTFChars(env, jto); LinphoneChatRoom* lResult = linphone_core_get_chat_room_from_uri((LinphoneCore*)lc,to); - env->ReleaseStringUTFChars(jto, to); + ReleaseStringUTFChars(env, jto, to); return getChatRoom(env, lResult); } @@ -2219,17 +2225,17 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_play_file((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_ring((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env ,jobject thiz @@ -2247,9 +2253,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setTone(JNIEnv* env ,jlong lc ,jint toneid ,jstring jpath) { - const char* path = jpath ? env->GetStringUTFChars(jpath, NULL) : NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_tone((LinphoneCore *)lc, (LinphoneToneID)toneid, path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCallErrorTone(JNIEnv* env @@ -2257,25 +2263,25 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCallErrorTone(JNIEnv* ,jlong lc ,jint reason ,jstring jpath) { - const char* path = jpath ? env->GetStringUTFChars(jpath, NULL) : NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_call_error_tone((LinphoneCore *)lc, (LinphoneReason)reason, path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_root_ca((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRingback(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_ringback((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } @@ -2283,9 +2289,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setProvisioningUri(JNIEn ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_provisioning_uri((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getProvisioningUri(JNIEnv* env @@ -2453,9 +2459,9 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_finalize(JNIEnv* } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) { - const char* identity = env->GetStringUTFChars(jidentity, NULL); + const char* identity = GetStringUTFChars(env, jidentity); linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity); - env->ReleaseStringUTFChars(jidentity, identity); + ReleaseStringUTFChars(env, jidentity, identity); } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) { const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg); @@ -2472,9 +2478,9 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setAddress(JNIEnv linphone_proxy_config_set_identity_address((LinphoneProxyConfig*)proxyCfg, (LinphoneAddress*) jidentity); } extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) { - const char* proxy = env->GetStringUTFChars(jproxy, NULL); + const char* proxy = GetStringUTFChars(env, jproxy); jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy); - env->ReleaseStringUTFChars(jproxy, proxy); + ReleaseStringUTFChars(env, jproxy, proxy); return err; } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) { @@ -2486,14 +2492,14 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEn } } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) { - const char* params = jparams ? env->GetStringUTFChars(jparams, NULL) : NULL; + const char* params = GetStringUTFChars(env, jparams); linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params); - if (jparams) env->ReleaseStringUTFChars(jparams, params); + ReleaseStringUTFChars(env, jparams, params); } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactUriParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) { - const char* params = jparams ? env->GetStringUTFChars(jparams, NULL) : NULL; + const char* params = GetStringUTFChars(env, jparams); linphone_proxy_config_set_contact_uri_parameters((LinphoneProxyConfig*)proxyCfg, params); - if (jparams) env->ReleaseStringUTFChars(jparams, params); + ReleaseStringUTFChars(env, jparams, params); } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg) { const char* params = linphone_proxy_config_get_contact_parameters((LinphoneProxyConfig*)proxyCfg); @@ -2507,9 +2513,9 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getContactUriP extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) { if (jroute != NULL) { - const char* route = env->GetStringUTFChars(jroute, NULL); + const char* route = GetStringUTFChars(env, jroute); jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route); - env->ReleaseStringUTFChars(jroute, route); + ReleaseStringUTFChars(env, jroute, route); return err; } else { return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL); @@ -2545,7 +2551,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhone ms_error("cannot normalized null number"); } char * normalized_phone; - const char* number = env->GetStringUTFChars(jnumber, NULL); + const char* number = GetStringUTFChars(env, jnumber); int len = env->GetStringLength(jnumber); if (len == 0) { ms_warning("cannot normalize empty number"); @@ -2553,26 +2559,26 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhone } normalized_phone = linphone_proxy_config_normalize_phone_number((LinphoneProxyConfig*)proxyCfg,number); jstring normalizedNumber = env->NewStringUTF(normalized_phone ? normalized_phone : number); - env->ReleaseStringUTFChars(jnumber, number); + ReleaseStringUTFChars(env, jnumber, number); ms_free(normalized_phone); return normalizedNumber; } extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_normalizeSipUri(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jusername) { - const char* username = env->GetStringUTFChars(jusername, NULL); + const char* username = GetStringUTFChars(env, jusername); LinphoneAddress *addr = linphone_proxy_config_normalize_sip_uri((LinphoneProxyConfig*)proxyCfg, username); - env->ReleaseStringUTFChars(jusername, username); + ReleaseStringUTFChars(env, jusername, username); return (jlong) addr; } extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) { - const char* iso = env->GetStringUTFChars(jiso, NULL); + const char* iso = GetStringUTFChars(env, jiso); int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso); - env->ReleaseStringUTFChars(jiso, iso); + ReleaseStringUTFChars(env, jiso, iso); return (jint) prefix; } extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromE164(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring je164) { - const char* e164 = env->GetStringUTFChars(je164, NULL); + const char* e164 = GetStringUTFChars(env, je164); int prefix = linphone_dial_plan_lookup_ccc_from_e164(e164); - env->ReleaseStringUTFChars(je164, e164); + ReleaseStringUTFChars(env, je164, e164); return (jint) prefix; } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env @@ -2598,9 +2604,9 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNI ,jobject thiz ,jlong proxyCfg ,jstring jprefix) { - const char* prefix = env->GetStringUTFChars(jprefix, NULL); + const char* prefix = GetStringUTFChars(env, jprefix); linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix); - env->ReleaseStringUTFChars(jprefix, prefix); + ReleaseStringUTFChars(env, jprefix, prefix); } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDialPrefix(JNIEnv* env,jobject thiz,jlong proxyCfg) { @@ -2712,9 +2718,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getUsernam */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setPassword (JNIEnv *env, jobject, jlong auth_info, jstring jpassword) { - const char* password = jpassword?env->GetStringUTFChars(jpassword, NULL):NULL; + const char* password = GetStringUTFChars(env, jpassword); linphone_auth_info_set_passwd((LinphoneAuthInfo*)auth_info,password); - if (password) env->ReleaseStringUTFChars(jpassword, password); + ReleaseStringUTFChars(env, jpassword, password); } /* @@ -2724,9 +2730,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setPassword */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setRealm (JNIEnv *env, jobject, jlong auth_info, jstring jrealm) { - const char* realm = jrealm?env->GetStringUTFChars(jrealm, NULL):NULL; + const char* realm = GetStringUTFChars(env, jrealm); linphone_auth_info_set_realm((LinphoneAuthInfo*)auth_info,realm); - if (realm) env->ReleaseStringUTFChars(jrealm, realm); + ReleaseStringUTFChars(env, jrealm, realm); } /* @@ -2736,10 +2742,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setRealm */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setDomain (JNIEnv *env, jobject, jlong auth_info, jstring jdomain) { - const char* domain = jdomain ? env->GetStringUTFChars(jdomain, NULL) : NULL; + const char* domain = GetStringUTFChars(env, jdomain); linphone_auth_info_set_domain((LinphoneAuthInfo*)auth_info, domain); - if (domain) - env->ReleaseStringUTFChars(jdomain, domain); + ReleaseStringUTFChars(env, jdomain, domain); } /* @@ -2749,9 +2754,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setDomain */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUsername (JNIEnv *env, jobject, jlong auth_info, jstring jusername) { - const char* username = jusername?env->GetStringUTFChars(jusername, NULL):NULL; + const char* username = GetStringUTFChars(env, jusername); linphone_auth_info_set_username((LinphoneAuthInfo*)auth_info,username); - if (username) env->ReleaseStringUTFChars(jusername, username); + ReleaseStringUTFChars(env, jusername, username); } /* @@ -2761,9 +2766,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUsername */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUserId (JNIEnv *env, jobject, jlong auth_info, jstring juserid) { - const char* userid = juserid?env->GetStringUTFChars(juserid, NULL):NULL; + const char* userid = GetStringUTFChars(env, juserid); linphone_auth_info_set_userid((LinphoneAuthInfo*)auth_info,userid); - if (userid) env->ReleaseStringUTFChars(juserid, userid); + ReleaseStringUTFChars(env, juserid, userid); } /* @@ -2788,9 +2793,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getUserId */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setHa1 (JNIEnv *env, jobject, jlong auth_info, jstring jha1) { - const char* ha1 = jha1?env->GetStringUTFChars(jha1, NULL):NULL; + const char* ha1 = GetStringUTFChars(env, jha1); linphone_auth_info_set_ha1((LinphoneAuthInfo*)auth_info,ha1); - if (ha1) env->ReleaseStringUTFChars(jha1, ha1); + ReleaseStringUTFChars(env, jha1, ha1); } @@ -2816,14 +2821,14 @@ extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressIm ,jobject thiz ,jstring juri ,jstring jdisplayName) { - const char* uri = juri?env->GetStringUTFChars(juri, NULL):NULL; + const char* uri = GetStringUTFChars(env, juri); LinphoneAddress* address = linphone_address_new(uri); if (jdisplayName && address) { - const char* displayName = env->GetStringUTFChars(jdisplayName, NULL); + const char* displayName = GetStringUTFChars(env, jdisplayName); linphone_address_set_display_name(address,displayName); - env->ReleaseStringUTFChars(jdisplayName, displayName); + ReleaseStringUTFChars(env, jdisplayName, displayName); } - if (uri) env->ReleaseStringUTFChars(juri, uri); + ReleaseStringUTFChars(env, juri, uri); return (jlong) address; } @@ -2908,25 +2913,25 @@ extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv ,jobject thiz ,jlong address ,jstring jdisplayName) { - const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL; + const char* displayName = GetStringUTFChars(env, jdisplayName); linphone_address_set_display_name((LinphoneAddress*)address,displayName); - if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName); + ReleaseStringUTFChars(env, jdisplayName, displayName); } extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setUserName(JNIEnv* env ,jobject thiz ,jlong address ,jstring juserName) { - const char* userName = juserName!= NULL?env->GetStringUTFChars(juserName, NULL):NULL; + const char* userName = GetStringUTFChars(env, juserName); linphone_address_set_username((LinphoneAddress*)address,userName); - if (userName != NULL) env->ReleaseStringUTFChars(juserName, userName); + ReleaseStringUTFChars(env, juserName, userName); } extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDomain(JNIEnv* env ,jobject thiz ,jlong address ,jstring jdomain) { - const char* domain = jdomain!= NULL?env->GetStringUTFChars(jdomain, NULL):NULL; + const char* domain = GetStringUTFChars(env, jdomain); linphone_address_set_domain((LinphoneAddress*)address,domain); - if (domain != NULL) env->ReleaseStringUTFChars(jdomain, domain); + ReleaseStringUTFChars(env, jdomain, domain); } extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setTransport(JNIEnv* env ,jobject thiz @@ -3099,8 +3104,9 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getCallLogs(JNIEnv extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env ,jobject thiz ,jlong ptr, jstring path) { - const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL; + const char* filePath = GetStringUTFChars(env, path); linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath); + ReleaseStringUTFChars(env, path, filePath); } extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env @@ -3246,10 +3252,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNI LinphoneFriend* lResult; if (jFriendUri) { - const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL); + const char* friendUri = GetStringUTFChars(env, jFriendUri); lResult = linphone_friend_new_with_address(friendUri); linphone_friend_set_user_data(lResult,env->NewWeakGlobalRef(thiz)); - env->ReleaseStringUTFChars(jFriendUri, friendUri); + ReleaseStringUTFChars(env, jFriendUri, friendUri); } else { lResult = linphone_friend_new(); linphone_friend_set_user_data(lResult,env->NewWeakGlobalRef(thiz)); @@ -3265,9 +3271,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneFriendListImpl_newLinphoneFriend } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_setUri(JNIEnv* env, jobject thiz, jlong list, jstring juri) { - const char* uri = env->GetStringUTFChars(juri, NULL); + const char* uri = GetStringUTFChars(env, juri); linphone_friend_list_set_uri((LinphoneFriendList*)list, uri); - env->ReleaseStringUTFChars(juri, uri); + ReleaseStringUTFChars(env, juri, uri); } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_synchronizeFriendsFromServer(JNIEnv* env, jobject thiz, jlong list) { @@ -3401,28 +3407,28 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setName(JNIEnv* env ,jobject thiz ,jlong ptr ,jstring jname) { - const char* name = env->GetStringUTFChars(jname, NULL); + const char* name = GetStringUTFChars(env, jname); linphone_friend_set_name((LinphoneFriend*)ptr, name); - env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_setRLSUri(JNIEnv* env ,jobject thiz ,jlong ptr ,jstring jrlsUri) { - const char* uri = env->GetStringUTFChars(jrlsUri, NULL); + const char* uri = GetStringUTFChars(env, jrlsUri); linphone_friend_list_set_rls_uri((LinphoneFriendList*)ptr, uri); - env->ReleaseStringUTFChars(jrlsUri, uri); + ReleaseStringUTFChars(env, jrlsUri, uri); } extern "C" jobject Java_org_linphone_core_LinphoneFriendListImpl_findFriendByUri(JNIEnv* env ,jobject thiz ,jlong friendListptr ,jstring juri) { - const char* uri = env->GetStringUTFChars(juri, NULL); + const char* uri = GetStringUTFChars(env, juri); LinphoneFriend* lFriend; lFriend = linphone_friend_list_find_friend_by_uri((LinphoneFriendList*)friendListptr, uri); - env->ReleaseStringUTFChars(juri, uri); + ReleaseStringUTFChars(env, juri, uri); if(lFriend != NULL) { jobject jfriend = getFriend(env,lFriend); // don't release local ref since it will be handled above by java @@ -3526,9 +3532,9 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_addPhoneNumber(JNIEnv* ,jlong ptr ,jstring jphone) { if (jphone) { - const char* phone = env->GetStringUTFChars(jphone, NULL); + const char* phone = GetStringUTFChars(env, jphone); linphone_friend_add_phone_number((LinphoneFriend*)ptr, phone); - env->ReleaseStringUTFChars(jphone, phone); + ReleaseStringUTFChars(env, jphone, phone); } } @@ -3537,9 +3543,9 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_removePhoneNumber(JNIE ,jlong ptr ,jstring jphone) { if (jphone) { - const char* phone = env->GetStringUTFChars(jphone, NULL); + const char* phone = GetStringUTFChars(env, jphone); linphone_friend_remove_phone_number((LinphoneFriend*)ptr, phone); - env->ReleaseStringUTFChars(jphone, phone); + ReleaseStringUTFChars(env, jphone, phone); } } @@ -3575,9 +3581,9 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setOrganization(JNIEnv LinphoneFriend *lf = (LinphoneFriend *)ptr; LinphoneVcard *lvc = linphone_friend_get_vcard(lf); if (lvc) { - const char* org = env->GetStringUTFChars(jorg, NULL); + const char* org = GetStringUTFChars(env, jorg); linphone_vcard_set_organization(lvc, org); - env->ReleaseStringUTFChars(jorg, org); + ReleaseStringUTFChars(env, jorg, org); } } @@ -3635,9 +3641,9 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setRefKey(JNIEnv* env ,jobject thiz ,jlong ptr ,jstring jkey) { - const char* key = env->GetStringUTFChars(jkey, NULL); + const char* key = GetStringUTFChars(env, jkey); linphone_friend_set_ref_key((LinphoneFriend*)ptr,key); - env->ReleaseStringUTFChars(jkey, key); + ReleaseStringUTFChars(env, jkey, key); } extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getRefKey(JNIEnv* env ,jobject thiz @@ -3701,9 +3707,9 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JN ,jobject thiz ,jlong ptr ,jstring jaddress) { - const char* address = env->GetStringUTFChars(jaddress, NULL); + const char* address = GetStringUTFChars(env, jaddress); LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address); - env->ReleaseStringUTFChars(jaddress, address); + ReleaseStringUTFChars(env, jaddress, address); if(lf != NULL) { jobject jfriend = getFriend(env,lf); return jfriend; @@ -3759,9 +3765,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatM ,jobject thiz ,jlong ptr ,jstring jmessage) { - const char* message = env->GetStringUTFChars(jmessage, NULL); + const char* message = GetStringUTFChars(env, jmessage); LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message); - env->ReleaseStringUTFChars(jmessage, message); + ReleaseStringUTFChars(env, jmessage, message); return (jlong) chatMessage; } @@ -3774,17 +3780,15 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatM ,jlong time ,jboolean read ,jboolean incoming) { - const char* message = jmessage?env->GetStringUTFChars(jmessage, NULL):NULL; - const char* url = jurl?env->GetStringUTFChars(jurl, NULL):NULL; + const char* message = GetStringUTFChars(env, jmessage); + const char* url = GetStringUTFChars(env, jurl); LinphoneChatMessage *chatMessage = linphone_chat_room_create_message_2( (LinphoneChatRoom *)ptr, message, url, (LinphoneChatMessageState)state, (time_t)time, read, incoming); - if (jmessage != NULL) - env->ReleaseStringUTFChars(jmessage, message); - if (jurl != NULL) - env->ReleaseStringUTFChars(jurl, url); + ReleaseStringUTFChars(env, jmessage, message); + ReleaseStringUTFChars(env, jurl, url); return (jlong) chatMessage; } @@ -3828,14 +3832,14 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createFileTransferM LinphoneChatMessage *message = NULL; const char *tmp; - linphone_content_set_type(content, tmp = env->GetStringUTFChars(jtype, NULL)); - env->ReleaseStringUTFChars(jtype, tmp); + linphone_content_set_type(content, tmp = GetStringUTFChars(env, jtype)); + ReleaseStringUTFChars(env, jtype, tmp); - linphone_content_set_subtype(content, tmp = env->GetStringUTFChars(jsubtype, NULL)); - env->ReleaseStringUTFChars(jsubtype, tmp); + linphone_content_set_subtype(content, tmp = GetStringUTFChars(env, jsubtype)); + ReleaseStringUTFChars(env, jsubtype, tmp); - linphone_content_set_name(content, tmp = env->GetStringUTFChars(jname, NULL)); - env->ReleaseStringUTFChars(jname, tmp); + linphone_content_set_name(content, tmp = GetStringUTFChars(env, jname)); + ReleaseStringUTFChars(env, jname, tmp); linphone_content_set_size(content, data_size); @@ -3865,17 +3869,15 @@ extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getAppData(JNI } extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setAppData(JNIEnv* env, jobject thiz, jlong ptr, jstring appdata) { - const char * data = appdata ? env->GetStringUTFChars(appdata, NULL) : NULL; + const char * data = GetStringUTFChars(env, appdata); linphone_chat_message_set_appdata((LinphoneChatMessage *)ptr, data); - if (appdata) - env->ReleaseStringUTFChars(appdata, data); + ReleaseStringUTFChars(env, appdata, data); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFileTransferServer(JNIEnv* env, jobject thiz, jlong ptr, jstring server_url) { - const char * url = server_url ? env->GetStringUTFChars(server_url, NULL) : NULL; + const char * url = GetStringUTFChars(env, server_url); linphone_core_set_file_transfer_server((LinphoneCore *)ptr, url); - if (server_url) - env->ReleaseStringUTFChars(server_url, url); + ReleaseStringUTFChars(env, server_url, url); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getFileTransferServer(JNIEnv* env, jobject thiz, jlong ptr) { @@ -3917,20 +3919,20 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getErrorInfo(JNI extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getCustomHeader(JNIEnv* env ,jobject thiz ,jlong ptr, jstring jheader_name) { - const char *name=env->GetStringUTFChars(jheader_name,NULL); + const char *name = GetStringUTFChars(env, jheader_name); const char *value=linphone_chat_message_get_custom_header((LinphoneChatMessage*)ptr,name); - env->ReleaseStringUTFChars(jheader_name, name); + ReleaseStringUTFChars(env, jheader_name, name); return value ? env->NewStringUTF(value) : NULL; } extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_addCustomHeader(JNIEnv* env ,jobject thiz ,jlong ptr, jstring jheader_name, jstring jheader_value) { - const char *name=env->GetStringUTFChars(jheader_name,NULL); - const char *value=env->GetStringUTFChars(jheader_value,NULL); + const char *name = GetStringUTFChars(env, jheader_name); + const char *value = GetStringUTFChars(env, jheader_value); linphone_chat_message_add_custom_header((LinphoneChatMessage*)ptr,name,value); - env->ReleaseStringUTFChars(jheader_name, name); - env->ReleaseStringUTFChars(jheader_value, value); + ReleaseStringUTFChars(env, jheader_name, name); + ReleaseStringUTFChars(env, jheader_value, value); } extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env @@ -3943,9 +3945,9 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUr ,jobject thiz ,jlong ptr ,jstring jurl) { - const char* url = env->GetStringUTFChars(jurl, NULL); + const char* url = GetStringUTFChars(env, jurl); linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url); - env->ReleaseStringUTFChars(jurl, url); + ReleaseStringUTFChars(env, jurl, url); } extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env ,jobject thiz @@ -3998,9 +4000,9 @@ extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_getStorageId(JNIE extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setFileTransferFilepath(JNIEnv* env ,jobject thiz ,jlong ptr, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_chat_message_set_file_transfer_filepath((LinphoneChatMessage*)ptr, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_downloadFile(JNIEnv* env @@ -4156,9 +4158,9 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* ,jobject thiz ,jlong ptr ,jstring jmessage) { - const char* message = env->GetStringUTFChars(jmessage, NULL); + const char* message = GetStringUTFChars(env, jmessage); linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message); - env->ReleaseStringUTFChars(jmessage, message); + ReleaseStringUTFChars(env, jmessage, message); } static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) { @@ -4263,10 +4265,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRemoteRingbackTone(JNIEnv *env, jobject thiz, jlong lc, jstring jtone){ - const char* tone = NULL; - if (jtone) tone=env->GetStringUTFChars(jtone, NULL); + const char* tone = GetStringUTFChars(env, jtone); linphone_core_set_remote_ringback_tone((LinphoneCore*)lc,tone); - if (tone) env->ReleaseStringUTFChars(jtone,tone); + ReleaseStringUTFChars(env, jtone,tone); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRemoteRingbackTone(JNIEnv *env, jobject thiz, jlong lc){ @@ -4285,10 +4286,9 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){ - const char* server = NULL; - if (jserver) server=env->GetStringUTFChars(jserver, NULL); + const char* server = GetStringUTFChars(env, jserver); linphone_core_set_stun_server((LinphoneCore*)lc,server); - if (server) env->ReleaseStringUTFChars(jserver,server); + ReleaseStringUTFChars(env, jserver,server); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){ @@ -4355,9 +4355,9 @@ extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setSessionName(JNI ,jobject thiz ,jlong cp ,jstring jname) { - const char *name = jname ? env->GetStringUTFChars(jname,NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); linphone_call_params_set_session_name((LinphoneCallParams*)cp,name); - if (name) env->ReleaseStringUTFChars(jname,name); + ReleaseStringUTFChars(env, jname, name); } extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){ @@ -4390,47 +4390,47 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenc } extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name){ - const char* header_name=env->GetStringUTFChars(jheader_name, NULL); - const char *header_value=linphone_call_params_get_custom_header((LinphoneCallParams*)lcp,header_name); - env->ReleaseStringUTFChars(jheader_name, header_name); + const char* header_name = GetStringUTFChars(env, jheader_name); + const char *header_value = linphone_call_params_get_custom_header((LinphoneCallParams*)lcp,header_name); + ReleaseStringUTFChars(env, jheader_name, header_name); return header_value ? env->NewStringUTF(header_value) : NULL; } extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_addCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name, jstring jheader_value){ - const char* header_name=env->GetStringUTFChars(jheader_name, NULL); - const char* header_value=env->GetStringUTFChars(jheader_value, NULL); + const char* header_name = GetStringUTFChars(env, jheader_name); + const char* header_value = GetStringUTFChars(env, jheader_value); linphone_call_params_add_custom_header((LinphoneCallParams*)lcp,header_name,header_value); - env->ReleaseStringUTFChars(jheader_name, header_name); - env->ReleaseStringUTFChars(jheader_value, header_value); + ReleaseStringUTFChars(env, jheader_name, header_name); + ReleaseStringUTFChars(env, jheader_value, header_value); } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_addCustomSdpAttribute(JNIEnv *env, jobject thiz, jlong ptr, jstring jname, jstring jvalue) { - const char *name = env->GetStringUTFChars(jname, NULL); - const char *value = env->GetStringUTFChars(jvalue, NULL); + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_call_params_add_custom_sdp_attribute((LinphoneCallParams *)ptr, name, value); - env->ReleaseStringUTFChars(jname, name); - env->ReleaseStringUTFChars(jvalue, value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_addCustomSdpMediaAttribute(JNIEnv *env, jobject thiz, jlong ptr, jint jtype, jstring jname, jstring jvalue) { - const char *name = env->GetStringUTFChars(jname, NULL); - const char *value = env->GetStringUTFChars(jvalue, NULL); + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_call_params_add_custom_sdp_media_attribute((LinphoneCallParams *)ptr, (LinphoneStreamType)jtype, name, value); - env->ReleaseStringUTFChars(jname, name); - env->ReleaseStringUTFChars(jvalue, value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_getCustomSdpAttribute(JNIEnv *env, jobject thiz, jlong ptr, jstring jname) { - const char *name = env->GetStringUTFChars(jname, NULL); + const char *name = GetStringUTFChars(env, jname); const char *value = linphone_call_params_get_custom_sdp_attribute((LinphoneCallParams *)ptr, name); - env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); return value ? env->NewStringUTF(value) : NULL; } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_getCustomSdpMediaAttribute(JNIEnv *env, jobject thiz, jlong ptr, jint jtype, jstring jname) { - const char *name = env->GetStringUTFChars(jname, NULL); + const char *name = GetStringUTFChars(env, jname); const char *value = linphone_call_params_get_custom_sdp_media_attribute((LinphoneCallParams *)ptr, (LinphoneStreamType)jtype, name); - env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); return value ? env->NewStringUTF(value) : NULL; } @@ -4444,9 +4444,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_clearCustom extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setRecordFile(JNIEnv *env, jobject thiz, jlong lcp, jstring jrecord_file){ if (jrecord_file){ - const char* record_file=env->GetStringUTFChars(jrecord_file, NULL); + const char* record_file = GetStringUTFChars(env, jrecord_file); linphone_call_params_set_record_file((LinphoneCallParams*)lcp,record_file); - env->ReleaseStringUTFChars(jrecord_file, record_file); + ReleaseStringUTFChars(env, jrecord_file, record_file); }else linphone_call_params_set_record_file((LinphoneCallParams*)lcp,NULL); } @@ -4553,9 +4553,9 @@ extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPreferredFramerate(J } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSizeByName(JNIEnv *env, jobject thiz, jlong lc, jstring jName) { - const char* cName = env->GetStringUTFChars(jName, NULL); + const char* cName = GetStringUTFChars(env, jName); linphone_core_set_preferred_video_size_by_name((LinphoneCore *)lc, cName); - env->ReleaseStringUTFChars(jName, cName); + ReleaseStringUTFChars(env, jName, cName); } extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){ @@ -4662,9 +4662,9 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getQuality JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_setQualityReportingCollector(JNIEnv *env, jobject thiz, jlong ptr, jstring jcollector) { if (jcollector){ - const char *collector=env->GetStringUTFChars(jcollector, NULL); + const char *collector = GetStringUTFChars(env, jcollector); linphone_proxy_config_set_quality_reporting_collector((LinphoneProxyConfig *)ptr, collector); - env->ReleaseStringUTFChars(jcollector,collector); + ReleaseStringUTFChars(env, jcollector, collector); } } @@ -4675,9 +4675,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getQual JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_setRealm(JNIEnv *env, jobject thiz, jlong ptr, jstring jrealm) { if (jrealm){ - const char *realm=env->GetStringUTFChars(jrealm, NULL); + const char *realm = GetStringUTFChars(env, jrealm); linphone_proxy_config_set_realm((LinphoneProxyConfig *)ptr, realm); - env->ReleaseStringUTFChars(jrealm,realm); + ReleaseStringUTFChars(env, jrealm, realm); } } @@ -4688,9 +4688,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getReal JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_isPhoneNumber(JNIEnv *env, jobject thiz, jlong ptr, jstring jusername) { if(jusername){ - const char *username=env->GetStringUTFChars(jusername, NULL); + const char *username = GetStringUTFChars(env, jusername); bool_t res = linphone_proxy_config_is_phone_number((LinphoneProxyConfig *)ptr, username); - env->ReleaseStringUTFChars(jusername,username); + ReleaseStringUTFChars(env, jusername, username); return (jboolean) res; } else { return JNI_FALSE; @@ -4698,17 +4698,17 @@ JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_isPhon } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_setCustomHeader(JNIEnv *env, jobject thiz, jlong prt, jstring jname, jstring jvalue) { - const char *name = jname ? env->GetStringUTFChars(jname, NULL) : NULL; - const char *value = jvalue ? env->GetStringUTFChars(jvalue, NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_proxy_config_set_custom_header((LinphoneProxyConfig*) prt, name, value); - if (jname) env->ReleaseStringUTFChars(jname, name); - if (jvalue) env->ReleaseStringUTFChars(jvalue, value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong ptr, jstring jname) { - const char *name = jname ? env->GetStringUTFChars(jname, NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); const char *value = linphone_proxy_config_get_custom_header((LinphoneProxyConfig *)ptr, name); - if (jname) env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); return value ? env->NewStringUTF(value) : NULL; } @@ -4830,9 +4830,9 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getConference(JNIEnv extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startConferenceRecording(JNIEnv *env,jobject thiz,jlong pCore, jstring jpath){ int err=-1; if (jpath){ - const char *path=env->GetStringUTFChars(jpath, NULL); + const char *path = GetStringUTFChars(env, jpath); err=linphone_core_start_conference_recording((LinphoneCore*)pCore,path); - env->ReleaseStringUTFChars(jpath,path); + ReleaseStringUTFChars(env, jpath, path); } return err; } @@ -4854,9 +4854,9 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,j } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) { - const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL); + const char* cReferTo = GetStringUTFChars(env, jReferTo); jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo); - env->ReleaseStringUTFChars(jReferTo, cReferTo); + ReleaseStringUTFChars(env, jReferTo, cReferTo); return err; } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) { @@ -4869,18 +4869,18 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_startReferedCall(JNIE extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) { if (jFile) { - const char* cFile=env->GetStringUTFChars(jFile, NULL); + const char* cFile =GetStringUTFChars(env, jFile); linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile); - env->ReleaseStringUTFChars(jFile, cFile); + ReleaseStringUTFChars(env, jFile, cFile); } else { linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL); } } extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) { - const char* cUri=env->GetStringUTFChars(jUri, NULL); + const char* cUri = GetStringUTFChars(env, jUri); const LinphoneCall *call=linphone_core_find_call_from_uri((const LinphoneCore *) pCore,cUri); - env->ReleaseStringUTFChars(jUri, cUri); + ReleaseStringUTFChars(env, jUri, cUri); return (jobject) getCall(env,(LinphoneCall*)call); } @@ -5003,14 +5003,14 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; - const char* cHost=env->GetStringUTFChars(jHost, NULL); + const char* cHost = GetStringUTFChars(env, jHost); LinphoneTunnelConfig *tunnelconfig = linphone_tunnel_config_new(); linphone_tunnel_config_set_host(tunnelconfig, cHost); linphone_tunnel_config_set_port(tunnelconfig, port); linphone_tunnel_config_set_delay(tunnelconfig, delay); linphone_tunnel_config_set_remote_udp_mirror_port(tunnelconfig, mirror); linphone_tunnel_add_server(tunnel, tunnelconfig); - env->ReleaseStringUTFChars(jHost, cHost); + ReleaseStringUTFChars(env, jHost, cHost); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServer(JNIEnv *env, jobject thiz, jlong pCore, jlong tunnelconfigptr) { @@ -5053,13 +5053,13 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEn LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; - const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL; - const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL; - const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL; + const char* cHost = GetStringUTFChars(env, jHost); + const char* cUsername = GetStringUTFChars(env, username); + const char* cPassword = GetStringUTFChars(env, password); linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword); - if (cHost) env->ReleaseStringUTFChars(jHost, cHost); - if (cUsername) env->ReleaseStringUTFChars(username, cUsername); - if (cPassword) env->ReleaseStringUTFChars(password, cPassword); + ReleaseStringUTFChars(env, jHost, cHost); + ReleaseStringUTFChars(env, username, cUsername); + ReleaseStringUTFChars(env, password, cPassword); } @@ -5111,11 +5111,11 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_tunnelSipEnabled(JNI } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){ - const char* cname=env->GetStringUTFChars(name, NULL); - const char* cversion=env->GetStringUTFChars(version, NULL); + const char* cname = GetStringUTFChars(env, name); + const char* cversion = GetStringUTFChars(env, version); linphone_core_set_user_agent((LinphoneCore *)pCore,cname,cversion); - env->ReleaseStringUTFChars(name, cname); - env->ReleaseStringUTFChars(version, cversion); + ReleaseStringUTFChars(env, name, cname); + ReleaseStringUTFChars(env, version, cversion); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){ @@ -5140,9 +5140,9 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getVideoAutoAcceptPo } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStaticPicture(JNIEnv *env, jobject thiz, jlong lc, jstring path) { - const char *cpath = env->GetStringUTFChars(path, NULL); + const char *cpath = GetStringUTFChars(env, path); linphone_core_set_static_picture((LinphoneCore *)lc, cpath); - env->ReleaseStringUTFChars(path, cpath); + ReleaseStringUTFChars(env, path, cpath); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jlong coreptr, jint count) { @@ -5275,20 +5275,20 @@ static LinphoneContent *create_content_from_java_args(JNIEnv *env, LinphoneCore void *data = (void*)env->GetByteArrayElements(jdata,NULL); const char *tmp; - linphone_content_set_type(content, tmp = env->GetStringUTFChars(jtype, NULL)); - env->ReleaseStringUTFChars(jtype, tmp); + linphone_content_set_type(content, tmp = GetStringUTFChars(env, jtype)); + ReleaseStringUTFChars(env, jtype, tmp); - linphone_content_set_subtype(content, tmp = env->GetStringUTFChars(jsubtype, NULL)); - env->ReleaseStringUTFChars(jsubtype, tmp); + linphone_content_set_subtype(content, tmp = GetStringUTFChars(env, jsubtype)); + ReleaseStringUTFChars(env, jsubtype, tmp); if (jname){ - linphone_content_set_name(content, tmp = env->GetStringUTFChars(jname, NULL)); - env->ReleaseStringUTFChars(jname, tmp); + linphone_content_set_name(content, tmp = GetStringUTFChars(env, jname)); + ReleaseStringUTFChars(env, jname, tmp); } if (jencoding){ - linphone_content_set_encoding(content, tmp = env->GetStringUTFChars(jencoding,NULL)); - env->ReleaseStringUTFChars(jencoding, tmp); + linphone_content_set_encoding(content, tmp = GetStringUTFChars(env, jencoding)); + ReleaseStringUTFChars(env, jencoding, tmp); } linphone_content_set_buffer(content, data, env->GetArrayLength(jdata)); @@ -5309,12 +5309,12 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_subscribe(JNIE LinphoneContent * content = create_content_from_java_args(env, (LinphoneCore*)coreptr, jtype, jsubtype, jdata, jencoding, NULL); LinphoneEvent *ev; jobject jev=NULL; - const char *evname=env->GetStringUTFChars(jevname,NULL); + const char *evname = GetStringUTFChars(env, jevname); ev=linphone_core_subscribe(lc,addr,evname,expires, content); if (content) linphone_content_unref(content); - env->ReleaseStringUTFChars(jevname,evname); + ReleaseStringUTFChars(env, jevname, evname); if (ev){ jev=getEvent(env,ev); } @@ -5333,11 +5333,11 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_publish(JNIEnv LinphoneContent * content = create_content_from_java_args(env, (LinphoneCore*)coreptr, jtype, jsubtype, jdata, jencoding, NULL); LinphoneEvent *ev; jobject jev=NULL; - const char *evname=env->GetStringUTFChars(jevname,NULL); + const char *evname = GetStringUTFChars(env, jevname); ev=linphone_core_publish(lc,addr,evname,expires, content); if (content) linphone_content_unref(content); - env->ReleaseStringUTFChars(jevname,evname); + ReleaseStringUTFChars(env, jevname, evname); if (ev){ jev=getEvent(env,ev); } @@ -5346,16 +5346,16 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_publish(JNIEnv // LpConfig extern "C" jlong Java_org_linphone_core_LpConfigImpl_newLpConfigImpl(JNIEnv *env, jobject thiz, jstring file) { - const char *cfile = env->GetStringUTFChars(file, NULL); + const char *cfile = GetStringUTFChars(env, file); LpConfig *lp = lp_config_new(cfile); - env->ReleaseStringUTFChars(file, cfile); + ReleaseStringUTFChars(env, file, cfile); return (jlong) lp; } extern "C" jlong Java_org_linphone_core_LpConfigImpl_newLpConfigImplFromBuffer(JNIEnv *env, jobject thiz, jstring buffer) { - const char *cbuffer = env->GetStringUTFChars(buffer, NULL); + const char *cbuffer = GetStringUTFChars(env, buffer); LpConfig *lp = lp_config_new_from_buffer(cbuffer); - env->ReleaseStringUTFChars(buffer, cbuffer); + ReleaseStringUTFChars(env, buffer, cbuffer); return (jlong) lp; } @@ -5371,77 +5371,77 @@ extern "C" void Java_org_linphone_core_LpConfigImpl_delete(JNIEnv *env, jobject extern "C" void Java_org_linphone_core_LpConfigImpl_setInt(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jint value) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); lp_config_set_int((LpConfig *)lpc, csection, ckey, (int) value); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); } extern "C" jint Java_org_linphone_core_LpConfigImpl_getInt(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jint defaultValue) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); int returnValue = lp_config_get_int((LpConfig *)lpc, csection, ckey, (int) defaultValue); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); return (jint) returnValue; } extern "C" void Java_org_linphone_core_LpConfigImpl_setFloat(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jfloat value) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); lp_config_set_float((LpConfig *)lpc, csection, ckey, (float) value); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); } extern "C" jfloat Java_org_linphone_core_LpConfigImpl_getFloat(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jfloat defaultValue) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); float returnValue = lp_config_get_float((LpConfig *)lpc, csection, ckey, (float) defaultValue); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); return (jfloat) returnValue; } extern "C" void Java_org_linphone_core_LpConfigImpl_setBool(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jboolean value) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); lp_config_set_int((LpConfig *)lpc, csection, ckey, value ? 1 : 0); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); } extern "C" jboolean Java_org_linphone_core_LpConfigImpl_getBool(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jboolean defaultValue) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); int returnValue = lp_config_get_int((LpConfig *)lpc, csection, ckey, defaultValue ? 1 : 0); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); return (jboolean) returnValue == 1; } extern "C" void Java_org_linphone_core_LpConfigImpl_setString(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jstring value) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); - const char *cvalue = value ? env->GetStringUTFChars(value, NULL) : NULL; + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); + const char *cvalue = GetStringUTFChars(env, value); lp_config_set_string((LpConfig *)lpc, csection, ckey, cvalue); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); - if (value) env->ReleaseStringUTFChars(value, cvalue); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); + ReleaseStringUTFChars(env, value, cvalue); } extern "C" jstring Java_org_linphone_core_LpConfigImpl_getString(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jstring defaultValue) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); - const char *cvalue = defaultValue ? env->GetStringUTFChars(defaultValue, NULL) : NULL; + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); + const char *cvalue = GetStringUTFChars(env, defaultValue); const char *returnValue = lp_config_get_string((LpConfig *)lpc, csection, ckey, cvalue); @@ -5449,33 +5449,32 @@ extern "C" jstring Java_org_linphone_core_LpConfigImpl_getString(JNIEnv *env, jo if (returnValue) jreturnValue = env->NewStringUTF(returnValue); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); - if (cvalue) - env->ReleaseStringUTFChars(defaultValue, cvalue); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); + ReleaseStringUTFChars(env, defaultValue, cvalue); return jreturnValue; } extern "C" void Java_org_linphone_core_LpConfigImpl_setIntRange(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jint min, jint max) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); lp_config_set_range((LpConfig *)lpc, csection, ckey, min, max); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); } extern "C" jintArray Java_org_linphone_core_LpConfigImpl_getIntRange(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jint defaultmin, jint defaultmax) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); int *values = (int*)calloc(2, sizeof(int)); lp_config_get_range((LpConfig *)lpc, csection, ckey, &values[0], &values[1], defaultmin, defaultmax); jintArray returnValues = env->NewIntArray(2); env->SetIntArrayRegion(returnValues, 0, 2, values); ms_free(values); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); return returnValues; } @@ -5587,15 +5586,14 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_setContent LinphoneContent * content = linphone_content_new(); const char *tmp; - linphone_content_set_type(content, tmp = env->GetStringUTFChars(jtype,NULL)); - env->ReleaseStringUTFChars(jtype, tmp); + linphone_content_set_type(content, tmp = GetStringUTFChars(env, jtype)); + ReleaseStringUTFChars(env, jtype, tmp); - linphone_content_set_type(content, tmp = env->GetStringUTFChars(jsubtype,NULL)); - env->ReleaseStringUTFChars(jsubtype, tmp); + linphone_content_set_type(content, tmp = GetStringUTFChars(env, jsubtype)); + ReleaseStringUTFChars(env, jsubtype, tmp); - - linphone_content_set_string_buffer(content, tmp = env->GetStringUTFChars(jdata,NULL)); - env->ReleaseStringUTFChars(jdata, tmp); + linphone_content_set_string_buffer(content, tmp = GetStringUTFChars(env, jdata)); + ReleaseStringUTFChars(env, jdata, tmp); linphone_info_message_set_content(infomsg, content); linphone_content_unref(content); @@ -5607,12 +5605,11 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_setContent * Signature: (JLjava/lang/String;Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_addHeader(JNIEnv *env, jobject jobj, jlong infoptr, jstring jname, jstring jvalue){ - const char *name=NULL,*value=NULL; - name=env->GetStringUTFChars(jname,NULL); - value=env->GetStringUTFChars(jvalue,NULL); + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_info_message_add_header((LinphoneInfoMessage*)infoptr,name,value); - env->ReleaseStringUTFChars(jname,name); - env->ReleaseStringUTFChars(jvalue,value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } /* @@ -5621,9 +5618,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_addHeader( * Signature: (JLjava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_getHeader(JNIEnv *env, jobject jobj, jlong infoptr, jstring jname){ - const char *name=env->GetStringUTFChars(jname,NULL); + const char *name = GetStringUTFChars(env, jname); const char *ret=linphone_info_message_get_header((LinphoneInfoMessage*)infoptr,name); - env->ReleaseStringUTFChars(jname,name); + ReleaseStringUTFChars(env, jname, name); return ret ? env->NewStringUTF(ret) : NULL; } @@ -5796,10 +5793,10 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createSubscrib LinphoneAddress *addr = (LinphoneAddress*) jaddr; LinphoneEvent *event; jobject jevent = NULL; - const char *event_name = env->GetStringUTFChars(jeventname, NULL); + const char *event_name = GetStringUTFChars(env, jeventname); event = linphone_core_create_subscribe(lc, addr, event_name, expires); - env->ReleaseStringUTFChars(jeventname, event_name); + ReleaseStringUTFChars(env, jeventname, event_name); if (event) { jevent = getEvent(env, event); } @@ -5819,10 +5816,10 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createPublish( LinphoneAddress *addr = (LinphoneAddress*) jaddr; LinphoneEvent *event; jobject jevent = NULL; - const char *event_name = env->GetStringUTFChars(jeventname, NULL); + const char *event_name = GetStringUTFChars(env, jeventname); event = linphone_core_create_publish(lc, addr, event_name, expires); - env->ReleaseStringUTFChars(jeventname, event_name); + ReleaseStringUTFChars(env, jeventname, event_name); if (event) { jevent = getEvent(env, event); } @@ -5837,18 +5834,18 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneEventImpl_sendPublish(JNIE } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneEventImpl_addCustomHeader(JNIEnv *env, jobject thiz, jlong jevent, jstring jname, jstring jvalue) { - const char *name = jname ? env->GetStringUTFChars(jname, NULL) : NULL; - const char *value = jvalue ? env->GetStringUTFChars(jvalue, NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_event_add_custom_header((LinphoneEvent*) jevent, name, value); - if (jname) env->ReleaseStringUTFChars(jname, name); - if (jvalue) env->ReleaseStringUTFChars(jvalue, value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneEventImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong jevent, jstring jname) { - const char *name = jname ? env->GetStringUTFChars(jname, NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); const char *header = linphone_event_get_custom_header((LinphoneEvent*) jevent, name); jstring jheader = header ? env->NewStringUTF(header) : NULL; - if (jname) env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); return jheader; } @@ -5880,10 +5877,10 @@ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceMode */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceModelImpl__ILjava_lang_String_2(JNIEnv *env, jobject jobj, jint type, jstring description) { LinphonePresenceModel *model; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); model = linphone_presence_model_new_with_activity((LinphonePresenceActivityType)type, cdescription); model = linphone_presence_model_ref(model); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + ReleaseStringUTFChars(env, description, cdescription); return (jlong)model; } @@ -5895,14 +5892,14 @@ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceMode JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceModelImpl__ILjava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2( JNIEnv *env, jobject jobj, jint type, jstring description, jstring note, jstring lang) { LinphonePresenceModel *model; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; - const char *cnote = note ? env->GetStringUTFChars(note, NULL) : NULL; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); + const char *cnote =GetStringUTFChars(env, note); + const char *clang = GetStringUTFChars(env, lang); model = linphone_presence_model_new_with_activity_and_note((LinphonePresenceActivityType)type, cdescription, cnote, clang); model = linphone_presence_model_ref(model); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); - if (cnote) env->ReleaseStringUTFChars(note, cnote); - if (clang) env->ReleaseStringUTFChars(lang, clang); + ReleaseStringUTFChars(env, description, cdescription); + ReleaseStringUTFChars(env, note, cnote); + ReleaseStringUTFChars(env, lang, clang); return (jlong)model; } @@ -5967,9 +5964,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceModelImpl_getContact(JN */ JNIEXPORT void JNICALL Java_org_linphone_core_PresenceModelImpl_setContact(JNIEnv *env, jobject jobj, jlong ptr, jstring contact) { LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - const char *ccontact = contact ? env->GetStringUTFChars(contact, NULL) : NULL; + const char *ccontact = GetStringUTFChars(env, contact); linphone_presence_model_set_contact(model, ccontact); - if (ccontact) env->ReleaseStringUTFChars(contact, ccontact); + ReleaseStringUTFChars(env, contact, ccontact); } /* @@ -5991,9 +5988,9 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getActivity(J */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_setActivity(JNIEnv *env, jobject jobj, jlong ptr, jint acttype, jstring description) { LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); jint res = (jint)linphone_presence_model_set_activity(model, (LinphonePresenceActivityType)acttype, cdescription); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + ReleaseStringUTFChars(env, description, cdescription); return res; } @@ -6045,9 +6042,9 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_clearActivities( */ JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getNote(JNIEnv *env , jobject jobj, jlong ptr, jstring lang) { LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *clang = GetStringUTFChars(env, lang); LinphonePresenceNote *note = linphone_presence_model_get_note(model, clang); - if (clang) env->ReleaseStringUTFChars(lang, clang); + ReleaseStringUTFChars(env, lang, clang); if (note == NULL) return NULL; RETURN_USER_DATA_OBJECT("PresenceNoteImpl", linphone_presence_note, note) } @@ -6059,11 +6056,11 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getNote(JNIEn */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_addNote(JNIEnv *env, jobject jobj, jlong ptr, jstring description, jstring lang) { LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); + const char *clang = GetStringUTFChars(env, lang); jint res = (jint)linphone_presence_model_add_note(model, cdescription, clang); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); - if (clang) env->ReleaseStringUTFChars(lang, clang); + ReleaseStringUTFChars(env, description, cdescription); + ReleaseStringUTFChars(env, lang, clang); return res; } @@ -6166,10 +6163,10 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_clearPersons(JNI */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceActivityImpl_newPresenceActivityImpl(JNIEnv *env, jobject jobj, jint type, jstring description) { LinphonePresenceActivity *activity; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); activity = linphone_presence_activity_new((LinphonePresenceActivityType)type, cdescription); activity = linphone_presence_activity_ref(activity); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + ReleaseStringUTFChars(env, description, cdescription); return (jlong)activity; } @@ -6234,9 +6231,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceActivityImpl_getDescrip */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceActivityImpl_setDescription(JNIEnv *env, jobject jobj, jlong ptr, jstring description) { LinphonePresenceActivity *activity = (LinphonePresenceActivity *)ptr; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); linphone_presence_activity_set_description(activity, cdescription); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + ReleaseStringUTFChars(env, description, cdescription); return (jint)0; } @@ -6247,12 +6244,12 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceActivityImpl_setDescriptio */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceServiceImpl_newPresenceServiceImpl(JNIEnv *env, jobject jobj, jstring id, jint basic_status, jstring contact) { LinphonePresenceService *service; - const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL; - const char *ccontact = contact ? env->GetStringUTFChars(contact, NULL) : NULL; + const char *cid = GetStringUTFChars(env, id); + const char *ccontact = GetStringUTFChars(env, contact); service = linphone_presence_service_new(cid, (LinphonePresenceBasicStatus)basic_status, ccontact); service = linphone_presence_service_ref(service); - if (cid) env->ReleaseStringUTFChars(id, cid); - if (ccontact) env->ReleaseStringUTFChars(contact, ccontact); + ReleaseStringUTFChars(env, id, cid); + ReleaseStringUTFChars(env, contact, ccontact); return (jlong)service; } @@ -6286,9 +6283,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceServiceImpl_getId(JNIEn */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_setId(JNIEnv *env, jobject jobj, jlong ptr, jstring id) { LinphonePresenceService *service = (LinphonePresenceService *)ptr; - const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL; + const char *cid = GetStringUTFChars(env, id); linphone_presence_service_set_id(service, cid); - if (cid) env->ReleaseStringUTFChars(id, cid); + ReleaseStringUTFChars(env, id, cid); return (jint)0; } @@ -6332,9 +6329,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceServiceImpl_getContact( */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_setContact(JNIEnv *env, jobject jobj, jlong ptr, jstring contact) { LinphonePresenceService *service = (LinphonePresenceService *)ptr; - const char *ccontact = contact ? env->GetStringUTFChars(contact, NULL) : NULL; + const char *ccontact = GetStringUTFChars(env, contact); linphone_presence_service_set_contact(service, ccontact); - if (ccontact) env->ReleaseStringUTFChars(contact, ccontact); + ReleaseStringUTFChars(env, contact, ccontact); return (jint)0; } @@ -6386,10 +6383,10 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_clearNotes(JNI */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresencePersonImpl_newPresencePersonImpl(JNIEnv *env, jobject jobj, jstring id) { LinphonePresencePerson *person; - const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL; + const char *cid = GetStringUTFChars(env, id); person = linphone_presence_person_new(cid); person = linphone_presence_person_ref(person); - if (cid) env->ReleaseStringUTFChars(id, cid); + ReleaseStringUTFChars(env, id, cid); return (jlong)person; } @@ -6423,9 +6420,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresencePersonImpl_getId(JNIEnv */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_setId(JNIEnv *env, jobject jobj, jlong ptr, jstring id) { LinphonePresencePerson *person = (LinphonePresencePerson *)ptr; - const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL; + const char *cid = GetStringUTFChars(env, id); linphone_presence_person_set_id(person, cid); - if (cid) env->ReleaseStringUTFChars(id, cid); + ReleaseStringUTFChars(env, id, cid); return (jint)0; } @@ -6559,12 +6556,12 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_clearActivitesN */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceNoteImpl_newPresenceNoteImpl(JNIEnv *env, jobject jobj, jstring content, jstring lang) { LinphonePresenceNote *note; - const char *ccontent = content ? env->GetStringUTFChars(content, NULL) : NULL; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *ccontent = GetStringUTFChars(env, content); + const char *clang = GetStringUTFChars(env, lang); note = linphone_presence_note_new(ccontent, clang); note = linphone_presence_note_ref(note); - if (clang) env->ReleaseStringUTFChars(lang, clang); - if (ccontent) env->ReleaseStringUTFChars(content, ccontent); + ReleaseStringUTFChars(env, lang, clang); + ReleaseStringUTFChars(env, content, ccontent); return (jlong)note; } @@ -6596,9 +6593,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceNoteImpl_getContent(JNI */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceNoteImpl_setContent(JNIEnv *env, jobject jobj, jlong ptr, jstring content) { LinphonePresenceNote *note = (LinphonePresenceNote *)ptr; - const char *ccontent = content ? env->GetStringUTFChars(content, NULL) : NULL; + const char *ccontent = GetStringUTFChars(env, content); linphone_presence_note_set_content(note, ccontent); - if (ccontent) env->ReleaseStringUTFChars(content, ccontent); + ReleaseStringUTFChars(env, content, ccontent); return (jint)0; } @@ -6620,9 +6617,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceNoteImpl_getLang(JNIEnv */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceNoteImpl_setLang(JNIEnv *env, jobject jobj, jlong ptr, jstring lang) { LinphonePresenceNote *note = (LinphonePresenceNote *)ptr; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *clang = GetStringUTFChars(env, lang); linphone_presence_note_set_lang(note, clang); - if (clang) env->ReleaseStringUTFChars(lang, clang); + ReleaseStringUTFChars(env, lang, clang); return (jint)0; } @@ -6633,9 +6630,9 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceNoteImpl_setLang(JNIEnv *e */ JNIEXPORT void JNICALL Java_org_linphone_core_PayloadTypeImpl_setRecvFmtp(JNIEnv *env, jobject jobj, jlong ptr, jstring jfmtp){ PayloadType *pt=(PayloadType *)ptr; - const char *fmtp=jfmtp ? env->GetStringUTFChars(jfmtp,NULL) : NULL; + const char *fmtp = GetStringUTFChars(env, jfmtp); payload_type_set_recv_fmtp(pt,fmtp); - if (fmtp) env->ReleaseStringUTFChars(jfmtp,fmtp); + ReleaseStringUTFChars(env, jfmtp, fmtp); } /* @@ -6656,9 +6653,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PayloadTypeImpl_getRecvFmtp(JNI */ JNIEXPORT void JNICALL Java_org_linphone_core_PayloadTypeImpl_setSendFmtp(JNIEnv *env, jobject jobj, jlong ptr , jstring jfmtp){ PayloadType *pt=(PayloadType *)ptr; - const char *fmtp=jfmtp ? env->GetStringUTFChars(jfmtp,NULL) : NULL; + const char *fmtp = GetStringUTFChars(env, jfmtp); payload_type_set_send_fmtp(pt,fmtp); - if (fmtp) env->ReleaseStringUTFChars(jfmtp,fmtp); + ReleaseStringUTFChars(env, jfmtp, fmtp); } /* @@ -6770,14 +6767,17 @@ static void _eof_callback(LinphonePlayer *player, void *user_data) { extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_open(JNIEnv *env, jobject jPlayer, jlong ptr, jstring filename, jobject listener) { LinphonePlayerData *data = NULL; LinphonePlayerEofCallback cb = NULL; + const char *cfilename = GetStringUTFChars(env, filename); if(listener) { data = new LinphonePlayerData(env, listener, jPlayer); cb = _eof_callback; } - if(linphone_player_open((LinphonePlayer *)ptr, env->GetStringUTFChars(filename, NULL), cb, data) == -1) { + if(linphone_player_open((LinphonePlayer *)ptr, cfilename, cb, data) == -1) { if(data) delete data; + ReleaseStringUTFChars(env, filename, cfilename); return -1; } + ReleaseStringUTFChars(env, filename, cfilename); return 0; } @@ -6850,10 +6850,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createLocalPlayer(JNIEn */ extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setAudioMulticastAddr (JNIEnv * env , jobject, jlong ptr, jstring value) { - const char *char_value = value ? env->GetStringUTFChars(value, NULL) : NULL; + const char *char_value = GetStringUTFChars(env, value); LinphoneCore *lc=(LinphoneCore*)ptr; int result = linphone_core_set_audio_multicast_addr(lc,char_value); - if (char_value) env->ReleaseStringUTFChars(value, char_value); + ReleaseStringUTFChars(env, value, char_value); return result; } @@ -6864,10 +6864,10 @@ extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setAudioMulticas */ extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoMulticastAddr (JNIEnv * env, jobject, jlong ptr, jstring value) { - const char *char_value = value ? env->GetStringUTFChars(value, NULL) : NULL; + const char *char_value = GetStringUTFChars(env, value); LinphoneCore *lc=(LinphoneCore*)ptr; int result = linphone_core_set_video_multicast_addr(lc,char_value); - if (char_value) env->ReleaseStringUTFChars(value, char_value); + ReleaseStringUTFChars(env, value, char_value); return result; } @@ -6981,10 +6981,10 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setDnsServers(JNI for (int i=0; i < count; i++) { jstring server = (jstring) env->GetObjectArrayElement(servers, i); - const char *str = env->GetStringUTFChars(server, NULL); + const char *str = GetStringUTFChars(env, server); if (str){ l = ms_list_append(l, ms_strdup(str)); - env->ReleaseStringUTFChars(server, str); + ReleaseStringUTFChars(env, server, str); } } } @@ -7001,9 +7001,9 @@ JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_dnsSrvEnabled } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoPreset(JNIEnv *env, jobject thiz, jlong lc, jstring preset) { - const char *char_preset = preset ? env->GetStringUTFChars(preset, NULL) : NULL; + const char *char_preset = GetStringUTFChars(env, preset); linphone_core_set_video_preset((LinphoneCore *)lc, char_preset); - if (char_preset) env->ReleaseStringUTFChars(preset, char_preset); + ReleaseStringUTFChars(env, preset, char_preset); } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCoreImpl_getVideoPreset(JNIEnv *env, jobject thiz, jlong lc) { @@ -7118,9 +7118,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_TunnelConfigImpl_getHost(JNIEnv */ JNIEXPORT void JNICALL Java_org_linphone_core_TunnelConfigImpl_setHost(JNIEnv *env, jobject obj, jlong ptr, jstring jstr){ LinphoneTunnelConfig *cfg = (LinphoneTunnelConfig *)ptr; - const char* host = jstr ? env->GetStringUTFChars(jstr, NULL) : NULL; + const char* host = GetStringUTFChars(env, jstr); linphone_tunnel_config_set_host(cfg, host); - if (jstr) env->ReleaseStringUTFChars(jstr, host); + ReleaseStringUTFChars(env, jstr, host); } /* @@ -7211,9 +7211,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallLogImpl_getCallId(J * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setHttpProxyHost(JNIEnv *env, jobject jobj, jlong core, jstring jhost){ - const char *host = jhost ? env->GetStringUTFChars(jhost, NULL) : NULL; + const char *host = GetStringUTFChars(env, jhost); linphone_core_set_http_proxy_host((LinphoneCore*)core, host); - if (host) env->ReleaseStringUTFChars(jhost, host); + ReleaseStringUTFChars(env, jhost, host); } /* @@ -7352,13 +7352,13 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setMediaNetworkRe } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setUserCertificatesPath(JNIEnv *env, jobject jobj, jlong pcore, jstring jpath){ - const char *path = jpath ? env->GetStringUTFChars(jpath, NULL) : NULL; + const char *path = GetStringUTFChars(env, jpath); linphone_core_set_user_certificates_path((LinphoneCore*)pcore, path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_reloadMsPlugins(JNIEnv *env, jobject jobj, jlong pcore, jstring jpath) { - const char *path = jpath ? env->GetStringUTFChars(jpath, NULL) : NULL; + const char *path = GetStringUTFChars(env, jpath); linphone_core_reload_ms_plugins((LinphoneCore*)pcore, path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } From 3b22e0f8b99ed2abee85c2bc1675992750cf86c9 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 17 Jun 2016 14:23:10 +0200 Subject: [PATCH 102/124] All calls to GetStringUTFChars and ReleaseStringUTFChars in JNI layer are now protected from NULL values --- coreapi/linphonecore_jni.cc | 736 ++++++++++++++++++------------------ 1 file changed, 368 insertions(+), 368 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 0c5a6fcfc..a96901c52 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -140,6 +140,14 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *ajvm, void *reserved) return JNI_VERSION_1_2; } +static const char* GetStringUTFChars(JNIEnv* env, jstring string) { + const char *cstring = string ? env->GetStringUTFChars(string, NULL) : NULL; + return cstring; +} + +static void ReleaseStringUTFChars(JNIEnv* env, jstring string, const char *cstring) { + if (string) env->ReleaseStringUTFChars(string, cstring); +} //LinphoneFactory extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIEnv* env @@ -147,7 +155,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setDebugMode(JNIE ,jboolean isDebug ,jstring jdebugTag) { if (isDebug) { - LogDomain = env->GetStringUTFChars(jdebugTag, NULL); + LogDomain = GetStringUTFChars(env, jdebugTag); linphone_core_enable_logs_with_cb(linphone_android_ortp_log_handler); } else { linphone_core_disable_logs(); @@ -172,9 +180,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreFactoryImpl_setLogCollectionP ,jobject thiz ,jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_log_collection_path(path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } // LinphoneCore @@ -1338,8 +1346,8 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* ,jstring jfactoryConfig ,jobject juserdata){ - const char* userConfig = juserConfig?env->GetStringUTFChars(juserConfig, NULL):NULL; - const char* factoryConfig = jfactoryConfig?env->GetStringUTFChars(jfactoryConfig, NULL):NULL; + const char* userConfig = GetStringUTFChars(env, juserConfig); + const char* factoryConfig = GetStringUTFChars(env, jfactoryConfig); LinphoneJavaBindings *ljb = new LinphoneJavaBindings(env); @@ -1353,8 +1361,8 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* LinphoneCore *lc = linphone_core_new(vTable, userConfig, factoryConfig, ljb); jlong nativePtr = (jlong)lc; - if (userConfig) env->ReleaseStringUTFChars(juserConfig, userConfig); - if (factoryConfig) env->ReleaseStringUTFChars(jfactoryConfig, factoryConfig); + ReleaseStringUTFChars(env, juserConfig, userConfig); + ReleaseStringUTFChars(env, jfactoryConfig, factoryConfig); return nativePtr; } @@ -1444,26 +1452,26 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_stopRinging(JNIEnv* env, } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setChatDatabasePath(JNIEnv* env, jobject thiz, jlong lc, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_chat_database_path((LinphoneCore*)lc, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCallLogsDatabasePath( JNIEnv* env, jobject thiz, jlong lc, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_call_logs_database_path((LinphoneCore*)lc, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFriendsDatabasePath( JNIEnv* env, jobject thiz, jlong lc, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_friends_database_path((LinphoneCore*)lc, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact2(JNIEnv* env, jobject thiz, jlong lc, jstring jcontact) { - const char* contact = env->GetStringUTFChars(jcontact, NULL); + const char* contact = GetStringUTFChars(env, jcontact); linphone_core_set_primary_contact((LinphoneCore*)lc, contact); - env->ReleaseStringUTFChars(jcontact, contact); + ReleaseStringUTFChars(env, jcontact, contact); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getPrimaryContact(JNIEnv* env, jobject thiz, jlong lc) { @@ -1473,8 +1481,8 @@ extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getPrimaryContact(JNI extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv* env, jobject thiz, jlong lc, jstring jdisplayname, jstring jusername) { - const char* displayname = jdisplayname ? env->GetStringUTFChars(jdisplayname, NULL) : NULL; - const char* username = jusername ? env->GetStringUTFChars(jusername, NULL) : NULL; + const char* displayname = GetStringUTFChars(env, jdisplayname); + const char* username = GetStringUTFChars(env, jusername); LinphoneAddress *parsed = linphone_core_get_primary_contact_parsed((LinphoneCore*)lc); if (parsed != NULL) { @@ -1484,8 +1492,8 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv linphone_core_set_primary_contact((LinphoneCore*)lc, contact); } - if (jdisplayname) env->ReleaseStringUTFChars(jdisplayname, displayname); - if (jusername) env->ReleaseStringUTFChars(jusername, username); + ReleaseStringUTFChars(env, jdisplayname, displayname); + ReleaseStringUTFChars(env, jusername, username); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getPrimaryContactUsername(JNIEnv* env, jobject thiz, jlong lc) { @@ -1575,16 +1583,14 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getAuthInfosList(J } extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findAuthInfos(JNIEnv* env, jobject thiz, jlong lc, jstring jusername, jstring jrealm, jstring jdomain) { - const char* username = env->GetStringUTFChars(jusername, NULL); - const char* realm = jrealm ? env->GetStringUTFChars(jrealm, NULL) : NULL; - const char* domain = jdomain ? env->GetStringUTFChars(jdomain, NULL) : NULL; + const char* username = GetStringUTFChars(env, jusername); + const char* realm = GetStringUTFChars(env, jrealm); + const char* domain = GetStringUTFChars(env, jdomain); const LinphoneAuthInfo *authInfo = linphone_core_find_auth_info((LinphoneCore*)lc, realm, username, domain); - if (realm) - env->ReleaseStringUTFChars(jrealm, realm); - if (domain) - env->ReleaseStringUTFChars(jdomain, domain); - env->ReleaseStringUTFChars(jusername, username); + ReleaseStringUTFChars(env, jrealm, realm); + ReleaseStringUTFChars(env, jdomain, domain); + ReleaseStringUTFChars(env, jusername, username); return (jlong) authInfo; } @@ -1612,9 +1618,9 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_invite(JNIEnv* env ,jobject thiz ,jlong lc ,jstring juri) { - const char* uri = env->GetStringUTFChars(juri, NULL); + const char* uri = GetStringUTFChars(env, juri); LinphoneCall* lCall = linphone_core_invite((LinphoneCore*)lc,uri); - env->ReleaseStringUTFChars(juri, uri); + ReleaseStringUTFChars(env, juri, uri); return getCall(env,lCall); } extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_inviteAddress(JNIEnv* env @@ -1797,9 +1803,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_interpretUrl( JNIEnv* ,jobject thiz ,jlong lc ,jstring jurl) { - const char* url = env->GetStringUTFChars(jurl, NULL); + const char* url = GetStringUTFChars(env, jurl); jlong result = (jlong)linphone_core_interpret_url((LinphoneCore*)lc,url); - env->ReleaseStringUTFChars(jurl, url); + ReleaseStringUTFChars(env, jurl, url); return result; } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_sendDtmf( JNIEnv* env @@ -1855,9 +1861,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_findPayloadType(JNIEnv* ,jstring jmime ,jint rate ,jint channels) { - const char* mime = env->GetStringUTFChars(jmime, NULL); + const char* mime = GetStringUTFChars(env, jmime); jlong result = (jlong)linphone_core_find_payload_type((LinphoneCore*)lc,mime,rate,channels); - env->ReleaseStringUTFChars(jmime, mime); + ReleaseStringUTFChars(env, jmime, mime); return result; } @@ -2001,9 +2007,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setAdaptiveRateAlgorithm ,jobject thiz ,jlong lc ,jstring jalg) { - const char* alg = jalg?env->GetStringUTFChars(jalg, NULL):NULL; + const char* alg = GetStringUTFChars(env, jalg); linphone_core_set_adaptive_rate_algorithm((LinphoneCore*)lc,alg); - if (alg) env->ReleaseStringUTFChars(jalg, alg); + ReleaseStringUTFChars(env, jalg, alg); } @@ -2050,23 +2056,23 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addFriend(JNIEnv* env } extern "C" jint Java_org_linphone_core_LinphoneFriendListImpl_importFriendsFromVCardFile(JNIEnv* env, jobject thiz, jlong list, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); int count = linphone_friend_list_import_friends_from_vcard4_file((LinphoneFriendList*)list, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); return count; } extern "C" jint Java_org_linphone_core_LinphoneFriendListImpl_importFriendsFromVCardBuffer(JNIEnv* env, jobject thiz, jlong list, jstring jbuffer) { - const char* buffer = env->GetStringUTFChars(jbuffer, NULL); + const char* buffer = GetStringUTFChars(env, jbuffer); int count = linphone_friend_list_import_friends_from_vcard4_buffer((LinphoneFriendList*)list, buffer); - env->ReleaseStringUTFChars(jbuffer, buffer); + ReleaseStringUTFChars(env, jbuffer, buffer); return count; } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_exportFriendsToVCardFile(JNIEnv* env, jobject thiz, jlong list, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_friend_list_export_friends_as_vcard4_file((LinphoneFriendList*)list, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_enableSubscriptions(JNIEnv* env, jobject thiz, jlong list, jboolean enable) { @@ -2144,9 +2150,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPresenceInfo(JNIEnv* ,jint minutes_away ,jstring jalternative_contact ,jint status) { - const char* alternative_contact = jalternative_contact?env->GetStringUTFChars(jalternative_contact, NULL):NULL; + const char* alternative_contact = GetStringUTFChars(env, jalternative_contact); linphone_core_set_presence_info((LinphoneCore*)lc,minutes_away,alternative_contact,(LinphoneOnlineStatus)status); - if (alternative_contact) env->ReleaseStringUTFChars(jalternative_contact, alternative_contact); + ReleaseStringUTFChars(env, jalternative_contact, alternative_contact); } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getPresenceInfo(JNIEnv *env, jobject thiz, jlong lc) { return (jint)linphone_core_get_presence_info((LinphoneCore *)lc); @@ -2180,9 +2186,9 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getOrCreateChatRoom(J ,jlong lc ,jstring jto) { - const char* to = env->GetStringUTFChars(jto, NULL); + const char* to = GetStringUTFChars(env, jto); LinphoneChatRoom* lResult = linphone_core_get_chat_room_from_uri((LinphoneCore*)lc,to); - env->ReleaseStringUTFChars(jto, to); + ReleaseStringUTFChars(env, jto, to); return getChatRoom(env, lResult); } @@ -2219,17 +2225,17 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlayFile(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_play_file((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRing(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_ring((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRing(JNIEnv* env ,jobject thiz @@ -2247,9 +2253,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setTone(JNIEnv* env ,jlong lc ,jint toneid ,jstring jpath) { - const char* path = jpath ? env->GetStringUTFChars(jpath, NULL) : NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_tone((LinphoneCore *)lc, (LinphoneToneID)toneid, path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCallErrorTone(JNIEnv* env @@ -2257,25 +2263,25 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCallErrorTone(JNIEnv* ,jlong lc ,jint reason ,jstring jpath) { - const char* path = jpath ? env->GetStringUTFChars(jpath, NULL) : NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_call_error_tone((LinphoneCore *)lc, (LinphoneReason)reason, path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRootCA(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_root_ca((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRingback(JNIEnv* env ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_ringback((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } @@ -2283,9 +2289,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setProvisioningUri(JNIEn ,jobject thiz ,jlong lc ,jstring jpath) { - const char* path = jpath?env->GetStringUTFChars(jpath, NULL):NULL; + const char* path = GetStringUTFChars(env, jpath); linphone_core_set_provisioning_uri((LinphoneCore*)lc,path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getProvisioningUri(JNIEnv* env @@ -2453,9 +2459,9 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_finalize(JNIEnv* } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jidentity) { - const char* identity = env->GetStringUTFChars(jidentity, NULL); + const char* identity = GetStringUTFChars(env, jidentity); linphone_proxy_config_set_identity((LinphoneProxyConfig*)proxyCfg,identity); - env->ReleaseStringUTFChars(jidentity, identity); + ReleaseStringUTFChars(env, jidentity, identity); } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getIdentity(JNIEnv* env,jobject thiz,jlong proxyCfg) { const char* identity = linphone_proxy_config_get_identity((LinphoneProxyConfig*)proxyCfg); @@ -2472,9 +2478,9 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setAddress(JNIEnv linphone_proxy_config_set_identity_address((LinphoneProxyConfig*)proxyCfg, (LinphoneAddress*) jidentity); } extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setProxy(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jproxy) { - const char* proxy = env->GetStringUTFChars(jproxy, NULL); + const char* proxy = GetStringUTFChars(env, jproxy); jint err=linphone_proxy_config_set_server_addr((LinphoneProxyConfig*)proxyCfg,proxy); - env->ReleaseStringUTFChars(jproxy, proxy); + ReleaseStringUTFChars(env, jproxy, proxy); return err; } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEnv* env,jobject thiz,jlong proxyCfg) { @@ -2486,14 +2492,14 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getProxy(JNIEn } } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) { - const char* params = jparams ? env->GetStringUTFChars(jparams, NULL) : NULL; + const char* params = GetStringUTFChars(env, jparams); linphone_proxy_config_set_contact_parameters((LinphoneProxyConfig*)proxyCfg, params); - if (jparams) env->ReleaseStringUTFChars(jparams, params); + ReleaseStringUTFChars(env, jparams, params); } extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setContactUriParameters(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jparams) { - const char* params = jparams ? env->GetStringUTFChars(jparams, NULL) : NULL; + const char* params = GetStringUTFChars(env, jparams); linphone_proxy_config_set_contact_uri_parameters((LinphoneProxyConfig*)proxyCfg, params); - if (jparams) env->ReleaseStringUTFChars(jparams, params); + ReleaseStringUTFChars(env, jparams, params); } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getContactParameters(JNIEnv* env,jobject thiz,jlong proxyCfg) { const char* params = linphone_proxy_config_get_contact_parameters((LinphoneProxyConfig*)proxyCfg); @@ -2507,9 +2513,9 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getContactUriP extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_setRoute(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jroute) { if (jroute != NULL) { - const char* route = env->GetStringUTFChars(jroute, NULL); + const char* route = GetStringUTFChars(env, jroute); jint err=linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,route); - env->ReleaseStringUTFChars(jroute, route); + ReleaseStringUTFChars(env, jroute, route); return err; } else { return (jint)linphone_proxy_config_set_route((LinphoneProxyConfig*)proxyCfg,NULL); @@ -2545,7 +2551,7 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhone ms_error("cannot normalized null number"); } char * normalized_phone; - const char* number = env->GetStringUTFChars(jnumber, NULL); + const char* number = GetStringUTFChars(env, jnumber); int len = env->GetStringLength(jnumber); if (len == 0) { ms_warning("cannot normalize empty number"); @@ -2553,26 +2559,26 @@ extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_normalizePhone } normalized_phone = linphone_proxy_config_normalize_phone_number((LinphoneProxyConfig*)proxyCfg,number); jstring normalizedNumber = env->NewStringUTF(normalized_phone ? normalized_phone : number); - env->ReleaseStringUTFChars(jnumber, number); + ReleaseStringUTFChars(env, jnumber, number); ms_free(normalized_phone); return normalizedNumber; } extern "C" jlong Java_org_linphone_core_LinphoneProxyConfigImpl_normalizeSipUri(JNIEnv* env,jobject thiz,jlong proxyCfg,jstring jusername) { - const char* username = env->GetStringUTFChars(jusername, NULL); + const char* username = GetStringUTFChars(env, jusername); LinphoneAddress *addr = linphone_proxy_config_normalize_sip_uri((LinphoneProxyConfig*)proxyCfg, username); - env->ReleaseStringUTFChars(jusername, username); + ReleaseStringUTFChars(env, jusername, username); return (jlong) addr; } extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromIso(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring jiso) { - const char* iso = env->GetStringUTFChars(jiso, NULL); + const char* iso = GetStringUTFChars(env, jiso); int prefix = linphone_dial_plan_lookup_ccc_from_iso(iso); - env->ReleaseStringUTFChars(jiso, iso); + ReleaseStringUTFChars(env, jiso, iso); return (jint) prefix; } extern "C" jint Java_org_linphone_core_LinphoneProxyConfigImpl_lookupCCCFromE164(JNIEnv* env, jobject thiz, jlong proxyCfg, jstring je164) { - const char* e164 = env->GetStringUTFChars(je164, NULL); + const char* e164 = GetStringUTFChars(env, je164); int prefix = linphone_dial_plan_lookup_ccc_from_e164(e164); - env->ReleaseStringUTFChars(je164, e164); + ReleaseStringUTFChars(env, je164, e164); return (jint) prefix; } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDomain(JNIEnv* env @@ -2598,9 +2604,9 @@ extern "C" void Java_org_linphone_core_LinphoneProxyConfigImpl_setDialPrefix(JNI ,jobject thiz ,jlong proxyCfg ,jstring jprefix) { - const char* prefix = env->GetStringUTFChars(jprefix, NULL); + const char* prefix = GetStringUTFChars(env, jprefix); linphone_proxy_config_set_dial_prefix((LinphoneProxyConfig*)proxyCfg,prefix); - env->ReleaseStringUTFChars(jprefix, prefix); + ReleaseStringUTFChars(env, jprefix, prefix); } extern "C" jstring Java_org_linphone_core_LinphoneProxyConfigImpl_getDialPrefix(JNIEnv* env,jobject thiz,jlong proxyCfg) { @@ -2712,9 +2718,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getUsernam */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setPassword (JNIEnv *env, jobject, jlong auth_info, jstring jpassword) { - const char* password = jpassword?env->GetStringUTFChars(jpassword, NULL):NULL; + const char* password = GetStringUTFChars(env, jpassword); linphone_auth_info_set_passwd((LinphoneAuthInfo*)auth_info,password); - if (password) env->ReleaseStringUTFChars(jpassword, password); + ReleaseStringUTFChars(env, jpassword, password); } /* @@ -2724,9 +2730,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setPassword */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setRealm (JNIEnv *env, jobject, jlong auth_info, jstring jrealm) { - const char* realm = jrealm?env->GetStringUTFChars(jrealm, NULL):NULL; + const char* realm = GetStringUTFChars(env, jrealm); linphone_auth_info_set_realm((LinphoneAuthInfo*)auth_info,realm); - if (realm) env->ReleaseStringUTFChars(jrealm, realm); + ReleaseStringUTFChars(env, jrealm, realm); } /* @@ -2736,10 +2742,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setRealm */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setDomain (JNIEnv *env, jobject, jlong auth_info, jstring jdomain) { - const char* domain = jdomain ? env->GetStringUTFChars(jdomain, NULL) : NULL; + const char* domain = GetStringUTFChars(env, jdomain); linphone_auth_info_set_domain((LinphoneAuthInfo*)auth_info, domain); - if (domain) - env->ReleaseStringUTFChars(jdomain, domain); + ReleaseStringUTFChars(env, jdomain, domain); } /* @@ -2749,9 +2754,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setDomain */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUsername (JNIEnv *env, jobject, jlong auth_info, jstring jusername) { - const char* username = jusername?env->GetStringUTFChars(jusername, NULL):NULL; + const char* username = GetStringUTFChars(env, jusername); linphone_auth_info_set_username((LinphoneAuthInfo*)auth_info,username); - if (username) env->ReleaseStringUTFChars(jusername, username); + ReleaseStringUTFChars(env, jusername, username); } /* @@ -2761,9 +2766,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUsername */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setUserId (JNIEnv *env, jobject, jlong auth_info, jstring juserid) { - const char* userid = juserid?env->GetStringUTFChars(juserid, NULL):NULL; + const char* userid = GetStringUTFChars(env, juserid); linphone_auth_info_set_userid((LinphoneAuthInfo*)auth_info,userid); - if (userid) env->ReleaseStringUTFChars(juserid, userid); + ReleaseStringUTFChars(env, juserid, userid); } /* @@ -2788,9 +2793,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_getUserId */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneAuthInfoImpl_setHa1 (JNIEnv *env, jobject, jlong auth_info, jstring jha1) { - const char* ha1 = jha1?env->GetStringUTFChars(jha1, NULL):NULL; + const char* ha1 = GetStringUTFChars(env, jha1); linphone_auth_info_set_ha1((LinphoneAuthInfo*)auth_info,ha1); - if (ha1) env->ReleaseStringUTFChars(jha1, ha1); + ReleaseStringUTFChars(env, jha1, ha1); } @@ -2816,14 +2821,14 @@ extern "C" jlong Java_org_linphone_core_LinphoneAddressImpl_newLinphoneAddressIm ,jobject thiz ,jstring juri ,jstring jdisplayName) { - const char* uri = juri?env->GetStringUTFChars(juri, NULL):NULL; + const char* uri = GetStringUTFChars(env, juri); LinphoneAddress* address = linphone_address_new(uri); if (jdisplayName && address) { - const char* displayName = env->GetStringUTFChars(jdisplayName, NULL); + const char* displayName = GetStringUTFChars(env, jdisplayName); linphone_address_set_display_name(address,displayName); - env->ReleaseStringUTFChars(jdisplayName, displayName); + ReleaseStringUTFChars(env, jdisplayName, displayName); } - if (uri) env->ReleaseStringUTFChars(juri, uri); + ReleaseStringUTFChars(env, juri, uri); return (jlong) address; } @@ -2908,25 +2913,25 @@ extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDisplayName(JNIEnv ,jobject thiz ,jlong address ,jstring jdisplayName) { - const char* displayName = jdisplayName!= NULL?env->GetStringUTFChars(jdisplayName, NULL):NULL; + const char* displayName = GetStringUTFChars(env, jdisplayName); linphone_address_set_display_name((LinphoneAddress*)address,displayName); - if (displayName != NULL) env->ReleaseStringUTFChars(jdisplayName, displayName); + ReleaseStringUTFChars(env, jdisplayName, displayName); } extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setUserName(JNIEnv* env ,jobject thiz ,jlong address ,jstring juserName) { - const char* userName = juserName!= NULL?env->GetStringUTFChars(juserName, NULL):NULL; + const char* userName = GetStringUTFChars(env, juserName); linphone_address_set_username((LinphoneAddress*)address,userName); - if (userName != NULL) env->ReleaseStringUTFChars(juserName, userName); + ReleaseStringUTFChars(env, juserName, userName); } extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setDomain(JNIEnv* env ,jobject thiz ,jlong address ,jstring jdomain) { - const char* domain = jdomain!= NULL?env->GetStringUTFChars(jdomain, NULL):NULL; + const char* domain = GetStringUTFChars(env, jdomain); linphone_address_set_domain((LinphoneAddress*)address,domain); - if (domain != NULL) env->ReleaseStringUTFChars(jdomain, domain); + ReleaseStringUTFChars(env, jdomain, domain); } extern "C" void Java_org_linphone_core_LinphoneAddressImpl_setTransport(JNIEnv* env ,jobject thiz @@ -3099,8 +3104,9 @@ extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getCallLogs(JNIEnv extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env ,jobject thiz ,jlong ptr, jstring path) { - const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL; + const char* filePath = GetStringUTFChars(env, path); linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath); + ReleaseStringUTFChars(env, path, filePath); } extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env @@ -3246,10 +3252,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneFriendImpl_newLinphoneFriend(JNI LinphoneFriend* lResult; if (jFriendUri) { - const char* friendUri = env->GetStringUTFChars(jFriendUri, NULL); + const char* friendUri = GetStringUTFChars(env, jFriendUri); lResult = linphone_friend_new_with_address(friendUri); linphone_friend_set_user_data(lResult,env->NewWeakGlobalRef(thiz)); - env->ReleaseStringUTFChars(jFriendUri, friendUri); + ReleaseStringUTFChars(env, jFriendUri, friendUri); } else { lResult = linphone_friend_new(); linphone_friend_set_user_data(lResult,env->NewWeakGlobalRef(thiz)); @@ -3265,9 +3271,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneFriendListImpl_newLinphoneFriend } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_setUri(JNIEnv* env, jobject thiz, jlong list, jstring juri) { - const char* uri = env->GetStringUTFChars(juri, NULL); + const char* uri = GetStringUTFChars(env, juri); linphone_friend_list_set_uri((LinphoneFriendList*)list, uri); - env->ReleaseStringUTFChars(juri, uri); + ReleaseStringUTFChars(env, juri, uri); } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_synchronizeFriendsFromServer(JNIEnv* env, jobject thiz, jlong list) { @@ -3401,28 +3407,28 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setName(JNIEnv* env ,jobject thiz ,jlong ptr ,jstring jname) { - const char* name = env->GetStringUTFChars(jname, NULL); + const char* name = GetStringUTFChars(env, jname); linphone_friend_set_name((LinphoneFriend*)ptr, name); - env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); } extern "C" void Java_org_linphone_core_LinphoneFriendListImpl_setRLSUri(JNIEnv* env ,jobject thiz ,jlong ptr ,jstring jrlsUri) { - const char* uri = env->GetStringUTFChars(jrlsUri, NULL); + const char* uri = GetStringUTFChars(env, jrlsUri); linphone_friend_list_set_rls_uri((LinphoneFriendList*)ptr, uri); - env->ReleaseStringUTFChars(jrlsUri, uri); + ReleaseStringUTFChars(env, jrlsUri, uri); } extern "C" jobject Java_org_linphone_core_LinphoneFriendListImpl_findFriendByUri(JNIEnv* env ,jobject thiz ,jlong friendListptr ,jstring juri) { - const char* uri = env->GetStringUTFChars(juri, NULL); + const char* uri = GetStringUTFChars(env, juri); LinphoneFriend* lFriend; lFriend = linphone_friend_list_find_friend_by_uri((LinphoneFriendList*)friendListptr, uri); - env->ReleaseStringUTFChars(juri, uri); + ReleaseStringUTFChars(env, juri, uri); if(lFriend != NULL) { jobject jfriend = getFriend(env,lFriend); // don't release local ref since it will be handled above by java @@ -3526,9 +3532,9 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_addPhoneNumber(JNIEnv* ,jlong ptr ,jstring jphone) { if (jphone) { - const char* phone = env->GetStringUTFChars(jphone, NULL); + const char* phone = GetStringUTFChars(env, jphone); linphone_friend_add_phone_number((LinphoneFriend*)ptr, phone); - env->ReleaseStringUTFChars(jphone, phone); + ReleaseStringUTFChars(env, jphone, phone); } } @@ -3537,9 +3543,9 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_removePhoneNumber(JNIE ,jlong ptr ,jstring jphone) { if (jphone) { - const char* phone = env->GetStringUTFChars(jphone, NULL); + const char* phone = GetStringUTFChars(env, jphone); linphone_friend_remove_phone_number((LinphoneFriend*)ptr, phone); - env->ReleaseStringUTFChars(jphone, phone); + ReleaseStringUTFChars(env, jphone, phone); } } @@ -3575,9 +3581,9 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setOrganization(JNIEnv LinphoneFriend *lf = (LinphoneFriend *)ptr; LinphoneVcard *lvc = linphone_friend_get_vcard(lf); if (lvc) { - const char* org = env->GetStringUTFChars(jorg, NULL); + const char* org = GetStringUTFChars(env, jorg); linphone_vcard_set_organization(lvc, org); - env->ReleaseStringUTFChars(jorg, org); + ReleaseStringUTFChars(env, jorg, org); } } @@ -3635,9 +3641,9 @@ extern "C" void Java_org_linphone_core_LinphoneFriendImpl_setRefKey(JNIEnv* env ,jobject thiz ,jlong ptr ,jstring jkey) { - const char* key = env->GetStringUTFChars(jkey, NULL); + const char* key = GetStringUTFChars(env, jkey); linphone_friend_set_ref_key((LinphoneFriend*)ptr,key); - env->ReleaseStringUTFChars(jkey, key); + ReleaseStringUTFChars(env, jkey, key); } extern "C" jstring Java_org_linphone_core_LinphoneFriendImpl_getRefKey(JNIEnv* env ,jobject thiz @@ -3701,9 +3707,9 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getFriendByAddress(JN ,jobject thiz ,jlong ptr ,jstring jaddress) { - const char* address = env->GetStringUTFChars(jaddress, NULL); + const char* address = GetStringUTFChars(env, jaddress); LinphoneFriend *lf = linphone_core_get_friend_by_address((LinphoneCore*)ptr, address); - env->ReleaseStringUTFChars(jaddress, address); + ReleaseStringUTFChars(env, jaddress, address); if(lf != NULL) { jobject jfriend = getFriend(env,lf); return jfriend; @@ -3759,9 +3765,9 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatM ,jobject thiz ,jlong ptr ,jstring jmessage) { - const char* message = env->GetStringUTFChars(jmessage, NULL); + const char* message = GetStringUTFChars(env, jmessage); LinphoneChatMessage *chatMessage = linphone_chat_room_create_message((LinphoneChatRoom *)ptr, message); - env->ReleaseStringUTFChars(jmessage, message); + ReleaseStringUTFChars(env, jmessage, message); return (jlong) chatMessage; } @@ -3774,17 +3780,15 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createLinphoneChatM ,jlong time ,jboolean read ,jboolean incoming) { - const char* message = jmessage?env->GetStringUTFChars(jmessage, NULL):NULL; - const char* url = jurl?env->GetStringUTFChars(jurl, NULL):NULL; + const char* message = GetStringUTFChars(env, jmessage); + const char* url = GetStringUTFChars(env, jurl); LinphoneChatMessage *chatMessage = linphone_chat_room_create_message_2( (LinphoneChatRoom *)ptr, message, url, (LinphoneChatMessageState)state, (time_t)time, read, incoming); - if (jmessage != NULL) - env->ReleaseStringUTFChars(jmessage, message); - if (jurl != NULL) - env->ReleaseStringUTFChars(jurl, url); + ReleaseStringUTFChars(env, jmessage, message); + ReleaseStringUTFChars(env, jurl, url); return (jlong) chatMessage; } @@ -3828,14 +3832,14 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatRoomImpl_createFileTransferM LinphoneChatMessage *message = NULL; const char *tmp; - linphone_content_set_type(content, tmp = env->GetStringUTFChars(jtype, NULL)); - env->ReleaseStringUTFChars(jtype, tmp); + linphone_content_set_type(content, tmp = GetStringUTFChars(env, jtype)); + ReleaseStringUTFChars(env, jtype, tmp); - linphone_content_set_subtype(content, tmp = env->GetStringUTFChars(jsubtype, NULL)); - env->ReleaseStringUTFChars(jsubtype, tmp); + linphone_content_set_subtype(content, tmp = GetStringUTFChars(env, jsubtype)); + ReleaseStringUTFChars(env, jsubtype, tmp); - linphone_content_set_name(content, tmp = env->GetStringUTFChars(jname, NULL)); - env->ReleaseStringUTFChars(jname, tmp); + linphone_content_set_name(content, tmp = GetStringUTFChars(env, jname)); + ReleaseStringUTFChars(env, jname, tmp); linphone_content_set_size(content, data_size); @@ -3865,17 +3869,15 @@ extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getAppData(JNI } extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setAppData(JNIEnv* env, jobject thiz, jlong ptr, jstring appdata) { - const char * data = appdata ? env->GetStringUTFChars(appdata, NULL) : NULL; + const char * data = GetStringUTFChars(env, appdata); linphone_chat_message_set_appdata((LinphoneChatMessage *)ptr, data); - if (appdata) - env->ReleaseStringUTFChars(appdata, data); + ReleaseStringUTFChars(env, appdata, data); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setFileTransferServer(JNIEnv* env, jobject thiz, jlong ptr, jstring server_url) { - const char * url = server_url ? env->GetStringUTFChars(server_url, NULL) : NULL; + const char * url = GetStringUTFChars(env, server_url); linphone_core_set_file_transfer_server((LinphoneCore *)ptr, url); - if (server_url) - env->ReleaseStringUTFChars(server_url, url); + ReleaseStringUTFChars(env, server_url, url); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getFileTransferServer(JNIEnv* env, jobject thiz, jlong ptr) { @@ -3917,20 +3919,20 @@ extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getErrorInfo(JNI extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getCustomHeader(JNIEnv* env ,jobject thiz ,jlong ptr, jstring jheader_name) { - const char *name=env->GetStringUTFChars(jheader_name,NULL); + const char *name = GetStringUTFChars(env, jheader_name); const char *value=linphone_chat_message_get_custom_header((LinphoneChatMessage*)ptr,name); - env->ReleaseStringUTFChars(jheader_name, name); + ReleaseStringUTFChars(env, jheader_name, name); return value ? env->NewStringUTF(value) : NULL; } extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_addCustomHeader(JNIEnv* env ,jobject thiz ,jlong ptr, jstring jheader_name, jstring jheader_value) { - const char *name=env->GetStringUTFChars(jheader_name,NULL); - const char *value=env->GetStringUTFChars(jheader_value,NULL); + const char *name = GetStringUTFChars(env, jheader_name); + const char *value = GetStringUTFChars(env, jheader_value); linphone_chat_message_add_custom_header((LinphoneChatMessage*)ptr,name,value); - env->ReleaseStringUTFChars(jheader_name, name); - env->ReleaseStringUTFChars(jheader_value, value); + ReleaseStringUTFChars(env, jheader_name, name); + ReleaseStringUTFChars(env, jheader_value, value); } extern "C" jstring Java_org_linphone_core_LinphoneChatMessageImpl_getExternalBodyUrl(JNIEnv* env @@ -3943,9 +3945,9 @@ extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setExternalBodyUr ,jobject thiz ,jlong ptr ,jstring jurl) { - const char* url = env->GetStringUTFChars(jurl, NULL); + const char* url = GetStringUTFChars(env, jurl); linphone_chat_message_set_external_body_url((LinphoneChatMessage *)ptr, url); - env->ReleaseStringUTFChars(jurl, url); + ReleaseStringUTFChars(env, jurl, url); } extern "C" jlong Java_org_linphone_core_LinphoneChatMessageImpl_getFrom(JNIEnv* env ,jobject thiz @@ -3998,9 +4000,9 @@ extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_getStorageId(JNIE extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setFileTransferFilepath(JNIEnv* env ,jobject thiz ,jlong ptr, jstring jpath) { - const char* path = env->GetStringUTFChars(jpath, NULL); + const char* path = GetStringUTFChars(env, jpath); linphone_chat_message_set_file_transfer_filepath((LinphoneChatMessage*)ptr, path); - env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_downloadFile(JNIEnv* env @@ -4156,9 +4158,9 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage(JNIEnv* ,jobject thiz ,jlong ptr ,jstring jmessage) { - const char* message = env->GetStringUTFChars(jmessage, NULL); + const char* message = GetStringUTFChars(env, jmessage); linphone_chat_room_send_message((LinphoneChatRoom*)ptr, message); - env->ReleaseStringUTFChars(jmessage, message); + ReleaseStringUTFChars(env, jmessage, message); } static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessageState state, void* ud) { @@ -4263,10 +4265,9 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setDeviceRotation(JNIEnv } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setRemoteRingbackTone(JNIEnv *env, jobject thiz, jlong lc, jstring jtone){ - const char* tone = NULL; - if (jtone) tone=env->GetStringUTFChars(jtone, NULL); + const char* tone = GetStringUTFChars(env, jtone); linphone_core_set_remote_ringback_tone((LinphoneCore*)lc,tone); - if (tone) env->ReleaseStringUTFChars(jtone,tone); + ReleaseStringUTFChars(env, jtone,tone); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getRemoteRingbackTone(JNIEnv *env, jobject thiz, jlong lc){ @@ -4285,10 +4286,9 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getFirewallPolicy(JNIEnv } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStunServer(JNIEnv *env, jobject thiz, jlong lc, jstring jserver){ - const char* server = NULL; - if (jserver) server=env->GetStringUTFChars(jserver, NULL); + const char* server = GetStringUTFChars(env, jserver); linphone_core_set_stun_server((LinphoneCore*)lc,server); - if (server) env->ReleaseStringUTFChars(jserver,server); + ReleaseStringUTFChars(env, jserver,server); } extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getStunServer(JNIEnv *env, jobject thiz, jlong lc){ @@ -4355,9 +4355,9 @@ extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setSessionName(JNI ,jobject thiz ,jlong cp ,jstring jname) { - const char *name = jname ? env->GetStringUTFChars(jname,NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); linphone_call_params_set_session_name((LinphoneCallParams*)cp,name); - if (name) env->ReleaseStringUTFChars(jname,name); + ReleaseStringUTFChars(env, jname, name); } extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_audioBandwidth(JNIEnv *env, jobject thiz, jlong lcp, jint bw){ @@ -4390,47 +4390,47 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCallParamsImpl_localConferenc } extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name){ - const char* header_name=env->GetStringUTFChars(jheader_name, NULL); - const char *header_value=linphone_call_params_get_custom_header((LinphoneCallParams*)lcp,header_name); - env->ReleaseStringUTFChars(jheader_name, header_name); + const char* header_name = GetStringUTFChars(env, jheader_name); + const char *header_value = linphone_call_params_get_custom_header((LinphoneCallParams*)lcp,header_name); + ReleaseStringUTFChars(env, jheader_name, header_name); return header_value ? env->NewStringUTF(header_value) : NULL; } extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_addCustomHeader(JNIEnv *env, jobject thiz, jlong lcp, jstring jheader_name, jstring jheader_value){ - const char* header_name=env->GetStringUTFChars(jheader_name, NULL); - const char* header_value=env->GetStringUTFChars(jheader_value, NULL); + const char* header_name = GetStringUTFChars(env, jheader_name); + const char* header_value = GetStringUTFChars(env, jheader_value); linphone_call_params_add_custom_header((LinphoneCallParams*)lcp,header_name,header_value); - env->ReleaseStringUTFChars(jheader_name, header_name); - env->ReleaseStringUTFChars(jheader_value, header_value); + ReleaseStringUTFChars(env, jheader_name, header_name); + ReleaseStringUTFChars(env, jheader_value, header_value); } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_addCustomSdpAttribute(JNIEnv *env, jobject thiz, jlong ptr, jstring jname, jstring jvalue) { - const char *name = env->GetStringUTFChars(jname, NULL); - const char *value = env->GetStringUTFChars(jvalue, NULL); + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_call_params_add_custom_sdp_attribute((LinphoneCallParams *)ptr, name, value); - env->ReleaseStringUTFChars(jname, name); - env->ReleaseStringUTFChars(jvalue, value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_addCustomSdpMediaAttribute(JNIEnv *env, jobject thiz, jlong ptr, jint jtype, jstring jname, jstring jvalue) { - const char *name = env->GetStringUTFChars(jname, NULL); - const char *value = env->GetStringUTFChars(jvalue, NULL); + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_call_params_add_custom_sdp_media_attribute((LinphoneCallParams *)ptr, (LinphoneStreamType)jtype, name, value); - env->ReleaseStringUTFChars(jname, name); - env->ReleaseStringUTFChars(jvalue, value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_getCustomSdpAttribute(JNIEnv *env, jobject thiz, jlong ptr, jstring jname) { - const char *name = env->GetStringUTFChars(jname, NULL); + const char *name = GetStringUTFChars(env, jname); const char *value = linphone_call_params_get_custom_sdp_attribute((LinphoneCallParams *)ptr, name); - env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); return value ? env->NewStringUTF(value) : NULL; } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_getCustomSdpMediaAttribute(JNIEnv *env, jobject thiz, jlong ptr, jint jtype, jstring jname) { - const char *name = env->GetStringUTFChars(jname, NULL); + const char *name = GetStringUTFChars(env, jname); const char *value = linphone_call_params_get_custom_sdp_media_attribute((LinphoneCallParams *)ptr, (LinphoneStreamType)jtype, name); - env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); return value ? env->NewStringUTF(value) : NULL; } @@ -4444,9 +4444,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_clearCustom extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setRecordFile(JNIEnv *env, jobject thiz, jlong lcp, jstring jrecord_file){ if (jrecord_file){ - const char* record_file=env->GetStringUTFChars(jrecord_file, NULL); + const char* record_file = GetStringUTFChars(env, jrecord_file); linphone_call_params_set_record_file((LinphoneCallParams*)lcp,record_file); - env->ReleaseStringUTFChars(jrecord_file, record_file); + ReleaseStringUTFChars(env, jrecord_file, record_file); }else linphone_call_params_set_record_file((LinphoneCallParams*)lcp,NULL); } @@ -4553,9 +4553,9 @@ extern "C" float Java_org_linphone_core_LinphoneCoreImpl_getPreferredFramerate(J } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setPreferredVideoSizeByName(JNIEnv *env, jobject thiz, jlong lc, jstring jName) { - const char* cName = env->GetStringUTFChars(jName, NULL); + const char* cName = GetStringUTFChars(env, jName); linphone_core_set_preferred_video_size_by_name((LinphoneCore *)lc, cName); - env->ReleaseStringUTFChars(jName, cName); + ReleaseStringUTFChars(env, jName, cName); } extern "C" jintArray Java_org_linphone_core_LinphoneCoreImpl_getPreferredVideoSize(JNIEnv *env, jobject thiz, jlong lc){ @@ -4662,9 +4662,9 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getQuality JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_setQualityReportingCollector(JNIEnv *env, jobject thiz, jlong ptr, jstring jcollector) { if (jcollector){ - const char *collector=env->GetStringUTFChars(jcollector, NULL); + const char *collector = GetStringUTFChars(env, jcollector); linphone_proxy_config_set_quality_reporting_collector((LinphoneProxyConfig *)ptr, collector); - env->ReleaseStringUTFChars(jcollector,collector); + ReleaseStringUTFChars(env, jcollector, collector); } } @@ -4675,9 +4675,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getQual JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_setRealm(JNIEnv *env, jobject thiz, jlong ptr, jstring jrealm) { if (jrealm){ - const char *realm=env->GetStringUTFChars(jrealm, NULL); + const char *realm = GetStringUTFChars(env, jrealm); linphone_proxy_config_set_realm((LinphoneProxyConfig *)ptr, realm); - env->ReleaseStringUTFChars(jrealm,realm); + ReleaseStringUTFChars(env, jrealm, realm); } } @@ -4688,9 +4688,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getReal JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_isPhoneNumber(JNIEnv *env, jobject thiz, jlong ptr, jstring jusername) { if(jusername){ - const char *username=env->GetStringUTFChars(jusername, NULL); + const char *username = GetStringUTFChars(env, jusername); bool_t res = linphone_proxy_config_is_phone_number((LinphoneProxyConfig *)ptr, username); - env->ReleaseStringUTFChars(jusername,username); + ReleaseStringUTFChars(env, jusername, username); return (jboolean) res; } else { return JNI_FALSE; @@ -4698,17 +4698,17 @@ JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_isPhon } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_setCustomHeader(JNIEnv *env, jobject thiz, jlong prt, jstring jname, jstring jvalue) { - const char *name = jname ? env->GetStringUTFChars(jname, NULL) : NULL; - const char *value = jvalue ? env->GetStringUTFChars(jvalue, NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_proxy_config_set_custom_header((LinphoneProxyConfig*) prt, name, value); - if (jname) env->ReleaseStringUTFChars(jname, name); - if (jvalue) env->ReleaseStringUTFChars(jvalue, value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneProxyConfigImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong ptr, jstring jname) { - const char *name = jname ? env->GetStringUTFChars(jname, NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); const char *value = linphone_proxy_config_get_custom_header((LinphoneProxyConfig *)ptr, name); - if (jname) env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); return value ? env->NewStringUTF(value) : NULL; } @@ -4830,9 +4830,9 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getConference(JNIEnv extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startConferenceRecording(JNIEnv *env,jobject thiz,jlong pCore, jstring jpath){ int err=-1; if (jpath){ - const char *path=env->GetStringUTFChars(jpath, NULL); + const char *path = GetStringUTFChars(env, jpath); err=linphone_core_start_conference_recording((LinphoneCore*)pCore,path); - env->ReleaseStringUTFChars(jpath,path); + ReleaseStringUTFChars(env, jpath, path); } return err; } @@ -4854,9 +4854,9 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getCallsNb(JNIEnv *env,j } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCall(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jstring jReferTo) { - const char* cReferTo=env->GetStringUTFChars(jReferTo, NULL); + const char* cReferTo = GetStringUTFChars(env, jReferTo); jint err = linphone_core_transfer_call((LinphoneCore *) pCore, (LinphoneCall *) pCall, cReferTo); - env->ReleaseStringUTFChars(jReferTo, cReferTo); + ReleaseStringUTFChars(env, jReferTo, cReferTo); return err; } extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_transferCallToAnother(JNIEnv *env,jobject thiz,jlong pCore, jlong pCall, jlong pDestCall) { @@ -4869,18 +4869,18 @@ extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_startReferedCall(JNIE extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setZrtpSecretsCache(JNIEnv *env,jobject thiz,jlong pCore, jstring jFile) { if (jFile) { - const char* cFile=env->GetStringUTFChars(jFile, NULL); + const char* cFile =GetStringUTFChars(env, jFile); linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,cFile); - env->ReleaseStringUTFChars(jFile, cFile); + ReleaseStringUTFChars(env, jFile, cFile); } else { linphone_core_set_zrtp_secrets_file((LinphoneCore *) pCore,NULL); } } extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_findCallFromUri(JNIEnv *env,jobject thiz,jlong pCore, jstring jUri) { - const char* cUri=env->GetStringUTFChars(jUri, NULL); + const char* cUri = GetStringUTFChars(env, jUri); const LinphoneCall *call=linphone_core_find_call_from_uri((const LinphoneCore *) pCore,cUri); - env->ReleaseStringUTFChars(jUri, cUri); + ReleaseStringUTFChars(env, jUri, cUri); return (jobject) getCall(env,(LinphoneCall*)call); } @@ -5003,14 +5003,14 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; - const char* cHost=env->GetStringUTFChars(jHost, NULL); + const char* cHost = GetStringUTFChars(env, jHost); LinphoneTunnelConfig *tunnelconfig = linphone_tunnel_config_new(); linphone_tunnel_config_set_host(tunnelconfig, cHost); linphone_tunnel_config_set_port(tunnelconfig, port); linphone_tunnel_config_set_delay(tunnelconfig, delay); linphone_tunnel_config_set_remote_udp_mirror_port(tunnelconfig, mirror); linphone_tunnel_add_server(tunnel, tunnelconfig); - env->ReleaseStringUTFChars(jHost, cHost); + ReleaseStringUTFChars(env, jHost, cHost); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServer(JNIEnv *env, jobject thiz, jlong pCore, jlong tunnelconfigptr) { @@ -5053,13 +5053,13 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEn LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; - const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL; - const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL; - const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL; + const char* cHost = GetStringUTFChars(env, jHost); + const char* cUsername = GetStringUTFChars(env, username); + const char* cPassword = GetStringUTFChars(env, password); linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword); - if (cHost) env->ReleaseStringUTFChars(jHost, cHost); - if (cUsername) env->ReleaseStringUTFChars(username, cUsername); - if (cPassword) env->ReleaseStringUTFChars(password, cPassword); + ReleaseStringUTFChars(env, jHost, cHost); + ReleaseStringUTFChars(env, username, cUsername); + ReleaseStringUTFChars(env, password, cPassword); } @@ -5111,11 +5111,11 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_tunnelSipEnabled(JNI } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setUserAgent(JNIEnv *env,jobject thiz,jlong pCore, jstring name, jstring version){ - const char* cname=env->GetStringUTFChars(name, NULL); - const char* cversion=env->GetStringUTFChars(version, NULL); + const char* cname = GetStringUTFChars(env, name); + const char* cversion = GetStringUTFChars(env, version); linphone_core_set_user_agent((LinphoneCore *)pCore,cname,cversion); - env->ReleaseStringUTFChars(name, cname); - env->ReleaseStringUTFChars(version, cversion); + ReleaseStringUTFChars(env, name, cname); + ReleaseStringUTFChars(env, version, cversion); } extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isTunnelAvailable(JNIEnv *env,jobject thiz){ @@ -5140,9 +5140,9 @@ extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getVideoAutoAcceptPo } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setStaticPicture(JNIEnv *env, jobject thiz, jlong lc, jstring path) { - const char *cpath = env->GetStringUTFChars(path, NULL); + const char *cpath = GetStringUTFChars(env, path); linphone_core_set_static_picture((LinphoneCore *)lc, cpath); - env->ReleaseStringUTFChars(path, cpath); + ReleaseStringUTFChars(env, path, cpath); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jlong coreptr, jint count) { @@ -5275,20 +5275,20 @@ static LinphoneContent *create_content_from_java_args(JNIEnv *env, LinphoneCore void *data = (void*)env->GetByteArrayElements(jdata,NULL); const char *tmp; - linphone_content_set_type(content, tmp = env->GetStringUTFChars(jtype, NULL)); - env->ReleaseStringUTFChars(jtype, tmp); + linphone_content_set_type(content, tmp = GetStringUTFChars(env, jtype)); + ReleaseStringUTFChars(env, jtype, tmp); - linphone_content_set_subtype(content, tmp = env->GetStringUTFChars(jsubtype, NULL)); - env->ReleaseStringUTFChars(jsubtype, tmp); + linphone_content_set_subtype(content, tmp = GetStringUTFChars(env, jsubtype)); + ReleaseStringUTFChars(env, jsubtype, tmp); if (jname){ - linphone_content_set_name(content, tmp = env->GetStringUTFChars(jname, NULL)); - env->ReleaseStringUTFChars(jname, tmp); + linphone_content_set_name(content, tmp = GetStringUTFChars(env, jname)); + ReleaseStringUTFChars(env, jname, tmp); } if (jencoding){ - linphone_content_set_encoding(content, tmp = env->GetStringUTFChars(jencoding,NULL)); - env->ReleaseStringUTFChars(jencoding, tmp); + linphone_content_set_encoding(content, tmp = GetStringUTFChars(env, jencoding)); + ReleaseStringUTFChars(env, jencoding, tmp); } linphone_content_set_buffer(content, data, env->GetArrayLength(jdata)); @@ -5309,12 +5309,12 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_subscribe(JNIE LinphoneContent * content = create_content_from_java_args(env, (LinphoneCore*)coreptr, jtype, jsubtype, jdata, jencoding, NULL); LinphoneEvent *ev; jobject jev=NULL; - const char *evname=env->GetStringUTFChars(jevname,NULL); + const char *evname = GetStringUTFChars(env, jevname); ev=linphone_core_subscribe(lc,addr,evname,expires, content); if (content) linphone_content_unref(content); - env->ReleaseStringUTFChars(jevname,evname); + ReleaseStringUTFChars(env, jevname, evname); if (ev){ jev=getEvent(env,ev); } @@ -5333,11 +5333,11 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_publish(JNIEnv LinphoneContent * content = create_content_from_java_args(env, (LinphoneCore*)coreptr, jtype, jsubtype, jdata, jencoding, NULL); LinphoneEvent *ev; jobject jev=NULL; - const char *evname=env->GetStringUTFChars(jevname,NULL); + const char *evname = GetStringUTFChars(env, jevname); ev=linphone_core_publish(lc,addr,evname,expires, content); if (content) linphone_content_unref(content); - env->ReleaseStringUTFChars(jevname,evname); + ReleaseStringUTFChars(env, jevname, evname); if (ev){ jev=getEvent(env,ev); } @@ -5346,16 +5346,16 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_publish(JNIEnv // LpConfig extern "C" jlong Java_org_linphone_core_LpConfigImpl_newLpConfigImpl(JNIEnv *env, jobject thiz, jstring file) { - const char *cfile = env->GetStringUTFChars(file, NULL); + const char *cfile = GetStringUTFChars(env, file); LpConfig *lp = lp_config_new(cfile); - env->ReleaseStringUTFChars(file, cfile); + ReleaseStringUTFChars(env, file, cfile); return (jlong) lp; } extern "C" jlong Java_org_linphone_core_LpConfigImpl_newLpConfigImplFromBuffer(JNIEnv *env, jobject thiz, jstring buffer) { - const char *cbuffer = env->GetStringUTFChars(buffer, NULL); + const char *cbuffer = GetStringUTFChars(env, buffer); LpConfig *lp = lp_config_new_from_buffer(cbuffer); - env->ReleaseStringUTFChars(buffer, cbuffer); + ReleaseStringUTFChars(env, buffer, cbuffer); return (jlong) lp; } @@ -5371,77 +5371,77 @@ extern "C" void Java_org_linphone_core_LpConfigImpl_delete(JNIEnv *env, jobject extern "C" void Java_org_linphone_core_LpConfigImpl_setInt(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jint value) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); lp_config_set_int((LpConfig *)lpc, csection, ckey, (int) value); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); } extern "C" jint Java_org_linphone_core_LpConfigImpl_getInt(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jint defaultValue) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); int returnValue = lp_config_get_int((LpConfig *)lpc, csection, ckey, (int) defaultValue); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); return (jint) returnValue; } extern "C" void Java_org_linphone_core_LpConfigImpl_setFloat(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jfloat value) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); lp_config_set_float((LpConfig *)lpc, csection, ckey, (float) value); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); } extern "C" jfloat Java_org_linphone_core_LpConfigImpl_getFloat(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jfloat defaultValue) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); float returnValue = lp_config_get_float((LpConfig *)lpc, csection, ckey, (float) defaultValue); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); return (jfloat) returnValue; } extern "C" void Java_org_linphone_core_LpConfigImpl_setBool(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jboolean value) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); lp_config_set_int((LpConfig *)lpc, csection, ckey, value ? 1 : 0); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); } extern "C" jboolean Java_org_linphone_core_LpConfigImpl_getBool(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jboolean defaultValue) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); int returnValue = lp_config_get_int((LpConfig *)lpc, csection, ckey, defaultValue ? 1 : 0); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); return (jboolean) returnValue == 1; } extern "C" void Java_org_linphone_core_LpConfigImpl_setString(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jstring value) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); - const char *cvalue = value ? env->GetStringUTFChars(value, NULL) : NULL; + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); + const char *cvalue = GetStringUTFChars(env, value); lp_config_set_string((LpConfig *)lpc, csection, ckey, cvalue); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); - if (value) env->ReleaseStringUTFChars(value, cvalue); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); + ReleaseStringUTFChars(env, value, cvalue); } extern "C" jstring Java_org_linphone_core_LpConfigImpl_getString(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jstring defaultValue) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); - const char *cvalue = defaultValue ? env->GetStringUTFChars(defaultValue, NULL) : NULL; + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); + const char *cvalue = GetStringUTFChars(env, defaultValue); const char *returnValue = lp_config_get_string((LpConfig *)lpc, csection, ckey, cvalue); @@ -5449,33 +5449,32 @@ extern "C" jstring Java_org_linphone_core_LpConfigImpl_getString(JNIEnv *env, jo if (returnValue) jreturnValue = env->NewStringUTF(returnValue); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); - if (cvalue) - env->ReleaseStringUTFChars(defaultValue, cvalue); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); + ReleaseStringUTFChars(env, defaultValue, cvalue); return jreturnValue; } extern "C" void Java_org_linphone_core_LpConfigImpl_setIntRange(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jint min, jint max) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); lp_config_set_range((LpConfig *)lpc, csection, ckey, min, max); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); } extern "C" jintArray Java_org_linphone_core_LpConfigImpl_getIntRange(JNIEnv *env, jobject thiz, jlong lpc, jstring section, jstring key, jint defaultmin, jint defaultmax) { - const char *csection = env->GetStringUTFChars(section, NULL); - const char *ckey = env->GetStringUTFChars(key, NULL); + const char *csection = GetStringUTFChars(env, section); + const char *ckey = GetStringUTFChars(env, key); int *values = (int*)calloc(2, sizeof(int)); lp_config_get_range((LpConfig *)lpc, csection, ckey, &values[0], &values[1], defaultmin, defaultmax); jintArray returnValues = env->NewIntArray(2); env->SetIntArrayRegion(returnValues, 0, 2, values); ms_free(values); - env->ReleaseStringUTFChars(section, csection); - env->ReleaseStringUTFChars(key, ckey); + ReleaseStringUTFChars(env, section, csection); + ReleaseStringUTFChars(env, key, ckey); return returnValues; } @@ -5587,15 +5586,14 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_setContent LinphoneContent * content = linphone_content_new(); const char *tmp; - linphone_content_set_type(content, tmp = env->GetStringUTFChars(jtype,NULL)); - env->ReleaseStringUTFChars(jtype, tmp); + linphone_content_set_type(content, tmp = GetStringUTFChars(env, jtype)); + ReleaseStringUTFChars(env, jtype, tmp); - linphone_content_set_type(content, tmp = env->GetStringUTFChars(jsubtype,NULL)); - env->ReleaseStringUTFChars(jsubtype, tmp); + linphone_content_set_type(content, tmp = GetStringUTFChars(env, jsubtype)); + ReleaseStringUTFChars(env, jsubtype, tmp); - - linphone_content_set_string_buffer(content, tmp = env->GetStringUTFChars(jdata,NULL)); - env->ReleaseStringUTFChars(jdata, tmp); + linphone_content_set_string_buffer(content, tmp = GetStringUTFChars(env, jdata)); + ReleaseStringUTFChars(env, jdata, tmp); linphone_info_message_set_content(infomsg, content); linphone_content_unref(content); @@ -5607,12 +5605,11 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_setContent * Signature: (JLjava/lang/String;Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_addHeader(JNIEnv *env, jobject jobj, jlong infoptr, jstring jname, jstring jvalue){ - const char *name=NULL,*value=NULL; - name=env->GetStringUTFChars(jname,NULL); - value=env->GetStringUTFChars(jvalue,NULL); + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_info_message_add_header((LinphoneInfoMessage*)infoptr,name,value); - env->ReleaseStringUTFChars(jname,name); - env->ReleaseStringUTFChars(jvalue,value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } /* @@ -5621,9 +5618,9 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_addHeader( * Signature: (JLjava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneInfoMessageImpl_getHeader(JNIEnv *env, jobject jobj, jlong infoptr, jstring jname){ - const char *name=env->GetStringUTFChars(jname,NULL); + const char *name = GetStringUTFChars(env, jname); const char *ret=linphone_info_message_get_header((LinphoneInfoMessage*)infoptr,name); - env->ReleaseStringUTFChars(jname,name); + ReleaseStringUTFChars(env, jname, name); return ret ? env->NewStringUTF(ret) : NULL; } @@ -5796,10 +5793,10 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createSubscrib LinphoneAddress *addr = (LinphoneAddress*) jaddr; LinphoneEvent *event; jobject jevent = NULL; - const char *event_name = env->GetStringUTFChars(jeventname, NULL); + const char *event_name = GetStringUTFChars(env, jeventname); event = linphone_core_create_subscribe(lc, addr, event_name, expires); - env->ReleaseStringUTFChars(jeventname, event_name); + ReleaseStringUTFChars(env, jeventname, event_name); if (event) { jevent = getEvent(env, event); } @@ -5819,10 +5816,10 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_LinphoneCoreImpl_createPublish( LinphoneAddress *addr = (LinphoneAddress*) jaddr; LinphoneEvent *event; jobject jevent = NULL; - const char *event_name = env->GetStringUTFChars(jeventname, NULL); + const char *event_name = GetStringUTFChars(env, jeventname); event = linphone_core_create_publish(lc, addr, event_name, expires); - env->ReleaseStringUTFChars(jeventname, event_name); + ReleaseStringUTFChars(env, jeventname, event_name); if (event) { jevent = getEvent(env, event); } @@ -5837,18 +5834,18 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneEventImpl_sendPublish(JNIE } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneEventImpl_addCustomHeader(JNIEnv *env, jobject thiz, jlong jevent, jstring jname, jstring jvalue) { - const char *name = jname ? env->GetStringUTFChars(jname, NULL) : NULL; - const char *value = jvalue ? env->GetStringUTFChars(jvalue, NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); + const char *value = GetStringUTFChars(env, jvalue); linphone_event_add_custom_header((LinphoneEvent*) jevent, name, value); - if (jname) env->ReleaseStringUTFChars(jname, name); - if (jvalue) env->ReleaseStringUTFChars(jvalue, value); + ReleaseStringUTFChars(env, jname, name); + ReleaseStringUTFChars(env, jvalue, value); } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneEventImpl_getCustomHeader(JNIEnv *env, jobject thiz, jlong jevent, jstring jname) { - const char *name = jname ? env->GetStringUTFChars(jname, NULL) : NULL; + const char *name = GetStringUTFChars(env, jname); const char *header = linphone_event_get_custom_header((LinphoneEvent*) jevent, name); jstring jheader = header ? env->NewStringUTF(header) : NULL; - if (jname) env->ReleaseStringUTFChars(jname, name); + ReleaseStringUTFChars(env, jname, name); return jheader; } @@ -5880,10 +5877,10 @@ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceMode */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceModelImpl__ILjava_lang_String_2(JNIEnv *env, jobject jobj, jint type, jstring description) { LinphonePresenceModel *model; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); model = linphone_presence_model_new_with_activity((LinphonePresenceActivityType)type, cdescription); model = linphone_presence_model_ref(model); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + ReleaseStringUTFChars(env, description, cdescription); return (jlong)model; } @@ -5895,14 +5892,14 @@ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceMode JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceModelImpl_newPresenceModelImpl__ILjava_lang_String_2Ljava_lang_String_2Ljava_lang_String_2( JNIEnv *env, jobject jobj, jint type, jstring description, jstring note, jstring lang) { LinphonePresenceModel *model; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; - const char *cnote = note ? env->GetStringUTFChars(note, NULL) : NULL; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); + const char *cnote =GetStringUTFChars(env, note); + const char *clang = GetStringUTFChars(env, lang); model = linphone_presence_model_new_with_activity_and_note((LinphonePresenceActivityType)type, cdescription, cnote, clang); model = linphone_presence_model_ref(model); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); - if (cnote) env->ReleaseStringUTFChars(note, cnote); - if (clang) env->ReleaseStringUTFChars(lang, clang); + ReleaseStringUTFChars(env, description, cdescription); + ReleaseStringUTFChars(env, note, cnote); + ReleaseStringUTFChars(env, lang, clang); return (jlong)model; } @@ -5967,9 +5964,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceModelImpl_getContact(JN */ JNIEXPORT void JNICALL Java_org_linphone_core_PresenceModelImpl_setContact(JNIEnv *env, jobject jobj, jlong ptr, jstring contact) { LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - const char *ccontact = contact ? env->GetStringUTFChars(contact, NULL) : NULL; + const char *ccontact = GetStringUTFChars(env, contact); linphone_presence_model_set_contact(model, ccontact); - if (ccontact) env->ReleaseStringUTFChars(contact, ccontact); + ReleaseStringUTFChars(env, contact, ccontact); } /* @@ -5991,9 +5988,9 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getActivity(J */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_setActivity(JNIEnv *env, jobject jobj, jlong ptr, jint acttype, jstring description) { LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); jint res = (jint)linphone_presence_model_set_activity(model, (LinphonePresenceActivityType)acttype, cdescription); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + ReleaseStringUTFChars(env, description, cdescription); return res; } @@ -6045,9 +6042,9 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_clearActivities( */ JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getNote(JNIEnv *env , jobject jobj, jlong ptr, jstring lang) { LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *clang = GetStringUTFChars(env, lang); LinphonePresenceNote *note = linphone_presence_model_get_note(model, clang); - if (clang) env->ReleaseStringUTFChars(lang, clang); + ReleaseStringUTFChars(env, lang, clang); if (note == NULL) return NULL; RETURN_USER_DATA_OBJECT("PresenceNoteImpl", linphone_presence_note, note) } @@ -6059,11 +6056,11 @@ JNIEXPORT jobject JNICALL Java_org_linphone_core_PresenceModelImpl_getNote(JNIEn */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_addNote(JNIEnv *env, jobject jobj, jlong ptr, jstring description, jstring lang) { LinphonePresenceModel *model = (LinphonePresenceModel *)ptr; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); + const char *clang = GetStringUTFChars(env, lang); jint res = (jint)linphone_presence_model_add_note(model, cdescription, clang); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); - if (clang) env->ReleaseStringUTFChars(lang, clang); + ReleaseStringUTFChars(env, description, cdescription); + ReleaseStringUTFChars(env, lang, clang); return res; } @@ -6166,10 +6163,10 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceModelImpl_clearPersons(JNI */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceActivityImpl_newPresenceActivityImpl(JNIEnv *env, jobject jobj, jint type, jstring description) { LinphonePresenceActivity *activity; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); activity = linphone_presence_activity_new((LinphonePresenceActivityType)type, cdescription); activity = linphone_presence_activity_ref(activity); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + ReleaseStringUTFChars(env, description, cdescription); return (jlong)activity; } @@ -6234,9 +6231,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceActivityImpl_getDescrip */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceActivityImpl_setDescription(JNIEnv *env, jobject jobj, jlong ptr, jstring description) { LinphonePresenceActivity *activity = (LinphonePresenceActivity *)ptr; - const char *cdescription = description ? env->GetStringUTFChars(description, NULL) : NULL; + const char *cdescription = GetStringUTFChars(env, description); linphone_presence_activity_set_description(activity, cdescription); - if (cdescription) env->ReleaseStringUTFChars(description, cdescription); + ReleaseStringUTFChars(env, description, cdescription); return (jint)0; } @@ -6247,12 +6244,12 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceActivityImpl_setDescriptio */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceServiceImpl_newPresenceServiceImpl(JNIEnv *env, jobject jobj, jstring id, jint basic_status, jstring contact) { LinphonePresenceService *service; - const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL; - const char *ccontact = contact ? env->GetStringUTFChars(contact, NULL) : NULL; + const char *cid = GetStringUTFChars(env, id); + const char *ccontact = GetStringUTFChars(env, contact); service = linphone_presence_service_new(cid, (LinphonePresenceBasicStatus)basic_status, ccontact); service = linphone_presence_service_ref(service); - if (cid) env->ReleaseStringUTFChars(id, cid); - if (ccontact) env->ReleaseStringUTFChars(contact, ccontact); + ReleaseStringUTFChars(env, id, cid); + ReleaseStringUTFChars(env, contact, ccontact); return (jlong)service; } @@ -6286,9 +6283,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceServiceImpl_getId(JNIEn */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_setId(JNIEnv *env, jobject jobj, jlong ptr, jstring id) { LinphonePresenceService *service = (LinphonePresenceService *)ptr; - const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL; + const char *cid = GetStringUTFChars(env, id); linphone_presence_service_set_id(service, cid); - if (cid) env->ReleaseStringUTFChars(id, cid); + ReleaseStringUTFChars(env, id, cid); return (jint)0; } @@ -6332,9 +6329,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceServiceImpl_getContact( */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_setContact(JNIEnv *env, jobject jobj, jlong ptr, jstring contact) { LinphonePresenceService *service = (LinphonePresenceService *)ptr; - const char *ccontact = contact ? env->GetStringUTFChars(contact, NULL) : NULL; + const char *ccontact = GetStringUTFChars(env, contact); linphone_presence_service_set_contact(service, ccontact); - if (ccontact) env->ReleaseStringUTFChars(contact, ccontact); + ReleaseStringUTFChars(env, contact, ccontact); return (jint)0; } @@ -6386,10 +6383,10 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceServiceImpl_clearNotes(JNI */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresencePersonImpl_newPresencePersonImpl(JNIEnv *env, jobject jobj, jstring id) { LinphonePresencePerson *person; - const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL; + const char *cid = GetStringUTFChars(env, id); person = linphone_presence_person_new(cid); person = linphone_presence_person_ref(person); - if (cid) env->ReleaseStringUTFChars(id, cid); + ReleaseStringUTFChars(env, id, cid); return (jlong)person; } @@ -6423,9 +6420,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresencePersonImpl_getId(JNIEnv */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_setId(JNIEnv *env, jobject jobj, jlong ptr, jstring id) { LinphonePresencePerson *person = (LinphonePresencePerson *)ptr; - const char *cid = id ? env->GetStringUTFChars(id, NULL) : NULL; + const char *cid = GetStringUTFChars(env, id); linphone_presence_person_set_id(person, cid); - if (cid) env->ReleaseStringUTFChars(id, cid); + ReleaseStringUTFChars(env, id, cid); return (jint)0; } @@ -6559,12 +6556,12 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresencePersonImpl_clearActivitesN */ JNIEXPORT jlong JNICALL Java_org_linphone_core_PresenceNoteImpl_newPresenceNoteImpl(JNIEnv *env, jobject jobj, jstring content, jstring lang) { LinphonePresenceNote *note; - const char *ccontent = content ? env->GetStringUTFChars(content, NULL) : NULL; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *ccontent = GetStringUTFChars(env, content); + const char *clang = GetStringUTFChars(env, lang); note = linphone_presence_note_new(ccontent, clang); note = linphone_presence_note_ref(note); - if (clang) env->ReleaseStringUTFChars(lang, clang); - if (ccontent) env->ReleaseStringUTFChars(content, ccontent); + ReleaseStringUTFChars(env, lang, clang); + ReleaseStringUTFChars(env, content, ccontent); return (jlong)note; } @@ -6596,9 +6593,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceNoteImpl_getContent(JNI */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceNoteImpl_setContent(JNIEnv *env, jobject jobj, jlong ptr, jstring content) { LinphonePresenceNote *note = (LinphonePresenceNote *)ptr; - const char *ccontent = content ? env->GetStringUTFChars(content, NULL) : NULL; + const char *ccontent = GetStringUTFChars(env, content); linphone_presence_note_set_content(note, ccontent); - if (ccontent) env->ReleaseStringUTFChars(content, ccontent); + ReleaseStringUTFChars(env, content, ccontent); return (jint)0; } @@ -6620,9 +6617,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PresenceNoteImpl_getLang(JNIEnv */ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceNoteImpl_setLang(JNIEnv *env, jobject jobj, jlong ptr, jstring lang) { LinphonePresenceNote *note = (LinphonePresenceNote *)ptr; - const char *clang = lang ? env->GetStringUTFChars(lang, NULL) : NULL; + const char *clang = GetStringUTFChars(env, lang); linphone_presence_note_set_lang(note, clang); - if (clang) env->ReleaseStringUTFChars(lang, clang); + ReleaseStringUTFChars(env, lang, clang); return (jint)0; } @@ -6633,9 +6630,9 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_PresenceNoteImpl_setLang(JNIEnv *e */ JNIEXPORT void JNICALL Java_org_linphone_core_PayloadTypeImpl_setRecvFmtp(JNIEnv *env, jobject jobj, jlong ptr, jstring jfmtp){ PayloadType *pt=(PayloadType *)ptr; - const char *fmtp=jfmtp ? env->GetStringUTFChars(jfmtp,NULL) : NULL; + const char *fmtp = GetStringUTFChars(env, jfmtp); payload_type_set_recv_fmtp(pt,fmtp); - if (fmtp) env->ReleaseStringUTFChars(jfmtp,fmtp); + ReleaseStringUTFChars(env, jfmtp, fmtp); } /* @@ -6656,9 +6653,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_PayloadTypeImpl_getRecvFmtp(JNI */ JNIEXPORT void JNICALL Java_org_linphone_core_PayloadTypeImpl_setSendFmtp(JNIEnv *env, jobject jobj, jlong ptr , jstring jfmtp){ PayloadType *pt=(PayloadType *)ptr; - const char *fmtp=jfmtp ? env->GetStringUTFChars(jfmtp,NULL) : NULL; + const char *fmtp = GetStringUTFChars(env, jfmtp); payload_type_set_send_fmtp(pt,fmtp); - if (fmtp) env->ReleaseStringUTFChars(jfmtp,fmtp); + ReleaseStringUTFChars(env, jfmtp, fmtp); } /* @@ -6770,14 +6767,17 @@ static void _eof_callback(LinphonePlayer *player, void *user_data) { extern "C" jint Java_org_linphone_core_LinphonePlayerImpl_open(JNIEnv *env, jobject jPlayer, jlong ptr, jstring filename, jobject listener) { LinphonePlayerData *data = NULL; LinphonePlayerEofCallback cb = NULL; + const char *cfilename = GetStringUTFChars(env, filename); if(listener) { data = new LinphonePlayerData(env, listener, jPlayer); cb = _eof_callback; } - if(linphone_player_open((LinphonePlayer *)ptr, env->GetStringUTFChars(filename, NULL), cb, data) == -1) { + if(linphone_player_open((LinphonePlayer *)ptr, cfilename, cb, data) == -1) { if(data) delete data; + ReleaseStringUTFChars(env, filename, cfilename); return -1; } + ReleaseStringUTFChars(env, filename, cfilename); return 0; } @@ -6850,10 +6850,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createLocalPlayer(JNIEn */ extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setAudioMulticastAddr (JNIEnv * env , jobject, jlong ptr, jstring value) { - const char *char_value = value ? env->GetStringUTFChars(value, NULL) : NULL; + const char *char_value = GetStringUTFChars(env, value); LinphoneCore *lc=(LinphoneCore*)ptr; int result = linphone_core_set_audio_multicast_addr(lc,char_value); - if (char_value) env->ReleaseStringUTFChars(value, char_value); + ReleaseStringUTFChars(env, value, char_value); return result; } @@ -6864,10 +6864,10 @@ extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setAudioMulticas */ extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoMulticastAddr (JNIEnv * env, jobject, jlong ptr, jstring value) { - const char *char_value = value ? env->GetStringUTFChars(value, NULL) : NULL; + const char *char_value = GetStringUTFChars(env, value); LinphoneCore *lc=(LinphoneCore*)ptr; int result = linphone_core_set_video_multicast_addr(lc,char_value); - if (char_value) env->ReleaseStringUTFChars(value, char_value); + ReleaseStringUTFChars(env, value, char_value); return result; } @@ -6981,10 +6981,10 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setDnsServers(JNI for (int i=0; i < count; i++) { jstring server = (jstring) env->GetObjectArrayElement(servers, i); - const char *str = env->GetStringUTFChars(server, NULL); + const char *str = GetStringUTFChars(env, server); if (str){ l = ms_list_append(l, ms_strdup(str)); - env->ReleaseStringUTFChars(server, str); + ReleaseStringUTFChars(env, server, str); } } } @@ -7001,9 +7001,9 @@ JNIEXPORT jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_dnsSrvEnabled } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoPreset(JNIEnv *env, jobject thiz, jlong lc, jstring preset) { - const char *char_preset = preset ? env->GetStringUTFChars(preset, NULL) : NULL; + const char *char_preset = GetStringUTFChars(env, preset); linphone_core_set_video_preset((LinphoneCore *)lc, char_preset); - if (char_preset) env->ReleaseStringUTFChars(preset, char_preset); + ReleaseStringUTFChars(env, preset, char_preset); } JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCoreImpl_getVideoPreset(JNIEnv *env, jobject thiz, jlong lc) { @@ -7118,9 +7118,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_TunnelConfigImpl_getHost(JNIEnv */ JNIEXPORT void JNICALL Java_org_linphone_core_TunnelConfigImpl_setHost(JNIEnv *env, jobject obj, jlong ptr, jstring jstr){ LinphoneTunnelConfig *cfg = (LinphoneTunnelConfig *)ptr; - const char* host = jstr ? env->GetStringUTFChars(jstr, NULL) : NULL; + const char* host = GetStringUTFChars(env, jstr); linphone_tunnel_config_set_host(cfg, host); - if (jstr) env->ReleaseStringUTFChars(jstr, host); + ReleaseStringUTFChars(env, jstr, host); } /* @@ -7211,9 +7211,9 @@ JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallLogImpl_getCallId(J * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setHttpProxyHost(JNIEnv *env, jobject jobj, jlong core, jstring jhost){ - const char *host = jhost ? env->GetStringUTFChars(jhost, NULL) : NULL; + const char *host = GetStringUTFChars(env, jhost); linphone_core_set_http_proxy_host((LinphoneCore*)core, host); - if (host) env->ReleaseStringUTFChars(jhost, host); + ReleaseStringUTFChars(env, jhost, host); } /* @@ -7352,13 +7352,13 @@ JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setMediaNetworkRe } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_setUserCertificatesPath(JNIEnv *env, jobject jobj, jlong pcore, jstring jpath){ - const char *path = jpath ? env->GetStringUTFChars(jpath, NULL) : NULL; + const char *path = GetStringUTFChars(env, jpath); linphone_core_set_user_certificates_path((LinphoneCore*)pcore, path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCoreImpl_reloadMsPlugins(JNIEnv *env, jobject jobj, jlong pcore, jstring jpath) { - const char *path = jpath ? env->GetStringUTFChars(jpath, NULL) : NULL; + const char *path = GetStringUTFChars(env, jpath); linphone_core_reload_ms_plugins((LinphoneCore*)pcore, path); - if (path) env->ReleaseStringUTFChars(jpath, path); + ReleaseStringUTFChars(env, jpath, path); } From d4ff86db9de79fee44714aa477f827108a20d19c Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Fri, 17 Jun 2016 14:53:59 +0200 Subject: [PATCH 103/124] License update. --- .../commands/adaptive-jitter-compensation.cc | 19 +++++++++++++ .../commands/adaptive-jitter-compensation.h | 19 +++++++++++++ daemon/commands/answer.cc | 19 +++++++++++++ daemon/commands/answer.h | 19 +++++++++++++ daemon/commands/audio-codec-get.cc | 19 +++++++++++++ daemon/commands/audio-codec-get.h | 19 +++++++++++++ daemon/commands/audio-codec-move.cc | 19 +++++++++++++ daemon/commands/audio-codec-move.h | 19 +++++++++++++ daemon/commands/audio-codec-set.cc | 19 +++++++++++++ daemon/commands/audio-codec-set.h | 19 +++++++++++++ daemon/commands/audio-codec-toggle.cc | 19 +++++++++++++ daemon/commands/audio-codec-toggle.h | 19 +++++++++++++ daemon/commands/audio-stream-start.cc | 19 +++++++++++++ daemon/commands/audio-stream-start.h | 19 +++++++++++++ daemon/commands/audio-stream-stats.cc | 19 +++++++++++++ daemon/commands/audio-stream-stats.h | 19 +++++++++++++ daemon/commands/audio-stream-stop.cc | 19 +++++++++++++ daemon/commands/audio-stream-stop.h | 19 +++++++++++++ daemon/commands/auth-infos-clear.cc | 19 +++++++++++++ daemon/commands/auth-infos-clear.h | 19 +++++++++++++ daemon/commands/call-mute.cc | 19 +++++++++++++ daemon/commands/call-mute.h | 19 +++++++++++++ daemon/commands/call-pause.cc | 19 +++++++++++++ daemon/commands/call-pause.h | 19 +++++++++++++ daemon/commands/call-resume.cc | 19 +++++++++++++ daemon/commands/call-resume.h | 19 +++++++++++++ daemon/commands/call-stats.cc | 19 +++++++++++++ daemon/commands/call-stats.h | 19 +++++++++++++ daemon/commands/call-status.cc | 19 +++++++++++++ daemon/commands/call-status.h | 19 +++++++++++++ daemon/commands/call-transfer.cc | 19 +++++++++++++ daemon/commands/call-transfer.h | 19 +++++++++++++ daemon/commands/call.cc | 19 +++++++++++++ daemon/commands/call.h | 19 +++++++++++++ daemon/commands/cn.cc | 19 +++++++++++++ daemon/commands/cn.h | 19 +++++++++++++ daemon/commands/conference.cc | 19 +++++++++++++ daemon/commands/conference.h | 19 +++++++++++++ daemon/commands/config.cc | 19 +++++++++++++ daemon/commands/configcommand.h | 19 +++++++++++++ daemon/commands/contact.cc | 19 +++++++++++++ daemon/commands/contact.h | 19 +++++++++++++ daemon/commands/dtmf.cc | 19 +++++++++++++ daemon/commands/dtmf.h | 19 +++++++++++++ daemon/commands/firewall-policy.cc | 19 +++++++++++++ daemon/commands/firewall-policy.h | 19 +++++++++++++ daemon/commands/help.cc | 19 +++++++++++++ daemon/commands/help.h | 19 +++++++++++++ daemon/commands/ipv6.cc | 19 +++++++++++++ daemon/commands/ipv6.h | 19 +++++++++++++ daemon/commands/jitterbuffer.cc | 19 +++++++++++++ daemon/commands/jitterbuffer.h | 19 +++++++++++++ daemon/commands/license.py | 27 +++++++++++++++++++ daemon/commands/media-encryption.cc | 19 +++++++++++++ daemon/commands/media-encryption.h | 19 +++++++++++++ daemon/commands/msfilter-add-fmtp.cc | 19 +++++++++++++ daemon/commands/msfilter-add-fmtp.h | 19 +++++++++++++ daemon/commands/netsim.cc | 19 +++++++++++++ daemon/commands/netsim.h | 19 +++++++++++++ daemon/commands/play-wav.cc | 19 +++++++++++++ daemon/commands/play-wav.h | 19 +++++++++++++ daemon/commands/pop-event.cc | 19 +++++++++++++ daemon/commands/pop-event.h | 19 +++++++++++++ daemon/commands/port.cc | 19 +++++++++++++ daemon/commands/port.h | 19 +++++++++++++ daemon/commands/ptime.cc | 19 +++++++++++++ daemon/commands/ptime.h | 19 +++++++++++++ daemon/commands/quit.cc | 19 +++++++++++++ daemon/commands/quit.h | 19 +++++++++++++ daemon/commands/register-status.cc | 19 +++++++++++++ daemon/commands/register-status.h | 19 +++++++++++++ daemon/commands/register.cc | 19 +++++++++++++ daemon/commands/register.h | 19 +++++++++++++ daemon/commands/terminate.cc | 19 +++++++++++++ daemon/commands/terminate.h | 19 +++++++++++++ daemon/commands/unregister.cc | 19 +++++++++++++ daemon/commands/unregister.h | 19 +++++++++++++ daemon/commands/version.cc | 19 +++++++++++++ daemon/commands/version.h | 19 +++++++++++++ daemon/commands/video.cc | 19 +++++++++++++ daemon/commands/video.h | 19 +++++++++++++ daemon/daemon-pipetest.c | 19 +++++++++++++ daemon/daemon.cc | 19 +++++++++++++ daemon/daemon.h | 19 +++++++++++++ 84 files changed, 1604 insertions(+) create mode 100644 daemon/commands/license.py diff --git a/daemon/commands/adaptive-jitter-compensation.cc b/daemon/commands/adaptive-jitter-compensation.cc index 949aa792d..8985a782e 100644 --- a/daemon/commands/adaptive-jitter-compensation.cc +++ b/daemon/commands/adaptive-jitter-compensation.cc @@ -1,3 +1,22 @@ +/* +adaptive-jitter-compensation.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "adaptive-jitter-compensation.h" using namespace std; diff --git a/daemon/commands/adaptive-jitter-compensation.h b/daemon/commands/adaptive-jitter-compensation.h index dc319b7c5..cfbe070dd 100644 --- a/daemon/commands/adaptive-jitter-compensation.h +++ b/daemon/commands/adaptive-jitter-compensation.h @@ -1,3 +1,22 @@ +/* +adaptive-jitter-compensation.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_ADAPTIVE_BUFFER_COMPENSATION_H_ #define COMMAND_ADAPTIVE_BUFFER_COMPENSATION_H_ diff --git a/daemon/commands/answer.cc b/daemon/commands/answer.cc index 943aa26fc..9c5da9f74 100644 --- a/daemon/commands/answer.cc +++ b/daemon/commands/answer.cc @@ -1,3 +1,22 @@ +/* +answer.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "answer.h" using namespace std; diff --git a/daemon/commands/answer.h b/daemon/commands/answer.h index 38e7e5e7a..a65c1bac7 100644 --- a/daemon/commands/answer.h +++ b/daemon/commands/answer.h @@ -1,3 +1,22 @@ +/* +answer.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_ANSWER_H_ #define COMMAND_ANSWER_H_ diff --git a/daemon/commands/audio-codec-get.cc b/daemon/commands/audio-codec-get.cc index 357525b05..01372da2c 100644 --- a/daemon/commands/audio-codec-get.cc +++ b/daemon/commands/audio-codec-get.cc @@ -1,3 +1,22 @@ +/* +audio-codec-get.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "audio-codec-get.h" using namespace std; diff --git a/daemon/commands/audio-codec-get.h b/daemon/commands/audio-codec-get.h index 14ff63d66..d298e6cf5 100644 --- a/daemon/commands/audio-codec-get.h +++ b/daemon/commands/audio-codec-get.h @@ -1,3 +1,22 @@ +/* +audio-codec-get.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_AUDIO_CODEC_GET_H_ #define COMMAND_AUDIO_CODEC_GET_H_ diff --git a/daemon/commands/audio-codec-move.cc b/daemon/commands/audio-codec-move.cc index 82816ac90..23f28b4ad 100644 --- a/daemon/commands/audio-codec-move.cc +++ b/daemon/commands/audio-codec-move.cc @@ -1,3 +1,22 @@ +/* +audio-codec-move.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "audio-codec-move.h" using namespace std; diff --git a/daemon/commands/audio-codec-move.h b/daemon/commands/audio-codec-move.h index ce299dd9b..eab54d677 100644 --- a/daemon/commands/audio-codec-move.h +++ b/daemon/commands/audio-codec-move.h @@ -1,3 +1,22 @@ +/* +audio-codec-move.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_AUDIO_CODEC_MOVE_H_ #define COMMAND_AUDIO_CODEC_MOVE_H_ diff --git a/daemon/commands/audio-codec-set.cc b/daemon/commands/audio-codec-set.cc index 2dffe2cd5..3b893d4ef 100644 --- a/daemon/commands/audio-codec-set.cc +++ b/daemon/commands/audio-codec-set.cc @@ -1,3 +1,22 @@ +/* +audio-codec-set.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "audio-codec-set.h" #include "private.h" diff --git a/daemon/commands/audio-codec-set.h b/daemon/commands/audio-codec-set.h index 1f5a07369..54025fb18 100644 --- a/daemon/commands/audio-codec-set.h +++ b/daemon/commands/audio-codec-set.h @@ -1,3 +1,22 @@ +/* +audio-codec-set.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_AUDIO_CODEC_SET_H_ #define COMMAND_AUDIO_CODEC_SET_H_ diff --git a/daemon/commands/audio-codec-toggle.cc b/daemon/commands/audio-codec-toggle.cc index 9b7b6beeb..ed5949b00 100644 --- a/daemon/commands/audio-codec-toggle.cc +++ b/daemon/commands/audio-codec-toggle.cc @@ -1,3 +1,22 @@ +/* +audio-codec-toggle.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "audio-codec-toggle.h" #include "audio-codec-get.h" diff --git a/daemon/commands/audio-codec-toggle.h b/daemon/commands/audio-codec-toggle.h index bce36dfa2..47c196e41 100644 --- a/daemon/commands/audio-codec-toggle.h +++ b/daemon/commands/audio-codec-toggle.h @@ -1,3 +1,22 @@ +/* +audio-codec-toggle.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_AUDIO_CODEC_TOGGLE_H_ #define COMMAND_AUDIO_CODEC_TOGGLE_H_ diff --git a/daemon/commands/audio-stream-start.cc b/daemon/commands/audio-stream-start.cc index e6b8bf8ba..a961d742e 100644 --- a/daemon/commands/audio-stream-start.cc +++ b/daemon/commands/audio-stream-start.cc @@ -1,3 +1,22 @@ +/* +audio-stream-start.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "audio-stream-start.h" #include "private.h" diff --git a/daemon/commands/audio-stream-start.h b/daemon/commands/audio-stream-start.h index e32f9192f..29372681d 100644 --- a/daemon/commands/audio-stream-start.h +++ b/daemon/commands/audio-stream-start.h @@ -1,3 +1,22 @@ +/* +audio-stream-start.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_AUDIO_STREAM_START_H_ #define COMMAND_AUDIO_STREAM_START_H_ diff --git a/daemon/commands/audio-stream-stats.cc b/daemon/commands/audio-stream-stats.cc index 8ec208301..93e51c36e 100644 --- a/daemon/commands/audio-stream-stats.cc +++ b/daemon/commands/audio-stream-stats.cc @@ -1,3 +1,22 @@ +/* +audio-stream-stats.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "audio-stream-stats.h" using namespace std; diff --git a/daemon/commands/audio-stream-stats.h b/daemon/commands/audio-stream-stats.h index c25746cd0..6e27e8d52 100644 --- a/daemon/commands/audio-stream-stats.h +++ b/daemon/commands/audio-stream-stats.h @@ -1,3 +1,22 @@ +/* +audio-stream-stats.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_AUDIO_STREAM_STATS_H_ #define COMMAND_AUDIO_STREAM_STATS_H_ diff --git a/daemon/commands/audio-stream-stop.cc b/daemon/commands/audio-stream-stop.cc index 69a1ec862..a1290a852 100644 --- a/daemon/commands/audio-stream-stop.cc +++ b/daemon/commands/audio-stream-stop.cc @@ -1,3 +1,22 @@ +/* +audio-stream-stop.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "audio-stream-stop.h" using namespace std; diff --git a/daemon/commands/audio-stream-stop.h b/daemon/commands/audio-stream-stop.h index 395e8d7c6..b885b0ff4 100644 --- a/daemon/commands/audio-stream-stop.h +++ b/daemon/commands/audio-stream-stop.h @@ -1,3 +1,22 @@ +/* +audio-stream-stop.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_AUDIO_STREAM_STOP_H_ #define COMMAND_AUDIO_STREAM_STOP_H_ diff --git a/daemon/commands/auth-infos-clear.cc b/daemon/commands/auth-infos-clear.cc index b39fe51e9..ec247daee 100644 --- a/daemon/commands/auth-infos-clear.cc +++ b/daemon/commands/auth-infos-clear.cc @@ -1,3 +1,22 @@ +/* +auth-infos-clear.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "auth-infos-clear.h" using namespace std; diff --git a/daemon/commands/auth-infos-clear.h b/daemon/commands/auth-infos-clear.h index a15861cd7..20a27afcd 100644 --- a/daemon/commands/auth-infos-clear.h +++ b/daemon/commands/auth-infos-clear.h @@ -1,3 +1,22 @@ +/* +auth-infos-clear.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_AUTH_INFOS_CLEAR_H_ #define COMMAND_AUTH_INFOS_CLEAR_H_ diff --git a/daemon/commands/call-mute.cc b/daemon/commands/call-mute.cc index 918552159..a244b4cf4 100644 --- a/daemon/commands/call-mute.cc +++ b/daemon/commands/call-mute.cc @@ -1,3 +1,22 @@ +/* +call-mute.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "call-mute.h" CallMute::CallMute() : diff --git a/daemon/commands/call-mute.h b/daemon/commands/call-mute.h index 193b59996..772c6cd0b 100644 --- a/daemon/commands/call-mute.h +++ b/daemon/commands/call-mute.h @@ -1,3 +1,22 @@ +/* +call-mute.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef CALLMUTE_H #define CALLMUTE_H diff --git a/daemon/commands/call-pause.cc b/daemon/commands/call-pause.cc index 24d722cdd..9bceb0ffc 100644 --- a/daemon/commands/call-pause.cc +++ b/daemon/commands/call-pause.cc @@ -1,3 +1,22 @@ +/* +call-pause.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "call-pause.h" CallPause::CallPause() : diff --git a/daemon/commands/call-pause.h b/daemon/commands/call-pause.h index 598eac2d5..0a52a0fb1 100644 --- a/daemon/commands/call-pause.h +++ b/daemon/commands/call-pause.h @@ -1,3 +1,22 @@ +/* +call-pause.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef CALLPAUSE_H #define CALLPAUSE_H diff --git a/daemon/commands/call-resume.cc b/daemon/commands/call-resume.cc index 31849fa42..43ceda8fd 100644 --- a/daemon/commands/call-resume.cc +++ b/daemon/commands/call-resume.cc @@ -1,3 +1,22 @@ +/* +call-resume.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "call-resume.h" CallResume::CallResume(): diff --git a/daemon/commands/call-resume.h b/daemon/commands/call-resume.h index e716d94d1..13824d584 100644 --- a/daemon/commands/call-resume.h +++ b/daemon/commands/call-resume.h @@ -1,3 +1,22 @@ +/* +call-resume.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef CALLRESUME_H #define CALLRESUME_H diff --git a/daemon/commands/call-stats.cc b/daemon/commands/call-stats.cc index 854e1714b..b239dfd75 100644 --- a/daemon/commands/call-stats.cc +++ b/daemon/commands/call-stats.cc @@ -1,3 +1,22 @@ +/* +call-stats.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "call-stats.h" using namespace std; diff --git a/daemon/commands/call-stats.h b/daemon/commands/call-stats.h index d03a3bcee..13b4370a3 100644 --- a/daemon/commands/call-stats.h +++ b/daemon/commands/call-stats.h @@ -1,3 +1,22 @@ +/* +call-stats.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_CALL_STATS_H_ #define COMMAND_CALL_STATS_H_ diff --git a/daemon/commands/call-status.cc b/daemon/commands/call-status.cc index 8587d99bd..675b160d8 100644 --- a/daemon/commands/call-status.cc +++ b/daemon/commands/call-status.cc @@ -1,3 +1,22 @@ +/* +call-status.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "call-status.h" using namespace std; diff --git a/daemon/commands/call-status.h b/daemon/commands/call-status.h index c59344939..b97551a93 100644 --- a/daemon/commands/call-status.h +++ b/daemon/commands/call-status.h @@ -1,3 +1,22 @@ +/* +call-status.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_CALL_STATUS_H_ #define COMMAND_CALL_STATUS_H_ diff --git a/daemon/commands/call-transfer.cc b/daemon/commands/call-transfer.cc index 2fdf7773e..17558f00d 100644 --- a/daemon/commands/call-transfer.cc +++ b/daemon/commands/call-transfer.cc @@ -1,3 +1,22 @@ +/* +call-transfer.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "call-transfer.h" CallTransfer::CallTransfer() : diff --git a/daemon/commands/call-transfer.h b/daemon/commands/call-transfer.h index 089a14fa9..1ff37952c 100644 --- a/daemon/commands/call-transfer.h +++ b/daemon/commands/call-transfer.h @@ -1,3 +1,22 @@ +/* +call-transfer.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef CALLTRANSFER_H #define CALLTRANSFER_H diff --git a/daemon/commands/call.cc b/daemon/commands/call.cc index 262dee8f5..f908b7f0b 100644 --- a/daemon/commands/call.cc +++ b/daemon/commands/call.cc @@ -1,3 +1,22 @@ +/* +call.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "call.h" using namespace std; diff --git a/daemon/commands/call.h b/daemon/commands/call.h index e46c409b4..5f0ea6b49 100644 --- a/daemon/commands/call.h +++ b/daemon/commands/call.h @@ -1,3 +1,22 @@ +/* +call.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_CALL_H_ #define COMMAND_CALL_H_ diff --git a/daemon/commands/cn.cc b/daemon/commands/cn.cc index 8f267fe78..d2eabad30 100644 --- a/daemon/commands/cn.cc +++ b/daemon/commands/cn.cc @@ -1,3 +1,22 @@ +/* +cn.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "cn.h" using namespace std; diff --git a/daemon/commands/cn.h b/daemon/commands/cn.h index 4e88e7899..b8ca19b88 100644 --- a/daemon/commands/cn.h +++ b/daemon/commands/cn.h @@ -1,3 +1,22 @@ +/* +cn.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_CN_H_ #define COMMAND_CN_H_ diff --git a/daemon/commands/conference.cc b/daemon/commands/conference.cc index c9664f598..c39c8515a 100644 --- a/daemon/commands/conference.cc +++ b/daemon/commands/conference.cc @@ -1,3 +1,22 @@ +/* +conference.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "conference.h" Conference::Conference() : diff --git a/daemon/commands/conference.h b/daemon/commands/conference.h index c430f43e5..e904e8792 100644 --- a/daemon/commands/conference.h +++ b/daemon/commands/conference.h @@ -1,3 +1,22 @@ +/* +conference.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMANDS_CONFERENCE_H #define COMMANDS_CONFERENCE_H diff --git a/daemon/commands/config.cc b/daemon/commands/config.cc index fa89bc8c3..385823256 100644 --- a/daemon/commands/config.cc +++ b/daemon/commands/config.cc @@ -1,3 +1,22 @@ +/* +config.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "configcommand.h" using namespace std; diff --git a/daemon/commands/configcommand.h b/daemon/commands/configcommand.h index 70327dbfc..5813f6735 100644 --- a/daemon/commands/configcommand.h +++ b/daemon/commands/configcommand.h @@ -1,3 +1,22 @@ +/* +configcommand.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_CONFIG_H_ #define COMMAND_CONFIG_H_ diff --git a/daemon/commands/contact.cc b/daemon/commands/contact.cc index 81872f579..b0b97f162 100644 --- a/daemon/commands/contact.cc +++ b/daemon/commands/contact.cc @@ -1,3 +1,22 @@ +/* +contact.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "contact.h" using namespace std; diff --git a/daemon/commands/contact.h b/daemon/commands/contact.h index 34879ae48..79a609bc8 100644 --- a/daemon/commands/contact.h +++ b/daemon/commands/contact.h @@ -1,3 +1,22 @@ +/* +contact.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_CONTACT_H_ #define COMMAND_CONTACT_H_ diff --git a/daemon/commands/dtmf.cc b/daemon/commands/dtmf.cc index 899ca8c5e..7d464f4de 100644 --- a/daemon/commands/dtmf.cc +++ b/daemon/commands/dtmf.cc @@ -1,3 +1,22 @@ +/* +dtmf.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "dtmf.h" using namespace std; diff --git a/daemon/commands/dtmf.h b/daemon/commands/dtmf.h index d1b6fc8cd..1af629457 100644 --- a/daemon/commands/dtmf.h +++ b/daemon/commands/dtmf.h @@ -1,3 +1,22 @@ +/* +dtmf.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_DTMF_H_ #define COMMAND_DTMF_H_ diff --git a/daemon/commands/firewall-policy.cc b/daemon/commands/firewall-policy.cc index e9bde0a9b..ae3a912b3 100644 --- a/daemon/commands/firewall-policy.cc +++ b/daemon/commands/firewall-policy.cc @@ -1,3 +1,22 @@ +/* +firewall-policy.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "firewall-policy.h" using namespace std; diff --git a/daemon/commands/firewall-policy.h b/daemon/commands/firewall-policy.h index 07fb63298..d90c78ecf 100644 --- a/daemon/commands/firewall-policy.h +++ b/daemon/commands/firewall-policy.h @@ -1,3 +1,22 @@ +/* +firewall-policy.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_FIREWALL_POLICY_H_ #define COMMAND_FIREWALL_POLICY_H_ diff --git a/daemon/commands/help.cc b/daemon/commands/help.cc index 23c08f523..329a96359 100644 --- a/daemon/commands/help.cc +++ b/daemon/commands/help.cc @@ -1,3 +1,22 @@ +/* +help.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "help.h" using namespace std; diff --git a/daemon/commands/help.h b/daemon/commands/help.h index 205240397..b6e1f966d 100644 --- a/daemon/commands/help.h +++ b/daemon/commands/help.h @@ -1,3 +1,22 @@ +/* +help.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_HELP_H_ #define COMMAND_HELP_H_ diff --git a/daemon/commands/ipv6.cc b/daemon/commands/ipv6.cc index 7682794a5..fc57cb531 100644 --- a/daemon/commands/ipv6.cc +++ b/daemon/commands/ipv6.cc @@ -1,3 +1,22 @@ +/* +ipv6.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "ipv6.h" using namespace std; diff --git a/daemon/commands/ipv6.h b/daemon/commands/ipv6.h index 591a3d7cb..61247cfc3 100644 --- a/daemon/commands/ipv6.h +++ b/daemon/commands/ipv6.h @@ -1,3 +1,22 @@ +/* +ipv6.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_IPV6_H_ #define COMMAND_IPV6_H_ diff --git a/daemon/commands/jitterbuffer.cc b/daemon/commands/jitterbuffer.cc index 155b6b234..be627a053 100644 --- a/daemon/commands/jitterbuffer.cc +++ b/daemon/commands/jitterbuffer.cc @@ -1,3 +1,22 @@ +/* +jitterbuffer.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "jitterbuffer.h" #include diff --git a/daemon/commands/jitterbuffer.h b/daemon/commands/jitterbuffer.h index 29e1ec03b..f63484b87 100644 --- a/daemon/commands/jitterbuffer.h +++ b/daemon/commands/jitterbuffer.h @@ -1,3 +1,22 @@ +/* +jitterbuffer.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_JITTER_SIZE_H_ #define COMMAND_JITTER_SIZE_H_ diff --git a/daemon/commands/license.py b/daemon/commands/license.py new file mode 100644 index 000000000..93eca687c --- /dev/null +++ b/daemon/commands/license.py @@ -0,0 +1,27 @@ +import glob, os + + +os.chdir("./") +for fichier in glob.glob("*.cc"): + print(fichier) + f = open(fichier) + text=f.read() + f.close() + seq = ["/*\n",fichier ,"\nCopyright (C) 2016 Belledonne Communications, Grenoble, France \n",\ + "\nThis library is free software; you can redistribute it and/or modify it\n",\ + "under the terms of the GNU Lesser General Public License as published by\n",\ + "the Free Software Foundation; either version 2.1 of the License, or (at\n",\ + "your option) any later version.\n",\ + "\nThis library is distributed in the hope that it will be useful, but WITHOUT\n",\ + "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n",\ + "FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public\nLicense for more details.\n",\ + "\nYou should have received a copy of the GNU Lesser General Public License\n",\ + "along with this library; if not, write to the Free Software Foundation," \ + "\nInc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n" \ + "*/\n\n"] + f = open(fichier,'wb') + f.seek(0) + line = f.writelines(seq) + f.write(text) + f.close() + diff --git a/daemon/commands/media-encryption.cc b/daemon/commands/media-encryption.cc index 6180790e4..f055053ce 100644 --- a/daemon/commands/media-encryption.cc +++ b/daemon/commands/media-encryption.cc @@ -1,3 +1,22 @@ +/* +media-encryption.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "media-encryption.h" using namespace std; diff --git a/daemon/commands/media-encryption.h b/daemon/commands/media-encryption.h index 09a13d88b..a15163829 100644 --- a/daemon/commands/media-encryption.h +++ b/daemon/commands/media-encryption.h @@ -1,3 +1,22 @@ +/* +media-encryption.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_MEDIA_ENCRYPTION_H_ #define COMMAND_MEDIA_ENCRYPTION_H_ diff --git a/daemon/commands/msfilter-add-fmtp.cc b/daemon/commands/msfilter-add-fmtp.cc index beb8aa84d..961aee825 100644 --- a/daemon/commands/msfilter-add-fmtp.cc +++ b/daemon/commands/msfilter-add-fmtp.cc @@ -1,3 +1,22 @@ +/* +msfilter-add-fmtp.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "msfilter-add-fmtp.h" #include #include diff --git a/daemon/commands/msfilter-add-fmtp.h b/daemon/commands/msfilter-add-fmtp.h index c7a5b01b5..0e92f7e21 100644 --- a/daemon/commands/msfilter-add-fmtp.h +++ b/daemon/commands/msfilter-add-fmtp.h @@ -1,3 +1,22 @@ +/* +msfilter-add-fmtp.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_MSFILTER_ADD_FMTP #define COMMAND_MSFILTER_ADD_FMTP diff --git a/daemon/commands/netsim.cc b/daemon/commands/netsim.cc index 6d0255317..204289ba4 100644 --- a/daemon/commands/netsim.cc +++ b/daemon/commands/netsim.cc @@ -1,3 +1,22 @@ +/* +netsim.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "netsim.h" using namespace std; diff --git a/daemon/commands/netsim.h b/daemon/commands/netsim.h index 55cfcbc76..b883b93dd 100644 --- a/daemon/commands/netsim.h +++ b/daemon/commands/netsim.h @@ -1,3 +1,22 @@ +/* +netsim.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_NETSIM_H_ #define COMMAND_NETSIM_H_ diff --git a/daemon/commands/play-wav.cc b/daemon/commands/play-wav.cc index 266341d65..18eae73e5 100644 --- a/daemon/commands/play-wav.cc +++ b/daemon/commands/play-wav.cc @@ -1,3 +1,22 @@ +/* +play-wav.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "play-wav.h" using namespace std; diff --git a/daemon/commands/play-wav.h b/daemon/commands/play-wav.h index a51832a71..30e947033 100644 --- a/daemon/commands/play-wav.h +++ b/daemon/commands/play-wav.h @@ -1,3 +1,22 @@ +/* +play-wav.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_PLAY_WAV_H_ #define COMMAND_PLAY_WAV_H_ diff --git a/daemon/commands/pop-event.cc b/daemon/commands/pop-event.cc index e9228a67d..2d2075497 100644 --- a/daemon/commands/pop-event.cc +++ b/daemon/commands/pop-event.cc @@ -1,3 +1,22 @@ +/* +pop-event.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "pop-event.h" using namespace std; diff --git a/daemon/commands/pop-event.h b/daemon/commands/pop-event.h index 17922803d..1a5fd581d 100644 --- a/daemon/commands/pop-event.h +++ b/daemon/commands/pop-event.h @@ -1,3 +1,22 @@ +/* +pop-event.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_POP_EVENT_H_ #define COMMAND_POP_EVENT_H_ diff --git a/daemon/commands/port.cc b/daemon/commands/port.cc index 0fd5f8e6f..1452c6157 100644 --- a/daemon/commands/port.cc +++ b/daemon/commands/port.cc @@ -1,3 +1,22 @@ +/* +port.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "port.h" using namespace std; diff --git a/daemon/commands/port.h b/daemon/commands/port.h index e2813970c..3618971dd 100644 --- a/daemon/commands/port.h +++ b/daemon/commands/port.h @@ -1,3 +1,22 @@ +/* +port.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_PORT_H_ #define COMMAND_PORT_H_ diff --git a/daemon/commands/ptime.cc b/daemon/commands/ptime.cc index 3931a7ccd..234bb8e46 100644 --- a/daemon/commands/ptime.cc +++ b/daemon/commands/ptime.cc @@ -1,3 +1,22 @@ +/* +ptime.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "ptime.h" using namespace std; diff --git a/daemon/commands/ptime.h b/daemon/commands/ptime.h index e07140296..18c59825b 100644 --- a/daemon/commands/ptime.h +++ b/daemon/commands/ptime.h @@ -1,3 +1,22 @@ +/* +ptime.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_PTIME_H_ #define COMMAND_PTIME_H_ diff --git a/daemon/commands/quit.cc b/daemon/commands/quit.cc index db07610df..8876e096d 100644 --- a/daemon/commands/quit.cc +++ b/daemon/commands/quit.cc @@ -1,3 +1,22 @@ +/* +quit.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "quit.h" using namespace std; diff --git a/daemon/commands/quit.h b/daemon/commands/quit.h index 7c0211fae..78e323e1f 100644 --- a/daemon/commands/quit.h +++ b/daemon/commands/quit.h @@ -1,3 +1,22 @@ +/* +quit.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_QUIT_H_ #define COMMAND_QUIT_H_ diff --git a/daemon/commands/register-status.cc b/daemon/commands/register-status.cc index 0c21eaac7..c50e49acb 100644 --- a/daemon/commands/register-status.cc +++ b/daemon/commands/register-status.cc @@ -1,3 +1,22 @@ +/* +register-status.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "register-status.h" using namespace std; diff --git a/daemon/commands/register-status.h b/daemon/commands/register-status.h index 31ce2a782..9af479580 100644 --- a/daemon/commands/register-status.h +++ b/daemon/commands/register-status.h @@ -1,3 +1,22 @@ +/* +register-status.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_REGISTER_STATUS_H_ #define COMMAND_REGISTER_STATUS_H_ diff --git a/daemon/commands/register.cc b/daemon/commands/register.cc index 7b99f4370..5ef151d73 100644 --- a/daemon/commands/register.cc +++ b/daemon/commands/register.cc @@ -1,3 +1,22 @@ +/* +register.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "register.h" #include "linphonecore.h" #include "private.h" diff --git a/daemon/commands/register.h b/daemon/commands/register.h index 916c0ab3e..73b990576 100644 --- a/daemon/commands/register.h +++ b/daemon/commands/register.h @@ -1,3 +1,22 @@ +/* +register.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_REGISTER_H_ #define COMMAND_REGISTER_H_ diff --git a/daemon/commands/terminate.cc b/daemon/commands/terminate.cc index eaea16cce..20630ed56 100644 --- a/daemon/commands/terminate.cc +++ b/daemon/commands/terminate.cc @@ -1,3 +1,22 @@ +/* +terminate.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "terminate.h" using namespace std; diff --git a/daemon/commands/terminate.h b/daemon/commands/terminate.h index cfa5556a7..93096acd6 100644 --- a/daemon/commands/terminate.h +++ b/daemon/commands/terminate.h @@ -1,3 +1,22 @@ +/* +terminate.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_TERMINATE_H_ #define COMMAND_TERMINATE_H_ diff --git a/daemon/commands/unregister.cc b/daemon/commands/unregister.cc index 60acb6b02..2b0852ece 100644 --- a/daemon/commands/unregister.cc +++ b/daemon/commands/unregister.cc @@ -1,3 +1,22 @@ +/* +unregister.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "unregister.h" using namespace std; diff --git a/daemon/commands/unregister.h b/daemon/commands/unregister.h index 85145c197..2c83c9137 100644 --- a/daemon/commands/unregister.h +++ b/daemon/commands/unregister.h @@ -1,3 +1,22 @@ +/* +unregister.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_UNREGISTER_H_ #define COMMAND_UNREGISTER_H_ diff --git a/daemon/commands/version.cc b/daemon/commands/version.cc index 285ee4167..f080a7dbd 100644 --- a/daemon/commands/version.cc +++ b/daemon/commands/version.cc @@ -1,3 +1,22 @@ +/* +version.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "version.h" using namespace std; diff --git a/daemon/commands/version.h b/daemon/commands/version.h index 492147448..f9cc7fee8 100644 --- a/daemon/commands/version.h +++ b/daemon/commands/version.h @@ -1,3 +1,22 @@ +/* +version.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef COMMAND_VERSION_H_ #define COMMAND_VERSION_H_ diff --git a/daemon/commands/video.cc b/daemon/commands/video.cc index a0e1dce61..78d5d50fd 100644 --- a/daemon/commands/video.cc +++ b/daemon/commands/video.cc @@ -1,3 +1,22 @@ +/* +video.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "commands/video.h" Video::Video() : diff --git a/daemon/commands/video.h b/daemon/commands/video.h index 05cd7e1eb..3fe9b07e9 100644 --- a/daemon/commands/video.h +++ b/daemon/commands/video.h @@ -1,3 +1,22 @@ +/* +video.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef CALLCAMERA_H #define CALLCAMERA_H diff --git a/daemon/daemon-pipetest.c b/daemon/daemon-pipetest.c index a67b8017f..970413662 100644 --- a/daemon/daemon-pipetest.c +++ b/daemon/daemon-pipetest.c @@ -1,3 +1,22 @@ +/* +daemon-pipetest.c +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #define _GNU_SOURCE #include diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 500759887..4d86cca35 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -1,3 +1,22 @@ +/* +daemon.cc +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include #include #include diff --git a/daemon/daemon.h b/daemon/daemon.h index 416877fa1..153c33c03 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -1,3 +1,22 @@ +/* +daemon.h +Copyright (C) 2016 Belledonne Communications, Grenoble, France + +This library is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or (at +your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #ifndef DAEMON_H_ #define DAEMON_H_ From c7b51b142b3cd1766ea023ae6258f1320aad075e Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Fri, 17 Jun 2016 16:04:24 +0200 Subject: [PATCH 104/124] Remove file committed by mistake. --- daemon/commands/license.py | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 daemon/commands/license.py diff --git a/daemon/commands/license.py b/daemon/commands/license.py deleted file mode 100644 index 93eca687c..000000000 --- a/daemon/commands/license.py +++ /dev/null @@ -1,27 +0,0 @@ -import glob, os - - -os.chdir("./") -for fichier in glob.glob("*.cc"): - print(fichier) - f = open(fichier) - text=f.read() - f.close() - seq = ["/*\n",fichier ,"\nCopyright (C) 2016 Belledonne Communications, Grenoble, France \n",\ - "\nThis library is free software; you can redistribute it and/or modify it\n",\ - "under the terms of the GNU Lesser General Public License as published by\n",\ - "the Free Software Foundation; either version 2.1 of the License, or (at\n",\ - "your option) any later version.\n",\ - "\nThis library is distributed in the hope that it will be useful, but WITHOUT\n",\ - "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n",\ - "FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public\nLicense for more details.\n",\ - "\nYou should have received a copy of the GNU Lesser General Public License\n",\ - "along with this library; if not, write to the Free Software Foundation," \ - "\nInc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n" \ - "*/\n\n"] - f = open(fichier,'wb') - f.seek(0) - line = f.writelines(seq) - f.write(text) - f.close() - From b890162ff10095589dde70daf310642854d31670 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Fri, 17 Jun 2016 16:16:20 +0200 Subject: [PATCH 105/124] Update mediastreamer2. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 5d1efd574..acdd30745 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 5d1efd57449513d402b52bcd646004a20b87a744 +Subproject commit acdd30745ad5c5f1e97edec4300c1a6448212a53 From 114bc713716fb42bf7eedf0609b704e2ccb70591 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 20 Jun 2016 13:12:21 +0200 Subject: [PATCH 106/124] Load the gnustl C++ library when loading the application. --- java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index 4b33bdf4b..11c59d1ad 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -41,6 +41,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { List cpuabis=Version.getCpuAbis(); boolean libLoaded=false; Throwable firstException=null; + System.loadLibrary("gnustl_shared"); for (String abi : cpuabis){ //android.util.Log.i("LinphoneCoreFactoryImpl","Trying to load liblinphone for " + abi); loadOptionalLibrary("ffmpeg-linphone-" + abi); From e81293ab4af60aa37c74d720b3f2da8f83d421e5 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 20 Jun 2016 13:12:21 +0200 Subject: [PATCH 107/124] Load the gnustl C++ library when loading the application. --- java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java index 4b33bdf4b..11c59d1ad 100644 --- a/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreFactoryImpl.java @@ -41,6 +41,7 @@ public class LinphoneCoreFactoryImpl extends LinphoneCoreFactory { List cpuabis=Version.getCpuAbis(); boolean libLoaded=false; Throwable firstException=null; + System.loadLibrary("gnustl_shared"); for (String abi : cpuabis){ //android.util.Log.i("LinphoneCoreFactoryImpl","Trying to load liblinphone for " + abi); loadOptionalLibrary("ffmpeg-linphone-" + abi); From 4f92fe40e8bbe1be32ab41aa74b2720695fb4d19 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Mon, 20 Jun 2016 14:53:17 +0200 Subject: [PATCH 108/124] Disable daemon build on Windows. TODO "fix daemon build on windows. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9e2d1fbe..1cec2f32a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ option(ENABLE_SHARED "Build shared library." YES) option(ENABLE_STATIC "Build static library." YES) option(ENABLE_CONSOLE_UI "Turn on or off compilation of console interface." YES) option(ENABLE_DATE "Use build date in internal version number." NO) -option(ENABLE_DAEMON "Enable the linphone daemon interface." YES) +cmake_dependent_option(ENABLE_DAEMON "Enable the linphone daemon interface." YES "NOT WIN32" NO) option(ENABLE_DOC "Enable documentation generation with Doxygen." YES) option(ENABLE_GTK_UI "Turn on or off compilation of gtk interface." YES) option(ENABLE_LDAP "Enable LDAP support." NO) From ef52735633a8e55e1f6a5552999f5a55499d6179 Mon Sep 17 00:00:00 2001 From: Sandrine Avakian Date: Tue, 21 Jun 2016 14:43:38 +0200 Subject: [PATCH 109/124] Fix windows compilation warnings. --- coreapi/linphone_tunnel.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/coreapi/linphone_tunnel.cc b/coreapi/linphone_tunnel.cc index c2ea6ee10..699de87b5 100644 --- a/coreapi/linphone_tunnel.cc +++ b/coreapi/linphone_tunnel.cc @@ -296,7 +296,7 @@ static void tunnelLogHandler(int level, const char *fmt, va_list l){ void linphone_tunnel_enable_logs_with_handler(LinphoneTunnel *tunnel, bool_t enabled, OrtpLogFunc logHandler){ tunnelOrtpLogHandler=logHandler; - bcTunnel(tunnel)->enableLogs(enabled, tunnelLogHandler); + bcTunnel(tunnel)->enableLogs(enabled == FALSE ? false : true, tunnelLogHandler); } void linphone_tunnel_set_http_proxy_auth_info(LinphoneTunnel *tunnel, const char* username,const char* passwd){ @@ -323,7 +323,7 @@ void linphone_tunnel_reconnect(LinphoneTunnel *tunnel){ } void linphone_tunnel_enable_sip(LinphoneTunnel *tunnel, bool_t enable) { - bcTunnel(tunnel)->tunnelizeSipPackets(enable); + bcTunnel(tunnel)->tunnelizeSipPackets(enable == FALSE ? false : true); lp_config_set_int(config(tunnel), "tunnel", "sip", (enable ? TRUE : FALSE)); } @@ -332,7 +332,7 @@ bool_t linphone_tunnel_sip_enabled(const LinphoneTunnel *tunnel) { } void linphone_tunnel_verify_server_certificate(LinphoneTunnel *tunnel, bool_t enable) { - bcTunnel(tunnel)->verifyServerCertificate(enable); + bcTunnel(tunnel)->verifyServerCertificate(enable == FALSE ? false : true); lp_config_set_int(config(tunnel), "tunnel", "verify_cert", (enable ? TRUE : FALSE)); } @@ -356,8 +356,10 @@ void linphone_tunnel_configure(LinphoneTunnel *tunnel){ linphone_tunnel_enable_logs_with_handler(tunnel,TRUE,my_ortp_logv); linphone_tunnel_load_config(tunnel); linphone_tunnel_enable_sip(tunnel, tunnelizeSIPPackets); - linphone_tunnel_set_mode(tunnel, mode); linphone_tunnel_verify_server_certificate(tunnel, tunnelVerifyServerCertificate); + /*Tunnel is started here if mode equals true*/ + linphone_tunnel_set_mode(tunnel, mode); + } /* Deprecated functions */ @@ -380,5 +382,5 @@ bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel) { } void linphone_tunnel_simulate_udp_loss(LinphoneTunnel *tunnel, bool_t enabled) { - bcTunnel(tunnel)->simulateUdpLoss(enabled); + bcTunnel(tunnel)->simulateUdpLoss(enabled == FALSE ? false : true); } From d25ee01e998708ff6040c4ea34931f989abab813 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 21 Jun 2016 17:14:48 +0200 Subject: [PATCH 110/124] Also clear the STUN server username when cleaning a NAT policy. --- coreapi/nat_policy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 6690c4751..cf3e11b9d 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -127,6 +127,7 @@ void linphone_nat_policy_clear(LinphoneNatPolicy *policy) { linphone_nat_policy_enable_ice(policy, FALSE); linphone_nat_policy_enable_upnp(policy, FALSE); linphone_nat_policy_set_stun_server(policy, NULL); + linphone_nat_policy_set_stun_server_username(policy, NULL); } bool_t linphone_nat_policy_stun_enabled(const LinphoneNatPolicy *policy) { From 01919efecc4dc731e000ca61c2515400dec03a11 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 22 Jun 2016 15:37:27 +0200 Subject: [PATCH 111/124] Fix crash in ICE when the tunnel is activated. --- coreapi/TunnelManager.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index 02fd650f1..2a5bfcde7 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -136,6 +136,8 @@ int TunnelManager::customRecvfrom(struct _RtpTransport *t, mblk_t *msg, int flag int err=((TunnelSocket*)t->data)->recvfrom(msg->b_wptr,msg->b_datap->db_lim-msg->b_datap->db_base,from,*fromlen); //to make ice happy inet_aton(((TunnelManager*)((TunnelSocket*)t->data)->getUserPointer())->mLocalAddr,&msg->recv_addr.addr.ipi_addr); + msg->recv_addr.family = AF_INET; + msg->recv_addr.port = htons((unsigned short)((TunnelSocket*)t->data)->getPort()); if (err>0) return err; return 0; } From 747209c6138b1188e4653f524f54176ebf3a4a5d Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 22 Jun 2016 16:23:32 +0200 Subject: [PATCH 112/124] tester: fix compilation on iOS --- coreapi/linphonecore.c | 11 ++---- mediastreamer2 | 2 +- oRTP | 2 +- tester/CMakeLists.txt | 58 +++++++++++++++++++++++----- tester/liblinphone_tester_ios.m | 67 +++++++++++++++++++++++++++++++++ tester/marie_xml | 50 ------------------------ tester/tester.c | 2 + 7 files changed, 122 insertions(+), 70 deletions(-) create mode 100644 tester/liblinphone_tester_ios.m delete mode 100644 tester/marie_xml diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 1c5bf1f9d..001a83d09 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -882,10 +882,9 @@ static void sound_config_read(LinphoneCore *lc) linphone_core_set_sound_source(lc,tmpbuf[0]); */ - tmpbuf = get_default_local_ring(lc); - tmpbuf=lp_config_get_string(lc->config,"sound","local_ring",tmpbuf); - if (ortp_file_exist(tmpbuf)==-1) { - ms_warning("%s does not exist",tmpbuf); + tmpbuf=lp_config_get_string(lc->config,"sound","local_ring",NULL); + if (tmpbuf==NULL||ortp_file_exist(tmpbuf)!=0) { + if (tmpbuf) ms_warning("%s does not exist",tmpbuf); tmpbuf = get_default_local_ring(lc); } linphone_core_set_ring(lc,tmpbuf); @@ -1389,12 +1388,9 @@ static void video_config_read(LinphoneCore *lc){ #ifdef VIDEO_ENABLED int capture, display, self_view, reuse_source; int automatic_video=1; -#endif const char *str; -#ifdef VIDEO_ENABLED LinphoneVideoPolicy vpol; memset(&vpol, 0, sizeof(LinphoneVideoPolicy)); -#endif build_video_devices_table(lc); str=lp_config_get_string(lc->config,"video","device",NULL); @@ -1409,7 +1405,6 @@ static void video_config_read(LinphoneCore *lc){ linphone_core_set_preferred_framerate(lc,lp_config_get_float(lc->config,"video","framerate",0)); -#ifdef VIDEO_ENABLED #if defined(ANDROID) || defined(__ios) automatic_video=0; #endif diff --git a/mediastreamer2 b/mediastreamer2 index acdd30745..e7d1e3ca6 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit acdd30745ad5c5f1e97edec4300c1a6448212a53 +Subproject commit e7d1e3ca68df2d9d13c8aa813780b2074de15a96 diff --git a/oRTP b/oRTP index 3d4de2044..f07032474 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 3d4de2044c3a08e5eefe7e945e82b5e321a6eea1 +Subproject commit f070324740b210977e619e716feeb63df0a6d84e diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 992ec309d..10a2668f2 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -20,10 +20,38 @@ # ############################################################################ -file(GLOB SOURCE_FILES "*_tester.c") -list(APPEND SOURCE_FILES accountmanager.c tester.c) +if(ENABLE_STATIC) + set(LINPHONE_LIBS_FOR_TOOLS linphone-static) +else() + set(LINPHONE_LIBS_FOR_TOOLS linphone) +endif() + +set(RESOURCES_FILES + certificates + flexisip + images + local_tester_hosts + messages.db + rcfiles + sipp + sounds + tester_hosts + vcards +) + +file(GLOB SOURCE_FILES_C "*_tester.c") +list(APPEND SOURCE_FILES_C accountmanager.c tester.c) + +set(SOURCE_FILES_OBJC ) +if(APPLE) + if (IOS) + list(APPEND SOURCE_FILES_OBJC liblinphone_tester_ios.m) + endif() +endif() + +apply_compile_flags(SOURCE_FILES_C "CPP" "C") +apply_compile_flags(SOURCE_FILES_OBJC "CPP" "OBJC") -apply_compile_flags(SOURCE_FILES "CPP" "C") if(MSVC) get_source_file_property(MESSAGE_TESTER_C_COMPILE_FLAGS message_tester.c COMPILE_FLAGS) set(MESSAGE_TESTER_C_COMPILE_FLAGS "${MESSAGE_TESTER_C_COMPILE_FLAGS} /wd4996") # Disable "was declared deprecated" warnings @@ -42,13 +70,14 @@ if(NOT IOS OR NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") endif() endif() +# on mobile platforms, we compile the tester as a library so that we can link with it directly from native applications if(ANDROID OR IOS) if(ANDROID) - add_library(linphonetester SHARED ${SOURCE_FILES}) + add_library(linphonetester SHARED ${SOURCE_FILES_C}) set_target_properties(linphonetester PROPERTIES OUTPUT_NAME "linphonetester-${CMAKE_SYSTEM_PROCESSOR}") endif() if(IOS) - add_library(linphonetester STATIC ${SOURCE_FILES}) + add_library(linphonetester STATIC ${SOURCE_FILES_C}) endif() target_include_directories(linphonetester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS}) target_link_libraries(linphonetester linphone ${BCTOOLBOX_TESTER_LIBRARIES}) @@ -63,7 +92,7 @@ if(ANDROID OR IOS) PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") - add_library(linphone_tester_static STATIC ${SOURCE_FILES}) + add_library(linphone_tester_static STATIC ${SOURCE_FILES_C}) target_include_directories(linphone_tester_static PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS}) target_link_libraries(linphone_tester_static linphone ${BCTOOLBOX_TESTER_LIBRARIES}) @@ -91,15 +120,24 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) endif() -else() - add_executable(liblinphone_tester ${SOURCE_FILES}) +endif() + +# on iOS though, we also build the exectuable so that one can compile it from Xcode and run it directly +if (NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + if (IOS) + set_source_files_properties(${RESOURCES_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + add_executable(liblinphone_tester MACOSX_BUNDLE ${RESOURCES_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_OBJC}) + set_target_properties(liblinphone_tester PROPERTIES LINK_FLAGS "-framework CoreFoundation -framework AudioToolbox -framework CoreAudio -framework Foundation -framework QuartzCore -framework OpenGLES -framework UIKit -framework AVFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework VideoToolbox") + else() + add_executable(liblinphone_tester ${SOURCE_FILES_C} ${SOURCE_FILES_OBJC}) + endif() set_target_properties(liblinphone_tester PROPERTIES LINKER_LANGUAGE CXX) target_include_directories(liblinphone_tester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS}) - target_link_libraries(liblinphone_tester linphone ${BCTOOLBOX_TESTER_LIBRARIES}) + target_link_libraries(liblinphone_tester ${LINPHONE_LIBS_FOR_TOOLS} ${BCTOOLBOX_TESTER_LIBRARIES}) if (GTK2_FOUND) target_compile_definitions(liblinphone_tester PRIVATE HAVE_GTK) target_include_directories(liblinphone_tester PUBLIC ${GTK2_INCLUDE_DIRS}) - target_link_libraries(liblinphone_tester linphone ${GTK2_LIBRARIES}) + target_link_libraries(liblinphone_tester ${GTK2_LIBRARIES}) if(GTKMACINTEGRATION_FOUND) target_include_directories(liblinphone_tester PUBLIC ${GTKMACINTEGRATION_INCLUDE_DIRS}) target_link_libraries(liblinphone_tester ${GTKMACINTEGRATION_LIBRARIES}) diff --git a/tester/liblinphone_tester_ios.m b/tester/liblinphone_tester_ios.m new file mode 100644 index 000000000..60b53ee93 --- /dev/null +++ b/tester/liblinphone_tester_ios.m @@ -0,0 +1,67 @@ +/* + linphone library - modular sound and video processing and streaming + Copyright (C) 2006-2014 Belledonne Communications, Grenoble + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#if TARGET_OS_IPHONE + +#import +#import +#include +#include +#include "liblinphone_tester.h" + +int g_argc; +char** g_argv; +void stop_handler(int sig) { + return; +} + +static void* _apple_main(void* data) { + NSString *bundlePath = [[[NSBundle mainBundle] bundlePath] retain]; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentPath = [[paths objectAtIndex:0] retain]; + + NSLog(@"Bundle path: %@", bundlePath); + NSLog(@"Document path: %@", documentPath); + + bc_tester_set_resource_dir_prefix(bundlePath.UTF8String); + bc_tester_set_writable_dir_prefix(documentPath.UTF8String); + + liblinphone_tester_init(NULL); + bc_tester_start("toto"); + liblinphone_tester_uninit(); + + [bundlePath release]; + [documentPath release]; + return NULL; +} +int main(int argc, char * argv[]) { + pthread_t main_thread; + g_argc=argc; + g_argv=argv; + pthread_create(&main_thread,NULL,_apple_main,NULL); + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + int value = UIApplicationMain(0, nil, nil, nil); + [pool release]; + return value; + pthread_join(main_thread,NULL); + return 0; +} + + +#endif // target IPHONE diff --git a/tester/marie_xml b/tester/marie_xml deleted file mode 100644 index 5818930ba..000000000 --- a/tester/marie_xml +++ /dev/null @@ -1,50 +0,0 @@ - - -
- -1 - -1 - -1 - 0 - 0 - 0 - 1 -
-
- marie - marie - secret - sip.example.org -
-
- sip.example.org;transport=tcp - sip.example.org;transport=tcp;lr - sip:marie@sip.example.org - 3600 - 1 - 0 - 0 -
-
- "Paupoche" <sip:pauline@sip.example.org> - accept - 0 -
-
- 8070 - 9072 -
-
- 0 - 0 - 0 - vga - 0 - 0 - 0 - 0 - StaticImage: Static picture -
-
- 0 #to not overload cpu in case of VG -
-
diff --git a/tester/tester.c b/tester/tester.c index 3861cf421..342722b3a 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -156,7 +156,9 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c sal_enable_test_features(lc->sal,TRUE); sal_set_dns_user_hosts_file(lc->sal, dnsuserhostspath); +#ifdef VIDEO_ENABLED linphone_core_set_static_picture(lc,nowebcampath); +#endif ms_free(ringpath); ms_free(ringbackpath); From f0467be10c955924be1550a4c15c1516ae309f5b Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 22 Jun 2016 17:25:46 +0200 Subject: [PATCH 113/124] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index e7d1e3ca6..15e62e052 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit e7d1e3ca68df2d9d13c8aa813780b2074de15a96 +Subproject commit 15e62e05297c56f940f198b2f7be480c3437f4f4 From 2bfa0495b6d10d2b3bd14ffea26a8b940971c06a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 22 Jun 2016 18:47:40 +0200 Subject: [PATCH 114/124] Remove obsolete and no longer maintained Visual Studio projects. --- build/wince/liblinphone.sln | 48 -- build/wince/liblinphone.vcproj | 585 ------------------------- build/wince/linphonec/linphonec.vcproj | 240 ---------- 3 files changed, 873 deletions(-) delete mode 100644 build/wince/liblinphone.sln delete mode 100644 build/wince/liblinphone.vcproj delete mode 100644 build/wince/linphonec/linphonec.vcproj diff --git a/build/wince/liblinphone.sln b/build/wince/liblinphone.sln deleted file mode 100644 index fe4efff27..000000000 --- a/build/wince/liblinphone.sln +++ /dev/null @@ -1,48 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblinphone", "liblinphone.vcproj", "{290078F0-3B63-47BF-A2A9-E1AF5411F5E7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "linphonec", "linphonec\linphonec.vcproj", "{92574924-BF59-4DAA-994B-9978B80E5797}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|Windows Mobile 6 Professional SDK (ARMV4I) = Debug|Windows Mobile 6 Professional SDK (ARMV4I) - Debug|Windows Mobile 6 Standard SDK (ARMV4I) = Debug|Windows Mobile 6 Standard SDK (ARMV4I) - Release|Win32 = Release|Win32 - Release|Windows Mobile 6 Professional SDK (ARMV4I) = Release|Windows Mobile 6 Professional SDK (ARMV4I) - Release|Windows Mobile 6 Standard SDK (ARMV4I) = Release|Windows Mobile 6 Standard SDK (ARMV4I) - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Debug|Win32.ActiveCfg = Debug|Win32 - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Debug|Win32.Build.0 = Debug|Win32 - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 6 Professional SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Debug|Windows Mobile 6 Professional SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 6 Professional SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Debug|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 6 Standard SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Debug|Windows Mobile 6 Standard SDK (ARMV4I).Build.0 = Debug|Windows Mobile 6 Standard SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Debug|Windows Mobile 6 Standard SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 6 Standard SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Release|Win32.ActiveCfg = Release|Win32 - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Release|Win32.Build.0 = Release|Win32 - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Release|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 6 Professional SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Release|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Release|Windows Mobile 6 Professional SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Release|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 6 Professional SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Release|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 6 Standard SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Release|Windows Mobile 6 Standard SDK (ARMV4I).Build.0 = Release|Windows Mobile 6 Standard SDK (ARMV4I) - {290078F0-3B63-47BF-A2A9-E1AF5411F5E7}.Release|Windows Mobile 6 Standard SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 6 Standard SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Debug|Win32.ActiveCfg = Debug|Windows Mobile 6 Professional SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 6 Professional SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Debug|Windows Mobile 6 Professional SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Debug|Windows Mobile 6 Professional SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Debug|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Debug|Windows Mobile 6 Professional SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Release|Win32.ActiveCfg = Release|Windows Mobile 6 Professional SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Release|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 6 Professional SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Release|Windows Mobile 6 Professional SDK (ARMV4I).Build.0 = Release|Windows Mobile 6 Professional SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Release|Windows Mobile 6 Professional SDK (ARMV4I).Deploy.0 = Release|Windows Mobile 6 Professional SDK (ARMV4I) - {92574924-BF59-4DAA-994B-9978B80E5797}.Release|Windows Mobile 6 Standard SDK (ARMV4I).ActiveCfg = Release|Windows Mobile 6 Professional SDK (ARMV4I) - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/build/wince/liblinphone.vcproj b/build/wince/liblinphone.vcproj deleted file mode 100644 index 9909c8a1f..000000000 --- a/build/wince/liblinphone.vcproj +++ /dev/null @@ -1,585 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/wince/linphonec/linphonec.vcproj b/build/wince/linphonec/linphonec.vcproj deleted file mode 100644 index 058ce425c..000000000 --- a/build/wince/linphonec/linphonec.vcproj +++ /dev/null @@ -1,240 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 8c5539406a9382c2d5a626360b5000cd3258fa8d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 23 Jun 2016 13:24:55 +0200 Subject: [PATCH 115/124] Update ortp and ms2 submodules. --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 15e62e052..d939b4667 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 15e62e05297c56f940f198b2f7be480c3437f4f4 +Subproject commit d939b46679603f7e8adf1590ad9f932814aad897 diff --git a/oRTP b/oRTP index f07032474..6a8d5ab7c 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit f070324740b210977e619e716feeb63df0a6d84e +Subproject commit 6a8d5ab7cb5de50c76b5b06478b1594f28b6119f From 103f7a60788f1a67f582a5a41fd9e9aa9308e3b4 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 23 Jun 2016 13:25:11 +0200 Subject: [PATCH 116/124] Do not include dependencies in the link interface when building a shared library. --- console/CMakeLists.txt | 12 +++++++++--- coreapi/CMakeLists.txt | 2 +- gtk/CMakeLists.txt | 2 +- tester/CMakeLists.txt | 20 +++++++++++++++----- tools/CMakeLists.txt | 4 ++-- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/console/CMakeLists.txt b/console/CMakeLists.txt index 078b4ee40..92016c04a 100644 --- a/console/CMakeLists.txt +++ b/console/CMakeLists.txt @@ -37,15 +37,21 @@ if(MSVC) endif() add_executable(linphonec ${LINPHONEC_SOURCE_FILES}) -target_link_libraries(linphonec linphone) +target_link_libraries(linphonec linphone ${BCTOOLBOX_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) +if(INTL_FOUND) + target_link_libraries(linphonec ${INTL_LIBRARIES}) +endif() if(WIN32) add_executable(linphoned WIN32 ${LINPHONEC_SOURCE_FILES}) - target_link_libraries(linphoned linphone) + target_link_libraries(linphoned linphone ${BCTOOLBOX_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) + if(INTL_FOUND) + target_link_libraries(linphoned ${INTL_LIBRARIES}) + endif() endif() add_executable(linphonecsh ${LINPHONECSH_SOURCE_FILES}) -target_link_libraries(linphonecsh linphone) +target_link_libraries(linphonecsh linphone ${ORTP_LIBRARIES}) set(INSTALL_TARGETS linphonec linphonecsh) if(WIN32) diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index b2653469e..de85a6fe6 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -230,7 +230,7 @@ if(ENABLE_SHARED) set_target_properties(linphone PROPERTIES SOVERSION ${LINPHONE_SO_VERSION}) endif() add_dependencies(linphone liblinphone-git-version) - target_link_libraries(linphone ${LIBS}) + target_link_libraries(linphone PRIVATE ${LIBS}) if(WIN32 AND CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") set_target_properties(linphone PROPERTIES PREFIX "lib") elseif(ANDROID) diff --git a/gtk/CMakeLists.txt b/gtk/CMakeLists.txt index aa04fdcce..75064ea28 100644 --- a/gtk/CMakeLists.txt +++ b/gtk/CMakeLists.txt @@ -94,7 +94,7 @@ else() endif() set_target_properties(linphone-gtk PROPERTIES OUTPUT_NAME linphone LINKER_LANGUAGE CXX) target_include_directories(linphone-gtk PUBLIC ${GTK2_INCLUDE_DIRS} ${INTL_INCLUDE_DIRS}) -target_link_libraries(linphone-gtk linphone ${GTK2_LIBRARIES}) +target_link_libraries(linphone-gtk linphone ${GTK2_LIBRARIES} ${BCTOOLBOX_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) if(INTL_FOUND) target_link_libraries(linphone-gtk ${INTL_LIBRARIES}) endif() diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 10a2668f2..1ea1bf47f 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -21,9 +21,19 @@ ############################################################################ if(ENABLE_STATIC) - set(LINPHONE_LIBS_FOR_TOOLS linphone-static) + set(LINPHONE_LIBS_FOR_TESTER linphone-static) else() - set(LINPHONE_LIBS_FOR_TOOLS linphone) + set(LINPHONE_LIBS_FOR_TESTER linphone) +endif() +set(OTHER_LIBS_FOR_TESTER ${BCTOOLBOX_LIBRARIES} ${BCTOOLBOX_TESTER_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${BELLESIP_LIBRARIES} ${XML2_LIBRARIES}) +if(INTL_FOUND) + list(APPEND OTHER_LIBS_FOR_TESTER ${INTL_LIBRARIES}) +endif() +if(SQLITE3_FOUND) + list(APPEND OTHER_LIBS_FOR_TESTER ${SQLITE3_LIBRARIES}) +endif() +if(ZLIB_FOUND) + list(APPEND OTHER_LIBS_FOR_TESTER ${ZLIB_LIBRARIES}) endif() set(RESOURCES_FILES @@ -80,7 +90,7 @@ if(ANDROID OR IOS) add_library(linphonetester STATIC ${SOURCE_FILES_C}) endif() target_include_directories(linphonetester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS}) - target_link_libraries(linphonetester linphone ${BCTOOLBOX_TESTER_LIBRARIES}) + target_link_libraries(linphonetester linphone ${OTHER_LIBS_FOR_TESTER}) install(TARGETS linphonetester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -94,7 +104,7 @@ if(ANDROID OR IOS) elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") add_library(linphone_tester_static STATIC ${SOURCE_FILES_C}) target_include_directories(linphone_tester_static PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS}) - target_link_libraries(linphone_tester_static linphone ${BCTOOLBOX_TESTER_LIBRARIES}) + target_link_libraries(linphone_tester_static linphone ${OTHER_LIBS_FOR_TESTER}) set(RUNTIME_COMPONENT_SOURCES liblinphone_tester_windows.cpp @@ -133,7 +143,7 @@ if (NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") endif() set_target_properties(liblinphone_tester PROPERTIES LINKER_LANGUAGE CXX) target_include_directories(liblinphone_tester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS}) - target_link_libraries(liblinphone_tester ${LINPHONE_LIBS_FOR_TOOLS} ${BCTOOLBOX_TESTER_LIBRARIES}) + target_link_libraries(liblinphone_tester ${LINPHONE_LIBS_FOR_TESTER} ${OTHER_LIBS_FOR_TESTER}) if (GTK2_FOUND) target_compile_definitions(liblinphone_tester PRIVATE HAVE_GTK) target_include_directories(liblinphone_tester PUBLIC ${GTK2_INCLUDE_DIRS}) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 0a871aba5..0438c6eba 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -65,7 +65,7 @@ add_definitions( apply_compile_flags(LP_AUTO_ANSWER_SOURCE_FILES "CPP" "C") add_executable(lp-auto-answer ${LP_AUTO_ANSWER_SOURCE_FILES}) -target_link_libraries(lp-auto-answer linphone) +target_link_libraries(lp-auto-answer linphone ${BCTOOLBOX_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) install(TARGETS lp-auto-answer @@ -85,7 +85,7 @@ add_definitions( apply_compile_flags(LP_SENDMSG_SOURCE_FILES "CPP" "C") add_executable(lp-sendmsg ${LP_SENDMSG_SOURCE_FILES}) -target_link_libraries(lp-sendmsg linphone) +target_link_libraries(lp-sendmsg linphone ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) install(TARGETS lp-sendmsg From 6a56550a8182fc90b7de147dba117b57476ef7f6 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 23 Jun 2016 13:53:26 +0200 Subject: [PATCH 117/124] Fix build of daemon with CMake. --- daemon/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 8d2fbc8df..bdd7f6d6f 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -114,10 +114,10 @@ apply_compile_flags(DAEMON_PIPETEST_SOURCE_FILES "CPP" "C") add_executable(linphone-daemon ${DAEMON_SOURCE_FILES}) target_include_directories(linphone-daemon PRIVATE ${CMAKE_CURRENT_LIST_DIR}) -target_link_libraries(linphone-daemon linphone) +target_link_libraries(linphone-daemon linphone ${MEDIASTREAMER2_LIBRARIES}) add_executable(linphone-daemon-pipetest ${DAEMON_PIPETEST_SOURCE_FILES}) -target_link_libraries(linphone-daemon-pipetest linphone) +target_link_libraries(linphone-daemon-pipetest linphone ${ORTP_LIBRARIES}) set(INSTALL_TARGETS linphone-daemon linphone-daemon-pipetest) From 4384f08929dfa34be179e5222395d5d3526f1618 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 23 Jun 2016 14:39:28 +0200 Subject: [PATCH 118/124] Fix build with Visual Studio. --- console/shell.c | 1 + 1 file changed, 1 insertion(+) diff --git a/console/shell.c b/console/shell.c index 850446ab7..3427fa601 100644 --- a/console/shell.c +++ b/console/shell.c @@ -39,6 +39,7 @@ #endif #include "ortp/ortp.h" +#include #define DEFAULT_REPLY_SIZE 4096 From f87664d5b1fd1f798c7cc7893397d57a34c4084a Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 23 Jun 2016 15:34:01 +0200 Subject: [PATCH 119/124] fix compilation issue --- tester/message_tester.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tester/message_tester.c b/tester/message_tester.c index fa6f8002f..4aac88394 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -764,9 +764,6 @@ static void is_composing_notification(void) { linphone_core_manager_destroy(pauline); } - -#ifdef HAVE_LIME - static FILE* fopen_from_write_dir(const char * name, const char * mode) { char *filepath = bc_tester_file(name); FILE * file = fopen(filepath,mode); @@ -1132,9 +1129,6 @@ static void lime_unit(void) { xmlFreeDoc(cacheBufferBob); } - -#endif /* HAVE_LIME */ - #ifdef SQLITE_STORAGE_ENABLED /* @@ -1339,6 +1333,7 @@ end: ms_free(src_db); bc_free(tmp_db); } +#endif static void text_status_after_destroying_chat_room(void) { LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); @@ -1852,6 +1847,7 @@ test_t message_tests[] = { TEST_NO_TAG("Database migration", database_migration), TEST_NO_TAG("History range", history_range), TEST_NO_TAG("History count", history_count), +#endif TEST_NO_TAG("Text status after destroying chat room", text_status_after_destroying_chat_room), TEST_NO_TAG("Transfer not sent if invalid url", file_transfer_not_sent_if_invalid_url), TEST_NO_TAG("Transfer not sent if host not found", file_transfer_not_sent_if_host_not_found), From 70cfc3201b5649ae7b82bd375795091edf9c5774 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 23 Jun 2016 16:17:17 +0200 Subject: [PATCH 120/124] update mediastreamer2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index d939b4667..417a1bb88 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit d939b46679603f7e8adf1590ad9f932814aad897 +Subproject commit 417a1bb884dfb54758c82a5f642977ee99b1ba7b From 228859ce6b88b628877de3e5eb3e488ceace8c2c Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 23 Jun 2016 15:34:19 +0200 Subject: [PATCH 121/124] tools: enable them on iOS --- CMakeLists.txt | 5 ++ cmake/LinphoneConfig.cmake.in | 1 - tester/CMakeLists.txt | 13 ++---- tools/CMakeLists.txt | 87 +++++++++++++++-------------------- 4 files changed, 46 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cec2f32a..99860bbb0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,11 @@ macro(apply_compile_flags SOURCE_FILES) endif() endmacro() +if(ENABLE_STATIC) + set(LINPHONE_LIBS_FOR_TOOLS linphone-static) +else() + set(LINPHONE_LIBS_FOR_TOOLS linphone) +endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") diff --git a/cmake/LinphoneConfig.cmake.in b/cmake/LinphoneConfig.cmake.in index 8c9ef3944..89e2c87dd 100644 --- a/cmake/LinphoneConfig.cmake.in +++ b/cmake/LinphoneConfig.cmake.in @@ -57,7 +57,6 @@ if(@ENABLE_SHARED@) else() set(LINPHONE_LIBRARIES linphone-static) endif() -set(LINPHONE_LDFLAGS @LINK_FLAGS@) list(APPEND LINPHONE_INCLUDE_DIRS ${MEDIASTREAMER2_INCLUDE_DIRS} ${BELLESIP_INCLUDE_DIRS}) list(APPEND LINPHONE_LIBRARIES ${MEDIASTREAMER2_LIBRARIES} ${BELLESIP_LIBRARIES}) set(LINPHONE_CPPFLAGS "${MEDIASTREAMER2_CPPFLAGS}") diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 1ea1bf47f..401d1185e 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -20,11 +20,6 @@ # ############################################################################ -if(ENABLE_STATIC) - set(LINPHONE_LIBS_FOR_TESTER linphone-static) -else() - set(LINPHONE_LIBS_FOR_TESTER linphone) -endif() set(OTHER_LIBS_FOR_TESTER ${BCTOOLBOX_LIBRARIES} ${BCTOOLBOX_TESTER_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${BELLESIP_LIBRARIES} ${XML2_LIBRARIES}) if(INTL_FOUND) list(APPEND OTHER_LIBS_FOR_TESTER ${INTL_LIBRARIES}) @@ -90,7 +85,7 @@ if(ANDROID OR IOS) add_library(linphonetester STATIC ${SOURCE_FILES_C}) endif() target_include_directories(linphonetester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS}) - target_link_libraries(linphonetester linphone ${OTHER_LIBS_FOR_TESTER}) + target_link_libraries(linphonetester ${LINPHONE_LIBS_FOR_TOOLS} ${OTHER_LIBS_FOR_TESTER}) install(TARGETS linphonetester RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} @@ -104,7 +99,7 @@ if(ANDROID OR IOS) elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") add_library(linphone_tester_static STATIC ${SOURCE_FILES_C}) target_include_directories(linphone_tester_static PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS}) - target_link_libraries(linphone_tester_static linphone ${OTHER_LIBS_FOR_TESTER}) + target_link_libraries(linphone_tester_static ${LINPHONE_LIBS_FOR_TOOLS} ${OTHER_LIBS_FOR_TESTER}) set(RUNTIME_COMPONENT_SOURCES liblinphone_tester_windows.cpp @@ -137,13 +132,13 @@ if (NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") if (IOS) set_source_files_properties(${RESOURCES_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) add_executable(liblinphone_tester MACOSX_BUNDLE ${RESOURCES_FILES} ${SOURCE_FILES_C} ${SOURCE_FILES_OBJC}) - set_target_properties(liblinphone_tester PROPERTIES LINK_FLAGS "-framework CoreFoundation -framework AudioToolbox -framework CoreAudio -framework Foundation -framework QuartzCore -framework OpenGLES -framework UIKit -framework AVFoundation -framework CoreGraphics -framework CoreMedia -framework CoreVideo -framework VideoToolbox") + set_target_properties(liblinphone_tester PROPERTIES LINK_FLAGS "${MEDIASTREAMER2_LDFLAGS}") else() add_executable(liblinphone_tester ${SOURCE_FILES_C} ${SOURCE_FILES_OBJC}) endif() set_target_properties(liblinphone_tester PROPERTIES LINKER_LANGUAGE CXX) target_include_directories(liblinphone_tester PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS}) - target_link_libraries(liblinphone_tester ${LINPHONE_LIBS_FOR_TESTER} ${OTHER_LIBS_FOR_TESTER}) + target_link_libraries(liblinphone_tester ${LINPHONE_LIBS_FOR_TOOLS} ${OTHER_LIBS_FOR_TESTER}) if (GTK2_FOUND) target_compile_definitions(liblinphone_tester PRIVATE HAVE_GTK) target_include_directories(liblinphone_tester PUBLIC ${GTK2_INCLUDE_DIRS}) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 0438c6eba..71a3acea5 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -25,72 +25,59 @@ if(MSVC) find_library(LIBMINGWEX NAMES mingwex) endif() +set(USE_BUNDLE ) +if (IOS) + set(USE_BUNDLE MACOSX_BUNDLE) +endif() + set(LP_GEN_WRAPPERS_SOURCE_FILES generator.cc generator.hh genwrappers.cc software-desc.cc software-desc.hh -) - -add_definitions( - -DIN_LINPHONE -) + ) +add_definitions(-DIN_LINPHONE) set(LP_GEN_WRAPPERS_LIBS ${LIBGCC} ${LIBMINGWEX} ${XML2_LIBRARIES} -) + ) apply_compile_flags(LP_GEN_WRAPPERS_SOURCE_FILES "CPP" "CXX") -add_executable(lp-gen-wrappers ${LP_GEN_WRAPPERS_SOURCE_FILES}) +add_executable(lp-gen-wrappers ${USE_BUNDLE} ${LP_GEN_WRAPPERS_SOURCE_FILES}) target_link_libraries(lp-gen-wrappers ${LP_GEN_WRAPPERS_LIBS}) - -install(TARGETS lp-gen-wrappers - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE -) - -set(LP_AUTO_ANSWER_SOURCE_FILES - auto_answer.c -) - -add_definitions( - -DIN_LINPHONE -) - +set(LP_AUTO_ANSWER_SOURCE_FILES auto_answer.c) apply_compile_flags(LP_AUTO_ANSWER_SOURCE_FILES "CPP" "C") -add_executable(lp-auto-answer ${LP_AUTO_ANSWER_SOURCE_FILES}) -target_link_libraries(lp-auto-answer linphone ${BCTOOLBOX_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) - - -install(TARGETS lp-auto-answer - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE -) - -set(LP_SENDMSG_SOURCE_FILES - lpsendmsg.c -) - -add_definitions( - -DIN_LINPHONE -) +add_executable(lp-auto-answer ${USE_BUNDLE} ${LP_AUTO_ANSWER_SOURCE_FILES}) +target_link_libraries(lp-auto-answer ${LINPHONE_LIBS_FOR_TOOLS} ${MEDIASTREAMER2_LIBRARIES}) +set_target_properties(lp-auto-answer PROPERTIES LINK_FLAGS "${MEDIASTREAMER2_LDFLAGS}") +set(LP_SENDMSG_SOURCE_FILES lpsendmsg.c) apply_compile_flags(LP_SENDMSG_SOURCE_FILES "CPP" "C") -add_executable(lp-sendmsg ${LP_SENDMSG_SOURCE_FILES}) -target_link_libraries(lp-sendmsg linphone ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) +add_executable(lp-sendmsg ${USE_BUNDLE} ${LP_SENDMSG_SOURCE_FILES}) +target_link_libraries(lp-sendmsg ${LINPHONE_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) +set_target_properties(lp-sendmsg PROPERTIES LINK_FLAGS "${MEDIASTREAMER2_LDFLAGS}") - -install(TARGETS lp-sendmsg - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE -) +if (NOT IOS) + install(TARGETS lp-gen-wrappers + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + ) + install(TARGETS lp-auto-answer + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + ) + install(TARGETS lp-sendmsg + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + ) +endif() From 142d46586204c5f3bc70cad4da20ec865f60cf6f Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 23 Jun 2016 16:25:32 +0200 Subject: [PATCH 122/124] add lime stubbed functions --- coreapi/lime.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/coreapi/lime.c b/coreapi/lime.c index e182d7f40..7d4e1ab93 100644 --- a/coreapi/lime.c +++ b/coreapi/lime.c @@ -825,8 +825,18 @@ void lime_freeKeys(limeURIKeys_t *associatedKeys){ int lime_getCachedSndKeysByURI(xmlDocPtr cacheBuffer, limeURIKeys_t *associatedKeys){ return LIME_NOT_ENABLED; } - - +int lime_encryptMessage(limeKey_t *key, uint8_t *plainMessage, uint32_t messageLength, uint8_t selfZID[12], uint8_t *encryptedMessage) { + return LIME_NOT_ENABLED; +} +int lime_setCachedKey(xmlDocPtr cacheBuffer, limeKey_t *associatedKey, uint8_t role) { + return LIME_NOT_ENABLED; +} +int lime_getCachedRcvKeyByZid(xmlDocPtr cacheBuffer, limeKey_t *associatedKey) { + return LIME_NOT_ENABLED; +} +int lime_decryptMessage(limeKey_t *key, uint8_t *encryptedMessage, uint32_t messageLength, uint8_t selfZID[12], uint8_t *plainMessage) { + return LIME_NOT_ENABLED; +} #endif /* HAVE_LIME */ char *lime_error_code_to_string(int errorCode) { From 2c709541306d52b35a7a6fe17b4a7756e6d78e58 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 23 Jun 2016 17:55:20 +0200 Subject: [PATCH 123/124] avoid crash for tester: file_transfer_2_messages_simultaneously --- tester/message_tester.c | 68 +++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/tester/message_tester.c b/tester/message_tester.c index 4aac88394..0b9df872b 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -616,41 +616,43 @@ static void file_transfer_2_messages_simultaneously(void) { linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 0, int, "%d"); - linphone_chat_room_send_chat_message(pauline_room,msg); - linphone_chat_room_send_chat_message(pauline_room,msg2); - if (BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1))) { - msg = linphone_chat_message_clone(marie->stat.last_received_chat_message); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,2)); - msg2 = marie->stat.last_received_chat_message; - BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 1, int, "%d"); - if (bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)) != 1) { - char * buf = ms_strdup_printf("Found %d rooms instead of 1: ", bctbx_list_size(linphone_core_get_chat_rooms(marie->lc))); - const bctbx_list_t *it = linphone_core_get_chat_rooms(marie->lc); - while (it) { - const LinphoneAddress * peer = linphone_chat_room_get_peer_address(it->data); - buf = ms_strcat_printf("%s, ", linphone_address_get_username(peer)); - it = it->next; + if (bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)) == 0) { + linphone_chat_room_send_chat_message(pauline_room,msg); + linphone_chat_room_send_chat_message(pauline_room,msg2); + if (BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1))) { + msg = linphone_chat_message_clone(marie->stat.last_received_chat_message); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,2)); + msg2 = marie->stat.last_received_chat_message; + BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)), 1, int, "%d"); + if (bctbx_list_size(linphone_core_get_chat_rooms(marie->lc)) != 1) { + char * buf = ms_strdup_printf("Found %d rooms instead of 1: ", bctbx_list_size(linphone_core_get_chat_rooms(marie->lc))); + const bctbx_list_t *it = linphone_core_get_chat_rooms(marie->lc); + while (it) { + const LinphoneAddress * peer = linphone_chat_room_get_peer_address(it->data); + buf = ms_strcat_printf("%s, ", linphone_address_get_username(peer)); + it = it->next; + } + ms_error("%s", buf); } - ms_error("%s", buf); + + cbs = linphone_chat_message_get_callbacks(msg); + linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); + linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); + linphone_chat_message_download_file(msg); + + cbs = linphone_chat_message_get_callbacks(msg2); + linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); + linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); + linphone_chat_message_download_file(msg2); + + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,2)); + + BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,4, int, "%d"); + BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,2, int, "%d"); + compare_files(send_filepath, receive_filepath); + + linphone_chat_message_unref(msg); } - - cbs = linphone_chat_message_get_callbacks(msg); - linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); - linphone_chat_message_download_file(msg); - - cbs = linphone_chat_message_get_callbacks(msg2); - linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); - linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); - linphone_chat_message_download_file(msg2); - - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,2)); - - BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,4, int, "%d"); - BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,2, int, "%d"); - compare_files(send_filepath, receive_filepath); - - linphone_chat_message_unref(msg); } linphone_core_manager_destroy(pauline); ms_free(send_filepath); From 71b9fc8300a311969cc755345209c628617dccb5 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 23 Jun 2016 18:41:58 +0200 Subject: [PATCH 124/124] fix lime unitary test when lime is not available --- tester/message_tester.c | 330 ++++++++++++++++++++-------------------- 1 file changed, 167 insertions(+), 163 deletions(-) diff --git a/tester/message_tester.c b/tester/message_tester.c index 0b9df872b..abdf8edf2 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -965,170 +965,174 @@ static void printHex(char *title, uint8_t *data, size_t length) { } static void lime_unit(void) { - const char* PLAIN_TEXT_TEST_MESSAGE = "Ceci est un fabuleux msg de test à encrypter"; - int retval; - size_t size; - uint8_t *cacheBufferString; - xmlDocPtr cacheBufferAlice; - xmlDocPtr cacheBufferBob; - uint8_t *multipartMessage = NULL; - uint8_t *decryptedMessage = NULL; - xmlChar *xmlStringOutput; - int xmlStringLength; - limeURIKeys_t associatedKeys; - int i; - limeKey_t associatedKey; - uint8_t targetZID[12] = {0x00, 0x5d, 0xbe, 0x03, 0x99, 0x64, 0x3d, 0x95, 0x3a, 0x22, 0x02, 0xdd}; - uint8_t senderZID[12] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x70, 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0}; - uint8_t encryptedMessage[1024]; - uint8_t plainMessage[1024]; - uint8_t receiverZID[12]; - xmlDocPtr cacheBuffer; - FILE *CACHE; - - /**** Low level tests using on cache file to extract keys, encrypt/decrypt ****/ - /**** use functions that are not directly used by external entities ****/ - - /* create and load cache file */ - CACHE = fopen_from_write_dir("ZIDCache.xml", "wb"); - fprintf (CACHE, "\nef7692d0792a67491ae2d44e005dbe0399643d953a2202dd9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899pipo1@pipo.com963c57bb28e62068d2df23e8f9b771932d3c57bb28e62068d2df23e8f9b7719305d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b771935f9aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b7719302ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b7719300000069000001e8011234567889643d953a2202ee9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899pipo1@pipo.com123456789012345678901234567890123456765431262068d2df23e8f9b7719325d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b77193f69aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b7719322ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b77193000000010000000001"); - fclose(CACHE); - CACHE = fopen_from_write_dir("ZIDCache.xml", "rb+"); - cacheBufferString = (uint8_t*) ms_load_file_content(CACHE, &size); - *(cacheBufferString+size) = '\0'; - fclose(CACHE); - /* parse it to an xmlDoc */ - cacheBuffer = xmlParseDoc(cacheBufferString); - ms_free(cacheBufferString); - - /* get data from cache : sender */ - associatedKeys.peerURI = (uint8_t *)malloc(15); - memcpy(associatedKeys.peerURI, "pipo1@pipo.com", 15); - associatedKeys.associatedZIDNumber = 0; - retval = lime_getCachedSndKeysByURI(cacheBuffer, &associatedKeys); - BC_ASSERT_EQUAL(retval, 0, int, "%d"); - BC_ASSERT_EQUAL(associatedKeys.associatedZIDNumber, 2, int, "%d"); /* there are 2 keys associated to pipo1@pipo.com address in the cache above*/ - ms_message("Get cached key by URI, for sender, return %d keys", associatedKeys.associatedZIDNumber); - - for (i=0; ipeerZID, 12); - printHex("key", associatedKeys.peerKeys[i]->key, 32); - printHex("sessionID", associatedKeys.peerKeys[i]->sessionId, 32); - ms_message("session index %d\n", associatedKeys.peerKeys[i]->sessionIndex); + if (lime_is_available()) { + const char* PLAIN_TEXT_TEST_MESSAGE = "Ceci est un fabuleux msg de test à encrypter"; + int retval; + size_t size; + uint8_t *cacheBufferString; + xmlDocPtr cacheBufferAlice; + xmlDocPtr cacheBufferBob; + uint8_t *multipartMessage = NULL; + uint8_t *decryptedMessage = NULL; + xmlChar *xmlStringOutput; + int xmlStringLength; + limeURIKeys_t associatedKeys; + int i; + limeKey_t associatedKey; + uint8_t targetZID[12] = {0x00, 0x5d, 0xbe, 0x03, 0x99, 0x64, 0x3d, 0x95, 0x3a, 0x22, 0x02, 0xdd}; + uint8_t senderZID[12] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x70, 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0}; + uint8_t encryptedMessage[1024]; + uint8_t plainMessage[1024]; + uint8_t receiverZID[12]; + xmlDocPtr cacheBuffer; + FILE *CACHE; + + /**** Low level tests using on cache file to extract keys, encrypt/decrypt ****/ + /**** use functions that are not directly used by external entities ****/ + + /* create and load cache file */ + CACHE = fopen_from_write_dir("ZIDCache.xml", "wb"); + fprintf (CACHE, "\nef7692d0792a67491ae2d44e005dbe0399643d953a2202dd9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899pipo1@pipo.com963c57bb28e62068d2df23e8f9b771932d3c57bb28e62068d2df23e8f9b7719305d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b771935f9aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b7719302ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b7719300000069000001e8011234567889643d953a2202ee9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899pipo1@pipo.com123456789012345678901234567890123456765431262068d2df23e8f9b7719325d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b77193f69aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b7719322ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b77193000000010000000001"); + fclose(CACHE); + CACHE = fopen_from_write_dir("ZIDCache.xml", "rb+"); + cacheBufferString = (uint8_t*) ms_load_file_content(CACHE, &size); + *(cacheBufferString+size) = '\0'; + fclose(CACHE); + /* parse it to an xmlDoc */ + cacheBuffer = xmlParseDoc(cacheBufferString); + ms_free(cacheBufferString); + + /* get data from cache : sender */ + associatedKeys.peerURI = (uint8_t *)malloc(15); + memcpy(associatedKeys.peerURI, "pipo1@pipo.com", 15); + associatedKeys.associatedZIDNumber = 0; + retval = lime_getCachedSndKeysByURI(cacheBuffer, &associatedKeys); + BC_ASSERT_EQUAL(retval, 0, int, "%d"); + BC_ASSERT_EQUAL(associatedKeys.associatedZIDNumber, 2, int, "%d"); /* there are 2 keys associated to pipo1@pipo.com address in the cache above*/ + ms_message("Get cached key by URI, for sender, return %d keys", associatedKeys.associatedZIDNumber); + + for (i=0; ipeerZID, 12); + printHex("key", associatedKeys.peerKeys[i]->key, 32); + printHex("sessionID", associatedKeys.peerKeys[i]->sessionId, 32); + ms_message("session index %d\n", associatedKeys.peerKeys[i]->sessionIndex); + } + + /* get data from cache : receiver */ + memcpy(associatedKey.peerZID, targetZID, 12); + retval = lime_getCachedRcvKeyByZid(cacheBuffer, &associatedKey); + BC_ASSERT_EQUAL(retval, 0, int, "%d"); + printHex("Got receiver key for ZID", targetZID, 12); + printHex("Key", associatedKey.key, 32); + printHex("sessionID", associatedKey.sessionId, 32); + ms_message("session index %d\n", associatedKey.sessionIndex); + + /* encrypt/decrypt a msg */ + lime_encryptMessage(associatedKeys.peerKeys[0], (uint8_t *)PLAIN_TEXT_TEST_MESSAGE, strlen(PLAIN_TEXT_TEST_MESSAGE), senderZID, encryptedMessage); + printHex("Ciphered", encryptedMessage, strlen((char *)encryptedMessage)); + /* invert sender and receiverZID to decrypt/authenticate */ + memcpy(receiverZID, associatedKeys.peerKeys[0]->peerZID, 12); + memcpy(associatedKeys.peerKeys[0]->peerZID, senderZID, 12); + retval = lime_decryptMessage(associatedKeys.peerKeys[0], encryptedMessage, strlen(PLAIN_TEXT_TEST_MESSAGE)+16, receiverZID, plainMessage); + BC_ASSERT_EQUAL(retval, 0, int, "%d"); + BC_ASSERT_STRING_EQUAL((char *)plainMessage, (char *)PLAIN_TEXT_TEST_MESSAGE); + ms_message("Decrypt and auth returned %d\nPlain text is %s\n", retval, plainMessage); + + /* update receiver data */ + associatedKey.sessionIndex++; + associatedKey.key[0]++; + associatedKey.sessionId[0]++; + retval = lime_setCachedKey(cacheBuffer, &associatedKey, LIME_RECEIVER); + BC_ASSERT_EQUAL(retval, 0, int, "%d"); + + /* update sender data */ + associatedKeys.peerKeys[0]->sessionIndex++; + associatedKeys.peerKeys[0]->key[0]++; + associatedKeys.peerKeys[0]->sessionId[0]++; + retval = lime_setCachedKey(cacheBuffer, associatedKeys.peerKeys[0], LIME_SENDER); + BC_ASSERT_EQUAL(retval, 0, int, "%d"); + + /* free memory */ + lime_freeKeys(&associatedKeys); + + /* write the file */ + /* dump the xml document into a string */ + xmlDocDumpFormatMemoryEnc(cacheBuffer, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); + /* write it to the file */ + CACHE = fopen_from_write_dir("ZIDCache.xml", "w+"); + fwrite(xmlStringOutput, 1, xmlStringLength, CACHE); + xmlFree(xmlStringOutput); + fclose(CACHE); + xmlFreeDoc(cacheBuffer); + + /**** Higher level tests using 2 caches to encrypt/decrypt a msg ****/ + /* Create Alice cache file and then load it */ + CACHE = fopen_from_write_dir("ZIDCacheAlice.xml", "wb"); + fprintf(CACHE, "\nef7692d0792a67491ae2d44e005dbe0399643d953a2202dd9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899sip:pauline@sip.example.org9111ebeb52e50edcc6fcb3eea1a2d3ae3c2c75d3668923e83c59d0f47245515060f020a3fe11dc2cc0e1e8ed9341b4cd14944db806ca4fc95456bbe45d95c43a5f9aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b77193bcffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b7719300000080000001cf011234567889643d953a2202ee9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899sip:pauline@sip.example.org72d80ab1cad243cf45634980c1d02cfb2df81ce0dd5dfcf1ebeacfc5345a917625d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b77193f69aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b7719322ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b771930000000f00000000"); + fclose(CACHE); + CACHE = fopen_from_write_dir("ZIDCacheAlice.xml", "rb+"); + cacheBufferString = (uint8_t *)ms_load_file_content(CACHE, &size); + *(cacheBufferString+size) = '\0'; + fclose(CACHE); + /* parse it to an xmlDoc */ + cacheBufferAlice = xmlParseDoc(cacheBufferString); + ms_free(cacheBufferString); + + /* Create Bob cache file and then load it */ + CACHE = fopen_from_write_dir("ZIDCacheBob.xml", "wb"); + fprintf(CACHE, "\n005dbe0399643d953a2202ddef7692d0792a67491ae2d44e9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899sip:marie@sip.example.org9111ebeb52e50edcc6fcb3eea1a2d3ae3c2c75d3668923e83c59d0f47245515060f020a3fe11dc2cc0e1e8ed9341b4cd14944db806ca4fc95456bbe45d95c43a5f9aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b77193bcffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b7719300000080000001cf011234567889643d953a2202ee9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899sip:marie@sip.example.org81e6e6362c34dc974263d1f77cbb9a8d6d6a718330994379099a8fa19fb12faa25d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b77193f69aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b7719322ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b771930000002e0000000001"); + fclose(CACHE); + CACHE = fopen_from_write_dir("ZIDCacheBob.xml", "rb+"); + cacheBufferString = (uint8_t *)ms_load_file_content(CACHE, &size); + *(cacheBufferString+size) = '\0'; + fclose(CACHE); + /* parse it to an xmlDoc */ + cacheBufferBob = xmlParseDoc(cacheBufferString); + ms_free(cacheBufferString); + + + + /* encrypt a msg */ + retval = lime_createMultipartMessage(cacheBufferAlice, (uint8_t *)PLAIN_TEXT_TEST_MESSAGE, (uint8_t *)"sip:pauline@sip.example.org", &multipartMessage); + + BC_ASSERT_EQUAL(retval, 0, int, "%d"); + if (retval == 0) { + ms_message("Encrypted msg created is %s", multipartMessage); + } + + /* decrypt the multipart msg */ + retval = lime_decryptMultipartMessage(cacheBufferBob, multipartMessage, &decryptedMessage); + + BC_ASSERT_EQUAL(retval, 0, int, "%d"); + if (retval == 0) { + BC_ASSERT_STRING_EQUAL((char *)decryptedMessage, (char *)PLAIN_TEXT_TEST_MESSAGE); + ms_message("Succesfully decrypted msg is %s", decryptedMessage); + } + free(multipartMessage); + free(decryptedMessage); + + /* update ZID files */ + /* dump the xml document into a string */ + xmlDocDumpFormatMemoryEnc(cacheBufferAlice, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); + /* write it to the file */ + CACHE = fopen_from_write_dir("ZIDCacheAlice.xml", "wb+"); + fwrite(xmlStringOutput, 1, xmlStringLength, CACHE); + xmlFree(xmlStringOutput); + fclose(CACHE); + + xmlDocDumpFormatMemoryEnc(cacheBufferBob, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); + /* write it to the file */ + CACHE = fopen_from_write_dir("ZIDCacheBob.xml", "wb+"); + fwrite(xmlStringOutput, 1, xmlStringLength, CACHE); + xmlFree(xmlStringOutput); + fclose(CACHE); + + + xmlFreeDoc(cacheBufferAlice); + xmlFreeDoc(cacheBufferBob); + } else { + ms_warning("Lime not available, skiping"); } - - /* get data from cache : receiver */ - memcpy(associatedKey.peerZID, targetZID, 12); - retval = lime_getCachedRcvKeyByZid(cacheBuffer, &associatedKey); - BC_ASSERT_EQUAL(retval, 0, int, "%d"); - printHex("Got receiver key for ZID", targetZID, 12); - printHex("Key", associatedKey.key, 32); - printHex("sessionID", associatedKey.sessionId, 32); - ms_message("session index %d\n", associatedKey.sessionIndex); - - /* encrypt/decrypt a msg */ - lime_encryptMessage(associatedKeys.peerKeys[0], (uint8_t *)PLAIN_TEXT_TEST_MESSAGE, strlen(PLAIN_TEXT_TEST_MESSAGE), senderZID, encryptedMessage); - printHex("Ciphered", encryptedMessage, strlen((char *)encryptedMessage)); - /* invert sender and receiverZID to decrypt/authenticate */ - memcpy(receiverZID, associatedKeys.peerKeys[0]->peerZID, 12); - memcpy(associatedKeys.peerKeys[0]->peerZID, senderZID, 12); - retval = lime_decryptMessage(associatedKeys.peerKeys[0], encryptedMessage, strlen(PLAIN_TEXT_TEST_MESSAGE)+16, receiverZID, plainMessage); - BC_ASSERT_EQUAL(retval, 0, int, "%d"); - BC_ASSERT_STRING_EQUAL((char *)plainMessage, (char *)PLAIN_TEXT_TEST_MESSAGE); - ms_message("Decrypt and auth returned %d\nPlain text is %s\n", retval, plainMessage); - - /* update receiver data */ - associatedKey.sessionIndex++; - associatedKey.key[0]++; - associatedKey.sessionId[0]++; - retval = lime_setCachedKey(cacheBuffer, &associatedKey, LIME_RECEIVER); - BC_ASSERT_EQUAL(retval, 0, int, "%d"); - - /* update sender data */ - associatedKeys.peerKeys[0]->sessionIndex++; - associatedKeys.peerKeys[0]->key[0]++; - associatedKeys.peerKeys[0]->sessionId[0]++; - retval = lime_setCachedKey(cacheBuffer, associatedKeys.peerKeys[0], LIME_SENDER); - BC_ASSERT_EQUAL(retval, 0, int, "%d"); - - /* free memory */ - lime_freeKeys(&associatedKeys); - - /* write the file */ - /* dump the xml document into a string */ - xmlDocDumpFormatMemoryEnc(cacheBuffer, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); - /* write it to the file */ - CACHE = fopen_from_write_dir("ZIDCache.xml", "w+"); - fwrite(xmlStringOutput, 1, xmlStringLength, CACHE); - xmlFree(xmlStringOutput); - fclose(CACHE); - xmlFreeDoc(cacheBuffer); - - /**** Higher level tests using 2 caches to encrypt/decrypt a msg ****/ - /* Create Alice cache file and then load it */ - CACHE = fopen_from_write_dir("ZIDCacheAlice.xml", "wb"); - fprintf(CACHE, "\nef7692d0792a67491ae2d44e005dbe0399643d953a2202dd9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899sip:pauline@sip.example.org9111ebeb52e50edcc6fcb3eea1a2d3ae3c2c75d3668923e83c59d0f47245515060f020a3fe11dc2cc0e1e8ed9341b4cd14944db806ca4fc95456bbe45d95c43a5f9aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b77193bcffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b7719300000080000001cf011234567889643d953a2202ee9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899sip:pauline@sip.example.org72d80ab1cad243cf45634980c1d02cfb2df81ce0dd5dfcf1ebeacfc5345a917625d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b77193f69aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b7719322ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b771930000000f00000000"); - fclose(CACHE); - CACHE = fopen_from_write_dir("ZIDCacheAlice.xml", "rb+"); - cacheBufferString = (uint8_t *)ms_load_file_content(CACHE, &size); - *(cacheBufferString+size) = '\0'; - fclose(CACHE); - /* parse it to an xmlDoc */ - cacheBufferAlice = xmlParseDoc(cacheBufferString); - ms_free(cacheBufferString); - - /* Create Bob cache file and then load it */ - CACHE = fopen_from_write_dir("ZIDCacheBob.xml", "wb"); - fprintf(CACHE, "\n005dbe0399643d953a2202ddef7692d0792a67491ae2d44e9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899sip:marie@sip.example.org9111ebeb52e50edcc6fcb3eea1a2d3ae3c2c75d3668923e83c59d0f47245515060f020a3fe11dc2cc0e1e8ed9341b4cd14944db806ca4fc95456bbe45d95c43a5f9aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b77193bcffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b7719300000080000001cf011234567889643d953a2202ee9b5c8f06f3b6c2c695f2dfc3c26f31f5fef8661f8c5fe7c95aeb5c5b0435b045f8324dd18ea905171ec2be89f879d01d5994132048d92ea020778cbdf31c605e2fdcef69380937c2cf221f7d11526f286c39f49641452ba9012521c705094899sip:marie@sip.example.org81e6e6362c34dc974263d1f77cbb9a8d6d6a718330994379099a8fa19fb12faa25d9ac653a83c4559cb0ae7394e7cd3b2d3c57bb28e62068d2df23e8f9b77193f69aa1e5e4c7ec88fa389a9f6b8879b42d3c57bb28e62068d2df23e8f9b7719322ffd51e7316a6c6f53a50fcf01b01bf2d3c57bb28e62068d2df23e8f9b771930000002e0000000001"); - fclose(CACHE); - CACHE = fopen_from_write_dir("ZIDCacheBob.xml", "rb+"); - cacheBufferString = (uint8_t *)ms_load_file_content(CACHE, &size); - *(cacheBufferString+size) = '\0'; - fclose(CACHE); - /* parse it to an xmlDoc */ - cacheBufferBob = xmlParseDoc(cacheBufferString); - ms_free(cacheBufferString); - - - - /* encrypt a msg */ - retval = lime_createMultipartMessage(cacheBufferAlice, (uint8_t *)PLAIN_TEXT_TEST_MESSAGE, (uint8_t *)"sip:pauline@sip.example.org", &multipartMessage); - - BC_ASSERT_EQUAL(retval, 0, int, "%d"); - if (retval == 0) { - ms_message("Encrypted msg created is %s", multipartMessage); - } - - /* decrypt the multipart msg */ - retval = lime_decryptMultipartMessage(cacheBufferBob, multipartMessage, &decryptedMessage); - - BC_ASSERT_EQUAL(retval, 0, int, "%d"); - if (retval == 0) { - BC_ASSERT_STRING_EQUAL((char *)decryptedMessage, (char *)PLAIN_TEXT_TEST_MESSAGE); - ms_message("Succesfully decrypted msg is %s", decryptedMessage); - } - free(multipartMessage); - free(decryptedMessage); - - /* update ZID files */ - /* dump the xml document into a string */ - xmlDocDumpFormatMemoryEnc(cacheBufferAlice, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); - /* write it to the file */ - CACHE = fopen_from_write_dir("ZIDCacheAlice.xml", "wb+"); - fwrite(xmlStringOutput, 1, xmlStringLength, CACHE); - xmlFree(xmlStringOutput); - fclose(CACHE); - - xmlDocDumpFormatMemoryEnc(cacheBufferBob, &xmlStringOutput, &xmlStringLength, "UTF-8", 0); - /* write it to the file */ - CACHE = fopen_from_write_dir("ZIDCacheBob.xml", "wb+"); - fwrite(xmlStringOutput, 1, xmlStringLength, CACHE); - xmlFree(xmlStringOutput); - fclose(CACHE); - - - xmlFreeDoc(cacheBufferAlice); - xmlFreeDoc(cacheBufferBob); } #ifdef SQLITE_STORAGE_ENABLED