From a2c89100065f684dcf8859be4ea5274a7e6d5b26 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 24 May 2023 20:22:35 +0200 Subject: [PATCH] Rename --no-mirror to --no-playback This option impacts video and audio _playback_. For example, if we use V4L2, the device is still "mirrored" (via V4L2), even if playback is disabled. Therefore, "playback" is more approriate than "mirror". The initial option --no-display option was renamed to --no-mirror by commit 6928acdeac29eee404a7c7014654965ef5128b88, but this has never been released, so it is ok to rename it one more time. Refs #3978 PR #4033 --- app/data/bash-completion/scrcpy | 2 +- app/data/zsh-completion/_scrcpy | 2 +- app/scrcpy.1 | 4 ++-- app/src/cli.c | 27 +++++++++++++-------------- app/src/options.c | 2 +- app/src/options.h | 2 +- app/src/scrcpy.c | 18 +++++++++--------- app/tests/test_cli.c | 8 ++++---- doc/recording.md | 4 ++-- doc/v4l2.md | 2 +- doc/video.md | 8 ++++---- 11 files changed, 39 insertions(+), 40 deletions(-) diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpy index cdc9270f..dccb68e5 100644 --- a/app/data/bash-completion/scrcpy +++ b/app/data/bash-completion/scrcpy @@ -33,7 +33,7 @@ _scrcpy() { --no-clipboard-autosync --no-downsize-on-error -n --no-control - -N --no-mirror + -N --no-playback --no-key-repeat --no-mipmaps --no-power-on diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpy index 5e40b2fb..afc6b1e6 100644 --- a/app/data/zsh-completion/_scrcpy +++ b/app/data/zsh-completion/_scrcpy @@ -39,7 +39,7 @@ arguments=( '--no-clipboard-autosync[Disable automatic clipboard synchronization]' '--no-downsize-on-error[Disable lowering definition on MediaCodec error]' {-n,--no-control}'[Disable device control \(mirror the device in read only\)]' - {-N,--no-mirror}'[Do not mirror device \(only when recording or V4L2 sink is enabled\)]' + {-N,--no-playback}'[Disable video and audio playback]' '--no-key-repeat[Do not forward repeated key events when a key is held down]' '--no-mipmaps[Disable the generation of mipmaps]' '--no-power-on[Do not power on the device on start]' diff --git a/app/scrcpy.1 b/app/scrcpy.1 index 29d14b58..a622d22b 100644 --- a/app/scrcpy.1 +++ b/app/scrcpy.1 @@ -210,8 +210,8 @@ This option disables this behavior. Disable device control (mirror the device in read\-only). .TP -.B \-N, \-\-no\-mirror -Do not mirror device video or audio on the computer (only when recording or V4L2 sink is enabled). +.B \-N, \-\-no\-playback +Disable video and audio playback on the computer. .TP .B \-\-no\-key\-repeat diff --git a/app/src/cli.c b/app/src/cli.c index e5b18277..dbf774a8 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -382,9 +382,8 @@ static const struct sc_option options[] = { }, { .shortopt = 'N', - .longopt = "no-mirror", - .text = "Do not mirror device video or audio on the computer (only " - "when recording or V4L2 sink is enabled).", + .longopt = "no-playback", + .text = "Disable video and audio playback on the computer.", }, { // deprecated @@ -1671,10 +1670,10 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], opts->control = false; break; case OPT_NO_DISPLAY: - LOGW("--no-display is deprecated, use --no-mirror instead."); + LOGW("--no-display is deprecated, use --no-playback instead."); // fall through case 'N': - opts->mirror = false; + opts->playback = false; break; case 'p': if (!parse_port_range(optarg, &opts->port_range)) { @@ -1924,8 +1923,8 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], } #ifdef HAVE_V4L2 - if (!opts->mirror && !opts->record_filename && !opts->v4l2_device) { - LOGE("-N/--no-mirror requires either screen recording (-r/--record)" + if (!opts->playback && !opts->record_filename && !opts->v4l2_device) { + LOGE("-N/--no-playback requires either screen recording (-r/--record)" " or sink to v4l2loopback device (--v4l2-sink)"); return false; } @@ -1949,14 +1948,14 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], return false; } #else - if (!opts->mirror && !opts->record_filename) { - LOGE("-N/--no-mirror requires screen recording (-r/--record)"); + if (!opts->playback && !opts->record_filename) { + LOGE("-N/--no-playback requires screen recording (-r/--record)"); return false; } #endif - if (opts->audio && !opts->mirror && !opts->record_filename) { - LOGI("No mirror and no recording: audio disabled"); + if (opts->audio && !opts->playback && !opts->record_filename) { + LOGI("No playback and no recording: audio disabled"); opts->audio = false; } @@ -2089,11 +2088,11 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], #endif #ifdef HAVE_USB - if (!(opts->mirror && opts->video) && !opts->otg) { + if (!(opts->playback && opts->video) && !opts->otg) { #else - if (!(opts->mirror && opts->video)) { + if (!(opts->playback && opts->video)) { #endif - // If video mirroring is disabled and OTG are disabled, then there is + // If video playback is disabled and OTG are disabled, then there is // no way to control the device. opts->control = false; } diff --git a/app/src/options.c b/app/src/options.c index 12283952..b021921f 100644 --- a/app/src/options.c +++ b/app/src/options.c @@ -52,7 +52,7 @@ const struct scrcpy_options scrcpy_options_default = { .fullscreen = false, .always_on_top = false, .control = true, - .mirror = true, + .playback = true, .turn_screen_off = false, .key_inject_mode = SC_KEY_INJECT_MODE_MIXED, .window_borderless = false, diff --git a/app/src/options.h b/app/src/options.h index 7c442149..0c886de0 100644 --- a/app/src/options.h +++ b/app/src/options.h @@ -147,7 +147,7 @@ struct scrcpy_options { bool fullscreen; bool always_on_top; bool control; - bool mirror; + bool playback; bool turn_screen_off; enum sc_key_inject_mode key_inject_mode; bool window_borderless; diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 39a2f1a4..3334f57d 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -137,7 +137,7 @@ sdl_set_hints(const char *render_driver) { } static void -sdl_configure(bool mirror, bool disable_screensaver) { +sdl_configure(bool playback, bool disable_screensaver) { #ifdef _WIN32 // Clean up properly on Ctrl+C on Windows bool ok = SetConsoleCtrlHandler(windows_ctrl_handler, TRUE); @@ -146,7 +146,7 @@ sdl_configure(bool mirror, bool disable_screensaver) { } #endif // _WIN32 - if (!mirror) { + if (!playback) { return; } @@ -386,10 +386,10 @@ scrcpy(struct scrcpy_options *options) { goto end; } - if (options->mirror) { + if (options->playback) { sdl_set_hints(options->render_driver); - // Initialize SDL video and audio in addition if mirroring is enabled + // Initialize SDL video and audio in addition if playback is enabled if (options->video && SDL_Init(SDL_INIT_VIDEO)) { LOGE("Could not initialize SDL video: %s", SDL_GetError()); goto end; @@ -401,7 +401,7 @@ scrcpy(struct scrcpy_options *options) { } } - sdl_configure(options->mirror, options->disable_screensaver); + sdl_configure(options->playback, options->disable_screensaver); // Await for server without blocking Ctrl+C handling bool connected; @@ -427,7 +427,7 @@ scrcpy(struct scrcpy_options *options) { struct sc_file_pusher *fp = NULL; - assert(!options->control || options->mirror); // control implies mirror + assert(!options->control || options->playback); // control implies playback if (options->control) { if (!sc_file_pusher_init(&s->file_pusher, serial, options->push_target)) { @@ -453,8 +453,8 @@ scrcpy(struct scrcpy_options *options) { &audio_demuxer_cbs, options); } - bool needs_video_decoder = options->mirror && options->video; - bool needs_audio_decoder = options->mirror && options->audio; + bool needs_video_decoder = options->playback && options->video; + bool needs_audio_decoder = options->playback && options->audio; #ifdef HAVE_V4L2 needs_video_decoder |= !!options->v4l2_device; #endif @@ -650,7 +650,7 @@ aoa_hid_end: // There is a controller if and only if control is enabled assert(options->control == !!controller); - if (options->mirror) { + if (options->playback) { const char *window_title = options->window_title ? options->window_title : info->device_name; diff --git a/app/tests/test_cli.c b/app/tests/test_cli.c index 1f00cb90..ec1a9531 100644 --- a/app/tests/test_cli.c +++ b/app/tests/test_cli.c @@ -53,7 +53,7 @@ static void test_options(void) { "--max-size", "1024", "--lock-video-orientation=2", // optional arguments require '=' // "--no-control" is not compatible with "--turn-screen-off" - // "--no-mirror" is not compatible with "--fulscreen" + // "--no-playback" is not compatible with "--fulscreen" "--port", "1234:1236", "--push-target", "/sdcard/Movies", "--record", "file", @@ -108,8 +108,8 @@ static void test_options2(void) { char *argv[] = { "scrcpy", "--no-control", - "--no-mirror", - "--record", "file.mp4", // cannot enable --no-mirror without recording + "--no-playback", + "--record", "file.mp4", // cannot enable --no-playback without recording }; bool ok = scrcpy_parse_args(&args, ARRAY_LEN(argv), argv); @@ -117,7 +117,7 @@ static void test_options2(void) { const struct scrcpy_options *opts = &args.opts; assert(!opts->control); - assert(!opts->mirror); + assert(!opts->playback); assert(!strcmp(opts->record_filename, "file.mp4")); assert(opts->record_format == SC_RECORD_FORMAT_MP4); } diff --git a/doc/recording.md b/doc/recording.md index 7d66f2ff..6f721062 100644 --- a/doc/recording.md +++ b/doc/recording.md @@ -21,10 +21,10 @@ scrcpy --no-video --audio-codec=aac --record-file=file.aac # .m4a/.mp4 and .mka/.mkv are also supported for both opus and aac ``` -To disable mirroring while recording: +To disable playback while recording: ```bash -scrcpy --no-mirror --record=file.mp4 +scrcpy --no-playback --record=file.mp4 scrcpy -Nr file.mkv # interrupt recording with Ctrl+C ``` diff --git a/doc/v4l2.md b/doc/v4l2.md index 2c6e2cfc..62480478 100644 --- a/doc/v4l2.md +++ b/doc/v4l2.md @@ -35,7 +35,7 @@ To start `scrcpy` using a v4l2 sink: ```bash scrcpy --v4l2-sink=/dev/videoN -scrcpy --v4l2-sink=/dev/videoN --no-mirror # disable mirroring window +scrcpy --v4l2-sink=/dev/videoN --no-playback # disable playback window ``` (replace `N` with the device ID, check with `ls /dev/video*`) diff --git a/doc/video.md b/doc/video.md index 303d9048..757d9324 100644 --- a/doc/video.md +++ b/doc/video.md @@ -159,15 +159,15 @@ scrcpy --display-buffer=50 --v4l2-buffer=300 ``` -## No mirror +## No playback -It is possible to capture an Android device without displaying a mirroring +It is possible to capture an Android device without displaying a playback window. This option is available if either [recording](recording.md) or [v4l2](#video4linux) is enabled: ```bash -scrcpy --v4l2-sink=/dev/video2 --no-mirror -scrcpy --record=file.mkv --no-mirror +scrcpy --v4l2-sink=/dev/video2 --no-playback +scrcpy --record=file.mkv --no-playback ```