# class DataTranslator | An unidirectional data translator (codec). More...
Full name | `TelEngine::DataTranslator`
Definition | `#include <yatephone.h>`
Inherits | TelEngine::DataConsumer [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- DataTranslator (const char* sFormat, const char* dFormat)
- explicit DataTranslator (const char* sFormat, DataSource* source = 0)
- ~DataTranslator ()
- virtual void* getObject (const String& name) const
- virtual bool valid () const
- virtual DataSource* getTransSource () const
- DataTranslator* getFirstTranslator ()
- const DataTranslator* getFirstTranslator () const

#### Public Static Methods

- static ObjList* srcFormats (const DataFormat& dFormat = "slin", int maxCost = -1, unsigned int maxLen = 0, ObjList* lst = 0)
- static ObjList* destFormats (const DataFormat& sFormat = "slin", int maxCost = -1, unsigned int maxLen = 0, ObjList* lst = 0)
- static ObjList* allFormats (const ObjList* formats, bool existing = true, bool sameRate = true, bool sameChans = true)
- static ObjList* allFormats (const String& formats, bool existing = true, bool sameRate = true, bool sameChans = true)
- static bool canConvert (const DataFormat& fmt1, const DataFormat& fmt2 = "slin")
- static int cost (const DataFormat& sFormat, const DataFormat& dFormat)
- static DataTranslator* create (const DataFormat& sFormat, const DataFormat& dFormat)
- static bool attachChain (DataSource* source, DataConsumer* consumer, bool override = false)
- static bool detachChain (DataSource* source, DataConsumer* consumer)
- static void setMaxChain (unsigned int maxChain)

#### Protected Methods

- virtual bool synchronize (DataSource* source)

#### Protected Static Methods

- static void install (TranslatorFactory* factory)
- static void uninstall (TranslatorFactory* factory)

## Detailed Description

The DataTranslator holds a translator (codec) capable of unidirectional conversion of data from one type to another.

DataTranslator (const char* sFormat, const char* dFormat) | ### DataTranslator

Construct a data translator.

Parameters:

sFormat | Name of the source format (data received from the consumer)
dFormat | Name of the destination format (data supplied to the source)

explicit DataTranslator (const char* sFormat, DataSource* source = 0) | ### DataTranslator

Creates a data translator from an existing source, does not increment the source's reference counter.

Parameters:

sFormat | Name of the source format (data received from the consumer)
source | Optional pointer to a DataSource object

~DataTranslator () | ### ~DataTranslator

Destroys the translator and its source

void* getObject (const String& name) | ### getObject

[const virtual]

Get a pointer to a derived class given that class name

Parameters:

name | Name of the class we are asking for

Returns: Pointer to the requested class or NULL if this object doesn't implement it

Reimplemented from DataConsumer.

bool valid () | ### valid

[const virtual]

Check if the data translator has a valid source

Returns: True if still valid, false if node should be removed

Reimplemented from DataNode.

DataSource* getTransSource () | ### getTransSource

[const virtual]

Get the data source of a translator object

Returns: A pointer to the DataSource object or NULL

Reimplemented from DataConsumer.

DataTranslator* getFirstTranslator () | ### getFirstTranslator

Get the first translator from a chain

Returns: Pointer to the first translator in a chain

const DataTranslator* getFirstTranslator () | ### getFirstTranslator

[const]

Constant version to get the first translator from a chain

Returns: Pointer to the first translator in a chain

ObjList* srcFormats (const DataFormat& dFormat = "slin", int maxCost = -1, unsigned int maxLen = 0, ObjList* lst = 0) | ### srcFormats

[static]

Get a list of formats supported for a given output format.

Parameters:

dFormat | Name of destination format
maxCost | Maximum cost of candidates to consider, -1 to accept all
maxLen | Maximum length of codec chains to consider, 0 to accept all
lst | Initial list, will append to it if not empty

Returns: List of source format names, must be freed by the caller

ObjList* destFormats (const DataFormat& sFormat = "slin", int maxCost = -1, unsigned int maxLen = 0, ObjList* lst = 0) | ### destFormats

[static]

Get a list of formats supported for a given input format

Parameters:

sFormat | Name of source format
maxCost | Maximum cost of candidates to consider, -1 to accept all
maxLen | Maximum length of codec chains to consider, 0 to accept all
lst | Initial list, will append to it if not empty

Returns: List of destination format names, must be freed by the caller

ObjList* allFormats (const ObjList* formats, bool existing = true, bool sameRate = true, bool sameChans = true) | ### allFormats

[static]

Get a list of formats supported by transcoding for a given format list

Parameters:

formats | List of data format names
existing | Also return formats already existing in the initial list
sameRate | Only return formats with same sampling rate
sameChans | Only return formats with same number of channels

Returns: List of format names, must be freed by the caller

ObjList* allFormats (const String& formats, bool existing = true, bool sameRate = true, bool sameChans = true) | ### allFormats

[static]

Get a list of formats supported by transcoding for a given format list

Parameters:

formats | Data format names as comma separated list
existing | Also return formats already existing in the initial list
sameRate | Only return formats with same sampling rate
sameChans | Only return formats with same number of channels

Returns: List of format names, must be freed by the caller

bool canConvert (const DataFormat& fmt1, const DataFormat& fmt2 = "slin") | ### canConvert

[static]

Check if bidirectional conversion can be performed by installed translators

Parameters:

fmt1 | Name of the first data format
fmt2 | Name of the second data format

Returns: True if translators can be created for both directions

int cost (const DataFormat& sFormat, const DataFormat& dFormat) | ### cost

[static]

Finds the cost of a translator given the source and destination format names

Parameters:

sFormat | Name of the source format (data received from the consumer)
dFormat | Name of the destination format (data supplied to the source)

Returns: Cost of best (cheapest) codec or -1 if no known codec exists

DataTranslator* create (const DataFormat& sFormat, const DataFormat& dFormat) | ### create

[static]

Creates a translator given the source and destination format names

Parameters:

sFormat | Name of the source format (data received from the consumer)
dFormat | Name of the destination format (data supplied to the source)

Returns: A pointer to a DataTranslator object or NULL if no known codec exists

bool attachChain (DataSource* source, DataConsumer* consumer, bool override = false) | ### attachChain

[static]

Attach a consumer to a source, possibly trough a chain of translators

Parameters:

source | Source to attach the chain to
consumer | Consumer where the chain ends
override | Attach chain for temporary source override

Returns: True if successfull, false if no translator chain could be built

bool detachChain (DataSource* source, DataConsumer* consumer) | ### detachChain

[static]

Detach a consumer from a source, possibly trough a chain of translators

Parameters:

source | Source to dettach the chain from
consumer | Consumer where the chain ends

Returns: True if successfull, false if source and consumers were not attached

void setMaxChain (unsigned int maxChain) | ### setMaxChain

[static]

Set the length of the longest translator chain we are allowed to create

Parameters:

maxChain | Desired longest chain length

bool synchronize (DataSource* source) | ### synchronize

[protected virtual]

Synchronize the consumer with a source

Parameters:

source | Data source to copy the timestamp from

Returns: True if we could synchronize with the source

Reimplemented from DataConsumer.

void install (TranslatorFactory* factory) | ### install

[protected static]

Install a Translator Factory in the list of known codecs

Parameters:

factory | A pointer to a TranslatorFactory instance

void uninstall (TranslatorFactory* factory) | ### uninstall

[protected static]

Remove a Translator Factory from the list of known codecs

Parameters:

factory | A pointer to a TranslatorFactory instance

Generated by: paulc on bussard on Mon Feb 10 13:15:47 2014, using kdoc 2.0a54.