Rename --codec to --video-codec

This prepares the introduction of --audio-codec.
This commit is contained in:
Romain Vimont 2023-02-20 21:19:36 +01:00
commit 7581dc10d3
13 changed files with 56 additions and 42 deletions

View file

@ -10,7 +10,7 @@ public class Options {
private int scid = -1; // 31-bit non-negative value, or -1
private boolean audio = true;
private int maxSize;
private VideoCodec codec = VideoCodec.H264;
private VideoCodec videoCodec = VideoCodec.H264;
private int bitRate = 8000000;
private int maxFps;
private int lockVideoOrientation = -1;
@ -66,12 +66,12 @@ public class Options {
this.maxSize = maxSize;
}
public VideoCodec getCodec() {
return codec;
public VideoCodec getVideoCodec() {
return videoCodec;
}
public void setCodec(VideoCodec codec) {
this.codec = codec;
public void setVideoCodec(VideoCodec videoCodec) {
this.videoCodec = videoCodec;
}
public int getBitRate() {

View file

@ -231,7 +231,7 @@ public class ScreenEncoder implements Device.RotationListener {
if (encoders != null && encoders.length > 0) {
msg.append("\nTry to use one of the available encoders:");
for (MediaCodecInfo encoder : encoders) {
msg.append("\n scrcpy --codec=").append(codec.getName()).append(" --encoder='").append(encoder.getName()).append("'");
msg.append("\n scrcpy --video-codec=").append(codec.getName()).append(" --encoder='").append(encoder.getName()).append("'");
}
}
return msg.toString();

View file

@ -96,7 +96,6 @@ public final class Server {
AudioEncoder audioEncoder = null;
try (DesktopConnection connection = DesktopConnection.open(scid, tunnelForward, audio, control, sendDummyByte)) {
VideoCodec codec = options.getCodec();
if (options.getSendDeviceMeta()) {
Size videoSize = device.getScreenInfo().getVideoSize();
connection.sendDeviceMeta(Device.getDeviceName(), videoSize.getWidth(), videoSize.getHeight());
@ -116,9 +115,10 @@ public final class Server {
audioEncoder.start();
}
Streamer videoStreamer = new Streamer(connection.getVideoFd(), codec, options.getSendCodecId(), options.getSendFrameMeta());
ScreenEncoder screenEncoder = new ScreenEncoder(device, videoStreamer, options.getBitRate(), options.getMaxFps(),
codecOptions, options.getEncoderName(), options.getDownsizeOnError());
Streamer videoStreamer = new Streamer(connection.getVideoFd(), options.getVideoCodec(), options.getSendCodecId(),
options.getSendFrameMeta());
ScreenEncoder screenEncoder = new ScreenEncoder(device, videoStreamer, options.getBitRate(), options.getMaxFps(), codecOptions,
options.getEncoderName(), options.getDownsizeOnError());
try {
// synchronous
screenEncoder.streamScreen();
@ -195,12 +195,12 @@ public final class Server {
boolean audio = Boolean.parseBoolean(value);
options.setAudio(audio);
break;
case "codec":
VideoCodec codec = VideoCodec.findByName(value);
if (codec == null) {
case "video_codec":
VideoCodec videoCodec = VideoCodec.findByName(value);
if (videoCodec == null) {
throw new IllegalArgumentException("Video codec " + value + " not supported");
}
options.setCodec(codec);
options.setVideoCodec(videoCodec);
break;
case "max_size":
int maxSize = Integer.parseInt(value) & ~7; // multiple of 8