1 /*
2 * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
28 import java.io.File;
29 import java.io.InputStream;
30 import java.io.IOException;
31 import java.net.URL;
32
33 import javax.sound.sampled.AudioFileFormat;
34 import javax.sound.sampled.AudioInputStream;
35 import javax.sound.sampled.UnsupportedAudioFileException;
36
37 /**
38 * Provider for audio file reading services. Classes providing concrete
39 * implementations can parse the format information from one or more types of
40 * audio file, and can produce audio input streams from files of these types.
41 *
42 * @author Kara Kytle
43 * @since 1.3
44 */
45 public abstract class AudioFileReader {
46
47 /**
48 * Obtains the audio file format of the input stream provided. The stream must
49 * point to valid audio file data. In general, audio file readers may
50 * need to read some data from the stream before determining whether they
51 * support it. These parsers must
52 * be able to mark the stream, read enough data to determine whether they
53 * support the stream, and, if not, reset the stream's read pointer to its original
54 * position. If the input stream does not support this, this method may fail
55 * with an <code>IOException</code>.
56 * @param stream the input stream from which file format information should be
57 * extracted
58 * @return an <code>AudioFileFormat</code> object describing the audio file format
59 * @throws UnsupportedAudioFileException if the stream does not point to valid audio
60 * file data recognized by the system
61 * @throws IOException if an I/O exception occurs
62 * @see InputStream#markSupported
63 * @see InputStream#mark
64 */
65 public abstract AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException;
66
67 /**
68 * Obtains the audio file format of the URL provided. The URL must
69 * point to valid audio file data.
70 * @param url the URL from which file format information should be
71 * extracted
72 * @return an <code>AudioFileFormat</code> object describing the audio file format
73 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
74 * file data recognized by the system
75 * @throws IOException if an I/O exception occurs
76 */
77 public abstract AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException;
78
79 /**
80 * Obtains the audio file format of the <code>File</code> provided. The <code>File</code> must
81 * point to valid audio file data.
82 * @param file the <code>File</code> from which file format information should be
83 * extracted
84 * @return an <code>AudioFileFormat</code> object describing the audio file format
85 * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
86 * file data recognized by the system
87 * @throws IOException if an I/O exception occurs
88 */
89 public abstract AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException;
90
91 /**
92 * Obtains an audio input stream from the input stream provided. The stream must
93 * point to valid audio file data. In general, audio file readers may
94 * need to read some data from the stream before determining whether they
95 * support it. These parsers must
96 * be able to mark the stream, read enough data to determine whether they
97 * support the stream, and, if not, reset the stream's read pointer to its original
98 * position. If the input stream does not support this, this method may fail
99 * with an <code>IOException</code>.
100 * @param stream the input stream from which the <code>AudioInputStream</code> should be
101 * constructed
102 * @return an <code>AudioInputStream</code> object based on the audio file data contained
103 * in the input stream.
104 * @throws UnsupportedAudioFileException if the stream does not point to valid audio
105 * file data recognized by the system
106 * @throws IOException if an I/O exception occurs
107 * @see InputStream#markSupported
108 * @see InputStream#mark
109 */
110 public abstract AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException;
111
112 /**
113 * Obtains an audio input stream from the URL provided. The URL must
114 * point to valid audio file data.
115 * @param url the URL for which the <code>AudioInputStream</code> should be
116 * constructed
117 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
118 * to by the URL
119 * @throws UnsupportedAudioFileException if the URL does not point to valid audio
120 * file data recognized by the system
121 * @throws IOException if an I/O exception occurs
122 */
123 public abstract AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException;
124
125 /**
126 * Obtains an audio input stream from the <code>File</code> provided. The <code>File</code> must
127 * point to valid audio file data.
128 * @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
129 * constructed
130 * @return an <code>AudioInputStream</code> object based on the audio file data pointed
131 * to by the File
132 * @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
133 * file data recognized by the system
134 * @throws IOException if an I/O exception occurs
135 */
136 public abstract AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException;
137 }
|
1 /*
2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
28 import java.io.File;
29 import java.io.InputStream;
30 import java.io.IOException;
31 import java.net.URL;
32
33 import javax.sound.sampled.AudioFileFormat;
34 import javax.sound.sampled.AudioInputStream;
35 import javax.sound.sampled.UnsupportedAudioFileException;
36
37 /**
38 * Provider for audio file reading services. Classes providing concrete
39 * implementations can parse the format information from one or more types of
40 * audio file, and can produce audio input streams from files of these types.
41 *
42 * @author Kara Kytle
43 * @since 1.3
44 */
45 public abstract class AudioFileReader {
46
47 /**
48 * Obtains the audio file format of the input stream provided. The stream
49 * must point to valid audio file data. In general, audio file readers may
50 * need to read some data from the stream before determining whether they
51 * support it. These parsers must be able to mark the stream, read enough
52 * data to determine whether they support the stream, and, if not, reset the
53 * stream's read pointer to its original position. If the input stream does
54 * not support this, this method may fail with an {@code IOException}.
55 *
56 * @param stream the input stream from which file format information should
57 * be extracted
58 * @return an {@code AudioFileFormat} object describing the audio file
59 * format
60 * @throws UnsupportedAudioFileException if the stream does not point to
61 * valid audio file data recognized by the system
62 * @throws IOException if an I/O exception occurs
63 * @see InputStream#markSupported
64 * @see InputStream#mark
65 */
66 public abstract AudioFileFormat getAudioFileFormat(InputStream stream)
67 throws UnsupportedAudioFileException, IOException;
68
69 /**
70 * Obtains the audio file format of the URL provided. The URL must point to
71 * valid audio file data.
72 *
73 * @param url the URL from which file format information should be
74 * extracted
75 * @return an {@code AudioFileFormat} object describing the audio file
76 * format
77 * @throws UnsupportedAudioFileException if the URL does not point to valid
78 * audio file data recognized by the system
79 * @throws IOException if an I/O exception occurs
80 */
81 public abstract AudioFileFormat getAudioFileFormat(URL url)
82 throws UnsupportedAudioFileException, IOException;
83
84 /**
85 * Obtains the audio file format of the {@code File} provided.
86 * The {@code File} must point to valid audio file data.
87 *
88 * @param file the {@code File} from which file format information
89 * should be extracted
90 * @return an {@code AudioFileFormat} object describing the audio file
91 * format
92 * @throws UnsupportedAudioFileException if the {@code File} does not point
93 * to valid audio file data recognized by the system
94 * @throws IOException if an I/O exception occurs
95 */
96 public abstract AudioFileFormat getAudioFileFormat(File file)
97 throws UnsupportedAudioFileException, IOException;
98
99 /**
100 * Obtains an audio input stream from the input stream provided. The stream
101 * must point to valid audio file data. In general, audio file readers may
102 * need to read some data from the stream before determining whether they
103 * support it. These parsers must be able to mark the stream, read enough
104 * data to determine whether they support the stream, and, if not, reset the
105 * stream's read pointer to its original position. If the input stream does
106 * not support this, this method may fail with an {@code IOException}.
107 *
108 * @param stream the input stream from which the {@code AudioInputStream}
109 * should be constructed
110 * @return an {@code AudioInputStream} object based on the audio file data
111 * contained in the input stream.
112 * @throws UnsupportedAudioFileException if the stream does not point to
113 * valid audio file data recognized by the system
114 * @throws IOException if an I/O exception occurs
115 * @see InputStream#markSupported
116 * @see InputStream#mark
117 */
118 public abstract AudioInputStream getAudioInputStream(InputStream stream)
119 throws UnsupportedAudioFileException, IOException;
120
121 /**
122 * Obtains an audio input stream from the URL provided. The URL must point
123 * to valid audio file data.
124 *
125 * @param url the URL for which the {@code AudioInputStream} should be
126 * constructed
127 * @return an {@code AudioInputStream} object based on the audio file data
128 * pointed to by the URL
129 * @throws UnsupportedAudioFileException if the URL does not point to valid
130 * audio file data recognized by the system
131 * @throws IOException if an I/O exception occurs
132 */
133 public abstract AudioInputStream getAudioInputStream(URL url)
134 throws UnsupportedAudioFileException, IOException;
135
136 /**
137 * Obtains an audio input stream from the {@code File} provided.
138 * The {@code File} must point to valid audio file data.
139 *
140 * @param file the {@code File} for which the {@code AudioInputStream}
141 * should be constructed
142 * @return an {@code AudioInputStream} object based on the audio file data
143 * pointed to by the File
144 * @throws UnsupportedAudioFileException if the {@code File} does not point
145 * to valid audio file data recognized by the system
146 * @throws IOException if an I/O exception occurs
147 */
148 public abstract AudioInputStream getAudioInputStream(File file)
149 throws UnsupportedAudioFileException, IOException;
150 }
|