add encoding options to remote desktop (#6198)

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
Simon Smith 2024-06-23 21:00:30 +01:00 committed by GitHub
parent 28c522c5bb
commit 602eb3c64a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 73 additions and 19 deletions

View File

@ -28311,7 +28311,9 @@
"zh-cht": "編碼",
"hu": "Kódolás",
"xloc": [
"default-mobile.handlebars->dialog->3->dialog7->d7amtkvm->3->1->0->1"
"default-mobile.handlebars->dialog->3->dialog7->d7amtkvm->3->1->0->1",
"default-mobile.handlebars->dialog->3->dialog7->d7meshkvm->3->1->6->1",
"default.handlebars->container->dialog->dialogBody->dialog7->d7meshkvm->9->1"
]
},
{
@ -40112,6 +40114,13 @@
"zh-cht": "物品",
"hu": "Elem"
},
{
"en": "JPEG",
"xloc": [
"default-mobile.handlebars->dialog->3->dialog7->d7meshkvm->3->1->6->3->d7encoding->1",
"default.handlebars->container->dialog->dialogBody->dialog7->d7meshkvm->9->d7encoding->1"
]
},
{
"bs": "JSON",
"cs": "JSON",
@ -43882,7 +43891,7 @@
"zh-cht": "斷開連接鎖定",
"hu": "Zárolás a kapcsolat bontásakor",
"xloc": [
"default-mobile.handlebars->dialog->3->dialog7->d7meshkvm->3->1->6->3->d7deskAutoLockLabel",
"default-mobile.handlebars->dialog->3->dialog7->d7meshkvm->3->1->8->3->d7deskAutoLockLabel",
"default.handlebars->container->dialog->dialogBody->dialog7->d7meshkvm->d7desktopOtherSettings->d7otherset2->d7deskAutoLockLabel"
]
},
@ -80665,6 +80674,13 @@
"default.handlebars->47->113"
]
},
{
"en": "WEBP",
"xloc": [
"default-mobile.handlebars->dialog->3->dialog7->d7meshkvm->3->1->6->3->d7encoding->3",
"default.handlebars->container->dialog->dialogBody->dialog7->d7meshkvm->9->d7encoding->3"
]
},
{
"bs": "WIN + Down",
"cs": "VYHRAJTE + Dolů",

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
@ -1226,6 +1226,17 @@
</select>
</td>
</tr>
<tr>
<td>
Encoding
</td>
<td style="width:100px">
<select id="d7encoding" style="float:right;width:200px" dir="rtl">
<option value=1>JPEG</option>
<option selected=selected value=4>WEBP</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td>
@ -1344,7 +1355,13 @@
// Check if WebP is supported
var webpSupport = false;
check_webp_feature('lossy', function (f, x) { webpSupport = x; });
check_webp_feature('lossy', function (f, x) {
webpSupport = x;
if (!x) {
d7encoding.options[1].disabled = true;
d7encoding.value = 1;
}
});
function startup() {
if ((features & 32) == 0) {
@ -4424,7 +4441,7 @@
var desktop;
var desktopNode;
var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50, autolock: false };
var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50, autolock: false, agentencoding: 4 };
function setupDesktop() {
// Setup the remote desktop
if ((desktopNode != currentNode) && (desktop != null)) { desktop.Stop(); desktopNode = null; desktop = null; }
@ -4548,7 +4565,7 @@
p11clearConsoleMsg();
}
}
desktop.m.ImageType = webpSupport ? 4 : 1; // Send 4 if WebP is supported, otherwise send 1 for JPEG.
desktop.m.ImageType = desktopsettings.agentencoding; // Send 4 if WebP is supported, otherwise send 1 for JPEG.
desktop.m.CompressionLevel = desktopsettings.quality; // Number from 1 to 100. 50 or less is best.
desktop.m.ScalingLevel = desktopsettings.scaling;
desktop.m.FrameRateTimer = desktopsettings.framerate;
@ -4632,12 +4649,14 @@
desktopsettings.scaling = d7bitmapscaling.value;
desktopsettings.framerate = d7framelimiter.value;
desktopsettings.autolock = d7deskAutoLock.checked;
desktopsettings.agentencoding = d7encoding.value;
localStorage.setItem('desktopsettings', JSON.stringify(desktopsettings));
applyDesktopSettings();
if (desktop) {
if (desktop.contype == 1) {
if (desktop.State != 0) { desktop.m.SendCompressionLevel(webpSupport ? 4 : 1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); }
if (desktop.State != 0) { desktop.m.SendCompressionLevel(desktopsettings.agentencoding, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); }
desktop.sendCtrlMsg('{"ctrlChannel":"102938","type":"autolock","value":' + desktopsettings.autolock + '}');
desktop.m.SendRefresh();
}
if (desktop.contype == 2) {
if (desktop.State != 0) { desktop.Stop(); setTimeout(function () { connectDesktop(null, 2); }, 50); }
@ -4651,6 +4670,7 @@
QH('d7bitmapquality', r);
d7desktopmode.value = desktopsettings.encoding;
d7bitmapquality.value = 40; // Default value
if (desktopsettings.agentencoding) { d7encoding.value = desktopsettings.agentencoding; } else { desktopsettings.agentencoding = 4; }
if (ops.indexOf(parseInt(desktopsettings.quality)) >= 0) { d7bitmapquality.value = desktopsettings.quality; }
d7bitmapscaling.value = desktopsettings.scaling;
if (desktopsettings.framerate) { d7framelimiter.value = desktopsettings.framerate; }

View File

@ -1402,6 +1402,13 @@
<option value=1000>Very slow</option>
</select>
</div>
<div>
<div>Encoding</div>
<select id="d7encoding" dir="rtl">
<option value=1>JPEG</option>
<option selected=selected value=4>WEBP</option>
</select>
</div>
<div id="d7desktopOtherSettings">
<div>Other Settings</div>
<div id="d7otherset2" style="display:block">
@ -1524,8 +1531,8 @@
var stars = {}; // Devices that have been "stared" by the user.
var nodeShortIdent = 0;
var desktop;
var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50, localkeymap: false, swapmouse: false, remotekeymap: false, autoclipboard: false, autolock: false };
var multidesktopsettings = { quality: 20, scaling: 128, framerate: 1000 };
var desktopsettings = { encoding: 2, showfocus: false, showmouse: true, showcad: true, quality: 40, scaling: 1024, framerate: 50, localkeymap: false, swapmouse: false, remotekeymap: false, autoclipboard: false, autolock: false, agentencoding: 4 };
var multidesktopsettings = { quality: 20, scaling: 128, framerate: 1000, agentencoding: 4 };
var terminal;
var files;
var debugLevel = parseInt('{{{debuglevel}}}');
@ -1600,7 +1607,13 @@
// Check if WebP is supported
var webpSupport = false;
check_webp_feature('lossy', function (f, x) { webpSupport = x; });
check_webp_feature('lossy', function (f, x) {
webpSupport = x;
if (!x) {
d7encoding.options[1].disabled = true;
d7encoding.value = 1;
}
});
function startup() {
if ((features & 32) == 0) {
@ -4612,7 +4625,7 @@
c.removeAttribute('onmousemove');
Q('xkvmid_' + shortid).appendChild(c);
QH('skvmid_' + shortid, ["Disconnected", "Connecting...", "Setup...", '', ''][((desktop.m.State == null)?desktop.m.state:desktop.m.State)]);
if (desktop.m.SendCompressionLevel) { desktop.m.SendCompressionLevel(webpSupport?4:1, multidesktopsettings.quality, multidesktopsettings.scaling, multidesktopsettings.framerate); }
if (desktop.m.SendCompressionLevel) { desktop.m.SendCompressionLevel(multidesktopsettings.agentencoding, multidesktopsettings.quality, multidesktopsettings.scaling, multidesktopsettings.framerate); }
desktop.shortid = shortid;
desktop.onStateChanged = onMultiDesktopStateChange;
desktop.m.onRemoteInputLockChanged = null;
@ -5147,6 +5160,7 @@
QV('d7desktopOtherSettings', false);
d7bitmapquality.value = multidesktopsettings.quality;
d7bitmapscaling.value = multidesktopsettings.scaling;
d7encoding.value = multidesktopsettings.agentencoding;
if (multidesktopsettings.framerate) { d7framelimiter.value = multidesktopsettings.framerate; } else { d7framelimiter.value = 100; }
setDialogMode(7, "Remote Desktop Settings", 3, showMultiDesktopSettingsChanged);
}
@ -5155,9 +5169,10 @@
multidesktopsettings.quality = d7bitmapquality.value;
multidesktopsettings.scaling = d7bitmapscaling.value;
multidesktopsettings.framerate = d7framelimiter.value;
multidesktopsettings.agentencoding = d7encoding.value;
localStorage.setItem('multidesktopsettings', JSON.stringify(multidesktopsettings));
// Make changes to all current connections
for (var i in multiDesktop) { multiDesktop[i].m.SendCompressionLevel(webpSupport?4:1, multidesktopsettings.quality, multidesktopsettings.scaling, multidesktopsettings.framerate); }
for (var i in multiDesktop) { multiDesktop[i].m.SendCompressionLevel(multidesktopsettings.agentencoding, multidesktopsettings.quality, multidesktopsettings.scaling, multidesktopsettings.framerate); }
}
function connectMultiDesktop(node, contype) {
@ -5189,7 +5204,7 @@
desk.attemptWebRTC = attemptWebRTC;
desk.onStateChanged = onMultiDesktopStateChange;
//desk.onConsoleMessageChange = function () { console.log('CONSOLEMSG:', desk.consoleMessage); }
desk.m.ImageType = webpSupport?4:1; // Send 4 if WebP is supported, otherwise send 1 for JPEG.
desk.m.ImageType = multidesktopsettings.agentencoding; // Send 4 if WebP is supported, otherwise send 1 for JPEG.
desk.m.CompressionLevel = multidesktopsettings.quality;
desk.m.ScalingLevel = multidesktopsettings.scaling;
if (multidesktopsettings.framerate) { desk.m.FrameRateTimer = multidesktopsettings.framerate; }
@ -9004,7 +9019,7 @@
c.removeAttribute('onclick');
Q('DeskParent').appendChild(c);
desktop = xdesk;
if (desktop.m.SendCompressionLevel) { desktop.m.SendCompressionLevel(webpSupport?4:1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); }
if (desktop.m.SendCompressionLevel) { desktop.m.SendCompressionLevel(desktopsettings.agentencoding, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate); }
desktop.onStateChanged = onDesktopStateChange;
desktop.onMetadataChange = function(metadata) { updateMetadata(desktop, 'deskmetadata'); }
if ((features2 & 0x2000) != 0) desktop.m.stopInput = true;
@ -9277,7 +9292,7 @@
}
}
desktop.onMetadataChange = function(metadata) { updateMetadata(desktop, 'deskmetadata'); }
desktop.m.ImageType = webpSupport?4:1; // Send 4 if WebP is supported, otherwise send 1 for JPEG.
desktop.m.ImageType = desktopsettings.agentencoding; // Send 4 if WebP is supported, otherwise send 1 for JPEG.
desktop.m.CompressionLevel = desktopsettings.quality; // Number from 1 to 100. 50 or less is best.
desktop.m.ScalingLevel = desktopsettings.scaling;
if (desktopsettings.framerate) { desktop.m.FrameRateTimer = desktopsettings.framerate; }
@ -9583,6 +9598,7 @@
desktopsettings.quality = d7bitmapquality.value;
desktopsettings.scaling = d7bitmapscaling.value;
desktopsettings.framerate = d7framelimiter.value;
desktopsettings.agentencoding = d7encoding.value;
desktopsettings.swapmouse = d7deskSwapMouse.checked;
desktopsettings.rmw = d7deskrmw.checked;
desktopsettings.remotekeymap = d7deskRemoteKeyMap.checked;
@ -9601,16 +9617,17 @@
applyDesktopSettings();
updateDesktopButtons();
if (desktop) {
if (desktop.contype == 1) { // Intel AMT KVM
if (desktop.contype == 1) { // Mesh Agent Remote Desktop
desktop.m.SwapMouse = desktopsettings.swapmouse;
desktop.m.ReverseMouseWheel = desktopsettings.rmw;
desktop.m.remoteKeyMap = desktopsettings.remotekeymap;
if (desktop.State != 0) {
desktop.m.SendCompressionLevel(webpSupport?4:1, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate);
desktop.m.SendCompressionLevel(desktopsettings.agentencoding, desktopsettings.quality, desktopsettings.scaling, desktopsettings.framerate);
desktop.sendCtrlMsg('{"ctrlChannel":"102938","type":"autolock","value":' + desktopsettings.autolock + '}');
desktop.m.SendRefresh();
}
}
if (desktop.contype == 2) { // Mesh Agent Remote Desktop
if (desktop.contype == 2) { // Intel AMT KVM
desktop.m.ReverseMouseWheel = desktopsettings.kvmrmw;
if (desktopsettings.showfocus == false) { desktop.m.focusmode = 0; deskFocusBtn.value = "All Focus"; }
if (desktop.State != 0) { desktop.Stop(); setTimeout(function () { connectDesktop(null, 2); }, 50); }
@ -9629,6 +9646,7 @@
d7desktopmode.value = desktopsettings.encoding;
d7showfocus.checked = desktopsettings.showfocus;
d7showcursor.checked = desktopsettings.showmouse;
if (desktopsettings.agentencoding) { d7encoding.value = desktopsettings.agentencoding; } else { desktopsettings.agentencoding = 4; }
d7bitmapquality.value = 40; // Default value
if (ops.indexOf(parseInt(desktopsettings.quality)) >= 0) { d7bitmapquality.value = desktopsettings.quality; }
d7bitmapscaling.value = desktopsettings.scaling;

View File

@ -8758,7 +8758,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
// Filter the user web site and only output state that we need to keep
const acceptableUserWebStateStrings = ['webPageStackMenu', 'notifications', 'deviceView', 'nightMode', 'webPageFullScreen', 'search', 'showRealNames', 'sort', 'deskAspectRatio', 'viewsize', 'DeskControl', 'uiMode', 'footerBar'];
const acceptableUserWebStateDesktopStrings = ['encoding', 'showfocus', 'showmouse', 'showcad', 'limitFrameRate', 'noMouseRotate', 'quality', 'scaling']
const acceptableUserWebStateDesktopStrings = ['encoding', 'showfocus', 'showmouse', 'showcad', 'limitFrameRate', 'noMouseRotate', 'quality', 'scaling', 'agentencoding']
obj.filterUserWebState = function (state) {
if (typeof state == 'string') { try { state = JSON.parse(state); } catch (ex) { return null; } }
if ((state == null) || (typeof state != 'object')) { return null; }