Commit 4a5a866c authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Finally RTT test is working

parent a919e567
......@@ -310,15 +310,9 @@ void linphone_chat_room_set_user_data(LinphoneChatRoom *cr, void *ud) {
void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage *msg) {
/*stubed rtt text*/
if (cr->call && linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(cr->call))) {
char crlf[4] = "CRLF";
linphone_chat_message_put_char(msg, *(uint32_t*)crlf); /*CRLF*/
char crlf[2] = "\r\n";
linphone_chat_message_put_char(msg, *(uint32_t*)crlf); // CRLF
linphone_chat_message_set_state(msg, LinphoneChatMessageStateDelivered);
if (cr->is_composing == LinphoneIsComposingActive) {
cr->is_composing = LinphoneIsComposingIdle;
}
linphone_chat_room_delete_composing_idle_timer(cr);
linphone_chat_room_delete_composing_refresh_timer(cr);
return;
}
linphone_chat_message_set_state(msg, LinphoneChatMessageStateInProgress);
......@@ -802,7 +796,7 @@ static void linphone_chat_room_send_is_composing_notification(LinphoneChatRoom *
}
void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *cr, uint32_t character, LinphoneCall *call) {
char *value = NULL;
char crlf[2] = "\r\n";
if (call && linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(call))) {
if (cr->call == NULL) {
......@@ -814,9 +808,7 @@ void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *c
cr->pending_message = linphone_chat_room_create_message(cr, "");
}
value = ms_strdup_printf("%c%c%c%c",((char*)&character)[0],((char*)&character)[1],((char*)&character)[2],((char*)&character)[3]);
ms_message("Received RTT character: %s (%lu)", value, (unsigned long)character);
if (strcmp(value, "CRLF") == 0) {
if (character == *(uint32_t*)crlf) {
// End of message
LinphoneChatMessage *msg = cr->pending_message;
ms_message("CRLF received, forge a message with content %s", cr->pending_message->message);
......@@ -836,10 +828,14 @@ void linphone_core_real_time_text_received(LinphoneCore *lc, LinphoneChatRoom *c
linphone_chat_message_unref(msg);
cr->pending_message = NULL;
} else {
char *value = ms_strdup_printf("%c%c%c%c",((char*)&character)[0],((char*)&character)[1],((char*)&character)[2],((char*)&character)[3]);
cr->pending_message->message = ms_strcat_printf(cr->pending_message->message, value);
ms_message("Received text since beginning of RTT session or last CRLF is %s", cr->pending_message->message);
ms_message("Received RTT character: %s (%lu), pending text is %s", value, (unsigned long)character, cr->pending_message->message);
ms_free(value);
cr->remote_is_composing = LinphoneIsComposingActive;
linphone_core_notify_is_composing_received(cr->lc, cr);
}
ms_free(value);
}
}
......@@ -859,9 +855,9 @@ int linphone_chat_message_put_char(LinphoneChatMessage *msg, uint32_t charater)
}
text_stream_putchar32(call->textstream, charater);
linphone_chat_room_compose(cr);
return 0;
}
static int linphone_chat_room_stop_composing(void *data, unsigned int revents) {
LinphoneChatRoom *cr = (LinphoneChatRoom *)data;
cr->is_composing = LinphoneIsComposingIdle;
......
......@@ -4247,7 +4247,7 @@ void linphone_call_handle_stream_events(LinphoneCall *call, int stream_index){
} else if (evt==ORTP_EVENT_TELEPHONE_EVENT){
linphone_core_dtmf_received(call,evd->info.telephone_event);
} else if (evt == ORTP_EVENT_RTT_CHARACTER_RECEIVED) {
LinphoneChatRoom * chat_room = linphone_core_get_chat_room(call->core, linphone_call_get_remote_address(call));
LinphoneChatRoom * chat_room = linphone_call_get_chat_room(call);
linphone_core_real_time_text_received(call->core, chat_room, evd->info.received_rtt_character, call);
}
ortp_event_destroy(ev);
......
......@@ -1282,16 +1282,15 @@ static void file_transfer_io_error_after_destroying_chatroom() {
file_transfer_io_error_base("https://www.linphone.org:444/lft.php", TRUE);
}
#if 0
static void real_time_text_message(void) {
LinphoneChatRoom *pauline_chat_room, *marie_chat_room;
LinphoneChatRoom *pauline_chat_room;
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
LinphoneCallParams *marie_params = linphone_core_create_default_call_parameters(marie->lc);
LinphoneCall *pauline_call, *marie_call;
linphone_call_params_enable_realtime_text(marie_params,TRUE);
BC_ASSERT_TRUE(call_with_caller_params(marie,pauline,marie_params));
BC_ASSERT_TRUE(call_with_caller_params(marie, pauline, marie_params));
pauline_call=linphone_core_get_current_call(pauline->lc);
marie_call=linphone_core_get_current_call(marie->lc);
BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(pauline_call)));
......@@ -1299,30 +1298,25 @@ static void real_time_text_message(void) {
pauline_chat_room = linphone_call_get_chat_room(pauline_call);
BC_ASSERT_PTR_NOT_NULL(pauline_chat_room);
if (pauline_chat_room) {
const char* message = "BLA BLA";
const char* message = "Lorem Ipsum Belledonnum Communicatum";
int i;
LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL);
linphone_chat_message_put_char(rtt_message,'Y');
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,1));
marie_chat_room = linphone_call_get_chat_room(marie_call);
BC_ASSERT_PTR_NOT_NULL(marie_chat_room);
for (i = 0; i < strlen(message); i++) {
linphone_chat_message_put_char(rtt_message,message[i]);
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneIsComposingActiveReceived,i+2,200));
BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room),message[i],char,"%c");
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000));
BC_ASSERT_EQUAL(linphone_chat_room_get_char(linphone_call_get_chat_room(marie_call)), message[i], char, "%c");
}
/*Commit the message, triggers a NEW LINE in T.140 */
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));
BC_ASSERT_TRUE(wait_for(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1));
{
LinphoneChatMessage * msg = marie->stat.last_received_chat_message;
BC_ASSERT_PTR_NOT_NULL(msg);
if (msg) {
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(msg),"BLA BLA");
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(msg), message);
}
}
linphone_chat_message_destroy(rtt_message);
......@@ -1332,7 +1326,6 @@ static void real_time_text_message(void) {
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
#endif
void file_transfer_with_http_proxy(void) {
......@@ -1382,11 +1375,8 @@ test_t message_tests[] = {
{"Transfer not sent if invalid url", file_transfer_not_sent_if_invalid_url},
{"Transfer not sent if host not found", file_transfer_not_sent_if_host_not_found},
{"Transfer not sent if url moved permanently", file_transfer_not_sent_if_url_moved_permanently},
{"Transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom}
#if 0
,
{"Transfer io error after destroying chatroom", file_transfer_io_error_after_destroying_chatroom},
{"Real Time Text message", real_time_text_message},
#endif
};
test_suite_t message_test_suite = {
......
......@@ -32,6 +32,7 @@ subscribe=0
[rtp]
audio_rtp_port=18070-28000
video_rtp_port=28070-38000
text_rtp_port=39000-49000
[video]
display=0
......
......@@ -31,6 +31,7 @@ dial_escape_plus=0
[rtp]
audio_rtp_port=18070-28000
video_rtp_port=39072-49000
text_rtp_port=49001-55000
[video]
display=0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment