pjsip logo pjsip.org
Open source SIP stack and media stack for presence, im/instant messaging, and multimedia communication

HOME

SIP/media Features
High Performance SIP
Small Footprint SIP
Symbian Port

FAQ

Documentation

Licensing

Download

Development (Trac)

Projects using pjsip

Mailing List

Open Source Links


About: PJLIB, PJLIB-UTIL, PJSIP, and PJMEDIA are created by: Benny Prijono
<bennylp@pjsip.org>


 

Home --> Documentations --> PJMEDIA Reference

Conference Bridge
[Media Ports Framework]


Detailed Description

This describes the conference bridge implementation in PJMEDIA. The conference bridge provides powerful and very efficient mechanism to route the audio flow and mix the audio signal when required.

Some more information about the media flow when conference bridge is used is described in http://www.pjsip.org/trac/wiki/media-flow .


Data Structures

struct  pjmedia_conf_port_info

Defines

#define PJMEDIA_CONF_BRIDGE_SIGNATURE   PJMEDIA_PORT_SIGNATURE('C', 'O', 'N', 'F')
#define PJMEDIA_CONF_SWITCH_SIGNATURE   PJMEDIA_PORT_SIGNATURE('A', 'S', 'W', 'I')

Typedefs

typedef struct pjmedia_conf pjmedia_conf

Enumerations

enum  pjmedia_conf_option {
  PJMEDIA_CONF_NO_MIC = 1,
  PJMEDIA_CONF_NO_DEVICE = 2,
  PJMEDIA_CONF_SMALL_FILTER = 4,
  PJMEDIA_CONF_USE_LINEAR = 8
}

Functions

pj_status_t pjmedia_conf_create (pj_pool_t *pool, unsigned max_slots, unsigned sampling_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample, unsigned options, pjmedia_conf **p_conf)
pj_status_t pjmedia_conf_destroy (pjmedia_conf *conf)
pjmedia_portpjmedia_conf_get_master_port (pjmedia_conf *conf)
pj_status_t pjmedia_conf_set_port0_name (pjmedia_conf *conf, const pj_str_t *name)
pj_status_t pjmedia_conf_add_port (pjmedia_conf *conf, pj_pool_t *pool, pjmedia_port *strm_port, const pj_str_t *name, unsigned *p_slot)
pj_status_t pjmedia_conf_add_passive_port (pjmedia_conf *conf, pj_pool_t *pool, const pj_str_t *name, unsigned clock_rate, unsigned channel_count, unsigned samples_per_frame, unsigned bits_per_sample, unsigned options, unsigned *p_slot, pjmedia_port **p_port)
pj_status_t pjmedia_conf_configure_port (pjmedia_conf *conf, unsigned slot, pjmedia_port_op tx, pjmedia_port_op rx)
pj_status_t pjmedia_conf_connect_port (pjmedia_conf *conf, unsigned src_slot, unsigned sink_slot, int level)
pj_status_t pjmedia_conf_disconnect_port (pjmedia_conf *conf, unsigned src_slot, unsigned sink_slot)
unsigned pjmedia_conf_get_port_count (pjmedia_conf *conf)
unsigned pjmedia_conf_get_connect_count (pjmedia_conf *conf)
pj_status_t pjmedia_conf_remove_port (pjmedia_conf *conf, unsigned slot)
pj_status_t pjmedia_conf_enum_ports (pjmedia_conf *conf, unsigned ports[], unsigned *count)
pj_status_t pjmedia_conf_get_port_info (pjmedia_conf *conf, unsigned slot, pjmedia_conf_port_info *info)
pj_status_t pjmedia_conf_get_ports_info (pjmedia_conf *conf, unsigned *size, pjmedia_conf_port_info info[])
pj_status_t pjmedia_conf_get_signal_level (pjmedia_conf *conf, unsigned slot, unsigned *tx_level, unsigned *rx_level)
pj_status_t pjmedia_conf_adjust_rx_level (pjmedia_conf *conf, unsigned slot, int adj_level)
pj_status_t pjmedia_conf_adjust_tx_level (pjmedia_conf *conf, unsigned slot, int adj_level)


Define Documentation

#define PJMEDIA_CONF_BRIDGE_SIGNATURE   PJMEDIA_PORT_SIGNATURE('C', 'O', 'N', 'F')

The conference bridge signature in pjmedia_port_info.

#define PJMEDIA_CONF_SWITCH_SIGNATURE   PJMEDIA_PORT_SIGNATURE('A', 'S', 'W', 'I')

The audio switchboard signature in pjmedia_port_info.


Typedef Documentation

typedef struct pjmedia_conf pjmedia_conf

Opaque type for conference bridge.


Enumeration Type Documentation

Conference port options. The values here can be combined in bitmask to be specified when the conference bridge is created.

Enumerator:
PJMEDIA_CONF_NO_MIC  Disable audio streams from the microphone device.
PJMEDIA_CONF_NO_DEVICE  Do not create sound device.
PJMEDIA_CONF_SMALL_FILTER  Use small filter table when resampling
PJMEDIA_CONF_USE_LINEAR  Use linear resampling instead of filter based.


Function Documentation

pj_status_t pjmedia_conf_create ( pj_pool_t pool,
unsigned  max_slots,
unsigned  sampling_rate,
unsigned  channel_count,
unsigned  samples_per_frame,
unsigned  bits_per_sample,
unsigned  options,
pjmedia_conf **  p_conf 
)

Create conference bridge with the specified parameters. The sampling rate, samples per frame, and bits per sample will be used for the internal operation of the bridge (e.g. when mixing audio frames). However, ports with different configuration may be connected to the bridge. In this case, the bridge is able to perform sampling rate conversion, and buffering in case the samples per frame is different.

For this version of PJMEDIA, only 16bits per sample is supported.

For this version of PJMEDIA, the channel count of the ports MUST match the channel count of the bridge.

Under normal operation (i.e. when PJMEDIA_CONF_NO_DEVICE option is NOT specified), the bridge internally create an instance of sound device and connect the sound device to port zero of the bridge.

If PJMEDIA_CONF_NO_DEVICE options is specified, no sound device will be created in the conference bridge. Application MUST acquire the port interface of the bridge by calling pjmedia_conf_get_master_port(), and connect this port interface to a sound device port by calling pjmedia_snd_port_connect(), or to a master port (pjmedia_master_port) if application doesn't want to instantiate any sound devices.

The sound device or master port are crucial for the bridge's operation, because it provides the bridge with necessary clock to process the audio frames periodically. Internally, the bridge runs when get_frame() to port zero is called.

Parameters:
pool Pool to use to allocate the bridge and additional buffers for the sound device.
max_slots Maximum number of slots/ports to be created in the bridge. Note that the bridge internally uses one port for the sound device, so the actual maximum number of ports will be less one than this value.
sampling_rate Set the sampling rate of the bridge. This value is also used to set the sampling rate of the sound device.
channel_count Number of channels in the PCM stream. Normally the value will be 1 for mono, but application may specify a value of 2 for stereo. Note that all ports that will be connected to the bridge MUST have the same number of channels as the bridge.
samples_per_frame Set the number of samples per frame. This value is also used to set the sound device.
bits_per_sample Set the number of bits per sample. This value is also used to set the sound device. Currently only 16bit per sample is supported.
options Bitmask options to be set for the bridge. The options are constructed from pjmedia_conf_option enumeration.
p_conf Pointer to receive the conference bridge instance.
Returns:
PJ_SUCCESS if conference bridge can be created.

pj_status_t pjmedia_conf_destroy ( pjmedia_conf conf  ) 

Destroy conference bridge.

Parameters:
conf The conference bridge.
Returns:
PJ_SUCCESS on success.

pjmedia_port* pjmedia_conf_get_master_port ( pjmedia_conf conf  ) 

Get the master port interface of the conference bridge. The master port corresponds to the port zero of the bridge. This is only usefull when application wants to manage the sound device by itself, instead of allowing the bridge to automatically create a sound device implicitly.

