1 7 8 package javax.sound.sampled.spi; 9 10 import java.io.InputStream ; 11 12 import javax.sound.sampled.AudioFormat ; 13 import javax.sound.sampled.AudioInputStream ; 14 15 34 public abstract class FormatConversionProvider { 35 36 37 39 45 public abstract AudioFormat.Encoding [] getSourceEncodings(); 46 47 48 54 public abstract AudioFormat.Encoding [] getTargetEncodings(); 55 56 57 63 public boolean isSourceEncodingSupported(AudioFormat.Encoding sourceEncoding){ 64 65 AudioFormat.Encoding sourceEncodings[] = getSourceEncodings(); 66 67 for(int i=0; i<sourceEncodings.length; i++) { 68 if( sourceEncoding.equals( sourceEncodings[i]) ) { 69 return true; 70 } 71 } 72 return false; 73 } 74 75 76 82 public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding){ 83 84 AudioFormat.Encoding targetEncodings[] = getTargetEncodings(); 85 86 for(int i=0; i<targetEncodings.length; i++) { 87 if( targetEncoding.equals( targetEncodings[i]) ) { 88 return true; 89 } 90 } 91 return false; 92 } 93 94 95 102 public abstract AudioFormat.Encoding [] getTargetEncodings(AudioFormat sourceFormat); 103 104 105 112 public boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){ 113 114 AudioFormat.Encoding targetEncodings[] = getTargetEncodings(sourceFormat); 115 116 for(int i=0; i<targetEncodings.length; i++) { 117 if( targetEncoding.equals( targetEncodings[i]) ) { 118 return true; 119 } 120 } 121 return false; 122 } 123 124 125 132 public abstract AudioFormat [] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat); 133 134 135 142 public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){ 143 144 AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat ); 145 146 for(int i=0; i<targetFormats.length; i++) { 147 if( targetFormat.matches( targetFormats[i] ) ) { 148 return true; 149 } 150 } 151 return false; 152 } 153 154 155 164 public abstract AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream); 165 166 167 176 public abstract AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream); 177 178 } 179 | Popular Tags |