Add a new option: -n/--no-window
This option will allow scrcpy to record the stream without display. Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
parent
e6e011baaf
commit
421a1141e2
3 changed files with 23 additions and 1 deletions
|
@ -16,6 +16,7 @@ struct args {
|
||||||
const char *record_filename;
|
const char *record_filename;
|
||||||
enum recorder_format record_format;
|
enum recorder_format record_format;
|
||||||
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;
|
||||||
|
@ -57,6 +58,9 @@ 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 (only when screen recording is enabled).\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"
|
||||||
|
@ -260,6 +264,7 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
{"fullscreen", no_argument, NULL, 'f'},
|
{"fullscreen", no_argument, NULL, 'f'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"max-size", required_argument, NULL, 'm'},
|
{"max-size", required_argument, NULL, 'm'},
|
||||||
|
{"no-window", no_argument, NULL, 'n'},
|
||||||
{"port", required_argument, NULL, 'p'},
|
{"port", required_argument, NULL, 'p'},
|
||||||
{"record", required_argument, NULL, 'r'},
|
{"record", required_argument, NULL, 'r'},
|
||||||
{"record-format", required_argument, NULL, 'f'},
|
{"record-format", required_argument, NULL, 'f'},
|
||||||
|
@ -269,7 +274,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:fF:hm:p:r:s:tTv", long_options, NULL)) != -1) {
|
while ((c = getopt_long(argc, argv, "b:c:fF:hm:np:r:s:tTv", 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)) {
|
||||||
|
@ -295,6 +300,9 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
args->no_window = SDL_TRUE;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
if (!parse_port(optarg, &args->port)) {
|
if (!parse_port(optarg, &args->port)) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
|
@ -321,6 +329,16 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args->no_window && !args->record_filename) {
|
||||||
|
LOGE("-n/--no-window requires screen recording (-r/--record)");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args->no_window && args->fullscreen) {
|
||||||
|
LOGE("-f/--fullscreen-window is incompatible with -n/--no-window");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int index = optind;
|
int index = optind;
|
||||||
if (index < argc) {
|
if (index < argc) {
|
||||||
LOGE("Unexpected additional argument: %s", argv[index]);
|
LOGE("Unexpected additional argument: %s", argv[index]);
|
||||||
|
@ -401,6 +419,7 @@ int main(int argc, char *argv[]) {
|
||||||
.show_touches = args.show_touches,
|
.show_touches = args.show_touches,
|
||||||
.fullscreen = args.fullscreen,
|
.fullscreen = args.fullscreen,
|
||||||
.always_on_top = args.always_on_top,
|
.always_on_top = args.always_on_top,
|
||||||
|
.no_window = args.no_window,
|
||||||
};
|
};
|
||||||
int res = scrcpy(&options) ? 0 : 1;
|
int res = scrcpy(&options) ? 0 : 1;
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ struct scrcpy_options {
|
||||||
SDL_bool show_touches;
|
SDL_bool show_touches;
|
||||||
SDL_bool fullscreen;
|
SDL_bool fullscreen;
|
||||||
SDL_bool always_on_top;
|
SDL_bool always_on_top;
|
||||||
|
SDL_bool no_window;
|
||||||
};
|
};
|
||||||
|
|
||||||
SDL_bool scrcpy(const struct scrcpy_options *options);
|
SDL_bool scrcpy(const struct scrcpy_options *options);
|
||||||
|
|
|
@ -17,6 +17,7 @@ struct screen {
|
||||||
struct size windowed_window_size;
|
struct size windowed_window_size;
|
||||||
SDL_bool has_frame;
|
SDL_bool has_frame;
|
||||||
SDL_bool fullscreen;
|
SDL_bool fullscreen;
|
||||||
|
SDL_bool no_window;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCREEN_INITIALIZER { \
|
#define SCREEN_INITIALIZER { \
|
||||||
|
@ -33,6 +34,7 @@ struct screen {
|
||||||
}, \
|
}, \
|
||||||
.has_frame = SDL_FALSE, \
|
.has_frame = SDL_FALSE, \
|
||||||
.fullscreen = SDL_FALSE, \
|
.fullscreen = SDL_FALSE, \
|
||||||
|
.no_window = SDL_FALSE, \
|
||||||
}
|
}
|
||||||
|
|
||||||
// init SDL and set appropriate hints
|
// init SDL and set appropriate hints
|
||||||
|
|
Loading…
Reference in a new issue