1 /*
2 * Copyright (c) 1999, 2003, 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
99 * @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
100 */
101 public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding){
102
103 AudioFormat.Encoding targetEncodings[] = getTargetEncodings();
104
105 for(int i=0; i<targetEncodings.length; i++) {
106 if( targetEncoding.equals( targetEncodings[i]) ) {
107 return true;
108 }
109 }
110 return false;
111 }
112
113
114 /**
115 * Obtains the set of target format encodings supported by the format converter
116 * given a particular source format.
117 * If no target format encodings are supported for this source format,
118 * an array of length 0 is returned.
119 * @return array of supported target format encodings.
120 */
121 public abstract AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat);
122
123
124 /**
125 * Indicates whether the format converter supports conversion to a particular encoding
126 * from a particular format.
127 * @param targetEncoding desired encoding of the outgoing data
128 * @param sourceFormat format of the incoming data
129 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
130 */
131 public boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
132
133 AudioFormat.Encoding targetEncodings[] = getTargetEncodings(sourceFormat);
134
135 for(int i=0; i<targetEncodings.length; i++) {
136 if( targetEncoding.equals( targetEncodings[i]) ) {
137 return true;
138 }
139 }
140 return false;
141 }
142
143
144 /**
145 * Obtains the set of target formats with the encoding specified
146 * supported by the format converter
147 * If no target formats with the specified encoding are supported
148 * for this source format, an array of length 0 is returned.
149 * @return array of supported target formats.
150 */
151 public abstract AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat);
152
153
154 /**
155 * Indicates whether the format converter supports conversion to one
156 * particular format from another.
157 * @param targetFormat desired format of outgoing data
158 * @param sourceFormat format of the incoming data
159 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
160 */
161 public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){
162
163 AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );
164
165 for(int i=0; i<targetFormats.length; i++) {
166 if( targetFormat.matches( targetFormats[i] ) ) {
167 return true;
168 }
|
1 /*
2 * Copyright (c) 1999, 2013, 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
99 * @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
100 */
101 public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding){
102
103 AudioFormat.Encoding targetEncodings[] = getTargetEncodings();
104
105 for(int i=0; i<targetEncodings.length; i++) {
106 if( targetEncoding.equals( targetEncodings[i]) ) {
107 return true;
108 }
109 }
110 return false;
111 }
112
113
114 /**
115 * Obtains the set of target format encodings supported by the format converter
116 * given a particular source format.
117 * If no target format encodings are supported for this source format,
118 * an array of length 0 is returned.
119 * @param sourceFormat format of the incoming data
120 * @return array of supported target format encodings.
121 */
122 public abstract AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat);
123
124
125 /**
126 * Indicates whether the format converter supports conversion to a particular encoding
127 * from a particular format.
128 * @param targetEncoding desired encoding of the outgoing data
129 * @param sourceFormat format of the incoming data
130 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
131 */
132 public boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
133
134 AudioFormat.Encoding targetEncodings[] = getTargetEncodings(sourceFormat);
135
136 for(int i=0; i<targetEncodings.length; i++) {
137 if( targetEncoding.equals( targetEncodings[i]) ) {
138 return true;
139 }
140 }
141 return false;
142 }
143
144
145 /**
146 * Obtains the set of target formats with the encoding specified
147 * supported by the format converter
148 * If no target formats with the specified encoding are supported
149 * for this source format, an array of length 0 is returned.
150 * @param targetEncoding desired encoding of the stream after processing
151 * @param sourceFormat format of the incoming data
152 * @return array of supported target formats.
153 */
154 public abstract AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat);
155
156
157 /**
158 * Indicates whether the format converter supports conversion to one
159 * particular format from another.
160 * @param targetFormat desired format of outgoing data
161 * @param sourceFormat format of the incoming data
162 * @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
163 */
164 public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){
165
166 AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );
167
168 for(int i=0; i<targetFormats.length; i++) {
169 if( targetFormat.matches( targetFormats[i] ) ) {
170 return true;
171 }
|