Rename --encoder to --video-encoder

This prepares the introduction of --audio-encoder.

PR #3757 <https://github.com/Genymobile/scrcpy/pull/3757>
This commit is contained in:
Romain Vimont 2023-02-22 22:44:01 +01:00
parent 31555fa530
commit e694619d53
12 changed files with 41 additions and 31 deletions

View file

@ -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

View file

@ -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=

View file

@ -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]'

View file

@ -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.

View file

@ -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: "
"<https://d.android.com/reference/android/media/MediaFormat>",
},
{
.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;

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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");

View file

@ -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;

View file

@ -21,7 +21,7 @@ public class Options {
private boolean showTouches;
private boolean stayAwake;
private List<CodecOption> 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) {

View file

@ -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<CodecOption> 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":