提交 7d67696b 编写于 作者: R Romain Vimont

Extract server-related functions

To lighten screen.c, move start_server() and stop_server() to a separate
file.
上级 52af91f6
......@@ -11,6 +11,7 @@ src = [
'src/lockutil.c',
'src/netutil.c',
'src/screen.c',
'src/server.c',
'src/strutil.c',
]
......
......@@ -16,6 +16,7 @@
#include "frames.h"
#include "lockutil.h"
#include "netutil.h"
#include "server.h"
#define DEVICE_NAME_FIELD_LENGTH 64
#define SOCKET_NAME "scrcpy"
......@@ -65,23 +66,6 @@ static TCPsocket listen_on_port(Uint16 port) {
return SDLNet_TCP_Open(&addr);
}
static process_t start_server(const char *serial) {
const char *const cmd[] = {
"shell",
"CLASSPATH=/data/local/tmp/scrcpy-server.jar",
"app_process",
"/system/bin",
"com.genymobile.scrcpy.ScrCpyServer"
};
return adb_execute(serial, cmd, sizeof(cmd) / sizeof(cmd[0]));
}
static void stop_server(process_t server) {
if (!cmd_terminate(server)) {
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, "Could not kill: %s", strerror(errno));
}
}
// name must be at least DEVICE_NAME_FIELD_LENGTH bytes
SDL_bool read_initial_device_info(TCPsocket socket, char *device_name, struct size *size) {
unsigned char buf[DEVICE_NAME_FIELD_LENGTH + 4];
......
#include "command.h"
#include <SDL2/SDL_log.h>
#include <errno.h>
process_t start_server(const char *serial) {
const char *const cmd[] = {
"shell",
"CLASSPATH=/data/local/tmp/scrcpy-server.jar",
"app_process",
"/system/bin",
"com.genymobile.scrcpy.ScrCpyServer"
};
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));
}
}
#include "command.h"
process_t start_server(const char *serial);
void stop_server(process_t server);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册