X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Ffilter%2FLameMp3Decoder.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsonitus%2Fdata%2Ffilter%2FLameMp3Decoder.java;h=d8240411b3c4fcf1c3294ecb6d356e4f3fbd8232;hb=85754e2a030dbff1245499f408c67ef154197fc4;hp=0000000000000000000000000000000000000000;hpb=3e7a3956733424c04aaa11de1dfb26719eecb26e;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
new file mode 100644
index 0000000..d824041
--- /dev/null
+++ b/src/main/java/net/pterodactylus/sonitus/data/filter/LameMp3Decoder.java
@@ -0,0 +1,64 @@
+/*
+ * Sonitus - LameMp3Decoder.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package net.pterodactylus.sonitus.data.filter;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * {@link ExternalMp3Decoder} implementation that uses LAME to decode an MP3.
+ *
+ * @author David âBombeâ Roden
+ */
+public class LameMp3Decoder extends ExternalMp3Decoder {
+
+ /**
+ * 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));
+ }
+
+ //
+ // STATIC METHODS
+ //
+
+ /**
+ * Generates the parameters for LAME.
+ *
+ * @param swapBytes
+ * {@code true} to swap the decoded bytes, {@code false} to use platform
+ * endianness
+ * @return The parameters for LAME
+ */
+ private static Iterable generateParameters(boolean swapBytes) {
+ ImmutableList.Builder parameters = ImmutableList.builder();
+ parameters.add("--mp3input").add("--decode").add("-t");
+ if (swapBytes) {
+ parameters.add("-x");
+ }
+ parameters.add("-").add("-");
+ return parameters.build();
+ }
+
+}