BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJMEDIA Reference

Media channel splitter/combiner

Split and combine multiple mono-channel media ports into a single multiple-channels media port. More...

Functions

PJ_BEGIN_DECL pj_status_t pjmedia_splitcomb_create (pj_pool_t *pool, unsigned clock_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample, unsigned options, pjmedia_port **p_splitcomb)
 
pj_status_t pjmedia_splitcomb_set_channel (pjmedia_port *splitcomb, unsigned ch_num, unsigned options, pjmedia_port *port)
 
pj_status_t pjmedia_splitcomb_create_rev_channel (pj_pool_t *pool, pjmedia_port *splitcomb, unsigned ch_num, unsigned options, pjmedia_port **p_chport)
 

Detailed Description

This section describes media port to split and combine media channels in the stream.

A splitter/combiner splits a single stereo/multichannels audio frame into multiple audio frames to each channel when put_frame() is called, and combines mono frames from each channel into a stereo/multichannel frame when get_frame() is called. A common application for the splitter/ combiner is to split frames from stereo to mono and vise versa.

Function Documentation

PJ_BEGIN_DECL pj_status_t pjmedia_splitcomb_create ( pj_pool_t pool,
unsigned  clock_rate,
unsigned  channel_count,
unsigned  samples_per_frame,
unsigned  bits_per_sample,
unsigned  options,
pjmedia_port **  p_splitcomb 
)

Create a media splitter/combiner with the specified parameters. When the splitter/combiner is created, it creates an instance of pjmedia_port. This media port represents the stereo/multichannel side of the splitter/combiner. Application needs to supply the splitter/ combiner with a media port for each audio channels.

Parameters
poolPool to allocate memory to create the splitter/ combiner.
clock_rateAudio clock rate/sampling rate.
channel_countNumber of channels.
samples_per_frameNumber of samples per frame.
bits_per_sampleBits per sample.
optionsOptional flags.
p_splitcombPointer to receive the splitter/combiner.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjmedia_splitcomb_set_channel ( pjmedia_port splitcomb,
unsigned  ch_num,
unsigned  options,
pjmedia_port port 
)

Supply the splitter/combiner with media port for the specified channel number. The media port will be called at the same phase as the splitter/combiner; which means that when application calls get_frame() of the splitter/combiner, it will call get_frame() for all ports that have the same phase. And similarly for put_frame().

Parameters
splitcombThe splitter/combiner.
ch_numAudio channel starting number (zero based).
optionsMust be zero at the moment.
portThe media port.
Returns
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pjmedia_splitcomb_create_rev_channel ( pj_pool_t pool,
pjmedia_port splitcomb,
unsigned  ch_num,
unsigned  options,
pjmedia_port **  p_chport 
)

Create a reverse phase media port for the specified channel number. For channels with reversed phase, when application calls put_frame() to the splitter/combiner, the splitter/combiner will only put the frame to a buffer. Later on, when application calls get_frame() on the channel's media port, it will return the frame that are available in the buffer. The same process happens when application calls put_frame() to the channel's media port, it will only put the frame to another buffer, which will be returned when application calls get_frame() to the splitter's media port. So this effectively reverse the phase of the media port.

Parameters
poolThe pool to allocate memory for the port and buffers.
splitcombThe splitter/combiner.
ch_numAudio channel starting number (zero based).
optionsNormally is zero, but the lower 8-bit of the options can be used to specify the number of buffers in the circular buffer. If zero, then default number will be used (default: 8).
p_chportThe media port created with reverse phase for the specified audio channel.
Returns
PJ_SUCCESS on success, or the appropriate error code.

 


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