Welcome to mirror list, hosted at ThFree Co, Russian Federation.

XrdpUlalacaPrivate.hpp - github.com/neutrinolabs/ulalaca-xrdp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 45b0136b0ac1227706c0d36c2cbb072036634414 (plain)
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
#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 <mutex>

#include "XrdpEvent.hpp"
#include "XrdpTransport.hpp"
#include "XrdpStream.hpp"

#include "UnixSocket.hpp"

#include "messages/projector.h"

struct XrdpUlalaca;
class ProjectionThread;

class XrdpUlalacaPrivate {
public:
    constexpr static const int RECT_SIZE_BYPASS_CREATE = 0;

    constexpr static const int NO_ERROR = 0;

    explicit XrdpUlalacaPrivate(XrdpUlalaca *mod);
    XrdpUlalacaPrivate(XrdpUlalacaPrivate &) = delete;

    /* 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);

    /* session-broker related */
    inline std::string getSessionSocketPathUsingCredential(
            const std::string &username,
            const std::string &password
    );

    /* paint related */
    inline int decideCopyRectSize() const;
    inline std::unique_ptr<std::vector<Rect>> createCopyRects(std::vector<Rect> &dirtyRects, int rectSize) const;

    void addDirtyRect(Rect &rect);
    void commitUpdate(const uint8_t *image, int32_t width, int32_t height);

    void calculateSessionSize();

    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;

    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<ProjectionThread> _projectionThread;

    std::atomic_bool _fullInvalidate;
    std::mutex _commitUpdateLock;

    std::vector<ULIPCRect> _dirtyRects;
};

#endif