FabGL
ESP32 Display Controller and Graphics Library
RFB.h
Go to the documentation of this file.
1 /*
2  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3  Copyright (c) 2019-2021 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6 
7 * Please contact fdivitto2013@gmail.com if you need a commercial license.
8 
9 
10 * This library and related software is available under GPL v3. Feel free to use FabGL in free software and hardware:
11 
12  FabGL is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  FabGL is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 
27 #pragma once
28 
29 
38 #include "fabglconf.h"
40 #include "fabutils.h"
41 #include "netutils.h"
42 
43 
44 
45 namespace fabgl {
46 
47 
48 void tripleDES_transform(char const * password, bool decode, uint8_t * inBlock, uint8_t * outBlock, size_t length);
49 
50 
51 
54 
55 
56 typedef void (*RenderRow)(void * context, int col, int row, void * data, int width);
57 
58 
59 enum class RFBState { Success,
60  HostNameError,
61  UnableToConnect,
62  CommunicationError,
63  UnsupportedProtocolVersion,
64  ErrorGettingSecTypes,
65  UnsupportedAuth,
66  AuthFailed,
67  };
68 
69 class RFBClient {
70 
71 public:
72 
73  RFBClient();
74  ~RFBClient();
75 
76  RFBState connect(char const * host, uint16_t port, char const * password, bool sharedConnection = true);
77 
78  void setPixelFormat(int bitsPerPixel, int depth, bool bigEndian, bool trueColor, int redMax, int greenMax, int blueMax, int redShift, int greenShift, int blueShift);
79 
80  void setRenderRowCallback(RenderRow value, void * context) { m_renderRow = value; m_renderRowContext = context; }
81 
82 protected:
83 
84  void sendSetEncodings(uint32_t const * encodings, size_t encodingsCount);
85  void sendRequestUpdate(int x, int y, int width, int height, bool incremental);
86  void sendSetPixelFormat();
87 
88 private:
89 
90  Socket m_socket;
91 
92  // frame buffer info
93  uint16_t m_frameBufferWidth;
94  uint16_t m_frameBufferHeight;
95 
96  // pixel format info
97  uint8_t m_bitsPerPixel;
98  uint8_t m_depth;
99  uint8_t m_bigEndian;
100  uint8_t m_trueColor;
101  uint16_t m_redMax;
102  uint16_t m_greenMax;
103  uint16_t m_blueMax;
104  uint8_t m_redShift;
105  uint8_t m_greenShift;
106  uint8_t m_blueShift;
107 
108  // server name
109  char * m_name;
110 
111  // render callback
112  RenderRow m_renderRow;
113  void * m_renderRowContext;
114 
115 };
116 
117 
120 
121 
122 
123 } // fabgl namespace
This file contains fabgl::VGA16Controller definition.
uint8_t const * data
This file contains some utility classes and functions.
Definition: canvas.cpp:36
This file contains RFBClient class.
This file contains FabGL library configuration settings, like number of supported colors...
uint8_t height
uint8_t width