sipxmedialib  Version 3.3
Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
MpCodecFactory Class Reference

#include <MpCodecFactory.h>

Collaboration diagram for MpCodecFactory:
Collaboration graph
[legend]

Public Member Functions

Accessors
OsStatus createDecoder (const UtlString &mime, const UtlString &fmtp, int sampleRate, int numChannels, int payloadType, MpDecoderBase *&rpDecoder) const
 Returns a new instance of a decoder of the indicated type. More...
 
OsStatus createEncoder (const UtlString &mime, const UtlString &fmtp, int sampleRate, int numChannels, int payloadType, MpEncoderBase *&rpEncoder) const
 Returns a new instance of an encoder of the indicated type. More...
 
void getCodecInfoArray (unsigned &count, const MppCodecInfoV1_1 **&codecInfoArray) const
 Get list of all codecs' info. More...
 
void addCodecsToList (SdpCodecList &codecList) const
 Add all supported codecs to SDP descriptions list. More...
 

Static Public Member Functions

Creators
static MpCodecFactorygetMpCodecFactory (void)
 Get/create singleton factory. More...
 
static void freeSingletonHandle ()
 Deinitialize all static codecs and freeing handle. Should be called only mpShutdown() More...
 

Protected Member Functions

 MpCodecFactory ()
 Constructor (called only indirectly via getMpCodecFactory()) More...
 
 ~MpCodecFactory ()
 Destructor. More...
 
MpCodecSubInfosearchByMIME (const UtlString &mime, int sampleRate, int numChannels) const
 Search codec by given MIME-subtype, sample rate and channels number. More...
 
void freeAllLoadedLibsAndCodec ()
 Deinitialize all dynamic codecs. Should be called only from mpShutdown() More...
 
void initializeStaticCodecs ()
 Initialize all static codecs. More...
 

Static Protected Member Functions

static void freeStaticCodecs ()
 Freeing internal data of static codecs. Should be called only from global .dtor. More...
 

Private Member Functions

OsStatus addCodecWrapperV1 (MpCodecCallInfoV1 *wrapper)
 Add new codec wrapper to codec list. More...
 
void updateCodecInfoCache () const
 Update cached array of MIME-types of loaded codecs. More...
 
 MpCodecFactory (const MpCodecFactory &rMpCodecFactory)
 Copy constructor (not supported) More...
 
MpCodecFactoryoperator= (const MpCodecFactory &rhs)
 Assignment operator (not supported) More...
 

Private Attributes

UtlHashBag mCodecsInfo
 List of all known and workable codecs. More...
 
UtlBoolean mCodecInfoCacheValid
 Should we rebuild MIME-subtypes cache? More...
 
unsigned mCachedCodecInfoNum
 Number of elements in mpMimeTypesCache. More...
 
const MppCodecInfoV1_1 ** mpCodecInfoCache
 This is used as return value of getMimeTypes(). More...
 

Static Private Attributes

static MpCodecFactoryspInstance = NULL
 Pointer to the singleton instance. More...
 
static OsBSem sLock
 
static MpCodecCallInfoV1sStaticCodecsV1 = NULL
 Filled by global magic .ctor. More...
 

Manipulators

static MpCodecCallInfoV1addStaticCodec (MpCodecCallInfoV1 *sStaticCode)
 Add static codec to factory. More...
 
OsStatus loadDynCodec (const char *name)
 Load specified codec plugin. More...
 
OsStatus loadAllDynCodecs (const char *path, const char *regexFilter)
 Load all codec plugins within specified path and filter. More...
 

Detailed Description

Singleton class used to generate encoder and decoder objects of an indicated type.

Constructor & Destructor Documentation

MpCodecFactory ( void  )
protected

Constructor (called only indirectly via getMpCodecFactory())

We identify this as a protected (rather than a private) method so that gcc doesn't complain that the class only defines a private constructor and has no friends.

~MpCodecFactory ( )
protected

Destructor.

MpCodecFactory ( const MpCodecFactory rMpCodecFactory)
private

Copy constructor (not supported)

Member Function Documentation

MpCodecFactory * getMpCodecFactory ( void  )
static

Get/create singleton factory.

Return a pointer to the MpCodecFactory singleton object, creating it if necessary

