mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-07-29 20:28:59 +00:00
Pass server parameters as key=value pairs
The options values to configure the server were identified by their command-line argument index. Now that there are a lot of arguments, many of them being booleans, it became unreadable and error-prone. Identify the arguments by a key string instead, and make them optional. This will also simplify running the server manually for debugging.
This commit is contained in:
parent
2eb881c5f1
commit
04e5537f8c
4 changed files with 105 additions and 77 deletions
|
@ -163,7 +163,6 @@ execute_server(struct sc_server *server,
|
|||
cmd[count++] = "/"; // unused
|
||||
cmd[count++] = "com.genymobile.scrcpy.Server";
|
||||
cmd[count++] = SCRCPY_VERSION;
|
||||
cmd[count++] = log_level_to_server_string(params->log_level);
|
||||
|
||||
unsigned dyn_idx = count; // from there, the strings are allocated
|
||||
#define ADD_PARAM(fmt, ...) { \
|
||||
|
@ -175,22 +174,25 @@ execute_server(struct sc_server *server,
|
|||
}
|
||||
#define STRBOOL(v) (v ? "true" : "false")
|
||||
|
||||
ADD_PARAM("%" PRIu16, params->max_size);
|
||||
ADD_PARAM("%" PRIu32, params->bit_rate);
|
||||
ADD_PARAM("%" PRIu16, params->max_fps);
|
||||
ADD_PARAM("%" PRIi8, params->lock_video_orientation);
|
||||
ADD_PARAM("%s", STRBOOL(server->tunnel.forward));
|
||||
ADD_PARAM("%s", params->crop ? params->crop : "-");
|
||||
ADD_PARAM("log_level=%s", log_level_to_server_string(params->log_level));
|
||||
ADD_PARAM("max_size=%" PRIu16, params->max_size);
|
||||
ADD_PARAM("bit_rate=%" PRIu32, params->bit_rate);
|
||||
ADD_PARAM("max_fps=%" PRIu16, params->max_fps);
|
||||
ADD_PARAM("lock_video_orientation=%" PRIi8, params->lock_video_orientation);
|
||||
ADD_PARAM("tunnel_forward=%s", STRBOOL(server->tunnel.forward));
|
||||
ADD_PARAM("crop=%s", params->crop ? params->crop : "");
|
||||
// always send frame meta (packet boundaries + timestamp)
|
||||
ADD_PARAM("true");
|
||||
ADD_PARAM("%s", STRBOOL(params->control));
|
||||
ADD_PARAM("%" PRIu32, params->display_id);
|
||||
ADD_PARAM("%s", STRBOOL(params->show_touches));
|
||||
ADD_PARAM("%s", STRBOOL(params->stay_awake));
|
||||
ADD_PARAM("%s", params->codec_options ? params->codec_options : "-");
|
||||
ADD_PARAM("%s", params->encoder_name ? params->encoder_name : "-");
|
||||
ADD_PARAM("%s", STRBOOL(params->power_off_on_close));
|
||||
ADD_PARAM("%s", STRBOOL(params->clipboard_autosync));
|
||||
ADD_PARAM("send_frame_meta=true");
|
||||
ADD_PARAM("control=%s", STRBOOL(params->control));
|
||||
ADD_PARAM("display_id=%" PRIu32, params->display_id);
|
||||
ADD_PARAM("show_touches=%s", STRBOOL(params->show_touches));
|
||||
ADD_PARAM("stay_awake=%s", STRBOOL(params->stay_awake));
|
||||
ADD_PARAM("codec_options=%s",
|
||||
params->codec_options ? params->codec_options : "");
|
||||
ADD_PARAM("encoder_name=%s",
|
||||
params->encoder_name ? params->encoder_name : "");
|
||||
ADD_PARAM("power_off_on_close=%s", STRBOOL(params->power_off_on_close));
|
||||
ADD_PARAM("clipboard_autosync=%s", STRBOOL(params->clipboard_autosync));
|
||||
|
||||
#undef ADD_PARAM
|
||||
#undef STRBOOL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue