Public Member Functions | Protected Attributes

audio.AbstractCODEC Class Reference

Base class for CODECs that can convert to and from PCM. More...

Inheritance diagram for audio.AbstractCODEC:
Inheritance graph
[legend]
Collaboration diagram for audio.AbstractCODEC:
Collaboration graph
[legend]

List of all members.

Public Member Functions

abstract void convertFromPCM (byte[] in, byte[] out)
 Encodes data to PCM, i.e.
abstract void convertToPCM (byte[] in, byte[] out)
 Decodes data from PCM, i.e.
abstract int getVoicePduSubclass ()
 Gets the VoicePDU subclass attribute of the AbstractAudio object.
void stopRecording ()
 Stops the recorder - but don't throw it away.
long startRecording ()
 Starts the recorder (returning the time)
void startPlay ()
 Starts the player.
void stopPlay ()
 Stops the player.
void startRinging ()
 Starts ringing signal.
void stopRinging ()
 Stops ringing signal.
void writeBuffered (byte[] buf, long timestamp) throws IOException
 Plays the sample given (AudioInterface.getSampleSize() bytes) assuming that it's timestamp is long.
long readWithTimestamp (byte[] buf) throws IOException
 Reads from the microphone, using the buffer provided, but only filling getSampSize() bytes.
void writeDirectly (byte[] f)
 Writes directly to source line without buffering.
void setAudioSender (AudioInterface.Packetizer as)
 Sets the audioSender attribute of the AbstractAudio object.
void cleanUp ()
 Cleans up resources used by the interface.
AudioInterface getByFormat (Integer format)
 Creates new instance of the interface by choosing specified CODEC format.

Protected Attributes

AudioInterfacePCM audio
 Instance of the audio interface that provides access to PCM (signed 16-bit linear) samples.
byte[] outputPcmBuf
 Output PCM buffer (converted from CODEC) written to audio interface.
byte[] inputPcmBuf
 Input PCM buffer (converted to CODEC) read from audio interface.

Detailed Description

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()).

Definition at line 12 of file AbstractCODEC.java.


Member Function Documentation

void audio.AbstractCODEC.cleanUp (  ) [virtual]

Cleans up resources used by the interface.

Implements audio.AudioInterface.

Definition at line 136 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, and audio.AudioInterfacePCM.cleanUp().

    {
        audio.cleanUp ();
    }
abstract void audio.AbstractCODEC.convertFromPCM ( byte[]  in,
byte[]  out 
) [pure virtual]

Encodes data to PCM, i.e.

converts samples from PCM to CODEC format.

Implemented in audio.AudioCodecAlaw, and audio.AudioCodecUlaw.

Referenced by audio.AbstractCODEC.readWithTimestamp().

abstract void audio.AbstractCODEC.convertToPCM ( byte[]  in,
byte[]  out 
) [pure virtual]

Decodes data from PCM, i.e.

converts samples from CODEC to PCM format.

Implemented in audio.AudioCodecAlaw, and audio.AudioCodecUlaw.

Referenced by audio.AbstractCODEC.writeBuffered(), and audio.AbstractCODEC.writeDirectly().

AudioInterface audio.AbstractCODEC.getByFormat ( Integer  format ) [virtual]

Creates new instance of the interface by choosing specified CODEC format.

Implements audio.AudioInterface.

Definition at line 144 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, and audio.AudioInterfacePCM.getByFormat().

    {
        return audio.getByFormat(format);
    }
abstract int audio.AbstractCODEC.getVoicePduSubclass (  ) [pure virtual]

Gets the VoicePDU subclass attribute of the AbstractAudio object.

Implements audio.AudioInterface.

Implemented in audio.AudioCodecAlaw, and audio.AudioCodecUlaw.

long audio.AbstractCODEC.readWithTimestamp ( byte[]  buf ) throws IOException [virtual]

Reads from the microphone, using the buffer provided, but only filling getSampSize() bytes.

Returns the time-stamp of the sample from the audio clock.

Implements audio.AudioInterface.

