Add name to all controlled components.
[sonitus.git] / src / main / java / net / pterodactylus / sonitus / data / filter / LameMp3Decoder.java
index d824041..7493b3e 100644 (file)
@@ -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<String> 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<String> parameters(Metadata metadata) {
+               ImmutableList.Builder<String> parameters = ImmutableList.builder();
                parameters.add("--mp3input").add("--decode").add("-t");
                if (swapBytes) {
                        parameters.add("-x");