WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJMEDIA Reference

Media codec framework and management. More...

Modules

 PJMEDIA-CODEC Compile Time Settings
 Various compile time settings such as to enable/disable codecs.
 
 PJMEDIA-CODEC Types and Constants
 Constants used by PJMEDIA-CODEC.
 
 Supported codecs
 Documentation about individual codec supported by PJMEDIAPlease see the APIs provided by the individual codecs below.
 
 Video Codecs
 

Data Structures

struct  pjmedia_codec_info
 
struct  pjmedia_codec_fmtp
 
struct  pjmedia_codec_param
 
struct  pjmedia_codec_op
 
struct  pjmedia_codec
 
struct  pjmedia_codec_factory_op
 
struct  pjmedia_codec_factory
 
struct  pjmedia_codec_desc
 
struct  pjmedia_codec_mgr
 

Macros

#define PJMEDIA_CODEC_MGR_MAX_CODECS   32
 

Typedefs

typedef char pjmedia_codec_id[32]
 
typedef struct pjmedia_codec_default_param pjmedia_codec_default_param
 

Enumerations

enum  pjmedia_rtp_pt {
  PJMEDIA_RTP_PT_PCMU = 0 ,
  PJMEDIA_RTP_PT_G721 = 2 ,
  PJMEDIA_RTP_PT_GSM = 3 ,
  PJMEDIA_RTP_PT_G723 = 4 ,
  PJMEDIA_RTP_PT_DVI4_8K = 5 ,
  PJMEDIA_RTP_PT_DVI4_16K = 6 ,
  PJMEDIA_RTP_PT_LPC = 7 ,
  PJMEDIA_RTP_PT_PCMA = 8 ,
  PJMEDIA_RTP_PT_G722 = 9 ,
  PJMEDIA_RTP_PT_L16_2 = 10 ,
  PJMEDIA_RTP_PT_L16_1 = 11 ,
  PJMEDIA_RTP_PT_QCELP = 12 ,
  PJMEDIA_RTP_PT_CN = 13 ,
  PJMEDIA_RTP_PT_MPA = 14 ,
  PJMEDIA_RTP_PT_G728 = 15 ,
  PJMEDIA_RTP_PT_DVI4_11K = 16 ,
  PJMEDIA_RTP_PT_DVI4_22K = 17 ,
  PJMEDIA_RTP_PT_G729 = 18 ,
  PJMEDIA_RTP_PT_CELB = 25 ,
  PJMEDIA_RTP_PT_JPEG = 26 ,
  PJMEDIA_RTP_PT_NV = 28 ,
  PJMEDIA_RTP_PT_H261 = 31 ,
  PJMEDIA_RTP_PT_MPV = 32 ,
  PJMEDIA_RTP_PT_MP2T = 33 ,
  PJMEDIA_RTP_PT_H263 = 34 ,
  PJMEDIA_RTP_PT_DYNAMIC = 96
}
 
enum  pjmedia_codec_priority {
  PJMEDIA_CODEC_PRIO_HIGHEST = 255 ,
  PJMEDIA_CODEC_PRIO_NEXT_HIGHER = 254 ,
  PJMEDIA_CODEC_PRIO_NORMAL = 128 ,
  PJMEDIA_CODEC_PRIO_LOWEST = 1 ,
  PJMEDIA_CODEC_PRIO_DISABLED = 0
}
 

Functions

pjmedia_codec_parampjmedia_codec_param_clone (pj_pool_t *pool, const pjmedia_codec_param *src)
 
pj_status_t pjmedia_codec_mgr_init (pjmedia_codec_mgr *mgr, pj_pool_factory *pf)
 
pj_status_t pjmedia_codec_mgr_destroy (pjmedia_codec_mgr *mgr)
 
pj_status_t pjmedia_codec_mgr_register_factory (pjmedia_codec_mgr *mgr, pjmedia_codec_factory *factory)
 
