Commit 2f1d16a3 authored by Ghislain MARY's avatar Ghislain MARY

Use c-wrapper for the Core object.

parent 2b8e1cca
......@@ -38,6 +38,7 @@ list(APPEND LINPHONE_PRIVATE_HEADER_FILES
carddav.h
conference_private.h
contact_providers_priv.h
core_private.h
enum.h
lime.h
lpc2xml.h
......
......@@ -30,6 +30,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <bctoolbox/crypto.h>
// TODO: From coreapi. Remove me later.
#include "private.h"
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorCbs);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorCbs, belle_sip_object_t,
......
......@@ -22,6 +22,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorService);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneAccountCreatorService, belle_sip_object_t,
......
......@@ -28,6 +28,9 @@
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
static void _linphone_auth_info_uninit(LinphoneAuthInfo *obj);
static void _linphone_auth_info_copy(LinphoneAuthInfo *dst, const LinphoneAuthInfo *src);
......
......@@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
static void linphone_buffer_destroy(LinphoneBuffer *buffer) {
if (buffer->content) belle_sip_free(buffer->content);
}
......
......@@ -35,6 +35,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
typedef struct _CallLogStorageResult {
LinphoneCore *core;
bctbx_list_t *result;
......
......@@ -54,22 +54,6 @@ using namespace LinphonePrivate;
static void register_failure(SalOp *op);
static bool_t already_a_call_with_remote_address(const LinphoneCore *lc, const LinphoneAddress *remote) {
bctbx_list_t *elem;
ms_message("Searching for already_a_call_with_remote_address.");
for(elem=lc->calls;elem!=NULL;elem=elem->next){
const LinphoneCall *call=(LinphoneCall*)elem->data;
const LinphoneAddress *cRemote=linphone_call_get_remote_address(call);
if (linphone_address_weak_equal(cRemote,remote)) {
ms_warning("already_a_call_with_remote_address found.");
return TRUE;
}
}
return FALSE;
}
static LinphoneCall * look_for_broken_call_to_replace(LinphonePrivate::SalOp *h, LinphoneCore *lc) {
const bctbx_list_t *calls = linphone_core_get_calls(lc);
const bctbx_list_t *it = calls;
......@@ -128,7 +112,7 @@ static void call_received(SalCallOp *h) {
} else if (sal_address_has_param(h->get_remote_contact_address(), "text")) {
linphone_address_unref(toAddr);
linphone_address_unref(fromAddr);
shared_ptr<ChatRoom> chatRoom = lc->cppCore->findChatRoom(
shared_ptr<ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
ChatRoomId(IdentityAddress(h->get_to()), IdentityAddress(h->get_to()))
);
if (chatRoom) {
......@@ -169,7 +153,7 @@ static void call_received(SalCallOp *h) {
}
}
if (!linphone_core_can_we_add_call(lc)) { /* Busy */
if (!L_GET_PRIVATE_FROM_C_OBJECT(lc)->canWeAddCall()) { /* Busy */
h->decline(SalReasonBusy, nullptr);
LinphoneErrorInfo *ei = linphone_error_info_new();
linphone_error_info_set(ei, nullptr, LinphoneReasonBusy, 486, "Busy - too many calls", nullptr);
......@@ -186,7 +170,7 @@ static void call_received(SalCallOp *h) {
fromAddressToSearchIfMe = linphone_address_new(pAssertedId);
else
ms_warning("Hidden from identity, don't know if it's me");
if (fromAddressToSearchIfMe && already_a_call_with_remote_address(lc, fromAddressToSearchIfMe)) {
if (fromAddressToSearchIfMe && L_GET_PRIVATE_FROM_C_OBJECT(lc)->isAlreadyInCallWithAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(fromAddressToSearchIfMe))) {
char *addr = linphone_address_as_string(fromAddr);
ms_warning("Receiving a call while one with same address [%s] is initiated, refusing this one with busy message", addr);
h->decline(SalReasonBusy, nullptr);
......@@ -767,7 +751,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
if (addr.hasUriParam("method") && (addr.getUriParamValue("method") == "BYE")) {
if (linphone_core_conference_server_enabled(lc)) {
// Removal of a participant at the server side
shared_ptr<ChatRoom> chatRoom = lc->cppCore->findChatRoom(
shared_ptr<ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
ChatRoomId(IdentityAddress(op->get_to()), IdentityAddress(op->get_to()))
);
if (chatRoom) {
......@@ -785,7 +769,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
} else {
// The server asks a participant to leave a chat room
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(
lc->cppCore->findChatRoom(ChatRoomId(addr, IdentityAddress(op->get_to())))
L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(ChatRoomId(addr, IdentityAddress(op->get_to())))
);
if (cr) {
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->leave();
......@@ -795,7 +779,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
static_cast<SalReferOp *>(op)->reply(SalReasonDeclined);
}
} else if (addr.hasParam("admin")) {
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(lc->cppCore->findChatRoom(
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
ChatRoomId(IdentityAddress(op->get_to()), IdentityAddress(op->get_to()))
));
if (cr) {
......@@ -814,7 +798,7 @@ static void refer_received(SalOp *op, const SalAddress *refer_to){
return;
}
} else {
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(lc->cppCore->findChatRoom(ChatRoomId(addr, IdentityAddress(op->get_to()))));
LinphoneChatRoom *cr = L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(ChatRoomId(addr, IdentityAddress(op->get_to()))));
if (!cr)
cr = _linphone_client_group_chat_room_new(lc, addr.asString().c_str(), nullptr);
L_GET_CPP_PTR_FROM_C_OBJECT(cr)->join();
......
......@@ -60,12 +60,12 @@ bool_t linphone_core_chat_enabled(const LinphoneCore *lc) {
const bctbx_list_t *linphone_core_get_chat_rooms (LinphoneCore *lc) {
if (lc->chat_rooms)
bctbx_list_free_with_data(lc->chat_rooms, (bctbx_list_free_func)linphone_chat_room_unref);
lc->chat_rooms = L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(lc->cppCore->getChatRooms());
lc->chat_rooms = L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getChatRooms());
return lc->chat_rooms;
}
static LinphoneChatRoom *linphone_chat_room_new (LinphoneCore *core, const LinphoneAddress *addr) {
return L_GET_C_BACK_PTR(core->cppCore->getOrCreateBasicChatRoom(
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(core)->getOrCreateBasicChatRoom(
*L_GET_CPP_PTR_FROM_C_OBJECT(addr),
linphone_core_realtime_text_enabled(core)
));
......@@ -79,11 +79,11 @@ LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call){
}
LinphoneChatRoom *linphone_core_get_chat_room (LinphoneCore *lc, const LinphoneAddress *addr) {
return L_GET_C_BACK_PTR(lc->cppCore->getOrCreateBasicChatRoom(*L_GET_CPP_PTR_FROM_C_OBJECT(addr)));
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getOrCreateBasicChatRoom(*L_GET_CPP_PTR_FROM_C_OBJECT(addr)));
}
LinphoneChatRoom *linphone_core_create_client_group_chat_room (LinphoneCore *lc, const char *subject) {
return L_GET_C_BACK_PTR(lc->cppCore->createClientGroupChatRoom(L_C_TO_STRING(subject)));
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->createClientGroupChatRoom(L_C_TO_STRING(subject)));
}
LinphoneChatRoom *_linphone_core_join_client_group_chat_room (LinphoneCore *lc, const LinphonePrivate::Address &addr) {
......@@ -101,7 +101,7 @@ void linphone_core_delete_chat_room (LinphoneCore *, LinphoneChatRoom *cr) {
}
LinphoneChatRoom *linphone_core_get_chat_room_from_uri(LinphoneCore *lc, const char *to) {
return L_GET_C_BACK_PTR(lc->cppCore->getOrCreateBasicChatRoomFromUri(L_C_TO_STRING(to)));
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getOrCreateBasicChatRoomFromUri(L_C_TO_STRING(to)));
}
LinphoneChatRoom *linphone_core_find_chat_room(
......@@ -109,7 +109,7 @@ LinphoneChatRoom *linphone_core_find_chat_room(
const LinphoneAddress *peer_addr,
const LinphoneAddress *local_addr
) {
return L_GET_C_BACK_PTR(lc->cppCore->findChatRoom(LinphonePrivate::ChatRoomId(
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ChatRoomId(
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(peer_addr)),
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(local_addr))
)));
......@@ -120,7 +120,7 @@ LinphoneChatRoom *linphone_core_find_one_to_one_chat_room (
const LinphoneAddress *local_addr,
const LinphoneAddress *participant_addr
) {
return L_GET_C_BACK_PTR(lc->cppCore->findOneToOneChatRoom(
return L_GET_C_BACK_PTR(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findOneToOneChatRoom(
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(local_addr)),
LinphonePrivate::IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(participant_addr))
));
......@@ -137,7 +137,7 @@ int linphone_core_message_received(LinphoneCore *lc, LinphonePrivate::SalOp *op,
localAddress = op->get_to();
}
shared_ptr<LinphonePrivate::ChatRoom> chatRoom = lc->cppCore->findChatRoom(
shared_ptr<LinphonePrivate::ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(
LinphonePrivate::ChatRoomId(LinphonePrivate::IdentityAddress(peerAddress), LinphonePrivate::IdentityAddress(localAddress))
);
......
......@@ -36,6 +36,9 @@
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
using namespace std;
namespace Linphone {
......@@ -535,6 +538,7 @@ int LocalConference::remoteParticipantsCount() {
int LocalConference::convertConferenceToCall(){
int err=0;
#if 0
bctbx_list_t *calls=m_core->calls;
if (remoteParticipantsCount()!=1){
......@@ -551,6 +555,7 @@ int LocalConference::convertConferenceToCall(){
break;
}
}
#endif
return err;
}
......@@ -583,6 +588,7 @@ int LocalConference::removeParticipant(const LinphoneAddress *uri) {
}
int LocalConference::terminate() {
#if 0
bctbx_list_t *calls=m_core->calls;
m_terminating =TRUE;
......@@ -596,11 +602,12 @@ int LocalConference::terminate() {
Conference::terminate();
m_terminating = FALSE;
#endif
return 0;
}
int LocalConference::enter() {
#if 0
if (linphone_core_sound_resources_locked(m_core)) {
return -1;
}
......@@ -608,6 +615,7 @@ int LocalConference::enter() {
_linphone_call_pause(m_core->current_call);
}
if (m_localParticipantStream==NULL) addLocalEndpoint();
#endif
return 0;
}
......
......@@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
static void linphone_content_set_sal_body_handler(LinphoneContent *content, SalBodyHandler *body_handler) {
if (content->body_handler != NULL) {
sal_body_handler_unref(content->body_handler);
......
/*
* core_private.h
* Copyright (C) 2010-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 _CORE_PRIVATE_H_
#define _CORE_PRIVATE_H_
#include "linphone/types.h"
#include "private_structs.h"
#include "private_types.h"
struct _LinphoneCore {
belle_sip_object_t base;
std::shared_ptr<LinphonePrivate::Core> cppPtr;
std::weak_ptr<LinphonePrivate::Core> weakCppPtr;
int owner;
LINPHONE_CORE_STRUCT_FIELDS
};
#endif /* _CORE_PRIVATE_H_ */
......@@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneErrorInfo);
static void linphone_error_info_reset(LinphoneErrorInfo *ei);
......
......@@ -23,6 +23,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
using namespace LinphonePrivate;
const char * linphone_subscription_dir_to_string(LinphoneSubscriptionDir dir){
......
......@@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
#ifndef PACKAGE_SOUND_DIR
#define PACKAGE_SOUND_DIR "."
#endif
......
......@@ -42,6 +42,9 @@
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
using namespace std;
using namespace LinphonePrivate;
......
......@@ -23,6 +23,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneFriendListCbs);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneFriendListCbs, belle_sip_object_t,
......
......@@ -21,6 +21,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneImNotifPolicy);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneImNotifPolicy, belle_sip_object_t,
......
......@@ -24,6 +24,9 @@
#include "c-wrapper/c-wrapper.h"
// TODO: From coreapi. Remove me later.
#include "private.h"
struct _LinphoneTunnelConfig {
belle_sip_object_t base;
char *host;
......
......@@ -51,7 +51,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "chat/chat-room/client-group-chat-room-p.h"
#include "chat/chat-room/server-group-chat-room-p.h"
#include "conference/handlers/remote-conference-event-handler.h"
#include "core/core.h"
#include "core/core-p.h"
// For migration purpose.
#include "address/address-p.h"
......@@ -128,7 +128,6 @@ static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t cu
static void set_sip_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t curtime);
static void set_media_network_reachable(LinphoneCore* lc,bool_t isReachable);
static void linphone_core_run_hooks(LinphoneCore *lc);
static void linphone_core_uninit(LinphoneCore *lc);
static void linphone_core_zrtp_cache_close(LinphoneCore *lc);
void linphone_core_zrtp_cache_db_init(LinphoneCore *lc, const char *fileName);
......@@ -456,15 +455,6 @@ void linphone_core_cbs_set_ec_calibration_audio_uninit(LinphoneCoreCbs *cbs, Lin
}
typedef belle_sip_object_t_vptr_t LinphoneCore_vptr_t;
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneCore);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneCore, belle_sip_object_t,
linphone_core_uninit, // destroy
NULL, // clone
NULL, // Marshall
FALSE
);
void lc_callback_obj_init(LCCallbackObj *obj,LinphoneCoreCbFunc func,void* ud) {
obj->_func=func;
obj->_user_data=ud;
......@@ -2021,8 +2011,7 @@ static void linphone_core_start(LinphoneCore * lc) {
lc->auto_net_state_mon=lc->sip_conf.auto_net_state_mon;
new(&lc->cppCore) std::shared_ptr<Core>();
lc->cppCore = Core::create(lc);
L_GET_PRIVATE_FROM_C_OBJECT(lc)->init();
linphone_core_set_state(lc,LinphoneGlobalOn,"Ready");
}
......@@ -2142,7 +2131,7 @@ static void linphone_core_internal_notify_received(LinphoneCore *lc, LinphoneEve
const LinphoneAddress *resource = linphone_event_get_resource(lev);
const LinphoneAddress *from = linphone_event_get_from(lev);
shared_ptr<ChatRoom> chatRoom = lc->cppCore->findChatRoom(LinphonePrivate::ChatRoomId(
shared_ptr<ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ChatRoomId(
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(from))
));
......@@ -2166,7 +2155,7 @@ static void _linphone_core_conference_subscription_state_changed(LinphoneCore *l
state == LinphoneSubscriptionIncomingReceived
) {
const LinphoneAddress *resource = linphone_event_get_resource(lev);
shared_ptr<ChatRoom> chatRoom = lc->cppCore->findChatRoom(LinphonePrivate::ChatRoomId(
shared_ptr<ChatRoom> chatRoom = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->findChatRoom(LinphonePrivate::ChatRoomId(
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource)),
IdentityAddress(*L_GET_CPP_PTR_FROM_C_OBJECT(resource))
));
......@@ -2326,7 +2315,8 @@ static void _linphone_core_set_system_context(LinphoneCore *lc, void *system_con
#endif
LinphoneCore *_linphone_core_new_with_config(LinphoneCoreCbs *cbs, struct _LpConfig *config, void *userdata, void *system_context) {
LinphoneCore *core = belle_sip_object_new(LinphoneCore);
LinphoneCore *core = L_INIT(Core);
Core::create(core);
linphone_core_init(core, cbs, config, userdata, system_context);
return core;
}
......@@ -2737,13 +2727,11 @@ bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc){
}
static void apply_jitter_value(LinphoneCore *lc, int value, MSFormatType stype){
LinphoneCall *call;
bctbx_list_t *it;
for (it=lc->calls;it!=NULL;it=it->next){
MediaStream *ms;
call=(LinphoneCall*)it->data;
ms = stype==MSAudio ? linphone_call_get_stream(call, LinphoneStreamTypeAudio) : linphone_call_get_stream(call, LinphoneStreamTypeVideo);
if (ms){
for (const auto &call : L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCalls()) {
MediaStream *ms = (stype == MSAudio)
? L_GET_PRIVATE(call)->getMediaStream(LinphoneStreamTypeAudio)
: L_GET_PRIVATE(call)->getMediaStream(LinphoneStreamTypeVideo);
if (ms) {
RtpSession *s=ms->sessions.rtp_session;
if (s){
if (value>0){
......@@ -3210,8 +3198,6 @@ static void linphone_core_do_plugin_tasks(LinphoneCore *lc){
}
void linphone_core_iterate(LinphoneCore *lc){
bctbx_list_t *calls;
LinphoneCall *call;
uint64_t curtime_ms = ms_get_cur_time_ms(); /*monotonic time*/
time_t current_real_time = ms_time(NULL);
int64_t diff_time;
......@@ -3251,7 +3237,6 @@ void linphone_core_iterate(LinphoneCore *lc){
lc->prevtime_ms = curtime_ms;
}else{
lc->prevtime_ms += 1000;
}
}
......@@ -3301,17 +3286,10 @@ void linphone_core_iterate(LinphoneCore *lc){
proxy_update(lc);
/* We have to iterate for each call */
calls = lc->calls;
while (calls) {
call = reinterpret_cast<LinphoneCall *>(bctbx_list_get_data(calls));
/* Get immediately a reference to next one in case the one we are going to examine is destroyed
* and removed during linphone_call_start_invite() */
calls = bctbx_list_next(calls);
L_GET_PRIVATE_FROM_C_OBJECT(call)->iterate(current_real_time, one_second_elapsed);
}
L_GET_PRIVATE_FROM_C_OBJECT(lc)->iterateCalls(current_real_time, one_second_elapsed);
if (linphone_core_video_preview_enabled(lc)){
if (lc->previewstream==NULL && lc->calls==NULL)
if (lc->previewstream==NULL && !L_GET_PRIVATE_FROM_C_OBJECT(lc)->hasCalls())
toggle_video_preview(lc,TRUE);
#ifdef VIDEO_ENABLED
if (lc->previewstream) video_stream_iterate(lc->previewstream);
......@@ -3613,9 +3591,8 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
return NULL;
}
if(!linphone_core_can_we_add_call(lc)){
if (!L_GET_PRIVATE_FROM_C_OBJECT(lc)->canWeAddCall())
return NULL;
}
cp = linphone_call_params_copy(params);
proxy=linphone_core_lookup_known_proxy(lc,addr);
......@@ -3636,8 +3613,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
call=linphone_call_new_outgoing(lc,parsed_url2,addr,cp,proxy);
linphone_address_unref(parsed_url2);
if(linphone_core_add_call(lc,call)!= 0)
{
if (L_GET_PRIVATE_FROM_C_OBJECT(lc)->addCall(L_GET_CPP_PTR_FROM_C_OBJECT(call)) != 0) {
ms_warning("we had a problem in adding the call into the invite ... weird");
linphone_call_unref(call);
linphone_call_params_unref(cp);
......@@ -3648,7 +3624,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
/* Unless this call is for a conference, it becomes now the current one*/
if (linphone_call_params_get_local_conference_mode(params) == FALSE)
#endif
lc->current_call=call;
L_GET_PRIVATE_FROM_C_OBJECT(lc)->setCurrentCall(L_GET_CPP_PTR_FROM_C_OBJECT(call));
bool defer = L_GET_PRIVATE_FROM_C_OBJECT(call)->initiateOutgoing();
if (!defer) {
if (L_GET_PRIVATE_FROM_C_OBJECT(call)->startInvite(nullptr) != 0) {
......@@ -3689,9 +3665,9 @@ bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription
void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call){
/* Play the ring if this is the only call*/
if (bctbx_list_size(lc->calls)==1){
if (linphone_core_get_calls_nb(lc)==1){
MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
lc->current_call=call;
L_GET_PRIVATE_FROM_C_OBJECT(lc)->setCurrentCall(L_GET_CPP_PTR_FROM_C_OBJECT(call));
if (lc->ringstream && lc->dmfs_playing_start_time!=0){
linphone_core_stop_dtmf_stream(lc);
}
......@@ -3765,13 +3741,7 @@ LinphoneStatus linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call
}
LinphoneStatus linphone_core_terminate_all_calls(LinphoneCore *lc) {
bctbx_list_t *calls=lc->calls;
while(calls) {
LinphoneCall *c=(LinphoneCall*)calls->data;
calls=calls->next;
linphone_call_terminate(c);
}
return 0;
return L_GET_CPP_PTR_FROM_C_OBJECT(lc)->terminateAllCalls();
}
LinphoneStatus linphone_core_decline_call(LinphoneCore *lc, LinphoneCall *call, LinphoneReason reason) {
......@@ -3779,31 +3749,29 @@ LinphoneStatus linphone_core_decline_call(LinphoneCore *lc, LinphoneCall *call,
}
const bctbx_list_t *linphone_core_get_calls(LinphoneCore *lc) {
return lc->calls;
if (lc->callsCache) {
bctbx_list_free(lc->callsCache);
lc->callsCache = NULL;
}
lc->callsCache = L_GET_RESOLVED_C_LIST_FROM_CPP_LIST(L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCalls());
return lc->callsCache;
}
bool_t linphone_core_in_call(const LinphoneCore *lc){
return linphone_core_get_current_call((LinphoneCore *)lc)!=NULL || linphone_core_is_in_conference(lc);
}
LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc){
return lc->current_call;
LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc) {
shared_ptr<LinphonePrivate::Call> call = L_GET_CPP_PTR_FROM_C_OBJECT(lc)->getCurrentCall();
return call ? L_GET_C_BACK_PTR(call) : NULL;
}
LinphoneStatus linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call) {
return linphone_call_pause(call);
}
LinphoneStatus linphone_core_pause_all_calls(LinphoneCore *lc){
const bctbx_list_t *elem;
for(elem=lc->calls;elem!=NULL;elem=elem->next){
LinphoneCall *call=(LinphoneCall *)elem->data;
LinphoneCallState cs=linphone_call_get_state(call);
if (cs==LinphoneCallStreamsRunning || cs==LinphoneCallPausedByRemote){
_linphone_call_pause(call);
}
}
return 0;
LinphoneStatus linphone_core_pause_all_calls(LinphoneCore *lc) {
return L_GET_CPP_PTR_FROM_C_OBJECT(lc)->pauseAllCalls();
}