diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bf085340b..443273c1e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/c-wrapper/api/c-call.cpp b/src/c-wrapper/api/c-call.cpp index 2630d627d..1208cb20d 100644 --- a/src/c-wrapper/api/c-call.cpp +++ b/src/c-wrapper/api/c-call.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(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 call; + string confType = lp_config_get_string(linphone_core_get_config(lc), "misc", "conference_type", "local"); + if (confType == "remote") { + call = make_shared(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(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(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 call; + string confType = lp_config_get_string(linphone_core_get_config(lc), "misc", "conference_type", "local"); + if (confType == "remote") { + call = make_shared(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(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; } diff --git a/src/call/call-p.h b/src/call/call-p.h index a5885c403..c2f5ec9a5 100644 --- a/src/call/call-p.h +++ b/src/call/call-p.h @@ -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 getActiveSession () const; + virtual std::shared_ptr 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; diff --git a/src/call/call.cpp b/src/call/call.cpp index b353d2a44..0463764e8 100644 --- a/src/call/call.cpp +++ b/src/call/call.cpp @@ -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 CallPrivate::getActiveSession () const { - return conference->getActiveParticipant()->getPrivate()->getSession(); -} - bool CallPrivate::getAudioMuted () const { return static_pointer_cast(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(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(getActiveSession().get())->resetFirstVideoFrameDecoded(); - #endif // ifdef VIDEO_ENABLED +#ifdef VIDEO_ENABLED + if (nextVideoFrameDecoded._func) + static_cast(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)) { +Call::Call (CallPrivate &p, shared_ptr core) : Object(p), CoreAccessor(core) { 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 = d->conference->getParticipants().front(); - participant->getPrivate()->getSession()->configure(direction, cfg, op, from, to); + d->nextVideoFrameDecoded._func = nullptr; + d->nextVideoFrameDecoded._user_data = nullptr; } // ----------------------------------------------------------------------------- @@ -398,11 +361,6 @@ float Call::getAverageQuality () const { return static_cast(d->getActiveSession().get())->getAverageQuality(); } -LinphoneCore *Call::getCore () const { - L_D(); - return d->core; -} - const MediaSessionParams *Call::getCurrentParams () const { L_D(); return static_cast(d->getActiveSession().get())->getCurrentParams(); diff --git a/src/call/call.h b/src/call/call.h index ca48c4826..85c3dfd5f 100644 --- a/src/call/call.h +++ b/src/call/call.h @@ -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); + private: L_DECLARE_PRIVATE(Call); L_DISABLE_COPY(Call); diff --git a/src/call/local-conference-call-p.h b/src/call/local-conference-call-p.h new file mode 100644 index 000000000..895f89afe --- /dev/null +++ b/src/call/local-conference-call-p.h @@ -0,0 +1,42 @@ +/* + * 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 getActiveSession () const override; + +private: + L_DECLARE_PUBLIC(LocalConferenceCall); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _LOCAL_CONFERENCE_CALL_P_H_ diff --git a/src/call/local-conference-call.cpp b/src/call/local-conference-call.cpp new file mode 100644 index 000000000..8e95f37d7 --- /dev/null +++ b/src/call/local-conference-call.cpp @@ -0,0 +1,57 @@ +/* + * 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 LocalConferenceCallPrivate::getActiveSession () const { + L_Q(); + return q->getActiveParticipant()->getPrivate()->getSession(); +} + +// ============================================================================= + +LocalConferenceCall::LocalConferenceCall ( + shared_ptr 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 = getParticipants().front(); + participant->getPrivate()->getSession()->configure(direction, cfg, op, from, to); +} + +shared_ptr LocalConferenceCall::getCore () const { + return Call::getCore(); +} + +LINPHONE_END_NAMESPACE diff --git a/src/call/local-conference-call.h b/src/call/local-conference-call.h new file mode 100644 index 000000000..66153c7a8 --- /dev/null +++ b/src/call/local-conference-call.h @@ -0,0 +1,60 @@ +/* + * 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, + LinphoneCallDir direction, + const Address &from, + const Address &to, + LinphoneProxyConfig *cfg, + SalCallOp *op, + const MediaSessionParams *msp + ); + + std::shared_ptr getCore () const; + +private: + L_DECLARE_PRIVATE(LocalConferenceCall); + L_DISABLE_COPY(LocalConferenceCall); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _LOCAL_CONFERENCE_CALL_H_ diff --git a/src/call/remote-conference-call-p.h b/src/call/remote-conference-call-p.h new file mode 100644 index 000000000..9a55f3e4d --- /dev/null +++ b/src/call/remote-conference-call-p.h @@ -0,0 +1,42 @@ +/* + * 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 getActiveSession () const override; + +private: + L_DECLARE_PUBLIC(RemoteConferenceCall); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _REMOTE_CONFERENCE_CALL_P_H_ diff --git a/src/call/remote-conference-call.cpp b/src/call/remote-conference-call.cpp new file mode 100644 index 000000000..59d7feb19 --- /dev/null +++ b/src/call/remote-conference-call.cpp @@ -0,0 +1,57 @@ +/* + * remote-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/remote-conference-p.h" +#include "conference/participant-p.h" +#include "remote-conference-call-p.h" + +// ============================================================================= + +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +shared_ptr RemoteConferenceCallPrivate::getActiveSession () const { + L_Q(); + return q->getActiveParticipant()->getPrivate()->getSession(); +} + +// ============================================================================= + +RemoteConferenceCall::RemoteConferenceCall ( + shared_ptr core, + LinphoneCallDir direction, + const Address &from, + const Address &to, + LinphoneProxyConfig *cfg, + SalCallOp *op, + const MediaSessionParams *msp + ) + : Call(*new RemoteConferenceCallPrivate, core), + RemoteConference(core, IdentityAddress((direction == LinphoneCallIncoming) ? to : from), getPrivate()) { + addParticipant((direction == LinphoneCallIncoming) ? from : to, msp, true); + shared_ptr participant = getParticipants().front(); + participant->getPrivate()->getSession()->configure(direction, cfg, op, from, to); +} + +shared_ptr RemoteConferenceCall::getCore () const { + return Call::getCore(); +} + +LINPHONE_END_NAMESPACE diff --git a/src/call/remote-conference-call.h b/src/call/remote-conference-call.h new file mode 100644 index 000000000..a2505cc80 --- /dev/null +++ b/src/call/remote-conference-call.h @@ -0,0 +1,55 @@ +/* + * remote-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 _REMOTE_CONFERENCE_CALL_H_ +#define _REMOTE_CONFERENCE_CALL_H_ + +#include "call/call.h" +#include "conference/remote-conference.h" + +// ============================================================================= + +LINPHONE_BEGIN_NAMESPACE + +class Core; +class RemoteConferenceCallPrivate; + +class LINPHONE_PUBLIC RemoteConferenceCall : public Call, public RemoteConference { +public: + // TODO: Make me private. + RemoteConferenceCall ( + std::shared_ptr core, + LinphoneCallDir direction, + const Address &from, + const Address &to, + LinphoneProxyConfig *cfg, + SalCallOp *op, + const MediaSessionParams *msp + ); + + std::shared_ptr getCore () const; + +private: + L_DECLARE_PRIVATE(RemoteConferenceCall); + L_DISABLE_COPY(RemoteConferenceCall); +}; + +LINPHONE_END_NAMESPACE + +#endif // ifndef _REMOTE_CONFERENCE_CALL_H_ diff --git a/src/conference/participant.h b/src/conference/participant.h index fbfaa2700..f18b7b5ec 100644 --- a/src/conference/participant.h +++ b/src/conference/participant.h @@ -41,11 +41,15 @@ class Participant : public Object { friend class ClientGroupChatRoomPrivate; friend class Conference; friend class LocalConference; + friend class LocalConferenceCall; + friend class LocalConferenceCallPrivate; friend class LocalConferenceEventHandler; friend class LocalConferenceEventHandlerPrivate; friend class MainDb; friend class MediaSessionPrivate; friend class RemoteConference; + friend class RemoteConferenceCall; + friend class RemoteConferenceCallPrivate; friend class ServerGroupChatRoom; friend class ServerGroupChatRoomPrivate; diff --git a/src/conference/session/media-session.cpp b/src/conference/session/media-session.cpp index ad39840be..29a802f44 100644 --- a/src/conference/session/media-session.cpp +++ b/src/conference/session/media-session.cpp @@ -897,7 +897,7 @@ int MediaSessionPrivate::selectFixedPort (int streamIndex, pair portRa bool alreadyUsed = false; for (const bctbx_list_t *elem = linphone_core_get_calls(q->getCore()->getCCore()); elem != nullptr; elem = bctbx_list_next(elem)) { LinphoneCall *lcall = reinterpret_cast(bctbx_list_get_data(elem)); - MediaSession *session = dynamic_cast(L_GET_PRIVATE_FROM_C_OBJECT(lcall)->getConference()->getActiveParticipant()->getPrivate()->getSession().get()); + shared_ptr session = static_pointer_cast(L_GET_CPP_PTR_FROM_C_OBJECT(lcall)->getPrivate()->getActiveSession()); int existingPort = session->getPrivate()->mediaPorts[streamIndex].rtpPort; if (existingPort == triedPort) { alreadyUsed = true; @@ -921,7 +921,7 @@ int MediaSessionPrivate::selectRandomPort (int streamIndex, pair portR if (triedPort < portRange.first) triedPort = portRange.first + 2; for (const bctbx_list_t *elem = linphone_core_get_calls(q->getCore()->getCCore()); elem != nullptr; elem = bctbx_list_next(elem)) { LinphoneCall *lcall = reinterpret_cast(bctbx_list_get_data(elem)); - MediaSession *session = dynamic_cast(L_GET_PRIVATE_FROM_C_OBJECT(lcall)->getConference()->getActiveParticipant()->getPrivate()->getSession().get()); + shared_ptr session = static_pointer_cast(L_GET_CPP_PTR_FROM_C_OBJECT(lcall)->getPrivate()->getActiveSession()); int existingPort = session->getPrivate()->mediaPorts[streamIndex].rtpPort; if (existingPort == triedPort) { alreadyUsed = true;