pj_status_t pjmedia_codec_mgr_unregister_factory (pjmedia_codec_mgr *mgr, pjmedia_codec_factory *factory)
 
pj_status_t pjmedia_codec_mgr_enum_codecs (pjmedia_codec_mgr *mgr, unsigned *count, pjmedia_codec_info info[], unsigned *prio)
 
pj_status_t pjmedia_codec_mgr_get_codec_info (pjmedia_codec_mgr *mgr, unsigned pt, const pjmedia_codec_info **inf)
 
char * pjmedia_codec_info_to_id (const pjmedia_codec_info *info, char *id, unsigned max_len)
 
pj_status_t pjmedia_codec_mgr_find_codecs_by_id (pjmedia_codec_mgr *mgr, const pj_str_t *codec_id, unsigned *count, const pjmedia_codec_info *p_info[], unsigned prio[])
 
pj_status_t pjmedia_codec_mgr_set_codec_priority (pjmedia_codec_mgr *mgr, const pj_str_t *codec_id, pj_uint8_t prio)
 
pj_status_t pjmedia_codec_mgr_get_default_param (pjmedia_codec_mgr *mgr, const pjmedia_codec_info *info, pjmedia_codec_param *param)
 
pj_status_t pjmedia_codec_mgr_set_default_param (pjmedia_codec_mgr *mgr, const pjmedia_codec_info *info, const pjmedia_codec_param *param)
 
pj_status_t pjmedia_codec_mgr_alloc_codec (pjmedia_codec_mgr *mgr, const pjmedia_codec_info *info, pjmedia_codec **p_codec)
 
pj_status_t pjmedia_codec_mgr_dealloc_codec (pjmedia_codec_mgr *mgr, pjmedia_codec *codec)
 
pj_status_t pjmedia_codec_init (pjmedia_codec *codec, pj_pool_t *pool)
 
pj_status_t pjmedia_codec_open (pjmedia_codec *codec, pjmedia_codec_param *param)
 
pj_status_t pjmedia_codec_close (pjmedia_codec *codec)
 
pj_status_t pjmedia_codec_modify (pjmedia_codec *codec, const pjmedia_codec_param *param)
 
pj_status_t pjmedia_codec_parse (pjmedia_codec *codec, void *pkt, pj_size_t pkt_size, const pj_timestamp *timestamp, unsigned *frame_cnt, pjmedia_frame frames[])
 
pj_status_t pjmedia_codec_encode (pjmedia_codec *codec, const struct pjmedia_frame *input, unsigned out_size, struct pjmedia_frame *output)
 
pj_status_t pjmedia_codec_decode (pjmedia_codec *codec, const struct pjmedia_frame *input, unsigned out_size, struct pjmedia_frame *output)
 
pj_status_t pjmedia_codec_recover (pjmedia_codec *codec, unsigned out_size, struct pjmedia_frame *output)
 

Detailed Description

Codec Management

Codec Manager

The codec manager is used to manage all codec capabilities in the endpoint. When used with media endpoint (pjmedia_endpt), application can retrieve the codec manager instance by calling pjmedia_endpt_get_codec_mgr().

Registering New Codec

New codec types can be registered to PJMEDIA (or to be precise, to the codec manager) during run-time. To do this, application needs to initialize an instance of codec factory (pjmedia_codec_factory) and registers this codec factory by calling pjmedia_codec_mgr_register_factory().

For codecs implemented/supported by PJMEDIA, this process is normally concealed in an easy to use function such as pjmedia_codec_g711_init().

Codec Factory

A codec factory (pjmedia_codec_factory) is registered to codec manager, and it is used to create and release codec instance.

The most important member of the codec factory is the "virtual" function table pjmedia_codec_factory_op, where it contains, among other thing, pointer to functions to allocate and deallocate codec instance.

Codec Instance

Application allocates codec instance by calling pjmedia_codec_mgr_alloc_codec(). One codec instance (pjmedia_codec) can be used for simultaneous encoding and decoding.

