bridge_softmix: Add SDP "label" attribute to streams

Adding the "label" attribute used for participant info correlation
was previously done in app_confbridge but it wasn't working
correctly because it didn't have knowledge about which video
streams belonged to which channel.  Only bridge_softmix has that
data so now it's set when the bridge topology is changed.

ASTERISK-28107

Change-Id: Ieddeca5799d710cad083af3fcc3e677fa2a2a499
This commit is contained in:
George Joseph
2018-10-16 06:02:19 -06:00
parent 649ee402e5
commit fec66b8f01
5 changed files with 55 additions and 63 deletions

View File

@@ -498,7 +498,7 @@ static int is_video_dest(const struct ast_stream *stream, const char *source_cha
}
static int append_source_streams(struct ast_stream_topology *dest,
const char *channel_name,
const char *channel_name, const char *sdp_label,
const struct ast_stream_topology *source)
{
int i;
@@ -523,6 +523,12 @@ static int append_source_streams(struct ast_stream_topology *dest,
if (!stream_clone) {
return -1;
}
/* Sends an "a:label" attribute in the SDP for participant event correlation */
if (!ast_strlen_zero(sdp_label)) {
ast_stream_set_metadata(stream_clone, "SDP:LABEL", sdp_label);
}
if (ast_stream_topology_append_stream(dest, stream_clone) < 0) {
ast_stream_free(stream_clone);
return -1;
@@ -585,9 +591,11 @@ static int append_all_streams(struct ast_stream_topology *dest,
* \param joiner The channel that is joining the softmix bridge
* \param participants The current participants in the softmix bridge
*/
static void sfu_topologies_on_join(struct ast_bridge_channel *joiner, struct ast_bridge_channels_list *participants)
static void sfu_topologies_on_join(struct ast_bridge *bridge,
struct ast_bridge_channel *joiner)
{
struct ast_stream_topology *joiner_video = NULL;
struct ast_bridge_channels_list *participants = &bridge->channels;
struct ast_bridge_channel *participant;
int res;
struct softmix_channel *sc;
@@ -600,7 +608,9 @@ static void sfu_topologies_on_join(struct ast_bridge_channel *joiner, struct ast
sc = joiner->tech_pvt;
ast_channel_lock(joiner->chan);
res = append_source_streams(joiner_video, ast_channel_name(joiner->chan), ast_channel_get_stream_topology(joiner->chan));
res = append_source_streams(joiner_video, ast_channel_name(joiner->chan),
bridge->softmix.send_sdp_label ? ast_channel_uniqueid(joiner->chan) : NULL,
ast_channel_get_stream_topology(joiner->chan));
sc->topology = ast_stream_topology_clone(ast_channel_get_stream_topology(joiner->chan));
ast_channel_unlock(joiner->chan);
@@ -614,7 +624,8 @@ static void sfu_topologies_on_join(struct ast_bridge_channel *joiner, struct ast
}
ast_channel_lock(participant->chan);
res = append_source_streams(sc->topology, ast_channel_name(participant->chan),
ast_channel_get_stream_topology(participant->chan));
bridge->softmix.send_sdp_label ? ast_channel_uniqueid(participant->chan) : NULL,
ast_channel_get_stream_topology(participant->chan));
ast_channel_unlock(participant->chan);
if (res) {
goto cleanup;
@@ -704,7 +715,7 @@ static int softmix_bridge_join(struct ast_bridge *bridge, struct ast_bridge_chan
bridge_channel, 0, set_binaural, pos_id, is_announcement);
if (bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_SFU) {
sfu_topologies_on_join(bridge_channel, &bridge->channels);
sfu_topologies_on_join(bridge, bridge_channel);
}
softmix_poke_thread(softmix_data);
@@ -1063,9 +1074,11 @@ static int remove_all_original_streams(struct ast_stream_topology *dest,
return 0;
}
static void sfu_topologies_on_source_change(struct ast_bridge_channel *source, struct ast_bridge_channels_list *participants)
static void sfu_topologies_on_source_change(struct ast_bridge *bridge,
struct ast_bridge_channel *source)
{
struct ast_stream_topology *source_video = NULL;
struct ast_bridge_channels_list *participants = &bridge->channels;
struct ast_bridge_channel *participant;
int res;
@@ -1075,7 +1088,9 @@ static void sfu_topologies_on_source_change(struct ast_bridge_channel *source, s
}
ast_channel_lock(source->chan);
res = append_source_streams(source_video, ast_channel_name(source->chan), ast_channel_get_stream_topology(source->chan));
res = append_source_streams(source_video, ast_channel_name(source->chan),
bridge->softmix.send_sdp_label ? ast_channel_uniqueid(source->chan) : NULL,
ast_channel_get_stream_topology(source->chan));
ast_channel_unlock(source->chan);
if (res) {
goto cleanup;
@@ -1198,7 +1213,7 @@ static int softmix_bridge_write_control(struct ast_bridge *bridge, struct ast_br
break;
case AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED:
if (bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_SFU) {
sfu_topologies_on_source_change(bridge_channel, &bridge->channels);
sfu_topologies_on_source_change(bridge, bridge_channel);
}
break;
default:
@@ -2383,7 +2398,7 @@ AST_TEST_DEFINE(sfu_append_source_streams)
goto end;
}
if (append_source_streams(topology_alice, "PJSIP/Bob-00000001", topology_bob)) {
if (append_source_streams(topology_alice, "PJSIP/Bob-00000001", NULL, topology_bob)) {
ast_test_status_update(test, "Failed to append Bob's streams to Alice\n");
goto end;
}
@@ -2402,7 +2417,7 @@ AST_TEST_DEFINE(sfu_append_source_streams)
goto end;
}
if (append_source_streams(topology_bob, "PJSIP/Alice-00000000", topology_alice)) {
if (append_source_streams(topology_bob, "PJSIP/Alice-00000000", NULL, topology_alice)) {
ast_test_status_update(test, "Failed to append Alice's streams to Bob\n");
goto end;
}