Path: blob/master/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java
41171 views
/*1* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.sound.sampled.spi;2627import java.io.File;28import java.io.IOException;29import java.io.InputStream;30import java.net.URL;3132import javax.sound.sampled.AudioFileFormat;33import javax.sound.sampled.AudioInputStream;34import javax.sound.sampled.UnsupportedAudioFileException;3536/**37* Provider for audio file reading services. Classes providing concrete38* implementations can parse the format information from one or more types of39* audio file, and can produce audio input streams from files of these types.40*41* @author Kara Kytle42* @since 1.343*/44public abstract class AudioFileReader {4546/**47* Constructor for subclasses to call.48*/49protected AudioFileReader() {}5051/**52* Obtains the audio file format of the input stream provided. The stream53* must point to valid audio file data. In general, audio file readers may54* need to read some data from the stream before determining whether they55* support it. These parsers must be able to mark the stream, read enough56* data to determine whether they support the stream, and reset the stream's57* read pointer to its original position. If the input stream does not58* support this, this method may fail with an {@code IOException}.59*60* @param stream the input stream from which file format information should61* be extracted62* @return an {@code AudioFileFormat} object describing the audio file63* format64* @throws UnsupportedAudioFileException if the stream does not point to65* valid audio file data recognized by the system66* @throws IOException if an I/O exception occurs67* @throws NullPointerException if {@code stream} is {@code null}68* @see InputStream#markSupported69* @see InputStream#mark70*/71public abstract AudioFileFormat getAudioFileFormat(InputStream stream)72throws UnsupportedAudioFileException, IOException;7374/**75* Obtains the audio file format of the {@code URL} provided. The76* {@code URL} must point to valid audio file data.77*78* @param url the {@code URL} from which file format information should be79* extracted80* @return an {@code AudioFileFormat} object describing the audio file81* format82* @throws UnsupportedAudioFileException if the {@code URL} does not point83* to valid audio file data recognized by the system84* @throws IOException if an I/O exception occurs85* @throws NullPointerException if {@code url} is {@code null}86*/87public abstract AudioFileFormat getAudioFileFormat(URL url)88throws UnsupportedAudioFileException, IOException;8990/**91* Obtains the audio file format of the {@code File} provided. The92* {@code File} must point to valid audio file data.93*94* @param file the {@code File} from which file format information should95* be extracted96* @return an {@code AudioFileFormat} object describing the audio file97* format98* @throws UnsupportedAudioFileException if the {@code File} does not point99* to valid audio file data recognized by the system100* @throws IOException if an I/O exception occurs101* @throws NullPointerException if {@code file} is {@code null}102*/103public abstract AudioFileFormat getAudioFileFormat(File file)104throws UnsupportedAudioFileException, IOException;105106/**107* Obtains an audio input stream from the input stream provided. The stream108* must point to valid audio file data. In general, audio file readers may109* need to read some data from the stream before determining whether they110* support it. These parsers must be able to mark the stream, read enough111* data to determine whether they support the stream, and reset the stream's112* read pointer to its original position. If the input stream does not113* support this, this method may fail with an {@code IOException}.114*115* @param stream the input stream from which the {@code AudioInputStream}116* should be constructed117* @return an {@code AudioInputStream} object based on the audio file data118* contained in the input stream119* @throws UnsupportedAudioFileException if the stream does not point to120* valid audio file data recognized by the system121* @throws IOException if an I/O exception occurs122* @throws NullPointerException if {@code stream} is {@code null}123* @see InputStream#markSupported124* @see InputStream#mark125*/126public abstract AudioInputStream getAudioInputStream(InputStream stream)127throws UnsupportedAudioFileException, IOException;128129/**130* Obtains an audio input stream from the {@code URL} provided. The131* {@code URL} must point to valid audio file data.132*133* @param url the {@code URL} for which the {@code AudioInputStream} should134* be constructed135* @return an {@code AudioInputStream} object based on the audio file data136* pointed to by the {@code URL}137* @throws UnsupportedAudioFileException if the {@code URL} does not point138* to valid audio file data recognized by the system139* @throws IOException if an I/O exception occurs140* @throws NullPointerException if {@code url} is {@code null}141*/142public abstract AudioInputStream getAudioInputStream(URL url)143throws UnsupportedAudioFileException, IOException;144145/**146* Obtains an audio input stream from the {@code File} provided. The147* {@code File} must point to valid audio file data.148*149* @param file the {@code File} for which the {@code AudioInputStream}150* should be constructed151* @return an {@code AudioInputStream} object based on the audio file data152* pointed to by the File153* @throws UnsupportedAudioFileException if the {@code File} does not point154* to valid audio file data recognized by the system155* @throws IOException if an I/O exception occurs156* @throws NullPointerException if {@code file} is {@code null}157*/158public abstract AudioInputStream getAudioInputStream(File file)159throws UnsupportedAudioFileException, IOException;160}161162163