ccAudio
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
ost::AudioCodec Class Reference

The codec class is a virtual used for transcoding audio samples between linear frames (or other known format) and an encoded "sample" buffer. More...

#include <audio2.h>

Inheritance diagram for ost::AudioCodec:
ost::Audio

List of all members.

Public Member Functions

 AudioCodec (const char *name, Encoding encoding)
 Base for codecs, create a named coded of a specific encoding.
virtual ~AudioCodec ()
virtual Level getImpulse (void *buffer, unsigned number=0)
 Get the impulse energy level of a frame of X samples in the specified codec format.
virtual Level getPeak (void *buffer, unsigned number=0)
 Get the peak energy level within the frame of X samples.
virtual bool isSilent (Level threashold, void *buffer, unsigned number=0)
 Signal if the current audio frame is silent.
virtual unsigned encode (Linear buffer, void *dest, unsigned number=0)=0
 Encode a linear sample frame into the codec sample buffer.
virtual unsigned encodeBuffered (Linear Buffer, Encoded dest, unsigned number)
 Encode linear samples buffered into the coded.
virtual unsigned decode (Linear buffer, void *source, unsigned number=0)=0
 Decode the sample frame into linear samples.
virtual unsigned decodeBuffered (Linear buffer, Encoded source, unsigned len)
 Buffer and decode data into linear samples.
virtual unsigned getEstimated (void)
 Get estimated data required for buffered operations.
virtual unsigned getRequired (void)
 get required samples for encoding.
virtual unsigned getPacket (Encoded destination, Encoded data, unsigned size)
 Get a packet of data rather than decode.
Info getInfo (void)
 Get an info description for this codec.

Static Public Member Functions

static void endCodec (AudioCodec *codec)
 End use of a requested codec.
static AudioCodecgetCodec (Encoding encoding, const char *format=NULL, bool loaded=false)
 Get the codec base class for accessing a specific derived codec identified by encoding type and optional spd info.
static AudioCodecgetCodec (Info &info, bool loaded=false)
 Get the codec base class for accessing a specific derived codec identified by audio source descriptor.
static bool load (const char *name)
 Load a named codec set into process memory.
static bool load (Encoding encoding)
 Find and load a codec file by it's encoding type.

Protected Member Functions

 AudioCodec ()
virtual AudioCodecgetByFormat (const char *format)
 often used to create a "new" codec of a subtype based on encoding format, default returns the current codec entity.
virtual AudioCodecgetByInfo (Info &info)
 get a codec by audio source info descriptor.

Protected Attributes

AudioCodecnext
Encoding encoding
const char * name
Info info

Static Protected Attributes

static AudioCodecfirst

Detailed Description

The codec class is a virtual used for transcoding audio samples between linear frames (or other known format) and an encoded "sample" buffer.

This class is only abstract and describes the core interface for loadable codec modules. This class is normally merged with AudioSample. A derived AudioCodecXXX will typically include a AudioRegisterXXX static class to automatically initialize and register the codec with the codec registry.

Author:
David Sugar <dyfet@ostel.com> process codec interface.

Constructor & Destructor Documentation

ost::AudioCodec::AudioCodec ( ) [protected]
ost::AudioCodec::AudioCodec ( const char *  name,
Encoding  encoding 
)

Base for codecs, create a named coded of a specific encoding.

Parameters:
nameof codec.
encodingtype of codec.
virtual ost::AudioCodec::~AudioCodec ( ) [inline, virtual]

Member Function Documentation

virtual unsigned ost::AudioCodec::decode ( Linear  buffer,
void *  source,
unsigned  number = 0 
) [pure virtual]

Decode the sample frame into linear samples.

Returns:
number of bytes scanned or returned
Parameters:
buffersample buffer to save linear samples into.
sourcefor encoded data.
numberof samples to extract.
virtual unsigned ost::AudioCodec::decodeBuffered ( Linear  buffer,
Encoded  source,
unsigned  len 
) [virtual]

Buffer and decode data into linear samples.

This is needed for audio formats that have irregular packet sizes.

Returns:
number of samples actually decoded.
Parameters:
destinationfor decoded data.
sourcefor encoded data.
numberof bytes being sent.
virtual unsigned ost::AudioCodec::encode ( Linear  buffer,
void *  dest,
unsigned  number = 0 
) [pure virtual]

