BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJMEDIA Reference

Modules

 Supported video codecs
 

Data Structures

struct  pjmedia_vid_encode_opt
 
struct  pjmedia_vid_codec_info
 
struct  pjmedia_vid_codec_param
 
struct  pjmedia_vid_codec_op
 
struct  pjmedia_vid_codec
 
struct  pjmedia_vid_codec_factory_op
 
struct  pjmedia_vid_codec_factory
 

Macros

#define PJMEDIA_VID_CODEC_MAX_DEC_FMT_CNT   8
 
#define PJMEDIA_VID_CODEC_MAX_FPS_CNT   16
 
#define PJMEDIA_VID_CODEC_MGR_MAX_CODECS   32
 

Typedefs

typedef struct pjmedia_vid_codec_mgr pjmedia_vid_codec_mgr
 

Enumerations

enum  pjmedia_vid_packing {
  PJMEDIA_VID_PACKING_UNKNOWN ,
  PJMEDIA_VID_PACKING_PACKETS = 1 ,
  PJMEDIA_VID_PACKING_WHOLE = 2
}
 
enum  pjmedia_vid_frm_bit_info { PJMEDIA_VID_FRM_KEYFRAME = 1 }
 

Functions

pjmedia_vid_codec_parampjmedia_vid_codec_param_clone (pj_pool_t *pool, const pjmedia_vid_codec_param *src)
 
pj_status_t pjmedia_vid_codec_mgr_create (pj_pool_t *pool, pjmedia_vid_codec_mgr **mgr)
 
pj_status_t pjmedia_vid_codec_mgr_destroy (pjmedia_vid_codec_mgr *mgr)
 
pjmedia_vid_codec_mgrpjmedia_vid_codec_mgr_instance (void)
 
void pjmedia_vid_codec_mgr_set_instance (pjmedia_vid_codec_mgr *mgr)
 
pj_status_t pjmedia_vid_codec_mgr_register_factory (pjmedia_vid_codec_mgr *mgr, pjmedia_vid_codec_factory *factory)
 
pj_status_t pjmedia_vid_codec_mgr_unregister_factory (pjmedia_vid_codec_mgr *mgr, pjmedia_vid_codec_factory *factory)
 
pj_status_t pjmedia_vid_codec_mgr_enum_codecs (pjmedia_vid_codec_mgr *mgr, unsigned *count, pjmedia_vid_codec_info info[], unsigned *prio)
 
pj_status_t pjmedia_vid_codec_mgr_get_codec_info (pjmedia_vid_codec_mgr *mgr, unsigned pt, const pjmedia_vid_codec_info **info)
 
pj_status_t pjmedia_vid_codec_mgr_get_codec_info2 (pjmedia_vid_codec_mgr *mgr, pjmedia_format_id fmt_id, const pjmedia_vid_codec_info **info)
 
char * pjmedia_vid_codec_info_to_id (const pjmedia_vid_codec_info *info, char *id, unsigned max_len)
 
pj_status_t pjmedia_vid_codec_mgr_find_codecs_by_id (pjmedia_vid_codec_mgr *mgr, const pj_str_t *codec_id, unsigned *count, const pjmedia_vid_codec_info *p_info[], unsigned prio[])
 
pj_status_t pjmedia_vid_codec_mgr_set_codec_priority (pjmedia_vid_codec_mgr *mgr, const pj_str_t *codec_id, pj_uint8_t prio)
 
pj_status_t pjmedia_vid_codec_mgr_get_default_param (pjmedia_vid_codec_mgr *mgr, const pjmedia_vid_codec_info *info, pjmedia_vid_codec_param *param)
 
pj_status_t pjmedia_vid_codec_mgr_set_default_param (pjmedia_vid_codec_mgr *mgr, const pjmedia_vid_codec_info *info, const pjmedia_vid_codec_param *param)
 
pj_status_t pjmedia_vid_codec_mgr_alloc_codec (pjmedia_vid_codec_mgr *mgr, const pjmedia_vid_codec_info *info, pjmedia_vid_codec **p_codec)
 
pj_status_t pjmedia_vid_codec_mgr_dealloc_codec (pjmedia_vid_codec_mgr *mgr, pjmedia_vid_codec *codec)
 