This function will only return a port interface if PJMEDIA_CONF_NO_DEVICE option was specified when the bridge was created.

Application can connect the port returned by this function to a sound device by calling pjmedia_snd_port_connect().

Parameters:
conf The conference bridge.
Returns:
The port interface of port zero of the bridge, only when PJMEDIA_CONF_NO_DEVICE options was specified when the bridge was created.

pj_status_t pjmedia_conf_set_port0_name ( pjmedia_conf conf,
const pj_str_t name 
)

Set master port name.

Parameters:
conf The conference bridge.
name Name to be assigned.
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_add_port ( pjmedia_conf conf,
pj_pool_t pool,
pjmedia_port strm_port,
const pj_str_t name,
unsigned *  p_slot 
)

Add media port to the conference bridge.

By default, the new conference port will have both TX and RX enabled, but it is not connected to any other ports. Application SHOULD call pjmedia_conf_connect_port() to enable audio transmission and receipt to/from this port.

Once the media port is connected to other port(s) in the bridge, the bridge will continuosly call get_frame() and put_frame() to the port, allowing media to flow to/from the port.

Parameters:
conf The conference bridge.
pool Pool to allocate buffers for this port.
strm_port Stream port interface.
name Optional name for the port. If this value is NULL, the name will be taken from the name in the port info.
p_slot Pointer to receive the slot index of the port in the conference bridge.
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_add_passive_port ( pjmedia_conf conf,
pj_pool_t pool,
const pj_str_t name,
unsigned  clock_rate,
unsigned  channel_count,
unsigned  samples_per_frame,
unsigned  bits_per_sample,
unsigned  options,
unsigned *  p_slot,
pjmedia_port **  p_port 
)

Warning: This API has been deprecated since 1.3 and will be removed in the future release, use PJMEDIA_SPLITCOMB instead.

Create and add a passive media port to the conference bridge. Unlike "normal" media port that is added with pjmedia_conf_add_port(), media port created with this function will not have its get_frame() and put_frame() called by the bridge; instead, application MUST continuosly call these functions to the port, to allow media to flow from/to the port.

Upon return of this function, application will be given two objects: the slot number of the port in the bridge, and pointer to the media port where application MUST start calling get_frame() and put_frame() to the port.

Parameters:
conf The conference bridge.
pool Pool to allocate buffers etc for this port.
name Name to be assigned to the port.
clock_rate Clock rate/sampling rate.
channel_count Number of channels.
samples_per_frame Number of samples per frame.
bits_per_sample Number of bits per sample.
options Options (should be zero at the moment).
p_slot Pointer to receive the slot index of the port in the conference bridge.
p_port Pointer to receive the port instance.
Returns:
PJ_SUCCESS on success, or the appropriate error code.

pj_status_t pjmedia_conf_configure_port ( pjmedia_conf conf,
unsigned  slot,
pjmedia_port_op  tx,
pjmedia_port_op  rx 
)

Change TX and RX settings for the port.

Parameters:
conf The conference bridge.
slot Port number/slot in the conference bridge.
tx Settings for the transmission TO this port.
rx Settings for the receipt FROM this port.
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_connect_port ( pjmedia_conf conf,
unsigned  src_slot,
unsigned  sink_slot,
int  level 
)

Enable unidirectional audio from the specified source slot to the specified sink slot.

Parameters:
conf The conference bridge.
src_slot Source slot.
sink_slot Sink slot.
level This argument is reserved for future improvements where it is possible to adjust the level of signal transmitted in a specific connection. For now, this argument MUST be zero.
Returns:
PJ_SUCCES on success.

pj_status_t pjmedia_conf_disconnect_port ( pjmedia_conf conf,
unsigned  src_slot,
unsigned  sink_slot 
)

Disconnect unidirectional audio from the specified source to the specified sink slot.

Parameters:
conf The conference bridge.
src_slot Source slot.
sink_slot Sink slot.
Returns:
PJ_SUCCESS on success.

unsigned pjmedia_conf_get_port_count ( pjmedia_conf conf  ) 

Get number of ports currently registered to the conference bridge.

