Home --> Documentations --> PJMEDIA Reference

Macros | Enumerations | Functions
Monochannel and multichannel audio frame converter

Mono - multi-channels audio conversion. More...




enum  pjmedia_stereo_port_options { PJMEDIA_STEREO_DONT_DESTROY_DN = 4 }


pj_status_t pjmedia_convert_channel_nto1 (pj_int16_t mono[], const pj_int16_t multi[], unsigned channel_count, unsigned samples_per_frame, pj_bool_t mix, unsigned channel_src)
pj_status_t pjmedia_convert_channel_1ton (pj_int16_t multi[], const pj_int16_t mono[], unsigned channel_count, unsigned samples_per_frame, unsigned options)
pj_status_t pjmedia_stereo_port_create (pj_pool_t *pool, pjmedia_port *dn_port, unsigned channel_count, unsigned options, pjmedia_port **p_port)

Detailed Description

Macro Definition Documentation


Multichannel to monochannel conversion mixes samples from all channels into the monochannel.

Enumeration Type Documentation

Options for channel converter port. The #pjmedia_stereo_options is also valid for this port options.


Specifies whether this port should not destroy downstream port when this port is destroyed.

Function Documentation

pj_status_t pjmedia_convert_channel_nto1 ( pj_int16_t  mono[],
const pj_int16_t  multi[],
unsigned  channel_count,
unsigned  samples_per_frame,
pj_bool_t  mix,
unsigned  channel_src 

Multichannel to monochannel conversion, it has two operation mode specified by param options,

See also
pjmedia_stereo_options. This function can work safely using the same buffer (in place conversion).
monoOutput buffer to store the mono frame extracted from the multichannels frame.
multiInput frame containing multichannels audio.
channel_countNumber of channels in the input frame.
samples_per_frameNumber of samples in the input frame.
mixIf the value is PJ_TRUE then the input channels will be mixed to produce output frame, otherwise only frame from channel_src will be copied to the output frame.
channel_srcWhen mixing is disabled, the mono output frame will be copied from this channel number.
PJ_SUCCESS on success;


pj_status_t pjmedia_convert_channel_1ton ( pj_int16_t  multi[],
const pj_int16_t  mono[],
unsigned  channel_count,
unsigned  samples_per_frame,
unsigned  options 

Monochannel to multichannel conversion, it will just duplicate the samples from monochannel frame to all channels in the multichannel frame. This function can work safely using the same buffer (in place conversion) as long as the buffer is big enough for the multichannel samples.

multiOutput buffer to store the multichannels frame mixed from the mono frame.
monoThe input monochannel audio frame.
channel_countDesired number of channels in the output frame.
samples_per_frameNumber of samples in the input frame.
optionsOptions for conversion, currently must be zero.
PJ_SUCCESS on success;


pj_status_t pjmedia_stereo_port_create ( pj_pool_t pool,
pjmedia_port dn_port,
unsigned  channel_count,
unsigned  options,
pjmedia_port **  p_port 

Create a mono-multi channel converter port. This creates a converter session, which will adjust the samples of audio frame to a different channel count when the port's get_frame() and put_frame() is called.

When the port's get_frame() is called, this port will get a frame from the downstream port and convert the frame to the target channel count before returning it to the caller.

When the port's put_frame() is called, this port will convert the frame to the downstream port's channel count before giving the frame to the downstream port.

poolPool to allocate the structure and buffers.
dn_portThe downstream port, which channel count is to be converted to the target channel count.
channel_countThis port channel count.
optionsBitmask flags from pjmedia_stereo_port_options and also application may add PJMEDIA_STEREO_MIX to mix channels. When this flag is zero, the default behavior is to use simple N-to-1 channel converter and to destroy downstream port when this port is destroyed.
p_portPointer to receive the stereo port instance.
PJ_SUCCESS on success.


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