Commit 88fb7651 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Call now inherits from Conference instead of including it.

parent 8b695901
......@@ -31,6 +31,10 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
call/call-listener.h
call/call-p.h
call/call.h
call/local-conference-call-p.h
call/local-conference-call.h
call/remote-conference-call-p.h
call/remote-conference-call.h
chat/chat-message/chat-message-p.h
chat/chat-message/chat-message.h
chat/chat-room/basic-chat-room-p.h
......@@ -160,6 +164,8 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
c-wrapper/api/c-participant.cpp
c-wrapper/internal/c-sal.cpp
call/call.cpp
call/local-conference-call.cpp
call/remote-conference-call.cpp
chat/chat-message/chat-message.cpp
chat/chat-room/basic-chat-room.cpp
chat/chat-room/chat-room-id.cpp
......
......@@ -25,7 +25,10 @@
#include "c-wrapper/c-wrapper.h"
#include "call/call-p.h"
#include "call/call.h"
#include "call/local-conference-call.h"
#include "call/remote-conference-call.h"
#include "conference/params/media-session-params-p.h"
#include "core/core.h"
// =============================================================================
......@@ -574,7 +577,7 @@ void linphone_call_notify_ack_processing (LinphoneCall *call, LinphoneHeaders *m
// =============================================================================
LinphoneCore *linphone_call_get_core (const LinphoneCall *call) {
return L_GET_CPP_PTR_FROM_C_OBJECT(call)->getCore();
return L_GET_CPP_PTR_FROM_C_OBJECT(call)->getCore()->getCCore();
}
LinphoneCallState linphone_call_get_state (const LinphoneCall *call) {
......@@ -1140,26 +1143,44 @@ void linphone_call_set_user_data (LinphoneCall *call, void *ud) {
// =============================================================================
LinphoneCall *linphone_call_new_outgoing (LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, const LinphoneCallParams *params, LinphoneProxyConfig *cfg) {
LinphoneCall *call = L_INIT(Call);
L_SET_CPP_PTR_FROM_C_OBJECT(call, make_shared<LinphonePrivate::Call>(call, lc, LinphoneCallOutgoing,
*L_GET_CPP_PTR_FROM_C_OBJECT(from), *L_GET_CPP_PTR_FROM_C_OBJECT(to),
cfg, nullptr, L_GET_CPP_PTR_FROM_C_OBJECT(params)));
call->currentParamsCache = linphone_call_params_new_for_wrapper();
call->paramsCache = linphone_call_params_new_for_wrapper();
call->remoteParamsCache = linphone_call_params_new_for_wrapper();
call->remoteAddressCache = linphone_address_new(nullptr);
return call;
LinphoneCall *lcall = L_INIT(Call);
shared_ptr<LinphonePrivate::Call> call;
string confType = lp_config_get_string(linphone_core_get_config(lc), "misc", "conference_type", "local");
if (confType == "remote") {
call = make_shared<LinphonePrivate::RemoteConferenceCall>(lc->cppCore, LinphoneCallOutgoing,
*L_GET_CPP_PTR_FROM_C_OBJECT(from), *L_GET_CPP_PTR_FROM_C_OBJECT(to),
cfg, nullptr, L_GET_CPP_PTR_FROM_C_OBJECT(params));
} else {
call = make_shared<LinphonePrivate::LocalConferenceCall>(lc->cppCore, LinphoneCallOutgoing,
*L_GET_CPP_PTR_FROM_C_OBJECT(from), *L_GET_CPP_PTR_FROM_C_OBJECT(to),
cfg, nullptr, L_GET_CPP_PTR_FROM_C_OBJECT(params));
}
L_SET_CPP_PTR_FROM_C_OBJECT(lcall, call);
lcall->currentParamsCache = linphone_call_params_new_for_wrapper();
lcall->paramsCache = linphone_call_params_new_for_wrapper();
lcall->remoteParamsCache = linphone_call_params_new_for_wrapper();
lcall->remoteAddressCache = linphone_address_new(nullptr);
return lcall;
}
LinphoneCall *linphone_call_new_incoming (LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to, LinphonePrivate::SalCallOp *op) {
LinphoneCall *call = L_INIT(Call);
L_SET_CPP_PTR_FROM_C_OBJECT(call, make_shared<LinphonePrivate::Call>(call, lc, LinphoneCallIncoming,
*L_GET_CPP_PTR_FROM_C_OBJECT(from), *L_GET_CPP_PTR_FROM_C_OBJECT(to),
nullptr, op, nullptr));
call->currentParamsCache = linphone_call_params_new_for_wrapper();
call->paramsCache = linphone_call_params_new_for_wrapper();
call->remoteParamsCache = linphone_call_params_new_for_wrapper();
call->remoteAddressCache = linphone_address_new(nullptr);
L_GET_PRIVATE_FROM_C_OBJECT(call)->initiateIncoming();
return call;
LinphoneCall *lcall = L_INIT(Call);
shared_ptr<LinphonePrivate::Call> call;
string confType = lp_config_get_string(linphone_core_get_config(lc), "misc", "conference_type", "local");
if (confType == "remote") {
call = make_shared<LinphonePrivate::RemoteConferenceCall>(lc->cppCore, LinphoneCallIncoming,
*L_GET_CPP_PTR_FROM_C_OBJECT(from), *L_GET_CPP_PTR_FROM_C_OBJECT(to),
nullptr, op, nullptr);
} else {
call = make_shared<LinphonePrivate::LocalConferenceCall>(lc->cppCore, LinphoneCallIncoming,
*L_GET_CPP_PTR_FROM_C_OBJECT(from), *L_GET_CPP_PTR_FROM_C_OBJECT(to),
nullptr, op, nullptr);
}
L_SET_CPP_PTR_FROM_C_OBJECT(lcall, call);
lcall->currentParamsCache = linphone_call_params_new_for_wrapper();
lcall->paramsCache = linphone_call_params_new_for_wrapper();
lcall->remoteParamsCache = linphone_call_params_new_for_wrapper();
lcall->remoteAddressCache = linphone_address_new(nullptr);
L_GET_PRIVATE_FROM_C_OBJECT(lcall)->initiateIncoming();
return lcall;
}
......@@ -32,21 +32,10 @@
LINPHONE_BEGIN_NAMESPACE
class CallPrivate :
public ObjectPrivate,
CallListener {
class CallPrivate : public ObjectPrivate, public CallListener {
public:
CallPrivate (
LinphoneCall *call,
LinphoneCore *core,
LinphoneCallDir direction,
const Address &from,
const Address &to,
LinphoneProxyConfig *cfg,
SalOp *op,
const MediaSessionParams *msp
);
virtual ~CallPrivate ();
CallPrivate () = default;
virtual ~CallPrivate () = default;
void initiateIncoming ();
bool initiateOutgoing ();
......@@ -55,11 +44,8 @@ public:
int startInvite (const Address *destination);
std::shared_ptr<CallSession> getActiveSession () const;
virtual std::shared_ptr<CallSession> getActiveSession () const { return nullptr; }
bool getAudioMuted () const;
Conference *getConference () const {
return conference;
}
LinphoneProxyConfig *getDestProxy () const;
IceSession *getIceSession () const;
......@@ -87,10 +73,6 @@ private:
void onFirstVideoFrameDecoded () override;
void onResetFirstVideoFrameDecoded () override;
LinphoneCall *lcall = nullptr;
LinphoneCore *core = nullptr;
Conference *conference = nullptr;
mutable LinphonePlayer *player = nullptr;
CallCallbackObj nextVideoFrameDecoded;
......
......@@ -19,9 +19,7 @@
#include "c-wrapper/c-wrapper.h"
#include "call-p.h"
#include "conference/local-conference.h"
#include "conference/participant-p.h"
#include "conference/remote-conference.h"
#include "conference/session/call-session-p.h"
#include "conference/session/media-session-p.h"
#include "logger/logger.h"
......@@ -31,31 +29,6 @@ using namespace std;
LINPHONE_BEGIN_NAMESPACE
CallPrivate::CallPrivate (
LinphoneCall *call,
LinphoneCore *core,
LinphoneCallDir direction,
const Address &from,
const Address &to,
LinphoneProxyConfig *cfg,
SalOp *op,
const MediaSessionParams *msp
) : lcall(call), core(core) {
nextVideoFrameDecoded._func = nullptr;
nextVideoFrameDecoded._user_data = nullptr;
}
CallPrivate::~CallPrivate () {
if (conference)
delete conference;
}
// -----------------------------------------------------------------------------
shared_ptr<CallSession> CallPrivate::getActiveSession () const {
return conference->getActiveParticipant()->getPrivate()->getSession();
}
bool CallPrivate::getAudioMuted () const {
return static_pointer_cast<MediaSession>(getActiveSession())->getPrivate()->getAudioMuted();
}
......@@ -112,21 +85,24 @@ void CallPrivate::createPlayer () const {
// -----------------------------------------------------------------------------
void CallPrivate::onAckBeingSent (LinphoneHeaders *headers) {
if (lcall)
linphone_call_notify_ack_processing(lcall, headers, false);
L_Q();
linphone_call_notify_ack_processing(L_GET_C_BACK_PTR(q), headers, false);
}
void CallPrivate::onAckReceived (LinphoneHeaders *headers) {
if (lcall)
linphone_call_notify_ack_processing(lcall, headers, true);
L_Q();
linphone_call_notify_ack_processing(L_GET_C_BACK_PTR(q), headers, true);
}
void CallPrivate::onCallSetReleased () {
if (lcall)
linphone_call_unref(lcall);
L_Q();
linphone_call_unref(L_GET_C_BACK_PTR(q));
}
void CallPrivate::onCallSetTerminated () {
L_Q();
LinphoneCall *lcall = L_GET_C_BACK_PTR(q);
LinphoneCore *core = q->getCore()->getCCore();
if (lcall) {
if (lcall == core->current_call) {
lInfo() << "Resetting the current call";
......@@ -150,12 +126,14 @@ void CallPrivate::onCallSetTerminated () {
}
void CallPrivate::onCallStateChanged (LinphoneCallState state, const string &message) {
if (lcall)
linphone_call_notify_state_changed(lcall, state, message.c_str());
L_Q();
linphone_call_notify_state_changed(L_GET_C_BACK_PTR(q), state, message.c_str());
}
void CallPrivate::onCheckForAcceptation () {
bctbx_list_t *copy = bctbx_list_copy(linphone_core_get_calls(core));
L_Q();
LinphoneCall *lcall = L_GET_C_BACK_PTR(q);
bctbx_list_t *copy = bctbx_list_copy(linphone_core_get_calls(q->getCore()->getCCore()));
for (bctbx_list_t *it = copy; it != nullptr; it = bctbx_list_next(it)) {
LinphoneCall *call = reinterpret_cast<LinphoneCall *>(bctbx_list_get_data(it));
if (call == lcall) continue;
......@@ -176,78 +154,63 @@ void CallPrivate::onCheckForAcceptation () {
}
void CallPrivate::onIncomingCallStarted () {
if (lcall)
linphone_core_notify_incoming_call(core, lcall);
L_Q();
linphone_core_notify_incoming_call(q->getCore()->getCCore(), L_GET_C_BACK_PTR(q));
}
void CallPrivate::onIncomingCallToBeAdded () {
if (lcall) /* The call is acceptable so we can now add it to our list */
linphone_core_add_call(core, lcall);
L_Q();
/* The call is acceptable so we can now add it to our list */
linphone_core_add_call(q->getCore()->getCCore(), L_GET_C_BACK_PTR(q));
}
void CallPrivate::onInfoReceived (const LinphoneInfoMessage *im) {
if (lcall)
linphone_call_notify_info_message_received(lcall, im);
L_Q();
linphone_call_notify_info_message_received(L_GET_C_BACK_PTR(q), im);
}
void CallPrivate::onEncryptionChanged (bool activated, const string &authToken) {
if (lcall)
linphone_call_notify_encryption_changed(lcall, activated, authToken.empty() ? nullptr : authToken.c_str());
L_Q();
linphone_call_notify_encryption_changed(L_GET_C_BACK_PTR(q), activated, authToken.empty() ? nullptr : authToken.c_str());
}
void CallPrivate::onStatsUpdated (const LinphoneCallStats *stats) {
if (lcall)
linphone_call_notify_stats_updated(lcall, stats);
L_Q();
linphone_call_notify_stats_updated(L_GET_C_BACK_PTR(q), stats);
}
void CallPrivate::onResetCurrentCall () {
core->current_call = nullptr;
L_Q();
q->getCore()->getCCore()->current_call = nullptr;
}
void CallPrivate::onSetCurrentCall () {
if (lcall)
core->current_call = lcall;
L_Q();
q->getCore()->getCCore()->current_call = L_GET_C_BACK_PTR(q);
}
void CallPrivate::onFirstVideoFrameDecoded () {
if (lcall && nextVideoFrameDecoded._func) {
nextVideoFrameDecoded._func(lcall, nextVideoFrameDecoded._user_data);
L_Q();
if (nextVideoFrameDecoded._func) {
nextVideoFrameDecoded._func(L_GET_C_BACK_PTR(q), nextVideoFrameDecoded._user_data);
nextVideoFrameDecoded._func = nullptr;
nextVideoFrameDecoded._user_data = nullptr;
}
}
void CallPrivate::onResetFirstVideoFrameDecoded () {
#ifdef VIDEO_ENABLED
if (lcall && nextVideoFrameDecoded._func)
static_cast<MediaSession *>(getActiveSession().get())->resetFirstVideoFrameDecoded();
#endif // ifdef VIDEO_ENABLED
#ifdef VIDEO_ENABLED
if (nextVideoFrameDecoded._func)
static_cast<MediaSession *>(getActiveSession().get())->resetFirstVideoFrameDecoded();
#endif // ifdef VIDEO_ENABLED
}
// =============================================================================
Call::Call (
LinphoneCall *call,
LinphoneCore *core,
LinphoneCallDir direction,
const Address &from,
const Address &to,
LinphoneProxyConfig *cfg,
SalCallOp *op,
const MediaSessionParams *msp
) : Object(*new CallPrivate(call, core, direction, from, to, cfg, op, msp)) {
L_D();
const Address *myAddress = (direction == LinphoneCallIncoming) ? &to : &from;
string confType = lp_config_get_string(linphone_core_get_config(core), "misc", "conference_type", "local");
if (confType == "remote") {
d->conference = new RemoteConference(core->cppCore, *myAddress, d);
} else {
d->conference = new LocalConference(core->cppCore, *myAddress, d);
}
const Address *remoteAddress = (direction == LinphoneCallIncoming) ? &from : &to;
d->conference->addParticipant(*remoteAddress, msp, true);
shared_ptr<Participant> participant = d->conference->getParticipants().front();
participant->getPrivate()->getSession()->configure(direction, cfg, op, from, to);
Call::Call (CallPrivate &p, shared_ptr<Core> core) : Object(p), CoreAccessor(core) {
L_D();
d->nextVideoFrameDecoded._func = nullptr;
d->nextVideoFrameDecoded._user_data = nullptr;
}
// -----------------------------------------------------------------------------
......@@ -398,11 +361,6 @@ float Call::getAverageQuality () const {
return static_cast<const MediaSession *>(d->getActiveSession().get())->getAverageQuality();
}
LinphoneCore *Call::getCore () const {
L_D();
return d->core;
}
const MediaSessionParams *Call::getCurrentParams () const {
L_D();
return static_cast<MediaSession *>(d->getActiveSession().get())->getCurrentParams();
......
......@@ -21,6 +21,7 @@
#define _CALL_CALL_H_
#include "conference/params/media-session-params.h"
#include "core/core-accessor.h"
#include "object/object.h"
// =============================================================================
......@@ -32,22 +33,11 @@ class CallPrivate;
class CallSessionPrivate;
class MediaSessionPrivate;
class Call : public Object {
class Call : public Object, public CoreAccessor {
friend class CallSessionPrivate;
friend class MediaSessionPrivate;
public:
Call (
LinphoneCall *call,
LinphoneCore *core,
LinphoneCallDir direction,
const Address &from,
const Address &to,
LinphoneProxyConfig *cfg,
SalCallOp *op,
const MediaSessionParams *msp
);
LinphoneStatus accept (const MediaSessionParams *msp = nullptr);
LinphoneStatus acceptEarlyMedia (const MediaSessionParams *msp = nullptr);
LinphoneStatus acceptUpdate (const MediaSessionParams *msp);
......@@ -78,7 +68,6 @@ public:
std::string getAuthenticationToken () const;
bool getAuthenticationTokenVerified () const;
float getAverageQuality () const;
LinphoneCore *getCore () const;
const MediaSessionParams *getCurrentParams () const;
float getCurrentQuality () const;
LinphoneCallDir getDirection () const;
......@@ -113,6 +102,9 @@ public:
void setNextVideoFrameDecodedCallback (LinphoneCallCbFunc cb, void *user_data);
void setSpeakerVolumeGain (float value);
protected:
Call (CallPrivate &p, std::shared_ptr<Core> core);
private:
L_DECLARE_PRIVATE(Call);
L_DISABLE_COPY(Call);
......
/*
* local-conference-call-p.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 _LOCAL_CONFERENCE_CALL_P_H_
#define _LOCAL_CONFERENCE_CALL_P_H_
#include "call-p.h"
#include "local-conference-call.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class LocalConferenceCallPrivate : public CallPrivate {
public:
LocalConferenceCallPrivate () = default;
std::shared_ptr<CallSession> getActiveSession () const override;
private:
L_DECLARE_PUBLIC(LocalConferenceCall);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _LOCAL_CONFERENCE_CALL_P_H_
/*
* local-conference-call.cpp
* 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.
*/
#include "conference/local-conference-p.h"
#include "conference/participant-p.h"
#include "local-conference-call-p.h"
// =============================================================================
using namespace std;
LINPHONE_BEGIN_NAMESPACE
shared_ptr<CallSession> LocalConferenceCallPrivate::getActiveSession () const {
L_Q();
return q->getActiveParticipant()->getPrivate()->getSession();
}
// =============================================================================
LocalConferenceCall::LocalConferenceCall (
shared_ptr<Core> core,
LinphoneCallDir direction,
const Address &from,
const Address &to,
LinphoneProxyConfig *cfg,
SalCallOp *op,
const MediaSessionParams *msp
)
: Call(*new LocalConferenceCallPrivate(), core),
LocalConference(getCore(), IdentityAddress((direction == LinphoneCallIncoming) ? to : from), getPrivate()) {
addParticipant((direction == LinphoneCallIncoming) ? from : to, msp, true);
shared_ptr<Participant> participant = getParticipants().front();
participant->getPrivate()->getSession()->configure(direction, cfg, op, from, to);
}
shared_ptr<Core> LocalConferenceCall::getCore () const {
return Call::getCore();
}
LINPHONE_END_NAMESPACE
/*
* local-conference-call.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 _LOCAL_CONFERENCE_CALL_H_
#define _LOCAL_CONFERENCE_CALL_H_
// From coreapi
#include "private.h"
#include "call/call.h"
#include "conference/local-conference.h"
#include "linphone/types.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class Core;
class LocalConferenceCallPrivate;
class LocalConferenceCall : public Call, public LocalConference {
public:
// TODO: Make me private!
LocalConferenceCall (
std::shared_ptr<Core> core,
LinphoneCallDir direction,
const Address &from,
const Address &to,
LinphoneProxyConfig *cfg,
SalCallOp *op,
const MediaSessionParams *msp
);
std::shared_ptr<Core> getCore () const;
private:
L_DECLARE_PRIVATE(LocalConferenceCall);
L_DISABLE_COPY(LocalConferenceCall);
};
LINPHONE_END_NAMESPACE
#endif // ifndef _LOCAL_CONFERENCE_CALL_H_
/*
* remote-conference-call-p.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 _REMOTE_CONFERENCE_CALL_P_H_
#define _REMOTE_CONFERENCE_CALL_P_H_
#include "call/call-p.h"
#include "remote-conference-call.h"
// =============================================================================
LINPHONE_BEGIN_NAMESPACE
class RemoteConferenceCallPrivate : public CallPrivate {
public:
RemoteConferenceCallPrivate () = default;
std::shared_ptr<CallSession> getActiveSession () const override;