mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 11:35:57 +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 *record_filename;
|
||||
SDL_bool fullscreen;
|
||||
SDL_bool no_window;
|
||||
SDL_bool help;
|
||||
SDL_bool version;
|
||||
SDL_bool show_touches;
|
||||
|
@ -50,6 +51,11 @@ static void usage(const char *arg0) {
|
|||
" is preserved.\n"
|
||||
" Default is %d%s.\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"
|
||||
" Set the TCP port the client listens on.\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'},
|
||||
{"crop", required_argument, NULL, 'c'},
|
||||
{"fullscreen", no_argument, NULL, 'f'},
|
||||
{"no-window", no_argument, NULL, 'n'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"max-size", required_argument, NULL, 'm'},
|
||||
{"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 },
|
||||
};
|
||||
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) {
|
||||
case 'b':
|
||||
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':
|
||||
args->fullscreen = SDL_TRUE;
|
||||
break;
|
||||
case 'n':
|
||||
args->no_window = SDL_TRUE;
|
||||
break;
|
||||
case 'h':
|
||||
args->help = SDL_TRUE;
|
||||
break;
|
||||
|
@ -324,6 +334,7 @@ int main(int argc, char *argv[]) {
|
|||
.bit_rate = args.bit_rate,
|
||||
.show_touches = args.show_touches,
|
||||
.fullscreen = args.fullscreen,
|
||||
.no_window = args.no_window
|
||||
};
|
||||
int res = scrcpy(&options) ? 0 : 1;
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ static struct controller controller;
|
|||
static struct file_handler file_handler;
|
||||
static struct recorder recorder;
|
||||
|
||||
SDL_bool no_window;
|
||||
|
||||
static struct input_manager input_manager = {
|
||||
.controller = &controller,
|
||||
.frames = &frames,
|
||||
|
@ -80,7 +82,9 @@ static SDL_bool event_loop(void) {
|
|||
if (!screen.has_frame) {
|
||||
screen.has_frame = SDL_TRUE;
|
||||
// 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)) {
|
||||
return SDL_FALSE;
|
||||
|
@ -237,6 +241,8 @@ SDL_bool scrcpy(const struct scrcpy_options *options) {
|
|||
screen_switch_fullscreen(&screen);
|
||||
}
|
||||
|
||||
no_window = options->no_window;
|
||||
|
||||
ret = event_loop();
|
||||
LOGD("quit...");
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ struct scrcpy_options {
|
|||
Uint32 bit_rate;
|
||||
SDL_bool show_touches;
|
||||
SDL_bool fullscreen;
|
||||
SDL_bool no_window;
|
||||
};
|
||||
|
||||
SDL_bool scrcpy(const struct scrcpy_options *options);
|
||||
|
|
Loading…
Add table
Reference in a new issue