X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Ffilter%2FExternalFilter.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Ffilter%2FExternalFilter.java;h=c3ab5082c4d72e8fbf9b8b9af9f4ad6e7f99cf8f;hb=9596adc0ca5b226e7682fc785f707d3fd1b2978e;hp=ff838d98b690749e119fa895c8393fca1f999f8e;hpb=3c80e17df7d3404a853c8782de55467be48d6ba1;p=sonitus.git diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/ExternalFilter.java b/src/main/java/net/pterodactylus/sonitus/data/filter/ExternalFilter.java index ff838d9..c3ab508 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/ExternalFilter.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/ExternalFilter.java @@ -48,31 +48,12 @@ public abstract class ExternalFilter implements Filter { /** The logger. */ private static final Logger logger = Logger.getLogger(ExternalFilter.class.getName()); - /** The binary to execute. */ - private final String binary; - - /** The parameters for the binary. */ - private final Iterable parameters; - /** The format of the source. */ private Format format; /** The input stream that will hold the converted source. */ private PipedInputStream pipedInputStream; - /** - * Creates a new external filter. - * - * @param binary - * The binary to execute - * @param parameters - * The parameter for the binary - */ - public ExternalFilter(String binary, Iterable parameters) { - this.binary = binary; - this.parameters = parameters; - } - // // FILTER METHODS @@ -94,7 +75,7 @@ public abstract class ExternalFilter implements Filter { format = source.format(); try { - Process process = Runtime.getRuntime().exec(Iterables.toArray(ImmutableList.builder().add(binary).addAll(parameters).build(), String.class)); + final Process process = Runtime.getRuntime().exec(Iterables.toArray(ImmutableList.builder().add(binary(format)).addAll(parameters(format)).build(), String.class)); final InputStream processOutput = process.getInputStream(); final OutputStream processInput = process.getOutputStream(); final InputStream processError = process.getErrorStream(); @@ -142,6 +123,28 @@ public abstract class ExternalFilter implements Filter { } // + // SUBCLASS METHODS + // + + /** + * Returns the location of the binary to execute. + * + * @param format + * The format being processed + * @return The location of the binary to execute + */ + protected abstract String binary(Format format); + + /** + * Returns the parameters for the binary. + * + * @param format + * The format being processed + * @return The parameters for the binary + */ + protected abstract Iterable parameters(Format format); + + // // STATIC METHODS //