X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Ffilter%2FLameMp3Encoder.java;h=d425fe283938eef3de098a973df8d99e29180069;hb=09f8bd2297dc864e24baa67c65be97104e00c320;hp=66abb10cc9f7a8570796762dcb98d09b9ea855f8;hpb=be717efd804c0e83882161a937578cc74bd963c9;p=sonitus.git diff --git a/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Encoder.java b/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Encoder.java index 66abb10..d425fe2 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Encoder.java +++ b/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Encoder.java @@ -19,7 +19,7 @@ package net.pterodactylus.sonitus.data.filter; import java.util.Arrays; -import net.pterodactylus.sonitus.data.Format; +import net.pterodactylus.sonitus.data.Metadata; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; @@ -52,7 +52,7 @@ public class LameMp3Encoder extends ExternalMp3Encoder { private final String binary; /** Whether to swap bytes in the input. */ - private final boolean swapBytes; + private boolean swapBytes; /** The preset to use. */ private final Optional preset; @@ -68,14 +68,11 @@ public class LameMp3Encoder extends ExternalMp3Encoder { * * @param binary * The location of the binary - * @param swapBytes - * {@code true} to swap bytes in the input, {@code false} to use platform - * endianness * @param preset * The preset to use */ - public LameMp3Encoder(String binary, boolean swapBytes, Preset preset) { - this(binary, swapBytes, preset, -1); + public LameMp3Encoder(String binary, Preset preset) { + this(binary, preset, -1); } /** @@ -83,14 +80,11 @@ public class LameMp3Encoder extends ExternalMp3Encoder { * * @param binary * The location of the binary - * @param swapBytes - * {@code true} to swap bytes in the input, {@code false} to use platform - * endianness * @param bitrate * The bitrate to encode to (in kbps) */ - public LameMp3Encoder(String binary, boolean swapBytes, int bitrate) { - this(binary, swapBytes, null, bitrate); + public LameMp3Encoder(String binary, int bitrate) { + this(binary, null, bitrate); } /** @@ -98,22 +92,32 @@ public class LameMp3Encoder extends ExternalMp3Encoder { * * @param binary * The location of the binary - * @param swapBytes - * {@code true} to swap bytes in the input, {@code false} to use platform - * endianness * @param preset * The preset to use * @param bitrate * The bitrate to encode to (in kbps) */ - private LameMp3Encoder(String binary, boolean swapBytes, Preset preset, int bitrate) { + private LameMp3Encoder(String binary, Preset preset, int bitrate) { + super("LAME Encoder"); this.binary = binary; - this.swapBytes = swapBytes; this.preset = Optional.fromNullable(preset); this.bitrate = (bitrate < 0) ? Optional.absent() : Optional.of(bitrate); } /** + * Sets whether to swap bytes on the input to encode + * + * @param swapBytes + * {@code true} to swap the input bytes, {@code false} to use platform + * endianness + * @return This MP3 encoder + */ + public LameMp3Encoder swapBytes(boolean swapBytes) { + this.swapBytes = swapBytes; + return this; + } + + /** * Sets whether to use highest quality encoding. * * @param hq @@ -130,15 +134,15 @@ public class LameMp3Encoder extends ExternalMp3Encoder { // @Override - protected String binary(Format format) { + protected String binary(Metadata metadata) { return binary; } @Override - protected Iterable parameters(Format format) { - ImmutableList.Builder parameters = ImmutableList.builder(); + protected Iterable parameters(Metadata metadata) { + ImmutableList.Builder parameters = ImmutableList.builder(); parameters.add("-r"); - parameters.add("-s").add(String.valueOf(format.frequency() / 1000.0)); + parameters.add("-s").add(String.valueOf(metadata.frequency() / 1000.0)); if (swapBytes) { parameters.add("-x"); }