call-session-p.h 5.09 KB
Newer Older
1 2
/*
 * call-session-p.h
Ronan's avatar
Ronan committed
3
 * Copyright (C) 2010-2018 Belledonne Communications SARL
4
 *
Ghislain MARY's avatar
Ghislain MARY committed
5 6 7 8
 * 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.
9 10 11 12 13 14 15
 *
 * 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
Ghislain MARY's avatar
Ghislain MARY committed
16 17
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 19
 */

20 21
#ifndef _L_CALL_SESSION_P_H_
#define _L_CALL_SESSION_P_H_
22 23 24 25

#include "object/object-p.h"

#include "call-session.h"
26
#include "sal/call-op.h"
27 28 29 30 31

// =============================================================================

LINPHONE_BEGIN_NAMESPACE

32
class CallSessionPrivate : public ObjectPrivate, public CoreListener {
33
public:
34 35
	int computeDuration () const;
	virtual void initializeParamsAccordingToIncomingCallParams ();
36
	void notifyReferState ();
37 38
	virtual void setState (CallSession::State newState, const std::string &message);
	void setTransferState (CallSession::State newState);
Ghislain MARY's avatar
Ghislain MARY committed
39
	void startIncomingNotification ();
40 41 42
	bool startPing ();
	void setPingTime (int value) { pingTime = value; }

Ghislain MARY's avatar
Ghislain MARY committed
43
	void createOp ();
44
	CallSessionParams *getCurrentParams () const { return currentParams; }
45
	LinphoneProxyConfig * getDestProxy () const { return destProxy; }
46
	SalCallOp * getOp () const { return op; }
47
	bool isBroken () const { return broken; }
Ghislain MARY's avatar
Ghislain MARY committed
48
	bool isInConference () const;
49
	void setParams (CallSessionParams *csp);
50 51
	void setReferPending (bool value) { referPending = value; }
	void setTransferTarget (std::shared_ptr<CallSession> session) { transferTarget = session; }
52

53
	virtual void abort (const std::string &errorMsg);
54 55 56
	virtual void accepted ();
	void ackBeingSent (LinphoneHeaders *headers);
	virtual void ackReceived (LinphoneHeaders *headers);
57
	void cancelDone ();
58
	virtual bool failure ();
59
	void infoReceived (SalBodyHandler *bodyHandler);
60
	void pingReply ();
61
	void referred (const Address &referToAddr);
62
	virtual void remoteRinging ();
63
	void replaceOp (SalCallOp *newOp);
64 65 66
	virtual void terminated ();
	void updated (bool isUpdate);
	void updatedByRemote ();
67
	virtual void updating (bool isUpdate);
68

69 70
	void setCallSessionListener (CallSessionListener *listener) { this->listener = listener; }

71
protected:
72 73
	void init ();

74
	void accept (const CallSessionParams *params);
75
	virtual LinphoneStatus acceptUpdate (const CallSessionParams *csp, CallSession::State nextState, const std::string &stateInfo);
76
	LinphoneStatus checkForAcceptation ();
77 78
	virtual void handleIncomingReceivedStateInIncomingNotification ();
	virtual bool isReadyForInvite () const;
79
	bool isUpdateAllowed (CallSession::State &nextState) const;
80
	virtual int restartInvite ();
81 82
	virtual void setReleased ();
	virtual void setTerminated ();
83
	virtual LinphoneStatus startAcceptUpdate (CallSession::State nextState, const std::string &stateInfo);
84
	virtual LinphoneStatus startUpdate (const std::string &subject);
85
	virtual void terminate ();
86
	virtual void updateCurrentParams () const;
87

Ghislain MARY's avatar
Ghislain MARY committed
88
	void setBroken ();
89 90
	void setContactOp ();

91 92 93
	virtual void reinviteToRecoverFromConnectionLoss ();
	virtual void repairByInviteWithReplaces ();

94
	// CoreListener
Ghislain MARY's avatar
Ghislain MARY committed
95
	void onNetworkReachable (bool sipNetworkReachable, bool mediaNetworkReachable) override;
96 97
	void onRegistrationStateChanged (LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const std::string &message) override;

98 99 100 101 102 103
private:
	void completeLog ();
	void createOpTo (const LinphoneAddress *to);

	LinphoneAddress * getFixedContact () const;

104 105
	void repairIfBroken ();

106 107 108
protected:
	CallSessionListener *listener = nullptr;

109
	CallSessionParams *params = nullptr;
110
	mutable CallSessionParams *currentParams = nullptr;
111
	CallSessionParams *remoteParams = nullptr;
112
	mutable Address diversionAddress;
113
	mutable Address remoteContactAddress;
114
	mutable Address toAddress;
115

116
	std::string subject;
117
	LinphoneCallDir direction = LinphoneCallOutgoing;
118 119 120
	CallSession::State state = CallSession::State::Idle;
	CallSession::State prevState = CallSession::State::Idle;
	CallSession::State transferState = CallSession::State::Idle;
121 122 123
	LinphoneProxyConfig *destProxy = nullptr;
	LinphoneErrorInfo *ei = nullptr;
	LinphoneCallLog *log = nullptr;
124
	std::string referTo;
125

126
	SalCallOp *op = nullptr;
127 128 129 130

	SalOp *pingOp = nullptr;
	bool pingReplied = false;
	int pingTime = 0;
131

132 133 134
	std::shared_ptr<CallSession> referer;
	std::shared_ptr<CallSession> transferTarget;

135
	bool broken = false;
136 137
	bool deferIncomingNotification = false;
	bool deferUpdate = false;
138
	bool deferUpdateInternal = false;
139
	bool needLocalIpRefresh = false;
140
	bool nonOpError = false; /* Set when the LinphoneErrorInfo was set at higher level than sal */
141
	bool notifyRinging = true;
142
	bool referPending = false;
143
	bool reinviteOnCancelResponseRequested = false;
144

145
private:
146 147 148 149 150
	L_DECLARE_PUBLIC(CallSession);
};

LINPHONE_END_NAMESPACE

151
#endif // ifndef _L_CALL_SESSION_P_H_