summaryrefslogtreecommitdiffstats
path: root/rfb
diff options
context:
space:
mode:
authorChristian Beier <[email protected]>2011-10-04 17:30:36 +0200
committerChristian Beier <[email protected]>2011-10-04 17:30:36 +0200
commitbffd9ee33bd141f5c75304b1430d2ea2725239b3 (patch)
tree0fd8ce48bd28965b623bc03c389847d11a55f3e8 /rfb
parent629fe03d617b2a968d30d7ed85c8f8b1e5d6a410 (diff)
parentabec0aa8c3e226682c684c9d8a0dab889815f511 (diff)
downloadlibtdevnc-bffd9ee33bd141f5c75304b1430d2ea2725239b3.tar.gz
libtdevnc-bffd9ee33bd141f5c75304b1430d2ea2725239b3.zip
Merge branch 'websockets'
Diffstat (limited to 'rfb')
-rw-r--r--rfb/rfb.h40
-rw-r--r--rfb/rfbconfig.h.cmake6
-rw-r--r--rfb/rfbproto.h22
3 files changed, 58 insertions, 10 deletions
diff --git a/rfb/rfb.h b/rfb/rfb.h
index c6cf524..004383d 100644
--- a/rfb/rfb.h
+++ b/rfb/rfb.h
@@ -373,6 +373,10 @@ typedef struct _rfbScreenInfo
rfbDisplayFinishedHookPtr displayFinishedHook;
/** xvpHook is called to handle an xvp client message */
rfbXvpHookPtr xvpHook;
+#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
+ char *sslkeyfile;
+ char *sslcertfile;
+#endif
} rfbScreenInfo, *rfbScreenInfoPtr;
@@ -419,6 +423,9 @@ typedef struct _rfbStatList {
struct _rfbStatList *Next;
} rfbStatList;
+typedef struct _rfbSslCtx rfbSslCtx;
+typedef struct _wsCtx wsCtx;
+
typedef struct _rfbClientRec {
/** back pointer to the screen */
@@ -547,7 +554,9 @@ typedef struct _rfbClientRec {
struct z_stream_s compStream;
rfbBool compStreamInited;
uint32_t zlibCompressLevel;
- /** the quality level is also used by ZYWRLE */
+#endif
+#if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG)
+ /** the quality level is also used by ZYWRLE and TightPng */
int tightQualityLevel;
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
@@ -555,6 +564,8 @@ typedef struct _rfbClientRec {
z_stream zsStruct[4];
rfbBool zsActive[4];
int zsLevel[4];
+#endif
+#if defined(LIBVNCSERVER_HAVE_LIBJPEG) || defined(LIBVNCSERVER_HAVE_LIBPNG)
int tightCompressLevel;
#endif
#endif
@@ -629,6 +640,15 @@ typedef struct _rfbClientRec {
char *afterEncBuf;
int afterEncBufSize;
int afterEncBufLen;
+#if defined(LIBVNCSERVER_HAVE_LIBZ) || defined(LIBVNCSERVER_HAVE_LIBPNG)
+ uint32_t tightEncoding; /* rfbEncodingTight or rfbEncodingTightPng */
+#endif
+
+#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
+ rfbSslCtx *sslctx;
+ wsCtx *wsctx;
+ char *wspath; /* Requests path component */
+#endif
} rfbClientRec, *rfbClientPtr;
/**
@@ -681,6 +701,7 @@ extern void rfbDisconnectUDPSock(rfbScreenInfoPtr rfbScreen);
extern void rfbCloseClient(rfbClientPtr cl);
extern int rfbReadExact(rfbClientPtr cl, char *buf, int len);
extern int rfbReadExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout);
+extern int rfbPeekExactTimeout(rfbClientPtr cl, char *buf, int len,int timeout);
extern int rfbWriteExact(rfbClientPtr cl, const char *buf, int len);
extern int rfbCheckFds(rfbScreenInfoPtr rfbScreen,long usec);
extern int rfbConnect(rfbScreenInfoPtr rfbScreen, char* host, int port);
@@ -690,6 +711,15 @@ extern int rfbListenOnUDPPort(int port, in_addr_t iface);
extern int rfbStringToAddr(char* string,in_addr_t* addr);
extern rfbBool rfbSetNonBlocking(int sock);
+#ifdef LIBVNCSERVER_WITH_WEBSOCKETS
+/* websockets.c */
+
+extern rfbBool webSocketsCheck(rfbClientPtr cl);
+extern rfbBool webSocketCheckDisconnect(rfbClientPtr cl);
+extern int webSocketsEncode(rfbClientPtr cl, const char *src, int len, char **dst);
+extern int webSocketsDecode(rfbClientPtr cl, char *dst, int len);
+#endif
+
/* rfbserver.c */
/* Routines to iterate over the client list in a thread-safe way.
@@ -805,7 +835,7 @@ extern rfbBool rfbSendRectEncodingUltra(rfbClientPtr cl, int x,int y,int w,int h
extern rfbBool rfbSendRectEncodingZlib(rfbClientPtr cl, int x, int y, int w,
int h);
-#ifdef LIBVNCSERVER_HAVE_LIBJPEG
+#if defined(LIBVNCSERVER_HAVE_LIBJPEG) || defined(LIBVNCSERVER_HAVE_LIBPNG)
/* tight.c */
#define TIGHT_DEFAULT_COMPRESSION 6
@@ -813,7 +843,13 @@ extern rfbBool rfbSendRectEncodingZlib(rfbClientPtr cl, int x, int y, int w,
extern rfbBool rfbTightDisableGradient;
extern int rfbNumCodedRectsTight(rfbClientPtr cl, int x,int y,int w,int h);
+
+#if defined(LIBVNCSERVER_HAVE_LIBJPEG)
extern rfbBool rfbSendRectEncodingTight(rfbClientPtr cl, int x,int y,int w,int h);
+#endif
+#if defined(LIBVNCSERVER_HAVE_LIBPNG)
+extern rfbBool rfbSendRectEncodingTightPng(rfbClientPtr cl, int x,int y,int w,int h);
+#endif
#endif
#endif
diff --git a/rfb/rfbconfig.h.cmake b/rfb/rfbconfig.h.cmake
index de898fc..b095948 100644
--- a/rfb/rfbconfig.h.cmake
+++ b/rfb/rfbconfig.h.cmake
@@ -18,6 +18,9 @@
/* Define to 1 if you have the `jpeg' library (-ljpeg). */
#cmakedefine LIBVNCSERVER_HAVE_LIBJPEG 1
+/* Define if you have the `png' library (-lpng). */
+#cmakedefine LIBVNCSERVER_HAVE_LIBPNG 1
+
/* Define to 1 if you have the `pthread' library (-lpthread). */
#cmakedefine LIBVNCSERVER_HAVE_LIBPTHREAD 1
@@ -60,6 +63,9 @@
/* Define to 1 if GnuTLS is present */
#cmakedefine LIBVNCSERVER_WITH_CLIENT_TLS 1
+/* Define to 1 to build with websockets */
+#cmakedefine LIBVNCSERVER_WITH_WEBSOCKETS 1
+
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#cmakedefine LIBVNCSERVER_WORDS_BIGENDIAN 1
diff --git a/rfb/rfbproto.h b/rfb/rfbproto.h
index 73d200a..c6dfd2c 100644
--- a/rfb/rfbproto.h
+++ b/rfb/rfbproto.h
@@ -434,6 +434,7 @@ typedef struct {
#define rfbEncodingHextile 5
#define rfbEncodingZlib 6
#define rfbEncodingTight 7
+#define rfbEncodingTightPng 0xFFFFFEFC /* -260 */
#define rfbEncodingZlibHex 8
#define rfbEncodingUltra 9
#define rfbEncodingZRLE 16
@@ -704,7 +705,10 @@ typedef struct {
#ifdef LIBVNCSERVER_HAVE_LIBZ
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- * Tight Encoding.
+ * Tight and TightPng Encoding.
+ *
+ *-- TightPng is like Tight but basic compression is not used, instead PNG
+ * data is sent.
*
*-- The first byte of each Tight-encoded rectangle is a "compression control
* byte". Its format is as follows (bit 0 is the least significant one):
@@ -715,8 +719,9 @@ typedef struct {
* bit 3: if 1, then compression stream 3 should be reset;
* bits 7-4: if 1000 (0x08), then the compression type is "fill",
* if 1001 (0x09), then the compression type is "jpeg",
+ * if 1001 (0x0A), then the compression type is "png",
* if 0xxx, then the compression type is "basic",
- * values greater than 1001 are not valid.
+ * values greater than 1010 are not valid.
*
* If the compression type is "basic", then bits 6..4 of the
* compression control byte (those xxx in 0xxx) specify the following:
@@ -726,17 +731,17 @@ typedef struct {
* bit 6: if 1, then a "filter id" byte is following this byte.
*
*-- The data that follows after the compression control byte described
- * above depends on the compression type ("fill", "jpeg" or "basic").
+ * above depends on the compression type ("fill", "jpeg", "png" or "basic").
*
*-- If the compression type is "fill", then the only pixel value follows, in
* client pixel format (see NOTE 1). This value applies to all pixels of the
* rectangle.
*
- *-- If the compression type is "jpeg", the following data stream looks like
- * this:
+ *-- If the compression type is "jpeg" or "png", the following data stream
+ * looks like this:
*
* 1..3 bytes: data size (N) in compact representation;
- * N bytes: JPEG image.
+ * N bytes: JPEG or PNG image.
*
* Data size is compactly represented in one, two or three bytes, according
* to the following scheme:
@@ -817,7 +822,7 @@ typedef struct {
*-- NOTE 2. The decoder must reset compression streams' states before
* decoding the rectangle, if some of bits 0,1,2,3 in the compression control
* byte are set to 1. Note that the decoder must reset zlib streams even if
- * the compression type is "fill" or "jpeg".
+ * the compression type is "fill", "jpeg" or "png".
*
*-- NOTE 3. The "gradient" filter and "jpeg" compression may be used only
* when bits-per-pixel value is either 16 or 32, not 8.
@@ -831,7 +836,8 @@ typedef struct {
#define rfbTightExplicitFilter 0x04
#define rfbTightFill 0x08
#define rfbTightJpeg 0x09
-#define rfbTightMaxSubencoding 0x09
+#define rfbTightPng 0x0A
+#define rfbTightMaxSubencoding 0x0A
/* Filters to improve compression efficiency */
#define rfbTightFilterCopy 0x00