forked from team-unstablers/ulalaca-xrdp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
XrdpUlalacaPrivate.hpp
137 lines (104 loc) · 3.6 KB
/
XrdpUlalacaPrivate.hpp
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
125
126
127
128
129
130
131
132
133
134
135
136
137
#ifndef XRDP_XRDPULALACAPRIVATE_HPP
#define XRDP_XRDPULALACAPRIVATE_HPP
#if defined(HAVE_CONFIG_H)
#include <config_ac.h>
#endif
extern "C" {
#include "arch.h"
#include "parse.h"
#include "os_calls.h"
#include "defines.h"
#include "guid.h"
#include "xrdp_client_info.h"
};
#include <queue>
#include <mutex>
#include "XrdpEvent.hpp"
#include "XrdpTransport.hpp"
#include "XrdpStream.hpp"
#include "UnixSocket.hpp"
#include "ProjectionTarget.hpp"
struct XrdpUlalaca;
class ProjectorClient;
struct ScreenUpdate {
double timestamp;
std::shared_ptr<uint8_t> image;
size_t size;
int32_t width;
int32_t height;
std::shared_ptr<std::vector<ULIPCRect>> dirtyRects;
};
class XrdpUlalacaPrivate: public ProjectionTarget {
public:
constexpr static const int RECT_SIZE_BYPASS_CREATE = 0;
constexpr static const int NO_ERROR = 0;
static bool isRectOverlaps(const ULIPCRect &a, const ULIPCRect &b);
static void mergeRect(ULIPCRect &a, const ULIPCRect &b);
static std::vector<ULIPCRect> removeRectOverlap(const ULIPCRect &a, const ULIPCRect &b);
explicit XrdpUlalacaPrivate(XrdpUlalaca *mod);
XrdpUlalacaPrivate(XrdpUlalacaPrivate &) = delete;
~XrdpUlalacaPrivate();
/* lib_mod_* */
int libModStart(int width, int height, int bpp);
int libModConnect();
int libModEvent(int type, long arg1, long arg2, long arg3, long arg4);
int libModSignal();
int libModEnd();
int libModSetParam(const char *cstrName, const char *cstrValue);
int libModSessionChange(int, int);
int libModGetWaitObjs(tbus *readObjs, int *rcount,
tbus *writeObjs, int *wcount, int *timeout);
int libModCheckWaitObjs();
int libModFrameAck(int flags, int frameId);
int libModSuppressOutput(int suppress,
int left, int top, int right, int bottom);
int libModServerMonitorResize(int width, int height);
int libModServerMonitorFullInvalidate(int width, int height);
int libModServerVersionMessage();
/* utility methods / lib_server_* wrappers */
void serverMessage(const char *message, int code);
/**
* attach to projector session
*/
void attachToSession(std::string sessionPath);
/* paint related */
inline int decideCopyRectSize() const;
inline std::unique_ptr<std::vector<ULIPCRect>> createCopyRects(std::vector<ULIPCRect> &dirtyRects, int rectSize) const;
void addDirtyRect(ULIPCRect &rect) override;
void commitUpdate(const uint8_t *image, size_t size, int32_t width, int32_t height) override;
void ipcDisconnected() override;
void updateThreadLoop();
void calculateSessionSize();
inline bool isNSCodec() const;
inline bool isRFXCodec() const;
inline bool isJPEGCodec() const;
inline bool isH264Codec() const;
inline bool isGFXH264Codec() const;
inline bool isRawBitmap() const;
private:
XrdpUlalaca *_mod;
int _error = 0;
bool _isUpdateThreadRunning;
ULIPCRect _sessionSize;
std::vector<ULIPCRect> _screenLayouts;
int _bpp;
std::atomic_int64_t _frameId;
std::atomic_int64_t _ackFrameId;
std::string _username;
std::string _password;
std::string _ip;
std::string _port;
int _keyLayout;
int _delayMs;
guid _guid;
int _encodingsMask;
xrdp_client_info _clientInfo;
std::unique_ptr<UnixSocket> _socket;
std::unique_ptr<ProjectorClient> _projectorClient;
std::unique_ptr<std::thread> _updateThread;
std::atomic_bool _fullInvalidate;
std::mutex _commitUpdateLock;
std::shared_ptr<std::vector<ULIPCRect>> _dirtyRects;
std::queue<ScreenUpdate> _updateQueue;
};
#endif