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

pjmedia_codec_op Struct Reference

#include <codec.h>

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

◆ init

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.

◆ open

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.

◆ close

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.

◆ modify

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. 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.

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.

◆ parse

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.

◆ encode

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;

◆ decode

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;

◆ recover

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.