Skip to content

Commit

Permalink
#266 move some encoding attributes to default settings
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Oct 2, 2023
1 parent a8d2b31 commit 5a7b1fa
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 79 deletions.
3 changes: 3 additions & 0 deletions html5/default-settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
# debug_keyboard = true

blocked-hosts = xpra.org,www.xpra.org

min-quality = 10
min-speed = 50
68 changes: 24 additions & 44 deletions html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!--
Copyright (c) 2013-2022 Antoine Martin <antoine@xpra.org>
Copyright (c) 2014 Joshua Higgins <josh@kxes.net>
Licensed under MPL 2.0
-->
Copyright (c) 2013-2022 Antoine Martin <antoine@xpra.org>
Copyright (c) 2014 Joshua Higgins <josh@kxes.net>
Licensed under MPL 2.0
-->

<title>xpra websockets client</title>
<meta charset="utf-8" />
Expand Down Expand Up @@ -48,10 +48,10 @@
<script type="text/javascript" src="js/lib/jsmpeg.js"></script>
<script type="text/javascript" src="js/lib/aurora/aurora.js"></script>
<!--
<script type="text/javascript" src="js/lib/aurora/mp3.js"></script>
<script type="text/javascript" src="js/lib/aurora/flac.js"></script>
<script type="text/javascript" src="js/lib/aurora/aac.js"></script>
-->
<script type="text/javascript" src="js/lib/aurora/mp3.js"></script>
<script type="text/javascript" src="js/lib/aurora/flac.js"></script>
<script type="text/javascript" src="js/lib/aurora/aac.js"></script>
-->
<script type="text/javascript" src="js/lib/aurora/aurora-xpra.js"></script>

<script
Expand Down Expand Up @@ -181,14 +181,6 @@
</li>
</ul>
</li>
<!--
<li class="-hasSubmenu">
<a href="#" data-icon="list">Features</a>
<ul>
<li><a href="#" data-icon="message">Notifications</a></li>
</ul>
</li>
-->
<li class="-hasSubmenu">
<a href="#" data-icon="info">Information</a>
<ul>
Expand Down Expand Up @@ -311,10 +303,6 @@ <h3>Connection Data</h3>
<th scope="row">Server Display</th>
<td id="server_display"></td>
</tr>
<!-- <tr>
<th>Server Hostname</th>
<td id="server_hostname"></td>
</tr> -->
<tr>
<th scope="row">Server Platform</th>
<td id="server_platform"></td>
Expand All @@ -324,9 +312,9 @@ <h3>Connection Data</h3>
<td id="server_load"></td>
</tr>
<!-- <tr>
<th>Session Started</th>
<td id="session_started"></td>
</tr> -->
<th>Session Started</th>
<td id="session_started"></td>
</tr> -->
<tr>
<th scope="row">Session Connected</th>
<td id="session_connected"></td>
Expand Down Expand Up @@ -395,33 +383,24 @@ <h2>Xpra Bug Report</h2>
clog("using", prop, "=", v, " from default settings");
}
else if (v != null && v != "") {
clog("using", prop, "=", v, " from parameters");
clog("using", prop, "=", v, " from parameters");
}
return v;
};