pj_status_t pjmedia_vid_codec_init (pjmedia_vid_codec *codec, pj_pool_t *pool)
 
pj_status_t pjmedia_vid_codec_open (pjmedia_vid_codec *codec, pjmedia_vid_codec_param *param)
 
pj_status_t pjmedia_vid_codec_close (pjmedia_vid_codec *codec)
 
pj_status_t pjmedia_vid_codec_modify (pjmedia_vid_codec *codec, const pjmedia_vid_codec_param *param)
 
pj_status_t pjmedia_vid_codec_get_param (pjmedia_vid_codec *codec, pjmedia_vid_codec_param *param)
 
pj_status_t pjmedia_vid_codec_encode_begin (pjmedia_vid_codec *codec, const pjmedia_vid_encode_opt *opt, const pjmedia_frame *input, unsigned out_size, pjmedia_frame *output, pj_bool_t *has_more)
 
pj_status_t pjmedia_vid_codec_encode_more (pjmedia_vid_codec *codec, unsigned out_size, pjmedia_frame *output, pj_bool_t *has_more)
 
pj_status_t pjmedia_vid_codec_decode (pjmedia_vid_codec *codec, pj_size_t pkt_count, pjmedia_frame packets[], unsigned out_size, pjmedia_frame *output)
 
pj_status_t pjmedia_vid_codec_recover (pjmedia_vid_codec *codec, unsigned out_size, pjmedia_frame *output)
 

Detailed Description

Macro Definition Documentation

◆ PJMEDIA_VID_CODEC_MGR_MAX_CODECS

#define PJMEDIA_VID_CODEC_MGR_MAX_CODECS   32

Declare maximum codecs

Typedef Documentation

◆ pjmedia_vid_codec_mgr

Opaque declaration for codec manager.

Enumeration Type Documentation

◆ pjmedia_vid_packing

This enumeration specifies the packetization property of video encoding process. The value is bitmask, and smaller value will have higher priority to be used.

Enumerator
PJMEDIA_VID_PACKING_UNKNOWN 

This specifies that the packetization is unknown, or if nothing is supported.

PJMEDIA_VID_PACKING_PACKETS 

This specifies that the result of video encoding process will be segmented into packets, which is suitable for RTP transmission. The maximum size of the packets is set in enc_mtu field of pjmedia_vid_codec_param.

PJMEDIA_VID_PACKING_WHOLE 

This specifies that video encoding function will produce a whole or full frame from the source frame. This is normally used for encoding video for offline storage such as to an AVI file. The maximum size of the packets is set in enc_mtu field of pjmedia_vid_codec_param.

◆ pjmedia_vid_frm_bit_info

Enumeration of video frame info flag for the bit_info field in the pjmedia_frame.

Enumerator
PJMEDIA_VID_FRM_KEYFRAME 

The video frame is keyframe.

Function Documentation

◆ pjmedia_vid_codec_param_clone()

pjmedia_vid_codec_param * pjmedia_vid_codec_param_clone ( pj_pool_t pool,
const pjmedia_vid_codec_param src 
)

Duplicate video codec parameter.

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

◆ pjmedia_vid_codec_mgr_create()

pj_status_t pjmedia_vid_codec_mgr_create ( pj_pool_t pool,
pjmedia_vid_codec_mgr **  mgr 
)

Initialize codec manager. If there is no the default video codec manager, this function will automatically set the default video codec manager to the new codec manager instance. Normally this function is called by pjmedia endpoint's initialization code.

Parameters
poolThe pool instance.
mgrThe pointer to the new codec manager instance.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_codec_mgr_destroy()

pj_status_t pjmedia_vid_codec_mgr_destroy ( pjmedia_vid_codec_mgr mgr)

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

Parameters
mgrCodec manager instance. If NULL, it is the default codec manager instance will be destroyed.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_codec_mgr_instance()

pjmedia_vid_codec_mgr * pjmedia_vid_codec_mgr_instance ( void  )

Get the default codec manager instance.

Returns
The default codec manager instance or NULL if none.

◆ pjmedia_vid_codec_mgr_set_instance()

void pjmedia_vid_codec_mgr_set_instance ( pjmedia_vid_codec_mgr mgr)

Set the default codec manager instance.

Parameters
mgrThe codec manager instance.

