01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package javax.sound.sampled.spi;
19:
20: import javax.sound.sampled.AudioFormat;
21: import javax.sound.sampled.AudioInputStream;
22: import javax.sound.sampled.AudioFormat.Encoding;
23:
24: public abstract class FormatConversionProvider {
25:
26: public abstract AudioInputStream getAudioInputStream(
27: AudioFormat.Encoding targetEncoding,
28: AudioInputStream sourceStream);
29:
30: public abstract AudioInputStream getAudioInputStream(
31: AudioFormat targetFormat, AudioInputStream sourceStream);
32:
33: public abstract AudioFormat.Encoding[] getTargetEncodings(
34: AudioFormat sourceFormat);
35:
36: public boolean isConversionSupported(
37: AudioFormat.Encoding targetEncoding,
38: AudioFormat sourceFormat) {
39: AudioFormat.Encoding[] encodings = getTargetEncodings(sourceFormat);
40: for (Encoding element : encodings) {
41: if (targetEncoding.equals(element)) {
42: return true;
43: }
44: }
45: return false;
46: }
47:
48: public abstract AudioFormat[] getTargetFormats(
49: AudioFormat.Encoding targetFormat, AudioFormat sourceFormat);
50:
51: public boolean isConversionSupported(AudioFormat targetFormat,
52: AudioFormat sourceFormat) {
53: AudioFormat[] formats = getTargetFormats(targetFormat
54: .getEncoding(), sourceFormat);
55: for (AudioFormat element : formats) {
56: if (targetFormat.equals(element)) {
57: return true;
58: }
59: }
60: return false;
61: }
62:
63: public abstract AudioFormat.Encoding[] getSourceEncodings();
64:
65: public boolean isSourceEncodingSupported(
66: AudioFormat.Encoding sourceEncoding) {
67: AudioFormat.Encoding[] encodings = getSourceEncodings();
68: for (Encoding element : encodings) {
69: if (sourceEncoding.equals(element)) {
70: return true;
71: }
72: }
73: return false;
74: }
75:
76: public abstract AudioFormat.Encoding[] getTargetEncodings();
77:
78: public boolean isTargetEncodingSupported(
79: AudioFormat.Encoding targetEncoding) {
80: AudioFormat.Encoding[] encodings = getTargetEncodings();
81: for (Encoding element : encodings) {
82: if (targetEncoding.equals(element)) {
83: return true;
84: }
85: }
86: return false;
87: }
88:
89: }
|