Merge pull request #677 from CendioOssman/perf
Support older base64 recordings
This commit is contained in:
commit
a2495799af
|
@ -9,7 +9,7 @@
|
||||||
/*global Util, VNC_frame_data, finish */
|
/*global Util, VNC_frame_data, finish */
|
||||||
|
|
||||||
var rfb, mode, test_state, frame_idx, frame_length,
|
var rfb, mode, test_state, frame_idx, frame_length,
|
||||||
iteration, iterations, istart_time,
|
iteration, iterations, istart_time, encoding,
|
||||||
|
|
||||||
// Pre-declarations for jslint
|
// Pre-declarations for jslint
|
||||||
send_array, next_iteration, queue_next_packet, do_packet, enable_test_mode;
|
send_array, next_iteration, queue_next_packet, do_packet, enable_test_mode;
|
||||||
|
@ -20,7 +20,6 @@ send_array = function (arr) {
|
||||||
};
|
};
|
||||||
|
|
||||||
enable_test_mode = function () {
|
enable_test_mode = function () {
|
||||||
rfb._sock._mode = VNC_frame_encoding;
|
|
||||||
rfb._sock.send = send_array;
|
rfb._sock.send = send_array;
|
||||||
rfb._sock.close = function () {};
|
rfb._sock.close = function () {};
|
||||||
rfb._sock.flush = function () {};
|
rfb._sock.flush = function () {};
|
||||||
|
@ -40,6 +39,19 @@ next_iteration = function () {
|
||||||
'onUpdateState': updateState});
|
'onUpdateState': updateState});
|
||||||
enable_test_mode();
|
enable_test_mode();
|
||||||
|
|
||||||
|
// Missing in older recordings
|
||||||
|
if (typeof VNC_frame_encoding === 'undefined') {
|
||||||
|
var frame = VNC_frame_data[0];
|
||||||
|
var start = frame.indexOf('{', 1) + 1;
|
||||||
|
if (frame.slice(start).startsWith('UkZC')) {
|
||||||
|
encoding = 'base64';
|
||||||
|
} else {
|
||||||
|
encoding = 'binary';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
encoding = VNC_frame_encoding;
|
||||||
|
}
|
||||||
|
|
||||||
if (iteration === 0) {
|
if (iteration === 0) {
|
||||||
frame_length = VNC_frame_data.length;
|
frame_length = VNC_frame_data.length;
|
||||||
test_state = 'running';
|
test_state = 'running';
|
||||||
|
@ -93,7 +105,7 @@ queue_next_packet = function () {
|
||||||
|
|
||||||
setTimeout(do_packet, delay);
|
setTimeout(do_packet, delay);
|
||||||
} else {
|
} else {
|
||||||
setTimeout(do_packet, 1);
|
setTimeout(do_packet, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,16 +115,18 @@ do_packet = function () {
|
||||||
//Util.Debug("Processing frame: " + frame_idx);
|
//Util.Debug("Processing frame: " + frame_idx);
|
||||||
var frame = VNC_frame_data[frame_idx],
|
var frame = VNC_frame_data[frame_idx],
|
||||||
start = frame.indexOf('{', 1) + 1;
|
start = frame.indexOf('{', 1) + 1;
|
||||||
bytes_processed += frame.length - start;
|
var u8;
|
||||||
if (VNC_frame_encoding === 'binary') {
|
if (encoding === 'base64') {
|
||||||
var u8 = new Uint8Array(frame.length - start);
|
u8 = Base64.decode(frame.slice(start));
|
||||||
|
start = 0;
|
||||||
|
} else {
|
||||||
|
u8 = new Uint8Array(frame.length - start);
|
||||||
for (var i = 0; i < frame.length - start; i++) {
|
for (var i = 0; i < frame.length - start; i++) {
|
||||||
u8[i] = frame.charCodeAt(start + i);
|
u8[i] = frame.charCodeAt(start + i);
|
||||||
}
|
}
|
||||||
rfb._sock._recv_message({'data' : u8});
|
|
||||||
} else {
|
|
||||||
rfb._sock._recv_message({'data' : frame.slice(start)});
|
|
||||||
}
|
}
|
||||||
|
bytes_processed += u8.length;
|
||||||
|
rfb._sock._recv_message({'data' : u8});
|
||||||
frame_idx += 1;
|
frame_idx += 1;
|
||||||
|
|
||||||
queue_next_packet();
|
queue_next_packet();
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var INCLUDE_URI= "../";
|
var INCLUDE_URI= "../";
|
||||||
// TODO: Data file should override
|
|
||||||
var VNC_frame_encoding = "binary";
|
|
||||||
</script>
|
</script>
|
||||||
<script src="../core/util.js"></script>
|
<script src="../core/util.js"></script>
|
||||||
<script src="../app/webutil.js"></script>
|
<script src="../app/webutil.js"></script>
|
||||||
|
|
|
@ -39,8 +39,6 @@
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var INCLUDE_URI= "../";
|
var INCLUDE_URI= "../";
|
||||||
// TODO: Data file should override
|
|
||||||
var VNC_frame_encoding = "binary";
|
|
||||||
</script>
|
</script>
|
||||||
<script src="../core/util.js"></script>
|
<script src="../core/util.js"></script>
|
||||||
<script src="../app/webutil.js"></script>
|
<script src="../app/webutil.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue