1
// Copyright (C) 2001 Constantin Kaplinsky. All Rights Reserved.
2
// Copyright (C) 2000 Tridia Corporation. All Rights Reserved.
3
// Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
5
// This file is part of the VNC system.
7
// The VNC system is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with this program; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22
// TightVNC distribution homepage on the Web: http://www.tightvnc.com/
24
// If the source code for the VNC system is not available from the place
25
// whence you received this file, check http://www.uk.research.att.com/vnc or contact
26
// the authors on vnc@uk.research.att.com for information on obtaining it.
31
// The vncEncoder object encodes regions of a display buffer for sending
36
#if !defined(RFBENCODER_DEFINED)
37
#define RFBENCODER_DEFINED
40
#include "vncBuffer.h"
41
#include "translate.h"
52
// Create/Destroy methods
54
virtual ~vncEncoder();
59
// A method to return the encoding name, used by the LogStats() method
60
virtual const char* GetEncodingName() { return "Raw"; }
62
// Central method for outputing encoding statistics
63
virtual void LogStats();
65
// Encoder stats used by the buffer object
66
virtual UINT RequiredBuffSize(UINT width, UINT height);
67
virtual UINT NumCodedRects(RECT &rect);
69
// Translation & encoding routines
70
// - Source is the base address of the ENTIRE SCREEN buffer.
71
// The Translate routine compensates automatically for the desired rectangle.
72
// - Dest is the base address to encode the rect to. The rect will be encoded
73
// into a contiguous region of the buffer.
74
virtual void Translate(BYTE *source, BYTE *dest, const RECT &rect);
75
virtual UINT EncodeRect(BYTE *source, BYTE *dest, const RECT &rect, int offsetx, int offsety);
76
virtual UINT EncodeRect(BYTE *source, VSocket *outConn, BYTE *dest, const RECT &rect, int offsetx, int offsety);
78
// Additional translation function for cursor shape data (overloaded!)
79
void Translate(BYTE *source, BYTE *dest, int w, int h, int bytesPerRow);
81
// Translation handling
82
BOOL SetLocalFormat(rfbPixelFormat &pixformat, int width, int height);
83
BOOL SetRemoteFormat(rfbPixelFormat &pixformat);
85
// Configuring encoder
86
void SetCompressLevel(int level);
87
void SetQualityLevel(int level);
88
void EnableXCursor(BOOL enable) { m_use_xcursor = enable; }
89
void EnableRichCursor(BOOL enable) { m_use_richcursor = enable; }
90
void EnableLastRect(BOOL enable) { m_use_lastrect = enable; }
92
// Colour map handling
93
BOOL GetRemotePalette(RGBQUAD *quadlist, UINT ncolours);
95
// Supporting cursor shape updates
96
BOOL SendEmptyCursorShape(VSocket *outConn);
97
BOOL SendCursorShape(VSocket *outConn, vncDesktop *desktop);
100
BOOL SetTranslateFunction();
102
// Supporting cursor shape updates
103
BOOL SendXCursorShape(VSocket *outConn, BYTE *mask, int xhot,int yhot,int width,int height);
104
BOOL SendRichCursorShape(VSocket *outConn, BYTE *mbits, BYTE *cbits, int xhot,int yhot,int width,int height);
105
void FixCursorMask(BYTE *mbits, BYTE *cbits, int width, int height, int width_bytes);
109
rfbTranslateFnType m_transfunc; // Translator function
110
char* m_transtable; // Colour translation LUT
111
char* m_localpalette; // Palette info if client is palette-based
112
rfbPixelFormat m_localformat; // Pixel Format info
113
rfbPixelFormat m_remoteformat; // Client pixel format info
114
rfbPixelFormat m_transformat; // Internal format used for translation (usually == client format)
115
int m_bytesPerRow; // Number of bytes per row locally
116
int dataSize; // Total size of raw data encoded
117
int rectangleOverhead; // Total size of rectangle header data
118
int encodedSize; // Total size of encoded data
119
int transmittedSize; // Total amount of data sent
121
int m_compresslevel; // Encoding-specific compression level (if needed).
122
int m_qualitylevel; // Image quality level for lossy JPEG compression.
123
BOOL m_use_xcursor; // XCursor cursor shape updates allowed.
124
BOOL m_use_richcursor; // RichCursor cursor shape updates allowed.
125
BOOL m_use_lastrect; // LastRect pseudo-encoding allowed.
128
#endif // vncENCODER_DEFINED