Commit 8b695901 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Use CoreAccessor in call related classes.

parent 6ef2937a
...@@ -6883,7 +6883,7 @@ void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m) { ...@@ -6883,7 +6883,7 @@ void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m) {
} }
void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params) { void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params) {
L_GET_CPP_PTR_FROM_C_OBJECT(params)->initDefault(lc); L_GET_CPP_PTR_FROM_C_OBJECT(params)->initDefault(lc->cppCore);
} }
void linphone_core_set_device_identifier(LinphoneCore *lc,const char* device_id) { void linphone_core_set_device_identifier(LinphoneCore *lc,const char* device_id) {
......
...@@ -176,7 +176,7 @@ int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, sock ...@@ -176,7 +176,7 @@ int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, sock
/* this functions runs a simple stun test and return the number of milliseconds to complete the tests, or -1 if the test were failed.*/ /* this functions runs a simple stun test and return the number of milliseconds to complete the tests, or -1 if the test were failed.*/
int linphone_run_stun_tests(LinphoneCore *lc, int audioPort, int videoPort, int textPort, int linphone_run_stun_tests(LinphoneCore *lc, int audioPort, int videoPort, int textPort,
char *audioCandidateAddr, int *audioCandidatePort, char *videoCandidateAddr, int *videoCandidatePort, char *textCandidateAddr, int *textCandidatePort) { char *audioCandidateAddr, int *audioCandidatePort, char *videoCandidateAddr, int *videoCandidatePort, char *textCandidateAddr, int *textCandidatePort) {
LinphonePrivate::StunClient *client = new LinphonePrivate::StunClient(lc); LinphonePrivate::StunClient *client = new LinphonePrivate::StunClient(lc->cppCore);
int ret = client->run(audioPort, videoPort, textPort); int ret = client->run(audioPort, videoPort, textPort);
strncpy(audioCandidateAddr, client->getAudioCandidate().address.c_str(), LINPHONE_IPADDR_SIZE); strncpy(audioCandidateAddr, client->getAudioCandidate().address.c_str(), LINPHONE_IPADDR_SIZE);
*audioCandidatePort = client->getAudioCandidate().port; *audioCandidatePort = client->getAudioCandidate().port;
......
...@@ -502,7 +502,7 @@ LinphoneCallParams *linphone_call_params_new (LinphoneCore *core) { ...@@ -502,7 +502,7 @@ LinphoneCallParams *linphone_call_params_new (LinphoneCore *core) {
LinphoneCallParams *params = _linphone_CallParams_init(); LinphoneCallParams *params = _linphone_CallParams_init();
auto mediaSessionParams = new LinphonePrivate::MediaSessionParams(); auto mediaSessionParams = new LinphonePrivate::MediaSessionParams();
L_SET_CPP_PTR_FROM_C_OBJECT(params, mediaSessionParams); L_SET_CPP_PTR_FROM_C_OBJECT(params, mediaSessionParams);
L_GET_CPP_PTR_FROM_C_OBJECT(params)->initDefault(core); L_GET_CPP_PTR_FROM_C_OBJECT(params)->initDefault(core->cppCore);
delete mediaSessionParams; delete mediaSessionParams;
return params; return params;
} }
......
...@@ -86,7 +86,7 @@ CallSessionParams &CallSessionParams::operator= (const CallSessionParams &src) { ...@@ -86,7 +86,7 @@ CallSessionParams &CallSessionParams::operator= (const CallSessionParams &src) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallSessionParams::initDefault (LinphoneCore *core) { void CallSessionParams::initDefault (const std::shared_ptr<Core> &core) {
L_D(); L_D();
d->inConference = false; d->inConference = false;
d->privacy = LinphonePrivacyDefault; d->privacy = LinphonePrivacyDefault;
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#ifndef _CALL_SESSION_PARAMS_H_ #ifndef _CALL_SESSION_PARAMS_H_
#define _CALL_SESSION_PARAMS_H_ #define _CALL_SESSION_PARAMS_H_
#include <memory>
#include "object/clonable-object.h" #include "object/clonable-object.h"
#include "linphone/types.h" #include "linphone/types.h"
...@@ -31,6 +33,7 @@ ...@@ -31,6 +33,7 @@
LINPHONE_BEGIN_NAMESPACE LINPHONE_BEGIN_NAMESPACE
class CallSessionParamsPrivate; class CallSessionParamsPrivate;
class Core;
class CallSessionParams : public ClonableObject { class CallSessionParams : public ClonableObject {
friend class CallSession; friend class CallSession;
...@@ -44,7 +47,7 @@ public: ...@@ -44,7 +47,7 @@ public:
CallSessionParams &operator= (const CallSessionParams &src); CallSessionParams &operator= (const CallSessionParams &src);
virtual void initDefault (LinphoneCore *core); virtual void initDefault (const std::shared_ptr<Core> &core);
const std::string& getSessionName () const; const std::string& getSessionName () const;
void setSessionName (const std::string &sessionName); void setSessionName (const std::string &sessionName);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "media-session-params.h" #include "media-session-params.h"
#include "core/core.h"
#include "logger/logger.h" #include "logger/logger.h"
#include "private.h" #include "private.h"
...@@ -223,27 +224,28 @@ MediaSessionParams &MediaSessionParams::operator= (const MediaSessionParams &src ...@@ -223,27 +224,28 @@ MediaSessionParams &MediaSessionParams::operator= (const MediaSessionParams &src
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void MediaSessionParams::initDefault (LinphoneCore *core) { void MediaSessionParams::initDefault (const std::shared_ptr<Core> &core) {
L_D(); L_D();
CallSessionParams::initDefault(core); CallSessionParams::initDefault(core);
LinphoneCore *cCore = core->getCCore();
d->audioEnabled = true; d->audioEnabled = true;
d->videoEnabled = linphone_core_video_enabled(core) && core->video_policy.automatically_initiate; d->videoEnabled = linphone_core_video_enabled(cCore) && cCore->video_policy.automatically_initiate;
if (!linphone_core_video_enabled(core) && core->video_policy.automatically_initiate) { if (!linphone_core_video_enabled(cCore) && cCore->video_policy.automatically_initiate) {
lError() << "LinphoneCore has video disabled for both capture and display, but video policy is to start the call with video. " lError() << "LinphoneCore has video disabled for both capture and display, but video policy is to start the call with video. "
"This is a possible mis-use of the API. In this case, video is disabled in default LinphoneCallParams"; "This is a possible mis-use of the API. In this case, video is disabled in default LinphoneCallParams";
} }
d->realtimeTextEnabled = !!linphone_core_realtime_text_enabled(core); d->realtimeTextEnabled = !!linphone_core_realtime_text_enabled(cCore);
d->encryption = linphone_core_get_media_encryption(core); d->encryption = linphone_core_get_media_encryption(cCore);
d->avpfEnabled = (linphone_core_get_avpf_mode(core) == LinphoneAVPFEnabled); d->avpfEnabled = (linphone_core_get_avpf_mode(cCore) == LinphoneAVPFEnabled);
d->_implicitRtcpFbEnabled = !!lp_config_get_int(linphone_core_get_config(core), "rtp", "rtcp_fb_implicit_rtcp_fb", true); d->_implicitRtcpFbEnabled = !!lp_config_get_int(linphone_core_get_config(cCore), "rtp", "rtcp_fb_implicit_rtcp_fb", true);
d->avpfRrInterval = static_cast<uint16_t>(linphone_core_get_avpf_rr_interval(core)); d->avpfRrInterval = static_cast<uint16_t>(linphone_core_get_avpf_rr_interval(cCore));
d->audioDirection = LinphoneMediaDirectionSendRecv; d->audioDirection = LinphoneMediaDirectionSendRecv;
d->videoDirection = LinphoneMediaDirectionSendRecv; d->videoDirection = LinphoneMediaDirectionSendRecv;
d->earlyMediaSendingEnabled = !!lp_config_get_int(linphone_core_get_config(core), "misc", "real_early_media", false); d->earlyMediaSendingEnabled = !!lp_config_get_int(linphone_core_get_config(cCore), "misc", "real_early_media", false);
d->audioMulticastEnabled = !!linphone_core_audio_multicast_enabled(core); d->audioMulticastEnabled = !!linphone_core_audio_multicast_enabled(cCore);
d->videoMulticastEnabled = !!linphone_core_video_multicast_enabled(core); d->videoMulticastEnabled = !!linphone_core_video_multicast_enabled(cCore);
d->updateCallWhenIceCompleted = !!lp_config_get_int(linphone_core_get_config(core), "sip", "update_call_when_ice_completed", true); d->updateCallWhenIceCompleted = !!lp_config_get_int(linphone_core_get_config(cCore), "sip", "update_call_when_ice_completed", true);
d->mandatoryMediaEncryptionEnabled = !!linphone_core_is_media_encryption_mandatory(core); d->mandatoryMediaEncryptionEnabled = !!linphone_core_is_media_encryption_mandatory(cCore);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
MediaSessionParams &operator= (const MediaSessionParams &src); MediaSessionParams &operator= (const MediaSessionParams &src);
void initDefault (LinphoneCore *core) override; void initDefault (const std::shared_ptr<Core> &core) override;
bool audioEnabled () const; bool audioEnabled () const;
bool audioMulticastEnabled () const; bool audioMulticastEnabled () const;
......
...@@ -35,10 +35,11 @@ LINPHONE_BEGIN_NAMESPACE ...@@ -35,10 +35,11 @@ LINPHONE_BEGIN_NAMESPACE
shared_ptr<CallSession> ParticipantPrivate::createSession ( shared_ptr<CallSession> ParticipantPrivate::createSession (
const Conference &conference, const CallSessionParams *params, bool hasMedia, CallSessionListener *listener const Conference &conference, const CallSessionParams *params, bool hasMedia, CallSessionListener *listener
) { ) {
L_Q();
if (hasMedia && (!params || dynamic_cast<const MediaSessionParams *>(params))) { if (hasMedia && (!params || dynamic_cast<const MediaSessionParams *>(params))) {
session = make_shared<MediaSession>(conference, params, listener); session = make_shared<MediaSession>(conference.getCore(), q->getSharedFromThis(), params, listener);
} else { } else {
session = make_shared<CallSession>(conference, params, listener); session = make_shared<CallSession>(conference.getCore(), params, listener);
} }
return session; return session;
} }
......
...@@ -50,6 +50,8 @@ class Participant : public Object { ...@@ -50,6 +50,8 @@ class Participant : public Object {
friend class ServerGroupChatRoomPrivate; friend class ServerGroupChatRoomPrivate;
public: public:
L_OVERRIDE_SHARED_FROM_THIS(Participant);
explicit Participant (const IdentityAddress &address); explicit Participant (const IdentityAddress &address);
explicit Participant (IdentityAddress &&address); explicit Participant (IdentityAddress &&address);
......
...@@ -31,8 +31,7 @@ LINPHONE_BEGIN_NAMESPACE ...@@ -31,8 +31,7 @@ LINPHONE_BEGIN_NAMESPACE
class CallSessionPrivate : public ObjectPrivate { class CallSessionPrivate : public ObjectPrivate {
public: public:
CallSessionPrivate (const Conference &conference, const CallSessionParams *params, CallSessionListener *listener); CallSessionPrivate () = default;
virtual ~CallSessionPrivate ();
int computeDuration () const; int computeDuration () const;
virtual void initializeParamsAccordingToIncomingCallParams (); virtual void initializeParamsAccordingToIncomingCallParams ();
...@@ -41,7 +40,6 @@ public: ...@@ -41,7 +40,6 @@ public:
bool startPing (); bool startPing ();
void setPingTime (int value) { pingTime = value; } void setPingTime (int value) { pingTime = value; }
LinphoneCore *getCore () const { return core; }
CallSessionParams *getCurrentParams () const { return currentParams; } CallSessionParams *getCurrentParams () const { return currentParams; }
LinphoneProxyConfig * getDestProxy () const { return destProxy; } LinphoneProxyConfig * getDestProxy () const { return destProxy; }
SalCallOp * getOp () const { return op; } SalCallOp * getOp () const { return op; }
...@@ -61,6 +59,8 @@ public: ...@@ -61,6 +59,8 @@ public:
virtual void updating (bool isUpdate); virtual void updating (bool isUpdate);
protected: protected:
void init ();
void accept (const CallSessionParams *params); void accept (const CallSessionParams *params);
virtual LinphoneStatus acceptUpdate (const CallSessionParams *csp, LinphoneCallState nextState, const std::string &stateInfo); virtual LinphoneStatus acceptUpdate (const CallSessionParams *csp, LinphoneCallState nextState, const std::string &stateInfo);
LinphoneStatus checkForAcceptation () const; LinphoneStatus checkForAcceptation () const;
...@@ -85,8 +85,6 @@ private: ...@@ -85,8 +85,6 @@ private:
LinphoneAddress * getFixedContact () const; LinphoneAddress * getFixedContact () const;
protected: protected:
const Conference &conference;
LinphoneCore *core = nullptr;
CallSessionListener *listener = nullptr; CallSessionListener *listener = nullptr;
CallSessionParams *params = nullptr; CallSessionParams *params = nullptr;
......
...@@ -40,32 +40,6 @@ LINPHONE_BEGIN_NAMESPACE ...@@ -40,32 +40,6 @@ LINPHONE_BEGIN_NAMESPACE
// ============================================================================= // =============================================================================
CallSessionPrivate::CallSessionPrivate (const Conference &conference, const CallSessionParams *params, CallSessionListener *listener)
: conference(conference), listener(listener) {
if (params)
setParams(new CallSessionParams(*params));
currentParams = new CallSessionParams();
core = conference.getCore()->getCCore();
ei = linphone_error_info_new();
}
CallSessionPrivate::~CallSessionPrivate () {
if (currentParams)
delete currentParams;
if (params)
delete params;
if (remoteParams)
delete remoteParams;
if (ei)
linphone_error_info_unref(ei);
if (log)
linphone_call_log_unref(log);
if (op)
op->release();
}
// -----------------------------------------------------------------------------
int CallSessionPrivate::computeDuration () const { int CallSessionPrivate::computeDuration () const {
if (log->connected_date_time == 0) if (log->connected_date_time == 0)
return 0; return 0;
...@@ -108,9 +82,9 @@ void CallSessionPrivate::setState(LinphoneCallState newState, const string &mess ...@@ -108,9 +82,9 @@ void CallSessionPrivate::setState(LinphoneCallState newState, const string &mess
switch (newState) { switch (newState) {
case LinphoneCallOutgoingInit: case LinphoneCallOutgoingInit:
case LinphoneCallIncomingReceived: case LinphoneCallIncomingReceived:
getPlatformHelpers(core)->acquireWifiLock(); getPlatformHelpers(q->getCore()->getCCore())->acquireWifiLock();
getPlatformHelpers(core)->acquireMcastLock(); getPlatformHelpers(q->getCore()->getCCore())->acquireMcastLock();
getPlatformHelpers(core)->acquireCpuLock(); getPlatformHelpers(q->getCore()->getCCore())->acquireCpuLock();
break; break;
case LinphoneCallEnd: case LinphoneCallEnd:
case LinphoneCallError: case LinphoneCallError:
...@@ -150,9 +124,9 @@ void CallSessionPrivate::setState(LinphoneCallState newState, const string &mess ...@@ -150,9 +124,9 @@ void CallSessionPrivate::setState(LinphoneCallState newState, const string &mess
log->connected_date_time = ms_time(nullptr); log->connected_date_time = ms_time(nullptr);
break; break;
case LinphoneCallReleased: case LinphoneCallReleased:
getPlatformHelpers(core)->acquireWifiLock(); getPlatformHelpers(q->getCore()->getCCore())->acquireWifiLock();
getPlatformHelpers(core)->acquireMcastLock(); getPlatformHelpers(q->getCore()->getCCore())->acquireMcastLock();
getPlatformHelpers(core)->acquireCpuLock(); getPlatformHelpers(q->getCore()->getCCore())->acquireCpuLock();
break; break;
default: default:
break; break;
...@@ -199,16 +173,17 @@ void CallSessionPrivate::startIncomingNotification () { ...@@ -199,16 +173,17 @@ void CallSessionPrivate::startIncomingNotification () {
} }
bool CallSessionPrivate::startPing () { bool CallSessionPrivate::startPing () {
if (core->sip_conf.ping_with_options) { L_Q();
if (q->getCore()->getCCore()->sip_conf.ping_with_options) {
/* Defer the start of the call after the OPTIONS ping for outgoing call or /* Defer the start of the call after the OPTIONS ping for outgoing call or
* send an option request back to the caller so that we get a chance to discover our nat'd address * send an option request back to the caller so that we get a chance to discover our nat'd address
* before answering for incoming call */ * before answering for incoming call */
pingReplied = false; pingReplied = false;
pingOp = new SalOp(core->sal); pingOp = new SalOp(q->getCore()->getCCore()->sal);
if (direction == LinphoneCallIncoming) { if (direction == LinphoneCallIncoming) {
const char *from = pingOp->get_from(); const char *from = pingOp->get_from();
const char *to = pingOp->get_to(); const char *to = pingOp->get_to();
linphone_configure_op(core, pingOp, log->from, nullptr, false); linphone_configure_op(q->getCore()->getCCore(), pingOp, log->from, nullptr, false);
pingOp->set_route(op->get_network_origin()); pingOp->set_route(op->get_network_origin());
pingOp->ping(from, to); pingOp->ping(from, to);
} else if (direction == LinphoneCallOutgoing) { } else if (direction == LinphoneCallOutgoing) {
...@@ -332,7 +307,7 @@ bool CallSessionPrivate::failure () { ...@@ -332,7 +307,7 @@ bool CallSessionPrivate::failure () {
void CallSessionPrivate::infoReceived (SalBodyHandler *bodyHandler) { void CallSessionPrivate::infoReceived (SalBodyHandler *bodyHandler) {
L_Q(); L_Q();
LinphoneInfoMessage *info = linphone_core_create_info_message(core); LinphoneInfoMessage *info = linphone_core_create_info_message(q->getCore()->getCCore());
linphone_info_message_set_headers(info, op->get_recv_custom_header()); linphone_info_message_set_headers(info, op->get_recv_custom_header());
if (bodyHandler) { if (bodyHandler) {
LinphoneContent *content = linphone_content_from_sal_body_handler(bodyHandler); LinphoneContent *content = linphone_content_from_sal_body_handler(bodyHandler);
...@@ -391,7 +366,8 @@ void CallSessionPrivate::terminated () { ...@@ -391,7 +366,8 @@ void CallSessionPrivate::terminated () {
} }
void CallSessionPrivate::updated (bool isUpdate) { void CallSessionPrivate::updated (bool isUpdate) {
deferUpdate = !!lp_config_get_int(linphone_core_get_config(core), "sip", "defer_update_default", FALSE); L_Q();
deferUpdate = !!lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "defer_update_default", FALSE);
SalErrorInfo sei; SalErrorInfo sei;
memset(&sei, 0, sizeof(sei)); memset(&sei, 0, sizeof(sei));
switch (state) { switch (state) {
...@@ -459,6 +435,13 @@ void CallSessionPrivate::updating (bool isUpdate) { ...@@ -459,6 +435,13 @@ void CallSessionPrivate::updating (bool isUpdate) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallSessionPrivate::init () {
currentParams = new CallSessionParams();
ei = linphone_error_info_new();
}
// -----------------------------------------------------------------------------
void CallSessionPrivate::accept (const CallSessionParams *csp) { void CallSessionPrivate::accept (const CallSessionParams *csp) {
L_Q(); L_Q();
/* Try to be best-effort in giving real local or routable contact address */ /* Try to be best-effort in giving real local or routable contact address */
...@@ -508,7 +491,7 @@ void CallSessionPrivate::handleIncomingReceivedStateInIncomingNotification () { ...@@ -508,7 +491,7 @@ void CallSessionPrivate::handleIncomingReceivedStateInIncomingNotification () {
/* Try to be best-effort in giving real local or routable contact address for 100Rel case */ /* Try to be best-effort in giving real local or routable contact address for 100Rel case */
setContactOp(); setContactOp();
op->notify_ringing(false); op->notify_ringing(false);
if (op->get_replaces() && lp_config_get_int(linphone_core_get_config(core), "sip", "auto_answer_replacing_calls", 1)) if (op->get_replaces() && lp_config_get_int(linphone_core_get_config(q->getCore()->getCCore()), "sip", "auto_answer_replacing_calls", 1))
q->accept(); q->accept();
} }
...@@ -658,11 +641,12 @@ void CallSessionPrivate::setContactOp () { ...@@ -658,11 +641,12 @@ void CallSessionPrivate::setContactOp () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void CallSessionPrivate::completeLog () { void CallSessionPrivate::completeLog () {
L_Q();
log->duration = computeDuration(); /* Store duration since connected */ log->duration = computeDuration(); /* Store duration since connected */
log->error_info = linphone_error_info_ref(ei); log->error_info = linphone_error_info_ref(ei);
if (log->status == LinphoneCallMissed) if (log->status == LinphoneCallMissed)
core->missed_calls++; q->getCore()->getCCore()->missed_calls++;
linphone_core_report_call_log(core, log); linphone_core_report_call_log(q->getCore()->getCCore(), log);
} }
void CallSessionPrivate::createOp () { void CallSessionPrivate::createOp () {
...@@ -673,13 +657,13 @@ void CallSessionPrivate::createOpTo (const LinphoneAddress *to) { ...@@ -673,13 +657,13 @@ void CallSessionPrivate::createOpTo (const LinphoneAddress *to) {
L_Q(); L_Q();
if (op) if (op)
op->release(); op->release();
op = new SalCallOp(core->sal); op = new SalCallOp(q->getCore()->getCCore()->sal);
op->set_user_pointer(q); op->set_user_pointer(q);
#if 0 #if 0
if (linphone_call_params_get_referer(call->params)) if (linphone_call_params_get_referer(call->params))
sal_call_set_referer(call->op,linphone_call_params_get_referer(call->params)->op); sal_call_set_referer(call->op,linphone_call_params_get_referer(call->params)->op);
#endif #endif
linphone_configure_op(core, op, to, q->getParams()->getPrivate()->getCustomHeaders(), false); linphone_configure_op(q->getCore()->getCCore(), op, to, q->getParams()->getPrivate()->getCustomHeaders(), false);
if (q->getParams()->getPrivacy() != LinphonePrivacyDefault) if (q->getParams()->getPrivacy() != LinphonePrivacyDefault)
op->set_privacy((SalPrivacyMask)q->getParams()->getPrivacy()); op->set_privacy((SalPrivacyMask)q->getParams()->getPrivacy());
/* else privacy might be set by proxy */ /* else privacy might be set by proxy */
...@@ -688,6 +672,7 @@ void CallSessionPrivate::createOpTo (const LinphoneAddress *to) { ...@@ -688,6 +672,7 @@ void CallSessionPrivate::createOpTo (const LinphoneAddress *to) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
LinphoneAddress * CallSessionPrivate::getFixedContact () const { LinphoneAddress * CallSessionPrivate::getFixedContact () const {
L_Q();
LinphoneAddress *result = nullptr; LinphoneAddress *result = nullptr;
if (op && op->get_contact_address()) { if (op && op->get_contact_address()) {
/* If already choosed, don't change it */ /* If already choosed, don't change it */
...@@ -703,7 +688,7 @@ LinphoneAddress * CallSessionPrivate::getFixedContact () const { ...@@ -703,7 +688,7 @@ LinphoneAddress * CallSessionPrivate::getFixedContact () const {
lInfo() << "Contact has been fixed using proxy"; lInfo() << "Contact has been fixed using proxy";
result = linphone_address_clone(linphone_proxy_config_get_contact(destProxy)); result = linphone_address_clone(linphone_proxy_config_get_contact(destProxy));
} else { } else {
result = linphone_core_get_primary_contact_parsed(core); result = linphone_core_get_primary_contact_parsed(q->getCore()->getCCore());
if (result) { if (result) {
/* Otherwise use supplied localip */ /* Otherwise use supplied localip */
linphone_address_set_domain(result, nullptr /* localip */); linphone_address_set_domain(result, nullptr /* localip */);
...@@ -716,12 +701,36 @@ LinphoneAddress * CallSessionPrivate::getFixedContact () const { ...@@ -716,12 +701,36 @@ LinphoneAddress * CallSessionPrivate::getFixedContact () const {
// ============================================================================= // =============================================================================
CallSession::CallSession (const Conference &conference, const CallSessionParams *params, CallSessionListener *listener) CallSession::CallSession (const shared_ptr<Core> &core, const CallSessionParams *params, CallSessionListener *listener)
: Object(*new CallSessionPrivate(conference, params, listener)) { : Object(*new CallSessionPrivate), CoreAccessor(core) {
L_D();
d->listener = listener;
if (params)
d->setParams(new CallSessionParams(*params));
d->init();
lInfo() << "New CallSession [" << this << "] initialized (LinphoneCore version: " << linphone_core_get_version() << ")"; lInfo() << "New CallSession [" << this << "] initialized (LinphoneCore version: " << linphone_core_get_version() << ")";
} }
CallSession::CallSession (CallSessionPrivate &p) : Object(p) {} CallSession::CallSession (CallSessionPrivate &p, const shared_ptr<Core> &core) : Object(p), CoreAccessor(core) {
L_D();
d->init();
}
CallSession::~CallSession () {
L_D();
if (d->currentParams)
delete d->currentParams;
if (d->params)
delete d->params;
if (d->remoteParams)
delete d->remoteParams;
if (d->ei)
linphone_error_info_unref(d->ei);
if (d->log)
linphone_call_log_unref(d->log);
if (d->op)
d->op->release();
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -750,7 +759,7 @@ void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg ...@@ -750,7 +759,7 @@ void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg
LinphoneAddress *toAddr = linphone_address_new(to.asString().c_str()); LinphoneAddress *toAddr = linphone_address_new(to.asString().c_str());
if (!d->destProxy) { if (!d->destProxy) {
/* Try to define the destination proxy if it has not already been done to have a correct contact field in the SIP messages */ /* Try to define the destination proxy if it has not already been done to have a correct contact field in the SIP messages */
d->destProxy = linphone_core_lookup_known_proxy(d->core, toAddr); d->destProxy = linphone_core_lookup_known_proxy(getCore()->getCCore(), toAddr);
} }
d->log = linphone_call_log_new(direction, fromAddr, toAddr); d->log = linphone_call_log_new(direction, fromAddr, toAddr);
...@@ -758,7 +767,7 @@ void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg ...@@ -758,7 +767,7 @@ void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg
/* We already have an op for incoming calls */ /* We already have an op for incoming calls */
d->op = op; d->op = op;
d->op->set_user_pointer(this); d->op->set_user_pointer(this);
op->enable_cnx_ip_to_0000_if_sendonly(!!lp_config_get_default_int(linphone_core_get_config(d->core), op->enable_cnx_ip_to_0000_if_sendonly(!!lp_config_get_default_int(linphone_core_get_config(getCore()->getCCore()),
"sip", "cnx_ip_to_0000_if_sendonly_enabled", 0)); "sip", "cnx_ip_to_0000_if_sendonly_enabled", 0));
d->log->call_id = ms_strdup(op->get_call_id()); /* Must be known at that time */ d->log->call_id = ms_strdup(op->get_call_id()); /* Must be known at that time */
} }
...@@ -767,7 +776,7 @@ void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg ...@@ -767,7 +776,7 @@ void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg
d->startPing(); d->startPing();
} else if (direction == LinphoneCallIncoming) { } else if (direction == LinphoneCallIncoming) {
d->setParams(new CallSessionParams()); d->setParams(new CallSessionParams());
d->params->initDefault(d->core); d->params->initDefault(getCore());
} }
} }