mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-08-03 14:49:29 +00:00
Added a new option : -n/--no-window
This option allows scrcpy to be run headless : we can now use scrcpy only for screen recording as an example
This commit is contained in:
parent
eea478b9dc
commit
8d4ff03b7f
3 changed files with 20 additions and 2 deletions
|
@ -13,6 +13,7 @@ struct args {
|
||||||
const char *crop;
|
const char *crop;
|
||||||
const char *record_filename;
|
const char *record_filename;
|
||||||
SDL_bool fullscreen;
|
SDL_bool fullscreen;
|
||||||
|
SDL_bool no_window;
|
||||||
SDL_bool help;
|
SDL_bool help;
|
||||||
SDL_bool version;
|
SDL_bool version;
|
||||||
SDL_bool show_touches;
|
SDL_bool show_touches;
|
||||||
|
@ -50,6 +51,11 @@ static void usage(const char *arg0) {
|
||||||
" is preserved.\n"
|
" is preserved.\n"
|
||||||
" Default is %d%s.\n"
|
" Default is %d%s.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
" -n, --no-window\n"
|
||||||
|
" Do not show window. This is useful, as an example\n"
|
||||||
|
" combined with -r/--record option to record screen without displaying\n"
|
||||||
|
" video feedback\n"
|
||||||
|
"\n"
|
||||||
" -p, --port port\n"
|
" -p, --port port\n"
|
||||||
" Set the TCP port the client listens on.\n"
|
" Set the TCP port the client listens on.\n"
|
||||||
" Default is %d.\n"
|
" Default is %d.\n"
|
||||||
|
@ -209,6 +215,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
{"bit-rate", required_argument, NULL, 'b'},
|
{"bit-rate", required_argument, NULL, 'b'},
|
||||||
{"crop", required_argument, NULL, 'c'},
|
{"crop", required_argument, NULL, 'c'},
|
||||||
{"fullscreen", no_argument, NULL, 'f'},
|
{"fullscreen", no_argument, NULL, 'f'},
|
||||||
|
{"no-window", no_argument, NULL, 'n'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"max-size", required_argument, NULL, 'm'},
|
{"max-size", required_argument, NULL, 'm'},
|
||||||
{"port", required_argument, NULL, 'p'},
|
{"port", required_argument, NULL, 'p'},
|
||||||
|
@ -219,7 +226,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
{NULL, 0, NULL, 0 },
|
{NULL, 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt_long(argc, argv, "b:c:fhm:p:r:s:tv", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "b:c:fnhm:p:r:s:tv", long_options, NULL)) != -1) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'b':
|
case 'b':
|
||||||
if (!parse_bit_rate(optarg, &args->bit_rate)) {
|
if (!parse_bit_rate(optarg, &args->bit_rate)) {
|
||||||
|
@ -232,6 +239,9 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
case 'f':
|
case 'f':
|
||||||
args->fullscreen = SDL_TRUE;
|
args->fullscreen = SDL_TRUE;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
args->no_window = SDL_TRUE;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
args->help = SDL_TRUE;
|
args->help = SDL_TRUE;
|
||||||
break;
|
break;
|
||||||
|
@ -324,6 +334,7 @@ int main(int argc, char *argv[]) {
|
||||||
.bit_rate = args.bit_rate,
|
.bit_rate = args.bit_rate,
|
||||||
.show_touches = args.show_touches,
|
.show_touches = args.show_touches,
|
||||||
.fullscreen = args.fullscreen,
|
.fullscreen = args.fullscreen,
|
||||||
|
.no_window = args.no_window
|
||||||
};
|
};
|
||||||
int res = scrcpy(&options) ? 0 : 1;
|
int res = scrcpy(&options) ? 0 : 1;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ static struct controller controller;
|
||||||
static struct file_handler file_handler;
|
static struct file_handler file_handler;
|
||||||
static struct recorder recorder;
|
static struct recorder recorder;
|
||||||
|
|
||||||
|
SDL_bool no_window;
|
||||||
|
|
||||||
static struct input_manager input_manager = {
|
static struct input_manager input_manager = {
|
||||||
.controller = &controller,
|
.controller = &controller,
|
||||||
.frames = &frames,
|
.frames = &frames,
|
||||||
|
@ -80,7 +82,9 @@ static SDL_bool event_loop(void) {
|
||||||
if (!screen.has_frame) {
|
if (!screen.has_frame) {
|
||||||
screen.has_frame = SDL_TRUE;
|
screen.has_frame = SDL_TRUE;
|
||||||
// this is the very first frame, show the window
|
// this is the very first frame, show the window
|
||||||
screen_show_window(&screen);
|
if (!no_window) {
|
||||||
|
screen_show_window(&screen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!screen_update_frame(&screen, &frames)) {
|
if (!screen_update_frame(&screen, &frames)) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
|
@ -237,6 +241,8 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
|
||||||
screen_switch_fullscreen(&screen);
|
screen_switch_fullscreen(&screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
no_window = options->no_window;
|
||||||
|
|
||||||
ret = event_loop();
|
ret = event_loop();
|
||||||
LOGD("quit...");
|
LOGD("quit...");
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ struct scrcpy_options {
|
||||||
Uint32 bit_rate;
|
Uint32 bit_rate;
|
||||||
SDL_bool show_touches;
|
SDL_bool show_touches;
|
||||||
SDL_bool fullscreen;
|
SDL_bool fullscreen;
|
||||||
|
SDL_bool no_window;
|
||||||
};
|
};
|
||||||
|
|
||||||
SDL_bool scrcpy(const struct scrcpy_options *options);
|
SDL_bool scrcpy(const struct scrcpy_options *options);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue