f09e79fb36a541aa45e768974519818f010915d8
[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("mp3", "MPEG 1 Layer 3", "MP3", "audio/mpeg", true, false));
35                 codecDescriptions.put("vorbis", new AudioCodecDescription("vorbis", "Ogg Vorbis", "Vorbis", "audio/vorbis", true, false));
36                 codecDescriptions.put("aac", new AudioCodecDescription("aac", "Advanced Audio Coding", "AAC", "audio/x-aac", true, false));
37                 codecDescriptions.put("flac", new AudioCodecDescription("flac", "Free Lossless Audio Codec", "FLAC", "audio/ogg", true, true));
38                 codecDescriptions.put("wav", new AudioCodecDescription("wav", "Waveform Audio", "WAV", "audio/vnc.wave", true, true));
39                 codecDescriptions.put("mod", new AudioCodecDescription("mod", "Module", "MOD", "audio/mod", false, true));
40                 codecDescriptions.put("ft2", new AudioCodecDescription("ft2", "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 code of this codec. */
53                 public final String code;
54
55                 /** The full name of the codec. */
56                 public final String name;
57
58                 /** The short name of the codec. */
59                 public final String shortName;
60
61                 /** The MIME type. */
62                 public final String mimeType;
63
64                 /** Whether this is a streaming codec. */
65                 public final boolean streaming;
66
67                 /** Whether this codec is lossless. */
68                 public final boolean lossless;
69
70                 /**
71                  * Creates a new audio codec description.
72                  *
73                  * @param code
74                  *            The code of the codec
75                  * @param name
76                  *            The full name of the codec
77                  * @param shortName
78                  *            The short name of the codec
79                  * @param mimeType
80                  *            The MIME type of the audio codec
81                  * @param streaming
82                  *            {@code true} if the codec is a streaming audio codec,
83                  *            {@code false} otherwise
84                  * @param lossless
85                  *            {@code true} if the codec is a lossless audio codec,
86                  *            {@code false} otherwise
87                  */
88                 AudioCodecDescription(String code, String name, String shortName, String mimeType, boolean streaming, boolean lossless) {
89                         this.code = code;
90                         this.name = name;
91                         this.shortName = shortName;
92                         this.mimeType = mimeType;
93                         this.streaming = streaming;
94                         this.lossless = lossless;
95                 }
96
97         }
98
99 }