This commit is contained in:
Solly 2015-05-19 15:53:30 +00:00
commit 9f02523a65
7 changed files with 2456 additions and 21 deletions

2409
include/inflator.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -12,19 +12,36 @@ var rfb, mode, test_state, frame_idx, frame_length,
iteration, iterations, istart_time,
// Pre-declarations for jslint
send_array, next_iteration, queue_next_packet, do_packet;
send_array, next_iteration, queue_next_packet, do_packet, enable_test_mode;
// Override send_array
send_array = function (arr) {
// Stub out send_array
};
enable_test_mode = function () {
rfb._sock._mode = VNC_frame_encoding;
rfb._sock.send = send_array;
rfb._sock.close = function () {};
rfb._sock.flush = function () {};
rfb._checkEvents = function () {};
rfb.connect = function (host, port, password, path) {
this._rfb_host = host;
this._rfb_port = port;
this._rfb_password = (password !== undefined) ? password : "";
this._rfb_path = (path !== undefined) ? path : "";
this._updateState('ProtocolVersion', "Starting VNC handshake");
};
};
next_iteration = function () {
rfb = new RFB({'target': $D('VNC_canvas'),
'onUpdateState': updateState});
enable_test_mode();
if (iteration === 0) {
frame_length = VNC_frame_data.length;
test_state = 'running';
} else {
rfb.disconnect();
}
if (test_state !== 'running') { return; }
@ -91,9 +108,9 @@ do_packet = function () {
for (var i = 0; i < frame.length - start; i++) {
u8[i] = frame.charCodeAt(start + i);
}
rfb.recv_message({'data' : u8});
rfb._sock._recv_message({'data' : u8});
} else {
rfb.recv_message({'data' : frame.slice(start)});
rfb._sock._recv_message({'data' : frame.slice(start)});
}
frame_idx += 1;

View File

@ -380,8 +380,9 @@ var RFB;
}
for (i = 0; i < 4; i++) {
this._FBU.zlibs[i] = new TINF();
this._FBU.zlibs[i].init();
//this._FBU.zlibs[i] = new TINF();
//this._FBU.zlibs[i].init();
this._FBU.zlibs[i] = new inflator.Inflate();
}
},
@ -1181,7 +1182,14 @@ var RFB;
this._timing.last_fbu = (new Date()).getTime();
ret = this._encHandlers[this._FBU.encoding]();
var handler = this._encHandlers[this._FBU.encoding];
try {
//ret = this._encHandlers[this._FBU.encoding]();
ret = handler();
} catch (ex) {
console.log("missed " + this._FBU.encoding + ": " + handler);
ret = this._encHandlers[this._FBU.encoding]();
}
now = (new Date()).getTime();
this._timing.cur_fbu += (now - this._timing.last_fbu);
@ -1639,12 +1647,14 @@ var RFB;
}
}
var uncompressed = this._FBU.zlibs[streamId].uncompress(data, 0);
if (uncompressed.status !== 0) {
//var uncompressed = this._FBU.zlibs[streamId].uncompress(data, 0);
var uncompressed = this._FBU.zlibs[streamId].inflate(data, true);
/*if (uncompressed.status !== 0) {
Util.Error("Invalid data in zlib stream");
}
}*/
return uncompressed.data;
//return uncompressed.data;
return uncompressed;
}.bind(this);
var indexedToRGB = function (data, numColors, palette, width, height) {

View File

@ -21,7 +21,7 @@ var UI;
window.onscriptsload = function () { UI.load(); };
Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
"keysymdef.js", "keyboard.js", "input.js", "display.js",
"jsunzip.js", "rfb.js", "keysym.js"]);
"rfb.js", "keysym.js", "inflator.js"]);
UI = {

View File

@ -1,4 +1,4 @@
// requires local modules: util, base64, websock, rfb, keyboard, keysym, keysymdef, input, jsunzip, des, display
// requires local modules: util, base64, websock, rfb, keyboard, keysym, keysymdef, input, inflator, des, display
// requires test modules: fake.websocket, assertions
/* jshint expr: true */
var assert = chai.assert;

View File

@ -59,9 +59,9 @@
if (fname) {
message("Loading " + fname);
// Load supporting scripts
Util.load_scripts(["base64.js", "websock.js", "des.js",
Util.load_scripts(["base64.js", "websock.js", "des.js", "keysym.js",
"keysymdef.js", "keyboard.js", "input.js", "display.js",
"jsunzip.js", "rfb.js", "playback.js", fname]);
"rfb.js", "playback.js", "inflator.js", fname]);
} else {
message("Must specify data=FOO in query string.");
@ -75,7 +75,6 @@
test_state = 'failed';
break;
case 'loaded':
$D('startButton').disabled = false;
break;
}
if (typeof msg !== 'undefined') {
@ -99,7 +98,8 @@
mode = 'realtime';
}
recv_message = rfb.testMode(send_array, VNC_frame_encoding);
//recv_message = rfb.testMode(send_array, VNC_frame_encoding);
next_iteration();
}
@ -130,9 +130,8 @@
}
if (fname) {
message("VNC_frame_data.length: " + VNC_frame_data.length);
rfb = new RFB({'target': $D('VNC_canvas'),
'onUpdateState': updateState});
}
$D('startButton').disabled = false;
}
</script>
</html>

View File

@ -77,7 +77,7 @@
// Load supporting scripts
Util.load_scripts(["webutil.js", "base64.js", "websock.js", "des.js",
"keysymdef.js", "keyboard.js", "input.js", "display.js",
"jsunzip.js", "rfb.js", "keysym.js"]);
"inflator.js", "rfb.js", "keysym.js"]);
var rfb;
var resizeTimeout;