Group PJMEDIA_CONVERTER

group PJMEDIA_CONVERTER

Audio and video converter utilities.

Typedefs

typedef void pjmedia_converter_convert_setting

Settings for pjmedia_converter_convert2().

typedef struct pjmedia_converter_mgr pjmedia_converter_mgr

Opaque data type for conversion manager. Typically, the conversion manager is a singleton instance, although application may instantiate more than one instances of this if required.

Enums

enum pjmedia_converter_priority_guide

Converter priority guides. Converter priority determines which converter instance to be used if more than one converters are able to perform the requested conversion. Converter implementor can use this value to order the preference based on attributes such as quality or performance. Higher number indicates higher priority.

Values:

enumerator PJMEDIA_CONVERTER_PRIORITY_LOWEST

Lowest priority.

enumerator PJMEDIA_CONVERTER_PRIORITY_NORMAL

Normal priority.

enumerator PJMEDIA_CONVERTER_PRIORITY_HIGHEST

Highest priority.

Functions

pj_status_t pjmedia_converter_mgr_create(pj_pool_t *pool, pjmedia_converter_mgr **mgr)

Create a new conversion manager instance. This will also set the pointer to the singleton instance if the value is still NULL.

Parameters:
  • pool – Pool to allocate memory from.

  • mgr – Pointer to hold the created instance of the conversion manager.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pjmedia_converter_mgr *pjmedia_converter_mgr_instance(void)

Get the singleton instance of the conversion manager.

Returns:

The instance.

void pjmedia_converter_mgr_set_instance(pjmedia_converter_mgr *mgr)

Manually assign a specific video manager instance as the singleton instance. Normally this is not needed if only one instance is ever going to be created, as the library automatically assign the singleton instance.

Parameters:

mgr – The instance to be used as the singleton instance. Application may specify NULL to clear the singleton singleton instance.

void pjmedia_converter_mgr_destroy(pjmedia_converter_mgr *mgr)

Destroy a converter manager. If the manager happens to be the singleton instance, the singleton instance will be set to NULL.

Parameters:

mgr – The converter manager. Specify NULL to use the singleton instance.

pj_status_t pjmedia_converter_mgr_register_factory(pjmedia_converter_mgr *mgr, pjmedia_converter_factory *f)

Register a converter factory to the converter manager.

Parameters:
  • mgr – The converter manager. Specify NULL to use the singleton instance.

  • f – The converter factory to be registered.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pjmedia_converter_mgr_unregister_factory(pjmedia_converter_mgr *mgr, pjmedia_converter_factory *f, pj_bool_t call_destroy)

Unregister a previously registered converter factory from the converter manager.

Parameters:
  • mgr – The converter manager. Specify NULL to use the singleton instance.

  • f – The converter factory to be unregistered.

  • call_destroy – If this is set to non-zero, the destroy_factory() callback of the factory will be called while unregistering the factory from the manager.

Returns:

PJ_SUCCESS on success or the appropriate error code.

pj_status_t pjmedia_converter_create(pjmedia_converter_mgr *mgr, pj_pool_t *pool, pjmedia_conversion_param *param, pjmedia_converter **p_cv)

Create a converter instance to perform the specified format conversion as specified in param.

Parameters:
  • mgr – The converter manager. Specify NULL to use the singleton instance.

  • pool – Pool to allocate the memory from.

  • param – Conversion parameter.

  • p_cv – Pointer to hold the created converter.

Returns:

PJ_SUCCESS if a converter has been created successfully or the appropriate error code.

pj_status_t pjmedia_converter_convert(pjmedia_converter *cv, pjmedia_frame *src_frame, pjmedia_frame *dst_frame)

Convert the buffer in the source frame and save the result in the buffer of the destination frame, according to conversion format that was specified when the converter was created.

Parameters:
  • cv – The converter instance.

  • src_frame – The source frame.

  • dst_frame – The destination frame.

Returns:

PJ_SUCCESS if conversion has been performed successfully.

pj_status_t pjmedia_converter_convert2(pjmedia_converter *cv, pjmedia_frame *src_frame, const pjmedia_rect_size *src_frame_size, const pjmedia_coord *src_pos, pjmedia_frame *dst_frame, const pjmedia_rect_size *dst_frame_size, const pjmedia_coord *dst_pos, pjmedia_converter_convert_setting *param)