The most important member of the codec instance is the "virtual" function table pjmedia_codec_op, where it holds pointer to functions to encode/decode media frames.

Codec Identification

A particular codec type in PJMEDIA can be uniquely identified by two keys: by pjmedia_codec_info, or by pjmedia_codec_id string. A fully qualified codec ID string consists of codec name, sampling rate, and number of channels. However, application may use only first parts of the tokens as long as it will make to codec ID unique. For example, "gsm" is a fully qualified codec name, since it will always have 8000 clock rate and 1 channel. Other examples of fully qualified codec ID strings are "pcma", "speex/8000", "speex/16000", and "L16/16000/1". A codec id "speex" (without clock rate) is not fully qualified, since it will match the narrowband, wideband, and ultrawideband Speex codec.

The two keys can be converted to one another, with pjmedia_codec_info_to_id() and pjmedia_codec_mgr_find_codecs_by_id() functions.

Codec ID string is not case sensitive.

Using the Codec Framework

Allocating Codec

Application needs to allocate one codec instance for encoding and decoding media frames. One codec instance can be used to perform both encoding and decoding.

Application allocates codec by calling pjmedia_codec_mgr_alloc_codec(). This function takes pjmedia_codec_info argument, which is used to locate the particular codec factory to be used to allocate the codec.

Application can build pjmedia_codec_info structure manually for the specific codec, or alternatively it may get the pjmedia_codec_info from the codec ID string, by using pjmedia_codec_mgr_find_codecs_by_id() function.

The following snippet shows an example to allocate a codec:

pj_str_t codec_id;
pjmedia_codec_info *codec_info;
unsigned count = 1;
codec_id = pj_str("pcma");
// Find codec info for the specified coded ID (i.e. "pcma").
status = pjmedia_codec_mgr_find_codecs_by_id( codec_mgr, &codec_id,
&count, &codec_info, NULL);
// Allocate the codec.
status = pjmedia_codec_mgr_alloc_codec( codec_mgr, codec_info, &codec );
pj_status_t pjmedia_codec_mgr_alloc_codec(pjmedia_codec_mgr *mgr, const pjmedia_codec_info *info, pjmedia_codec **p_codec)
pj_status_t pjmedia_codec_mgr_find_codecs_by_id(pjmedia_codec_mgr *mgr, const pj_str_t *codec_id, unsigned *count, const pjmedia_codec_info *p_info[], unsigned prio[])
pj_str_t pj_str(char *str)
Definition: siprtp.c:101
Definition: codec.h:235
Definition: codec.h:502

Initializing Codec

Once codec is allocated, application needs to initialize the codec by calling open member of the codec. This function takes pjmedia_codec_param as the argument, which contains the settings for the codec.

Application shoud use pjmedia_codec_mgr_get_default_param() function to initiaize pjmedia_codec_param. The setting part of pjmedia_codec_param then can be tuned to suit the application's requirements.

The following snippet shows an example to initialize codec:

// Retrieve default codec param for the specified codec.
&param);
// Application may change the "settings" part of codec param,
// for example, to disable VAD
param.setting.vad = 0;
// Open the codec using the specified settings.
codec->op->open( codec, &param );
pj_status_t pjmedia_codec_mgr_get_default_param(pjmedia_codec_mgr *mgr, const pjmedia_codec_info *info, pjmedia_codec_param *param)
Definition: codec.h:268
struct pjmedia_codec_param::@9 setting
unsigned vad
Definition: codec.h:300

Encoding and Decoding Media Frames

Application encodes and decodes media frames by calling encode and decode member of the codec's "virtual" function table (pjmedia_codec_op).

Concealing Lost Frames

All codecs has Packet Lost Concealment (PLC) feature, and application can activate the PLC to conceal lost frames by calling recover member of the codec's "virtual" function table (pjmedia_codec_op).

If the codec's algorithm supports PLC, the recover function will use the codec's PLC. Otherwise for codecs that don't have intrinsic PLC, PJMEDIA will suply the PLC implementation from the Packet Lost Concealment (PLC) implementation.