void freeSingletonHandle ( )
static

Deinitialize all static codecs and freeing handle. Should be called only mpShutdown()

OsStatus loadDynCodec ( const char *  name)

Load specified codec plugin.

OsStatus loadAllDynCodecs ( const char *  path,
const char *  regexFilter 
)

Load all codec plugins within specified path and filter.

Load all libs in given plugins directory.

Return values
OS_SUCCESS- if at least one codec plugin was found. Note, that OS_SUCCESS is returned even if loading of found plugins failed.
OS_FAILED- if no codec plugins were found.
MpCodecCallInfoV1 * addStaticCodec ( MpCodecCallInfoV1 sStaticCode)
static

Add static codec to factory.

OsStatus createDecoder ( const UtlString &  mime,
const UtlString &  fmtp,
int  sampleRate,
int  numChannels,
int  payloadType,
MpDecoderBase *&  rpDecoder 
) const

Returns a new instance of a decoder of the indicated type.

Parameters
[in]mime- codec MIME-subtype
[in]fmtp- codec-specific string in format of SDP "fmtp" parameter
[in]sampleRate- requested codec's sample rate
[in]numChannels- requested codec's number of channels
[in]payloadType- RTP payload type to be associated with this decoder
[out]rpDecoder- Reference to a pointer to the new decoder object
OsStatus createEncoder ( const UtlString &  mime,
const UtlString &  fmtp,
int  sampleRate,
int  numChannels,
int  payloadType,
MpEncoderBase *&  rpEncoder 
) const

Returns a new instance of an encoder of the indicated type.

Parameters
[in]mime- codec MIME-subtype
[in]fmtp- codec-specific string in format of SDP "fmtp" parameter
[in]sampleRate- requested codec's sample rate
[in]numChannels- requested codec's number of channels
[in]payloadType- RTP payload type to be associated with this encoder
[out]rpEncoder- Reference to a pointer to the new encoder object
void getCodecInfoArray ( unsigned &  count,
const MppCodecInfoV1_1 **&  codecInfoArray 
) const

Get list of all codecs' info.

Parameters
[out]count- number of elements returned in codecInfoArray array.
[out]codecInfoArray- array of pointers to codecs' info.
void addCodecsToList ( SdpCodecList &  codecList) const

Add all supported codecs to SDP descriptions list.

Note
Not really all codecs are added to list. Only codecs, known by sipXsdpLib are added.
MpCodecSubInfo * searchByMIME ( const UtlString &  mime,
int  sampleRate,
int  numChannels 
) const
protected

Search codec by given MIME-subtype, sample rate and channels number.

void freeAllLoadedLibsAndCodec ( )
protected

Deinitialize all dynamic codecs. Should be called only from mpShutdown()

void initializeStaticCodecs ( )
protected

Initialize all static codecs.

Note
This should called exactly once at startup. At current code it is called from mpStartUp().
void freeStaticCodecs ( )
staticprotected

Freeing internal data of static codecs. Should be called only from global .dtor.

OsStatus addCodecWrapperV1 ( MpCodecCallInfoV1 wrapper)
private

Add new codec wrapper to codec list.

void updateCodecInfoCache ( ) const
private

Update cached array of MIME-types of loaded codecs.

MpCodecFactory& operator= ( const MpCodecFactory rhs)
private

Assignment operator (not supported)

Member Data Documentation

UtlHashBag mCodecsInfo
private

List of all known and workable codecs.

UtlBoolean mCodecInfoCacheValid
mutableprivate

Should we rebuild MIME-subtypes cache?

unsigned mCachedCodecInfoNum
mutableprivate

Number of elements in mpMimeTypesCache.

const MppCodecInfoV1_1** mpCodecInfoCache
mutableprivate

This is used as return value of getMimeTypes().

Cached array of MIME-subtypes of loaded codecs.

MpCodecFactory * spInstance = NULL
staticprivate

Pointer to the singleton instance.

OsBSem sLock
staticprivate

Semaphore used to synchronize singleton construction and destruction.

MpCodecCallInfoV1 * sStaticCodecsV1 = NULL
staticprivate

Filled by global magic .ctor.

List of all static codecs.