Encode a linear sample frame into the codec sample buffer.

Returns:
number of bytes written.
Parameters:
bufferlinear sample buffer to use.
destbuffer to store encoded results.
numberof samples.
virtual unsigned ost::AudioCodec::encodeBuffered ( Linear  Buffer,
Encoded  dest,
unsigned  number 
) [virtual]

Encode linear samples buffered into the coded.

Returns:
number of bytes written or 0 if incomplete.
Parameters:
bufferlinear samples to post.
destinationof encoded audio.
numberof samples being buffered.
static void ost::AudioCodec::endCodec ( AudioCodec codec) [static]

End use of a requested codec.

If constructed then will be deleted.

Parameters:
codecpointer to getCodec returned coded pointer.
virtual AudioCodec* ost::AudioCodec::getByFormat ( const char *  format) [inline, protected, virtual]

often used to create a "new" codec of a subtype based on encoding format, default returns the current codec entity.

Returns:
pointer to an active codec or NULL if not found.
Parameters:
formatname from spd.
virtual AudioCodec* ost::AudioCodec::getByInfo ( Info info) [inline, protected, virtual]

get a codec by audio source info descriptor.

Returns:
pointer to an active codec or NULL if not found.
Parameters:
infoaudio source descriptor.
static AudioCodec* ost::AudioCodec::getCodec ( Encoding  encoding,
const char *  format = NULL,
bool  loaded = false 
) [static]

Get the codec base class for accessing a specific derived codec identified by encoding type and optional spd info.

Returns:
pointer to codec for processing.
Parameters:
encodingformat requested.
formatspd options to pass to codec being created.
loadedtrue to load if not already in memory.
static AudioCodec* ost::AudioCodec::getCodec ( Info info,
bool  loaded = false 
) [static]

Get the codec base class for accessing a specific derived codec identified by audio source descriptor.

Returns:
pointer to codec for processing.
Parameters:
infosource descriptor for codec being requested.
loadedtrue to load codec if not already in memory.
virtual unsigned ost::AudioCodec::getEstimated ( void  ) [virtual]

Get estimated data required for buffered operations.

Returns:
estimated number of bytes required for decode.
virtual Level ost::AudioCodec::getImpulse ( void *  buffer,
unsigned  number = 0 
) [virtual]

Get the impulse energy level of a frame of X samples in the specified codec format.

Returns:
average impulse energy of frame (sumnation).
Parameters:
bufferof encoded samples.
numberof encoded samples.
Info ost::AudioCodec::getInfo ( void  ) [inline]

Get an info description for this codec.

Returns:
info.
virtual unsigned ost::AudioCodec::getPacket ( Encoded  destination,
Encoded  data,
unsigned  size 
) [virtual]

Get a packet of data rather than decode.

This is tied with getEstimated.

Returns:
size of data packet or 0 if not complete.
Parameters:
destinationto save.
datato push into buffer.
numberof bytes to push.
virtual Level ost::AudioCodec::getPeak ( void *  buffer,
unsigned  number = 0 
) [virtual]

Get the peak energy level within the frame of X samples.

Returns:
peak energy impulse in frame (largest).
Parameters:
bufferof encoded samples.
numberof encoded samples.
virtual unsigned ost::AudioCodec::getRequired ( void  ) [virtual]

get required samples for encoding.

Returns:
required number of samples for encoder buffer.
virtual bool ost::AudioCodec::isSilent ( Level  threashold,
void *  buffer,
unsigned  number = 0 
) [virtual]

Signal if the current audio frame is silent.

This can be deterimed either by an impulse computation, or, in some cases, some codecs may signal and flag silent packets.

Returns:
true if silent
Parameters:
threasholdto use if not signaled.
bufferof encoded samples.
numberof encoded samples.
static bool ost::AudioCodec::load ( Encoding  encoding) [static]

Find and load a codec file by it's encoding type.

Converts the type into a codec name and invokes the other loader...

Returns:
true if successful.
Parameters:
encodingtype for file.
static bool ost::AudioCodec::load ( const char *  name) [static]

Load a named codec set into process memory.

Returns:
true if successful.
Parameters:
nameof codec set to load.

Member Data Documentation

AudioCodec* ost::AudioCodec::first [static, protected]
const char* ost::AudioCodec::name [protected]

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