Closing and Releasing the Codec

The codec must be closed by calling close member of the codec's operation. Then it must be released by calling pjmedia_codec_mgr_dealloc_codec().

Macro Definition Documentation

◆ PJMEDIA_CODEC_MGR_MAX_CODECS

#define PJMEDIA_CODEC_MGR_MAX_CODECS   32

Declare maximum codecs

Typedef Documentation

◆ pjmedia_codec_id

typedef char pjmedia_codec_id[32]

Codec identification (e.g. "pcmu/8000/1"). See Codec Identification for more info.

◆ pjmedia_codec_default_param

Opaque declaration of default codecs parameters.

Enumeration Type Documentation

◆ pjmedia_rtp_pt

Standard RTP static payload types, as defined by RFC 3551. The header file <pjmedia-codec/types.h> also declares dynamic payload type numbers that are used by PJMEDIA when advertising the capability for example in SDP message.

Enumerator
PJMEDIA_RTP_PT_PCMU 

audio PCMU

PJMEDIA_RTP_PT_G721 

audio G721 (old def for G726-32)

PJMEDIA_RTP_PT_GSM 

audio GSM

PJMEDIA_RTP_PT_G723 

audio G723

PJMEDIA_RTP_PT_DVI4_8K 

audio DVI4 8KHz

PJMEDIA_RTP_PT_DVI4_16K 

audio DVI4 16Khz

PJMEDIA_RTP_PT_LPC 

audio LPC

PJMEDIA_RTP_PT_PCMA 

audio PCMA

PJMEDIA_RTP_PT_G722 

audio G722

PJMEDIA_RTP_PT_L16_2 

audio 16bit linear 44.1KHz stereo

PJMEDIA_RTP_PT_L16_1 

audio 16bit linear 44.1KHz mono

PJMEDIA_RTP_PT_QCELP 

audio QCELP

PJMEDIA_RTP_PT_CN 

audio Comfort Noise

PJMEDIA_RTP_PT_MPA 

audio MPEG1/MPEG2 elemetr. streams

PJMEDIA_RTP_PT_G728 

audio G728

PJMEDIA_RTP_PT_DVI4_11K 

audio DVI4 11.025KHz mono

PJMEDIA_RTP_PT_DVI4_22K 

audio DVI4 22.050KHz mono

PJMEDIA_RTP_PT_G729 

audio G729

PJMEDIA_RTP_PT_CELB 

video/comb Cell-B by Sun (RFC2029)

PJMEDIA_RTP_PT_JPEG 

video JPEG

PJMEDIA_RTP_PT_NV 

video NV by nv program by Xerox

PJMEDIA_RTP_PT_H261 

video H261

PJMEDIA_RTP_PT_MPV 

video MPEG1 or MPEG2 elementary

PJMEDIA_RTP_PT_MP2T 

video MPEG2 transport

PJMEDIA_RTP_PT_H263 

video H263

PJMEDIA_RTP_PT_DYNAMIC 

start of dynamic RTP payload

◆ pjmedia_codec_priority

Specify these values to set the codec priority, by calling pjmedia_codec_mgr_set_codec_priority().

Enumerator
PJMEDIA_CODEC_PRIO_HIGHEST 

This priority makes the codec the highest in the order. The last codec specified with this priority will get the highest place in the order, and will change the priority of previously highest priority codec to NEXT_HIGHER.

PJMEDIA_CODEC_PRIO_NEXT_HIGHER 

This priority will put the codec as the next codec after codecs with this same priority.

PJMEDIA_CODEC_PRIO_NORMAL 

This is the initial codec priority when it is registered to codec manager by codec factory.

PJMEDIA_CODEC_PRIO_LOWEST 

This priority makes the codec the lowest in the order. The last codec specified with this priority will be put in the last place in the order.

PJMEDIA_CODEC_PRIO_DISABLED 

This priority will prevent the codec from being listed in the SDP created by media endpoint, thus should prevent the codec from being used in the sessions. However, the codec will still be listed by pjmedia_codec_mgr_enum_codecs() and other codec query functions.

Function Documentation

◆ pjmedia_codec_param_clone()

pjmedia_codec_param * pjmedia_codec_param_clone ( pj_pool_t pool,
const pjmedia_codec_param src 
)

Duplicate codec parameter.

Parameters
poolThe pool.
srcThe codec parameter to be duplicated.
Returns
Duplicated codec parameter.

◆ pjmedia_codec_mgr_init()

pj_status_t pjmedia_codec_mgr_init ( pjmedia_codec_mgr mgr,
pj_pool_factory pf 
)

Initialize codec manager. Normally this function is called by pjmedia endpoint's initialization code.

Parameters
mgrCodec manager instance.
pfPool factory instance.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_mgr_destroy()

pj_status_t pjmedia_codec_mgr_destroy ( pjmedia_codec_mgr mgr)

Destroy codec manager. Normally this function is called by pjmedia endpoint's deinitialization code.

Parameters
mgrCodec manager instance.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_mgr_register_factory()

pj_status_t pjmedia_codec_mgr_register_factory ( pjmedia_codec_mgr mgr,
pjmedia_codec_factory factory 
)

Register codec factory to codec manager. This will also register all supported codecs in the factory to the codec manager.

Parameters
mgrThe codec manager instance. Application can get the instance by calling pjmedia_endpt_get_codec_mgr().
factoryThe codec factory to be registered.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_mgr_unregister_factory()

pj_status_t pjmedia_codec_mgr_unregister_factory ( pjmedia_codec_mgr mgr,
pjmedia_codec_factory factory 
)

Unregister codec factory from the codec manager. This will also remove all the codecs registered by the codec factory from the codec manager's list of supported codecs. This function should only be called by the codec implementers and not by application.

Parameters
mgrThe codec manager instance, use pjmedia_endpt_get_codec_mgr().
factoryThe codec factory to be unregistered.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_mgr_enum_codecs()

pj_status_t pjmedia_codec_mgr_enum_codecs ( pjmedia_codec_mgr mgr,
unsigned *  count,
pjmedia_codec_info  info[],
unsigned *  prio 
)

Enumerate all supported codecs that have been registered to the codec manager by codec factories.

Parameters
mgrThe codec manager instance. Application can get the instance by calling pjmedia_endpt_get_codec_mgr().
countOn input, specifies the number of elements in the array. On output, the value will be set to the number of elements that have been initialized by this function.
infoThe codec info array, which contents will be initialized upon return.
prioOptional pointer to receive array of codec priorities.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_mgr_get_codec_info()

pj_status_t pjmedia_codec_mgr_get_codec_info ( pjmedia_codec_mgr mgr,
unsigned  pt,
const pjmedia_codec_info **  inf 
)

Get codec info for the specified static payload type. Note that this can only find codec with static payload types. This function can be used to find codec info for a payload type inside SDP which doesn't have the corresponding rtpmap attribute.

Parameters
mgrThe codec manager instance. Application can get the instance by calling pjmedia_endpt_get_codec_mgr().
ptStatic payload type/number.
infPointer to receive codec info.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_info_to_id()

char * pjmedia_codec_info_to_id ( const pjmedia_codec_info info,
char *  id,
unsigned  max_len 
)

Convert codec info struct into a unique codec identifier. A codec identifier looks something like "L16/44100/2".

Parameters
infoThe codec info
idBuffer to put the codec info string.
max_lenThe length of the buffer.
Returns
The null terminated codec info string, or NULL if the buffer is not long enough.

◆ pjmedia_codec_mgr_find_codecs_by_id()

pj_status_t pjmedia_codec_mgr_find_codecs_by_id ( pjmedia_codec_mgr mgr,
const pj_str_t codec_id,
unsigned *  count,
const pjmedia_codec_info p_info[],
unsigned  prio[] 
)

