ccAudio
|
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>
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 AudioCodec * | getCodec (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 AudioCodec * | getCodec (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 AudioCodec * | getByFormat (const char *format) |
often used to create a "new" codec of a subtype based on encoding format, default returns the current codec entity. | |
virtual AudioCodec * | getByInfo (Info &info) |
get a codec by audio source info descriptor. | |
Protected Attributes | |
AudioCodec * | next |
Encoding | encoding |
const char * | name |
Info | info |
Static Protected Attributes | |
static AudioCodec * | first |
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.
ost::AudioCodec::AudioCodec | ( | ) | [protected] |
ost::AudioCodec::AudioCodec | ( | const char * | name, |
Encoding | encoding | ||
) |
Base for codecs, create a named coded of a specific encoding.
name | of codec. |
encoding | type of codec. |
virtual ost::AudioCodec::~AudioCodec | ( | ) | [inline, virtual] |
virtual unsigned ost::AudioCodec::decode | ( | Linear | buffer, |
void * | source, | ||
unsigned | number = 0 |
||
) | [pure virtual] |
Decode the sample frame into linear samples.
buffer | sample buffer to save linear samples into. |
source | for encoded data. |
number | of 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.
destination | for decoded data. |
source | for encoded data. |
number | of 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.
buffer | linear sample buffer to use. |
dest | buffer to store encoded results. |
number | of samples. |
virtual unsigned ost::AudioCodec::encodeBuffered | ( | Linear | Buffer, |
Encoded | dest, | ||
unsigned | number | ||
) | [virtual] |
Encode linear samples buffered into the coded.
buffer | linear samples to post. |
destination | of encoded audio. |
number | of samples being buffered. |
static void ost::AudioCodec::endCodec | ( | AudioCodec * | codec | ) | [static] |
End use of a requested codec.
If constructed then will be deleted.
codec | pointer 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.
format | name from spd. |
virtual AudioCodec* ost::AudioCodec::getByInfo | ( | Info & | info | ) | [inline, protected, virtual] |
get a codec by audio source info descriptor.
info | audio 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.
encoding | format requested. |
format | spd options to pass to codec being created. |
loaded | true 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.
info | source descriptor for codec being requested. |
loaded | true to load codec if not already in memory. |
virtual unsigned ost::AudioCodec::getEstimated | ( | void | ) | [virtual] |
Get estimated data required for buffered operations.
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.
buffer | of encoded samples. |
number | of encoded samples. |
Info ost::AudioCodec::getInfo | ( | void | ) | [inline] |
Get an info description for this codec.
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.
destination | to save. |
data | to push into buffer. |
number | of 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.
buffer | of encoded samples. |
number | of encoded samples. |
virtual unsigned ost::AudioCodec::getRequired | ( | void | ) | [virtual] |
get required samples for encoding.
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.
threashold | to use if not signaled. |
buffer | of encoded samples. |
number | of 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...
encoding | type for file. |
static bool ost::AudioCodec::load | ( | const char * | name | ) | [static] |
Load a named codec set into process memory.
name | of codec set to load. |
Encoding ost::AudioCodec::encoding [protected] |
AudioCodec* ost::AudioCodec::first [static, protected] |
Info ost::AudioCodec::info [protected] |
const char* ost::AudioCodec::name [protected] |
AudioCodec* ost::AudioCodec::next [protected] |