a3c90c36206d0a4e97e0f54e4329050c2b921265
[demoscenemusic.git] / src / main / java / net / pterodactylus / demoscenemusic / utils / AudioCodecs.java
1 /*
2  * DemosceneMusic - AudioCodecFilter.java - Copyright © 2012 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.demoscenemusic.utils;
19
20 import java.util.HashMap;
21 import java.util.Map;
22
23 /**
24  * Helper for audio codec descriptions.
25  *
26  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
27  */
28 public class AudioCodecs {
29
30         /** Descriptions for audio codecs. */
31         public static final Map<String, AudioCodecDescription> codecDescriptions = new HashMap<String, AudioCodecDescription>();
32
33         static {
34                 codecDescriptions.put("mp3", new AudioCodecDescription("MPEG 1 Layer 3", "MP3", "audio/mpeg", true, false));
35                 codecDescriptions.put("vorbis", new AudioCodecDescription("Ogg Vorbis", "Vorbis", "audio/vorbis", true, false));
36                 codecDescriptions.put("aac", new AudioCodecDescription("Advanced Audio Coding", "AAC", "audio/x-aac", true, false));
37                 codecDescriptions.put("flac", new AudioCodecDescription("Free Lossless Audio Codec", "FLAC", "audio/ogg", true, true));
38                 codecDescriptions.put("WAV", new AudioCodecDescription("Waveform Audio", "WAV", "audio/vnc.wave", true, true));
39                 codecDescriptions.put("mod", new AudioCodecDescription("Module", "MOD", "audio/mod", false, true));
40                 codecDescriptions.put("ft2", new AudioCodecDescription("FastTracker II Module", "XM", "audio/xm", false, true));
41         }
42
43         /**
44          * Bundles descriptions for various audio codecs. For simplicity reasons,
45          * file formats such as MOD, IT, or SID are also treated as audio codecs
46          * even though they are not.
47          *
48          * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
49          */
50         public final static class AudioCodecDescription {
51
52                 /** The full name of the codec. */
53                 public final String name;
54
55                 /** The short name of the codec. */
56                 public final String shortName;
57
58                 /** The MIME type. */
59                 public final String mimeType;
60
61                 /** Whether this is a streaming codec. */
62                 public final boolean streaming;
63
64                 /** Whether this codec is lossless. */
65                 public final boolean lossless;
66
67                 /**
68                  * Creates a new audio codec description.
69                  *
70                  * @param name
71                  *            The full name of the codec
72                  * @param shortName
73                  *            The short name of the codec
74                  * @param mimeType
75                  *            The MIME type of the audio codec
76                  * @param streaming
77                  *            {@code true} if the codec is a streaming audio codec,
78                  *            {@code false} otherwise
79                  * @param lossless
80                  *            {@code true} if the codec is a lossless audio codec,
81                  *            {@code false} otherwise
82                  */
83                 AudioCodecDescription(String name, String shortName, String mimeType, boolean streaming, boolean lossless) {
84                         this.name = name;
85                         this.shortName = shortName;
86                         this.mimeType = mimeType;
87                         this.streaming = streaming;
88                         this.lossless = lossless;
89                 }
90
91         }
92
93 }