Find codecs by the unique codec identifier. This function will find all codecs that match the codec identifier prefix. For example, if "L16" is specified, then it will find "L16/8000/1", "L16/16000/1", and so on, up to the maximum count specified in the argument.

Parameters
mgrThe codec manager instance. Application can get the instance by calling pjmedia_endpt_get_codec_mgr().
codec_idThe full codec ID or codec ID prefix. If an empty string is given, it will match all codecs.
countMaximum number of codecs to find. On return, it contains the actual number of codecs found.
p_infoArray of pointer to codec info to be filled. This argument may be NULL, which in this case, only codec count will be returned.
prioOptional array of codec priorities.
Returns
PJ_SUCCESS if at least one codec info is found.

◆ pjmedia_codec_mgr_set_codec_priority()

pj_status_t pjmedia_codec_mgr_set_codec_priority ( pjmedia_codec_mgr mgr,
const pj_str_t codec_id,
pj_uint8_t  prio 
)

Set codec priority. The codec priority determines the order of the codec in the SDP created by the endpoint. If more than one codecs are found with the same codec_id prefix, then the function sets the priorities of all those codecs.

Parameters
mgrThe codec manager instance. Application can get the instance by calling pjmedia_endpt_get_codec_mgr().
codec_idThe full codec ID or codec ID prefix. If an empty string is given, it will match all codecs.
prioPriority to be set. The priority can have any value between 1 to 255. When the priority is set to zero, the codec will be disabled.
Returns
PJ_SUCCESS if at least one codec info is found.

◆ pjmedia_codec_mgr_get_default_param()

pj_status_t pjmedia_codec_mgr_get_default_param ( pjmedia_codec_mgr mgr,
const pjmedia_codec_info info,
pjmedia_codec_param param 
)

Get default codec param for the specified codec info.

Parameters
mgrThe codec manager instance. Application can get the instance by calling pjmedia_endpt_get_codec_mgr().
infoThe codec info, which default parameter's is being queried.
paramOn return, will be filled with the default codec parameter.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_mgr_set_default_param()

pj_status_t pjmedia_codec_mgr_set_default_param ( pjmedia_codec_mgr mgr,
const pjmedia_codec_info info,
const pjmedia_codec_param param 
)

Set default codec param for the specified codec info.

Parameters
mgrThe codec manager instance. Application can get the instance by calling pjmedia_endpt_get_codec_mgr().
infoThe codec info, which default parameter's is being updated.
paramThe new default codec parameter. Set to NULL to reset codec parameter to library default settings.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_mgr_alloc_codec()

pj_status_t pjmedia_codec_mgr_alloc_codec ( pjmedia_codec_mgr mgr,
const pjmedia_codec_info info,
pjmedia_codec **  p_codec 
)

Request the codec manager to allocate one instance of codec with the specified codec info. The codec will enumerate all codec factories until it finds factory that is able to create the specified codec.

Parameters
mgrThe codec manager instance. Application can get the instance by calling pjmedia_endpt_get_codec_mgr().
infoThe information about the codec to be created.
p_codecPointer to receive the codec instance.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_mgr_dealloc_codec()

pj_status_t pjmedia_codec_mgr_dealloc_codec ( pjmedia_codec_mgr mgr,
pjmedia_codec codec 
)

Deallocate the specified codec instance. The codec manager will return the instance of the codec back to its factory.

Parameters
mgrThe codec manager instance. Application can get the instance by calling pjmedia_endpt_get_codec_mgr().
codecThe codec instance.
Returns
PJ_SUCESS on success.

◆ pjmedia_codec_init()

pj_status_t pjmedia_codec_init ( pjmedia_codec codec,
pj_pool_t pool 
)

Initialize codec using the specified attribute.

Parameters
codecThe codec instance.
poolPool to use when the codec needs to allocate some memory.
Returns
PJ_SUCCESS on success.

◆ pjmedia_codec_open()

pj_status_t pjmedia_codec_open ( pjmedia_codec codec,
pjmedia_codec_param param 
)

