diff --git a/coreapi/bellesip_sal/sal_op_message.c b/coreapi/bellesip_sal/sal_op_message.c index a051dc52f..445afd1e2 100644 --- a/coreapi/bellesip_sal/sal_op_message.c +++ b/coreapi/bellesip_sal/sal_op_message.c @@ -149,6 +149,7 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve belle_sip_object_unref(address); belle_sip_free(from); if (salmsg.url) ms_free((char*)salmsg.url); + ms_free((char *)salmsg.content_type); } } else { ms_error("Unsupported MESSAGE (no Content-Type)"); diff --git a/coreapi/chat_file_transfer.c b/coreapi/chat_file_transfer.c index 490bc91cc..b1d066f4b 100644 --- a/coreapi/chat_file_transfer.c +++ b/coreapi/chat_file_transfer.c @@ -109,7 +109,7 @@ static int on_send_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t * lc = msg->chat_room->lc; /* if we've not reach the end of file yet, ask for more data */ /* in case of file body handler, won't be called */ - if (offset < linphone_content_get_size(msg->file_transfer_information)) { + if (msg->file_transfer_filepath == NULL && offset < linphone_content_get_size(msg->file_transfer_information)) { /* get data from call back */ LinphoneChatMessageCbsFileTransferSendCb file_transfer_send_cb = linphone_chat_message_cbs_get_file_transfer_send(msg->callbacks); if (file_transfer_send_cb) { @@ -397,13 +397,15 @@ static void on_recv_body(belle_sip_user_body_handler_t *bh, belle_sip_message_t ms_free(decrypted_buffer); if (retval <= 0) { - if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { - LinphoneBuffer *lb = linphone_buffer_new_from_data(buffer, size); - linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); - linphone_buffer_unref(lb); - } else { - /* Legacy: call back given by application level */ - linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, (const char *)buffer, size); + if (msg->file_transfer_filepath == NULL) { + if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { + LinphoneBuffer *lb = linphone_buffer_new_from_data(buffer, size); + linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); + linphone_buffer_unref(lb); + } else { + /* Legacy: call back given by application level */ + linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, (const char *)buffer, size); + } } } else { ms_warning("File transfer decrypt failed with code %d", (int)retval); @@ -428,13 +430,15 @@ static void on_recv_end(belle_sip_user_body_handler_t *bh, void *data) { } if (retval <= 0) { - if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { - LinphoneBuffer *lb = linphone_buffer_new(); - linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); - linphone_buffer_unref(lb); - } else { - /* Legacy: call back given by application level */ - linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); + if (msg->file_transfer_filepath == NULL) { + if (linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)) { + LinphoneBuffer *lb = linphone_buffer_new(); + linphone_chat_message_cbs_get_file_transfer_recv(msg->callbacks)(msg, msg->file_transfer_information, lb); + linphone_buffer_unref(lb); + } else { + /* Legacy: call back given by application level */ + linphone_core_notify_file_transfer_recv(lc, msg, msg->file_transfer_information, NULL, 0); + } } } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 21e53e43b..2e274e1b9 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -688,24 +688,30 @@ void linphone_call_update_biggest_desc(LinphoneCall *call, SalMediaDescription * static void force_streams_dir_according_to_state(LinphoneCall *call, SalMediaDescription *md){ int i; - switch (call->state){ - case LinphoneCallPausing: - case LinphoneCallPaused: - break; - default: - return; - break; - } - for (i=0; istreams[i]; - if (sd->dir != SalStreamInactive) { - sd->dir = SalStreamSendOnly; - if (sd->type == SalVideo){ - if (lp_config_get_int(call->core->config, "sip", "inactive_video_on_pause", 0)) { - sd->dir = SalStreamInactive; + + switch (call->state){ + case LinphoneCallPausing: + case LinphoneCallPaused: + if (sd->dir != SalStreamInactive) { + sd->dir = SalStreamSendOnly; + if (sd->type == SalVideo){ + if (lp_config_get_int(call->core->config, "sip", "inactive_video_on_pause", 0)) { + sd->dir = SalStreamInactive; + } + } } - } + break; + default: + break; + } + + /* Reflect the stream directions in the call params */ + if (i == call->main_audio_stream_index) { + linphone_call_params_set_audio_direction(call->current_params, media_direction_from_sal_stream_dir(sd->dir)); + } else if (i == call->main_video_stream_index) { + linphone_call_params_set_video_direction(call->current_params, media_direction_from_sal_stream_dir(sd->dir)); } } } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 76b3072cc..4fd54e556 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3471,6 +3471,7 @@ int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call){ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params){ int err=0; LinphoneCallState nextstate, initial_state; + const LinphoneCallParams *current_params; #if defined(VIDEO_ENABLED) && defined(BUILD_UPNP) bool_t has_video = FALSE; @@ -3501,7 +3502,12 @@ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const Linpho ms_error("linphone_core_update_call() is not allowed in [%s] state",linphone_call_state_to_string(call->state)); return -1; } - + + current_params = linphone_call_get_current_params(call); + if ((current_params != NULL) && (current_params == params)) { + ms_warning("linphone_core_update_call() is given the current params of the call, this probably not what you intend to do!"); + } + linphone_call_check_ice_session(call, IR_Controlling, TRUE); if (params!=NULL){ diff --git a/include/linphone/chat.h b/include/linphone/chat.h index 770ae34f4..517834b79 100644 --- a/include/linphone/chat.h +++ b/include/linphone/chat.h @@ -110,7 +110,11 @@ typedef LinphoneBuffer * (*LinphoneChatMessageCbsFileTransferSendCb)(LinphoneCha */ typedef void (*LinphoneChatMessageCbsFileTransferProgressIndicationCb)(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total); - +/** + * Set the chat database path. + * @param lc the linphone core + * @param path the database path + */ LINPHONE_PUBLIC void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path); /** diff --git a/include/linphone/core.h b/include/linphone/core.h index 6f4714d25..28a9781bf 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -1820,10 +1820,12 @@ LINPHONE_PUBLIC int linphone_core_terminate_all_calls(LinphoneCore *lc); /** * Pauses the call. If a music file has been setup using linphone_core_set_play_file(), * this file will be played to the remote user. + * The only way to resume a paused call is to call linphone_core_resume_call(). * @param[in] lc LinphoneCore object * @param[in] call The call to pause * @return 0 on success, -1 on failure * @ingroup call_control + * @see linphone_core_resume_call() **/ LINPHONE_PUBLIC int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call); @@ -1837,10 +1839,12 @@ LINPHONE_PUBLIC int linphone_core_pause_all_calls(LinphoneCore *lc); /** * Resumes a call. + * The call needs to have been paused previously with linphone_core_pause_call(). * @param[in] lc LinphoneCore object * @param[in] call The call to resume * @return 0 on success, -1 on failure * @ingroup call_control + * @see linphone_core_pause_call() **/ LINPHONE_PUBLIC int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *call); @@ -1850,6 +1854,8 @@ LINPHONE_PUBLIC int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *ca * - setting up/down the video stream according to the video parameter of the LinphoneCallParams (see linphone_call_params_enable_video() ). * - changing the size of the transmitted video after calling linphone_core_set_preferred_video_size() * In case no changes are requested through the LinphoneCallParams argument, then this argument can be omitted and set to NULL. + * WARNING: Updating a call in the LinphoneCallPaused state will still result in a paused call even if the media directions set in the + * params are sendrecv. To resume a paused call, you need to call linphone_core_resume_call(). * @param[in] lc LinphoneCore object * @param[in] call The call to be updated * @param[in] params The new call parameters to use (may be NULL) diff --git a/mediastreamer2 b/mediastreamer2 index dcfd617bf..66423e002 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit dcfd617bf70a131d9090d1d410f909a7a9cfadb0 +Subproject commit 66423e00293dc6f840428ad0e5dabd52f1ec0115 diff --git a/oRTP b/oRTP index 155f0c85c..767cbcd61 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 155f0c85cd659222e97b59b4bb7e0b036370f081 +Subproject commit 767cbcd61a28fa80e901d3f58ae6a7afc96c2879 diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index b929ceb80..b5c0bc576 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -130,7 +130,9 @@ set(RC_FILES rcfiles/zero_length_params_rc ) -set(IMAGE_FILES images/nowebcamCIF.jpg) +set(IMAGE_FILES + images/nowebcamCIF.jpg + images/nowebcamVGA.jpg) set(VCARD_FILES vcards/thousand_vcards.vcf diff --git a/tester/Makefile.am b/tester/Makefile.am index d6969b303..4bc979e1c 100644 --- a/tester/Makefile.am +++ b/tester/Makefile.am @@ -78,7 +78,7 @@ RCFILES = \ rcfiles/friends_rc\ rcfiles/carddav_rc -IMAGE_FILES = images/nowebcamCIF.jpg +IMAGE_FILES = images/nowebcamCIF.jpg images/nowebcamVGA.jpg VCARDS_FILE = vcards/vcards.vcf vcards/thousand_vcards.vcf diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index d0dbd4c0b..d3a036eca 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -2899,6 +2899,7 @@ static void call_rejected_because_wrong_credentials_with_params(const char* user ((VTableReference*)(marie->lc->vtable_refs->data))->cbs->vtable->auth_info_requested=NULL; linphone_core_add_auth_info(marie->lc,wrong_auth_info); } + BC_ASSERT_PTR_NOT_NULL(linphone_core_invite_address(marie->lc,marie->identity)); @@ -2918,6 +2919,7 @@ static void call_rejected_because_wrong_credentials_with_params(const char* user linphone_core_clear_all_auth_info(marie->lc); linphone_core_add_auth_info(marie->lc,good_auth_info); linphone_auth_info_destroy(good_auth_info); + linphone_auth_info_destroy(wrong_auth_info); linphone_core_manager_destroy(marie); } @@ -5381,7 +5383,7 @@ static void call_with_network_reachable_down_in_callback(void){ linphone_core_cbs_set_call_state_changed(cbs, my_call_state_changed_cb); - marie = linphone_core_manager_new("marie_rc"); + marie = linphone_core_manager_new("laure_rc_udp"); linphone_core_add_callbacks(marie->lc, cbs); diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index a4d415024..7cd5179b7 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -69,11 +69,24 @@ static void call_paused_resumed_with_video_base(bool_t sdp_200_ack 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)); + if (resume_in_audio_send_only_video_inactive_first) { + LinphoneCallParams *params = linphone_core_create_call_params(pauline->lc, call_pauline); + linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendOnly); + linphone_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); + linphone_core_update_call(pauline->lc, call_pauline, params); + linphone_call_params_unref(params); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdating,1)); + } else { + 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)); + if (resume_in_audio_send_only_video_inactive_first) { + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2)); + } else { + 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); @@ -93,19 +106,19 @@ static void call_paused_resumed_with_video_base(bool_t sdp_200_ack /*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_call_params_set_video_direction(params,LinphoneMediaDirectionInactive); 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); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3)); linphone_call_params_set_audio_direction(params,LinphoneMediaDirectionSendRecv); + linphone_call_params_set_video_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)); + BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,4)); linphone_call_params_unref(params); } else { linphone_core_resume_call(pauline->lc, call_pauline); diff --git a/tester/images/nowebcamVGA.jpg b/tester/images/nowebcamVGA.jpg new file mode 100644 index 000000000..968234d32 Binary files /dev/null and b/tester/images/nowebcamVGA.jpg differ diff --git a/tester/message_tester.c b/tester/message_tester.c index 17b0d9634..4ec384cd5 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -75,34 +75,25 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess void file_transfer_received(LinphoneChatMessage *msg, const LinphoneContent* content, const LinphoneBuffer *buffer){ FILE* file=NULL; char *receive_file = NULL; - LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(msg); - LinphoneCore *lc = linphone_chat_room_get_core(cr); - if (linphone_chat_message_get_file_transfer_filepath(msg) != NULL) { - if (linphone_buffer_is_empty(buffer)) { - stats* counters = get_stats(lc); - counters->number_of_LinphoneFileTransferDownloadSuccessful++; - return; - } - } else { - 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*/ - } - bc_free(receive_file); - file = (FILE*)linphone_chat_message_get_user_data(msg); - BC_ASSERT_PTR_NOT_NULL(file); - if (linphone_buffer_is_empty(buffer)) { /* tranfer complete */ - stats* counters = get_stats(lc); - counters->number_of_LinphoneFileTransferDownloadSuccessful++; - linphone_chat_message_set_user_data(msg, NULL); - fclose(file); - } 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)); - } + // If a file path is set, we should NOT call the on_recv callback ! + BC_ASSERT_PTR_NULL(msg->file_transfer_filepath); + + 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*/ + } + bc_free(receive_file); + file = (FILE*)linphone_chat_message_get_user_data(msg); + BC_ASSERT_PTR_NOT_NULL(file); + if (linphone_buffer_is_empty(buffer)) { /* tranfer complete */ + linphone_chat_message_set_user_data(msg, NULL); + fclose(file); + } 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)); } } } @@ -116,6 +107,9 @@ LinphoneBuffer * tester_file_transfer_send(LinphoneChatMessage *msg, const Linph 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(msg->file_transfer_filepath); BC_ASSERT_PTR_NOT_NULL(file_to_send); if (file_to_send == NULL){ @@ -126,7 +120,7 @@ LinphoneBuffer * tester_file_transfer_send(LinphoneChatMessage *msg, const Linph 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, size_to_send, 1, file_to_send)!=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); @@ -154,6 +148,9 @@ void file_transfer_progress_indication(LinphoneChatMessage *msg, const LinphoneC ,(linphone_chat_message_is_outgoing(msg)?"to":"from") , address); counters->progress_of_LinphoneFileTransfer = progress; + if (progress == 100) { + counters->number_of_LinphoneFileTransferDownloadSuccessful++; + } free(address); } @@ -224,7 +221,7 @@ LinphoneChatMessage* create_message_from_nowebcam(LinphoneChatRoom *chat_room) { LinphoneContent* content; LinphoneChatMessage* msg; size_t file_size; - char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); + char *send_filepath = bc_tester_res("images/nowebcamVGA.jpg"); file_to_send = fopen(send_filepath, "rb"); fseek(file_to_send, 0, SEEK_END); file_size = ftell(file_to_send); @@ -235,7 +232,7 @@ LinphoneChatMessage* create_message_from_nowebcam(LinphoneChatRoom *chat_room) { linphone_content_set_type(content,"image"); linphone_content_set_subtype(content,"jpeg"); linphone_content_set_size(content,file_size); /*total size to be transfered*/ - linphone_content_set_name(content,"nowebcamCIF.jpg"); + linphone_content_set_name(content,"nowebcamVGA.jpg"); msg = linphone_chat_room_create_file_transfer_message(chat_room, content); cbs = linphone_chat_message_get_callbacks(msg); @@ -243,6 +240,7 @@ LinphoneChatMessage* create_message_from_nowebcam(LinphoneChatRoom *chat_room) { linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); linphone_chat_message_set_user_data(msg, file_to_send); + BC_ASSERT_PTR_NOT_NULL(linphone_chat_message_get_user_data(msg)); linphone_content_unref(content); ms_free(send_filepath); @@ -253,17 +251,18 @@ LinphoneChatMessage* create_file_transfer_message_from_nowebcam(LinphoneChatRoom LinphoneChatMessageCbs *cbs; LinphoneContent* content; LinphoneChatMessage* msg; - char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); + char *send_filepath = bc_tester_res("images/nowebcamVGA.jpg"); content = linphone_core_create_content(chat_room->lc); belle_sip_object_set_name(&content->base, "nowebcam content"); linphone_content_set_type(content,"image"); linphone_content_set_subtype(content,"jpeg"); - linphone_content_set_name(content,"nowebcamCIF.jpg"); + linphone_content_set_name(content,"nowebcamVGA.jpg"); msg = linphone_chat_room_create_file_transfer_message(chat_room, content); linphone_chat_message_set_file_transfer_filepath(msg, send_filepath); cbs = linphone_chat_message_get_callbacks(msg); + linphone_chat_message_cbs_set_file_transfer_send(cbs, tester_file_transfer_send); linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); @@ -451,7 +450,7 @@ static void text_message_with_external_body(void) { void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pauline, bool_t upload_error, bool_t download_error, bool_t use_file_body_handler_in_upload, bool_t use_file_body_handler_in_download, bool_t download_from_history) { - char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); + char *send_filepath = bc_tester_res("images/nowebcamVGA.jpg"); char *receive_filepath = bc_tester_file("receive_file.dump"); LinphoneChatRoom* chat_room; LinphoneChatMessage* msg; @@ -681,7 +680,7 @@ static void file_transfer_2_messages_simultaneously(void) { LinphoneChatMessage* msg; LinphoneChatMessage* msg2; LinphoneChatMessageCbs *cbs; - char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); + char *send_filepath = bc_tester_res("images/nowebcamVGA.jpg"); char *receive_filepath = bc_tester_file("receive_file.dump"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); @@ -722,11 +721,13 @@ static void file_transfer_2_messages_simultaneously(void) { cbs = linphone_chat_message_get_callbacks(msg); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); + linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); linphone_chat_message_download_file(msg); cbs = linphone_chat_message_get_callbacks(msg2); linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); + linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); linphone_chat_message_download_file(msg2); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,2)); @@ -1217,7 +1218,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st LinphoneChatMessageCbs *cbs; char *pauline_id, *marie_id; char *filepath; - char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg"); + char *send_filepath = bc_tester_res("images/nowebcamVGA.jpg"); char *receive_filepath = bc_tester_file("receive_file.dump"); MSList * msg_list = NULL; @@ -1286,6 +1287,7 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st 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_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); content = linphone_chat_message_get_file_transfer_information(recv_msg); if (!content) goto end; if (encrypt_file) @@ -1564,7 +1566,7 @@ int message_tester_copy_file(const char *from, const char *to) } /* Copy data from "in" to "out" */ - while ( (n=fread(buf, 1, sizeof buf, in)) > 0 ) + while ( (n=fread(buf, sizeof(char), sizeof(buf), in)) > 0 ) { if ( ! fwrite(buf, 1, n, out) ) { diff --git a/wrappers/cpp/CMakeLists.txt b/wrappers/cpp/CMakeLists.txt index 164870026..a1630a524 100644 --- a/wrappers/cpp/CMakeLists.txt +++ b/wrappers/cpp/CMakeLists.txt @@ -1,119 +1,17 @@ -set(GENERATED_SOURCES - src/account_creator.cc - src/address.cc - src/auth_info.cc - src/buffer.cc - src/call.cc - src/call_log.cc - src/call_params.cc - src/call_stats.cc - src/chat_message.cc - src/chat_room.cc - src/conference.cc - src/conference_params.cc - src/config.cc - src/content.cc - src/core.cc - src/core_v_table.cc - src/error_info.cc - src/event.cc - src/factory.cc - src/friend.cc - src/friend_list.cc - src/nat_policy.cc - src/payload_type.cc - src/player.cc - src/presence_activity.cc - src/presence_model.cc - src/presence_note.cc - src/presence_person.cc - src/presence_service.cc - src/proxy_config.cc - src/sip_transports.cc - src/tunnel.cc - src/tunnel_config.cc - src/vcard.cc - src/video_policy.cc - src/xml_rpc_request.cc - src/xml_rpc_session.cc -) -set(SOURCES - ${GENERATED_SOURCES} - object.cc -) -set(GENERATED_HEADERS - ${CMAKE_CURRENT_BINARY_DIR}/include/account_creator.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/account_creator_listener.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/address.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/auth_info.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/buffer.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/call.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/call_log.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/call_params.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/call_stats.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/chat_message.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/chat_message_listener.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/chat_room.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/conference.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/conference_params.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/config.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/content.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/core.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/core_listener.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/core_v_table.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/enums.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/error_info.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/event.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/factory.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/friend.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/friend_list.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/friend_list_listener.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/linphone.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/nat_policy.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/payload_type.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/player.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/presence_activity.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/presence_model.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/presence_note.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/presence_person.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/presence_service.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/proxy_config.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/sip_transports.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/tunnel_config.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/tunnel.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/vcard.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/video_policy.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/xml_rpc_request.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/xml_rpc_request_listener.hh - ${CMAKE_CURRENT_BINARY_DIR}/include/xml_rpc_session.hh -) -set(HEADERS - ${GENERATED_HEADERS} - object.hh -) +configure_file(c_make_lists.mustache.in c_make_lists.mustache @ONLY) +configure_file(object.cc src/object.cc COPYONLY) +configure_file(object.hh include/object.hh COPYONLY) -add_custom_command(OUTPUT ${GENERATED_SOURCES} ${GENERATED_HEADERS} +add_custom_command(OUTPUT CMakeLists.txt include/linphone.hh COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/genheaders.py" "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml" - DEPENDS *.py *.mustache linphone-doc "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml/index.xml" + DEPENDS *.py *.mustache linphone-doc + "${PROJECT_BINARY_DIR}/coreapi/help/doc/xml/index.xml" + "${CMAKE_CURRENT_BINARY_DIR}/c_make_lists.mustache" ) - -add_compile_options(-Wall -Wextra -Wno-deprecated-declarations -Wno-unused-parameter -Werror --std=c++11) -add_definitions(-DWRAPPER_BUILD) - -add_library(linphone++ SHARED ${SOURCES}) -target_link_libraries(linphone++ PRIVATE linphone) -target_include_directories(linphone++ - PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${PROJECT_SOURCE_DIR} +add_custom_target(make_cpp_wrapper ALL ${CMAKE_COMMAND} -E make_directory build/ + COMMAND ${CMAKE_COMMAND} -E chdir build/ ${CMAKE_COMMAND} .. -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + COMMAND ${CMAKE_COMMAND} --build build/ + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_BINARY_DIR}/include/linphone.hh ) -set_target_properties(linphone++ - PROPERTIES SOVERSION ${LINPHONE_SO_VERSION} -) - -install(TARGETS linphone++ - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -) -install(FILES ${HEADERS} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/linphone++ -) - +install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/build --target install)") diff --git a/wrappers/cpp/abstractapi.py b/wrappers/cpp/abstractapi.py index 5b6a5cd23..790891e2e 100644 --- a/wrappers/cpp/abstractapi.py +++ b/wrappers/cpp/abstractapi.py @@ -1,3 +1,19 @@ +# Copyright (C) 2017 Belledonne Communications SARL +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + import re import genapixml as CApi diff --git a/wrappers/cpp/c_make_lists.mustache.in b/wrappers/cpp/c_make_lists.mustache.in new file mode 100644 index 000000000..9484d28f0 --- /dev/null +++ b/wrappers/cpp/c_make_lists.mustache.in @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.0) + +include(GNUInstallDirs) + +set(GENERATED_SOURCES + {{#classes}} + src/{{{source}}} + {{/classes}} +) +set(SOURCES + ${GENERATED_SOURCES} + src/object.cc +) +set(GENERATED_HEADERS + {{#classes}} + ${CMAKE_CURRENT_SOURCE_DIR}/include/{{{header}}} + {{/classes}} +) +set(HEADERS + ${GENERATED_HEADERS} + ${CMAKE_CURRENT_SOURCE_DIR}/include/object.hh +) + +add_library(linphone++ SHARED ${SOURCES}) +target_link_libraries(linphone++ PRIVATE @PROJECT_BINARY_DIR@/coreapi/liblinphone.so.@LINPHONE_SO_VERSION@) +target_include_directories(linphone++ + PUBLIC include + PRIVATE @PROJECT_SOURCE_DIR@/include +) +set_target_properties(linphone++ + PROPERTIES SOVERSION @LINPHONE_SO_VERSION@ +) + +install(TARGETS linphone++ + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install(FILES ${HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/linphone++ +) + diff --git a/wrappers/cpp/class_header.mustache b/wrappers/cpp/class_header.mustache index 5f63341f8..61b458ce7 100644 --- a/wrappers/cpp/class_header.mustache +++ b/wrappers/cpp/class_header.mustache @@ -1,3 +1,21 @@ +/* +Copyright (C) 2017 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #ifndef {{define}} #define {{define}} diff --git a/wrappers/cpp/class_impl.mustache b/wrappers/cpp/class_impl.mustache index b993397c3..19889a091 100644 --- a/wrappers/cpp/class_impl.mustache +++ b/wrappers/cpp/class_impl.mustache @@ -1,3 +1,21 @@ +/* +Copyright (C) 2017 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include "linphone.hh" using namespace {{{namespace}}}; diff --git a/wrappers/cpp/enums_header.mustache b/wrappers/cpp/enums_header.mustache index aaf7b9dff..46d9b8220 100644 --- a/wrappers/cpp/enums_header.mustache +++ b/wrappers/cpp/enums_header.mustache @@ -1,3 +1,21 @@ +/* +Copyright (C) 2017 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #ifndef _ENUMS_HH #define _ENUMS_HH diff --git a/wrappers/cpp/genheaders.py b/wrappers/cpp/genheaders.py index d00b3e5f2..113f2de63 100755 --- a/wrappers/cpp/genheaders.py +++ b/wrappers/cpp/genheaders.py @@ -1,5 +1,21 @@ #!/usr/bin/python +# Copyright (C) 2017 Belledonne Communications SARL +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + import pystache import re @@ -611,6 +627,11 @@ class ClassImpl(object): namespace = parsedClass.find_first_ancestor_by_type(AbsApi.Namespace) self.namespace = namespace.name.concatenate(fullName=True) if namespace is not None else None +class CMakeLists(object): + def __init__(self): + self.classes = [] + self.interfaces = [] + def main(): argparser = argparse.ArgumentParser(description='Generate source files for the C++ wrapper') @@ -631,26 +652,6 @@ def main(): parser = AbsApi.CParser(project) parser.parse_all() translator = CppTranslator() - #translator.ignore += ['linphone_tunnel_get_http_proxy', - #'linphone_core_can_we_add_call', - #'linphone_core_get_default_proxy', - #'linphone_core_add_listener', - #'linphone_core_remove_listener', - #'linphone_core_get_current_callbacks', - #'linphone_proxy_config_normalize_number', - #'linphone_proxy_config_set_file_transfer_server', - #'linphone_proxy_config_get_file_transfer_server', - #'linphone_factory_create_core', - #'linphone_factory_create_core_with_config', - #'linphone_buffer_get_content', - #'linphone_chat_room_send_chat_message', - #'linphone_config_read_relative_file', - #'linphone_core_new_with_config', - #'LinphoneImEncryptionEngine', - #'LinphoneImEncryptionEngineCbs', - #'LinphoneImNotifPolicy', - #'LpConfig'] - renderer = pystache.Renderer() header = EnumsHeader(translator) @@ -664,13 +665,23 @@ def main(): f.write(renderer.render(header)) mainHeader = MainHeader() + cmakelists = CMakeLists() for _class in parser.classesIndex.values() + parser.interfacesIndex.values(): if _class is not None: try: header = ClassHeader(_class, translator, ignore=['LinphoneBuffer']) impl = ClassImpl(_class, header._class) - mainHeader.add_include(_class.name.to_snake_case() + '.hh') + + headerName = _class.name.to_snake_case() + '.hh' + sourceName = _class.name.to_snake_case() + '.cc' + mainHeader.add_include(headerName) + + if type(_class) is AbsApi.Class: + cmakelists.classes.append({'header': headerName, 'source': sourceName}) + else: + cmakelists.interfaces.append({'header': headerName}) + with open(args.outputdir + '/include/' + header.filename, mode='w') as f: f.write(renderer.render(header)) @@ -683,6 +694,9 @@ def main(): with open(args.outputdir + '/include/linphone.hh', mode='w') as f: f.write(renderer.render(mainHeader)) + + with open(args.outputdir + '/CMakeLists.txt', mode='w') as f: + f.write(renderer.render(cmakelists)) if __name__ == '__main__': diff --git a/wrappers/cpp/main_header.mustache b/wrappers/cpp/main_header.mustache index 9bc3acf87..e8493c720 100644 --- a/wrappers/cpp/main_header.mustache +++ b/wrappers/cpp/main_header.mustache @@ -1,3 +1,22 @@ +/* +linphone.hh +Copyright (C) 2017 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #ifndef {{{define}}} #define {{{define}}} diff --git a/wrappers/cpp/object.cc b/wrappers/cpp/object.cc index 9a3e1e356..7afb183cc 100644 --- a/wrappers/cpp/object.cc +++ b/wrappers/cpp/object.cc @@ -1,3 +1,22 @@ +/* +object.cc +Copyright (C) 2017 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #include "object.hh" #include #include diff --git a/wrappers/cpp/object.hh b/wrappers/cpp/object.hh index 57d93acd4..b827bb631 100644 --- a/wrappers/cpp/object.hh +++ b/wrappers/cpp/object.hh @@ -1,3 +1,22 @@ +/* +object.hh +Copyright (C) 2017 Belledonne Communications SARL + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + #ifndef _LINPHONE_OBJECT_HH #define _LINPHONE_OBJECT_HH