Home --> Documentations --> PJMEDIA Reference

Data Fields
pjmedia_codec_op Struct Reference

Data Fields

pj_status_t(* init )(pjmedia_codec *codec, pj_pool_t *pool)
 
pj_status_t(* open )(pjmedia_codec *codec, pjmedia_codec_param *param)
 
pj_status_t(* close )(pjmedia_codec *codec)
 
pj_status_t(* modify )(pjmedia_codec *codec, const pjmedia_codec_param *param)
 
pj_status_t(* parse )(pjmedia_codec *codec, void *pkt, pj_size_t pkt_size, const pj_timestamp *timestamp, unsigned *frame_cnt, pjmedia_frame frames[])
 
pj_status_t(* encode )(pjmedia_codec *codec, const struct pjmedia_frame *input, unsigned out_size, struct pjmedia_frame *output)
 
pj_status_t(* decode )(pjmedia_codec *codec, const struct pjmedia_frame *input, unsigned out_size, struct pjmedia_frame *output)
 
pj_status_t(* recover )(pjmedia_codec *codec, unsigned out_size, struct pjmedia_frame *output)
 

Detailed Description

This structure describes codec operations. Each codec MUST implement all of these functions.

Field Documentation

pj_status_t(* pjmedia_codec_op::init)(pjmedia_codec *codec, pj_pool_t *pool)

Initialize codec using the specified attribute.

Application should call pjmedia_codec_init() instead of calling this function directly.

Parameters
codecThe codec instance.
poolPool to use when the codec needs to allocate some memory.
Returns
PJ_SUCCESS on success.
pj_status_t(* pjmedia_codec_op::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).

Application should call pjmedia_codec_open() instead of calling this function directly.

Parameters
codecThe codec instance.
paramCodec initialization parameter.
Returns
PJ_SUCCESS on success.
pj_status_t(* pjmedia_codec_op::close)(pjmedia_codec *codec)

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

Application should call pjmedia_codec_close() instead of calling this function directly.

Parameters
codecThe codec instance.
Returns
PJ_SUCCESS on success.
pj_status_t(* pjmedia_codec_op::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. When the parameter cannot be changed, this function will return non-PJ_SUCCESS, and the original parameters will not be changed.

Application can expect changing trivial codec settings such as changing VAD setting to succeed.

Application should call pjmedia_codec_modify() instead of calling this function directly.

Parameters
codecThe codec instance.
paramThe new codec parameter.
Returns
PJ_SUCCESS on success.
pj_status_t(* pjmedia_codec_op::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).

Application should call pjmedia_codec_parse() instead of calling this function directly.

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.
pj_status_t(* pjmedia_codec_op::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).

Application should call pjmedia_codec_encode() instead of calling this function directly.

Parameters
codecThe codec instance.
inputThe input frame.
out_sizeThe length of buffer in the output frame.
outputThe output frame.
Returns
PJ_SUCCESS on success;
pj_status_t(* pjmedia_codec_op::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.

Application should call pjmedia_codec_decode() instead of calling this function directly.

Parameters
codecThe codec instance.
inputThe input frame.
out_sizeThe length of buffer in the output frame.
outputThe output frame.
Returns
PJ_SUCCESS on success;
pj_status_t(* pjmedia_codec_op::recover)(pjmedia_codec *codec, unsigned out_size, struct pjmedia_frame *output)

Instruct the codec to recover a missing frame.

Application should call pjmedia_codec_recover() instead of calling this function directly.

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;

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

 


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