OpenH323 1.18.0
Public Member Functions | Protected Attributes
H323FramedAudioCodec Class Reference

#include <codecs.h>

Inheritance diagram for H323FramedAudioCodec:
H323AudioCodec H323Codec H323StreamedAudioCodec OpalDynaAudioCodec H323_ALawCodec H323_muLawCodec OpalDynaNonStandardAudioCodec

List of all members.

Public Member Functions

 H323FramedAudioCodec (const char *mediaFormat, Direction direction)
virtual BOOL Read (BYTE *buffer, unsigned &length, RTP_DataFrame &rtpFrame)
virtual BOOL Write (const BYTE *buffer, unsigned length, const RTP_DataFrame &rtpFrame, unsigned &written)
virtual unsigned GetAverageSignalLevel ()
virtual BOOL EncodeFrame (BYTE *buffer, unsigned &length)=0
virtual BOOL DecodeFrame (const BYTE *buffer, unsigned length, unsigned &written, unsigned &bytesOutput)
virtual BOOL DecodeFrame (const BYTE *buffer, unsigned length, unsigned &written)
virtual void DecodeSilenceFrame (void *buffer, unsigned length)

Protected Attributes

PShortArray sampleBuffer
unsigned bytesPerFrame

Detailed Description

This class defines a codec class that will use the standard platform PCM output device, and the encoding/decoding has fixed blocks. That is each input block of n samples is encoded to exactly the same sized compressed data, eg G.711, GSM etc.

An application may create a descendent off this class and override functions as required for descibing a specific codec.


Constructor & Destructor Documentation

H323FramedAudioCodec::H323FramedAudioCodec ( const char *  mediaFormat,
Direction  direction 
)

Create a new audio codec. This opens the standard PCM audio output device, for input and output and allows descendent codec classes to do audio I/O after decoding/encoding.

Parameters:
mediaFormatMedia format for codec
directionDirection in which this instance runs

Member Function Documentation

virtual BOOL H323FramedAudioCodec::DecodeFrame ( const BYTE *  buffer,
unsigned  length,
unsigned &  written,
unsigned &  bytesOutput 
) [virtual]

Decode a sample block from the buffer specified. The samples must be placed into the writeBuffer member variable. It is expected that exactly samplesPerFrame samples is decoded.

Parameters:
bufferBuffer from which encoded data is found
lengthLength of encoded data buffer
writtenNumber of bytes used from data buffer
bytesOutputNumber of bytes in decoded data

Reimplemented in H323StreamedAudioCodec.

virtual BOOL H323FramedAudioCodec::DecodeFrame ( const BYTE *  buffer,
unsigned  length,
unsigned &  written 
) [virtual]
Parameters:
bufferBuffer from which encoded data is found
lengthLength of encoded data buffer
writtenNumber of bytes used from data buffer

Reimplemented in OpalDynaAudioCodec.

virtual void H323FramedAudioCodec::DecodeSilenceFrame ( void *  buffer,
unsigned  length 
) [inline, virtual]

Called when a frame is missed due to late arrival or other reasons By default, this function fills the buffer with silence

Parameters:
bufferBuffer from which encoded data is found
lengthLength of encoded data buffer
virtual BOOL H323FramedAudioCodec::EncodeFrame ( BYTE *  buffer,
unsigned &  length 
) [pure virtual]

Encode a sample block into the buffer specified. The samples have been read and are waiting in the readBuffer member variable. it is expected this function will encode exactly bytesPerFrame bytes.

Parameters:
bufferBuffer into which encoded bytes are placed
lengthActual length of encoded data buffer

Implemented in H323StreamedAudioCodec, and OpalDynaAudioCodec.

virtual unsigned H323FramedAudioCodec::GetAverageSignalLevel ( ) [virtual]

Get the average signal level in the audio stream. This is called from within DetectSilence() to calculate the average signal level since the last call to DetectSilence().

Reimplemented from H323AudioCodec.

virtual BOOL H323FramedAudioCodec::Read ( BYTE *  buffer,
unsigned &  length,
RTP_DataFrame rtpFrame 
) [virtual]

Encode the data from the appropriate device. This will encode data for transmission. The exact size and description of the data placed in the buffer is codec dependent but should be less than OpalMediaFormat::GetFrameSize() in length.

The length parameter is filled with the actual length of the encoded data, often this will be the same as OpalMediaFormat::GetFrameSize().

This function is called every GetFrameRate() timestamp units, so MUST take less than (or equal to) that amount of time to complete. It should always return the amount of data that corresponds to the GetFrameRate() timestamp units as well.

A returned length of zero indicates that time has passed but there is no data encoded. This is typically used for silence detection in an audio codec.

Parameters:
bufferBuffer of encoded data
lengthActual length of encoded data buffer
rtpFrameRTP data frame

Implements H323Codec.

virtual BOOL H323FramedAudioCodec::Write ( const BYTE *  buffer,
unsigned  length,
const RTP_DataFrame rtpFrame,
unsigned &  written 
) [virtual]

Decode the data and output it to appropriate device. This will decode a single frame of received data. The exact size and description of the data required in the buffer is codec dependent but should be less than H323Capability::GetRxFramesInPacket() * OpalMediaFormat::GetFrameSize() in length.

It is expected this function anunciates the data. That is, for example with audio data, the sound is output on a speaker.

This function is called every GetFrameRate() timestamp units, so MUST take less than that amount of time to complete!

Parameters:
bufferBuffer of encoded data
lengthLength of encoded data buffer
rtpFrameRTP data frame
writtenNumber of bytes used from data buffer

Implements H323Codec.


Member Data Documentation

Reimplemented in OpalDynaAudioCodec.

PShortArray H323FramedAudioCodec::sampleBuffer [protected]

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