Add options for quality, compression and encodings

qemu-extended-key-event
Andri Yngvason 2020-07-11 22:24:11 +00:00
parent 0c43623ceb
commit 905eb8dc29
3 changed files with 76 additions and 4 deletions

View File

@ -35,3 +35,6 @@ void vnc_client_send_pointer_event(struct vnc_client* self, int x, int y,
uint32_t button_mask); uint32_t button_mask);
void vnc_client_send_keyboard_event(struct vnc_client* self, uint32_t symbol, void vnc_client_send_keyboard_event(struct vnc_client* self, uint32_t symbol,
bool is_pressed); bool is_pressed);
void vnc_client_set_encodings(struct vnc_client* self, const char* encodings);
void vnc_client_set_quality_level(struct vnc_client* self, int value);
void vnc_client_set_compression_level(struct vnc_client* self, int value);

View File

@ -23,6 +23,7 @@
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <getopt.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <aml.h> #include <aml.h>
#include <wayland-client.h> #include <wayland-client.h>
@ -446,6 +447,14 @@ static int usage(int r)
{ {
fprintf(r ? stderr : stdout, "\ fprintf(r ? stderr : stdout, "\
Usage: wlvncc <address> [port]\n\ Usage: wlvncc <address> [port]\n\
\n\
-c,--compression Compression level (0 - 9).\n\
-e,--encodings=<list> Set allowed encodings, comma separated list.\n\
Supported values: tight, zrle, ultra, copyrect,\n\
hextile, zlib, corre, rre, raw.\n\
-h,--help Get help.\n\
-q,--quality Quality level (0 - 9).\n\
\n\
"); ");
return r; return r;
} }
@ -454,13 +463,50 @@ int main(int argc, char* argv[])
{ {
int rc = -1; int rc = -1;
if (argc < 2) const char* encodings = NULL;
int quality = -1;
int compression = -1;
static const char* shortopts = "q:c:e:h";
static const struct option longopts[] = {
{ "compression", required_argument, NULL, 'c' },
{ "encodings", required_argument, NULL, 'e' },
{ "help", no_argument, NULL, 'h' },
{ "quality", required_argument, NULL, 'q' },
{ NULL, 0, NULL, 0 }
};
while (1) {
int c = getopt_long(argc, argv, shortopts, longopts, NULL);
if (c < 0)
break;
switch (c) {
case 'q':
quality = atoi(optarg);
break;
case 'c':
compression = atoi(optarg);
break;
case 'e':
encodings = optarg;
break;
case 'h':
return usage(0);
default:
return usage(1);
}
}
int n_args = argc - optind;
if (n_args < 1)
return usage(1); return usage(1);
const char* address = argv[1]; const char* address = argv[optind];
int port = 5900; int port = 5900;
if (argc > 2) if (n_args >= 2)
port = atoi(argv[2]); port = atoi(argv[optind + 1]);
struct aml* aml = aml_new(); struct aml* aml = aml_new();
if (!aml) if (!aml)
@ -520,6 +566,14 @@ int main(int argc, char* argv[])
goto vnc_setup_failure; goto vnc_setup_failure;
} }
vnc_client_set_encodings(vnc, encodings);
if (quality >= 0)
vnc_client_set_quality_level(vnc, quality);
if (compression >= 0)
vnc_client_set_compression_level(vnc, compression);
if (vnc_client_connect(vnc, address, port) < 0) { if (vnc_client_connect(vnc, address, port) < 0) {
fprintf(stderr, "Failed to connect to server\n"); fprintf(stderr, "Failed to connect to server\n");
goto vnc_setup_failure; goto vnc_setup_failure;

View File

@ -198,3 +198,18 @@ void vnc_client_send_keyboard_event(struct vnc_client* self, uint32_t symbol,
{ {
SendKeyEvent(self->client, symbol, is_pressed); SendKeyEvent(self->client, symbol, is_pressed);
} }
void vnc_client_set_encodings(struct vnc_client* self, const char* encodings)
{
self->client->appData.encodingsString = encodings;
}
void vnc_client_set_quality_level(struct vnc_client* self, int value)
{
self->client->appData.qualityLevel = value;
}
void vnc_client_set_compression_level(struct vnc_client* self, int value)
{
self->client->appData.compressLevel = value;
}