scrcpy/app/src/server.c
Romain Vimont 89f6a3cfe7 Handle resized video stream
Accept a parameter to limit the video size.

For instance, with "-m 960", the great side of the video will be scaled
down to 960 (if necessary), while the other side will be scaled down so
that the aspect ratio is preserved. Both dimensions must be a multiple
of 8, so black bands might be added, and the mouse positions must be
computed accordingly.
2018-01-29 15:40:33 +01:00

43 lines
1.2 KiB
C

#include "command.h"
#include <SDL2/SDL_log.h>
#include <errno.h>
#define SOCKET_NAME "scrcpy"
process_t push_server(const char *serial) {
const char *server_jar_path = getenv("SCRCPY_SERVER_JAR");
if (!server_jar_path) {
server_jar_path = "scrcpy-server.jar";
}
return adb_push(serial, server_jar_path, "/data/local/tmp/");
}
process_t enable_tunnel(const char *serial, Uint16 local_port) {
return adb_reverse(serial, SOCKET_NAME, local_port);
}
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);
const char *const cmd[] = {
"shell",
"CLASSPATH=/data/local/tmp/scrcpy-server.jar",
"app_process",
"/system/bin",
"com.genymobile.scrcpy.ScrCpyServer",
maximum_size_string,
};
return adb_execute(serial, cmd, sizeof(cmd) / sizeof(cmd[0]));
}
void stop_server(process_t server) {
if (!cmd_terminate(server)) {
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not terminate server: %s", strerror(errno));
}
}