Commit 4b4496ad authored by Joel Martin's avatar Joel Martin

DesktopResize and compression level pseudo-encodings.

- Implement resizing of desktop pseudo-encoding.

- Also send lowest (fastest) compression level pseudo-encoding.
  Ought be user tweakable.
parent 8a837006
...@@ -102,8 +102,7 @@ init: function (id, width, height, true_color, keyDown, keyUp, ...@@ -102,8 +102,7 @@ init: function (id, width, height, true_color, keyDown, keyUp,
document.addEvent('click', Canvas.ctxDisable); document.addEvent('click', Canvas.ctxDisable);
document.body.addEvent('contextmenu', Canvas.ctxDisable); document.body.addEvent('contextmenu', Canvas.ctxDisable);
c.width = width; Canvas.resize(width, height);
c.height = height;
Canvas.c_x = c.getPosition().x; Canvas.c_x = c.getPosition().x;
Canvas.c_y = c.getPosition().y; Canvas.c_y = c.getPosition().y;
Canvas.c_wx = c.getSize().x; Canvas.c_wx = c.getSize().x;
...@@ -125,9 +124,13 @@ init: function (id, width, height, true_color, keyDown, keyUp, ...@@ -125,9 +124,13 @@ init: function (id, width, height, true_color, keyDown, keyUp,
clear: function () { clear: function () {
Canvas.ctx.clearRect(0, 0, Canvas.c_wx, Canvas.c_wy); Canvas.ctx.clearRect(0, 0, Canvas.c_wx, Canvas.c_wy);
Canvas.resize(640, 20);
},
resize: function (width, height) {
var c = $(Canvas.id); var c = $(Canvas.id);
c.width = 640; c.width = width;
c.height = 20; c.height = height;
}, },
stop: function () { stop: function () {
......
...@@ -63,8 +63,14 @@ encodings : [ ...@@ -63,8 +63,14 @@ encodings : [
['HEXTILE', 0x05, 'display_hextile'], ['HEXTILE', 0x05, 'display_hextile'],
['RRE', 0x02, 'display_rre'], ['RRE', 0x02, 'display_rre'],
['RAW', 0x00, 'display_raw'], ['RAW', 0x00, 'display_raw'],
['JPEG quality', Math.pow(2,32) - 32, 'set_jpeg_quality'], ['DesktopSize', -223, 'set_desktopsize'],
['DesktopSize', Math.pow(2,32) - 223, 'set_desktopsize'] ],
// Psuedo-encoding settings
['JPEG_quality_lo', -32, 'set_jpeg_quality'],
// ['JPEG_quality_hi', -23, 'set_jpeg_quality'],
['compress_lo', -255, 'set_compress_level']
// ['compress_hi', -247, 'set_compress_level']
],
setUpdateState: function(externalUpdateState) { setUpdateState: function(externalUpdateState) {
RFB.externalUpdateState = externalUpdateState; RFB.externalUpdateState = externalUpdateState;
...@@ -116,6 +122,8 @@ load: function () { ...@@ -116,6 +122,8 @@ load: function () {
RFB.encHandlers[RFB.encodings[i][1]] = RFB[RFB.encodings[i][2]]; RFB.encHandlers[RFB.encodings[i][1]] = RFB[RFB.encodings[i][2]];
RFB.encNames[RFB.encodings[i][1]] = RFB.encodings[i][0]; RFB.encNames[RFB.encodings[i][1]] = RFB.encodings[i][0];
} }
RFB.encHandlers[0x07] = RFB.display_tight_png;
RFB.encNames[0x07] = 'TIGHT';
//console.log("<< load"); //console.log("<< load");
}, },
...@@ -883,6 +891,7 @@ display_tight_png: function() { ...@@ -883,6 +891,7 @@ display_tight_png: function() {
return; return;
} }
//console.log(" RQ.slice(0,20): " + RFB.RQ.slice(0,20) + " (" + RFB.RQ.length + ")");
//console.log(" cmode: " + cmode); //console.log(" cmode: " + cmode);
// Determine FBU.bytes // Determine FBU.bytes
...@@ -897,7 +906,7 @@ display_tight_png: function() { ...@@ -897,7 +906,7 @@ display_tight_png: function() {
clength = getCLength(RQ, 1); clength = getCLength(RQ, 1);
FBU.bytes = 1 + clength[0] + clength[1]; // ctl + clength size + jpeg-data FBU.bytes = 1 + clength[0] + clength[1]; // ctl + clength size + jpeg-data
if (RQ.length < FBU.bytes) { if (RQ.length < FBU.bytes) {
console.log(" waiting for TIGHT " + cmode + " bytes"); //console.log(" waiting for TIGHT " + cmode + " bytes");
return; return;
} }
...@@ -929,13 +938,34 @@ extract_data_uri : function (arr) { ...@@ -929,13 +938,34 @@ extract_data_uri : function (arr) {
return ";base64," + Base64.encode(arr); return ";base64," + Base64.encode(arr);
}, },
set_desktopsize : function () {
console.log(">> set_desktopsize");
RFB.fb_width = RFB.FBU.width;
RFB.fb_height = RFB.FBU.height;
Canvas.clear();
Canvas.resize(RFB.fb_width, RFB.fb_height);
RFB.timing.fbu_rt_start = (new Date()).getTime();
// Send a new non-incremental request
RFB.send_array(RFB.fbUpdateRequest(0));
console.log("<< set_desktopsize");
RFB.FBU.bytes = 0;
RFB.FBU.rects --;
},
set_jpeg_quality : function () {
console.log(">> set_jpeg_quality");
},
set_compress_level: function () {
console.log(">> set_compress_level");
},
/* /*
* Client message routines * Client message routines
*/ */
pixelFormat: function () { pixelFormat: function () {
//console.log(">> setPixelFormat"); //console.log(">> pixelFormat");
var arr; var arr;
arr = [0]; // msg-type arr = [0]; // msg-type
arr.push8(0); // padding arr.push8(0); // padding
...@@ -957,7 +987,7 @@ pixelFormat: function () { ...@@ -957,7 +987,7 @@ pixelFormat: function () {
arr.push8(0); // padding arr.push8(0); // padding
arr.push8(0); // padding arr.push8(0); // padding
arr.push8(0); // padding arr.push8(0); // padding
//console.log("<< setPixelFormat"); //console.log("<< pixelFormat");
return arr; return arr;
}, },
...@@ -965,7 +995,7 @@ fixColourMapEntries: function () { ...@@ -965,7 +995,7 @@ fixColourMapEntries: function () {
}, },
clientEncodings: function () { clientEncodings: function () {
//console.log(">> setEncodings"); //console.log(">> clientEncodings");
var arr, i; var arr, i;
arr = [2]; // msg-type arr = [2]; // msg-type
arr.push8(0); // padding arr.push8(0); // padding
...@@ -975,7 +1005,7 @@ clientEncodings: function () { ...@@ -975,7 +1005,7 @@ clientEncodings: function () {
for (i=0; i<RFB.encodings.length; i++) { for (i=0; i<RFB.encodings.length; i++) {
arr.push32(RFB.encodings[i][1]); arr.push32(RFB.encodings[i][1]);
} }
console.log("<< setEncodings: " + arr); console.log("<< clientEncodings: " + arr);
return arr; return arr;
}, },
...@@ -1133,6 +1163,7 @@ recv_message_reorder: function(e) { ...@@ -1133,6 +1163,7 @@ recv_message_reorder: function(e) {
}, },
handle_message: function () { handle_message: function () {
//console.log("RQ.slice(0,20): " + RFB.RQ.slice(0,20) + " (" + RFB.RQ.length + ")");
switch (RFB.state) { switch (RFB.state) {
case 'disconnected': case 'disconnected':
console.error("Got data while disconnected"); console.error("Got data while disconnected");
......
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