Definition at line 108 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, audio.AbstractCODEC.convertFromPCM(), audio.AbstractCODEC.inputPcmBuf, and audio.AudioInterfacePCM.readWithTimestamp().

    {
        long ret = audio.readWithTimestamp( inputPcmBuf );
        convertFromPCM( inputPcmBuf, buf );
        return ret;
    }
void audio.AbstractCODEC.setAudioSender ( AudioInterface.Packetizer  as ) [virtual]

Sets the audioSender attribute of the AbstractAudio object.

Implements audio.AudioInterface.

Definition at line 128 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, and audio.AudioInterfacePCM.setAudioSender().

    {
        audio.setAudioSender( as );
    }
void audio.AbstractCODEC.startPlay (  ) [virtual]

Starts the player.

Implements audio.AudioInterface.

Definition at line 64 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, and audio.AudioInterfacePCM.startPlay().

    {
        audio.startPlay();
    }
long audio.AbstractCODEC.startRecording (  ) [virtual]

Starts the recorder (returning the time)

Implements audio.AudioInterface.

Definition at line 56 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, and audio.AudioInterfacePCM.startRecording().

    {
        return audio.startRecording ();
    }
void audio.AbstractCODEC.startRinging (  ) [virtual]

Starts ringing signal.

Implements audio.AudioInterface.

Definition at line 80 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, and audio.AudioInterfacePCM.startRinging().

    {
        audio.startRinging ();
    }
void audio.AbstractCODEC.stopPlay (  ) [virtual]

Stops the player.

Implements audio.AudioInterface.

Definition at line 72 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, and audio.AudioInterfacePCM.stopPlay().

    {
        audio.stopPlay();
    }
void audio.AbstractCODEC.stopRecording (  ) [virtual]

Stops the recorder - but don't throw it away.

Implements audio.AudioInterface.

Definition at line 48 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, and audio.AudioInterfacePCM.stopRecording().

    {
        audio.stopRecording ();
    }
void audio.AbstractCODEC.stopRinging (  ) [virtual]

Stops ringing signal.

Implements audio.AudioInterface.

Definition at line 88 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, and audio.AudioInterfacePCM.stopRinging().

    {
        audio.stopRinging ();
    }
void audio.AbstractCODEC.writeBuffered ( byte[]  buf,
long  timestamp 
) throws IOException [virtual]

Plays the sample given (AudioInterface.getSampleSize() bytes) assuming that it's timestamp is long.

Implements audio.AudioInterface.

Definition at line 97 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, audio.AbstractCODEC.convertToPCM(), audio.AbstractCODEC.outputPcmBuf, and audio.AudioInterfacePCM.writeBuffered().

    {
        convertToPCM( buf, outputPcmBuf );
        audio.writeBuffered( outputPcmBuf, timestamp );
    }
void audio.AbstractCODEC.writeDirectly ( byte[]  f ) [virtual]

Writes directly to source line without buffering.

Implements audio.AudioInterface.

Definition at line 118 of file AbstractCODEC.java.

References audio.AbstractCODEC.audio, audio.AbstractCODEC.convertToPCM(), and audio.AudioInterfacePCM.writeDirectly().

    {
        byte[] tf = new byte[ 2 * f.length ];
        convertToPCM( f, tf );
        audio.writeDirectly( tf );
    }

Member Data Documentation

byte [] audio.AbstractCODEC.inputPcmBuf [protected]

Input PCM buffer (converted to CODEC) read from audio interface.

Definition at line 43 of file AbstractCODEC.java.

Referenced by audio.AudioCodecAlaw.AudioCodecAlaw(), audio.AudioCodecUlaw.AudioCodecUlaw(), and audio.AbstractCODEC.readWithTimestamp().

byte [] audio.AbstractCODEC.outputPcmBuf [protected]

Output PCM buffer (converted from CODEC) written to audio interface.

Definition at line 38 of file AbstractCODEC.java.

Referenced by audio.AudioCodecAlaw.AudioCodecAlaw(), audio.AudioCodecUlaw.AudioCodecUlaw(), and audio.AbstractCODEC.writeBuffered().


The documentation for this class was generated from the following file: