author | darcy |
Thu, 04 Jun 2015 18:11:43 -0700 | |
changeset 30967 | cfeec3444c25 |
parent 26037 | 508779ce6619 |
child 34412 | bed825be8cd8 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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 |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.sound.sampled.spi; |
|
27 |
||
28 |
import java.io.File; |
|
29 |
import java.io.IOException; |
|
30 |
import java.io.OutputStream; |
|
31 |
||
32 |
import javax.sound.sampled.AudioInputStream; |
|
26003
d630c97424bd
8050852: Javadoc cleanup of javax.sound.midi package
serb
parents:
24561
diff
changeset
|
33 |
import javax.sound.sampled.AudioSystem; |
2 | 34 |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
35 |
import static javax.sound.sampled.AudioFileFormat.Type; |
2 | 36 |
|
37 |
/** |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
38 |
* Provider for audio file writing services. Classes providing concrete |
2 | 39 |
* implementations can write one or more types of audio file from an audio |
40 |
* stream. |
|
41 |
* |
|
42 |
* @author Kara Kytle |
|
43 |
* @since 1.3 |
|
44 |
*/ |
|
45 |
public abstract class AudioFileWriter { |
|
46 |
||
47 |
/** |
|
48 |
* Obtains the file types for which file writing support is provided by this |
|
49 |
* audio file writer. |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
50 |
* |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
51 |
* @return array of file types. If no file types are supported, an array of |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
52 |
* length 0 is returned. |
2 | 53 |
*/ |
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
54 |
public abstract Type[] getAudioFileTypes(); |
2 | 55 |
|
56 |
/** |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
57 |
* Indicates whether file writing support for the specified file type is |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
58 |
* provided by this audio file writer. |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
59 |
* |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
60 |
* @param fileType the file type for which write capabilities are queried |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
61 |
* @return {@code true} if the file type is supported, otherwise |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
62 |
* {@code false} |
2 | 63 |
*/ |
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
64 |
public boolean isFileTypeSupported(Type fileType) { |
2 | 65 |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
66 |
Type types[] = getAudioFileTypes(); |
2 | 67 |
|
68 |
for(int i=0; i<types.length; i++) { |
|
69 |
if( fileType.equals( types[i] ) ) { |
|
70 |
return true; |
|
71 |
} |
|
72 |
} |
|
73 |
return false; |
|
74 |
} |
|
75 |
||
76 |
/** |
|
77 |
* Obtains the file types that this audio file writer can write from the |
|
78 |
* audio input stream specified. |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
79 |
* |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
80 |
* @param stream the audio input stream for which audio file type support |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
81 |
* is queried |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
82 |
* @return array of file types. If no file types are supported, an array of |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
83 |
* length 0 is returned. |
2 | 84 |
*/ |
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
85 |
public abstract Type[] getAudioFileTypes(AudioInputStream stream); |
2 | 86 |
|
87 |
/** |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
88 |
* Indicates whether an audio file of the type specified can be written from |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
89 |
* the audio input stream indicated. |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
90 |
* |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
91 |
* @param fileType file type for which write capabilities are queried |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
92 |
* @param stream for which file writing support is queried |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
93 |
* @return {@code true} if the file type is supported for this audio input |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
94 |
* stream, otherwise {@code false} |
2 | 95 |
*/ |
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
96 |
public boolean isFileTypeSupported(Type fileType, AudioInputStream stream) { |
2 | 97 |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
98 |
Type types[] = getAudioFileTypes( stream ); |
2 | 99 |
|
100 |
for(int i=0; i<types.length; i++) { |
|
101 |
if( fileType.equals( types[i] ) ) { |
|
102 |
return true; |
|
103 |
} |
|
104 |
} |
|
105 |
return false; |
|
106 |
} |
|
107 |
||
108 |
/** |
|
109 |
* Writes a stream of bytes representing an audio file of the file type |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
110 |
* indicated to the output stream provided. Some file types require that |
2 | 111 |
* the length be written into the file header, and cannot be written from |
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
112 |
* start to finish unless the length is known in advance. An attempt to |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
113 |
* write such a file type will fail with an IOException if the length in the |
26003
d630c97424bd
8050852: Javadoc cleanup of javax.sound.midi package
serb
parents:
24561
diff
changeset
|
114 |
* audio file format is {@link AudioSystem#NOT_SPECIFIED}. |
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
115 |
* |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
116 |
* @param stream the audio input stream containing audio data to be written |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
117 |
* to the output stream |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
118 |
* @param fileType file type to be written to the output stream |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
119 |
* @param out stream to which the file data should be written |
2 | 120 |
* @return the number of bytes written to the output stream |
121 |
* @throws IOException if an I/O exception occurs |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
122 |
* @throws IllegalArgumentException if the file type is not supported by the |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
123 |
* system |
30967
cfeec3444c25
8083664: Update AudioFileWriter to generate working @see reference
darcy
parents:
26037
diff
changeset
|
124 |
* @see #isFileTypeSupported(AudioFileFormat.Type, AudioInputStream) |
2 | 125 |
* @see #getAudioFileTypes |
126 |
*/ |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
127 |
public abstract int write(AudioInputStream stream, Type fileType, |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
128 |
OutputStream out) throws IOException; |
2 | 129 |
|
130 |
/** |
|
131 |
* Writes a stream of bytes representing an audio file of the file format |
|
132 |
* indicated to the external file provided. |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
133 |
* |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
134 |
* @param stream the audio input stream containing audio data to be written |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
135 |
* to the file |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
136 |
* @param fileType file type to be written to the file |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
137 |
* @param out external file to which the file data should be written |
2 | 138 |
* @return the number of bytes written to the file |
139 |
* @throws IOException if an I/O exception occurs |
|
140 |
* @throws IllegalArgumentException if the file format is not supported by |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
141 |
* the system |
2 | 142 |
* @see #isFileTypeSupported |
143 |
* @see #getAudioFileTypes |
|
144 |
*/ |
|
24561
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
145 |
public abstract int write(AudioInputStream stream, Type fileType, File out) |
81c6f1aff26e
8042007: Javadoc cleanup of javax.sound.sampled.spi package
serb
parents:
5506
diff
changeset
|
146 |
throws IOException; |
2 | 147 |
} |