Add audio codec helper class.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 28 Jul 2012 22:15:53 +0000 (00:15 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 28 Jul 2012 22:15:53 +0000 (00:15 +0200)
src/main/java/net/pterodactylus/demoscenemusic/utils/AudioCodecs.java [new file with mode: 0644]

diff --git a/src/main/java/net/pterodactylus/demoscenemusic/utils/AudioCodecs.java b/src/main/java/net/pterodactylus/demoscenemusic/utils/AudioCodecs.java
new file mode 100644 (file)
index 0000000..baa4e92
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * DemosceneMusic - AudioCodecFilter.java - Copyright © 2012 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 <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.demoscenemusic.utils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Helper for audio codec descriptions.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class AudioCodecs {
+
+       /** Descriptions for audio codecs. */
+       public static final Map<String, AudioCodecDescription> codecDescriptions = new HashMap<String, AudioCodecDescription>();
+
+       static {
+               codecDescriptions.put("mp3", new AudioCodecDescription("MPEG 1 Layer 3", "MP3", true, false));
+               codecDescriptions.put("vorbis", new AudioCodecDescription("Ogg Vorbis", "Vorbis", true, false));
+               codecDescriptions.put("aac", new AudioCodecDescription("Advanced Audio Coding", "AAC", true, false));
+               codecDescriptions.put("flac", new AudioCodecDescription("Free Lossless Audio Codec", "FLAC", true, true));
+               codecDescriptions.put("WAV", new AudioCodecDescription("Waveform Audio", "WAV", true, true));
+               codecDescriptions.put("mod", new AudioCodecDescription("Module", "MOD", false, true));
+       }
+
+       /**
+        * Bundles descriptions for various audio codecs. For simplicity reasons,
+        * file formats such as MOD, IT, or SID are also treated as audio codecs
+        * even though they are not.
+        *
+        * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+        */
+       public final static class AudioCodecDescription {
+
+               /** The full name of the codec. */
+               public final String name;
+
+               /** The short name of the codec. */
+               public final String shortName;
+
+               /** Whether this is a streaming codec. */
+               public final boolean streaming;
+
+               /** Whether this codec is lossless. */
+               public final boolean lossless;
+
+               /**
+                * Creates a new audio codec description.
+                *
+                * @param name
+                *            The full name of the codec
+                * @param shortName
+                *            The short name of the codec
+                * @param streaming
+                *            {@code true} if the codec is a streaming audio codec,
+                *            {@code false} otherwise
+                * @param lossless
+                *            {@code true} if the codec is a lossless audio codec,
+                *            {@code false} otherwise
+                */
+               AudioCodecDescription(String name, String shortName, boolean streaming, boolean lossless) {
+                       this.name = name;
+                       this.shortName = shortName;
+                       this.streaming = streaming;
+                       this.lossless = lossless;
+               }
+
+       }
+
+}