blob: f7a7044b4f56b26d7abc0704f86336a852f89c33 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
Pierre Ossman0d3ce872018-06-18 15:59:00 +02002 * Copyright 2014-2018 Pierre Ossman for Cendio AB
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00003 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */
19//
Pierre Ossman0d3ce872018-06-18 15:59:00 +020020// ClientParams - structure describing the current state of the remote client
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000021//
22
Pierre Ossman0d3ce872018-06-18 15:59:00 +020023#ifndef __RFB_CLIENTPARAMS_H__
24#define __RFB_CLIENTPARAMS_H__
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000025
Pierre Ossmanc0397262014-03-14 15:59:46 +010026#include <set>
27
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000028#include <rdr/types.h>
Pierre Ossman126e5642014-02-13 14:40:25 +010029#include <rfb/Cursor.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000030#include <rfb/PixelFormat.h>
Pierre Ossmancbd1b2c2009-03-20 16:05:04 +000031#include <rfb/ScreenSet.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000032
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000033namespace rfb {
34
Pierre Ossmanb948a912014-01-15 13:23:43 +010035 const int subsampleUndefined = -1;
36 const int subsampleNone = 0;
37 const int subsampleGray = 1;
38 const int subsample2X = 2;
39 const int subsample4X = 3;
40 const int subsample8X = 4;
41 const int subsample16X = 5;
42
Pierre Ossman0d3ce872018-06-18 15:59:00 +020043 class ClientParams {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000044 public:
Pierre Ossman0d3ce872018-06-18 15:59:00 +020045 ClientParams();
46 ~ClientParams();
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000047
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000048 int majorVersion;
49 int minorVersion;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000050
51 void setVersion(int major, int minor) {
52 majorVersion = major; minorVersion = minor;
53 }
Pierre Ossmanf22d3502015-11-10 12:58:49 +010054 bool isVersion(int major, int minor) const {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000055 return majorVersion == major && minorVersion == minor;
56 }
Pierre Ossmanf22d3502015-11-10 12:58:49 +010057 bool beforeVersion(int major, int minor) const {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000058 return (majorVersion < major ||
59 (majorVersion == major && minorVersion < minor));
60 }
Pierre Ossmanf22d3502015-11-10 12:58:49 +010061 bool afterVersion(int major, int minor) const {
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000062 return !beforeVersion(major,minor+1);
63 }
64
Pierre Ossman9312b0e2018-06-20 12:25:14 +020065 const int width() const { return width_; }
66 const int height() const { return height_; }
67 const ScreenSet& screenLayout() const { return screenLayout_; }
68 void setDimensions(int width, int height);
69 void setDimensions(int width, int height, const ScreenSet& layout);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000070
Pierre Ossmanf22d3502015-11-10 12:58:49 +010071 const PixelFormat& pf() const { return pf_; }
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000072 void setPF(const PixelFormat& pf);
73
Pierre Ossmanf22d3502015-11-10 12:58:49 +010074 const char* name() const { return name_; }
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000075 void setName(const char* name);
76
Pierre Ossman6a1a0d02017-02-19 15:48:17 +010077 const Cursor& cursor() const { return *cursor_; }
Pierre Ossman126e5642014-02-13 14:40:25 +010078 void setCursor(const Cursor& cursor);
79
Pierre Ossmanf22d3502015-11-10 12:58:49 +010080 bool supportsEncoding(rdr::S32 encoding) const;
Pierre Ossman941d2902014-01-15 13:51:53 +010081
Peter Åstrand98fe98c2010-02-10 07:43:02 +000082 void setEncodings(int nEncodings, const rdr::S32* encodings);
Pierre Ossman941d2902014-01-15 13:51:53 +010083
Pierre Ossman2fa63f82016-12-05 15:26:21 +010084 unsigned int ledState() { return ledState_; }
85 void setLEDState(unsigned int state);
86
Pierre Ossmanb114f5c2018-06-18 16:34:16 +020087 // Wrappers to check for functionality rather than specific
88 // encodings
89 bool supportsLocalCursor() const;
Pierre Ossman2daba9b2018-10-29 10:03:37 +010090 bool supportsDesktopSize() const;
Pierre Ossmanb114f5c2018-06-18 16:34:16 +020091 bool supportsLEDState() const;
92 bool supportsFence() const;
93 bool supportsContinuousUpdates() const;
Pierre Ossmancbd1b2c2009-03-20 16:05:04 +000094
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000095 int compressLevel;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000096 int qualityLevel;
DRCb4a83232011-08-19 04:57:18 +000097 int fineQualityLevel;
Pierre Ossmanb948a912014-01-15 13:23:43 +010098 int subsampling;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000099
100 private:
101
Pierre Ossman9312b0e2018-06-20 12:25:14 +0200102 int width_;
103 int height_;
104 ScreenSet screenLayout_;
105
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +0000106 PixelFormat pf_;
107 char* name_;
Pierre Ossman6a1a0d02017-02-19 15:48:17 +0100108 Cursor* cursor_;
Pierre Ossmanc0397262014-03-14 15:59:46 +0100109 std::set<rdr::S32> encodings_;
Pierre Ossman2fa63f82016-12-05 15:26:21 +0100110 unsigned int ledState_;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +0000111 };
112}
113#endif