Open the codec and initialize with the specified parameter. Upon successful initialization, the codec may modify the parameter and fills in the unspecified values (such as enc_ptime, when encoder ptime is different than decoder ptime).

Parameters
codecThe codec instance.
paramCodec initialization parameter.
Returns
PJ_SUCCESS on success.

References pjmedia_codec_desc::param, and PJ_INLINE.

◆ pjmedia_codec_close()

pj_status_t pjmedia_codec_close ( pjmedia_codec codec)

Close and shutdown codec, releasing all resources allocated by this codec, if any.

Parameters
codecThe codec instance.
Returns
PJ_SUCCESS on success.

References PJ_INLINE.

◆ pjmedia_codec_modify()

pj_status_t pjmedia_codec_modify ( pjmedia_codec codec,
const pjmedia_codec_param param 
)

Modify the codec parameter after the codec is open. Note that not all codec parameters can be modified during run-time. Currently, only Opus codec supports changing key codec parameters such as bitrate and bandwidth, while other codecs may only be able to modify minor settings such as VAD or PLC.

Parameters
codecThe codec instance.
paramThe new codec parameter.
Returns
PJ_SUCCESS on success.

References pjmedia_codec_desc::param, and PJ_INLINE.

◆ pjmedia_codec_parse()

pj_status_t pjmedia_codec_parse ( pjmedia_codec codec,
void *  pkt,
pj_size_t  pkt_size,
const pj_timestamp timestamp,
unsigned *  frame_cnt,
pjmedia_frame  frames[] 
)

Instruct the codec to inspect the specified payload/packet and split the packet into individual base frames. Each output frames will have ptime that is equal to basic frame ptime (i.e. the value of info.frm_ptime in pjmedia_codec_param).

Parameters
codecThe codec instance
pktThe input packet.
pkt_sizeSize of the packet.
timestampThe timestamp of the first sample in the packet.
frame_cntOn input, specifies the maximum number of frames in the array. On output, the codec must fill with number of frames detected in the packet.
framesOn output, specifies the frames that have been detected in the packet.
Returns
PJ_SUCCESS on success.

References PJ_INLINE.

◆ pjmedia_codec_encode()

pj_status_t pjmedia_codec_encode ( pjmedia_codec codec,
const struct pjmedia_frame input,
unsigned  out_size,
struct pjmedia_frame output 
)

Instruct the codec to encode the specified input frame. The input PCM samples MUST have ptime that is multiplication of base frame ptime (i.e. the value of info.frm_ptime in pjmedia_codec_param).

Parameters
codecThe codec instance.
inputThe input frame.
out_sizeThe length of buffer in the output frame.
outputThe output frame.
Returns
PJ_SUCCESS on success;

References PJ_INLINE.

◆ pjmedia_codec_decode()

pj_status_t pjmedia_codec_decode ( pjmedia_codec codec,
const struct pjmedia_frame input,
unsigned  out_size,
struct pjmedia_frame output 
)

Instruct the codec to decode the specified input frame. The input frame MUST have ptime that is exactly equal to base frame ptime (i.e. the value of info.frm_ptime in pjmedia_codec_param). Application can achieve this by parsing the packet into base frames before decoding each frame.

Parameters
codecThe codec instance.
inputThe input frame.
out_sizeThe length of buffer in the output frame.
outputThe output frame.
Returns
PJ_SUCCESS on success;

References PJ_INLINE.

◆ pjmedia_codec_recover()

pj_status_t pjmedia_codec_recover ( pjmedia_codec codec,
unsigned  out_size,
struct pjmedia_frame output 
)

Instruct the codec to recover a missing frame.

Parameters
codecThe codec instance.
out_sizeThe length of buffer in the output frame.
outputThe output frame where generated signal will be placed.
Returns
PJ_SUCCESS on success;

References PJ_ENOTSUP, and PJ_INLINE.

 


PJMEDIA small footprint Open Source media stack
Copyright (C) 2006-2008 Teluu Inc.