callcontext-transcoder.hh 3.22 KB
Newer Older
Simon Morlat's avatar
Simon Morlat committed
1 2
/*
	Flexisip, a flexible SIP proxy server with media capabilities.
3
	Copyright (C) 2010  Belledonne Communications SARL.
Simon Morlat's avatar
Simon Morlat committed
4

5 6 7 8
	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU Affero General Public License as
	published by the Free Software Foundation, either version 3 of the
	License, or (at your option) any later version.
Simon Morlat's avatar
Simon Morlat committed
9

10 11 12 13
	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 Affero General Public License for more details.
Simon Morlat's avatar
Simon Morlat committed
14

15 16
	You should have received a copy of the GNU Affero General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
Simon Morlat's avatar
Simon Morlat committed
17 18 19 20 21 22
*/

#ifndef callcontext_hh
#define callcontext_hh

#include "callstore.hh"
23
#include <list>
Simon Morlat's avatar
Simon Morlat committed
24 25 26 27

#include <mediastreamer2/msfilter.h>
#include <mediastreamer2/msticker.h>
#include <mediastreamer2/msrtp.h>
Simon Morlat's avatar
Simon Morlat committed
28
#include <mediastreamer2/bitratecontrol.h>
Simon Morlat's avatar
Simon Morlat committed
29

30 31

class Transcoder;
32
class TranscodedCall;
33 34 35
class CallContextParams {
  public:
	int mJbNomSize;
36 37
};

38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
class CallSide {
  public:
	CallSide(TranscodedCall *ctx, const CallContextParams &params);
	~CallSide();
	MSConnectionPoint getRecvPoint();
	PayloadType *getRecvFormat();
	void enableRc(bool enabled);
	void connect(CallSide *recvSide, MSTicker *t = NULL);
	void disconnect(CallSide *recvSide);
	const std::string &getLocalAddress();
	int getAudioPort();
	void setRemoteAddr(const char *addr, int port);
	void assignPayloads(std::list<PayloadType *> &payloads);
	void setPtime(int ptime);
	void dump();
	void playTone(char tone_name);
54
	time_t getLastActivity();
55 56 57
	void doBgTasks();

  private:
58 59
	static void payloadTypeChanged(RtpSession *s, void *data, void *, void *);
	static void onTelephoneEvent(RtpSession *s, void *dtmfIndex, void *userData, void *);
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
	TranscodedCall *mCallCtx;
	RtpSession *mSession;
	RtpProfile *mProfile;
	PayloadType *getSendFormat();
	MSFilter *mReceiver;
	MSFilter *mSender;
	MSFilter *mDecoder;
	MSFilter *mEncoder;
	MSBitrateController *mRc;
	MSFilter *mToneGen;
	time_t mLastCheck;
	uint64_t mLastRecvCount;
	OrtpEvQueue *mRtpEvq;
	int mPtime;
	bool mRcEnabled;
	bool mUsePlc;
	std::string mLocalAddress;
Simon Morlat's avatar
Simon Morlat committed
77 78
};

79 80
class TranscodedCall : public CallContextBase {
  public:
81
	TranscodedCall(MSFactory *factory, sip_t *invite, const std::string &bind_address);
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
	void prepare(const CallContextParams &params);
	void join(MSTicker *ticker);
	void unjoin();
	bool isJoined() const;
	void redraw(CallSide *receiver);
	void setInitialOffer(std::list<PayloadType *> &payloads);
	const std::list<PayloadType *> &getInitialOffer() const;
	CallSide *getFrontSide() {
		return mFrontSide;
	}
	CallSide *getBackSide() {
		return mBackSide;
	}
	void playTone(sip_t *info);
	void playTone(CallSide *origin, char dtmf);
	~TranscodedCall();
	void dump();
	void doBgTasks();
100
	virtual time_t getLastActivity();
101 102 103
	const std::string &getBindAddress() const {
		return mBindAddress;
	}
104 105 106
	MSFactory *getFactory()const{
		return mFactory;
	}
107 108

  private:
109
	MSFactory *mFactory;
110 111 112 113 114 115 116 117
	CallSide *getOther(CallSide *cs);
	MSTicker *mTicker;
	CallSide *mFrontSide;
	CallSide *mBackSide;
	std::list<PayloadType *> mInitialOffer;
	int mInfoCSeq;
	std::string mBindAddress;
	time_t mCreateTime;
Simon Morlat's avatar
Simon Morlat committed
118 119 120
};

#endif