Parameters:
conf The conference bridge.
Returns:
Number of ports currently registered to the conference bridge.

unsigned pjmedia_conf_get_connect_count ( pjmedia_conf conf  ) 

Get total number of ports connections currently set up in the bridge.

Parameters:
conf The conference bridge.
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_remove_port ( pjmedia_conf conf,
unsigned  slot 
)

Remove the specified port from the conference bridge.

Parameters:
conf The conference bridge.
slot The port index to be removed.
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_enum_ports ( pjmedia_conf conf,
unsigned  ports[],
unsigned *  count 
)

Enumerate occupied ports in the bridge.

Parameters:
conf The conference bridge.
ports Array of port numbers to be filled in.
count On input, specifies the maximum number of ports in the array. On return, it will be filled with the actual number of ports.
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_get_port_info ( pjmedia_conf conf,
unsigned  slot,
pjmedia_conf_port_info info 
)

Get port info.

Parameters:
conf The conference bridge.
slot Port index.
info Pointer to receive the info.
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_get_ports_info ( pjmedia_conf conf,
unsigned *  size,
pjmedia_conf_port_info  info[] 
)

Get occupied ports info.

Parameters:
conf The conference bridge.
size On input, contains maximum number of infos to be retrieved. On output, contains the actual number of infos that have been copied.
info Array of info.
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_get_signal_level ( pjmedia_conf conf,
unsigned  slot,
unsigned *  tx_level,
unsigned *  rx_level 
)

Get last signal level transmitted to or received from the specified port. This will retrieve the "real-time" signal level of the audio as they are transmitted or received by the specified port. Application may call this function periodically to display the signal level to a VU meter.

The signal level is an integer value in zero to 255, with zero indicates no signal, and 255 indicates the loudest signal level.

Parameters:
conf The conference bridge.
slot Slot number.
tx_level Optional argument to receive the level of signal transmitted to the specified port (i.e. the direction is from the bridge to the port).
rx_level Optional argument to receive the level of signal received from the port (i.e. the direction is from the port to the bridge).
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_adjust_rx_level ( pjmedia_conf conf,
unsigned  slot,
int  adj_level 
)

Adjust the level of signal received from the specified port. Application may adjust the level to make signal received from the port either louder or more quiet. The level adjustment is calculated with this formula: output = input * (adj_level+128) / 128. Using this, zero indicates no adjustment, the value -128 will mute the signal, and the value of +128 will make the signal 100% louder, +256 will make it 200% louder, etc.

The level adjustment value will stay with the port until the port is removed from the bridge or new adjustment value is set. The current level adjustment value is reported in the media port info when the pjmedia_conf_get_port_info() function is called.

Parameters:
conf The conference bridge.
slot Slot number of the port.
adj_level Adjustment level, which must be greater than or equal to -128. A value of zero means there is no level adjustment to be made, the value -128 will mute the signal, and the value of +128 will make the signal 100% louder, +256 will make it 200% louder, etc. See the function description for the formula.
Returns:
PJ_SUCCESS on success.

pj_status_t pjmedia_conf_adjust_tx_level ( pjmedia_conf conf,
unsigned  slot,
int  adj_level 
)

Adjust the level of signal to be transmitted to the specified port. Application may adjust the level to make signal transmitted to the port either louder or more quiet. The level adjustment is calculated with this formula: output = input * (adj_level+128) / 128. Using this, zero indicates no adjustment, the value -128 will mute the signal, and the value of +128 will make the signal 100% louder, +256 will make it 200% louder, etc.

The level adjustment value will stay with the port until the port is removed from the bridge or new adjustment value is set. The current level adjustment value is reported in the media port info when the pjmedia_conf_get_port_info() function is called.

Parameters:
conf The conference bridge.
slot Slot number of the port.
adj_level Adjustment level, which must be greater than or equal to -128. A value of zero means there is no level adjustment to be made, the value -128 will mute the signal, and the value of +128 will make the signal 100% louder, +256 will make it 200% louder, etc. See the function description for the formula.
Returns:
PJ_SUCCESS on success.

 


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