Commit 8a837006 authored by Joel Martin's avatar Joel Martin

More dynamic encoding list handling.

parent c3d28aab
...@@ -56,15 +56,15 @@ RFB = { ...@@ -56,15 +56,15 @@ RFB = {
*/ */
clipboardFocus : false, clipboardFocus : false,
// In preference order
encodings : [ encodings : [
1, // COPYRECT, should always be first ['COPYRECT', 0x01, 'display_copy_rect'],
0x17, // TIGHT_PNG ['TIGHT_PNG', 0x17, 'display_tight_png'],
Math.pow(2,32) - 32, // JPEG quality pseudo-encoding ['HEXTILE', 0x05, 'display_hextile'],
5, // HEXTILE ['RRE', 0x02, 'display_rre'],
2, // RRE ['RAW', 0x00, 'display_raw'],
0 // RAW ['JPEG quality', Math.pow(2,32) - 32, 'set_jpeg_quality'],
], ['DesktopSize', Math.pow(2,32) - 223, 'set_desktopsize'] ],
setUpdateState: function(externalUpdateState) { setUpdateState: function(externalUpdateState) {
RFB.externalUpdateState = externalUpdateState; RFB.externalUpdateState = externalUpdateState;
...@@ -85,6 +85,7 @@ setPassword: function(passwd) { ...@@ -85,6 +85,7 @@ setPassword: function(passwd) {
}, },
load: function () { load: function () {
var i;
//console.log(">> load"); //console.log(">> load");
/* Load web-socket-js if no builtin WebSocket support */ /* Load web-socket-js if no builtin WebSocket support */
...@@ -108,6 +109,13 @@ load: function () { ...@@ -108,6 +109,13 @@ load: function () {
} }
} }
// Populate encoding lookup tables
RFB.encHandlers = {};
RFB.encNames = {};
for (i=0; i < RFB.encodings.length; i++) {
RFB.encHandlers[RFB.encodings[i][1]] = RFB[RFB.encodings[i][2]];
RFB.encNames[RFB.encodings[i][1]] = RFB.encodings[i][0];
}
//console.log("<< load"); //console.log("<< load");
}, },
...@@ -189,6 +197,9 @@ RQ_reorder : [], // Receive Queue re-order list ...@@ -189,6 +197,9 @@ RQ_reorder : [], // Receive Queue re-order list
RQ_seq_num : 0, // Expected sequence number RQ_seq_num : 0, // Expected sequence number
SQ : "", // Send Queue SQ : "", // Send Queue
encHandlers : {},
encNames : {},
// Frame buffer update state // Frame buffer update state
FBU : { FBU : {
rects : 0, rects : 0,
...@@ -495,33 +506,25 @@ normal_msg: function () { ...@@ -495,33 +506,25 @@ normal_msg: function () {
// Debug: // Debug:
/* /*
msg = "FramebufferUpdate rects:" + FBU.rects + if (RFB.encNames[FBU.encoding]) {
" encoding:" + FBU.encoding msg = "FramebufferUpdate rects:" + FBU.rects;
switch (FBU.encoding) { msg += " encoding:" + FBU.encoding;
case 0: msg += "(RAW)"; break; msg += "(" + RFB.encNames[FBU.encoding] + ")";
case 1: msg += "(COPYRECT)"; break; msg += ", RQ.length: " + RQ.length;
case 2: msg += "(RRE)"; break; console.log(msg);
case 5: msg += "(HEXTILE)"; break; } else {
case 7: msg += "(TIGHT_PNG)"; break; RFB.updateState('failed',
default: "Disconnected: unsupported encoding " +
RFB.updateState('failed', FBU.encoding);
"Disconnected: unsupported encoding " + return false;
FBU.encoding);
return false;
} }
msg += ", RQ.length: " + RQ.length
console.log(msg);
*/ */
} }
RFB.timing.last_fbu = (new Date()).getTime(); RFB.timing.last_fbu = (new Date()).getTime();
switch (FBU.encoding) {
case 0: ret = RFB.display_raw(); break; // Raw ret = RFB.encHandlers[FBU.encoding]();
case 1: ret = RFB.display_copy_rect(); break; // CopyRect
case 2: ret = RFB.display_rre(); break; // RRE
case 5: ret = RFB.display_hextile(); break; // hextile
case 7: ret = RFB.display_tight_png(); break; // tight_png
}
now = (new Date()).getTime(); now = (new Date()).getTime();
RFB.timing.cur_fbu += (now - RFB.timing.last_fbu); RFB.timing.cur_fbu += (now - RFB.timing.last_fbu);
if (FBU.rects === 0) { if (FBU.rects === 0) {
...@@ -970,7 +973,7 @@ clientEncodings: function () { ...@@ -970,7 +973,7 @@ clientEncodings: function () {
arr.push16(RFB.encodings.length); // encoding count arr.push16(RFB.encodings.length); // encoding count
for (i=0; i<RFB.encodings.length; i++) { for (i=0; i<RFB.encodings.length; i++) {
arr.push32(RFB.encodings[i]); arr.push32(RFB.encodings[i][1]);
} }
console.log("<< setEncodings: " + arr); console.log("<< setEncodings: " + arr);
return arr; return arr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment