mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 19:45:00 +00:00
Added ssh-endpoint
option.
This commit is contained in:
parent
8517390476
commit
772cc7ba00
7 changed files with 37 additions and 1 deletions
|
@ -652,6 +652,7 @@ guess_record_format(const char *filename) {
|
|||
#define OPT_SHORTCUT_MOD 1021
|
||||
#define OPT_NO_KEY_REPEAT 1022
|
||||
#define OPT_USE_SSH 1024
|
||||
#define OPT_SSH_ENDPOINT 1025
|
||||
|
||||
bool
|
||||
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||
|
@ -687,6 +688,7 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||
{"serial", required_argument, NULL, 's'},
|
||||
{"shortcut-mod", required_argument, NULL, OPT_SHORTCUT_MOD},
|
||||
{"show-touches", no_argument, NULL, 't'},
|
||||
{"ssh-endpoint", required_argument, NULL, OPT_SSH_ENDPOINT},
|
||||
{"stay-awake", no_argument, NULL, 'w'},
|
||||
{"turn-screen-off", no_argument, NULL, 'S'},
|
||||
{"verbosity", required_argument, NULL, 'V'},
|
||||
|
@ -801,6 +803,9 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||
case OPT_WINDOW_TITLE:
|
||||
opts->window_title = optarg;
|
||||
break;
|
||||
case OPT_SSH_ENDPOINT:
|
||||
opts->ssh_endpoint = optarg;
|
||||
break;
|
||||
case OPT_WINDOW_X:
|
||||
if (!parse_window_position(optarg, &opts->window_x)) {
|
||||
return false;
|
||||
|
|
|
@ -102,6 +102,24 @@ show_adb_err_msg(enum process_result err, const char *const argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
process_t
|
||||
ssh_execute(const char *endpoint, const char *const adb_cmd[], size_t len) {
|
||||
const char *cmd[len + 3];
|
||||
int i = 2;
|
||||
process_t process;
|
||||
cmd[0] = "ssh";
|
||||
cmd[1] = endpoint;
|
||||
|
||||
memcpy(&cmd[i], adb_cmd, len * sizeof(const char *));
|
||||
cmd[len + i] = NULL;
|
||||
enum process_result r = cmd_execute(cmd, &process);
|
||||
if (r != PROCESS_SUCCESS) {
|
||||
show_adb_err_msg(r, cmd);
|
||||
return PROCESS_NONE;
|
||||
}
|
||||
return process;
|
||||
}
|
||||
|
||||
process_t
|
||||
adb_execute(const char *serial, const char *const adb_cmd[], size_t len) {
|
||||
const char *cmd[len + 4];
|
||||
|
|
|
@ -57,6 +57,9 @@ cmd_terminate(process_t pid);
|
|||
bool
|
||||
cmd_simple_wait(process_t pid, exit_code_t *exit_code);
|
||||
|
||||
process_t
|
||||
ssh_execute(const char *serial, const char *const adb_cmd[], size_t len);
|
||||
|
||||
process_t
|
||||
adb_execute(const char *serial, const char *const adb_cmd[], size_t len);
|
||||
|
||||
|
|
|
@ -319,6 +319,8 @@ scrcpy(const struct scrcpy_options *options) {
|
|||
.stay_awake = options->stay_awake,
|
||||
.codec_options = options->codec_options,
|
||||
.force_adb_forward = options->force_adb_forward,
|
||||
.use_ssh = options->use_ssh,
|
||||
.ssh_endpoint = options->ssh_endpoint,
|
||||
};
|
||||
if (!server_start(&server, options->serial, ¶ms)) {
|
||||
return false;
|
||||
|
|
|
@ -51,6 +51,7 @@ struct scrcpy_options {
|
|||
const char *push_target;
|
||||
const char *render_driver;
|
||||
const char *codec_options;
|
||||
const char *ssh_endpoint;
|
||||
enum sc_log_level log_level;
|
||||
enum sc_record_format record_format;
|
||||
struct sc_port_range port_range;
|
||||
|
@ -125,6 +126,7 @@ struct scrcpy_options {
|
|||
.disable_screensaver = false, \
|
||||
.forward_key_repeat = true, \
|
||||
.use_ssh = false, \
|
||||
.ssh_endpoint = NULL, \
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -265,6 +265,7 @@ execute_server(struct server *server, const struct server_params *params) {
|
|||
sprintf(display_id_string, "%"PRIu16, params->display_id);
|
||||
const char *const cmd[] = {
|
||||
"shell",
|
||||
params->use_ssh ? "ANDROID_DATA=/data" : "UNUSED_ENV_VAR=/data",
|
||||
"CLASSPATH=" DEVICE_SERVER_PATH,
|
||||
"app_process",
|
||||
#ifdef SERVER_DEBUGGER
|
||||
|
@ -306,7 +307,10 @@ execute_server(struct server *server, const struct server_params *params) {
|
|||
// Port: 5005
|
||||
// Then click on "Debug"
|
||||
#endif
|
||||
return adb_execute(server->serial, cmd, sizeof(cmd) / sizeof(cmd[0]));
|
||||
if (params->use_ssh)
|
||||
return ssh_execute(params->ssh_endpoint, cmd, sizeof(cmd) / sizeof(cmd[0]));
|
||||
else
|
||||
return adb_execute(server->serial, cmd, sizeof(cmd) / sizeof(cmd[0]));
|
||||
}
|
||||
|
||||
static socket_t
|
||||
|
|
|
@ -48,6 +48,7 @@ struct server_params {
|
|||
enum sc_log_level log_level;
|
||||
const char *crop;
|
||||
const char *codec_options;
|
||||
const char *ssh_endpoint;
|
||||
struct sc_port_range port_range;
|
||||
uint16_t max_size;
|
||||
uint32_t bit_rate;
|
||||
|
@ -58,6 +59,7 @@ struct server_params {
|
|||
bool show_touches;
|
||||
bool stay_awake;
|
||||
bool force_adb_forward;
|
||||
bool use_ssh;
|
||||
};
|
||||
|
||||
// init default values
|
||||
|
|
Loading…
Add table
Reference in a new issue