APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.media.sound

public final Class UlawCodec

extends FormatConversionProvider
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Objects, javax.sound.sampled.AudioFormat, .AudioFormat.Encoding, .AudioInputStream, .AudioSystem, javax.sound.sampled.spi.FormatConversionProvider

U-law encodes linear data, and decodes u-law data to linear data.
Author
Kara Kytle

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private static final short[]
private static final byte[]
private static final byte[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public AudioInputStream
getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Obtains an audio input stream with the specified encoding from the given audio input stream.

public AudioInputStream
getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Obtains an audio input stream with the specified format from the given audio input stream.

private AudioInputStream

Returns:

stream from which processed data may be read
getConvertedStream
(AudioFormat
desired data format of the stream after processing
outputFormat
,
AudioInputStream
stream from which data to be processed should be read
stream
)

Opens the codec with the specified parameters.

private AudioFormat[]

Returns:

array of supported output formats.
getOutputFormats
(AudioFormat inputFormat)

Obtains the set of output formats supported by the codec given a particular input format.

public AudioFormat.Encoding[]
getSourceEncodings()

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getSourceEncodings.

Obtains the set of source format encodings from which format conversion services are provided by this provider.

public AudioFormat.Encoding[]
getTargetEncodings()

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Obtains the set of target format encodings to which format conversion services are provided by this provider.

public AudioFormat.Encoding[]
getTargetEncodings(AudioFormat sourceFormat)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Obtains the set of target format encodings supported by the format converter given a particular source format.

public AudioFormat[]
getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetFormats.

Obtains the set of target formats with the encoding specified supported by the format converter.

Inherited from javax.sound.sampled.spi.FormatConversionProvider:
isConversionSupportedisConversionSupportedisSourceEncodingSupportedisTargetEncodingSupported

Field Detail

seg_endback to summary
private static final short[] seg_end
ULAW_TABHback to summary
private static final byte[] ULAW_TABH
ULAW_TABLback to summary
private static final byte[] ULAW_TABL

Constructor Detail

UlawCodecback to summary
public UlawCodec()

Method Detail

getAudioInputStreamback to summary
public AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Obtains an audio input stream with the specified encoding from the given audio input stream.

Annotations
@Override
getAudioInputStreamback to summary
public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getAudioInputStream.

Obtains an audio input stream with the specified format from the given audio input stream.

Annotations
@Override
getConvertedStreamback to summary
private AudioInputStream getConvertedStream(AudioFormat outputFormat, AudioInputStream stream)

Opens the codec with the specified parameters.

Parameters
outputFormat:AudioFormat

desired data format of the stream after processing

stream:AudioInputStream

stream from which data to be processed should be read

Returns:AudioInputStream

stream from which processed data may be read

Exceptions
IllegalArgumentException:
if the format combination supplied is not supported.
getOutputFormatsback to summary
private AudioFormat[] getOutputFormats(AudioFormat inputFormat)

Obtains the set of output formats supported by the codec given a particular input format. If no output formats are supported for this input format, returns an array of length 0.

Returns:AudioFormat[]

array of supported output formats.

getSourceEncodingsback to summary
public AudioFormat.Encoding[] getSourceEncodings()

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getSourceEncodings.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getSourceEncodings.

Obtains the set of source format encodings from which format conversion services are provided by this provider.

Annotations
@Override
getTargetEncodingsback to summary
public AudioFormat.Encoding[] getTargetEncodings()

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Obtains the set of target format encodings to which format conversion services are provided by this provider.

Annotations
@Override
getTargetEncodingsback to summary
public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getTargetEncodings.

Obtains the set of target format encodings supported by the format converter given a particular source format. If no target format encodings are supported for this source format, an array of length 0 is returned.

Annotations
@Override
getTargetFormatsback to summary
public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat)

Implements abstract javax.sound.sampled.spi.FormatConversionProvider.getTargetFormats.

Doc from javax.sound.sampled.spi.FormatConversionProvider.getTargetFormats.

Obtains the set of target formats with the encoding specified supported by the format converter. If no target formats with the specified encoding are supported for this source format, an array of length 0 is returned.

Annotations
@Override
com.sun.media.sound back to summary

private final Class UlawCodec.UlawCodecStream

extends AudioInputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv AudioFormat
pack-priv boolean
encode

True to encode to u-law, false to decode to linear.

pack-priv AudioFormat
pack-priv int
pack-priv int
pack-priv byte[]
pack-priv byte[]
private byte[]
private static final int
Inherited from javax.sound.sampled.AudioInputStream:
formatframeLengthframePosframeSize

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
read()

Overrides javax.sound.sampled.AudioInputStream.read.

Note that this won't actually read anything; must read in two-byte units.

public int
read(byte[] b)

Overrides javax.sound.sampled.AudioInputStream.read.

Reads some number of bytes from the audio input stream and stores them into the buffer array b.

public int
read(byte[] b, int off, int len)

Overrides javax.sound.sampled.AudioInputStream.read.

Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array.

private short
search(short val, short[] table, short size)

public long
skip(final long n)

Overrides javax.sound.sampled.AudioInputStream.skip.

Skips over and discards a specified number of bytes from this audio input stream.

Inherited from javax.sound.sampled.AudioInputStream:
availableclosegetFormatgetFrameLengthmarkmarkSupportedreset

Field Detail

decodeFormatback to summary
pack-priv AudioFormat decodeFormat
encodeback to summary
pack-priv boolean encode

True to encode to u-law, false to decode to linear.

encodeFormatback to summary
pack-priv AudioFormat encodeFormat
highByteback to summary
pack-priv int highByte
lowByteback to summary
pack-priv int lowByte
tabByte1back to summary
pack-priv byte[] tabByte1
tabByte2back to summary
pack-priv byte[] tabByte2
tempBufferback to summary
private byte[] tempBuffer
tempBufferSizeback to summary
private static final int tempBufferSize

Constructor Detail

UlawCodecStreamback to summary
pack-priv UlawCodecStream(AudioInputStream stream, AudioFormat outputFormat)

Method Detail

readback to summary
public int read() throws IOException

Overrides javax.sound.sampled.AudioInputStream.read.

Note that this won't actually read anything; must read in two-byte units.

Annotations
@Override
Exceptions
IOException:

Doc from javax.sound.sampled.AudioInputStream.read.

if an input or output error occurs

readback to summary
public int read(byte[] b) throws IOException

Overrides javax.sound.sampled.AudioInputStream.read.

Doc from javax.sound.sampled.AudioInputStream.read.

Reads some number of bytes from the audio input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

This method will always read an integral number of frames. If the length of the array is not an integral number of frames, a maximum of b.length - (b.length % frameSize) bytes will be read.

Annotations
@Override
Exceptions
IOException:
if an input or output error occurs
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides javax.sound.sampled.AudioInputStream.read.

Doc from javax.sound.sampled.AudioInputStream.read.

Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array.

This method will always read an integral number of frames. If len does not specify an integral number of frames, a maximum of len - (len % frameSize) bytes will be read.

Annotations
@Override
Exceptions
IOException:
if an input or output error occurs
searchback to summary
private short search(short val, short[] table, short size)
skipback to summary
public long skip(final long n) throws IOException

Overrides javax.sound.sampled.AudioInputStream.skip.

Doc from javax.sound.sampled.AudioInputStream.skip.

Skips over and discards a specified number of bytes from this audio input stream.

This method will always skip an integral number of frames. If n does not specify an integral number of frames, a maximum of n - (n % frameSize) bytes will be skipped.

Annotations
@Override
Exceptions
IOException:
if an input or output error occurs