0
|
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC.
|
|
2 // All rights reserved.
|
|
3 //
|
|
4 //-------------------------------------------------------------------------
|
|
5 // This file is part of the TightVNC software. Please visit our Web site:
|
|
6 //
|
|
7 // http://www.tightvnc.com/
|
|
8 //
|
|
9 // This program is free software; you can redistribute it and/or modify
|
|
10 // it under the terms of the GNU General Public License as published by
|
|
11 // the Free Software Foundation; either version 2 of the License, or
|
|
12 // (at your option) any later version.
|
|
13 //
|
|
14 // This program is distributed in the hope that it will be useful,
|
|
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 // GNU General Public License for more details.
|
|
18 //
|
|
19 // You should have received a copy of the GNU General Public License along
|
|
20 // with this program; if not, write to the Free Software Foundation, Inc.,
|
|
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
22 //-------------------------------------------------------------------------
|
|
23 //
|
|
24
|
|
25 package com.glavsoft.rfb.encoding;
|
|
26
|
|
27 import java.util.LinkedHashSet;
|
|
28
|
|
29 /**
|
|
30 * Encoding types
|
|
31 */
|
|
32 public enum EncodingType {
|
|
33 /**
|
|
34 * Desktop data representes as raw bytes stream
|
|
35 */
|
|
36 RAW_ENCODING(0, "Raw"),
|
|
37 /**
|
|
38 * Specfies encodings which allow to copy part of image in client's
|
|
39 * framebuffer from one place to another.
|
|
40 */
|
|
41 COPY_RECT(1, "CopyRect"),
|
|
42 RRE(2, "RRE"),
|
|
43 /**
|
|
44 * Hextile encoding, uses palettes, filling and raw subencoding
|
|
45 */
|
|
46 HEXTILE(5, "Hextile"),
|
|
47 /**
|
|
48 * This encoding is like raw but previously all data compressed with zlib.
|
|
49 */
|
|
50 ZLIB(6, "ZLib"),
|
|
51 /**
|
|
52 * Tight Encoding for slow connection. It is uses raw data, palettes, filling
|
|
53 * and jpeg subencodings
|
|
54 */
|
|
55 TIGHT(7, "Tight"),
|
|
56 //ZlibHex(8),
|
|
57 /**
|
|
58 * ZRLE Encoding is like Hextile but previously all data compressed with zlib.
|
|
59 */
|
|
60 ZRLE(16, "ZRLE"),
|
|
61
|
|
62 /**
|
|
63 * Rich Cursor pseudo encoding which allows to transfer cursor shape
|
|
64 * with transparency
|
|
65 */
|
|
66 RICH_CURSOR(0xFFFFFF11, "RichCursor"),
|
|
67 /**
|
|
68 * Desktop Size Pseudo encoding allows to notificate client about
|
|
69 * remote screen resolution changed.
|
|
70 */
|
|
71 DESKTOP_SIZE(0xFFFFFF21, "DesctopSize"),
|
|
72 /**
|
|
73 * Cusros position encoding allows to transfer remote cursor position to
|
|
74 * client side.
|
|
75 */
|
|
76 CURSOR_POS(0xFFFFFF18, "CursorPos"),
|
|
77
|
|
78 COMPRESS_LEVEL_0(0xFFFFFF00 + 0, "CompressionLevel0"),
|
|
79 COMPRESS_LEVEL_1(0xFFFFFF00 + 1, "CompressionLevel1"),
|
|
80 COMPRESS_LEVEL_2(0xFFFFFF00 + 2, "CompressionLevel2"),
|
|
81 COMPRESS_LEVEL_3(0xFFFFFF00 + 3, "CompressionLevel3"),
|
|
82 COMPRESS_LEVEL_4(0xFFFFFF00 + 4, "CompressionLevel4"),
|
|
83 COMPRESS_LEVEL_5(0xFFFFFF00 + 5, "CompressionLevel5"),
|
|
84 COMPRESS_LEVEL_6(0xFFFFFF00 + 6, "CompressionLevel6"),
|
|
85 COMPRESS_LEVEL_7(0xFFFFFF00 + 7, "CompressionLevel7"),
|
|
86 COMPRESS_LEVEL_8(0xFFFFFF00 + 8, "CompressionLevel8"),
|
|
87 COMPRESS_LEVEL_9(0xFFFFFF00 + 9, "CompressionLevel9"),
|
|
88
|
|
89 JPEG_QUALITY_LEVEL_0(0xFFFFFFE0 + 0, "JpegQualityLevel0"),
|
|
90 JPEG_QUALITY_LEVEL_1(0xFFFFFFE0 + 1, "JpegQualityLevel1"),
|
|
91 JPEG_QUALITY_LEVEL_2(0xFFFFFFE0 + 2, "JpegQualityLevel2"),
|
|
92 JPEG_QUALITY_LEVEL_3(0xFFFFFFE0 + 3, "JpegQualityLevel3"),
|
|
93 JPEG_QUALITY_LEVEL_4(0xFFFFFFE0 + 4, "JpegQualityLevel4"),
|
|
94 JPEG_QUALITY_LEVEL_5(0xFFFFFFE0 + 5, "JpegQualityLevel5"),
|
|
95 JPEG_QUALITY_LEVEL_6(0xFFFFFFE0 + 6, "JpegQualityLevel6"),
|
|
96 JPEG_QUALITY_LEVEL_7(0xFFFFFFE0 + 7, "JpegQualityLevel7"),
|
|
97 JPEG_QUALITY_LEVEL_8(0xFFFFFFE0 + 8, "JpegQualityLevel8"),
|
|
98 JPEG_QUALITY_LEVEL_9(0xFFFFFFE0 + 9, "JpegQualityLevel9");
|
|
99
|
|
100 private int id;
|
|
101 private final String name;
|
|
102 private EncodingType(int id, String name) {
|
|
103 this.id = id;
|
|
104 this.name = name;
|
|
105 }
|
|
106
|
|
107 public int getId() {
|
|
108 return id;
|
|
109 }
|
|
110 public String getName() {
|
|
111 return name;
|
|
112 }
|
|
113
|
|
114 public static LinkedHashSet<EncodingType> ordinaryEncodings = new LinkedHashSet<EncodingType>();
|
|
115 static {
|
|
116 ordinaryEncodings.add(TIGHT);
|
|
117 ordinaryEncodings.add(HEXTILE);
|
|
118 ordinaryEncodings.add(ZRLE);
|
|
119 ordinaryEncodings.add(ZLIB);
|
|
120 ordinaryEncodings.add(RRE);
|
|
121 ordinaryEncodings.add(COPY_RECT);
|
|
122 // ordinaryEncodings.add(RAW_ENCODING);
|
|
123 }
|
|
124
|
|
125 public static LinkedHashSet<EncodingType> pseudoEncodings = new LinkedHashSet<EncodingType>();
|
|
126 static {
|
|
127 pseudoEncodings.add(RICH_CURSOR);
|
|
128 pseudoEncodings.add(CURSOR_POS);
|
|
129 pseudoEncodings.add(DESKTOP_SIZE);
|
|
130 }
|
|
131
|
|
132 public static LinkedHashSet<EncodingType> compressionEncodings = new LinkedHashSet<EncodingType>();
|
|
133 static {
|
|
134 compressionEncodings.add(COMPRESS_LEVEL_0);
|
|
135 compressionEncodings.add(JPEG_QUALITY_LEVEL_0);
|
|
136 }
|
|
137
|
|
138 public static EncodingType byId(int id) {
|
|
139 // TODO needs to speedup with hash usage?
|
|
140 for (EncodingType type : values()) {
|
|
141 if (type.getId() == id)
|
|
142 return type;
|
|
143 }
|
|
144 throw new IllegalArgumentException("Unsupported encoding id: " + id);
|
|
145 }
|
|
146
|
|
147 }
|