Commit 33e77fda authored by Nicolas Michon's avatar Nicolas Michon
Browse files

Feature/groupchat benchmark

parent a556d959
......@@ -147,6 +147,8 @@ set(RC_FILES
rcfiles/stun_rc
rcfiles/zero_length_params_rc
rcfiles/marie_bodyless_rc
rcfiles/groupchat_rc
rcfiles/groupchat_lime_x3dh_rc
)
set(IMAGE_FILES
......@@ -236,15 +238,31 @@ if(APPLE)
endif()
endif()
set(GROUP_CHAT_BENCHMARK_SOURCE_C
accountmanager.c
tester.c
group_chat_tester.c
group_chat_benchmark.c
)
set(GROUP_CHAT_BENCHMARK_HEADERS
liblinphone_tester.h
tools/tester.h
)
# TODO: Remove me later!
list(REMOVE_ITEM STRICT_OPTIONS_CPP "-Wconversion" "-Werror=conversion" "-Wcast-align" "-Werror=cast-align")
if (ANDROID AND CMAKE_C_COMPILER_ID STREQUAL "GNU") #restrict to Android as it seems to break reguler linux
list (APPEND STRICT_OPTIONS_C "-std=c99")
endif()
bc_apply_compile_flags(SOURCE_FILES_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
bc_apply_compile_flags(SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
bc_apply_compile_flags(SOURCE_FILES_OBJC STRICT_OPTIONS_CPP STRICT_OPTIONS_OBJC)
bc_apply_compile_flags(GROUP_CHAT_BENCHMARK_SOURCE_C STRICT_OPTIONS_CPP STRICT_OPTIONS_C)
add_definitions("-DLINPHONE_TESTER")
if(MSVC)
......@@ -341,6 +359,21 @@ if(NOT ANDROID AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
add_executable(groupchat_benchmark ${GROUP_CHAT_BENCHMARK_HEADERS} ${GROUP_CHAT_BENCHMARK_SOURCE_C})
set_target_properties(groupchat_benchmark PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}")
set_target_properties(groupchat_benchmark PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(groupchat_benchmark PROPERTIES C_STANDARD 99)
target_include_directories(groupchat_benchmark PUBLIC ${BCTOOLBOX_TESTER_INCLUDE_DIRS})
target_link_libraries(groupchat_benchmark ${LINPHONE_LIBS_FOR_TOOLS} ${OTHER_LIBS_FOR_TESTER})
install(TARGETS groupchat_benchmark
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(FILES ${CERTIFICATE_ALT_FILES} DESTINATION "${CMAKE_INSTALL_DATADIR}/liblinphone_tester/certificates/altname")
install(FILES ${CERTIFICATE_CLIENT_FILES} DESTINATION "${CMAKE_INSTALL_DATADIR}/liblinphone_tester/certificates/client")
......
This diff is collapsed.
......@@ -19,13 +19,6 @@
#include "liblinphone_tester.h"
#include "tester_utils.h"
void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
stats* counters = get_stats(lc);
char** dst = &counters->dtmf_list_received;
*dst = *dst ? ms_strcat_printf(*dst, "%c", dtmf) : ms_strdup_printf("%c", dtmf);
counters->dtmf_count++;
}
void send_dtmf_base(LinphoneCoreManager **pmarie, LinphoneCoreManager **ppauline, bool_t use_rfc2833, bool_t use_sipinfo, char dtmf, char* dtmf_seq, bool_t use_opus) {
char* expected = NULL;
int dtmf_count_prev;
......
......@@ -24,8 +24,8 @@
#include "liblinphone_tester.h"
#include "tester_utils.h"
static const char *subscribe_content="<somexml>blabla</somexml>";
static const char *notify_content="<somexml2>blabla</somexml2>";
static const char *subscribe_content="<somexml>blabla</somexml>";
const char *liblinphone_tester_get_subscribe_content(void){
return subscribe_content;
......@@ -35,102 +35,6 @@ const char *liblinphone_tester_get_notify_content(void){
return notify_content;
}
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");
if (!BC_ASSERT_PTR_NOT_NULL(content)) return;
if (!linphone_content_is_multipart(content) && (!ua || !strstr(ua, "flexisip"))) { /*disable check for full presence server support*/
/*hack to disable content checking for list notify */
BC_ASSERT_STRING_EQUAL(linphone_content_get_string_buffer(content), notify_content);
}
mgr = get_manager(lc);
mgr->stat.number_of_NotifyReceived++;
}
void linphone_subscribe_received(LinphoneCore *lc, LinphoneEvent *lev, const char *eventname, const LinphoneContent *content) {
LinphoneCoreManager *mgr = get_manager(lc);
if (!mgr->decline_subscribe)
linphone_event_accept_subscription(lev);
else
linphone_event_deny_subscription(lev, LinphoneReasonDeclined);
}
void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) {
stats* counters = get_stats(lc);
LinphoneCoreManager *mgr=get_manager(lc);
LinphoneContent* content;
const LinphoneAddress* from_addr = linphone_event_get_from(lev);
char* from = linphone_address_as_string(from_addr);
content = linphone_core_create_content(lc);
linphone_content_set_type(content,"application");
linphone_content_set_subtype(content,"somexml2");
linphone_content_set_buffer(content,(const uint8_t *)notify_content,strlen(notify_content));
ms_message("Subscription state [%s] from [%s]",linphone_subscription_state_to_string(state),from);
ms_free(from);
switch(state){
case LinphoneSubscriptionNone:
break;
case LinphoneSubscriptionIncomingReceived:
counters->number_of_LinphoneSubscriptionIncomingReceived++;
mgr->lev=lev;
break;
case LinphoneSubscriptionOutgoingProgress:
counters->number_of_LinphoneSubscriptionOutgoingProgress++;
break;
case LinphoneSubscriptionPending:
counters->number_of_LinphoneSubscriptionPending++;
break;
case LinphoneSubscriptionActive:
counters->number_of_LinphoneSubscriptionActive++;
if (linphone_event_get_subscription_dir(lev)==LinphoneSubscriptionIncoming){
mgr->lev=lev;
if(strcmp(linphone_event_get_name(lev), "conference") == 0) {
// TODO : Get LocalConfEventHandler and call handler->subscribeReceived(lev)
} else {
linphone_event_notify(lev,content);
}
}
break;
case LinphoneSubscriptionTerminated:
counters->number_of_LinphoneSubscriptionTerminated++;
mgr->lev=NULL;
break;
case LinphoneSubscriptionError:
counters->number_of_LinphoneSubscriptionError++;
mgr->lev=NULL;
break;
case LinphoneSubscriptionExpiring:
counters->number_of_LinphoneSubscriptionExpiring++;
mgr->lev=NULL;
break;
}
linphone_content_unref(content);
}
void linphone_publish_state_changed(LinphoneCore *lc, LinphoneEvent *ev, LinphonePublishState state){
stats* counters = get_stats(lc);
const LinphoneAddress* from_addr = linphone_event_get_from(ev);
char* from = linphone_address_as_string(from_addr);
ms_message("Publish state [%s] from [%s]",linphone_publish_state_to_string(state),from);
ms_free(from);
switch(state){
case LinphonePublishProgress: counters->number_of_LinphonePublishProgress++; break;
case LinphonePublishOk:
/*make sure custom header access API is working*/
BC_ASSERT_PTR_NOT_NULL(linphone_event_get_custom_header(ev,"From"));
counters->number_of_LinphonePublishOk++;
break;
case LinphonePublishError: counters->number_of_LinphonePublishError++; break;
case LinphonePublishExpiring: counters->number_of_LinphonePublishExpiring++; break;
case LinphonePublishCleared: counters->number_of_LinphonePublishCleared++;break;
default:
break;
}
}
static void subscribe_test_declined(void) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
......
This diff is collapsed.
......@@ -73,7 +73,11 @@ static void chat_room_participant_device_added (LinphoneChatRoom *cr, const Linp
static void chat_room_state_changed (LinphoneChatRoom *cr, LinphoneChatRoomState newState) {
LinphoneCore *core = linphone_chat_room_get_core(cr);
LinphoneCoreManager *manager = (LinphoneCoreManager *)linphone_core_get_user_data(core);
ms_message("ChatRoom [%p] state changed: %d", cr, newState);
const LinphoneAddress *addr = linphone_chat_room_get_conference_address(cr);
if (addr) {
ms_message("ChatRoom [%s] state changed: %d", linphone_address_as_string(addr), newState);
}
switch (newState) {
case LinphoneChatRoomStateNone:
break;
......@@ -138,7 +142,7 @@ static void chat_room_conference_joined (LinphoneChatRoom *cr, const LinphoneEve
manager->stat.number_of_LinphoneChatRoomConferenceJoined++;
}
static void core_chat_room_state_changed (LinphoneCore *core, LinphoneChatRoom *cr, LinphoneChatRoomState state) {
void core_chat_room_state_changed (LinphoneCore *core, LinphoneChatRoom *cr, LinphoneChatRoomState state) {
if (state == LinphoneChatRoomStateInstantiated) {
LinphoneChatRoomCbs *cbs = linphone_factory_create_chat_room_cbs(linphone_factory_get());
linphone_chat_room_cbs_set_is_composing_received(cbs, chat_room_is_composing_received);
......@@ -156,7 +160,7 @@ static void core_chat_room_state_changed (LinphoneCore *core, LinphoneChatRoom *
}
}
static void configure_core_for_conference (LinphoneCore *core, const char* username, const LinphoneAddress *factoryAddr, bool_t server) {
void configure_core_for_conference (LinphoneCore *core, const char* username, const LinphoneAddress *factoryAddr, bool_t server) {
const char *identity = linphone_core_get_identity(core);
const char *new_username;
LinphoneAddress *addr = linphone_address_new(identity);
......@@ -176,22 +180,22 @@ static void configure_core_for_conference (LinphoneCore *core, const char* usern
linphone_core_set_linphone_specs(core, "groupchat");
}
static void _configure_core_for_conference (LinphoneCoreManager *lcm, LinphoneAddress *factoryAddr) {
void _configure_core_for_conference (LinphoneCoreManager *lcm, LinphoneAddress *factoryAddr) {
configure_core_for_conference(lcm->lc, NULL, factoryAddr, FALSE);
}
static void _configure_core_for_callbacks(LinphoneCoreManager *lcm, LinphoneCoreCbs *cbs) {
void configure_core_for_callbacks(LinphoneCoreManager *lcm, LinphoneCoreCbs *cbs) {
// Remove is-composing callback from the core, we use our own on the chat room
linphone_core_cbs_set_is_composing_received(lcm->cbs, NULL);
linphone_core_add_callbacks(lcm->lc, cbs);
linphone_core_set_user_data(lcm->lc, lcm);
}
static void _start_core(LinphoneCoreManager *lcm) {
void _start_core(LinphoneCoreManager *lcm) {
linphone_core_manager_start(lcm, TRUE);
}
static LinphoneChatMessage *_send_message(LinphoneChatRoom *chatRoom, const char *message) {
LinphoneChatMessage *_send_message(LinphoneChatRoom *chatRoom, const char *message) {
LinphoneChatMessage *msg = linphone_chat_room_create_message(chatRoom, message);
LinphoneChatMessageCbs *msgCbs = linphone_chat_message_get_callbacks(msg);
linphone_chat_message_cbs_set_msg_state_changed(msgCbs, liblinphone_tester_chat_message_msg_state_changed);
......@@ -274,14 +278,14 @@ static void _receive_file_plus_text(bctbx_list_t *coresList, LinphoneCoreManager
}
// Configure list of core manager for conference and add the listener
static bctbx_list_t * init_core_for_conference(bctbx_list_t *coreManagerList) {
bctbx_list_t * init_core_for_conference(bctbx_list_t *coreManagerList) {
LinphoneAddress *factoryAddr = linphone_address_new(sFactoryUri);
bctbx_list_for_each2(coreManagerList, (void (*)(void *, void *))_configure_core_for_conference, (void *) factoryAddr);
linphone_address_unref(factoryAddr);
LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get());
linphone_core_cbs_set_chat_room_state_changed(cbs, core_chat_room_state_changed);
bctbx_list_for_each2(coreManagerList, (void (*)(void *, void *))_configure_core_for_callbacks, (void *) cbs);
bctbx_list_for_each2(coreManagerList, (void (*)(void *, void *))configure_core_for_callbacks, (void *) cbs);
linphone_core_cbs_unref(cbs);
bctbx_list_t *coresList = NULL;
......@@ -291,11 +295,11 @@ static bctbx_list_t * init_core_for_conference(bctbx_list_t *coreManagerList) {
return coresList;
}
static void start_core_for_conference(bctbx_list_t *coreManagerList) {
void start_core_for_conference(bctbx_list_t *coreManagerList) {
bctbx_list_for_each(coreManagerList, (void (*)(void *))_start_core);
}
static LinphoneChatRoom * check_creation_chat_room_client_side(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, const LinphoneAddress *confAddr, const char* subject, int participantNumber, bool_t isAdmin) {
LinphoneChatRoom * check_creation_chat_room_client_side(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, const LinphoneAddress *confAddr, const char* subject, int participantNumber, bool_t isAdmin) {
BC_ASSERT_TRUE(wait_for_list(lcs, &lcm->stat.number_of_LinphoneChatRoomStateCreationPending, initialStats->number_of_LinphoneChatRoomStateCreationPending + 1, 3000));
BC_ASSERT_TRUE(wait_for_list(lcs, &lcm->stat.number_of_LinphoneChatRoomStateCreated, initialStats->number_of_LinphoneChatRoomStateCreated + 1, 3000));
BC_ASSERT_TRUE(wait_for_list(lcs, &lcm->stat.number_of_LinphoneChatRoomConferenceJoined, initialStats->number_of_LinphoneChatRoomConferenceJoined + 1, 3000));
......@@ -316,7 +320,7 @@ static LinphoneChatRoom * check_creation_chat_room_client_side(bctbx_list_t *lcs
return chatRoom;
}
static LinphoneChatRoom * create_chat_room_client_side_with_expected_number_of_participants(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, bctbx_list_t *participantsAddresses, const char* initialSubject, int expectedParticipantSize, bool_t encrypted) {
LinphoneChatRoom * create_chat_room_client_side_with_expected_number_of_participants(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, bctbx_list_t *participantsAddresses, const char* initialSubject, int expectedParticipantSize, bool_t encrypted) {
LinphoneChatRoom *chatRoom = linphone_core_create_client_group_chat_room_2(lcm->lc, initialSubject, FALSE, encrypted);
if (!chatRoom) return NULL;
......@@ -345,7 +349,7 @@ static LinphoneChatRoom * create_chat_room_client_side_with_expected_number_of_p
return chatRoom;
}
static LinphoneChatRoom * create_chat_room_client_side(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, bctbx_list_t *participantsAddresses, const char* initialSubject, bool_t encrypted) {
LinphoneChatRoom * create_chat_room_client_side(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, bctbx_list_t *participantsAddresses, const char* initialSubject, bool_t encrypted) {
return create_chat_room_client_side_with_expected_number_of_participants(lcs, lcm, initialStats, participantsAddresses, initialSubject, -1, encrypted);
}
......@@ -2017,7 +2021,7 @@ static void group_chat_room_add_device (void) {
linphone_address_unref(factoryAddr);
LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(linphone_factory_get());
linphone_core_cbs_set_chat_room_state_changed(cbs, core_chat_room_state_changed);
_configure_core_for_callbacks(marie2, cbs);
configure_core_for_callbacks(marie2, cbs);
linphone_core_cbs_unref(cbs);
coresList = bctbx_list_append(coresList, marie2->lc);
_start_core(marie2);
......
......@@ -306,6 +306,51 @@ int logfile_arg_func(const char *arg) {
return 0;
}
void liblinphone_tester_add_suites() {
bc_tester_add_suite(&setup_test_suite);
bc_tester_add_suite(&register_test_suite);
bc_tester_add_suite(&tunnel_test_suite);
bc_tester_add_suite(&offeranswer_test_suite);
bc_tester_add_suite(&call_test_suite);
#ifdef VIDEO_ENABLED
bc_tester_add_suite(&call_video_test_suite);
#endif // ifdef VIDEO_ENABLED
bc_tester_add_suite(&audio_bypass_suite);
bc_tester_add_suite(&multi_call_test_suite);
bc_tester_add_suite(&message_test_suite);
bc_tester_add_suite(&presence_test_suite);
bc_tester_add_suite(&presence_server_test_suite);
bc_tester_add_suite(&account_creator_test_suite);
bc_tester_add_suite(&stun_test_suite);
bc_tester_add_suite(&event_test_suite);
bc_tester_add_suite(&conference_event_test_suite);
bc_tester_add_suite(&contents_test_suite);
bc_tester_add_suite(&flexisip_test_suite);
bc_tester_add_suite(&remote_provisioning_test_suite);
bc_tester_add_suite(&quality_reporting_test_suite);
bc_tester_add_suite(&log_collection_test_suite);
bc_tester_add_suite(&player_test_suite);
bc_tester_add_suite(&dtmf_test_suite);
bc_tester_add_suite(&cpim_test_suite);
bc_tester_add_suite(&multipart_test_suite);
bc_tester_add_suite(&clonable_object_test_suite);
bc_tester_add_suite(&main_db_test_suite);
bc_tester_add_suite(&property_container_test_suite);
#ifdef VIDEO_ENABLED
bc_tester_add_suite(&video_test_suite);
#endif // ifdef VIDEO_ENABLED
bc_tester_add_suite(&multicast_call_test_suite);
bc_tester_add_suite(&proxy_config_test_suite);
#if HAVE_SIPP
bc_tester_add_suite(&complex_sip_call_test_suite);
#endif
#ifdef VCARD_ENABLED
bc_tester_add_suite(&vcard_test_suite);
#endif
bc_tester_add_suite(&group_chat_test_suite);
bc_tester_add_suite(&utils_test_suite);
}
void liblinphone_tester_init(void(*ftester_printf)(int level, const char *fmt, va_list args)) {
bctbx_init_logger(FALSE);
if (! log_file) {
......
......@@ -362,8 +362,10 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr);
void linphone_core_manager_wait_for_stun_resolution(LinphoneCoreManager *mgr);
void linphone_core_manager_destroy(LinphoneCoreManager* mgr);
void linphone_core_manager_delete_chat_room (LinphoneCoreManager *mgr, LinphoneChatRoom *cr, bctbx_list_t *coresList);
bctbx_list_t * init_core_for_conference(bctbx_list_t *coreManagerList);
void start_core_for_conference(bctbx_list_t *coreManagerList);
void reset_counters( stats* counters);
void reset_counters(stats* counters);
void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message);
void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg);
......@@ -373,6 +375,7 @@ void notify_presence_received_for_uri_or_tel(LinphoneCore *lc, LinphoneFriend *l
void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage* message);
void file_transfer_received(LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer);
LinphoneBuffer * tester_file_transfer_send(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size);
LinphoneChatMessage *_send_message(LinphoneChatRoom *chatRoom, const char *message);
LinphoneBuffer * tester_memory_file_transfer_send(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t size);
void file_transfer_progress_indication(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total);
void is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room);
......@@ -420,6 +423,8 @@ const char *liblinphone_tester_get_subscribe_content(void);
const char *liblinphone_tester_get_notify_content(void);
void liblinphone_tester_chat_message_state_change(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud);
void liblinphone_tester_chat_message_msg_state_changed(LinphoneChatMessage *msg, LinphoneChatMessageState state);
void core_chat_room_state_changed (LinphoneCore *core, LinphoneChatRoom *cr, LinphoneChatRoomState state);
void liblinphone_tester_check_rtcp(LinphoneCoreManager* caller, LinphoneCoreManager* callee);
void liblinphone_tester_clock_start(MSTimeSpec *start);
bool_t liblinphone_tester_clock_elapsed(const MSTimeSpec *start, int value_ms);
......@@ -427,6 +432,7 @@ void linphone_core_manager_check_accounts(LinphoneCoreManager *m);
void account_manager_destroy(void);
LinphoneAddress *account_manager_get_identity_with_modified_identity(const LinphoneAddress *modified_identity);
LinphoneCore *configure_lc_from(LinphoneCoreCbs *cbs, const char *path, const char *file, void *user_data);
void configure_core_for_callbacks(LinphoneCoreManager *lcm, LinphoneCoreCbs *cbs);
void liblinphone_tester_set_next_video_frame_decoded_cb(LinphoneCall *call);
void call_paused_resumed_base(bool_t multicast,bool_t with_losses);
......@@ -442,6 +448,14 @@ void _call_with_ice_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie
int 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);
void setup_sdp_handling(const LinphoneCallTestParams* params, LinphoneCoreManager* mgr);
LinphoneChatRoom * create_chat_room_client_side(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, bctbx_list_t *participantsAddresses, const char* initialSubject, bool_t encrypted);
LinphoneChatRoom * check_creation_chat_room_client_side(bctbx_list_t *lcs, LinphoneCoreManager *lcm, stats *initialStats, const LinphoneAddress *confAddr, const char* subject, int participantNumber, bool_t isAdmin);
void configure_core_for_conference (LinphoneCore *core, const char* username, const LinphoneAddress *factoryAddr, bool_t server);
void _start_core(LinphoneCoreManager *lcm);
/*
* this function return max value in the last 3 seconds*/
int linphone_core_manager_get_max_audio_down_bw(const LinphoneCoreManager *mgr);
......
127.0.0.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 sipv4.example.org conf.example.org subscribe.example.org x3dh.example.org http-proxy.example.org
::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-nat64.example.org
64:ff9b::94.23.19.176 sipv4-nat64.example.org
......@@ -32,8 +32,6 @@
#endif
static char* message_external_body_url=NULL;
/* sql cache creation string, contains 3 string to be inserted : selfuri/selfuri/peeruri */
static const char *marie_zid_sqlcache = "BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS ziduri (zuid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,zid BLOB NOT NULL DEFAULT '000000000000',selfuri TEXT NOT NULL DEFAULT 'unset',peeruri TEXT NOT NULL DEFAULT 'unset'); INSERT INTO `ziduri` (zuid,zid,selfuri,peeruri) VALUES (1,X'4ddc8042bee500ad0366bf93','%s','self'), (2,X'bcb4028bf55e1b7ac4c4edee','%s','%s'); CREATE TABLE IF NOT EXISTS zrtp (zuid INTEGER NOT NULL DEFAULT 0 UNIQUE,rs1 BLOB DEFAULT NULL,rs2 BLOB DEFAULT NULL,aux BLOB DEFAULT NULL,pbx BLOB DEFAULT NULL,pvs BLOB DEFAULT NULL,FOREIGN KEY(zuid) REFERENCES ziduri(zuid) ON UPDATE CASCADE ON DELETE CASCADE); INSERT INTO `zrtp` (zuid,rs1,rs2,aux,pbx,pvs) VALUES (2,X'f0e0ad4d3d4217ba4048d1553e5ab26fae0b386cdac603f29a66d5f4258e14ef',NULL,NULL,NULL,X'01'); CREATE TABLE IF NOT EXISTS lime (zuid INTEGER NOT NULL DEFAULT 0 UNIQUE,sndKey BLOB DEFAULT NULL,rcvKey BLOB DEFAULT NULL,sndSId BLOB DEFAULT NULL,rcvSId BLOB DEFAULT NULL,sndIndex BLOB DEFAULT NULL,rcvIndex BLOB DEFAULT NULL,valid BLOB DEFAULT NULL,FOREIGN KEY(zuid) REFERENCES ziduri(zuid) ON UPDATE CASCADE ON DELETE CASCADE); INSERT INTO `lime` (zuid,sndKey,rcvKey,sndSId,rcvSId,sndIndex,rcvIndex,valid) VALUES (2,X'97c75a5a92a041b415296beec268efc3373ef4aa8b3d5f301ac7522a7fb4e332',x'3b74b709b961e5ebccb1db6b850ea8c1f490546d6adee2f66b5def7093cead3d',X'e2ebca22ad33071bc37631393bf25fc0a9badeea7bf6dcbcb5d480be7ff8c5ea',X'a2086d195344ec2997bf3de7441d261041cda5d90ed0a0411ab2032e5860ea48',X'33376935',X'7ce32d86',X'0000000000000000'); COMMIT;";
......@@ -41,190 +39,11 @@ static const char *pauline_zid_sqlcache = "BEGIN TRANSACTION; CREATE TABLE IF NO
static const char *xmlCacheMigration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<cache><selfZID>00112233445566778899aabb</selfZID><peer><ZID>99887766554433221100ffee</ZID><rs1>c4274f13a2b6fa05c15ec93158f930e7264b0a893393376dbc80c6eb1cccdc5a</rs1><uri>sip:bob@sip.linphone.org</uri><sndKey>219d9e445d10d4ed64083c7ccbb83a23bc17a97df0af5de4261f3fe026b05b0b</sndKey><rcvKey>747e72a5cc996413cb9fa6e3d18d8b370436e274cd6ba4efc1a4580340af57ca</rcvKey><sndSId>df2bf38e719fa89e17332cf8d5e774ee70d347baa74d16dee01f306c54789869</sndSId><rcvSId>928ce78b0bfc30427a02b1b668b2b3b0496d5664d7e89b75ed292ee97e3fc850</rcvSId><sndIndex>496bcc89</sndIndex><rcvIndex>59337abe</rcvIndex><rs2>5dda11f388384b349d210612f30824268a3753a7afa52ef6df5866dca76315c4</rs2><uri>sip:bob2@sip.linphone.org</uri></peer><peer><ZID>ffeeddccbbaa987654321012</ZID><rs1>858b495dfad483af3c088f26d68c4beebc638bd44feae45aea726a771727235e</rs1><uri>sip:bob@sip.linphone.org</uri><sndKey>b6aac945057bc4466bfe9a23771c6a1b3b8d72ec3e7d8f30ed63cbc5a9479a25</sndKey><rcvKey>bea5ac3225edd0545b816f061a8190370e3ee5160e75404846a34d1580e0c263</rcvKey><sndSId>17ce70fdf12e500294bcb5f2ffef53096761bb1c912b21e972ae03a5a9f05c47</sndSId><rcvSId>7e13a20e15a517700f0be0921f74b96d4b4a0c539d5e14d5cdd8706441874ac0</rcvSId><sndIndex>75e18caa</sndIndex><rcvIndex>2cfbbf06</rcvIndex><rs2>1533dee20c8116dc2c282cae9adfea689b87bc4c6a4e18a846f12e3e7fea3959</rs2></peer><peer><ZID>0987654321fedcba5a5a5a5a</ZID><rs1>cb6ecc87d1dd87b23f225eec53a26fc541384917623e0c46abab8c0350c6929e</rs1><sndKey>92bb03988e8f0ccfefa37a55fd7c5893bea3bfbb27312f49dd9b10d0e3c15fc7</sndKey><rcvKey>2315705a5830b98f68458fcd49623144cb34a667512c4d44686aee125bb8b622</rcvKey><sndSId>94c56eea0dd829379263b6da3f6ac0a95388090f168a3568736ca0bd9f8d595f</sndSId><rcvSId>c319ae0d41183fec90afc412d42253c5b456580f7a463c111c7293623b8631f4</rcvSId><uri>sip:bob@sip.linphone.org</uri><sndIndex>2c46ddcc</sndIndex><rcvIndex>15f5779e</rcvIndex><valid>0000000058f095bf</valid><pvs>01</pvs></peer></cache>";
void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage* msg) {
char* from=linphone_address_as_string(linphone_chat_message_get_from_address(msg));
stats* counters;
const char *text=linphone_chat_message_get_text(msg);
const char *external_body_url=linphone_chat_message_get_external_body_url(msg);
ms_message("Message from [%s] is [%s] , external URL [%s]",from?from:""
,text?text:""
,external_body_url?external_body_url:"");
ms_free(from);
counters = get_stats(lc);
counters->number_of_LinphoneMessageReceived++;
if (counters->last_received_chat_message) {
linphone_chat_message_unref(counters->last_received_chat_message);
}
counters->last_received_chat_message=linphone_chat_message_ref(msg);
LinphoneContent * content = linphone_chat_message_get_file_transfer_information(msg);
if (content)
counters->number_of_LinphoneMessageReceivedWithFile++;
else if (linphone_chat_message_get_external_body_url(msg)) {
counters->number_of_LinphoneMessageExtBodyReceived++;
if (message_external_body_url) {
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_external_body_url(msg),message_external_body_url);
message_external_body_url=NULL;
}
}
}
/**
* function invoked when a file transfer is received.
* */
void file_transfer_received(LinphoneChatMessage *msg, const LinphoneContent* content, const LinphoneBuffer *buffer){
FILE* file=NULL;
char *receive_file = NULL;
// If a file path is set, we should NOT call the on_recv callback !
BC_ASSERT_PTR_NULL(linphone_chat_message_get_file_transfer_filepath(msg));
receive_file = bc_tester_file("receive_file.dump");
if (!linphone_chat_message_get_user_data(msg)) {
/*first chunk, creating file*/
file = fopen(receive_file,"wb");
linphone_chat_message_set_user_data(msg,(void*)file); /*store fd for next chunks*/
}
file = (FILE*)linphone_chat_message_get_user_data(msg);
BC_ASSERT_PTR_NOT_NULL(file);
if (linphone_buffer_is_empty(buffer)) { /* tranfer complete */
struct stat st;
linphone_chat_message_set_user_data(msg, NULL);
fclose(file);
BC_ASSERT_TRUE(stat(receive_file, &st)==0);
BC_ASSERT_EQUAL((int)linphone_content_get_file_size(content), (int)st.st_size, int, "%i");
} else { /* store content on a file*/
if (fwrite(linphone_buffer_get_content(buffer),linphone_buffer_get_size(buffer),1,file)==0){
ms_error("file_transfer_received(): write() failed: %s",strerror(errno));
}
}
bc_free(receive_file);
}
/*
* function called when the file transfer is initiated. file content should be feed into object LinphoneContent
* */
LinphoneBuffer * tester_file_transfer_send(LinphoneChatMessage *msg, const LinphoneContent* content, size_t offset, size_t size){
LinphoneBuffer *lb;
size_t file_size;
size_t size_to_send;
uint8_t *buf;
FILE *file_to_send = linphone_chat_message_get_user_data(msg);
// If a file path is set, we should NOT call the on_send callback !
BC_ASSERT_PTR_NULL(linphone_chat_message_get_file_transfer_filepath(msg));
BC_ASSERT_PTR_NOT_NULL(file_to_send);
if (file_to_send == NULL){
return NULL;
}
fseek(file_to_send, 0, SEEK_END);
file_size = ftell(file_to_send);
fseek(file_to_send, (long)offset, SEEK_SET);
size_to_send = MIN(size, file_size - offset);
buf = ms_malloc(size_to_send);
if (fread(buf, sizeof(uint8_t), size_to_send, file_to_send) != size_to_send){
// reaching end of file, close it
fclose(file_to_send);
linphone_chat_message_set_user_data(msg, NULL);
}
lb = linphone_buffer_new_from_data(buf, size_to_send);
ms_free(buf);
return lb;
}
/**
* function invoked to report file transfer progress.
* */
void file_transfer_progress_indication(LinphoneChatMessage *msg, const LinphoneContent* content, size_t offset, size_t total) {
const LinphoneAddress *from_address = linphone_chat_message_get_from_address(msg);
const LinphoneAddress *to_address = linphone_chat_message_get_to_address(msg);
int progress = (int)((offset * 100)/total);
LinphoneCore *lc = linphone_chat_message_get_core(msg);
stats *counters = get_stats(lc);
char *address = linphone_address_as_string(linphone_chat_message_is_outgoing(msg) ? to_address : from_address);
bctbx_message(
"File transfer [%d%%] %s of type [%s/%s] %s [%s] \n",
progress,
linphone_chat_message_is_outgoing(msg) ? "sent" : "received",
linphone_content_get_type(content),
linphone_content_get_subtype(content),
linphone_chat_message_is_outgoing(msg) ? "to" : "from",
address
);
counters->progress_of_LinphoneFileTransfer = progress;
if (progress == 100) {
counters->number_of_LinphoneFileTransferDownloadSuccessful++;
}
free(address);
}
void is_composing_received(LinphoneCore *lc, LinphoneChatRoom *room) {
stats *counters = get_stats(lc);
if (linphone_chat_room_is_remote_composing(room)) {
counters->number_of_LinphoneIsComposingActiveReceived++;
} else {
counters->number_of_LinphoneIsComposingIdleReceived++;
}
}
void liblinphone_tester_chat_message_state_change(LinphoneChatMessage* msg,LinphoneChatMessageState state,void* ud) {
liblinphone_tester_chat_message_msg_state_changed(msg, state);
}
void liblinphone_tester_chat_message_msg_state_changed(LinphoneChatMessage *msg, LinphoneChatMessageState state) {
LinphoneCore *lc = linphone_chat_message_get_core(msg);
stats *counters = get_stats(lc);
switch (state) {
case LinphoneChatMessageStateIdle:
return;
case LinphoneChatMessageStateDelivered:
counters->number_of_LinphoneMessageDelivered++;
return;
case LinphoneChatMessageStateNotDelivered:
counters->number_of_LinphoneMessageNotDelivered++;
return;
case LinphoneChatMessageStateInProgress:
counters->number_of_LinphoneMessageInProgress++;
return;
case LinphoneChatMessageStateFileTransferError:
counters->number_of_LinphoneMessageNotDelivered++;
counters->number_of_LinphoneMessageFileTransferError++;
return;
case LinphoneChatMessageStateFileTransferDone:
counters->number_of_LinphoneMessageFileTransferDone++;
return;
case LinphoneChatMessageStateDeliveredToUser:
counters->number_of_LinphoneMessageDeliveredToUser++;
return;
case LinphoneChatMessageStateDisplayed:
counters->number_of_LinphoneMessageDisplayed++