Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion pjmedia/include/pjmedia/conference.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,19 @@ PJ_DECL(pjmedia_port*) pjmedia_conf_get_master_port(pjmedia_conf *conf);
PJ_DECL(pj_status_t) pjmedia_conf_set_port0_name(pjmedia_conf *conf,
const pj_str_t *name);

/**
* compare signature of the port with the signature of the port in the conference bridge
*
* if the conf_slot is not found, return PJ_FALSE
*
* @param conf The conference bridge.
* @param conf_slot conference bridge slot
* @param signature signature of the port
*
* @return PJ_TRUE if the signature of the port is the same as the signature of the port in the conference bridge
*/

PJ_DECL(pj_bool_t) pjmedia_conf_compare_port_signature(pjmedia_conf* conf, unsigned conf_slot, pj_uint32_t signature);
/**
* Add media port to the conference bridge.
*
Expand Down Expand Up @@ -433,7 +445,18 @@ PJ_DECL(pj_status_t) pjmedia_conf_remove_port( pjmedia_conf *conf,
PJ_DECL(pj_status_t) pjmedia_conf_enum_ports( pjmedia_conf *conf,
unsigned ports[],
unsigned *count );

/**
* Get port info.
*
* @param conf The conference bridge.
* @param slot Port index.
* @param info Pointer to receive the info.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_conf_get_media_port_info(pjmedia_conf* conf,
unsigned slot,
pjmedia_port_info* info);

/**
* Get port info.
Expand Down
9 changes: 8 additions & 1 deletion pjmedia/include/pjmedia/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,14 @@ typedef enum pjmedia_port_op
/**
* Enable TX and RX to/from this port.
*/
PJMEDIA_PORT_ENABLE
PJMEDIA_PORT_ENABLE,

/**
* Enable TX and RX to/from this port and invoke get_frame() and
* put_frame() even if there are no connections/listeners or non-
* silence audio frames respectively.
*/
PJMEDIA_PORT_ENABLE_ALWAYS

} pjmedia_port_op;

