forked from DoubangoTelecom/webrtc2sip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mp_engine.h
executable file
·124 lines (106 loc) · 4.55 KB
/
mp_engine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* Copyright (C) 2012-2015 Doubango Telecom <http://www.doubango.org>
*
* This file is part of Open Source 'webrtc2sip' project
* <http://code.google.com/p/webrtc2sip/>
*
* 'webrtc2sip' 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.
*
* 'webrtc2sip' 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 'webrtc2sip'.
*/
#if !defined(_MEDIAPROXY_ENGINE_H_)
#define _MEDIAPROXY_ENGINE_H_
#include "mp_config.h"
#include "mp_object.h"
#include "mp_mutex.h"
#include "mp_wrap.h"
#include "mp_peer.h"
#include "mp_c2c.h"
#include "mp_mail.h"
#include "mp_recaptcha.h"
#include "db/mp_db.h"
#include "db/mp_db_model.h"
#include <map>
#include <list>
namespace webrtc2sip {
//
// MPEngine
//
class MPEngine : public MPObject
{
friend class MPSipCallback;
protected:
MPEngine(const char* pRealmUri, const char* pPrivateIdentity, const char* pPublicIdentity);
public:
virtual ~MPEngine();
virtual MP_INLINE const char* getObjectId() { return "MPEngine"; }
virtual MP_INLINE bool isValid(){ return m_bValid; }
virtual MP_INLINE bool isStarted(){ return m_bStarted; }
virtual bool setDebugLevel(const char* pcLevel);
virtual bool addTransport(const char* pTransport, uint16_t nLocalPort, const char* pcLocalIP = tsk_null);
virtual bool setRtpSymetricEnabled(bool bEnabled);
virtual bool set100relEnabled(bool bEnabled);
virtual bool setMediaCoderEnabled(bool bEnabled);
virtual bool setVideoJbEnabled(bool bEnabled);
virtual bool setRtpBuffSize(int32_t nSize);
virtual bool setAvpfTail(int32_t nMin, int32_t nMax);
virtual bool setPrefVideoSize(const char* pcPrefVideoSize);
virtual bool setSSLCertificates(const char* pcPrivateKey, const char* pcPublicKey, const char* pcCA, bool bVerify = false);
virtual bool setCodecs(const char* pcCodecs);
virtual bool setCodecOpusMaxRates(int32_t nPlaybackMaxRate, int32_t nCaptureMaxRate);
virtual bool setSRTPMode(const char* pcMode);
virtual bool setSRTPType(const char* pcTypesCommaSep);
virtual bool setDtmfType(const char* pcDtmfType);
virtual bool setStunServer(const char* pcIP, unsigned short nPort, const char* pcUsrName, const char* pcUsrPwd);
virtual bool setIceStunEnabled(bool bEnabled);
virtual bool setMaxFds(int32_t nMaxFds);
virtual bool addDNSServer(const char* pcDNSServer);
virtual bool setDbInfo(const char* pcDbType, const char* pcDbConnectionInfo);
virtual bool setHttpDomain(const char* pcC2CHttpDomain);
virtual bool setRecaptchaInfo(const char* pcSiteVerifyUrl, const char* pcSecret);
virtual bool setMailAccountInfo(const char* pcScheme, const char* pcLocalIP, unsigned short nLocalPort, const char* pcSmtpHost, unsigned short nSmtpPort, const char* pcEmail, const char* pcAuthName, const char* pcAuthPwd);
virtual bool addAccountSipCaller(const char* pcDisplayName, const char* pcImpu, const char* pcImpi, const char* pcRealm, const char* pcPassword);
virtual MPObjectWrapper<MPDbAccountSipCaller*> findAccountSipCallerByRealm(const char* pcRealm);
virtual bool start();
virtual bool stop();
virtual MP_INLINE MPObjectWrapper<MPDb*> getDB() { return m_oDb; }
static MPObjectWrapper<MPEngine*> New();
protected:
virtual MP_INLINE void setStarted(bool bStarted){ m_bStarted = bStarted; }
virtual MPObjectWrapper<MPPeer*> getPeerById(uint64_t nId);
virtual MPObjectWrapper<MPPeer*> getPeerBySessionId(uint64_t nId, bool bSessionLeft);
virtual void insertPeer(MPObjectWrapper<MPPeer*> oPeer);
virtual void removePeer(uint64_t nId);
private:
MPObjectWrapper<MPMutex*> m_oMutex;
MPObjectWrapper<MPSipCallback*> m_oCallback;
MPObjectWrapper<MPSipStack*> m_oSipStack;
MPObjectWrapper<MPDb*> m_oDb;
std::map<uint64_t, MPObjectWrapper<MPPeer*> > m_Peers;
std::list<MPObjectWrapper<MPC2CTransport*> > m_C2CTransports;
MPObjectWrapper<MPMailTransport*> m_oMailTransport;
MPObjectWrapper<MPRecaptchaTransport*> m_oRecaptchaTransport;
MPObjectWrapper<MPMutex*> m_oMutexPeers;
std::list<MPObjectWrapper<MPDbAccountSipCaller*> > m_oAccountSipCallers;
struct{
char* pPrivateKey;
char* pPublicKey;
char* pCA;
bool bVerify;
} m_SSL;
char* m_pDtmfType;
char* m_pC2CHttpDomain;
bool m_bStarted;
bool m_bValid;
static bool g_bInitialized;
};
} // namespace
#endif /* _MEDIAPROXY_ENGINE_H_ */