audio
Class AbstractCODEC

java.lang.Object
  extended by audio.AbstractCODEC
All Implemented Interfaces:
AudioInterface
Direct Known Subclasses:
AudioCodecAlaw, AudioCodecUlaw

public abstract class AbstractCODEC
extends java.lang.Object
implements AudioInterface

Base class for CODECs that can convert to and from PCM. The class wraps underlying AudioInterfacePCM that can find and talk to PCM hardware. Derived classes should only implement encoding/decoding part from/to PCM (methods AbstractCODEC.convertFromPCM() and AbstractCODEC.convertToPCM()).


Nested Class Summary
 
Nested classes/interfaces inherited from interface audio.AudioInterface
AudioInterface.Packetizer
 
Field Summary
protected  AudioInterfacePCM audio
          Instance of the audio interface that provides access to PCM (signed 16-bit linear) samples.
protected  byte[] inputPcmBuf
          Input PCM buffer (converted to CODEC) read from audio interface
protected  byte[] outputPcmBuf
          Output PCM buffer (converted from CODEC) written to audio interface
 
Constructor Summary
AbstractCODEC()
           
 
Method Summary
 void cleanUp()
          Cleans up resources used by the interface.
abstract  void convertFromPCM(byte[] in, byte[] out)
          Encodes data to PCM, i.e. converts samples from PCM to CODEC format.
abstract  void convertToPCM(byte[] in, byte[] out)
          Decodes data from PCM, i.e. converts samples from CODEC to PCM format.
 AudioInterface getByFormat(java.lang.Integer format)
          Creates new instance of the interface by choosing specified CODEC format
abstract  int getVoicePduSubclass()
          Gets the VoicePDU subclass attribute of the AbstractAudio object
 long readWithTimestamp(byte[] buf)
          Reads from the microphone, using the buffer provided, but only filling getSampSize() bytes.
 void setAudioSender(AudioInterface.Packetizer as)
          Sets the audioSender attribute of the AbstractAudio object
 void startPlay()
          Starts the player
 long startRecording()
          Starts the recorder (returning the time)
 void startRinging()
          Starts ringing signal
 void stopPlay()
          Stops the player
 void stopRecording()
          Stops the recorder - but don't throw it away.
 void stopRinging()
          Stops ringing signal
 void writeBuffered(byte[] buf, long timestamp)
          Plays the sample given (AudioInterface.getSampleSize() bytes) assuming that it's timestamp is long
 void writeDirectly(byte[] f)
          Writes directly to source line without buffering
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface audio.AudioInterface
getSampleSize
 

Field Detail

audio

protected AudioInterfacePCM audio
Instance of the audio interface that provides access to PCM (signed 16-bit linear) samples.


outputPcmBuf

protected byte[] outputPcmBuf
Output PCM buffer (converted from CODEC) written to audio interface


inputPcmBuf

protected byte[] inputPcmBuf
Input PCM buffer (converted to CODEC) read from audio interface

Constructor Detail

AbstractCODEC

public AbstractCODEC()
Method Detail

convertFromPCM

public abstract void convertFromPCM(byte[] in,
                                    byte[] out)
Encodes data to PCM, i.e. converts samples from PCM to CODEC format.


convertToPCM

public abstract void convertToPCM(byte[] in,
                                  byte[] out)
Decodes data from PCM, i.e. converts samples from CODEC to PCM format.


getVoicePduSubclass

public abstract int getVoicePduSubclass()
Gets the VoicePDU subclass attribute of the AbstractAudio object

Specified by:
getVoicePduSubclass in interface AudioInterface

stopRecording

public void stopRecording()
Stops the recorder - but don't throw it away.

Specified by:
stopRecording in interface AudioInterface

startRecording

public long startRecording()
Starts the recorder (returning the time)

Specified by:
startRecording in interface AudioInterface

startPlay

public void startPlay()
Starts the player

Specified by:
startPlay in interface AudioInterface

stopPlay

public void stopPlay()
Stops the player

Specified by:
stopPlay in interface AudioInterface

startRinging

public void startRinging()
Starts ringing signal

Specified by:
startRinging in interface AudioInterface

stopRinging

public void stopRinging()
Stops ringing signal

Specified by:
stopRinging in interface AudioInterface

writeBuffered

public void writeBuffered(byte[] buf,
                          long timestamp)
                   throws java.io.IOException
Plays the sample given (AudioInterface.getSampleSize() bytes) assuming that it's timestamp is long

Specified by:
writeBuffered in interface AudioInterface
Throws:
java.io.IOException

readWithTimestamp

public long readWithTimestamp(byte[] buf)
                       throws java.io.IOException
Reads from the microphone, using the buffer provided, but only filling getSampSize() bytes. Returns the time-stamp of the sample from the audio clock.

Specified by:
readWithTimestamp in interface AudioInterface
Throws:
java.io.IOException

writeDirectly

public void writeDirectly(byte[] f)
Writes directly to source line without buffering

Specified by:
writeDirectly in interface AudioInterface

setAudioSender

public void setAudioSender(AudioInterface.Packetizer as)
Sets the audioSender attribute of the AbstractAudio object

Specified by:
setAudioSender in interface AudioInterface

cleanUp

public void cleanUp()
Cleans up resources used by the interface.

Specified by:
cleanUp in interface AudioInterface

getByFormat

public AudioInterface getByFormat(java.lang.Integer format)
Creates new instance of the interface by choosing specified CODEC format

Specified by:
getByFormat in interface AudioInterface