Convert a region in the buffer of the source frame and put the result into a region in the buffer of the destination frame, according to conversion format that was specified when the converter was created.

Parameters:
  • cv – The converter instance.

  • src_frame – The source frame.

  • src_frame_size – The source frame size.

  • src_pos – The source region position.

  • dst_frame – The destination frame.

  • dst_frame_size – The destination frame size.

  • dst_pos – The destination region position.

  • param – This is unused for now and must be NULL.

Returns:

PJ_SUCCESS if conversion has been performed successfully.

void pjmedia_converter_destroy(pjmedia_converter *cv)

Destroy the converter.

Parameters:

cv – The converter instance.

struct pjmedia_conversion_param
#include <converter.h>

This describes conversion parameter. It specifies the source and destination formats of the conversion.

Public Members

pjmedia_format src

Source format.

pjmedia_format dst

Destination format.

struct pjmedia_converter_factory
#include <converter.h>

Converter factory. The converter factory registers a callback function to create converters.

Public Functions

PJ_DECL_LIST_MEMBER(struct pjmedia_converter_factory)

Standard list members.

Public Members

const char *name

Factory name.

int priority

Converter priority determines which converter instance to be used if more than one converters are able to perform the requested conversion. Converter implementor can use this value to order the preference based on attributes such as quality or performance. Higher number indicates higher priority. The pjmedia_converter_priority_guide enumeration shall be used as the base value to set the priority.

pjmedia_converter_factory_op *op

Pointer to factory operation.

struct pjmedia_converter
#include <converter.h>

This structure describes a converter instance.

Public Members

pjmedia_converter_op *op

Pointer to converter operation.

struct pjmedia_converter_factory_op
#include <converter.h>

Converter factory operation.

Forward declaration of factory operation structure

Public Members

pj_status_t (*create_converter)(pjmedia_converter_factory *cf, pj_pool_t *pool, const pjmedia_conversion_param *prm, pjmedia_converter **p_cv)

This function creates a converter with the specified conversion format, if such format is supported.

Param cf:

The converter factory.

Param pool:

Pool to allocate memory from.

Param prm:

Conversion parameter.

Param p_cv:

Pointer to hold the created converter instance.

Return:

PJ_SUCCESS if converter has been created successfully.

void (*destroy_factory)(pjmedia_converter_factory *cf)

Destroy the factory.

Param cf:

The converter factory.

struct pjmedia_converter_op
#include <converter.h>

Converter operation.

Forward declaration for converter operation.

Public Members

pj_status_t (*convert)(pjmedia_converter *cv, pjmedia_frame *src_frame, pjmedia_frame *dst_frame)

Convert the buffer of the source frame and save the result in the buffer of the destination frame, according to conversion format that was specified when the converter was created.

Note that application should use pjmedia_converter_convert() instead of calling this function directly.

Param cv:

The converter instance.

Param src_frame:

The source frame.

Param dst_frame:

The destination frame.

Return:

PJ_SUCCESS if conversion has been performed successfully.

void (*destroy)(pjmedia_converter *cv)

Destroy the converter instance.

Note that application should use pjmedia_converter_destroy() instead of calling this function directly.

Param cv:

The converter.

pj_status_t (*convert2)(pjmedia_converter *cv, pjmedia_frame *src_frame, const pjmedia_rect_size *src_frame_size, const pjmedia_coord *src_pos, pjmedia_frame *dst_frame, const pjmedia_rect_size *dst_frame_size, const pjmedia_coord *dst_pos, pjmedia_converter_convert_setting *param)

Convert a region in the buffer of the source frame and put the result into a region in the buffer of the destination frame, according to conversion format that was specified when the converter was created.

Note that application should use pjmedia_converter_convert2() instead of calling this function directly.

Param cv:

The converter instance.

Param src_frame:

The source frame.

Param src_frame_size:

The source frame size.

Param src_reg_pos:

The source region position.

Param dst_frame:

The destination frame.

Param dst_frame_size:

The destination frame size.

Param dst_reg_pos:

The destination region position.

Param param:

This is unused for now and must be NULL.

Return:

PJ_SUCCESS if conversion has been performed successfully.