Debian Codegraph @

Xpjproject/pjsip-apps/src/pjsua/winrt/gui/uwp/VoipBackEnd/MyApp.h

raw symbols SCIP
1 /* $Id*/
2 /*
3 * Copyright (C) 2016 Teluu Inc. (http://www.teluu.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 #pragma once
21 #include <pjsua2.hpp>
22 #include <collection.h>
23
24 namespace VoipBackEnd
25 {
26 typedef int TransportId;
27
28 typedef Platform::Collections::Vector<Platform::String^> StringVector;
29 typedef Windows::Foundation::Collections::IVector<Platform::String^>
30 IStringVector;
31
32 typedef public enum class INV_STATE
33 {
34 PJSIP_INV_STATE_NULL, /**< Before INVITE is sent or received */
35 PJSIP_INV_STATE_CALLING, /**< After INVITE is sent */
36 PJSIP_INV_STATE_INCOMING, /**< After INVITE is received. */
37 PJSIP_INV_STATE_EARLY, /**< After response with To tag. */
38 PJSIP_INV_STATE_CONNECTING, /**< After 2xx is sent/received. */
39 PJSIP_INV_STATE_CONFIRMED, /**< After ACK is sent/received. */
40 PJSIP_INV_STATE_DISCONNECTED, /**< Session is terminated. */
41 } INV_STATE;
42
43 class ImpLogWriter : public pj::LogWriter
44 {
45 public:
46 virtual void write(const pj::LogEntry &entry);
47 };
48
49 /* Account related data type. */
50 public ref struct OnRegStateParamRT sealed
51 {
52 OnRegStateParamRT();
53
54 property pj_status_t status
55 {
56 pj_status_t get();
57 };
58
59 property unsigned code
60 {
61 unsigned get();
62 };
63
64 property Platform::String^ reason
65 {
66 Platform::String^ get();
67 };
68
69 property int expiration
70 {
71 int get();
72 };
73
74 internal:
75 OnRegStateParamRT(const pj::OnRegStateParam& param);
76
77 private:
78 pj::OnRegStateParam* inPtr;
79
80 ~OnRegStateParamRT();
81 };
82
83 public ref struct CallInfoRT sealed
84 {
85 property Platform::String^ localUri
86 {
87 Platform::String^ get();
88 }
89
90 property Platform::String^ localContact
91 {
92 Platform::String^ get();
93 }
94
95 property Platform::String^ remoteUri
96 {
97 Platform::String^ get();
98 }
99
100 property Platform::String^ remoteContact
101 {
102 Platform::String^ get();
103 }
104
105 property INV_STATE state
106 {
107 INV_STATE get();
108 };
109
110 internal:
111 CallInfoRT(const pj::CallInfo& info);
112
113 private:
114 pj::CallInfo* inPtr;
115
116 ~CallInfoRT();
117
118 };
119
120 public interface class IntAccount
121 {
122 public:
123 virtual void onRegState(OnRegStateParamRT^ prm);
124 virtual void onIncomingCall(CallInfoRT^ info);
125 };
126
127 class ImpAccount : public pj::Account
128 {
129 public:
130 void setCallback(IntAccount^ callback);
131
132 virtual void onIncomingCall(pj::OnIncomingCallParam& prm);
133 virtual void onRegState(pj::OnRegStateParam& prm);
134
135 ~ImpAccount() {};
136
137 private:
138 IntAccount^ cb;
139 };
140
141 /* Call related data type. */
142 public ref class CallOpParamRT sealed
143 {
144 public:
145 CallOpParamRT();
146
147 property unsigned statusCode
148 {
149 unsigned get();
150 void set(unsigned val);
151 }
152
153 property Platform::String^ reason {
154 Platform::String^ get();
155 void set(Platform::String^ val);
156 }
157
158 internal:
159 pj::CallOpParam* getPtr();
160
161 private:
162 pj::CallOpParam* inPtr;
163
164 ~CallOpParamRT();
165 };
166
167 public interface class IntCall
168 {
169
170 public:
171 virtual void onCallState(CallInfoRT^ info);
172 };
173
174 class ImpCall : public pj::Call
175 {
176 public:
177 ImpCall(pj::Account& account, int call_id);
178 virtual ~ImpCall() {};
179
180 void setCallback(IntCall^ callback);
181
182 virtual void onCallState(pj::OnCallStateParam& prm);
183 virtual void onCallMediaState(pj::OnCallMediaStateParam& prm);
184
185 private:
186 IntCall^ cb;
187 };
188
189 public ref class AccountInfo sealed
190 {
191 public:
192 property Platform::String^ id {
193 Platform::String^ get();
194 }
195 property Platform::String^ registrar {
196 Platform::String^ get();
197 }
198 property Platform::String^ proxy {
199 Platform::String^ get();
200 }
201 property Platform::String^ username {
202 Platform::String^ get();
203 }
204 property Platform::String^ password {
205 Platform::String^ get();
206 }
207 internal:
208 AccountInfo(pj::AccountConfig* accConfig);
209 private:
210 pj::AccountConfig* cfg;
211 };
212
213 /* App class. */
214 public ref class MyAppRT sealed
215 {
216 public:
217 static property MyAppRT^ Instance {
218 MyAppRT^ get();
219 }
220
221 void init(IntAccount^ iAcc, IntCall^ iCall);
222 void deInit();
223
224 /* Util */
225 void writeLog(int level, Platform::String^ message);
226
227 /* Call handling. */
228 void hangupCall();
229 void answerCall(CallOpParamRT^ prm);
230 void makeCall(Platform::String^ dst_uri);
231 CallInfoRT^ getCallInfo();
232
233 /* Thread handling. */
234 void registerThread(Platform::String^ name);
235 bool isThreadRegistered();
236
237 /* Account handling. */
238 AccountInfo^ getAccountInfo();
239
240 void modifyAccount(Platform::String^ id, Platform::String^ registrar,
241 Platform::String^ proxy, Platform::String^ username,
242 Platform::String^ password);
243
244 internal:
245 pj_bool_t handleIncomingCall(int callId);
246
247 private:
248 MyAppRT();
249 ~MyAppRT();
250
251 void loadConfig();
252 void saveConfig();
253
254 static MyAppRT^ singleton;
255
256 ImpLogWriter* logWriter;
257 pj::Endpoint ep;
258
259 /* Configs */
260 pj::EpConfig* epConfig;
261 pj::AccountConfig* accConfig;
262 pj::TransportConfig* sipTpConfig;
263
264 std::string appDir;
265 ImpAccount* account;
266 ImpCall* activeCall;
267
268 IntAccount^ intAcc;
269 IntCall^ intCall;
270 };
271 }