◆ pjmedia_vid_codec_mgr_register_factory()

pj_status_t pjmedia_vid_codec_mgr_register_factory ( pjmedia_vid_codec_mgr mgr,
pjmedia_vid_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. If NULL, the default codec manager instance will be used.
factoryThe codec factory to be registered.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_codec_mgr_unregister_factory()

pj_status_t pjmedia_vid_codec_mgr_unregister_factory ( pjmedia_vid_codec_mgr mgr,
pjmedia_vid_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.

Parameters
mgrThe codec manager instance. If NULL, the default codec manager instance will be used.
factoryThe codec factory to be unregistered.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_codec_mgr_enum_codecs()

pj_status_t pjmedia_vid_codec_mgr_enum_codecs ( pjmedia_vid_codec_mgr mgr,
unsigned *  count,
pjmedia_vid_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. If NULL, the default codec manager instance will be used.
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_vid_codec_mgr_get_codec_info()

pj_status_t pjmedia_vid_codec_mgr_get_codec_info ( pjmedia_vid_codec_mgr mgr,
unsigned  pt,
const pjmedia_vid_codec_info **  info 
)

Get codec info for the specified payload type. The payload type must be static or locally defined in pjmedia_video_pt.

Parameters
mgrThe codec manager instance. If NULL, the default codec manager instance will be used.
ptThe payload type/number.
infoPointer to receive codec info.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_codec_mgr_get_codec_info2()

pj_status_t pjmedia_vid_codec_mgr_get_codec_info2 ( pjmedia_vid_codec_mgr mgr,
pjmedia_format_id  fmt_id,
const pjmedia_vid_codec_info **  info 
)

Get codec info for the specified format ID.

Parameters
mgrThe codec manager instance. If NULL, the default codec manager instance will be used.
fmt_idFormat ID. See pjmedia_format_id
infoPointer to receive codec info.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_codec_info_to_id()

char * pjmedia_vid_codec_info_to_id ( const pjmedia_vid_codec_info info,
char *  id,
unsigned  max_len 
)

Convert codec info struct into a unique codec identifier. A codec identifier looks something like "H263/34", where "H263" is the codec name and "34" is the (default) payload type.

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_vid_codec_mgr_find_codecs_by_id()

pj_status_t pjmedia_vid_codec_mgr_find_codecs_by_id ( pjmedia_vid_codec_mgr mgr,
const pj_str_t codec_id,
unsigned *  count,
const pjmedia_vid_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 "H26" is specified, then it will find "H263", "H264", and so on, up to the maximum count specified in the argument.

Parameters
mgrThe codec manager instance. If NULL, the default codec manager instance will be used.
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_vid_codec_mgr_set_codec_priority()

pj_status_t pjmedia_vid_codec_mgr_set_codec_priority ( pjmedia_vid_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. If NULL, the default codec manager instance will be used.
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_vid_codec_mgr_get_default_param()

pj_status_t pjmedia_vid_codec_mgr_get_default_param ( pjmedia_vid_codec_mgr mgr,
const pjmedia_vid_codec_info info,
pjmedia_vid_codec_param param 
)

Get default codec param for the specified codec info.

Parameters
mgrThe codec manager instance. If NULL, the default codec manager instance will be used.
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_vid_codec_mgr_set_default_param()

pj_status_t pjmedia_vid_codec_mgr_set_default_param ( pjmedia_vid_codec_mgr mgr,
const pjmedia_vid_codec_info info,
const pjmedia_vid_codec_param param 
)

Set default codec param for the specified codec info.

Parameters
mgrThe codec manager instance. If NULL, the default codec manager instance will be used.
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_vid_codec_mgr_alloc_codec()

pj_status_t pjmedia_vid_codec_mgr_alloc_codec ( pjmedia_vid_codec_mgr mgr,
const pjmedia_vid_codec_info info,
pjmedia_vid_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. If NULL, the default codec manager instance will be used.
infoThe information about the codec to be created.
p_codecPointer to receive the codec instance.
Returns
PJ_SUCCESS on success.

◆ pjmedia_vid_codec_mgr_dealloc_codec()

pj_status_t pjmedia_vid_codec_mgr_dealloc_codec ( pjmedia_vid_codec_mgr mgr,
pjmedia_vid_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. If NULL, the default codec manager instance will be used.
codecThe codec instance.
Returns
PJ_SUCESS on success.

◆ pjmedia_vid_codec_init()

pj_status_t pjmedia_vid_codec_init ( pjmedia_vid_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_vid_codec_open()

pj_status_t pjmedia_vid_codec_open ( pjmedia_vid_codec codec,
pjmedia_vid_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 size or frame rate of the encoder format, as it may need to be negotiated with remote preferences via SDP fmtp).

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

References PJ_INLINE.

◆ pjmedia_vid_codec_close()

pj_status_t pjmedia_vid_codec_close ( pjmedia_vid_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_vid_codec_modify()

pj_status_t pjmedia_vid_codec_modify ( pjmedia_vid_codec codec,
const pjmedia_vid_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.

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

◆ pjmedia_vid_codec_get_param()

pj_status_t pjmedia_vid_codec_get_param ( pjmedia_vid_codec codec,
pjmedia_vid_codec_param param 
)

Get the codec parameter after the codec is opened.

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

◆ pjmedia_vid_codec_encode_begin()

pj_status_t pjmedia_vid_codec_encode_begin ( pjmedia_vid_codec codec,
const pjmedia_vid_encode_opt opt,
const pjmedia_frame input,
unsigned  out_size,
pjmedia_frame output,
pj_bool_t has_more 
)

Encode the specified input frame. The input MUST contain only one picture with the appropriate format as specified when opening the codec. Depending on the packing or packetization set in the packing param, the process may produce multiple encoded packets or payloads to represent the picture. This is true for example for PJMEDIA_VID_PACKING_PACKETS packing. In this case, the has_more field will be set to PJ_TRUE, and application should call pjmedia_vid_codec_encode_more() to get the remaining results from the codec.

Parameters
codecThe codec instance.
optOptional encoding options.
inputThe input frame.
out_sizeThe length of buffer in the output frame. This should be at least the same as the configured encoding MTU of the codec.
outputThe output frame.
has_morePJ_TRUE if more payloads are available; application should then call pjmedia_vid_codec_encode_more() to retrieve the remaining results.
Returns
PJ_SUCCESS on success;

◆ pjmedia_vid_codec_encode_more()

pj_status_t pjmedia_vid_codec_encode_more ( pjmedia_vid_codec codec,
unsigned  out_size,
pjmedia_frame output,
pj_bool_t has_more 
)

Retrieve more encoded packets/payloads from the codec. Application should call this function repeatedly until has_more flag is set to PJ_FALSE.

Parameters
codecThe codec instance.
out_sizeThe length of buffer in the output frame. This should be at least the same as as the configured encoding MTU of the codec.
outputThe output frame.
has_morePJ_TRUE if more payloads are available, which in this case application should call encode_more() to retrieve them.
Returns
PJ_SUCCESS on success;

◆ pjmedia_vid_codec_decode()

pj_status_t pjmedia_vid_codec_decode ( pjmedia_vid_codec codec,
pj_size_t  pkt_count,
pjmedia_frame  packets[],
unsigned  out_size,
pjmedia_frame output 
)

Decode the input packets into one picture. If the packing is set to PJMEDIA_VID_PACKING_PACKETS when opening the codec, the codec is set to decode multiple encoded packets into one picture. These encoded packets are typically retrieved from the jitter buffer. If the packing is set to PJMEDIA_VID_PACKING_WHOLE, then this decode function can only accept one frame as the input.

Note that the decoded picture format may different to the configured setting (i.e. the format specified in the pjmedia_vid_codec_param when opening the codec), in this case the PJMEDIA_EVENT_FMT_CHANGED event will be emitted by the codec to notify the event. The codec parameter will also be updated, and application can query the format by using pjmedia_vid_codec_get_param().

Parameters
codecThe codec instance.
pkt_countNumber of packets in the input.
packetsArray of input packets, each containing an encoded frame.
out_sizeThe length of buffer in the output frame.
outputThe output frame.
Returns
PJ_SUCCESS on success;

References PJ_INLINE.

◆ pjmedia_vid_codec_recover()

pj_status_t pjmedia_vid_codec_recover ( pjmedia_vid_codec codec,
unsigned  out_size,
pjmedia_frame output 
)

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.