Expand Down
3 changes: 2 additions & 1 deletion pjmedia/src/pjmedia/conf_switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,8 @@ static pj_status_t get_frame(pjmedia_port *this_port,

while (pj_cmp_timestamp(&cport->ts_clock, &cport->ts_tx) > 0)
{
if (cport->tx_setting == PJMEDIA_PORT_ENABLE) {
if ((cport->tx_setting == PJMEDIA_PORT_ENABLE) ||
(cport->tx_setting == PJMEDIA_PORT_ENABLE_ALWAYS)) {
pjmedia_frame tmp_f;

tmp_f.timestamp = cport->ts_tx;
Expand Down
74 changes: 67 additions & 7 deletions pjmedia/src/pjmedia/conference.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,16 +1293,18 @@ PJ_DEF(pj_status_t) pjmedia_conf_enum_ports( pjmedia_conf *conf,
{
unsigned i, count=0;

PJ_ASSERT_RETURN(conf && p_count && ports, PJ_EINVAL);
PJ_ASSERT_RETURN(conf && p_count, PJ_EINVAL);

/* Lock mutex */
pj_mutex_lock(conf->mutex);

for (i=0; i<conf->max_ports && count<*p_count; ++i) {
if (!conf->ports[i])
continue;

if (ports)
ports[count++] = i;
else
count++;
}

/* Unlock mutex */
Expand All @@ -1311,7 +1313,59 @@ PJ_DEF(pj_status_t) pjmedia_conf_enum_ports( pjmedia_conf *conf,
*p_count = count;
return PJ_SUCCESS;
}
PJ_DECL(pj_bool_t) pjmedia_conf_compare_port_signature(pjmedia_conf* conf,unsigned conf_slot, pj_uint32_t signature)
{
/* Check arguments */
PJ_ASSERT_RETURN(conf, PJ_FALSE);
if (conf_slot<0 || conf_slot >= conf->max_ports)
{
PJ_LOG(4, (THIS_FILE, " pjmedia_conf_compare_port_signature : [conf_slot : %d], [conf->max_ports:%d]",conf_slot, conf->max_ports));
return PJ_FALSE;
}
pjmedia_port_info port_info;
if (pjmedia_conf_get_media_port_info(conf, conf_slot, &port_info) != PJ_SUCCESS)
{
return PJ_FALSE;
}
return port_info.signature == signature;
}
PJ_DEF(pj_status_t) pjmedia_conf_get_media_port_info(pjmedia_conf* conf,unsigned slot, pjmedia_port_info* info)
{
struct conf_port* conf_port;

/* Check arguments */
if (slot < 0 || slot >= conf->max_ports)
{
PJ_LOG(2, (THIS_FILE, " pjmedia_conf_get_media_port_info : [slot : %d], [conf->max_ports:%d]", slot, conf->max_ports));
return PJ_EINVAL;
}
PJ_ASSERT_RETURN(conf && slot >=0 && slot < conf->max_ports, PJ_EINVAL);

/* Lock mutex */
pj_mutex_lock(conf->mutex);

/* Port must be valid. */
conf_port = conf->ports[slot];
if (conf_port == NULL) {
pj_mutex_unlock(conf->mutex);
return PJ_EINVAL;
}

if (!conf_port->port) {
pj_mutex_unlock(conf->mutex);
return PJ_EINVAL;
}
pjmedia_port_info * port_info = &conf_port->port->info;
pjmedia_format_copy(&info->fmt, &port_info->fmt);
info->name= port_info->name;
info->dir= port_info->dir;
info->signature= port_info->signature;

/* Unlock mutex */
pj_mutex_unlock(conf->mutex);

return PJ_SUCCESS;
}
/*
* Get port info
*/
Expand Down Expand Up @@ -1718,7 +1772,8 @@ static pj_status_t write_port(pjmedia_conf *conf, struct conf_port *cport,
*frm_type = PJMEDIA_FRAME_TYPE_AUDIO;

/* Skip port if it is disabled */
if (cport->tx_setting != PJMEDIA_PORT_ENABLE) {
if (cport->tx_setting == PJMEDIA_PORT_DISABLE &&
(cport->tx_setting != PJMEDIA_PORT_ENABLE_ALWAYS)) {
cport->tx_level = 0;
*frm_type = PJMEDIA_FRAME_TYPE_NONE;
return PJ_SUCCESS;
Expand Down Expand Up @@ -2006,7 +2061,8 @@ static pj_status_t get_frame(pjmedia_port *this_port,
}

/* Also skip if this port doesn't have listeners. */
if (conf_port->listener_cnt == 0) {
if ((conf_port->listener_cnt == 0) &&
(conf_port->rx_setting != PJMEDIA_PORT_ENABLE_ALWAYS)) {
conf_port->rx_level = 0;
continue;
}
Expand Down Expand Up @@ -2119,7 +2175,8 @@ static pj_status_t get_frame(pjmedia_port *this_port,
listener = conf->ports[conf_port->listener_slots[cj]];

/* Skip if this listener doesn't want to receive audio */
if (listener->tx_setting != PJMEDIA_PORT_ENABLE)
if ((listener->tx_setting != PJMEDIA_PORT_ENABLE) &&
(listener->tx_setting != PJMEDIA_PORT_ENABLE_ALWAYS))
continue;

mix_buf = listener->mix_buf;
Expand Down Expand Up @@ -2301,12 +2358,15 @@ static pj_status_t put_frame(pjmedia_port *this_port,
PJ_ASSERT_RETURN( port->delay_buf, PJ_EBUG );

/* Skip if this port is muted/disabled. */
if (port->rx_setting != PJMEDIA_PORT_ENABLE) {
if ((port->rx_setting != PJMEDIA_PORT_ENABLE) &&
(port->rx_setting != PJMEDIA_PORT_ENABLE_ALWAYS)) {
return PJ_SUCCESS;
}

/* Skip if no port is listening to the microphone */
if (port->listener_cnt == 0) {
if ((port->listener_cnt == 0) &&
(port->rx_setting != PJMEDIA_PORT_ENABLE_ALWAYS))
{
return PJ_SUCCESS;
}

Expand Down
Loading