call-session-p.h 3.66 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * call-session-p.h
 * Copyright (C) 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 3 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, see <http://www.gnu.org/licenses/>.
 */

#ifndef _CALL_SESSION_P_H_
#define _CALL_SESSION_P_H_

22 23 24
#include <memory>
#include <string>

25 26 27 28 29 30 31 32 33 34
#include "object/object-p.h"

#include "call-session.h"

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

LINPHONE_BEGIN_NAMESPACE

class CallSessionPrivate : public ObjectPrivate {
public:
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
	CallSessionPrivate (const Conference &conference, const std::shared_ptr<CallSessionParams> params, CallSessionListener *listener);
	virtual ~CallSessionPrivate ();

	int computeDuration () const;
	virtual void initializeParamsAccordingToIncomingCallParams ();
	virtual void setState (LinphoneCallState newState, const std::string &message);
	bool startPing ();
	void setPingTime (int value) { pingTime = value; }

	LinphoneProxyConfig * getDestProxy () const { return destProxy; }
	SalOp * getOp () const { return op; }

	virtual void accepted ();
	void ackBeingSent (LinphoneHeaders *headers);
	virtual void ackReceived (LinphoneHeaders *headers);
	virtual bool failure ();
	void pingReply ();
	virtual void remoteRinging ();
	virtual void terminated ();
	void updated (bool isUpdate);
	void updatedByRemote ();
	void updating (bool isUpdate);

protected:
	void accept (const std::shared_ptr<CallSessionParams> params);
	virtual LinphoneStatus acceptUpdate (const std::shared_ptr<CallSessionParams> csp, LinphoneCallState nextState, const std::string &stateInfo);
	LinphoneStatus checkForAcceptation () const;
	virtual void handleIncomingReceivedStateInIncomingNotification ();
	virtual bool isReadyForInvite () const;
	bool isUpdateAllowed (LinphoneCallState &nextState) const;
	virtual void setReleased ();
	virtual void setTerminated ();
	virtual LinphoneStatus startAcceptUpdate (LinphoneCallState nextState, const std::string &stateInfo);
	virtual LinphoneStatus startUpdate ();
	virtual void terminate ();
	virtual void updateCurrentParams ();

	void setContactOp ();

private:
	void completeLog ();
	void createOpTo (const LinphoneAddress *to);

	LinphoneAddress * getFixedContact () const;

protected:
	const Conference &conference;
	LinphoneCore *core = nullptr;
	CallSessionListener *listener = nullptr;

	std::shared_ptr<CallSessionParams> params = nullptr;
	std::shared_ptr<CallSessionParams> currentParams = nullptr;
	std::shared_ptr<CallSessionParams> remoteParams = nullptr;

	LinphoneCallDir direction = LinphoneCallOutgoing;
	LinphoneCallState state = LinphoneCallIdle;
	LinphoneCallState prevState = LinphoneCallIdle;
	//LinphoneCallState transferState = LinphoneCallIdle;
	LinphoneProxyConfig *destProxy = nullptr;
	LinphoneErrorInfo *ei = nullptr;
	LinphoneCallLog *log = nullptr;
	LinphoneNatPolicy *natPolicy = nullptr;

	SalOp *op = nullptr;

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

104 105 106
	bool deferIncomingNotification = false;
	bool deferUpdate = false;
	bool nonOpError = false; /* Set when the LinphoneErrorInfo was set at higher level than sal */
107 108 109 110 111 112 113

	L_DECLARE_PUBLIC(CallSession);
};

LINPHONE_END_NAMESPACE

#endif // ifndef _CALL_SESSION_P_H_