Overview Package Class Use Source Tree Index Deprecated About
GNU Classpath (0.95)
Frames | No Frames

Source for javax.sound.sampled.spi.FormatConversionProvider

 1:  /* Format conversion API
 2:  Copyright (C) 2005 Free Software Foundation, Inc.
 3: 
 4: This file is part of GNU Classpath.
 5: 
 6: GNU Classpath is free software; you can redistribute it and/or modify
 7: it under the terms of the GNU General Public License as published by
 8: the Free Software Foundation; either version 2, or (at your option)
 9: any later version.
 10: 
 11: GNU Classpath is distributed in the hope that it will be useful, but
 12: WITHOUT ANY WARRANTY; without even the implied warranty of
 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 14: General Public License for more details.
 15: 
 16: You should have received a copy of the GNU General Public License
 17: along with GNU Classpath; see the file COPYING. If not, write to the
 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19: 02110-1301 USA.
 20: 
 21: Linking this library statically or dynamically with other modules is
 22: making a combined work based on this library. Thus, the terms and
 23: conditions of the GNU General Public License cover the whole
 24: combination.
 25: 
 26: As a special exception, the copyright holders of this library give you
 27: permission to link this library with independent modules to produce an
 28: executable, regardless of the license terms of these independent
 29: modules, and to copy and distribute the resulting executable under
 30: terms of your choice, provided that you also meet, for each linked
 31: independent module, the terms and conditions of the license of that
 32: module. An independent module is a module which is not derived from
 33: or based on this library. If you modify this library, you may extend
 34: this exception to your version of the library, but you are not
 35: obligated to do so. If you do not wish to do so, delete this
 36: exception statement from your version. */
 37: 
 38: 
 39:  package javax.sound.sampled.spi;
 40: 
 41:  import javax.sound.sampled.AudioFormat;
 42:  import javax.sound.sampled.AudioInputStream;
 43: 
 44:  /**
 45:  * A format conversion provider supplies methods for converting between 
 46:  * different audio formats. This abstract class defines the interface
 47:  * to this functionality; concrete subclasses will implement the methods
 48:  * declared here.
 49:  * @since 1.3
 50:  */
 51:  public abstract class FormatConversionProvider
 52: {
 53:  /**
 54:  * Create a new format conversion provider.
 55:  */
 56:  public FormatConversionProvider()
 57:  {
 58:  }
 59: 
 60:  /**
 61:  * Return an audio input stream given the desired target encoding and
 62:  * another audio input stream. The data in the given stream will be
 63:  * converted to the desired encoding.
 64:  * @param encoding the encoding
 65:  * @param source the source audio input stream
 66:  * @return a new audio input stream
 67:  * @throws IllegalArgumentException if the conversion is not supported
 68:  */
 69:  public abstract AudioInputStream getAudioInputStream(AudioFormat.Encoding encoding,
 70:  AudioInputStream source);
 71: 
 72:  /**
 73:  * Return an audio input stream given the desired target format and
 74:  * another audio input stream. The data in the given stream will be
 75:  * converted to the desired format.
 76:  * @param format the format
 77:  * @param source the source audio input stream
 78:  * @return a new audio input stream
 79:  * @throws IllegalArgumentException if the conversion is not supported
 80:  */
 81:  public abstract AudioInputStream getAudioInputStream(AudioFormat format,
 82:  AudioInputStream source);
 83: 
 84:  /**
 85:  * Return an array of all the source encodings supported by this conversion
 86:  * provider.
 87:  */
 88:  public abstract AudioFormat.Encoding[] getSourceEncodings();
 89: 
 90:  /**
 91:  * Return an array of all the target encodings supported by this conversion
 92:  * provider.
 93:  */
 94:  public abstract AudioFormat.Encoding[] getTargetEncodings();
 95: 
 96:  /**
 97:  * Return an array of all the target encodings that are available for a given
 98:  * source format.
 99:  * @param fmt the source format
 100:  * @return an array of supported target encodings
 101:  */
 102:  public abstract AudioFormat.Encoding[] getTargetEncodings(AudioFormat fmt);
 103: 
 104:  /**
 105:  * Return a array of all the target formats that match given target encoding,
 106:  * and to which this provider can convert the source format.
 107:  * @param targ the target encoding to match
 108:  * @param src the source format
 109:  * @return an array of supported target formats
 110:  */
 111:  public abstract AudioFormat[] getTargetFormats(AudioFormat.Encoding targ,
 112:  AudioFormat src);
 113: 
 114:  /**
 115:  * Return true if this provider supports conversion from the given
 116:  * source format to the given target encoding.
 117:  * @param targ the target encoding
 118:  * @param src the source format
 119:  * @return true if the conversion is supported
 120:  */
 121:  public boolean isConversionSupported(AudioFormat.Encoding targ,
 122:  AudioFormat src)
 123:  {
 124:  AudioFormat.Encoding[] encodings = getTargetEncodings(src);
 125:  for (int i = 0; i < encodings.length; ++i)
 126:  {
 127:  if (targ.equals(encodings[i]))
 128:  return true;
 129:  }
 130:  return false;
 131:  }
 132: 
 133:  /**
 134:  * Return true if this provider supports conversions from the given
 135:  * source format to the given target format.
 136:  * @param targ the source format
 137:  * @param src the target format
 138:  * @return true if the conversion is supported
 139:  */
 140:  public boolean isConversionSupported(AudioFormat targ, AudioFormat src)
 141:  {
 142:  AudioFormat[] encodings = getTargetFormats(targ.getEncoding(), src);
 143:  return encodings.length > 0;
 144:  }
 145: 
 146:  /**
 147:  * Return true if an encoding matching the argument is supported as a
 148:  * source encoding by this provider.
 149:  * @param src the source encoding
 150:  * @return true if it is supported
 151:  */
 152:  public boolean isSourceEncodingSupported(AudioFormat.Encoding src)
 153:  {
 154:  AudioFormat.Encoding[] srcs = getSourceEncodings();
 155:  for (int i = 0; i < srcs.length; ++i)
 156:  {
 157:  if (src.equals(srcs[i]))
 158:  return true;
 159:  }
 160:  return false;
 161:  }
 162: 
 163:  /**
 164:  * Return true if an encoding matching the argument is supported as a 
 165:  * target encoding by this provider.
 166:  * @param targ the target encoding
 167:  * @return true if it is supported
 168:  */
 169:  public boolean isTargetEncodingSupported(AudioFormat.Encoding targ)
 170:  {
 171:  AudioFormat.Encoding[] encodings = getTargetEncodings();
 172:  for (int i = 0; i < encodings.length; ++i)
 173:  {
 174:  if (targ.equals(encodings[i]))
 175:  return true;
 176:  }
 177:  return false;
 178:  }
 179: }
Overview Package Class Use Source Tree Index Deprecated About
GNU Classpath (0.95)

AltStyle によって変換されたページ (->オリジナル) /