From 993050f05a59bb9906815d69f1a5f11639f7cc87 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 6 Jun 2016 11:56:55 +0200 Subject: [PATCH 01/37] 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 52090f148..39ebc0197 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1813,13 +1813,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 0a44f8a023fcec2c4dd0559c016aeac129209927 Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Mon, 6 Jun 2016 16:12:25 +0200 Subject: [PATCH 02/37] 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 39ebc0197..ffe8a36d0 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -918,17 +918,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 11306361e85df46ea46d67ba6bd350e11eeb1b8a Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Mon, 6 Jun 2016 16:32:40 +0200 Subject: [PATCH 03/37] 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 ffe8a36d0..3908ec3b9 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -917,13 +917,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 73e1013cc153f440e4ba0e9ca7e6a26ac8c02c40 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 7 Jun 2016 10:58:44 +0200 Subject: [PATCH 04/37] submodules: update ms2 and ortp --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 9dbf6cd97..05c196459 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 9dbf6cd9723f359b8b1bc0fe2a06a3de5100e2ad +Subproject commit 05c1964597789d17219ed01d6749fd95bf81d54e diff --git a/oRTP b/oRTP index d511e07b9..7612f40de 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit d511e07b937c22996dea1ee3f1449756d16597cb +Subproject commit 7612f40de599ebdde055290366281905904f902c From a37e897645be8716a7f2f0620cadcab49535ab0b Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 7 Jun 2016 12:00:46 +0200 Subject: [PATCH 05/37] 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 3908ec3b9..9815ed988 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -919,14 +919,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 2a6375dce40f987a5129838c4ab04f4dd7ad9dab Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 7 Jun 2016 13:58:42 +0200 Subject: [PATCH 06/37] 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 1cc34c2a6..2ef760ab3 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 98a67def3..643fd5031 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -6326,10 +6326,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), @@ -6343,6 +6373,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 b02861d6a..7dea47ed1 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 928cff4a2..9accb8719 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -451,6 +451,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 345aee27dc1a97c1561d79d356cb156d60af573b Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 7 Jun 2016 14:10:36 +0200 Subject: [PATCH 07/37] 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 9815ed988..07844e4e6 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -919,15 +919,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 6a82b0bd85253b0fe6259bae5ba14187f46c134f Mon Sep 17 00:00:00 2001 From: Erwan Croze Date: Tue, 7 Jun 2016 14:15:13 +0200 Subject: [PATCH 08/37] 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 07844e4e6..bec6f5d6e 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -927,7 +927,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 4acacb58437561a20ad517232bd246013226e434 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 3 Jun 2016 12:11:56 +0200 Subject: [PATCH 09/37] 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 643fd5031..a0e19d1d7 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); @@ -6369,6 +6416,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 dca7132fe4c07bc7fd62ebecbcd0efa576875c70 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 2 Jun 2016 17:09:24 +0200 Subject: [PATCH 10/37] 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 9accb8719..5e4414dd1 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); @@ -375,7 +375,11 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies if (linphone_core_get_stun_server(mgr->lc) != NULL){ /*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 a0affe66aba8b9b2b3bfa53127d87ebcb6fe4823 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 7 Jun 2016 15:45:53 +0200 Subject: [PATCH 11/37] 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 48a97b74502cdc2d05357a19a81cc592f613ec5d Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Wed, 8 Jun 2016 10:56:43 +0200 Subject: [PATCH 12/37] [Outgrade submodule] oRTP reverted to 0.27.0 to fix compil issue with rtpmodifiers --- oRTP | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oRTP b/oRTP index 7612f40de..171c441fa 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 7612f40de599ebdde055290366281905904f902c +Subproject commit 171c441fa7aa4cdc616461a88cad74fd842c6145 From 593bb0c1a634e8d98c7e381ee7c9b81945816d66 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 8 Jun 2016 11:23:37 +0200 Subject: [PATCH 13/37] 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 a0e19d1d7..0bef52f79 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 e5b846411071acb805367db0cb608acfa41d0e35 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 8 Jun 2016 11:45:28 +0200 Subject: [PATCH 14/37] enable ice when ipv6 is enabled but call is ipv4 --- coreapi/linphonecall.c | 2 +- tester/call_tester.c | 16 +++++++++ tester/flexisip/flexisip.conf | 2 +- tester/rcfiles/marie_nat64_rc | 4 +-- tester/rcfiles/marie_v4proxy_rc | 55 +++++++++++++++++++++++++++++++ tester/rcfiles/pauline_nat64_rc | 4 +-- tester/rcfiles/pauline_v4proxy_rc | 51 ++++++++++++++++++++++++++++ tester/tester_hosts | 4 +-- 8 files changed, 130 insertions(+), 8 deletions(-) create mode 100644 tester/rcfiles/marie_v4proxy_rc create mode 100644 tester/rcfiles/pauline_v4proxy_rc diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 2ef760ab3..bcd8d5995 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -626,7 +626,7 @@ static void transfer_already_assigned_payload_types(SalMediaDescription *old, Sa static const char *linphone_call_get_bind_ip_for_stream(LinphoneCall *call, int stream_index){ const char *bind_ip = lp_config_get_string(call->core->config,"rtp","bind_address", - linphone_core_ipv6_enabled(call->core) ? "::0" : "0.0.0.0"); + call->af == AF_INET6 ? "::0" : "0.0.0.0"); if (stream_index<2 && call->media_ports[stream_index].multicast_ip[0]!='\0'){ if (call->dir==LinphoneCallOutgoing){ diff --git a/tester/call_tester.c b/tester/call_tester.c index 0bef52f79..004af44cb 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -6406,6 +6406,21 @@ static void v6_call_over_nat_64(void){ }else ms_warning("Test skipped, no ipv6 nat64 available"); } +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*/ + liblinphonetester_ipv6=TRUE; + + LinphoneCoreManager* marie = linphone_core_manager_new("marie_v4proxy_rc"); + LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_v4proxy_rc"); + _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), @@ -6422,6 +6437,7 @@ test_t call_tests[] = { 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("Call with ICE in IPv4 with IPv6 enabled", call_with_ice_in_ipv4_with_v6_enabled), 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/flexisip/flexisip.conf b/tester/flexisip/flexisip.conf index 9aaceda2f..5ad6cb028 100644 --- a/tester/flexisip/flexisip.conf +++ b/tester/flexisip/flexisip.conf @@ -18,7 +18,7 @@ auto-respawn=true # List of white space separated host names pointing to this machine. # This is to prevent loops while routing SIP messages. # Default value: localhost -aliases=localhost sip2.linphone.org sipopen.example.org sip.example.org auth.example.org auth1.example.org auth2.example.org client.example.org +aliases=localhost sip2.linphone.org sipopen.example.org sip.example.org auth.example.org auth1.example.org auth2.example.org client.example.org sipv4.example.org sipv4-nat64.example.org # List of white space separated SIP uris where the proxy must listen.Wildcard # (*) can be used to mean 'all local ip addresses'. If 'transport' diff --git a/tester/rcfiles/marie_nat64_rc b/tester/rcfiles/marie_nat64_rc index a59516c72..58358b579 100644 --- a/tester/rcfiles/marie_nat64_rc +++ b/tester/rcfiles/marie_nat64_rc @@ -16,8 +16,8 @@ realm=sip.example.org [proxy_0] -reg_proxy=sipv4.example.org;transport=tcp -reg_route=sipv4.example.org;transport=tcp;lr +reg_proxy=sipv4-nat64.example.org;transport=tcp +reg_route=sipv4-nat64.example.org;transport=tcp;lr reg_identity="Super Marie" reg_expires=3600 reg_sendregister=1 diff --git a/tester/rcfiles/marie_v4proxy_rc b/tester/rcfiles/marie_v4proxy_rc new file mode 100644 index 000000000..a59516c72 --- /dev/null +++ b/tester/rcfiles/marie_v4proxy_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 index b2255c3c6..c90b6a363 100644 --- a/tester/rcfiles/pauline_nat64_rc +++ b/tester/rcfiles/pauline_nat64_rc @@ -15,8 +15,8 @@ realm=sip.example.org [proxy_0] -reg_proxy=sipv4.example.org;transport=tls -reg_route=sipv4.example.org;transport=tls +reg_proxy=sipv4-nat64.example.org;transport=tls +reg_route=sipv4-nat64.example.org;transport=tls reg_identity=sip:pauline@sip.example.org reg_expires=3600 reg_sendregister=1 diff --git a/tester/rcfiles/pauline_v4proxy_rc b/tester/rcfiles/pauline_v4proxy_rc new file mode 100644 index 000000000..b2255c3c6 --- /dev/null +++ b/tester/rcfiles/pauline_v4proxy_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_hosts b/tester/tester_hosts index 6416ddebc..686c42b88 100644 --- a/tester/tester_hosts +++ b/tester/tester_hosts @@ -1,4 +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 +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 sipv4.example.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 +64:ff9b::94.23.19.176 sipv4-nat64.example.org From d5928ad08c7505ff3922b854314bf88d40da663e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 9 Jun 2016 11:04:50 +0200 Subject: [PATCH 15/37] Fix tester compilation --- 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 004af44cb..3d894f6e4 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -6409,10 +6409,10 @@ 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*/ - liblinphonetester_ipv6=TRUE; - 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); From 9c3a3f32b72f0bbc5859e4f5317d0d161cca5896 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 8 Jun 2016 13:13:43 +0200 Subject: [PATCH 16/37] 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 bec6f5d6e..b5787b456 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1248,24 +1248,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 00236d147f2d154eb5397e615c4ca6a5593f191b Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 9 Jun 2016 11:19:37 +0200 Subject: [PATCH 17/37] 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 997c7f108..8af587b7b 100644 --- a/coreapi/message_storage.c +++ b/coreapi/message_storage.c @@ -128,7 +128,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) { @@ -144,6 +146,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; } @@ -266,13 +269,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); @@ -636,6 +641,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 d8158669f356262a93034645f2bb14829127bba4 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 9 Jun 2016 15:14:36 +0200 Subject: [PATCH 18/37] add tests for lime & file transfer --- coreapi/chat.c | 12 +++++++- coreapi/linphonecore.c | 3 ++ coreapi/linphonecore.h | 8 +++++- tester/message_tester.c | 64 ++++++++++++++++++++++++++++++----------- tester/tester.c | 14 ++++++--- 5 files changed, 78 insertions(+), 23 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index ac2e6e291..0279db9f5 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -385,7 +385,7 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage linphone_chat_room_upload_file(msg); } else { SalOp *op = NULL; - LinphoneCall *call; + LinphoneCall *call=NULL; char *content_type; const char *identity = NULL; msg->time = ms_time(0); @@ -460,6 +460,16 @@ void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage } linphone_chat_room_delete_composing_idle_timer(cr); linphone_chat_room_delete_composing_refresh_timer(cr); + + if (call && call->op == op) { + /*In this case, chat delivery status is not notified, so unrefing chat message right now*/ + /*Might be better fixed by delivering status, but too costly for now*/ + msg->chat_room->transient_messages = ms_list_remove(msg->chat_room->transient_messages, msg); + linphone_chat_message_unref(msg); + linphone_chat_message_unref(msg); + return; + } + } // if operation failed, we should not change message state diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b5787b456..057d2c272 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -7459,6 +7459,9 @@ void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path){ linphone_core_message_storage_init(lc); } } +const char* linphone_core_get_chat_database_path(const LinphoneCore *lc) { + return lc->chat_db_file; +} void linphone_core_enable_sdp_200_ack(LinphoneCore *lc, bool_t enable) { lp_config_set_int(lc->config,"sip","sdp_200_ack",lc->sip_conf.sdp_200_ack=enable); } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 9661b5d92..773c16877 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1299,7 +1299,13 @@ typedef void (*LinphoneChatMessageCbsFileTransferProgressIndicationCb)(LinphoneC LINPHONE_PUBLIC void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path); - +/** + * Get path to the database file used for storing chat messages. + * @param lc the linphone core + * @return file path or NULL if not exist + **/ + +LINPHONE_PUBLIC const char *linphone_core_get_chat_database_path(const LinphoneCore *lc); /** * Get a chat room whose peer is the supplied address. If it does not exist yet, it will be created. * No reference is transfered to the application. The LinphoneCore keeps a reference on the chat room. diff --git a/tester/message_tester.c b/tester/message_tester.c index 26c615e7c..5ada03f4e 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -774,6 +774,10 @@ static void lime_text_message(void) { 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; + } /* make sure lime is enabled */ linphone_core_enable_lime(marie->lc, 1); linphone_core_enable_lime(pauline->lc, 1); @@ -802,7 +806,7 @@ static void lime_text_message(void) { BC_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity)); /* TODO : check the msg arrived correctly deciphered */ - +end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -813,7 +817,11 @@ 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; + } /* make sure lime is enabled */ linphone_core_enable_lime(marie->lc, 0); linphone_core_enable_lime(pauline->lc, 1); @@ -835,10 +843,11 @@ static void lime_text_message_to_non_lime(void) { BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceivedLegacy,0, int, "%d"); BC_ASSERT_PTR_NOT_NULL(linphone_core_get_chat_room(marie->lc,pauline->identity)); +end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -void lime_transfer_message_base(bool_t encrypt_file) { +void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_stored_msg) { FILE *ZIDCacheMarieFD, *ZIDCachePaulineFD; LinphoneCoreManager *marie, *pauline; LinphoneChatMessage *msg; @@ -848,7 +857,11 @@ void lime_transfer_message_base(bool_t encrypt_file) { 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; + } /* make sure lime is enabled */ linphone_core_enable_lime(marie->lc, 1); linphone_core_enable_lime(pauline->lc, 1); @@ -886,26 +899,49 @@ void lime_transfer_message_base(bool_t encrypt_file) { linphone_chat_room_send_chat_message(msg->chat_room, msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1)); if (marie->stat.last_received_chat_message ) { - cbs = linphone_chat_message_get_callbacks(marie->stat.last_received_chat_message); + LinphoneChatMessage *recv_msg; + const LinphoneContent* content; + if (download_file_from_stored_msg) { + LinphoneChatRoom *marie_room = linphone_core_get_chat_room(marie->lc, pauline->identity); + MSList * msgs = linphone_chat_room_get_history(marie_room,1); + BC_ASSERT_PTR_NOT_NULL(msgs); + if (!msgs) goto end; + recv_msg = (LinphoneChatMessage *)msgs->data; + ms_list_free(msgs); + } else { + recv_msg = marie->stat.last_received_chat_message; + } + cbs = linphone_chat_message_get_callbacks(recv_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(marie->stat.last_received_chat_message); + content = linphone_chat_message_get_file_transfer_information(recv_msg); + if (!content) goto end; + if (encrypt_file) + BC_ASSERT_PTR_NOT_NULL(linphone_content_get_key(content)); + else + BC_ASSERT_PTR_NULL(linphone_content_get_key(content)); + linphone_chat_message_download_file(recv_msg); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1)); } - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1)); BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,2, int, "%d"); // file transfer BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered,1, int, "%d"); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1, int, "%d"); +end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } static void lime_transfer_message(void) { - lime_transfer_message_base(TRUE); + lime_transfer_message_base(TRUE,FALSE); +} + +static void lime_transfer_message_from_history(void) { + lime_transfer_message_base(TRUE,TRUE); } static void lime_transfer_message_without_encryption(void) { - lime_transfer_message_base(FALSE); + lime_transfer_message_base(FALSE,FALSE); } static void printHex(char *title, uint8_t *data, uint32_t length) { @@ -1092,8 +1128,6 @@ static void lime_unit(void) { #endif /* HAVE_LIME */ -#ifdef MSG_STORAGE_ENABLED - /* * Copy file "from" to file "to". * Destination file is truncated if existing. @@ -1285,7 +1319,6 @@ static void history_count(void) { 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"); @@ -1759,7 +1792,7 @@ void file_transfer_with_http_proxy(void) { test_t message_tests[] = { TEST_NO_TAG("Text message", text_message), - TEST_ONE_TAG("Text message within call dialog", text_message_within_call_dialog, "LeaksMemory"), + TEST_NO_TAG("Text message within call dialog", text_message_within_call_dialog), TEST_NO_TAG("Text message with credentials from auth callback", text_message_with_credential_from_auth_callback), TEST_NO_TAG("Text message with privacy", text_message_with_privacy), TEST_NO_TAG("Text message compatibility mode", text_message_compatibility_mode), @@ -1778,18 +1811,15 @@ test_t message_tests[] = { TEST_NO_TAG("Info message", info_message), TEST_NO_TAG("Info message with body", info_message_with_body), TEST_NO_TAG("IsComposing notification", is_composing_notification), -#ifdef HAVE_LIME TEST_NO_TAG("Lime text message", lime_text_message), TEST_NO_TAG("Lime text message to non lime", lime_text_message_to_non_lime), TEST_NO_TAG("Lime transfer message", lime_transfer_message), + TEST_ONE_TAG("Lime transfer message from history", lime_transfer_message_from_history,"LeaksMemory"), 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 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_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"), diff --git a/tester/tester.c b/tester/tester.c index 5e4414dd1..e6d472918 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -117,6 +117,7 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c char *rootcapath = NULL; char *dnsuserhostspath = NULL; char *nowebcampath = NULL; + char *chatdb = NULL; if (path==NULL) path="."; @@ -134,8 +135,8 @@ 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 ) { lp_config_set_string(config, "sound", "remote_ring", ringbackpath); @@ -149,18 +150,22 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, c linphone_core_set_ringback(lc, ringbackpath); 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); sal_set_dns_user_hosts_file(lc->sal, dnsuserhostspath); linphone_core_set_static_picture(lc,nowebcampath); + linphone_core_set_chat_database_path(lc, chatdb); + ms_free(ringpath); ms_free(ringbackpath); ms_free(nowebcampath); ms_free(rootcapath); ms_free(dnsuserhostspath); + ms_free(chatdb); if( filepath ) ms_free(filepath); @@ -415,7 +420,7 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) { if (mgr->stat.last_received_info_message) linphone_info_message_destroy(mgr->stat.last_received_info_message); if (mgr->lc){ const char *record_file=linphone_core_get_record_file(mgr->lc); - + const char *chatdb = linphone_core_get_chat_database_path(mgr->lc); if (!liblinphone_tester_keep_record_files && record_file){ if ((bc_get_number_of_failures()-mgr->number_of_cunit_error_at_creation)>0) { ms_message ("Test has failed, keeping recorded file [%s]",record_file); @@ -424,6 +429,7 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) { } } linphone_core_destroy(mgr->lc); + if (chatdb) unlink(chatdb); } if (mgr->identity) { linphone_address_destroy(mgr->identity); From e374b6505f8840199d9e6fc2eafbd4e3776320c1 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 10 Jun 2016 16:45:01 +0200 Subject: [PATCH 19/37] 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 7efea0504c964c7c7ded4f38964de626d2bb0bd6 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 09:32:58 +0200 Subject: [PATCH 20/37] 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 865d08ffd1e2943ccb5b7be0f8eb1e835bf1ba3f Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 10 Jun 2016 23:27:42 +0200 Subject: [PATCH 21/37] 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 22/37] 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 23/37] 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 24/37] 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 25/37] 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 26/37] 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 a48fa8d01bbf847c544c2943fb3a7ee50fd0c9ad Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Mon, 13 Jun 2016 12:34:18 +0200 Subject: [PATCH 27/37] 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 28/37] 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 29/37] 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 30/37] 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 54767c23cc990b9aa65238ae3d295d93a8bf65d1 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 14 Jun 2016 10:34:59 +0200 Subject: [PATCH 31/37] 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 5aa18ce2f9f814a41799e10b666c1d39afa2c2e8 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 14 Jun 2016 11:10:00 +0200 Subject: [PATCH 32/37] 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 a93e4cc4e4ba28e984d55d595d16af372611025a Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 15 Jun 2016 10:35:17 +0200 Subject: [PATCH 33/37] 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 65e3ef2009d6f157841392f01b3216da609c8db6 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 15 Jun 2016 14:41:52 +0200 Subject: [PATCH 34/37] 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 35/37] 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 3b22e0f8b99ed2abee85c2bc1675992750cf86c9 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Fri, 17 Jun 2016 14:23:10 +0200 Subject: [PATCH 36/37] 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 e81293ab4af60aa37c74d720b3f2da8f83d421e5 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 20 Jun 2016 13:12:21 +0200 Subject: [PATCH 37/37] 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);