From 4029e83de77b5c82a8ca6512a43b5f8be48e619f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 28 Sep 2017 15:52:31 +0200 Subject: [PATCH] Use string conversion macros. --- src/c-wrapper/api/c-call-params.cpp | 25 ++++++++++-------------- src/c-wrapper/api/c-call.cpp | 7 +++---- src/c-wrapper/api/c-chat-room.cpp | 4 ++-- src/conference/session/media-session.cpp | 6 +++--- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/c-wrapper/api/c-call-params.cpp b/src/c-wrapper/api/c-call-params.cpp index e4415fb73..1750d14e4 100644 --- a/src/c-wrapper/api/c-call-params.cpp +++ b/src/c-wrapper/api/c-call-params.cpp @@ -90,15 +90,15 @@ void linphone_call_params_set_custom_sdp_media_attributes (LinphoneCallParams *p // ============================================================================= void linphone_call_params_add_custom_header (LinphoneCallParams *params, const char *header_name, const char *header_value) { - L_GET_CPP_PTR_FROM_C_OBJECT(params)->addCustomHeader(header_name, header_value); + L_GET_CPP_PTR_FROM_C_OBJECT(params)->addCustomHeader(header_name, L_C_TO_STRING(header_value)); } void linphone_call_params_add_custom_sdp_attribute (LinphoneCallParams *params, const char *attribute_name, const char *attribute_value) { - L_GET_CPP_PTR_FROM_C_OBJECT(params)->addCustomSdpAttribute(attribute_name, attribute_value); + L_GET_CPP_PTR_FROM_C_OBJECT(params)->addCustomSdpAttribute(attribute_name, L_C_TO_STRING(attribute_value)); } void linphone_call_params_add_custom_sdp_media_attribute (LinphoneCallParams *params, LinphoneStreamType type, const char *attribute_name, const char *attribute_value) { - L_GET_CPP_PTR_FROM_C_OBJECT(params)->addCustomSdpMediaAttribute(type, attribute_name, attribute_value); + L_GET_CPP_PTR_FROM_C_OBJECT(params)->addCustomSdpMediaAttribute(type, attribute_name, L_C_TO_STRING(attribute_value)); } void linphone_call_params_clear_custom_sdp_attributes (LinphoneCallParams *params) { @@ -139,18 +139,15 @@ void linphone_call_params_enable_video (LinphoneCallParams *params, bool_t enabl } const char *linphone_call_params_get_custom_header (const LinphoneCallParams *params, const char *header_name) { - string value = L_GET_CPP_PTR_FROM_C_OBJECT(params)->getCustomHeader(header_name); - return value.empty() ? nullptr : value.c_str(); + return L_GET_CPP_PTR_FROM_C_OBJECT(params)->getCustomHeader(header_name); } const char *linphone_call_params_get_custom_sdp_attribute (const LinphoneCallParams *params, const char *attribute_name) { - string value = L_GET_CPP_PTR_FROM_C_OBJECT(params)->getCustomSdpAttribute(attribute_name); - return value.empty() ? nullptr : value.c_str(); + return L_GET_CPP_PTR_FROM_C_OBJECT(params)->getCustomSdpAttribute(attribute_name); } const char *linphone_call_params_get_custom_sdp_media_attribute (const LinphoneCallParams *params, LinphoneStreamType type, const char *attribute_name) { - string value = L_GET_CPP_PTR_FROM_C_OBJECT(params)->getCustomSdpMediaAttribute(type, attribute_name); - return value.empty() ? nullptr : value.c_str(); + return L_GET_CPP_PTR_FROM_C_OBJECT(params)->getCustomSdpMediaAttribute(type, attribute_name); } bool_t linphone_call_params_get_local_conference_mode (const LinphoneCallParams *params) { @@ -187,8 +184,7 @@ const LinphoneVideoDefinition *linphone_call_params_get_received_video_definitio } const char *linphone_call_params_get_record_file (const LinphoneCallParams *params) { - const string &value = L_GET_CPP_PTR_FROM_C_OBJECT(params)->getRecordFilePath(); - return value.empty() ? nullptr : value.c_str(); + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(params)->getRecordFilePath()); } const char *linphone_call_params_get_rtp_profile (const LinphoneCallParams *params) { @@ -217,8 +213,7 @@ const LinphoneVideoDefinition *linphone_call_params_get_sent_video_definition (c } const char *linphone_call_params_get_session_name (const LinphoneCallParams *params) { - const string &value = L_GET_CPP_PTR_FROM_C_OBJECT(params)->getSessionName(); - return value.empty() ? nullptr : value.c_str(); + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(params)->getSessionName()); } LinphonePayloadType *linphone_call_params_get_used_audio_payload_type (const LinphoneCallParams *params) { @@ -278,11 +273,11 @@ void linphone_call_params_set_privacy (LinphoneCallParams *params, LinphonePriva } void linphone_call_params_set_record_file (LinphoneCallParams *params, const char *path) { - L_GET_CPP_PTR_FROM_C_OBJECT(params)->setRecordFilePath(path ? path : ""); + L_GET_CPP_PTR_FROM_C_OBJECT(params)->setRecordFilePath(L_C_TO_STRING(path)); } void linphone_call_params_set_session_name (LinphoneCallParams *params, const char *name) { - L_GET_CPP_PTR_FROM_C_OBJECT(params)->setSessionName(name ? name : ""); + L_GET_CPP_PTR_FROM_C_OBJECT(params)->setSessionName(L_C_TO_STRING(name)); } bool_t linphone_call_params_audio_enabled (const LinphoneCallParams *params) { diff --git a/src/c-wrapper/api/c-call.cpp b/src/c-wrapper/api/c-call.cpp index 3a398b8fb..3f49beeca 100644 --- a/src/c-wrapper/api/c-call.cpp +++ b/src/c-wrapper/api/c-call.cpp @@ -708,11 +708,11 @@ bool_t linphone_call_camera_enabled (const LinphoneCall *call) { } LinphoneStatus linphone_call_take_video_snapshot (LinphoneCall *call, const char *file) { - return L_GET_CPP_PTR_FROM_C_OBJECT(call)->takeVideoSnapshot(file ? file : ""); + return L_GET_CPP_PTR_FROM_C_OBJECT(call)->takeVideoSnapshot(L_C_TO_STRING(file)); } LinphoneStatus linphone_call_take_preview_snapshot (LinphoneCall *call, const char *file) { - return L_GET_CPP_PTR_FROM_C_OBJECT(call)->takePreviewSnapshot(file ? file : ""); + return L_GET_CPP_PTR_FROM_C_OBJECT(call)->takePreviewSnapshot(L_C_TO_STRING(file)); } LinphoneReason linphone_call_get_reason (const LinphoneCall *call) { @@ -745,8 +745,7 @@ const char * linphone_call_get_remote_contact (LinphoneCall *call) { } const char *linphone_call_get_authentication_token (LinphoneCall *call) { - string token = L_GET_CPP_PTR_FROM_C_OBJECT(call)->getAuthenticationToken(); - return token.empty() ? nullptr : token.c_str(); + return L_STRING_TO_C(L_GET_CPP_PTR_FROM_C_OBJECT(call)->getAuthenticationToken()); } bool_t linphone_call_get_authentication_token_verified (const LinphoneCall *call) { diff --git a/src/c-wrapper/api/c-chat-room.cpp b/src/c-wrapper/api/c-chat-room.cpp index f3ea4571d..251e560d6 100644 --- a/src/c-wrapper/api/c-chat-room.cpp +++ b/src/c-wrapper/api/c-chat-room.cpp @@ -97,7 +97,7 @@ const LinphoneAddress *linphone_chat_room_get_peer_address (LinphoneChatRoom *cr } LinphoneChatMessage *linphone_chat_room_create_message (LinphoneChatRoom *cr, const char *message) { - return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createMessage(message ? message : ""); + return L_GET_CPP_PTR_FROM_C_OBJECT(cr)->createMessage(L_C_TO_STRING(message)); } LinphoneChatMessage *linphone_chat_room_create_message_2 ( @@ -304,7 +304,7 @@ LinphoneChatRoom *_linphone_client_group_chat_room_new (LinphoneCore *core, cons from = linphone_core_get_primary_contact(core); LinphonePrivate::Address me(from); LinphoneChatRoom *cr = L_INIT(ChatRoom); - L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared(core, me, subject ? subject : "")); + L_SET_CPP_PTR_FROM_C_OBJECT(cr, make_shared(core, me, L_C_TO_STRING(subject))); L_GET_PRIVATE_FROM_C_OBJECT(cr)->setState(LinphonePrivate::ChatRoom::State::Instantiated); return cr; } diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index 08e362a92..3b2c377ae 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -2552,8 +2552,8 @@ void MediaSessionPrivate::startAudioStream (LinphoneCallState targetState, bool MSSndCard *captcard = core->sound_conf.capt_sndcard; if (!captcard) lWarning() << "No card defined for capture!"; - string playfile = core->play_file ? core->play_file : ""; - string recfile = core->rec_file ? core->rec_file : ""; + string playfile = L_C_TO_STRING(core->play_file); + string recfile = L_C_TO_STRING(core->rec_file); /* Don't use file or soundcard capture when placed in recv-only mode */ if ((stream->rtp_port == 0) || (stream->dir == SalStreamRecvOnly) || ((stream->multicast_role == SalMulticastReceiver) && isMulticast)) { captcard = nullptr; @@ -3106,7 +3106,7 @@ void MediaSessionPrivate::updateFrozenPayloads (SalMediaDescription *result) { /* New codec, needs to be added to the list */ localDesc->streams[i].already_assigned_payloads = bctbx_list_append(localDesc->streams[i].already_assigned_payloads, payload_type_clone(pt)); lInfo() << "CallSession[" << q << "] : payload type " << payload_type_get_number(pt) << " " << pt->mime_type << "/" << pt->clock_rate - << " fmtp=" << (pt->recv_fmtp ? pt->recv_fmtp : "") << " added to frozen list"; + << " fmtp=" << L_C_TO_STRING(pt->recv_fmtp) << " added to frozen list"; } } }