X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Ffilter%2FLameMp3Decoder.java;h=7493b3e1d0d7f772b743182c6687938eec71e641;hb=09f8bd2297dc864e24baa67c65be97104e00c320;hp=d8240411b3c4fcf1c3294ecb6d356e4f3fbd8232;hpb=85754e2a030dbff1245499f408c67ef154197fc4;p=sonitus.git diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Decoder.java b/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Decoder.java index d824041..7493b3e 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Decoder.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Decoder.java @@ -17,6 +17,8 @@ package net.pterodactylus.sonitus.data.filter; +import net.pterodactylus.sonitus.data.Metadata; + import com.google.common.collect.ImmutableList; /** @@ -26,33 +28,48 @@ import com.google.common.collect.ImmutableList; */ public class LameMp3Decoder extends ExternalMp3Decoder { + /** The location of the binary. */ + private final String binary; + + /** Whether to swap bytes in the decoded output. */ + private boolean swapBytes; + /** * Creates a new LAME MP3 decoder. * * @param binary * The location of the binary - * @param swapBytes - * {@code true} to swap the decoded bytes, {@code false} to use platform - * endianness */ - public LameMp3Decoder(String binary, boolean swapBytes) { - super(binary, generateParameters(swapBytes)); + public LameMp3Decoder(String binary) { + super("LAME Decoder"); + this.binary = binary; } - // - // STATIC METHODS - // - /** - * Generates the parameters for LAME. + * Sets whether to swap bytes on the decoded output. * * @param swapBytes * {@code true} to swap the decoded bytes, {@code false} to use platform * endianness - * @return The parameters for LAME + * @return This MP3 decoder */ - private static Iterable generateParameters(boolean swapBytes) { - ImmutableList.Builder parameters = ImmutableList.builder(); + public LameMp3Decoder swapBytes(boolean swapBytes) { + this.swapBytes = swapBytes; + return this; + } + + // + // EXTERNALFILTER METHODS + // + + @Override + protected String binary(Metadata metadata) { + return binary; + } + + @Override + protected Iterable parameters(Metadata metadata) { + ImmutableList.Builder parameters = ImmutableList.builder(); parameters.add("--mp3input").add("--decode").add("-t"); if (swapBytes) { parameters.add("-x");