Group PJMEDIA_STEREO

group PJMEDIA_STEREO

Mono - multi-channels audio conversion.

Defines

PJMEDIA_STEREO_MIX

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

Enums

enum pjmedia_stereo_port_options

Options for channel converter port.

Values:

enumerator PJMEDIA_STEREO_DONT_DESTROY_DN

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

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)

Multichannel to monochannel conversion. This function can work safely using the same buffer (in place conversion).

Parameters:
  • mono – Output buffer to store the mono frame extracted from the multichannels frame.

  • multi – Input frame containing multichannels audio.

  • channel_count – Number of channels in the input frame.

  • samples_per_frame – Number of samples in the input frame.

  • mix – If 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_src – When mixing is disabled, the mono output frame will be copied from this channel number.

Returns:

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.

Parameters:
  • multi – Output buffer to store the multichannels frame mixed from the mono frame.

  • mono – The input monochannel audio frame.

  • channel_count – Desired number of channels in the output frame.

  • samples_per_frame – Number of samples in the input frame.

  • options – Options for conversion, currently must be zero.

Returns:

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.

Parameters:
  • pool – Pool to allocate the structure and buffers.

  • dn_port – The downstream port, which channel count is to be converted to the target channel count.

  • channel_count – This port channel count.

  • options – Bitmask 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_port – Pointer to receive the stereo port instance.

Returns:

PJ_SUCCESS on success.