All checks were successful
KnarCraft/FFmpegConvert/pipeline/head This commit looks good
138 lines
4.4 KiB
Java
138 lines
4.4 KiB
Java
package net.knarcraft.ffmpegconverter.config;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
/**
|
|
* A representation of all configuration keys
|
|
*/
|
|
public class ConfigKey<T> {
|
|
|
|
private static final Set<ConfigKey<?>> allKeys = new HashSet<>();
|
|
|
|
/**
|
|
* The configuration key for the list of hardware-accelerated encoders available on the system
|
|
*/
|
|
public static final ConfigKey<String> HARDWARE_ACCELERATED_ENCODERS = new ConfigKey<>("encoders-hardware-accelerated", String.class, "qsv,cuda,dxva2,d3d11va,opencl,vulkan");
|
|
|
|
/**
|
|
* The configuration key for toggling debug mode
|
|
*/
|
|
public static final ConfigKey<Boolean> DEBUG = createKey("debug", Boolean.class, false);
|
|
|
|
/**
|
|
* The configuration key for toggling hardware encoding
|
|
*/
|
|
public static final ConfigKey<Boolean> USE_HARDWARE_ENCODING = createKey("hardware-acceleration-encode", Boolean.class, false);
|
|
|
|
/**
|
|
* The configuration key for toggling hardware decoding
|
|
*/
|
|
public static final ConfigKey<Boolean> USE_HARDWARE_DECODING = createKey("hardware-acceleration-decode", Boolean.class, true);
|
|
|
|
/**
|
|
* The configuration key for toggling forced flac encoding
|
|
*/
|
|
public static final ConfigKey<Boolean> ENCODE_FLAC_ALWAYS = createKey("encode-flac-always", Boolean.class, false);
|
|
|
|
/**
|
|
* The configuration key for anime audio languages
|
|
*/
|
|
public static final ConfigKey<String> AUDIO_LANGUAGES_ANIME = createKey("audio-languages-anime", String.class, "jpn,eng,*");
|
|
|
|
/**
|
|
* The configuration key for anime subtitle languages
|
|
*/
|
|
public static final ConfigKey<String> SUBTITLE_LANGUAGES_ANIME = createKey("subtitle-languages-anime", String.class, "eng,*");
|
|
|
|
/**
|
|
* The configuration key for the minimal subtitle preference
|
|
*/
|
|
public static final ConfigKey<String> MINIMAL_SUBTITLE_PREFERENCE = createKey("minimal-subtitle-preference", String.class, "AVOID");
|
|
|
|
/**
|
|
* The configuration key for whether to de-interlace video streams
|
|
*/
|
|
public static final ConfigKey<Boolean> DE_INTERLACE_VIDEO = createKey("de-interlace-video", Boolean.class, false);
|
|
|
|
/**
|
|
* The configuration key for whether to copy attached cover images
|
|
*/
|
|
public static final ConfigKey<Boolean> COPY_ATTACHED_IMAGES = createKey("copy-attached-images", Boolean.class, false);
|
|
|
|
/**
|
|
* The configuration key for whether to overwrite the original file when converting
|
|
*/
|
|
public static final ConfigKey<Boolean> OVERWRITE_FILES = createKey("overwrite-files", Boolean.class, false);
|
|
|
|
private final String configKey;
|
|
private final T defaultValue;
|
|
private final Class<T> type;
|
|
|
|
/**
|
|
* Instantiates a new config key
|
|
*
|
|
* @param configKey <p>The storage key in the configuration file</p>
|
|
* @param type <p>The type of this option's value</p>
|
|
* @param defaultValue <p>The default value of this option</p>
|
|
*/
|
|
private ConfigKey(@NotNull String configKey, @NotNull Class<T> type, @NotNull T defaultValue) {
|
|
this.configKey = configKey;
|
|
this.type = type;
|
|
this.defaultValue = defaultValue;
|
|
}
|
|
|
|
/**
|
|
* Creates a new config key
|
|
*
|
|
* @param configKey <p>The storage key in the configuration file</p>
|
|
* @param type <p>The type of this option's value</p>
|
|
* @param defaultValue <p>The default value of this option</p>
|
|
* @param <F> <p>The type of key to create</p>
|
|
* @return <p>The new config key</p>
|
|
*/
|
|
private static <F> ConfigKey<F> createKey(@NotNull String configKey, @NotNull Class<F> type, @NotNull F defaultValue) {
|
|
ConfigKey<F> key = new ConfigKey<>(configKey, type, defaultValue);
|
|
allKeys.add(key);
|
|
return key;
|
|
}
|
|
|
|
/**
|
|
* Gets the type of this option's value
|
|
*
|
|
* @return <p>The type of the value</p>
|
|
*/
|
|
@NotNull
|
|
public Class<T> getType() {
|
|
return this.type;
|
|
}
|
|
|
|
/**
|
|
* Gets the default value for the option represented by this key
|
|
*
|
|
* @return <p>The default value</p>
|
|
*/
|
|
@NotNull
|
|
public T getDefaultValue() {
|
|
return this.defaultValue;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return this.configKey;
|
|
}
|
|
|
|
/**
|
|
* Gets all configuration keys
|
|
*
|
|
* @return <p>All configuration keys</p>
|
|
*/
|
|
@NotNull
|
|
public static ConfigKey<?>[] values() {
|
|
return allKeys.toArray(new ConfigKey[0]);
|
|
}
|
|
|
|
}
|