BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJMEDIA Reference

Monochannel and multichannel audio frame converter

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

Macros

#define PJMEDIA_STEREO_MIX   PJ_TRUE
 

Enumerations

enum  pjmedia_stereo_port_options { PJMEDIA_STEREO_DONT_DESTROY_DN = 4 }
 

Functions

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

#define PJMEDIA_STEREO_MIX   PJ_TRUE

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.

Enumerator
PJMEDIA_STEREO_DONT_DESTROY_DN 

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).
Parameters
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.
Returns
PJ_SUCCESS on success;

References PJ_ASSERT_RETURN, PJ_EINVAL, PJ_FALSE, PJ_INLINE, and PJ_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.

Parameters
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.
Returns
PJ_SUCCESS on success;

References PJ_ASSERT_RETURN, PJ_EINVAL, PJ_INLINE, PJ_SUCCESS, and PJ_UNUSED_ARG.

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.

Parameters
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.
Returns
PJ_SUCCESS on success.

 


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