Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/sound/sampled/spi/AudioFileReader.java
38918 views
/*1* Copyright (c) 1999, 2002, 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.InputStream;29import java.io.IOException;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* Obtains the audio file format of the input stream provided. The stream must48* point to valid audio file data. In general, audio file readers may49* need to read some data from the stream before determining whether they50* support it. These parsers must51* be able to mark the stream, read enough data to determine whether they52* support the stream, and, if not, reset the stream's read pointer to its original53* position. If the input stream does not support this, this method may fail54* with an <code>IOException</code>.55* @param stream the input stream from which file format information should be56* extracted57* @return an <code>AudioFileFormat</code> object describing the audio file format58* @throws UnsupportedAudioFileException if the stream does not point to valid audio59* file data recognized by the system60* @throws IOException if an I/O exception occurs61* @see InputStream#markSupported62* @see InputStream#mark63*/64public abstract AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException;6566/**67* Obtains the audio file format of the URL provided. The URL must68* point to valid audio file data.69* @param url the URL from which file format information should be70* extracted71* @return an <code>AudioFileFormat</code> object describing the audio file format72* @throws UnsupportedAudioFileException if the URL does not point to valid audio73* file data recognized by the system74* @throws IOException if an I/O exception occurs75*/76public abstract AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException;7778/**79* Obtains the audio file format of the <code>File</code> provided. The <code>File</code> must80* point to valid audio file data.81* @param file the <code>File</code> from which file format information should be82* extracted83* @return an <code>AudioFileFormat</code> object describing the audio file format84* @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio85* file data recognized by the system86* @throws IOException if an I/O exception occurs87*/88public abstract AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException;8990/**91* Obtains an audio input stream from the input stream provided. The stream must92* point to valid audio file data. In general, audio file readers may93* need to read some data from the stream before determining whether they94* support it. These parsers must95* be able to mark the stream, read enough data to determine whether they96* support the stream, and, if not, reset the stream's read pointer to its original97* position. If the input stream does not support this, this method may fail98* with an <code>IOException</code>.99* @param stream the input stream from which the <code>AudioInputStream</code> should be100* constructed101* @return an <code>AudioInputStream</code> object based on the audio file data contained102* in the input stream.103* @throws UnsupportedAudioFileException if the stream does not point to valid audio104* file data recognized by the system105* @throws IOException if an I/O exception occurs106* @see InputStream#markSupported107* @see InputStream#mark108*/109public abstract AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException;110111/**112* Obtains an audio input stream from the URL provided. The URL must113* point to valid audio file data.114* @param url the URL for which the <code>AudioInputStream</code> should be115* constructed116* @return an <code>AudioInputStream</code> object based on the audio file data pointed117* to by the URL118* @throws UnsupportedAudioFileException if the URL does not point to valid audio119* file data recognized by the system120* @throws IOException if an I/O exception occurs121*/122public abstract AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException;123124/**125* Obtains an audio input stream from the <code>File</code> provided. The <code>File</code> must126* point to valid audio file data.127* @param file the <code>File</code> for which the <code>AudioInputStream</code> should be128* constructed129* @return an <code>AudioInputStream</code> object based on the audio file data pointed130* to by the File131* @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio132* file data recognized by the system133* @throws IOException if an I/O exception occurs134*/135public abstract AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException;136}137138139