Remove Options setters

Now that options parsing is performed from the Options class, setters
are not necessary anymore.
This commit is contained in:
Romain Vimont 2023-04-09 19:58:34 +02:00
parent ce064fb5e0
commit 9cfea347d0

View file

@ -47,166 +47,82 @@ public class Options {
return logLevel; return logLevel;
} }
public void setLogLevel(Ln.Level logLevel) {
this.logLevel = logLevel;
}
public int getScid() { public int getScid() {
return scid; return scid;
} }
public void setScid(int scid) {
this.scid = scid;
}
public boolean getAudio() { public boolean getAudio() {
return audio; return audio;
} }
public void setAudio(boolean audio) {
this.audio = audio;
}
public int getMaxSize() { public int getMaxSize() {
return maxSize; return maxSize;
} }
public void setMaxSize(int maxSize) {
this.maxSize = maxSize;
}
public VideoCodec getVideoCodec() { public VideoCodec getVideoCodec() {
return videoCodec; return videoCodec;
} }
public void setVideoCodec(VideoCodec videoCodec) {
this.videoCodec = videoCodec;
}
public AudioCodec getAudioCodec() { public AudioCodec getAudioCodec() {
return audioCodec; return audioCodec;
} }
public void setAudioCodec(AudioCodec audioCodec) {
this.audioCodec = audioCodec;
}
public int getVideoBitRate() { public int getVideoBitRate() {
return videoBitRate; return videoBitRate;
} }
public void setVideoBitRate(int videoBitRate) {
this.videoBitRate = videoBitRate;
}
public int getAudioBitRate() { public int getAudioBitRate() {
return audioBitRate; return audioBitRate;
} }
public void setAudioBitRate(int audioBitRate) {
this.audioBitRate = audioBitRate;
}
public int getMaxFps() { public int getMaxFps() {
return maxFps; return maxFps;
} }
public void setMaxFps(int maxFps) {
this.maxFps = maxFps;
}
public int getLockVideoOrientation() { public int getLockVideoOrientation() {
return lockVideoOrientation; return lockVideoOrientation;
} }
public void setLockVideoOrientation(int lockVideoOrientation) {
this.lockVideoOrientation = lockVideoOrientation;
}
public boolean isTunnelForward() { public boolean isTunnelForward() {
return tunnelForward; return tunnelForward;
} }
public void setTunnelForward(boolean tunnelForward) {
this.tunnelForward = tunnelForward;
}
public Rect getCrop() { public Rect getCrop() {
return crop; return crop;
} }
public void setCrop(Rect crop) {
this.crop = crop;
}
public boolean getControl() { public boolean getControl() {
return control; return control;
} }
public void setControl(boolean control) {
this.control = control;
}
public int getDisplayId() { public int getDisplayId() {
return displayId; return displayId;
} }
public void setDisplayId(int displayId) {
this.displayId = displayId;
}
public boolean getShowTouches() { public boolean getShowTouches() {
return showTouches; return showTouches;
} }
public void setShowTouches(boolean showTouches) {
this.showTouches = showTouches;
}
public boolean getStayAwake() { public boolean getStayAwake() {
return stayAwake; return stayAwake;
} }
public void setStayAwake(boolean stayAwake) {
this.stayAwake = stayAwake;
}
public List<CodecOption> getVideoCodecOptions() { public List<CodecOption> getVideoCodecOptions() {
return videoCodecOptions; return videoCodecOptions;
} }
public void setVideoCodecOptions(List<CodecOption> videoCodecOptions) {
this.videoCodecOptions = videoCodecOptions;
}
public List<CodecOption> getAudioCodecOptions() { public List<CodecOption> getAudioCodecOptions() {
return audioCodecOptions; return audioCodecOptions;
} }
public void setAudioCodecOptions(List<CodecOption> audioCodecOptions) {
this.audioCodecOptions = audioCodecOptions;
}
public String getVideoEncoder() { public String getVideoEncoder() {
return videoEncoder; return videoEncoder;
} }
public void setVideoEncoder(String videoEncoder) {
this.videoEncoder = videoEncoder;
}
public String getAudioEncoder() { public String getAudioEncoder() {
return audioEncoder; return audioEncoder;
} }
public void setAudioEncoder(String audioEncoder) {
this.audioEncoder = audioEncoder;
}
public void setPowerOffScreenOnClose(boolean powerOffScreenOnClose) {
this.powerOffScreenOnClose = powerOffScreenOnClose;
}
public boolean getPowerOffScreenOnClose() { public boolean getPowerOffScreenOnClose() {
return this.powerOffScreenOnClose; return this.powerOffScreenOnClose;
} }
@ -215,82 +131,42 @@ public class Options {
return clipboardAutosync; return clipboardAutosync;
} }
public void setClipboardAutosync(boolean clipboardAutosync) {
this.clipboardAutosync = clipboardAutosync;
}
public boolean getDownsizeOnError() { public boolean getDownsizeOnError() {
return downsizeOnError; return downsizeOnError;
} }
public void setDownsizeOnError(boolean downsizeOnError) {
this.downsizeOnError = downsizeOnError;
}
public boolean getCleanup() { public boolean getCleanup() {
return cleanup; return cleanup;
} }
public void setCleanup(boolean cleanup) {
this.cleanup = cleanup;
}
public boolean getPowerOn() { public boolean getPowerOn() {
return powerOn; return powerOn;
} }
public void setPowerOn(boolean powerOn) {
this.powerOn = powerOn;
}
public boolean getListEncoders() { public boolean getListEncoders() {
return listEncoders; return listEncoders;
} }
public void setListEncoders(boolean listEncoders) {
this.listEncoders = listEncoders;
}
public boolean getListDisplays() { public boolean getListDisplays() {
return listDisplays; return listDisplays;
} }
public void setListDisplays(boolean listDisplays) {
this.listDisplays = listDisplays;
}
public boolean getSendDeviceMeta() { public boolean getSendDeviceMeta() {
return sendDeviceMeta; return sendDeviceMeta;
} }
public void setSendDeviceMeta(boolean sendDeviceMeta) {
this.sendDeviceMeta = sendDeviceMeta;
}
public boolean getSendFrameMeta() { public boolean getSendFrameMeta() {
return sendFrameMeta; return sendFrameMeta;
} }
public void setSendFrameMeta(boolean sendFrameMeta) {
this.sendFrameMeta = sendFrameMeta;
}
public boolean getSendDummyByte() { public boolean getSendDummyByte() {
return sendDummyByte; return sendDummyByte;
} }
public void setSendDummyByte(boolean sendDummyByte) {
this.sendDummyByte = sendDummyByte;
}
public boolean getSendCodecMeta() { public boolean getSendCodecMeta() {
return sendCodecMeta; return sendCodecMeta;
} }
public void setSendCodecMeta(boolean sendCodecMeta) {
this.sendCodecMeta = sendCodecMeta;
}
@SuppressWarnings("MethodLength") @SuppressWarnings("MethodLength")
public static Options parse(String... args) { public static Options parse(String... args) {
if (args.length < 1) { if (args.length < 1) {
@ -319,142 +195,116 @@ public class Options {
if (scid < -1) { if (scid < -1) {
throw new IllegalArgumentException("scid may not be negative (except -1 for 'none'): " + scid); throw new IllegalArgumentException("scid may not be negative (except -1 for 'none'): " + scid);
} }
options.setScid(scid); options.scid = scid;
break; break;
case "log_level": case "log_level":
Ln.Level level = Ln.Level.valueOf(value.toUpperCase(Locale.ENGLISH)); options.logLevel = Ln.Level.valueOf(value.toUpperCase(Locale.ENGLISH));
options.setLogLevel(level);
break; break;
case "audio": case "audio":
boolean audio = Boolean.parseBoolean(value); options.audio = Boolean.parseBoolean(value);
options.setAudio(audio);
break; break;
case "video_codec": case "video_codec":
VideoCodec videoCodec = VideoCodec.findByName(value); VideoCodec videoCodec = VideoCodec.findByName(value);
if (videoCodec == null) { if (videoCodec == null) {
throw new IllegalArgumentException("Video codec " + value + " not supported"); throw new IllegalArgumentException("Video codec " + value + " not supported");
} }
options.setVideoCodec(videoCodec); options.videoCodec = videoCodec;
break; break;
case "audio_codec": case "audio_codec":
AudioCodec audioCodec = AudioCodec.findByName(value); AudioCodec audioCodec = AudioCodec.findByName(value);
if (audioCodec == null) { if (audioCodec == null) {
throw new IllegalArgumentException("Audio codec " + value + " not supported"); throw new IllegalArgumentException("Audio codec " + value + " not supported");
} }
options.setAudioCodec(audioCodec); options.audioCodec = audioCodec;
break; break;
case "max_size": case "max_size":
int maxSize = Integer.parseInt(value) & ~7; // multiple of 8 options.maxSize = Integer.parseInt(value) & ~7; // multiple of 8
options.setMaxSize(maxSize);
break; break;
case "video_bit_rate": case "video_bit_rate":
int videoBitRate = Integer.parseInt(value); options.videoBitRate = Integer.parseInt(value);
options.setVideoBitRate(videoBitRate);
break; break;
case "audio_bit_rate": case "audio_bit_rate":
int audioBitRate = Integer.parseInt(value); options.audioBitRate = Integer.parseInt(value);
options.setAudioBitRate(audioBitRate);
break; break;
case "max_fps": case "max_fps":
int maxFps = Integer.parseInt(value); options.maxFps = Integer.parseInt(value);
options.setMaxFps(maxFps);
break; break;
case "lock_video_orientation": case "lock_video_orientation":
int lockVideoOrientation = Integer.parseInt(value); options.lockVideoOrientation = Integer.parseInt(value);
options.setLockVideoOrientation(lockVideoOrientation);
break; break;
case "tunnel_forward": case "tunnel_forward":
boolean tunnelForward = Boolean.parseBoolean(value); options.tunnelForward = Boolean.parseBoolean(value);
options.setTunnelForward(tunnelForward);
break; break;
case "crop": case "crop":
Rect crop = parseCrop(value); options.crop = parseCrop(value);
options.setCrop(crop);
break; break;
case "control": case "control":
boolean control = Boolean.parseBoolean(value); options.control = Boolean.parseBoolean(value);
options.setControl(control);
break; break;
case "display_id": case "display_id":
int displayId = Integer.parseInt(value); options.displayId = Integer.parseInt(value);
options.setDisplayId(displayId);
break; break;
case "show_touches": case "show_touches":
boolean showTouches = Boolean.parseBoolean(value); options.showTouches = Boolean.parseBoolean(value);
options.setShowTouches(showTouches);
break; break;
case "stay_awake": case "stay_awake":
boolean stayAwake = Boolean.parseBoolean(value); options.stayAwake = Boolean.parseBoolean(value);
options.setStayAwake(stayAwake);
break; break;
case "video_codec_options": case "video_codec_options":
List<CodecOption> videoCodecOptions = CodecOption.parse(value); options.videoCodecOptions = CodecOption.parse(value);
options.setVideoCodecOptions(videoCodecOptions);
break; break;
case "audio_codec_options": case "audio_codec_options":
List<CodecOption> audioCodecOptions = CodecOption.parse(value); options.audioCodecOptions = CodecOption.parse(value);
options.setAudioCodecOptions(audioCodecOptions);
break; break;
case "video_encoder": case "video_encoder":
if (!value.isEmpty()) { if (!value.isEmpty()) {
options.setVideoEncoder(value); options.videoEncoder = value;
} }
break; break;
case "audio_encoder": case "audio_encoder":
if (!value.isEmpty()) { if (!value.isEmpty()) {
options.setAudioEncoder(value); options.audioEncoder = value;
} }
case "power_off_on_close": case "power_off_on_close":
boolean powerOffScreenOnClose = Boolean.parseBoolean(value); options.powerOffScreenOnClose = Boolean.parseBoolean(value);
options.setPowerOffScreenOnClose(powerOffScreenOnClose);
break; break;
case "clipboard_autosync": case "clipboard_autosync":
boolean clipboardAutosync = Boolean.parseBoolean(value); options.clipboardAutosync = Boolean.parseBoolean(value);
options.setClipboardAutosync(clipboardAutosync);
break; break;
case "downsize_on_error": case "downsize_on_error":
boolean downsizeOnError = Boolean.parseBoolean(value); options.downsizeOnError = Boolean.parseBoolean(value);
options.setDownsizeOnError(downsizeOnError);
break; break;
case "cleanup": case "cleanup":
boolean cleanup = Boolean.parseBoolean(value); options.cleanup = Boolean.parseBoolean(value);
options.setCleanup(cleanup);
break; break;
case "power_on": case "power_on":
boolean powerOn = Boolean.parseBoolean(value); options.powerOn = Boolean.parseBoolean(value);
options.setPowerOn(powerOn);
break; break;
case "list_encoders": case "list_encoders":
boolean listEncoders = Boolean.parseBoolean(value); options.listEncoders = Boolean.parseBoolean(value);
options.setListEncoders(listEncoders);
break; break;
case "list_displays": case "list_displays":
boolean listDisplays = Boolean.parseBoolean(value); options.listDisplays = Boolean.parseBoolean(value);
options.setListDisplays(listDisplays);
break; break;
case "send_device_meta": case "send_device_meta":
boolean sendDeviceMeta = Boolean.parseBoolean(value); options.sendDeviceMeta = Boolean.parseBoolean(value);
options.setSendDeviceMeta(sendDeviceMeta);
break; break;
case "send_frame_meta": case "send_frame_meta":
boolean sendFrameMeta = Boolean.parseBoolean(value); options.sendFrameMeta = Boolean.parseBoolean(value);
options.setSendFrameMeta(sendFrameMeta);
break; break;
case "send_dummy_byte": case "send_dummy_byte":
boolean sendDummyByte = Boolean.parseBoolean(value); options.sendDummyByte = Boolean.parseBoolean(value);
options.setSendDummyByte(sendDummyByte);
break; break;
case "send_codec_meta": case "send_codec_meta":
boolean sendCodecMeta = Boolean.parseBoolean(value); options.sendCodecMeta = Boolean.parseBoolean(value);
options.setSendCodecMeta(sendCodecMeta);
break; break;
case "raw_video_stream": case "raw_video_stream":
boolean rawVideoStream = Boolean.parseBoolean(value); boolean rawVideoStream = Boolean.parseBoolean(value);
if (rawVideoStream) { if (rawVideoStream) {
options.setSendDeviceMeta(false); options.sendDeviceMeta = false;
options.setSendFrameMeta(false); options.sendFrameMeta = false;
options.setSendDummyByte(false); options.sendDummyByte = false;
options.setSendCodecMeta(false); options.sendCodecMeta = false;
} }
break; break;
default: default: