Parse codec options early

For consistency with other options, parse the codec options on the
server before storing them in the Options instance.
This commit is contained in:
Romain Vimont 2021-11-24 21:06:02 +01:00
parent 5434ea543c
commit 2c3099e2de
2 changed files with 7 additions and 5 deletions

View file

@ -2,6 +2,8 @@ package com.genymobile.scrcpy;
import android.graphics.Rect; import android.graphics.Rect;
import java.util.List;
public class Options { public class Options {
private Ln.Level logLevel; private Ln.Level logLevel;
private int maxSize; private int maxSize;
@ -15,7 +17,7 @@ public class Options {
private int displayId; private int displayId;
private boolean showTouches; private boolean showTouches;
private boolean stayAwake; private boolean stayAwake;
private String codecOptions; private List<CodecOption> codecOptions;
private String encoderName; private String encoderName;
private boolean powerOffScreenOnClose; private boolean powerOffScreenOnClose;
private boolean clipboardAutosync; private boolean clipboardAutosync;
@ -116,11 +118,11 @@ public class Options {
this.stayAwake = stayAwake; this.stayAwake = stayAwake;
} }
public String getCodecOptions() { public List<CodecOption> getCodecOptions() {
return codecOptions; return codecOptions;
} }
public void setCodecOptions(String codecOptions) { public void setCodecOptions(List<CodecOption> codecOptions) {
this.codecOptions = codecOptions; this.codecOptions = codecOptions;
} }

View file

@ -61,7 +61,7 @@ public final class Server {
private static void scrcpy(Options options) throws IOException { private static void scrcpy(Options options) throws IOException {
Ln.i("Device: " + Build.MANUFACTURER + " " + Build.MODEL + " (Android " + Build.VERSION.RELEASE + ")"); Ln.i("Device: " + Build.MANUFACTURER + " " + Build.MODEL + " (Android " + Build.VERSION.RELEASE + ")");
final Device device = new Device(options); final Device device = new Device(options);
List<CodecOption> codecOptions = CodecOption.parse(options.getCodecOptions()); List<CodecOption> codecOptions = options.getCodecOptions();
Thread initThread = startInitThread(options); Thread initThread = startInitThread(options);
@ -204,7 +204,7 @@ public final class Server {
boolean stayAwake = Boolean.parseBoolean(args[12]); boolean stayAwake = Boolean.parseBoolean(args[12]);
options.setStayAwake(stayAwake); options.setStayAwake(stayAwake);
String codecOptions = args[13]; List<CodecOption> codecOptions = CodecOption.parse(args[13]);
options.setCodecOptions(codecOptions); options.setCodecOptions(codecOptions);
String encoderName = "-".equals(args[14]) ? null : args[14]; String encoderName = "-".equals(args[14]) ? null : args[14];