mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-04 23:29:22 +00:00
Adding intent broadcasts cli options from the client
This commit is contained in:
parent
eae1c7e5d6
commit
5190bf8289
5 changed files with 69 additions and 0 deletions
|
@ -656,6 +656,51 @@ guess_record_format(const char *filename) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static bool
|
||||||
|
parse_intent_broadcast(const char *s, uint32_t *intents) {
|
||||||
|
|
||||||
|
// if no arg provided activates all intents for all intents and purposes
|
||||||
|
if(!s){
|
||||||
|
*intents = -1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
char *comma = strchr(s, ',');
|
||||||
|
|
||||||
|
assert(!comma || comma > s);
|
||||||
|
size_t limit = comma ? (size_t) (comma - s) : strlen(s);
|
||||||
|
|
||||||
|
|
||||||
|
#define STREQ(literal, s, len) \
|
||||||
|
((sizeof(literal)-1 == len) && !memcmp(literal, s, len))
|
||||||
|
|
||||||
|
if (STREQ("start", s, limit)) {
|
||||||
|
*intents |= SC_INTENT_BROADCAST_START;
|
||||||
|
} else if (STREQ("stop", s, limit)) {
|
||||||
|
*intents |= SC_INTENT_BROADCAST_STOP;
|
||||||
|
} else if (STREQ("cleaned", s, limit)) {
|
||||||
|
*intents |= SC_INTENT_BROADCAST_CLEANED;
|
||||||
|
} else {
|
||||||
|
LOGE("Unknown broadcast intent: %.*s "
|
||||||
|
"(must be one of: start, stop, cleaned)",
|
||||||
|
(int) limit, s);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#undef STREQ
|
||||||
|
|
||||||
|
if (!comma) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = comma + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define OPT_RENDER_EXPIRED_FRAMES 1000
|
#define OPT_RENDER_EXPIRED_FRAMES 1000
|
||||||
#define OPT_WINDOW_TITLE 1001
|
#define OPT_WINDOW_TITLE 1001
|
||||||
#define OPT_PUSH_TARGET 1002
|
#define OPT_PUSH_TARGET 1002
|
||||||
|
@ -684,6 +729,7 @@ guess_record_format(const char *filename) {
|
||||||
#define OPT_ENCODER_NAME 1025
|
#define OPT_ENCODER_NAME 1025
|
||||||
#define OPT_POWER_OFF_ON_CLOSE 1026
|
#define OPT_POWER_OFF_ON_CLOSE 1026
|
||||||
#define OPT_V4L2_SINK 1027
|
#define OPT_V4L2_SINK 1027
|
||||||
|
#define OPT_INTENT_BROADCAST 1028
|
||||||
|
|
||||||
bool
|
bool
|
||||||
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
|
@ -739,6 +785,8 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
OPT_WINDOW_BORDERLESS},
|
OPT_WINDOW_BORDERLESS},
|
||||||
{"power-off-on-close", no_argument, NULL,
|
{"power-off-on-close", no_argument, NULL,
|
||||||
OPT_POWER_OFF_ON_CLOSE},
|
OPT_POWER_OFF_ON_CLOSE},
|
||||||
|
{"intent-broadcast", optional_argument, NULL,
|
||||||
|
OPT_INTENT_BROADCAST},
|
||||||
{NULL, 0, NULL, 0 },
|
{NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -917,6 +965,12 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
||||||
opts->v4l2_device = optarg;
|
opts->v4l2_device = optarg;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
case OPT_INTENT_BROADCAST:
|
||||||
|
if (!parse_intent_broadcast(optarg, &opts->intent_broadcasts)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// getopt prints the error message on stderr
|
// getopt prints the error message on stderr
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -278,6 +278,7 @@ scrcpy(const struct scrcpy_options *options) {
|
||||||
.encoder_name = options->encoder_name,
|
.encoder_name = options->encoder_name,
|
||||||
.force_adb_forward = options->force_adb_forward,
|
.force_adb_forward = options->force_adb_forward,
|
||||||
.power_off_on_close = options->power_off_on_close,
|
.power_off_on_close = options->power_off_on_close,
|
||||||
|
.intent_broadcasts = options->intent_broadcasts,
|
||||||
};
|
};
|
||||||
if (!server_start(&s->server, ¶ms)) {
|
if (!server_start(&s->server, ¶ms)) {
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
@ -53,6 +53,14 @@ struct sc_port_range {
|
||||||
|
|
||||||
#define SC_WINDOW_POSITION_UNDEFINED (-0x8000)
|
#define SC_WINDOW_POSITION_UNDEFINED (-0x8000)
|
||||||
|
|
||||||
|
|
||||||
|
enum sc_intent_broadcast {
|
||||||
|
SC_INTENT_BROADCAST_START = 1 << 0,
|
||||||
|
SC_INTENT_BROADCAST_STOP = 1 << 30,
|
||||||
|
SC_INTENT_BROADCAST_CLEANED = 1 << 31,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct scrcpy_options {
|
struct scrcpy_options {
|
||||||
const char *serial;
|
const char *serial;
|
||||||
const char *crop;
|
const char *crop;
|
||||||
|
@ -93,6 +101,7 @@ struct scrcpy_options {
|
||||||
bool forward_all_clicks;
|
bool forward_all_clicks;
|
||||||
bool legacy_paste;
|
bool legacy_paste;
|
||||||
bool power_off_on_close;
|
bool power_off_on_close;
|
||||||
|
uint32_t intent_broadcasts;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCRCPY_OPTIONS_DEFAULT { \
|
#define SCRCPY_OPTIONS_DEFAULT { \
|
||||||
|
@ -141,6 +150,7 @@ struct scrcpy_options {
|
||||||
.forward_all_clicks = false, \
|
.forward_all_clicks = false, \
|
||||||
.legacy_paste = false, \
|
.legacy_paste = false, \
|
||||||
.power_off_on_close = false, \
|
.power_off_on_close = false, \
|
||||||
|
.intent_broadcasts = 0, \
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -256,11 +256,13 @@ execute_server(struct server *server, const struct server_params *params) {
|
||||||
char max_fps_string[6];
|
char max_fps_string[6];
|
||||||
char lock_video_orientation_string[5];
|
char lock_video_orientation_string[5];
|
||||||
char display_id_string[11];
|
char display_id_string[11];
|
||||||
|
char intent_broadcasts_string[11];
|
||||||
sprintf(max_size_string, "%"PRIu16, params->max_size);
|
sprintf(max_size_string, "%"PRIu16, params->max_size);
|
||||||
sprintf(bit_rate_string, "%"PRIu32, params->bit_rate);
|
sprintf(bit_rate_string, "%"PRIu32, params->bit_rate);
|
||||||
sprintf(max_fps_string, "%"PRIu16, params->max_fps);
|
sprintf(max_fps_string, "%"PRIu16, params->max_fps);
|
||||||
sprintf(lock_video_orientation_string, "%"PRIi8, params->lock_video_orientation);
|
sprintf(lock_video_orientation_string, "%"PRIi8, params->lock_video_orientation);
|
||||||
sprintf(display_id_string, "%"PRIu32, params->display_id);
|
sprintf(display_id_string, "%"PRIu32, params->display_id);
|
||||||
|
sprintf(intent_broadcasts_string, "%"PRIu32, params->intent_broadcasts);
|
||||||
const char *const cmd[] = {
|
const char *const cmd[] = {
|
||||||
"shell",
|
"shell",
|
||||||
"CLASSPATH=" DEVICE_SERVER_PATH,
|
"CLASSPATH=" DEVICE_SERVER_PATH,
|
||||||
|
@ -294,6 +296,7 @@ execute_server(struct server *server, const struct server_params *params) {
|
||||||
params->codec_options ? params->codec_options : "-",
|
params->codec_options ? params->codec_options : "-",
|
||||||
params->encoder_name ? params->encoder_name : "-",
|
params->encoder_name ? params->encoder_name : "-",
|
||||||
params->power_off_on_close ? "true" : "false",
|
params->power_off_on_close ? "true" : "false",
|
||||||
|
intent_broadcasts_string,
|
||||||
};
|
};
|
||||||
#ifdef SERVER_DEBUGGER
|
#ifdef SERVER_DEBUGGER
|
||||||
LOGI("Server debugger waiting for a client on device port "
|
LOGI("Server debugger waiting for a client on device port "
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct server_params {
|
||||||
bool stay_awake;
|
bool stay_awake;
|
||||||
bool force_adb_forward;
|
bool force_adb_forward;
|
||||||
bool power_off_on_close;
|
bool power_off_on_close;
|
||||||
|
uint32_t intent_broadcasts;
|
||||||
};
|
};
|
||||||
|
|
||||||
// init default values
|
// init default values
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue