KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > media > format > audio > mpeg > MpegAudioFormat


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 package org.jboss.media.format.audio.mpeg;
9
10 import java.io.InputStream JavaDoc;
11 import java.net.URL JavaDoc;
12
13 import javax.emb.Media;
14 import javax.emb.MediaException;
15 import javax.emb.MediaFormat;
16 import javax.emb.MediaHeader;
17 import javax.emb.MediaSegment;
18
19 import org.jboss.media.format.audio.AudioMediaFormat;
20
21 /**
22  * Represents MPEG Audio formats (Layers I,II and III).
23  *
24  * <p>A representation of an MPEG Audio format.
25  *
26  * @version <tt>$Revision 1.1 $</tt>
27  * @author <a HREF="mailto:ogreen@users.sourceforge.net">Owen Green</a>
28  */

29 public class MpegAudioFormat extends AudioMediaFormat implements MediaFormat
30 {
31    /**
32     * @see javax.emb.MediaFormat#assembleContent(URL, MediaSegment[])
33     */

34    public byte[] assembleContent(
35       URL JavaDoc mediaLocation,
36       MediaSegment[] mediaSegments)
37       throws MediaException
38    {
39       return null;
40    }
41
42    /**
43     * @see javax.emb.MediaFormat#disassembleContent(URL, byte[])
44     */

45    public MediaSegment[] disassembleContent(
46       URL JavaDoc mediaLocation,
47       byte[] mediaContent)
48       throws MediaException
49    {
50       return null;
51    }
52
53    /**
54     * @see javax.emb.MediaFormat#extractHeader(InputStream)
55     */

56    public MediaHeader extractHeader(InputStream JavaDoc content) throws MediaException
57    {
58       if (null == content)
59       {
60          throw new NullPointerException JavaDoc();
61       }
62       return new MpegAudioHeader(content);
63    }
64
65    /**
66     * @see javax.emb.MediaFormat#extractProxy(InputStream)
67     */

68    public Media extractProxy(InputStream JavaDoc content) throws MediaException
69    {
70       // TODO: Create a generic proxy
71
return null;
72    }
73
74    /**
75     * @see javax.emb.MediaFormat#getDefaultMimeType()
76     */

77    public String JavaDoc getDefaultMimeType()
78    {
79       return "audio/mpeg";
80    }
81
82    /**
83     * @see javax.emb.MediaFormat#isEmbedded()
84     */

85    public boolean isEmbedded()
86    {
87       return false;
88    }
89
90    /**
91     * @see javax.emb.MediaFormat#isStreamingDesirable()
92     */

93    public boolean isStreamingDesirable()
94    {
95       return false;
96    }
97
98    /**
99     * Enumeration of possible versions for MPEG Audio
100     */

101    public static class Version
102    {
103       /**
104       * MPEG Version 1(ISO/IEC 11172-3)
105       */

106       public final static Version MPEG1 = new Version("MPEG v1");
107
108       /**
109       * MPEG Version 2(ISO/IEC 13818-3)
110       */

111       public final static Version MPEG2 = new Version("MPEG v2");
112
113       /**
114       * MPEG Version 2.5 (recent extension to MPEG 2)
115       */

116       public final static Version MPEG25 = new Version("MPEG v2.5");
117
118       private final String JavaDoc description;
119
120       private Version(String JavaDoc description)
121       {
122          this.description = description;
123       }
124
125       /**
126       * Returns a string description of this MPEG version indentifier
127       *
128       * @return a string description of this MPEG version indentifier
129       */

130       public String JavaDoc toString()
131       {
132          return description;
133       }
134    }
135
136    /**
137     * Enumerates the possible layers for MPEG audio.
138     */

139    public static class Layer
140    {
141       /**
142       * MPEG Audio Layer I
143       */

144       public static final Layer LAYERI = new Layer("Layer I");
145
146       /**
147       * MPEG Audio Layer II
148       */

149       public static final Layer LAYERII = new Layer("Layer II");
150
151       /**
152       * MPEG Audio Layer III
153       */

154       public static final Layer LAYERIII = new Layer("Layer III");
155
156       private final String JavaDoc description;
157
158       private Layer(String JavaDoc description)
159       {
160          this.description = description;
161       }
162
163       /**
164       * Returns a string description of this MPEG layer indentifier
165       *
166       * @return a string description of this MPEG layer indentifier
167       */

168       public String JavaDoc toString()
169       {
170          return description;
171       }
172    }
173
174    /**
175     * Enumerates the possible Channel Modes in MPEG Audio
176     */

177    public static class ChannelMode
178    {
179       public static final ChannelMode STEREO = new ChannelMode("Stereo");
180       public static final ChannelMode JOINT_STEREO =
181          new ChannelMode("Joint Stereo");
182       public static final ChannelMode DUAL_CHANNEL =
183          new ChannelMode("Dual Channel");
184       public static final ChannelMode SINGLE_CHANNEL = new ChannelMode("Mono");
185
186       private final String JavaDoc description;
187
188       private ChannelMode(String JavaDoc description)
189       {
190          this.description = description;
191       }
192
193       /**
194       * Returns a string description of this channel mode
195       *
196       * @return a string description of this channel mode
197       */

198       public String JavaDoc toString()
199       {
200          return description;
201       }
202    }
203 }
Popular Tags