From ee93f3f23a74591d67e772f8e27e1141684c514e Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 1 Feb 2018 12:18:06 +0100 Subject: [PATCH] Rename maximum_size to max_size The long option is --max-size, so for consistency, adapt the code accordingly. --- app/src/main.c | 12 +++++++----- app/src/scrcpy.c | 4 ++-- app/src/scrcpy.h | 2 +- app/src/server.c | 8 ++++---- app/src/server.h | 2 +- .../main/java/com/genymobile/scrcpy/Device.java | 16 ++++++++-------- .../main/java/com/genymobile/scrcpy/Options.java | 10 +++++----- .../java/com/genymobile/scrcpy/ScrCpyServer.java | 4 ++-- 8 files changed, 30 insertions(+), 28 deletions(-) diff --git a/app/src/main.c b/app/src/main.c index 2e7a65d8..c855f3b2 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -6,11 +6,12 @@ #include #define DEFAULT_LOCAL_PORT 27183 +#define DEFAULT_MAX_SIZE 0 struct args { const char *serial; Uint16 port; - Uint16 maximum_size; + Uint16 max_size; }; static int parse_args(struct args *args, int argc, char *argv[]) { @@ -40,14 +41,14 @@ static int parse_args(struct args *args, int argc, char *argv[]) { char *endptr; long value = strtol(optarg, &endptr, 0); if (*optarg == '\0' || *endptr != '\0') { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid maximum size: %s\n", optarg); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid max size: %s\n", optarg); return -1; } if (value & ~0xffff) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Maximum size must be between 0 and 65535: %ld\n", value); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Max size must be between 0 and 65535: %ld\n", value); return -1; } - args->maximum_size = (Uint16) value; + args->max_size = (Uint16) value; break; } default: @@ -72,6 +73,7 @@ int main(int argc, char *argv[]) { struct args args = { .serial = NULL, + .max_size = DEFAULT_MAX_SIZE, .port = DEFAULT_LOCAL_PORT, }; if (parse_args(&args, argc, argv)) { @@ -86,7 +88,7 @@ int main(int argc, char *argv[]) { SDL_LogSetAllPriority(SDL_LOG_PRIORITY_DEBUG); - res = scrcpy(args.serial, args.port, args.maximum_size) ? 0 : 1; + res = scrcpy(args.serial, args.port, args.max_size) ? 0 : 1; avformat_network_deinit(); // ignore failure diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index c8d96a1b..0addb487 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -382,7 +382,7 @@ void event_loop(void) { } } -SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 maximum_size) { +SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size) { SDL_bool ret = 0; process_t push_proc = push_server(serial); @@ -402,7 +402,7 @@ SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 maximum_size) { } // server will connect to our socket - process_t server = start_server(serial, maximum_size); + process_t server = start_server(serial, max_size); if (server == PROCESS_NONE) { ret = SDL_FALSE; SDLNet_TCP_Close(server_socket); diff --git a/app/src/scrcpy.h b/app/src/scrcpy.h index addc7b40..1a89dc89 100644 --- a/app/src/scrcpy.h +++ b/app/src/scrcpy.h @@ -3,6 +3,6 @@ #include -SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 maximum_size); +SDL_bool scrcpy(const char *serial, Uint16 local_port, Uint16 max_size); #endif diff --git a/app/src/server.c b/app/src/server.c index a23c45d7..a7bb9b60 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -21,16 +21,16 @@ process_t disable_tunnel(const char *serial) { return adb_reverse_remove(serial, SOCKET_NAME); } -process_t start_server(const char *serial, Uint16 maximum_size) { - char maximum_size_string[6]; - sprintf(maximum_size_string, "%d", maximum_size); +process_t start_server(const char *serial, Uint16 max_size) { + char max_size_string[6]; + sprintf(max_size_string, "%d", max_size); const char *const cmd[] = { "shell", "CLASSPATH=/data/local/tmp/scrcpy.apk", "app_process", "/", // unused "com.genymobile.scrcpy.ScrCpyServer", - maximum_size_string, + max_size_string, }; return adb_execute(serial, cmd, sizeof(cmd) / sizeof(cmd[0])); } diff --git a/app/src/server.h b/app/src/server.h index e366fac2..3b49ef9e 100644 --- a/app/src/server.h +++ b/app/src/server.h @@ -4,5 +4,5 @@ process_t push_server(const char *serial); process_t enable_tunnel(const char *serial, Uint16 local_port); process_t disable_tunnel(const char *serial); -process_t start_server(const char *serial, Uint16 maximum_size); +process_t start_server(const char *serial, Uint16 max_size); void stop_server(process_t server); diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java index 542f2035..234090bf 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Device.java +++ b/server/src/main/java/com/genymobile/scrcpy/Device.java @@ -20,7 +20,7 @@ public final class Device { private RotationListener rotationListener; public Device(Options options) { - screenInfo = computeScreenInfo(options.getMaximumSize()); + screenInfo = computeScreenInfo(options.getMaxSize()); registerRotationWatcher(new IRotationWatcher.Stub() { @Override public void onRotationChanged(int rotation) throws RemoteException { @@ -40,10 +40,10 @@ public final class Device { return screenInfo; } - private ScreenInfo computeScreenInfo(int maximumSize) { + private ScreenInfo computeScreenInfo(int maxSize) { // Compute the video size and the padding of the content inside this video. // Principle: - // - scale down the great side of the screen to maximumSize (if necessary); + // - scale down the great side of the screen to maxSize (if necessary); // - scale down the other side so that the aspect ratio is preserved; // - round this value to the nearest multiple of 8 (H.264 only accepts multiples of 8) DisplayInfo displayInfo = serviceManager.getDisplayManager().getDisplayInfo(); @@ -51,16 +51,16 @@ public final class Device { Size deviceSize = displayInfo.getSize(); int w = deviceSize.getWidth(); int h = deviceSize.getHeight(); - if (maximumSize > 0) { - assert maximumSize % 8 == 0; + if (maxSize > 0) { + assert maxSize % 8 == 0; boolean portrait = h > w; int major = portrait ? h : w; int minor = portrait ? w : h; - if (major > maximumSize) { - int minorExact = minor * maximumSize / major; + if (major > maxSize) { + int minorExact = minor * maxSize / major; // +4 to round the value to the nearest multiple of 8 minor = (minorExact + 4) & ~7; - major = maximumSize; + major = maxSize; } w = portrait ? minor : major; h = portrait ? major : minor; diff --git a/server/src/main/java/com/genymobile/scrcpy/Options.java b/server/src/main/java/com/genymobile/scrcpy/Options.java index f37ed7fb..30083e91 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Options.java +++ b/server/src/main/java/com/genymobile/scrcpy/Options.java @@ -1,13 +1,13 @@ package com.genymobile.scrcpy; public class Options { - private int maximumSize; + private int maxSize; - public int getMaximumSize() { - return maximumSize; + public int getMaxSize() { + return maxSize; } - public void setMaximumSize(int maximumSize) { - this.maximumSize = maximumSize; + public void setMaxSize(int maxSize) { + this.maxSize = maxSize; } } diff --git a/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java b/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java index bf84f31b..23d29e3a 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScrCpyServer.java @@ -37,8 +37,8 @@ public class ScrCpyServer { private static Options createOptions(String... args) { Options options = new Options(); if (args.length > 0) { - int maximumSize = Integer.parseInt(args[0]) & ~7; // multiple of 8 - options.setMaximumSize(maximumSize); + int maxSize = Integer.parseInt(args[0]) & ~7; // multiple of 8 + options.setMaxSize(maxSize); } return options; }