static void linphone_interpret_url_test(void) { LinphoneCoreVTable v_table; LinphoneCore* lc; const char* sips_address = "sips:[email protected]"; LinphoneAddress* address; LinphoneProxyConfig *proxy_config; char *tmp; memset ( &v_table,0,sizeof ( v_table ) ); lc = linphone_core_new ( &v_table,NULL,NULL,NULL ); BC_ASSERT_PTR_NOT_NULL_FATAL ( lc ); proxy_config =linphone_core_create_proxy_config(lc); linphone_proxy_config_set_identity(proxy_config, "sip:[email protected]"); linphone_proxy_config_enable_register(proxy_config, FALSE); linphone_proxy_config_set_server_addr(proxy_config,"sip:sip.linphone.org"); linphone_core_add_proxy_config(lc, proxy_config); linphone_core_set_default_proxy_config(lc,proxy_config); linphone_proxy_config_unref(proxy_config); address = linphone_core_interpret_url(lc, sips_address); BC_ASSERT_PTR_NOT_NULL_FATAL(address); BC_ASSERT_STRING_EQUAL_FATAL(linphone_address_get_scheme(address), "sips"); BC_ASSERT_STRING_EQUAL_FATAL(linphone_address_get_username(address), "margaux"); BC_ASSERT_STRING_EQUAL_FATAL(linphone_address_get_domain(address), "sip.linphone.org"); linphone_address_destroy(address); address = linphone_core_interpret_url(lc,"23"); BC_ASSERT_PTR_NOT_NULL(address); BC_ASSERT_STRING_EQUAL(linphone_address_get_scheme(address), "sip"); BC_ASSERT_STRING_EQUAL(linphone_address_get_username(address), "23"); BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(address), "sip.linphone.org"); linphone_address_destroy(address); address = linphone_core_interpret_url(lc,"#24"); BC_ASSERT_PTR_NOT_NULL(address); BC_ASSERT_STRING_EQUAL(linphone_address_get_scheme(address), "sip"); BC_ASSERT_STRING_EQUAL(linphone_address_get_username(address), "#24"); BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(address), "sip.linphone.org"); tmp = linphone_address_as_string(address); BC_ASSERT_TRUE(strcmp (tmp,"sip:%[email protected]") == 0); linphone_address_destroy(address); address = linphone_core_interpret_url(lc,tmp); BC_ASSERT_STRING_EQUAL(linphone_address_get_scheme(address), "sip"); BC_ASSERT_STRING_EQUAL(linphone_address_get_username(address), "#24"); BC_ASSERT_STRING_EQUAL(linphone_address_get_domain(address), "sip.linphone.org"); linphone_address_destroy(address); ms_free(tmp); linphone_core_destroy (lc); }
static void carddav_sync(void) { LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE); LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); LinphoneCardDavContext *c = NULL; linphone_friend_list_set_uri(lfl, CARDDAV_SERVER); linphone_core_add_friend_list(manager->lc, lfl); linphone_friend_list_unref(lfl); c = linphone_carddav_context_new(lfl); BC_ASSERT_PTR_NOT_NULL_FATAL(c); linphone_carddav_set_user_data(c, stats); linphone_carddav_set_synchronization_done_callback(c, carddav_sync_done); linphone_carddav_set_new_contact_callback(c, carddav_new_contact); linphone_carddav_set_removed_contact_callback(c, carddav_removed_contact); linphone_carddav_set_updated_contact_callback(c, carddav_updated_contact); linphone_carddav_synchronize(c); wait_for_until(manager->lc, NULL, &stats->new_contact_count, 1, 5000); BC_ASSERT_EQUAL(stats->new_contact_count, 1, int, "%i"); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); ms_free(stats); linphone_carddav_context_destroy(c); linphone_core_manager_destroy(manager); }
static void carddav_sync_4(void) { LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE); LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); LinphoneCardDavContext *c = NULL; linphone_friend_list_set_uri(lfl, CARDDAV_SERVER); linphone_core_add_friend_list(manager->lc, lfl); linphone_friend_list_unref(lfl); c = linphone_carddav_context_new(lfl); BC_ASSERT_PTR_NOT_NULL_FATAL(c); linphone_carddav_set_user_data(c, stats); linphone_carddav_set_synchronization_done_callback(c, carddav_sync_done); linphone_carddav_set_new_contact_callback(c, carddav_new_contact); linphone_carddav_set_removed_contact_callback(c, carddav_removed_contact); linphone_carddav_set_updated_contact_callback(c, carddav_updated_contact); BC_ASSERT_PTR_NULL(linphone_vcard_get_uid(lvc)); linphone_carddav_put_vcard(c, lf); BC_ASSERT_PTR_NOT_NULL(linphone_vcard_get_uid(lvc)); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); linphone_carddav_delete_vcard(c, lf); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 2, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 2, int, "%i"); linphone_friend_unref(lf); ms_free(stats); linphone_carddav_context_destroy(c); linphone_core_manager_destroy(manager); }
static void core_sip_transport_test(void) { LinphoneCoreVTable v_table; LinphoneCore* lc; LCSipTransports tr; memset (&v_table,0,sizeof(v_table)); lc = linphone_core_new(&v_table,NULL,NULL,NULL); BC_ASSERT_PTR_NOT_NULL_FATAL(lc); linphone_core_get_sip_transports(lc,&tr); BC_ASSERT_EQUAL(tr.udp_port,5060, int, "%d"); /*default config*/ BC_ASSERT_EQUAL(tr.tcp_port,5060, int, "%d"); /*default config*/ tr.udp_port=LC_SIP_TRANSPORT_RANDOM; tr.tcp_port=LC_SIP_TRANSPORT_RANDOM; tr.tls_port=LC_SIP_TRANSPORT_RANDOM; linphone_core_set_sip_transports(lc,&tr); linphone_core_get_sip_transports(lc,&tr); BC_ASSERT_NOT_EQUAL(tr.udp_port,5060,int,"%d"); /*default config*/ BC_ASSERT_NOT_EQUAL(tr.tcp_port,5060,int,"%d"); /*default config*/ BC_ASSERT_EQUAL(lp_config_get_int(linphone_core_get_config(lc),"sip","sip_port",-2),LC_SIP_TRANSPORT_RANDOM, int, "%d"); BC_ASSERT_EQUAL(lp_config_get_int(linphone_core_get_config(lc),"sip","sip_tcp_port",-2),LC_SIP_TRANSPORT_RANDOM, int, "%d"); BC_ASSERT_EQUAL(lp_config_get_int(linphone_core_get_config(lc),"sip","sip_tls_port",-2),LC_SIP_TRANSPORT_RANDOM, int, "%d"); linphone_core_destroy(lc); }
static void client_process_response_event(void *obj, const belle_sip_response_event_t *event){ //belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event); endpoint_t* endpoint = (endpoint_t*)obj; int status = belle_sip_response_get_status_code(belle_sip_response_event_get_response(event)); belle_sip_message("caller_process_response_event [%i]",status); switch (status) { case 200: endpoint->stat.twoHundredOk++; if (endpoint->connection_family!=AF_UNSPEC){ const char *host; int family_found; belle_sip_header_contact_t *ct=belle_sip_message_get_header_by_type( (belle_sip_message_t*)belle_sip_response_event_get_response(event),belle_sip_header_contact_t); BC_ASSERT_PTR_NOT_NULL_FATAL(ct); host=belle_sip_uri_get_host(belle_sip_header_address_get_uri((belle_sip_header_address_t*)ct)); if (strchr(host,':')) family_found=AF_INET6; else family_found=AF_INET; BC_ASSERT_TRUE(family_found==endpoint->connection_family); } break; case 401:endpoint->stat.fourHundredOne++; break; default: break; } }
static void chat_root_test(void) { LinphoneCoreVTable v_table; LinphoneCore* lc; memset (&v_table,0,sizeof(v_table)); lc = linphone_core_new(&v_table,NULL,NULL,NULL); BC_ASSERT_PTR_NOT_NULL_FATAL(lc); linphone_core_create_chat_room(lc,"sip:[email protected]"); linphone_core_destroy(lc); }
/* Successful IPv6 AAAA query */ static void ipv6_aaaa_query(void) { struct addrinfo *ai; int timeout; endpoint_t *client; if (!belle_sip_tester_ipv6_available()){ belle_sip_warning("Test skipped, IPv6 connectivity not available."); return; } client = create_endpoint(); BC_ASSERT_PTR_NOT_NULL_FATAL(client); timeout = belle_sip_stack_get_dns_timeout(client->stack); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV6_SIP_DOMAIN, SIP_PORT, AF_INET6, a_resolve_done, client); BC_ASSERT_PTR_NOT_NULL(client->resolver_ctx); BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout)); BC_ASSERT_PTR_NOT_EQUAL(client->ai_list, NULL); if (client->ai_list) { struct addrinfo *next; struct sockaddr_in6 *sock_in6 = (struct sockaddr_in6 *)client->ai_list->ai_addr; int ntohsi = ntohs(sock_in6->sin6_port); BC_ASSERT_EQUAL(ntohsi, SIP_PORT, int, "%d"); /*the IPv6 address shall return first, and must be a real ipv6 address*/ BC_ASSERT_TRUE(client->ai_list->ai_family==AF_INET6); BC_ASSERT_FALSE(IN6_IS_ADDR_V4MAPPED(&sock_in6->sin6_addr)); ai = belle_sip_ip_address_to_addrinfo(AF_INET6, IPV6_SIP_IP, SIP_PORT); BC_ASSERT_PTR_NOT_NULL(ai); if (ai) { struct in6_addr *ipv6_address = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr; int i; for (i = 0; i < 8; i++) { BC_ASSERT_EQUAL(sock_in6->sin6_addr.s6_addr[i], ipv6_address->s6_addr[i], int, "%d"); } belle_sip_freeaddrinfo(ai); } next=client->ai_list->ai_next; BC_ASSERT_PTR_NOT_NULL(next); if (next){ int ntohsi = ntohs(sock_in6->sin6_port); sock_in6 = (struct sockaddr_in6 *)next->ai_addr; BC_ASSERT_TRUE(next->ai_family==AF_INET6); BC_ASSERT_TRUE(IN6_IS_ADDR_V4MAPPED(&sock_in6->sin6_addr)); BC_ASSERT_EQUAL(ntohsi, SIP_PORT, int, "%d"); ai = belle_sip_ip_address_to_addrinfo(AF_INET6, IPV6_SIP_IPV4, SIP_PORT); BC_ASSERT_PTR_NOT_NULL(ai); if (ai) { struct in6_addr *ipv6_address = &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr; int i; for (i = 0; i < 8; i++) { BC_ASSERT_EQUAL(sock_in6->sin6_addr.s6_addr[i], ipv6_address->s6_addr[i], int, "%d"); } belle_sip_freeaddrinfo(ai); } } } destroy_endpoint(client); }
static void core_init_test(void) { LinphoneCoreVTable v_table; LinphoneCore* lc; memset (&v_table,0,sizeof(v_table)); lc = linphone_core_new(&v_table,NULL,NULL,NULL); /* until we have good certificates on our test server... */ linphone_core_verify_server_certificates(lc,FALSE); BC_ASSERT_PTR_NOT_NULL_FATAL(lc); linphone_core_destroy(lc); }
/* IPv4 A query send failure */ static void ipv4_a_query_send_failure(void) { endpoint_t *client = create_endpoint(); BC_ASSERT_PTR_NOT_NULL_FATAL(client); belle_sip_stack_set_resolver_send_error(client->stack, -1); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV4_SIP_DOMAIN, SIP_PORT, AF_INET, a_resolve_done, client); BC_ASSERT_PTR_NULL(client->resolver_ctx); belle_sip_stack_set_resolver_send_error(client->stack, 0); destroy_endpoint(client); }
void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *eventname, const LinphoneContent *content){ LinphoneCoreManager *mgr; const char * ua = linphone_event_get_custom_header(lev, "User-Agent"); BC_ASSERT_PTR_NOT_NULL_FATAL(content); if (!linphone_content_is_multipart(content) && (!ua || !strstr(ua, "flexisip"))) { /*disable check for full presence serveur support*/ /*hack to disable content checking for list notify */ BC_ASSERT_STRING_EQUAL(notify_content,(const char*)linphone_content_get_buffer(content)); } mgr=get_manager(lc); mgr->stat.number_of_NotifyReceived++; }
static void caller_process_response_event(void *user_ctx, const belle_sip_response_event_t *event){ belle_sip_client_transaction_t* client_transaction = belle_sip_response_event_get_client_transaction(event); belle_sip_header_from_t* from=belle_sip_message_get_header_by_type(belle_sip_response_event_get_response(event),belle_sip_header_from_t); belle_sip_header_cseq_t* invite_cseq=belle_sip_message_get_header_by_type(belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(client_transaction)),belle_sip_header_cseq_t); belle_sip_request_t* ack; belle_sip_dialog_t* dialog; int status; if (!belle_sip_uri_equals(BELLE_SIP_URI(user_ctx),belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(from)))) { belle_sip_message("Message [%p] not for caller, skipping",belle_sip_response_event_get_response(event)); return; /*not for the caller*/ } status = belle_sip_response_get_status_code(belle_sip_response_event_get_response(event)); belle_sip_message("caller_process_response_event [%i]",status); BC_ASSERT_PTR_NOT_NULL_FATAL(client_transaction); dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(client_transaction)); BC_ASSERT_PTR_NOT_NULL_FATAL(dialog); BC_ASSERT_PTR_EQUAL(caller_dialog,dialog); if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_NULL) { BC_ASSERT_EQUAL(status,100, int, "%d"); } else if (belle_sip_dialog_get_state(dialog) == BELLE_SIP_DIALOG_EARLY){
LinphoneAddress * create_linphone_address(const char * domain) { LinphoneAddress *addr = linphone_address_new(NULL); BC_ASSERT_PTR_NOT_NULL_FATAL(addr); linphone_address_set_username(addr,test_username); BC_ASSERT_STRING_EQUAL(test_username,linphone_address_get_username(addr)); if (!domain) domain= test_route; linphone_address_set_domain(addr,domain); BC_ASSERT_STRING_EQUAL(domain,linphone_address_get_domain(addr)); linphone_address_set_display_name(addr, NULL); linphone_address_set_display_name(addr, "Mr Tester"); BC_ASSERT_STRING_EQUAL("Mr Tester",linphone_address_get_display_name(addr)); return addr; }
/* Successful IPv4 A query with no result */ static void ipv4_a_query_no_result(void) { int timeout; endpoint_t *client = create_endpoint(); BC_ASSERT_PTR_NOT_NULL_FATAL(client); timeout = belle_sip_stack_get_dns_timeout(client->stack); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV4_SIP_BAD_DOMAIN, SIP_PORT, AF_INET, a_resolve_done, client); BC_ASSERT_PTR_NOT_NULL(client->resolver_ctx); BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout)); BC_ASSERT_PTR_EQUAL(client->ai_list, NULL); destroy_endpoint(client); }
static void linphone_interpret_url_test() { LinphoneCoreVTable v_table; LinphoneCore* lc; const char* sips_address = "sips:[email protected]"; LinphoneAddress* address; memset ( &v_table,0,sizeof ( v_table ) ); lc = linphone_core_new ( &v_table,NULL,NULL,NULL ); BC_ASSERT_PTR_NOT_NULL_FATAL ( lc ); address = linphone_core_interpret_url(lc, sips_address); BC_ASSERT_PTR_NOT_NULL_FATAL(address); BC_ASSERT_STRING_EQUAL_FATAL(linphone_address_get_scheme(address), "sips"); BC_ASSERT_STRING_EQUAL_FATAL(linphone_address_get_username(address), "margaux"); BC_ASSERT_STRING_EQUAL_FATAL(linphone_address_get_domain(address), "sip.linphone.org"); linphone_address_destroy(address); linphone_core_destroy ( lc ); }
/* IPv4 A query timeout */ static void ipv4_a_query_timeout(void) { endpoint_t *client = create_endpoint(); BC_ASSERT_PTR_NOT_NULL_FATAL(client); belle_sip_stack_set_dns_timeout(client->stack, 0); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, "toto.com", SIP_PORT, AF_INET, a_resolve_done, client); BC_ASSERT_PTR_NOT_NULL(client->resolver_ctx); BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, 2000)); BC_ASSERT_PTR_EQUAL(client->ai_list, NULL); BC_ASSERT_EQUAL(client->resolve_ko,1, int, "%d"); destroy_endpoint(client); }
static void linphone_vcard_update_existing_friends_test(void) { LinphoneFriend *lf = linphone_friend_new_with_addr("sip:[email protected]"); BC_ASSERT_PTR_NOT_NULL_FATAL(lf); BC_ASSERT_PTR_NULL(linphone_friend_get_vcard(lf)); linphone_friend_edit(lf); linphone_friend_set_name(lf, "Old Friend"); linphone_friend_done(lf); BC_ASSERT_PTR_NOT_NULL(linphone_friend_get_vcard(lf)); BC_ASSERT_STRING_EQUAL(linphone_vcard_get_full_name(linphone_friend_get_vcard(lf)), "Old Friend"); linphone_friend_unref(lf); lf = NULL; }
/* Successful SRV query */ static void srv_query(void) { int timeout; endpoint_t *client = create_endpoint(); BC_ASSERT_PTR_NOT_NULL_FATAL(client); timeout = belle_sip_stack_get_dns_timeout(client->stack); client->resolver_ctx = belle_sip_stack_resolve_srv(client->stack, "udp", SRV_DOMAIN, srv_resolve_done, client); BC_ASSERT_PTR_NOT_NULL(client->resolver_ctx); BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout)); BC_ASSERT_PTR_NOT_NULL(client->srv_list); BC_ASSERT_NOT_EQUAL(belle_sip_list_size(client->srv_list), 0,int,"%d"); if (client->srv_list && (belle_sip_list_size(client->srv_list) > 0)) { belle_sip_dns_srv_t *result_srv = belle_sip_list_nth_data(client->srv_list, 0); BC_ASSERT_EQUAL(belle_sip_dns_srv_get_port(result_srv), SIP_PORT, int, "%d"); }
static void local_query(void) { int timeout; endpoint_t *client = create_endpoint(); BC_ASSERT_PTR_NOT_NULL_FATAL(client); timeout = belle_sip_stack_get_dns_timeout(client->stack); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, "localhost", SIP_PORT, AF_INET, a_resolve_done, client); BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout)); BC_ASSERT_PTR_NOT_EQUAL(client->ai_list, NULL); if (client->ai_list) { struct sockaddr_in *sock_in = (struct sockaddr_in *)client->ai_list->ai_addr; int ntohsi = (int)ntohs(sock_in->sin_port); BC_ASSERT_EQUAL(ntohsi, SIP_PORT, int, "%d"); } destroy_endpoint(client); }
static void caller_process_request_event(void *user_ctx, const belle_sip_request_event_t *event) { belle_sip_server_transaction_t* server_transaction; belle_sip_response_t* resp; belle_sip_dialog_t* dialog; belle_sip_header_to_t* to=belle_sip_message_get_header_by_type(belle_sip_request_event_get_request(event),belle_sip_header_to_t); if (!belle_sip_uri_equals(BELLE_SIP_URI(user_ctx),belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(to)))) { belle_sip_message("Message [%p] not for caller, skipping",belle_sip_request_event_get_request(event)); return; /*not for the caller*/ } belle_sip_message("caller_process_request_event received [%s] message",belle_sip_request_get_method(belle_sip_request_event_get_request(event))); server_transaction=belle_sip_provider_create_server_transaction(prov,belle_sip_request_event_get_request(event)); BC_ASSERT_STRING_EQUAL_FATAL("BYE",belle_sip_request_get_method(belle_sip_request_event_get_request(event))); dialog = belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(server_transaction)); BC_ASSERT_PTR_NOT_NULL_FATAL(dialog); BC_ASSERT_EQUAL(belle_sip_dialog_get_state(dialog) , BELLE_SIP_DIALOG_CONFIRMED, int, "%d"); resp=belle_sip_response_create_from_request(belle_sip_request_event_get_request(event),200); belle_sip_server_transaction_send_response(server_transaction,resp); }
static void ipv4_a_query_with_v4mapped_results(void) { int timeout; endpoint_t *client; if (!belle_sip_tester_ipv6_available()){ belle_sip_warning("Test skipped, IPv6 connectivity not available."); return; } client = create_endpoint(); BC_ASSERT_PTR_NOT_NULL_FATAL(client); timeout = belle_sip_stack_get_dns_timeout(client->stack); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV4_SIP_DOMAIN, SIP_PORT, AF_INET6, a_resolve_done, client); BC_ASSERT_PTR_NOT_NULL(client->resolver_ctx); BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout)); BC_ASSERT_PTR_NOT_NULL(client->ai_list); destroy_endpoint(client); }
static void carddav_sync_2(void) { LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE); LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); LinphoneFriend *lf = linphone_core_create_friend_with_address(manager->lc, "\"Sylvain\" <sip:[email protected]>"); char *friends_db = create_filepath(bc_tester_get_writable_dir_prefix(), "friends", "db"); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); LinphoneCardDavContext *c = NULL; linphone_friend_list_set_uri(lfl, CARDDAV_SERVER); linphone_core_add_friend_list(manager->lc, lfl); linphone_friend_list_unref(lfl); c = linphone_carddav_context_new(lfl); BC_ASSERT_PTR_NOT_NULL_FATAL(c); unlink(friends_db); linphone_core_set_friends_database_path(manager->lc, friends_db); BC_ASSERT_EQUAL_FATAL(linphone_friend_list_add_local_friend(lfl, lf), LinphoneFriendListOK, int, "%d"); linphone_friend_unref(lf); linphone_carddav_set_user_data(c, stats); linphone_carddav_set_synchronization_done_callback(c, carddav_sync_done); linphone_carddav_set_new_contact_callback(c, carddav_new_contact); linphone_carddav_set_removed_contact_callback(c, carddav_removed_contact); linphone_carddav_set_updated_contact_callback(c, carddav_updated_contact); linphone_carddav_synchronize(c); wait_for_until(manager->lc, NULL, &stats->new_contact_count, 1, 5000); BC_ASSERT_EQUAL(stats->new_contact_count, 1, int, "%i"); wait_for_until(manager->lc, NULL, &stats->removed_contact_count, 1, 5000); BC_ASSERT_EQUAL(stats->removed_contact_count, 1, int, "%i"); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); ms_free(stats); unlink(friends_db); ms_free(friends_db); linphone_carddav_context_destroy(c); linphone_core_manager_destroy(manager); }
static void carddav_sync_3(void) { LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE); LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1); LinphoneVcard *lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nFN:Sylvain Berfini\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n"); LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc); char *friends_db = create_filepath(bc_tester_get_writable_dir_prefix(), "friends", "db"); LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc); LinphoneCardDavContext *c = NULL; linphone_friend_list_set_uri(lfl, CARDDAV_SERVER); linphone_core_add_friend_list(manager->lc, lfl); linphone_friend_list_unref(lfl); c = linphone_carddav_context_new(lfl); BC_ASSERT_PTR_NOT_NULL_FATAL(c); unlink(friends_db); linphone_core_set_friends_database_path(manager->lc, friends_db); BC_ASSERT_EQUAL_FATAL(linphone_friend_list_add_local_friend(lfl, lf), LinphoneFriendListOK, int, "%d"); linphone_friend_unref(lf); linphone_carddav_set_user_data(c, stats); linphone_carddav_set_synchronization_done_callback(c, carddav_sync_done); linphone_carddav_set_new_contact_callback(c, carddav_new_contact); linphone_carddav_set_removed_contact_callback(c, carddav_removed_contact); linphone_carddav_set_updated_contact_callback(c, carddav_updated_contact); linphone_carddav_synchronize(c); wait_for_until(manager->lc, NULL, &stats->updated_contact_count, 1, 5000); BC_ASSERT_EQUAL(stats->updated_contact_count, 1, int, "%i"); wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000); BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i"); ms_free(stats); unlink(friends_db); ms_free(friends_db); linphone_carddav_context_destroy(c); c = NULL; linphone_core_manager_destroy(manager); }
/*This tests the recursion of dns.c*/ static void ipv4_cname_a_query(void) { struct addrinfo *ai; int timeout; endpoint_t *client = create_endpoint(); BC_ASSERT_PTR_NOT_NULL_FATAL(client); timeout = belle_sip_stack_get_dns_timeout(client->stack); client->resolver_ctx = belle_sip_stack_resolve_a(client->stack, IPV4_CNAME, SIP_PORT, AF_INET, a_resolve_done, client); BC_ASSERT_PTR_NOT_NULL(client->resolver_ctx); BC_ASSERT_TRUE(wait_for(client->stack, &client->resolve_done, 1, timeout)); BC_ASSERT_PTR_NOT_EQUAL(client->ai_list, NULL); if (client->ai_list) { struct sockaddr_in *sock_in = (struct sockaddr_in *)client->ai_list->ai_addr; int ntohsi = (int)ntohs(sock_in->sin_port); BC_ASSERT_EQUAL(ntohsi, SIP_PORT, int, "%d"); ai = belle_sip_ip_address_to_addrinfo(AF_INET, IPV4_CNAME_IP, SIP_PORT); if (ai) { BC_ASSERT_EQUAL(sock_in->sin_addr.s_addr, ((struct sockaddr_in *)ai->ai_addr)->sin_addr.s_addr, int, "%d"); belle_sip_freeaddrinfo(ai); } } destroy_endpoint(client); }
static void carddav_updated_contact(LinphoneCardDavContext *c, LinphoneFriend *new_lf, LinphoneFriend *old_lf) { LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)linphone_carddav_get_user_data(c); BC_ASSERT_PTR_NOT_NULL_FATAL(new_lf); BC_ASSERT_PTR_NOT_NULL_FATAL(old_lf); stats->updated_contact_count++; }
static void carddav_removed_contact(LinphoneCardDavContext *c, LinphoneFriend *lf) { LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)linphone_carddav_get_user_data(c); BC_ASSERT_PTR_NOT_NULL_FATAL(lf); stats->removed_contact_count++; }
static void subscribe_test(void) { belle_sip_listener_callbacks_t client_callbacks; belle_sip_listener_callbacks_t server_callbacks; belle_sip_request_t* req; belle_sip_client_transaction_t* trans; belle_sip_header_route_t* destination_route; const char* identity = "sip:" USERNAME "@" SIPDOMAIN ; const char* domain="sip:" SIPDOMAIN ; endpoint_t* client,*server; belle_sip_uri_t *dest_uri; belle_sip_refresher_t* refresher; belle_sip_header_contact_t* contact=belle_sip_header_contact_new(); uint64_t begin; uint64_t end; memset(&client_callbacks,0,sizeof(belle_sip_listener_callbacks_t)); memset(&server_callbacks,0,sizeof(belle_sip_listener_callbacks_t)); client_callbacks.process_dialog_terminated=client_process_dialog_terminated; client_callbacks.process_response_event=client_process_response_event; client_callbacks.process_auth_requested=client_process_auth_requested; server_callbacks.process_request_event=server_process_request_event; server_callbacks.process_dialog_terminated=server_process_dialog_terminated; client = create_udp_endpoint(3452,&client_callbacks); server = create_udp_endpoint(6788,&server_callbacks); server->expire_in_contact=0; server->auth=digest_auth; dest_uri=(belle_sip_uri_t*)belle_sip_object_clone((belle_sip_object_t*)belle_sip_listening_point_get_uri(server->lp)); belle_sip_uri_set_host(dest_uri,"127.0.0.1"); destination_route=belle_sip_header_route_create(belle_sip_header_address_create(NULL,dest_uri)); req=belle_sip_request_create( belle_sip_uri_parse(domain), "SUBSCRIBE", belle_sip_provider_create_call_id(client->provider), belle_sip_header_cseq_create(20,"SUBSCRIBE"), belle_sip_header_from_create2(identity,BELLE_SIP_RANDOM_TAG), belle_sip_header_to_create2(identity,NULL), belle_sip_header_via_new(), 70); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(contact)); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_expires_create(1))); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(belle_sip_header_create("Event","Presence"))); belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),BELLE_SIP_HEADER(destination_route)); trans=belle_sip_provider_create_client_transaction(client->provider,req); belle_sip_object_ref(trans);/*to avoid trans from being deleted before refresher can use it*/ belle_sip_client_transaction_send_request(trans); BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.fourHundredOne,1,1000)); req=belle_sip_client_transaction_create_authenticated_request(trans,NULL,NULL); belle_sip_object_unref(trans); trans=belle_sip_provider_create_client_transaction(client->provider,req); belle_sip_object_ref(trans); belle_sip_client_transaction_send_request(trans); BC_ASSERT_TRUE_FATAL(wait_for(server->stack,client->stack,&client->stat.twoHundredOk,1,1000)); /*maybe dialog should be automatically created*/ BC_ASSERT_PTR_NOT_NULL_FATAL(belle_sip_transaction_get_dialog(BELLE_SIP_TRANSACTION(trans))); refresher = belle_sip_client_transaction_create_refresher(trans); belle_sip_object_unref(trans); belle_sip_refresher_set_listener(refresher,belle_sip_refresher_listener,client); begin = belle_sip_time_ms(); BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.refreshOk,3,4000)); end = belle_sip_time_ms(); BC_ASSERT_TRUE(end-begin>=3000); BC_ASSERT_TRUE(end-begin<5000); /*unsubscribe twice to make sure refresh operation can be safely cascaded*/ belle_sip_refresher_refresh(refresher,0); belle_sip_refresher_refresh(refresher,0); belle_sip_refresher_stop(refresher); BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&client->stat.dialogTerminated,1,4000)); BC_ASSERT_TRUE(wait_for(server->stack,client->stack,&server->stat.dialogTerminated,1,4000)); belle_sip_object_unref(refresher); destroy_endpoint(client); destroy_endpoint(server); }
static endpoint_t* create_udp_endpoint(int port,belle_sip_listener_callbacks_t* listener_callbacks) { endpoint_t *endpoint=create_endpoint("0.0.0.0",port,"udp",listener_callbacks); BC_ASSERT_PTR_NOT_NULL_FATAL(endpoint->lp); return endpoint; }
void start_adaptive_stream(MSFormatType type, stream_manager_t ** pmarielle, stream_manager_t ** pmargaux, int payload, int initial_bitrate, int max_bw, float loss_rate, int latency, float dup_ratio) { int pause_time=0; PayloadType* pt; MediaStream *marielle_ms,*margaux_ms; OrtpNetworkSimulatorParams params={0}; #if VIDEO_ENABLED MSWebCam * marielle_webcam=mediastreamer2_tester_get_mire_webcam(ms_web_cam_manager_get()); #endif stream_manager_t *marielle=*pmarielle=stream_manager_new(type); stream_manager_t *margaux=*pmargaux=stream_manager_new(type); char* file = bc_tester_res(HELLO_16K_1S_FILE); char* recorded_file = bc_tester_file(RECORDED_16K_1S_FILE); marielle->user_data = recorded_file; params.enabled=TRUE; params.loss_rate=loss_rate; params.max_bandwidth=max_bw; params.latency=latency; if (type == MSAudio){ marielle_ms=&marielle->audio_stream->ms; margaux_ms=&margaux->audio_stream->ms; }else{ marielle_ms=&marielle->video_stream->ms; margaux_ms=&margaux->video_stream->ms; } /* Disable avpf. */ pt = rtp_profile_get_payload(&rtp_profile, VP8_PAYLOAD_TYPE); BC_ASSERT_PTR_NOT_NULL_FATAL(pt); payload_type_unset_flag(pt, PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED); media_stream_enable_adaptive_bitrate_control(marielle_ms,TRUE); media_stream_set_adaptive_bitrate_algorithm(marielle_ms, MSQosAnalyzerAlgorithmStateful); rtp_session_set_duplication_ratio(marielle_ms->sessions.rtp_session, dup_ratio); if (marielle->type == MSAudio){ audio_manager_start(marielle,payload,margaux->local_rtp,initial_bitrate,file,NULL); ms_filter_call_method(marielle->audio_stream->soundread,MS_FILE_PLAYER_LOOP,&pause_time); audio_manager_start(margaux,payload,marielle->local_rtp,0,NULL,recorded_file); }else{ #if VIDEO_ENABLED marielle->video_stream->staticimage_webcam_fps_optimization = FALSE; video_manager_start(marielle,payload,margaux->local_rtp,0,marielle_webcam); video_stream_set_direction(margaux->video_stream, MediaStreamRecvOnly); video_manager_start(margaux,payload,marielle->local_rtp,0,NULL); #else ms_fatal("Unsupported stream type [%s]",ms_format_type_to_string(marielle->type)); #endif } ms_qos_analyzer_set_on_action_suggested(ms_bitrate_controller_get_qos_analyzer(marielle_ms->rc), qos_analyzer_on_action_suggested, *pmarielle); rtp_session_enable_network_simulation(margaux_ms->sessions.rtp_session,¶ms); free(recorded_file); free(file); }