From e694619d53d1f38ed02b269be1649c7a67a11916 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Wed, 22 Feb 2023 22:44:01 +0100 Subject: [PATCH] Rename --encoder to --video-encoder This prepares the introduction of --audio-encoder. PR #3757 --- README.md | 6 ++--- app/data/bash-completion/scrcpy | 2 +- app/data/zsh-completion/_scrcpy | 2 +- app/scrcpy.1 | 8 +++---- app/src/cli.c | 22 ++++++++++++++----- app/src/options.c | 2 +- app/src/options.h | 2 +- app/src/scrcpy.c | 2 +- app/src/server.c | 8 +++---- app/src/server.h | 2 +- .../java/com/genymobile/scrcpy/Options.java | 10 ++++----- .../java/com/genymobile/scrcpy/Server.java | 6 ++--- 12 files changed, 41 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 81371b92..8eabafa9 100644 --- a/README.md +++ b/README.md @@ -270,15 +270,15 @@ Some devices have more than one encoder for a specific codec, and some of them may cause issues or crash. It is possible to select a different encoder: ```bash -scrcpy --encoder=OMX.qcom.video.encoder.avc +scrcpy --video-encoder=OMX.qcom.video.encoder.avc ``` To list the available encoders, you can pass an invalid encoder name; the error will give the available encoders: ```bash -scrcpy --encoder=_ # for the default codec -scrcpy --video-codec=h265 --encoder=_ # for a specific codec +scrcpy --video-encoder=_ # for the default codec +scrcpy --video-codec=h265 --video-encoder=_ # for a specific codec ``` ### Capture diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpy index 167f736f..450bd32d 100644 --- a/app/data/bash-completion/scrcpy +++ b/app/data/bash-completion/scrcpy @@ -9,7 +9,6 @@ _scrcpy() { --display= --display-buffer= -e --select-tcpip - --encoder= --force-adb-forward --forward-all-clicks -f --fullscreen @@ -55,6 +54,7 @@ _scrcpy() { -v --version --video-codec= --video-codec-options= + --video-encoder= -w --stay-awake --window-borderless --window-title= diff --git a/app/data/zsh-completion/_scrcpy b/app/data/zsh-completion/_scrcpy index 29bec42d..86d9ffbf 100644 --- a/app/data/zsh-completion/_scrcpy +++ b/app/data/zsh-completion/_scrcpy @@ -16,7 +16,6 @@ arguments=( '--display=[Specify the display id to mirror]' '--display-buffer=[Add a buffering delay \(in milliseconds\) before displaying]' {-e,--select-tcpip}'[Use TCP/IP device]' - '--encoder=[Use a specific MediaCodec encoder]' '--force-adb-forward[Do not attempt to use \"adb reverse\" to connect to the device]' '--forward-all-clicks[Forward clicks to device]' {-f,--fullscreen}'[Start in fullscreen]' @@ -60,6 +59,7 @@ arguments=( {-v,--version}'[Print the version of scrcpy]' '--video-codec=[Select the video codec]:codec:(h264 h265 av1)' '--video-codec-options=[Set a list of comma-separated key\:type=value options for the device video encoder]' + '--video-encoder=[Use a specific MediaCodec video encoder]' {-w,--stay-awake}'[Keep the device on while scrcpy is running, when the device is plugged in]' '--window-borderless[Disable window decorations \(display borderless window\)]' '--window-title=[Set a custom window title]' diff --git a/app/scrcpy.1 b/app/scrcpy.1 index 49d05a14..34bb750e 100644 --- a/app/scrcpy.1 +++ b/app/scrcpy.1 @@ -64,10 +64,6 @@ Use TCP/IP device (if there is exactly one, like adb -e). Also see \fB\-d\fR (\fB\-\-select\-usb\fR). -.TP -.BI "\-\-encoder " name -Use a specific MediaCodec encoder (depending on the codec provided by \fB\-\-video\-codec\fR). - .TP .B \-\-force\-adb\-forward Do not attempt to use "adb reverse" to connect to the device. @@ -329,6 +325,10 @@ The list of possible codec options is available in the Android documentation .UR https://d.android.com/reference/android/media/MediaFormat .UE . +.TP +.BI "\-\-video\-encoder " name +Use a specific MediaCodec video encoder (depending on the codec provided by \fB\-\-video\-codec\fR). + .TP .B \-w, \-\-stay-awake Keep the device on while scrcpy is running, when the device is plugged in. diff --git a/app/src/cli.c b/app/src/cli.c index cb1af46e..685c2f3d 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -45,7 +45,8 @@ enum { OPT_NO_KEY_REPEAT, OPT_FORWARD_ALL_CLICKS, OPT_LEGACY_PASTE, - OPT_ENCODER_NAME, + OPT_ENCODER, + OPT_VIDEO_ENCODER, OPT_POWER_OFF_ON_CLOSE, OPT_V4L2_SINK, OPT_DISPLAY_BUFFER, @@ -178,11 +179,10 @@ static const struct sc_option options[] = { "Also see -d (--select-usb).", }, { - .longopt_id = OPT_ENCODER_NAME, + // deprecated + .longopt_id = OPT_ENCODER, .longopt = "encoder", .argdesc = "name", - .text = "Use a specific MediaCodec encoder (depending on the codec " - "provided by --video-codec).", }, { .longopt_id = OPT_FORCE_ADB_FORWARD, @@ -543,6 +543,13 @@ static const struct sc_option options[] = { "Android documentation: " "", }, + { + .longopt_id = OPT_VIDEO_ENCODER, + .longopt = "video-encoder", + .argdesc = "name", + .text = "Use a specific MediaCodec video encoder (depending on the " + "codec provided by --video-codec).", + }, { .shortopt = 'w', .longopt = "stay-awake", @@ -1629,8 +1636,11 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], case OPT_VIDEO_CODEC_OPTIONS: opts->video_codec_options = optarg; break; - case OPT_ENCODER_NAME: - opts->encoder_name = optarg; + case OPT_ENCODER: + LOGW("--encoder is deprecated, use --video-encoder instead."); + // fall through + case OPT_VIDEO_ENCODER: + opts->video_encoder = optarg; break; case OPT_FORCE_ADB_FORWARD: opts->force_adb_forward = true; diff --git a/app/src/options.c b/app/src/options.c index 0547da1b..fa025dea 100644 --- a/app/src/options.c +++ b/app/src/options.c @@ -8,7 +8,7 @@ const struct scrcpy_options scrcpy_options_default = { .push_target = NULL, .render_driver = NULL, .video_codec_options = NULL, - .encoder_name = NULL, + .video_encoder = NULL, #ifdef HAVE_V4L2 .v4l2_device = NULL, #endif diff --git a/app/src/options.h b/app/src/options.h index bde79687..3c602b7e 100644 --- a/app/src/options.h +++ b/app/src/options.h @@ -94,7 +94,7 @@ struct scrcpy_options { const char *push_target; const char *render_driver; const char *video_codec_options; - const char *encoder_name; + const char *video_encoder; #ifdef HAVE_V4L2 const char *v4l2_device; #endif diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index 2bb5794c..776f5d13 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -329,7 +329,7 @@ scrcpy(struct scrcpy_options *options) { .show_touches = options->show_touches, .stay_awake = options->stay_awake, .video_codec_options = options->video_codec_options, - .encoder_name = options->encoder_name, + .video_encoder = options->video_encoder, .force_adb_forward = options->force_adb_forward, .power_off_on_close = options->power_off_on_close, .clipboard_autosync = options->clipboard_autosync, diff --git a/app/src/server.c b/app/src/server.c index eb91b2b2..583c338e 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -72,7 +72,7 @@ sc_server_params_destroy(struct sc_server_params *params) { free((char *) params->req_serial); free((char *) params->crop); free((char *) params->video_codec_options); - free((char *) params->encoder_name); + free((char *) params->video_encoder); free((char *) params->tcpip_dst); } @@ -96,7 +96,7 @@ sc_server_params_copy(struct sc_server_params *dst, COPY(req_serial); COPY(crop); COPY(video_codec_options); - COPY(encoder_name); + COPY(video_encoder); COPY(tcpip_dst); #undef COPY @@ -258,8 +258,8 @@ execute_server(struct sc_server *server, if (params->video_codec_options) { ADD_PARAM("video_codec_options=%s", params->video_codec_options); } - if (params->encoder_name) { - ADD_PARAM("encoder_name=%s", params->encoder_name); + if (params->video_encoder) { + ADD_PARAM("video_encoder=%s", params->video_encoder); } if (params->power_off_on_close) { ADD_PARAM("power_off_on_close=true"); diff --git a/app/src/server.h b/app/src/server.h index 352d2cae..97c9aea2 100644 --- a/app/src/server.h +++ b/app/src/server.h @@ -28,7 +28,7 @@ struct sc_server_params { enum sc_codec video_codec; const char *crop; const char *video_codec_options; - const char *encoder_name; + const char *video_encoder; struct sc_port_range port_range; uint32_t tunnel_host; uint16_t tunnel_port; diff --git a/server/src/main/java/com/genymobile/scrcpy/Options.java b/server/src/main/java/com/genymobile/scrcpy/Options.java index 9cfb7871..c518bf07 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Options.java +++ b/server/src/main/java/com/genymobile/scrcpy/Options.java @@ -21,7 +21,7 @@ public class Options { private boolean showTouches; private boolean stayAwake; private List videoCodecOptions; - private String encoderName; + private String videoEncoder; private boolean powerOffScreenOnClose; private boolean clipboardAutosync = true; private boolean downsizeOnError = true; @@ -154,12 +154,12 @@ public class Options { this.videoCodecOptions = videoCodecOptions; } - public String getEncoderName() { - return encoderName; + public String getVideoEncoder() { + return videoEncoder; } - public void setEncoderName(String encoderName) { - this.encoderName = encoderName; + public void setVideoEncoder(String videoEncoder) { + this.videoEncoder = videoEncoder; } public void setPowerOffScreenOnClose(boolean powerOffScreenOnClose) { diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java index 4ff938b4..b809e90f 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Server.java +++ b/server/src/main/java/com/genymobile/scrcpy/Server.java @@ -117,7 +117,7 @@ public final class Server { Streamer videoStreamer = new Streamer(connection.getVideoFd(), options.getVideoCodec(), options.getSendCodecId(), options.getSendFrameMeta()); ScreenEncoder screenEncoder = new ScreenEncoder(device, videoStreamer, options.getVideoBitRate(), options.getMaxFps(), - options.getVideoCodecOptions(), options.getEncoderName(), options.getDownsizeOnError()); + options.getVideoCodecOptions(), options.getVideoEncoder(), options.getDownsizeOnError()); try { // synchronous screenEncoder.streamScreen(); @@ -245,9 +245,9 @@ public final class Server { List videoCodecOptions = CodecOption.parse(value); options.setVideoCodecOptions(videoCodecOptions); break; - case "encoder_name": + case "video_encoder": if (!value.isEmpty()) { - options.setEncoderName(value); + options.setVideoEncoder(value); } break; case "power_off_on_close":