@novnc/novnc 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/base64.js +104 -0
- package/core/crypto/aes.js +178 -0
- package/core/crypto/bigint.js +34 -0
- package/core/crypto/crypto.js +90 -0
- package/core/crypto/des.js +330 -0
- package/core/crypto/dh.js +55 -0
- package/core/crypto/md5.js +82 -0
- package/core/crypto/rsa.js +132 -0
- package/core/decoders/copyrect.js +27 -0
- package/core/decoders/h264.js +321 -0
- package/core/decoders/hextile.js +181 -0
- package/core/decoders/jpeg.js +161 -0
- package/core/decoders/raw.js +59 -0
- package/core/decoders/rre.js +44 -0
- package/core/decoders/tight.js +393 -0
- package/core/decoders/tightpng.js +27 -0
- package/core/decoders/zlib.js +51 -0
- package/core/decoders/zrle.js +185 -0
- package/core/deflator.js +84 -0
- package/core/display.js +578 -0
- package/core/encodings.js +54 -0
- package/core/inflator.js +65 -0
- package/core/input/domkeytable.js +311 -0
- package/core/input/fixedkeys.js +129 -0
- package/core/input/gesturehandler.js +567 -0
- package/core/input/keyboard.js +294 -0
- package/core/input/keysym.js +616 -0
- package/core/input/keysymdef.js +688 -0
- package/core/input/util.js +191 -0
- package/core/input/vkeys.js +116 -0
- package/core/input/xtscancodes.js +173 -0
- package/core/ra2.js +312 -0
- package/core/rfb.js +3411 -0
- package/core/util/browser.js +233 -0
- package/core/util/cursor.js +249 -0
- package/core/util/element.js +32 -0
- package/core/util/events.js +138 -0
- package/core/util/eventtarget.js +35 -0
- package/core/util/int.js +15 -0
- package/core/util/logging.js +56 -0
- package/core/util/strings.js +28 -0
- package/core/websock.js +369 -0
- package/docs/API.md +0 -5
- package/package.json +6 -10
- package/vendor/pako/LICENSE +21 -0
- package/vendor/pako/README.md +6 -0
- package/{lib/vendor → vendor}/pako/lib/utils/common.js +13 -23
- package/{lib/vendor → vendor}/pako/lib/zlib/adler32.js +12 -14
- package/vendor/pako/lib/zlib/constants.js +47 -0
- package/{lib/vendor → vendor}/pako/lib/zlib/crc32.js +15 -14
- package/{lib/vendor → vendor}/pako/lib/zlib/deflate.js +459 -334
- package/{lib/vendor → vendor}/pako/lib/zlib/gzheader.js +13 -19
- package/{lib/vendor → vendor}/pako/lib/zlib/inffast.js +116 -119
- package/vendor/pako/lib/zlib/inflate.js +1527 -0
- package/{lib/vendor → vendor}/pako/lib/zlib/inftrees.js +103 -91
- package/vendor/pako/lib/zlib/messages.js +11 -0
- package/{lib/vendor → vendor}/pako/lib/zlib/trees.js +313 -268
- package/{lib/vendor → vendor}/pako/lib/zlib/zstream.js +4 -10
- package/lib/base64.js +0 -100
- package/lib/crypto/aes.js +0 -481
- package/lib/crypto/bigint.js +0 -41
- package/lib/crypto/crypto.js +0 -109
- package/lib/crypto/des.js +0 -374
- package/lib/crypto/dh.js +0 -81
- package/lib/crypto/md5.js +0 -97
- package/lib/crypto/rsa.js +0 -312
- package/lib/decoders/copyrect.js +0 -40
- package/lib/decoders/h264.js +0 -349
- package/lib/decoders/hextile.js +0 -195
- package/lib/decoders/jpeg.js +0 -175
- package/lib/decoders/raw.js +0 -66
- package/lib/decoders/rre.js +0 -52
- package/lib/decoders/tight.js +0 -363
- package/lib/decoders/tightpng.js +0 -51
- package/lib/decoders/zlib.js +0 -57
- package/lib/decoders/zrle.js +0 -192
- package/lib/deflator.js +0 -88
- package/lib/display.js +0 -588
- package/lib/encodings.js +0 -70
- package/lib/inflator.js +0 -77
- package/lib/input/domkeytable.js +0 -313
- package/lib/input/fixedkeys.js +0 -127
- package/lib/input/gesturehandler.js +0 -573
- package/lib/input/keyboard.js +0 -293
- package/lib/input/keysym.js +0 -878
- package/lib/input/keysymdef.js +0 -1351
- package/lib/input/util.js +0 -217
- package/lib/input/vkeys.js +0 -121
- package/lib/input/xtscancodes.js +0 -343
- package/lib/ra2.js +0 -535
- package/lib/rfb.js +0 -3398
- package/lib/util/browser.js +0 -239
- package/lib/util/cursor.js +0 -269
- package/lib/util/element.js +0 -41
- package/lib/util/events.js +0 -133
- package/lib/util/eventtarget.js +0 -53
- package/lib/util/int.js +0 -21
- package/lib/util/logging.js +0 -56
- package/lib/util/strings.js +0 -36
- package/lib/vendor/pako/lib/zlib/constants.js +0 -47
- package/lib/vendor/pako/lib/zlib/inflate.js +0 -1602
- package/lib/vendor/pako/lib/zlib/messages.js +0 -25
- package/lib/websock.js +0 -395
package/lib/decoders/h264.js
DELETED
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.H264Parser = exports.H264Context = void 0;
|
|
7
|
-
var Log = _interopRequireWildcard(require("../util/logging.js"));
|
|
8
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
10
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
12
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
18
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
19
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
20
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
21
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
22
|
-
* noVNC: HTML5 VNC client
|
|
23
|
-
* Copyright (C) 2024 The noVNC authors
|
|
24
|
-
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
25
|
-
*
|
|
26
|
-
* See README.md for usage and integration instructions.
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
var H264Parser = exports.H264Parser = /*#__PURE__*/function () {
|
|
30
|
-
function H264Parser(data) {
|
|
31
|
-
_classCallCheck(this, H264Parser);
|
|
32
|
-
this._data = data;
|
|
33
|
-
this._index = 0;
|
|
34
|
-
this.profileIdc = null;
|
|
35
|
-
this.constraintSet = null;
|
|
36
|
-
this.levelIdc = null;
|
|
37
|
-
}
|
|
38
|
-
return _createClass(H264Parser, [{
|
|
39
|
-
key: "_getStartSequenceLen",
|
|
40
|
-
value: function _getStartSequenceLen(index) {
|
|
41
|
-
var data = this._data;
|
|
42
|
-
if (data[index + 0] == 0 && data[index + 1] == 0 && data[index + 2] == 0 && data[index + 3] == 1) {
|
|
43
|
-
return 4;
|
|
44
|
-
}
|
|
45
|
-
if (data[index + 0] == 0 && data[index + 1] == 0 && data[index + 2] == 1) {
|
|
46
|
-
return 3;
|
|
47
|
-
}
|
|
48
|
-
return 0;
|
|
49
|
-
}
|
|
50
|
-
}, {
|
|
51
|
-
key: "_indexOfNextNalUnit",
|
|
52
|
-
value: function _indexOfNextNalUnit(index) {
|
|
53
|
-
var data = this._data;
|
|
54
|
-
for (var i = index; i < data.length; ++i) {
|
|
55
|
-
if (this._getStartSequenceLen(i) != 0) {
|
|
56
|
-
return i;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return -1;
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "_parseSps",
|
|
63
|
-
value: function _parseSps(index) {
|
|
64
|
-
this.profileIdc = this._data[index];
|
|
65
|
-
this.constraintSet = this._data[index + 1];
|
|
66
|
-
this.levelIdc = this._data[index + 2];
|
|
67
|
-
}
|
|
68
|
-
}, {
|
|
69
|
-
key: "_parseNalUnit",
|
|
70
|
-
value: function _parseNalUnit(index) {
|
|
71
|
-
var firstByte = this._data[index];
|
|
72
|
-
if (firstByte & 0x80) {
|
|
73
|
-
throw new Error('H264 parsing sanity check failed, forbidden zero bit is set');
|
|
74
|
-
}
|
|
75
|
-
var unitType = firstByte & 0x1f;
|
|
76
|
-
switch (unitType) {
|
|
77
|
-
case 1:
|
|
78
|
-
// coded slice, non-idr
|
|
79
|
-
return {
|
|
80
|
-
slice: true
|
|
81
|
-
};
|
|
82
|
-
case 5:
|
|
83
|
-
// coded slice, idr
|
|
84
|
-
return {
|
|
85
|
-
slice: true,
|
|
86
|
-
key: true
|
|
87
|
-
};
|
|
88
|
-
case 6:
|
|
89
|
-
// sei
|
|
90
|
-
return {};
|
|
91
|
-
case 7:
|
|
92
|
-
// sps
|
|
93
|
-
this._parseSps(index + 1);
|
|
94
|
-
return {};
|
|
95
|
-
case 8:
|
|
96
|
-
// pps
|
|
97
|
-
return {};
|
|
98
|
-
default:
|
|
99
|
-
Log.Warn("Unhandled unit type: ", unitType);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
return {};
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "parse",
|
|
106
|
-
value: function parse() {
|
|
107
|
-
var startIndex = this._index;
|
|
108
|
-
var isKey = false;
|
|
109
|
-
while (this._index < this._data.length) {
|
|
110
|
-
var startSequenceLen = this._getStartSequenceLen(this._index);
|
|
111
|
-
if (startSequenceLen == 0) {
|
|
112
|
-
throw new Error('Invalid start sequence in bit stream');
|
|
113
|
-
}
|
|
114
|
-
var _this$_parseNalUnit = this._parseNalUnit(this._index + startSequenceLen),
|
|
115
|
-
slice = _this$_parseNalUnit.slice,
|
|
116
|
-
key = _this$_parseNalUnit.key;
|
|
117
|
-
var nextIndex = this._indexOfNextNalUnit(this._index + startSequenceLen);
|
|
118
|
-
if (nextIndex == -1) {
|
|
119
|
-
this._index = this._data.length;
|
|
120
|
-
} else {
|
|
121
|
-
this._index = nextIndex;
|
|
122
|
-
}
|
|
123
|
-
if (key) {
|
|
124
|
-
isKey = true;
|
|
125
|
-
}
|
|
126
|
-
if (slice) {
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
if (startIndex === this._index) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
return {
|
|
134
|
-
frame: this._data.subarray(startIndex, this._index),
|
|
135
|
-
key: isKey
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
}]);
|
|
139
|
-
}();
|
|
140
|
-
var H264Context = exports.H264Context = /*#__PURE__*/function () {
|
|
141
|
-
function H264Context(width, height) {
|
|
142
|
-
_classCallCheck(this, H264Context);
|
|
143
|
-
this.lastUsed = 0;
|
|
144
|
-
this._width = width;
|
|
145
|
-
this._height = height;
|
|
146
|
-
this._profileIdc = null;
|
|
147
|
-
this._constraintSet = null;
|
|
148
|
-
this._levelIdc = null;
|
|
149
|
-
this._decoder = null;
|
|
150
|
-
this._pendingFrames = [];
|
|
151
|
-
}
|
|
152
|
-
return _createClass(H264Context, [{
|
|
153
|
-
key: "_handleFrame",
|
|
154
|
-
value: function _handleFrame(frame) {
|
|
155
|
-
var pending = this._pendingFrames.shift();
|
|
156
|
-
if (pending === undefined) {
|
|
157
|
-
throw new Error("Pending frame queue empty when receiving frame from decoder");
|
|
158
|
-
}
|
|
159
|
-
if (pending.timestamp != frame.timestamp) {
|
|
160
|
-
throw new Error("Video frame timestamp mismatch. Expected " + frame.timestamp + " but but got " + pending.timestamp);
|
|
161
|
-
}
|
|
162
|
-
pending.frame = frame;
|
|
163
|
-
pending.ready = true;
|
|
164
|
-
pending.resolve();
|
|
165
|
-
if (!pending.keep) {
|
|
166
|
-
frame.close();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
key: "_handleError",
|
|
171
|
-
value: function _handleError(e) {
|
|
172
|
-
throw new Error("Failed to decode frame: " + e.message);
|
|
173
|
-
}
|
|
174
|
-
}, {
|
|
175
|
-
key: "_configureDecoder",
|
|
176
|
-
value: function _configureDecoder(profileIdc, constraintSet, levelIdc) {
|
|
177
|
-
var _this = this;
|
|
178
|
-
if (this._decoder === null || this._decoder.state === 'closed') {
|
|
179
|
-
this._decoder = new VideoDecoder({
|
|
180
|
-
output: function output(frame) {
|
|
181
|
-
return _this._handleFrame(frame);
|
|
182
|
-
},
|
|
183
|
-
error: function error(e) {
|
|
184
|
-
return _this._handleError(e);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
var codec = 'avc1.' + profileIdc.toString(16).padStart(2, '0') + constraintSet.toString(16).padStart(2, '0') + levelIdc.toString(16).padStart(2, '0');
|
|
189
|
-
this._decoder.configure({
|
|
190
|
-
codec: codec,
|
|
191
|
-
codedWidth: this._width,
|
|
192
|
-
codedHeight: this._height,
|
|
193
|
-
optimizeForLatency: true
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
|
-
key: "_preparePendingFrame",
|
|
198
|
-
value: function _preparePendingFrame(timestamp) {
|
|
199
|
-
var pending = {
|
|
200
|
-
timestamp: timestamp,
|
|
201
|
-
promise: null,
|
|
202
|
-
resolve: null,
|
|
203
|
-
frame: null,
|
|
204
|
-
ready: false,
|
|
205
|
-
keep: false
|
|
206
|
-
};
|
|
207
|
-
pending.promise = new Promise(function (resolve) {
|
|
208
|
-
pending.resolve = resolve;
|
|
209
|
-
});
|
|
210
|
-
this._pendingFrames.push(pending);
|
|
211
|
-
return pending;
|
|
212
|
-
}
|
|
213
|
-
}, {
|
|
214
|
-
key: "decode",
|
|
215
|
-
value: function decode(payload) {
|
|
216
|
-
var parser = new H264Parser(payload);
|
|
217
|
-
var result = null;
|
|
218
|
-
|
|
219
|
-
// Ideally, this timestamp should come from the server, but we'll just
|
|
220
|
-
// approximate it instead.
|
|
221
|
-
var timestamp = Math.round(window.performance.now() * 1e3);
|
|
222
|
-
while (true) {
|
|
223
|
-
var encodedFrame = parser.parse();
|
|
224
|
-
if (encodedFrame === null) {
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
if (parser.profileIdc !== null) {
|
|
228
|
-
self._profileIdc = parser.profileIdc;
|
|
229
|
-
self._constraintSet = parser.constraintSet;
|
|
230
|
-
self._levelIdc = parser.levelIdc;
|
|
231
|
-
}
|
|
232
|
-
if (this._decoder === null || this._decoder.state !== 'configured') {
|
|
233
|
-
if (!encodedFrame.key) {
|
|
234
|
-
Log.Warn("Missing key frame. Can't decode until one arrives");
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
if (self._profileIdc === null) {
|
|
238
|
-
Log.Warn('Cannot config decoder. Have not received SPS and PPS yet.');
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
this._configureDecoder(self._profileIdc, self._constraintSet, self._levelIdc);
|
|
242
|
-
}
|
|
243
|
-
result = this._preparePendingFrame(timestamp);
|
|
244
|
-
var chunk = new EncodedVideoChunk({
|
|
245
|
-
timestamp: timestamp,
|
|
246
|
-
type: encodedFrame.key ? 'key' : 'delta',
|
|
247
|
-
data: encodedFrame.frame
|
|
248
|
-
});
|
|
249
|
-
try {
|
|
250
|
-
this._decoder.decode(chunk);
|
|
251
|
-
} catch (e) {
|
|
252
|
-
Log.Warn("Failed to decode:", e);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// We only keep last frame of each payload
|
|
257
|
-
if (result !== null) {
|
|
258
|
-
result.keep = true;
|
|
259
|
-
}
|
|
260
|
-
return result;
|
|
261
|
-
}
|
|
262
|
-
}]);
|
|
263
|
-
}();
|
|
264
|
-
var H264Decoder = exports["default"] = /*#__PURE__*/function () {
|
|
265
|
-
function H264Decoder() {
|
|
266
|
-
_classCallCheck(this, H264Decoder);
|
|
267
|
-
this._tick = 0;
|
|
268
|
-
this._contexts = {};
|
|
269
|
-
}
|
|
270
|
-
return _createClass(H264Decoder, [{
|
|
271
|
-
key: "_contextId",
|
|
272
|
-
value: function _contextId(x, y, width, height) {
|
|
273
|
-
return [x, y, width, height].join(',');
|
|
274
|
-
}
|
|
275
|
-
}, {
|
|
276
|
-
key: "_findOldestContextId",
|
|
277
|
-
value: function _findOldestContextId() {
|
|
278
|
-
var oldestTick = Number.MAX_VALUE;
|
|
279
|
-
var oldestKey = undefined;
|
|
280
|
-
for (var _i = 0, _Object$entries = Object.entries(this._contexts); _i < _Object$entries.length; _i++) {
|
|
281
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
282
|
-
key = _Object$entries$_i[0],
|
|
283
|
-
value = _Object$entries$_i[1];
|
|
284
|
-
if (value.lastUsed < oldestTick) {
|
|
285
|
-
oldestTick = value.lastUsed;
|
|
286
|
-
oldestKey = key;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return oldestKey;
|
|
290
|
-
}
|
|
291
|
-
}, {
|
|
292
|
-
key: "_createContext",
|
|
293
|
-
value: function _createContext(x, y, width, height) {
|
|
294
|
-
var maxContexts = 64;
|
|
295
|
-
if (Object.keys(this._contexts).length >= maxContexts) {
|
|
296
|
-
var oldestContextId = this._findOldestContextId();
|
|
297
|
-
delete this._contexts[oldestContextId];
|
|
298
|
-
}
|
|
299
|
-
var context = new H264Context(width, height);
|
|
300
|
-
this._contexts[this._contextId(x, y, width, height)] = context;
|
|
301
|
-
return context;
|
|
302
|
-
}
|
|
303
|
-
}, {
|
|
304
|
-
key: "_getContext",
|
|
305
|
-
value: function _getContext(x, y, width, height) {
|
|
306
|
-
var context = this._contexts[this._contextId(x, y, width, height)];
|
|
307
|
-
return context !== undefined ? context : this._createContext(x, y, width, height);
|
|
308
|
-
}
|
|
309
|
-
}, {
|
|
310
|
-
key: "_resetContext",
|
|
311
|
-
value: function _resetContext(x, y, width, height) {
|
|
312
|
-
delete this._contexts[this._contextId(x, y, width, height)];
|
|
313
|
-
}
|
|
314
|
-
}, {
|
|
315
|
-
key: "_resetAllContexts",
|
|
316
|
-
value: function _resetAllContexts() {
|
|
317
|
-
this._contexts = {};
|
|
318
|
-
}
|
|
319
|
-
}, {
|
|
320
|
-
key: "decodeRect",
|
|
321
|
-
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
322
|
-
var resetContextFlag = 1;
|
|
323
|
-
var resetAllContextsFlag = 2;
|
|
324
|
-
if (sock.rQwait("h264 header", 8)) {
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
var length = sock.rQshift32();
|
|
328
|
-
var flags = sock.rQshift32();
|
|
329
|
-
if (sock.rQwait("h264 payload", length, 8)) {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
if (flags & resetAllContextsFlag) {
|
|
333
|
-
this._resetAllContexts();
|
|
334
|
-
} else if (flags & resetContextFlag) {
|
|
335
|
-
this._resetContext(x, y, width, height);
|
|
336
|
-
}
|
|
337
|
-
var context = this._getContext(x, y, width, height);
|
|
338
|
-
context.lastUsed = this._tick++;
|
|
339
|
-
if (length !== 0) {
|
|
340
|
-
var payload = sock.rQshiftBytes(length, false);
|
|
341
|
-
var frame = context.decode(payload);
|
|
342
|
-
if (frame !== null) {
|
|
343
|
-
display.videoFrame(x, y, width, height, frame);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return true;
|
|
347
|
-
}
|
|
348
|
-
}]);
|
|
349
|
-
}();
|
package/lib/decoders/hextile.js
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var Log = _interopRequireWildcard(require("../util/logging.js"));
|
|
8
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
10
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
12
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
13
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /*
|
|
16
|
-
* noVNC: HTML5 VNC client
|
|
17
|
-
* Copyright (C) 2019 The noVNC authors
|
|
18
|
-
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
19
|
-
*
|
|
20
|
-
* See README.md for usage and integration instructions.
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
var HextileDecoder = exports["default"] = /*#__PURE__*/function () {
|
|
24
|
-
function HextileDecoder() {
|
|
25
|
-
_classCallCheck(this, HextileDecoder);
|
|
26
|
-
this._tiles = 0;
|
|
27
|
-
this._lastsubencoding = 0;
|
|
28
|
-
this._tileBuffer = new Uint8Array(16 * 16 * 4);
|
|
29
|
-
}
|
|
30
|
-
return _createClass(HextileDecoder, [{
|
|
31
|
-
key: "decodeRect",
|
|
32
|
-
value: function decodeRect(x, y, width, height, sock, display, depth) {
|
|
33
|
-
if (this._tiles === 0) {
|
|
34
|
-
this._tilesX = Math.ceil(width / 16);
|
|
35
|
-
this._tilesY = Math.ceil(height / 16);
|
|
36
|
-
this._totalTiles = this._tilesX * this._tilesY;
|
|
37
|
-
this._tiles = this._totalTiles;
|
|
38
|
-
}
|
|
39
|
-
while (this._tiles > 0) {
|
|
40
|
-
var bytes = 1;
|
|
41
|
-
if (sock.rQwait("HEXTILE", bytes)) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
var subencoding = sock.rQpeek8();
|
|
45
|
-
if (subencoding > 30) {
|
|
46
|
-
// Raw
|
|
47
|
-
throw new Error("Illegal hextile subencoding (subencoding: " + subencoding + ")");
|
|
48
|
-
}
|
|
49
|
-
var currTile = this._totalTiles - this._tiles;
|
|
50
|
-
var tileX = currTile % this._tilesX;
|
|
51
|
-
var tileY = Math.floor(currTile / this._tilesX);
|
|
52
|
-
var tx = x + tileX * 16;
|
|
53
|
-
var ty = y + tileY * 16;
|
|
54
|
-
var tw = Math.min(16, x + width - tx);
|
|
55
|
-
var th = Math.min(16, y + height - ty);
|
|
56
|
-
|
|
57
|
-
// Figure out how much we are expecting
|
|
58
|
-
if (subencoding & 0x01) {
|
|
59
|
-
// Raw
|
|
60
|
-
bytes += tw * th * 4;
|
|
61
|
-
} else {
|
|
62
|
-
if (subencoding & 0x02) {
|
|
63
|
-
// Background
|
|
64
|
-
bytes += 4;
|
|
65
|
-
}
|
|
66
|
-
if (subencoding & 0x04) {
|
|
67
|
-
// Foreground
|
|
68
|
-
bytes += 4;
|
|
69
|
-
}
|
|
70
|
-
if (subencoding & 0x08) {
|
|
71
|
-
// AnySubrects
|
|
72
|
-
bytes++; // Since we aren't shifting it off
|
|
73
|
-
|
|
74
|
-
if (sock.rQwait("HEXTILE", bytes)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
var subrects = sock.rQpeekBytes(bytes).at(-1);
|
|
78
|
-
if (subencoding & 0x10) {
|
|
79
|
-
// SubrectsColoured
|
|
80
|
-
bytes += subrects * (4 + 2);
|
|
81
|
-
} else {
|
|
82
|
-
bytes += subrects * 2;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (sock.rQwait("HEXTILE", bytes)) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// We know the encoding and have a whole tile
|
|
91
|
-
sock.rQshift8();
|
|
92
|
-
if (subencoding === 0) {
|
|
93
|
-
if (this._lastsubencoding & 0x01) {
|
|
94
|
-
// Weird: ignore blanks are RAW
|
|
95
|
-
Log.Debug(" Ignoring blank after RAW");
|
|
96
|
-
} else {
|
|
97
|
-
display.fillRect(tx, ty, tw, th, this._background);
|
|
98
|
-
}
|
|
99
|
-
} else if (subencoding & 0x01) {
|
|
100
|
-
// Raw
|
|
101
|
-
var pixels = tw * th;
|
|
102
|
-
var data = sock.rQshiftBytes(pixels * 4, false);
|
|
103
|
-
// Max sure the image is fully opaque
|
|
104
|
-
for (var i = 0; i < pixels; i++) {
|
|
105
|
-
data[i * 4 + 3] = 255;
|
|
106
|
-
}
|
|
107
|
-
display.blitImage(tx, ty, tw, th, data, 0);
|
|
108
|
-
} else {
|
|
109
|
-
if (subencoding & 0x02) {
|
|
110
|
-
// Background
|
|
111
|
-
this._background = new Uint8Array(sock.rQshiftBytes(4));
|
|
112
|
-
}
|
|
113
|
-
if (subencoding & 0x04) {
|
|
114
|
-
// Foreground
|
|
115
|
-
this._foreground = new Uint8Array(sock.rQshiftBytes(4));
|
|
116
|
-
}
|
|
117
|
-
this._startTile(tx, ty, tw, th, this._background);
|
|
118
|
-
if (subencoding & 0x08) {
|
|
119
|
-
// AnySubrects
|
|
120
|
-
var _subrects = sock.rQshift8();
|
|
121
|
-
for (var s = 0; s < _subrects; s++) {
|
|
122
|
-
var color = void 0;
|
|
123
|
-
if (subencoding & 0x10) {
|
|
124
|
-
// SubrectsColoured
|
|
125
|
-
color = sock.rQshiftBytes(4);
|
|
126
|
-
} else {
|
|
127
|
-
color = this._foreground;
|
|
128
|
-
}
|
|
129
|
-
var xy = sock.rQshift8();
|
|
130
|
-
var sx = xy >> 4;
|
|
131
|
-
var sy = xy & 0x0f;
|
|
132
|
-
var wh = sock.rQshift8();
|
|
133
|
-
var sw = (wh >> 4) + 1;
|
|
134
|
-
var sh = (wh & 0x0f) + 1;
|
|
135
|
-
this._subTile(sx, sy, sw, sh, color);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
this._finishTile(display);
|
|
139
|
-
}
|
|
140
|
-
this._lastsubencoding = subencoding;
|
|
141
|
-
this._tiles--;
|
|
142
|
-
}
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// start updating a tile
|
|
147
|
-
}, {
|
|
148
|
-
key: "_startTile",
|
|
149
|
-
value: function _startTile(x, y, width, height, color) {
|
|
150
|
-
this._tileX = x;
|
|
151
|
-
this._tileY = y;
|
|
152
|
-
this._tileW = width;
|
|
153
|
-
this._tileH = height;
|
|
154
|
-
var red = color[0];
|
|
155
|
-
var green = color[1];
|
|
156
|
-
var blue = color[2];
|
|
157
|
-
var data = this._tileBuffer;
|
|
158
|
-
for (var i = 0; i < width * height * 4; i += 4) {
|
|
159
|
-
data[i] = red;
|
|
160
|
-
data[i + 1] = green;
|
|
161
|
-
data[i + 2] = blue;
|
|
162
|
-
data[i + 3] = 255;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// update sub-rectangle of the current tile
|
|
167
|
-
}, {
|
|
168
|
-
key: "_subTile",
|
|
169
|
-
value: function _subTile(x, y, w, h, color) {
|
|
170
|
-
var red = color[0];
|
|
171
|
-
var green = color[1];
|
|
172
|
-
var blue = color[2];
|
|
173
|
-
var xend = x + w;
|
|
174
|
-
var yend = y + h;
|
|
175
|
-
var data = this._tileBuffer;
|
|
176
|
-
var width = this._tileW;
|
|
177
|
-
for (var j = y; j < yend; j++) {
|
|
178
|
-
for (var i = x; i < xend; i++) {
|
|
179
|
-
var p = (i + j * width) * 4;
|
|
180
|
-
data[p] = red;
|
|
181
|
-
data[p + 1] = green;
|
|
182
|
-
data[p + 2] = blue;
|
|
183
|
-
data[p + 3] = 255;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// draw the current tile to the screen
|
|
189
|
-
}, {
|
|
190
|
-
key: "_finishTile",
|
|
191
|
-
value: function _finishTile(display) {
|
|
192
|
-
display.blitImage(this._tileX, this._tileY, this._tileW, this._tileH, this._tileBuffer, 0);
|
|
193
|
-
}
|
|
194
|
-
}]);
|
|
195
|
-
}();
|