const getboolparam = function (prop, default_value) {
let v = Utilities.getparam(prop);
if (v == null && prop in default_settings) {
v = default_settings[prop];
}
const v = getparam(prop);
return Utilities.stristrue(v, default_value);
};
const getboolautoparam = function (prop, default_value) {
let v = Utilities.getparam(prop);
if (v == null && prop in default_settings) {
v = default_settings[prop];
}
const v = getparam(prop);
if (v == "auto") {
return "auto";
}
return Utilities.stristrue(v, default_value);
};
const getintparam = function (prop, default_value) {
let v = Utilities.getparam(prop);
if (v == null && prop in default_settings) {
v = default_settings[prop];
}
let v = getparam(prop);
try {
v = parseInt(v);
} catch (e) {
Expand All @@ -433,10 +412,7 @@ <h2>Xpra Bug Report</h2>
return v;
};
const getfloatparam = function (prop, default_value) {
let v = Utilities.getparam(prop);
if (v == null && prop in default_settings) {
v = default_settings[prop];
}
let v = getparam(prop);
try {
v = parseFloat(v);
} catch (e) {
Expand Down Expand Up @@ -953,6 +929,13 @@ <h2>Xpra Bug Report</h2>
// the primary encoding
client.set_encoding(encoding);
}
for (const key of ["speed", "min-speed", "quality", "min-quality"]) {
const v = getintparam(key, -1);
clog(key, "=", v);
if (v>=0) {
client.set_encoding_option(key, v);
}
}
client.offscreen_api = offscreen && client.offscreen_api;

if (action && action != "connect") {
Expand Down Expand Up @@ -1007,10 +990,7 @@ <h2>Xpra Bug Report</h2>
}

// check for encryption parameters
if (
encryption &&
["0", "false", "no", "disabled"].indexOf(encryption.toLowerCase()) < 0
) {
if (Utilities.stristrue(encryption, false)) {
client.encryption = encryption.toUpperCase();
if (key) {
client.encryption_key = key;
Expand Down
74 changes: 39 additions & 35 deletions html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,6 @@ class XpraClient {
this.steal = true;
this.remote_logging = true;
this.encoding = "auto";
//basic set of encodings:
//(more may be added after checking via the DecodeWorker)
this.supported_encodings = [
"jpeg",
"png",
"png/P",
"png/L",
"rgb",
"rgb32",
"rgb24",
"scroll",
"void",
];
//extra encodings we enable if validated via the decode worker:
//(we also validate jpeg and png as a sanity check)
this.check_encodings = [
"jpeg",
"png",
"png/P",
"png/L",
"rgb",
"rgb32",
"rgb24",
"scroll",
"webp",
"void",
"avif",
];
this.debug_categories = [];
this.start_new_session = null;
this.clipboard_enabled = false;
Expand Down Expand Up @@ -143,6 +115,38 @@ class XpraClient {
this.offscreen_api = DECODE_WORKER && XpraOffscreenWorker.isAvailable();
this.try_gpu = TRY_GPU_TRIGGER;

//basic set of encodings:
//(more may be added after checking via the DecodeWorker)
this.supported_encodings = [
"jpeg",
"png",
"png/P",
"png/L",
"rgb",
"rgb32",
"rgb24",
"scroll",
"void",
];
//extra encodings we enable if validated via the decode worker:
//(we also validate jpeg and png as a sanity check)
this.check_encodings = [
"jpeg",
"png",
"png/P",
"png/L",
"rgb",
"rgb32",
"rgb24",
"scroll",
"webp",
"void",
"avif",
];
let video_max_size = [1024, 768];
if (this.offscreen_api) {
video_max_size = [4096, 4096];
}
this.encoding_options = {
"encoding" : this.encoding,
"icons.max_size": [30, 30],
Expand Down Expand Up @@ -725,6 +729,11 @@ class XpraClient {
this.encoding = encoding;
this.encoding_options["encoding"] = this.encoding;
}
set_encoding_option(option, value) {
// add an encoding to our hello.encodings list
this.clog("encoding: ", option, "=", value);
this.encoding_options[option] = value;
}

_route_packet(packet) {
// ctx refers to `this` because we came through a callback
Expand Down Expand Up @@ -1556,11 +1565,6 @@ class XpraClient {
});
}

let video_max_size = [1024, 768];
if (this.offscreen_api) {
video_max_size = [4096, 4096];
}

this._update_capabilities({
auto_refresh_delay: 500,
"metadata.supported": [
Expand Down Expand Up @@ -1610,8 +1614,8 @@ class XpraClient {
screen_sizes: this._get_screen_sizes(),
dpi: this._get_DPI(),
//not handled yet, but we will:
clipboard : get_clipboard_caps(),
notifications : get_notifications_caps(),
clipboard : this.get_clipboard_caps(),
notifications : this.get_notifications_caps(),
cursors: true,
bell: true,
system_tray: true,
Expand Down

0 comments on commit 5a7b1fa

Please sign in to comment.