<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10485">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bridge_softmix: Add SDP "label" attribute to streams<br><br>Adding the "label" attribute used for participant info correlation<br>was previously done in app_confbridge but it wasn't working<br>correctly because it didn't have knowledge about which video<br>streams belonged to which channel. Only bridge_softmix has that<br>data so now it's set when the bridge topology is changed.<br><br>ASTERISK-28107<br><br>Change-Id: Ieddeca5799d710cad083af3fcc3e677fa2a2a499<br>---<br>M apps/app_confbridge.c<br>M apps/confbridge/confbridge_manager.c<br>M bridges/bridge_softmix.c<br>M include/asterisk/bridge.h<br>M main/bridge.c<br>5 files changed, 55 insertions(+), 63 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c</span><br><span>index edb7e03..5936400 100644</span><br><span>--- a/apps/app_confbridge.c</span><br><span>+++ b/apps/app_confbridge.c</span><br><span>@@ -1568,6 +1568,10 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_test_flag(&conference->b_profile, BRIDGE_OPT_ENABLE_EVENTS)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_bridge_set_send_sdp_label(conference->bridge, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Link it into the conference bridges container */</span><br><span> if (!ao2_link(conference_bridges, conference)) {</span><br><span> ao2_ref(conference, -1);</span><br><span>diff --git a/apps/confbridge/confbridge_manager.c b/apps/confbridge/confbridge_manager.c</span><br><span>index a7f2fce..e88bbc2 100644</span><br><span>--- a/apps/confbridge/confbridge_manager.c</span><br><span>+++ b/apps/confbridge/confbridge_manager.c</span><br><span>@@ -355,56 +355,6 @@</span><br><span> return pack_bridge_and_channels(json_bridge, json_channel, msg);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-enum label_direction {</span><br><span style="color: hsl(0, 100%, 40%);">- LABEL_DIRECTION_SRC,</span><br><span style="color: hsl(0, 100%, 40%);">- LABEL_DIRECTION_DEST,</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static struct ast_stream *get_stream(struct ast_stream_topology *topology,</span><br><span style="color: hsl(0, 100%, 40%);">- enum ast_media_type m_type)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- int count;</span><br><span style="color: hsl(0, 100%, 40%);">- int i;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- count = ast_stream_topology_get_count(topology);</span><br><span style="color: hsl(0, 100%, 40%);">- if (count < 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- for (i = 0; i < count; i++) {</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_stream *s;</span><br><span style="color: hsl(0, 100%, 40%);">- enum ast_stream_state s_state;</span><br><span style="color: hsl(0, 100%, 40%);">- enum ast_media_type s_type;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- s = ast_stream_topology_get_stream(topology, i);</span><br><span style="color: hsl(0, 100%, 40%);">- s_state = ast_stream_get_state(s);</span><br><span style="color: hsl(0, 100%, 40%);">- s_type = ast_stream_get_type(s);</span><br><span style="color: hsl(0, 100%, 40%);">- if (s_type == m_type</span><br><span style="color: hsl(0, 100%, 40%);">- && (s_state == AST_STREAM_STATE_SENDRECV || s_state == AST_STREAM_STATE_RECVONLY)) {</span><br><span style="color: hsl(0, 100%, 40%);">- return s;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static void set_media_labels(struct confbridge_conference *conference,</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_channel *src_chan, struct ast_channel *dest_chan, enum label_direction dir)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_stream_topology *topology;</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_stream *stream;</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_channel *chan = dir == LABEL_DIRECTION_SRC ? dest_chan : src_chan;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!chan) {</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- topology = ast_channel_get_stream_topology(chan);</span><br><span style="color: hsl(0, 100%, 40%);">- stream = get_stream(topology, AST_MEDIA_TYPE_VIDEO);</span><br><span style="color: hsl(0, 100%, 40%);">- if (stream) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_stream_set_metadata(stream, "SDP:LABEL", ast_channel_uniqueid(chan));</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> static void send_message(const char *msg_name, char *conf_name, struct ast_json *json_object,</span><br><span> struct ast_channel *chan)</span><br><span> {</span><br><span>@@ -508,7 +458,6 @@</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- set_media_labels(conference, chan, user->chan, LABEL_DIRECTION_SRC);</span><br><span> target_json_channel = channel_to_json(target_snapshot, extras, NULL);</span><br><span> ao2_ref(target_snapshot, -1);</span><br><span> </span><br><span>@@ -538,8 +487,6 @@</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- set_media_labels(conference, chan, user->chan, LABEL_DIRECTION_DEST);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> json_object = pack_snapshots(obj->bridge, obj->channel, extras, NULL, msg);</span><br><span> </span><br><span> if (!json_object) {</span><br><span>diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c</span><br><span>index b11fccc..cf61340 100644</span><br><span>--- a/bridges/bridge_softmix.c</span><br><span>+++ b/bridges/bridge_softmix.c</span><br><span>@@ -498,7 +498,7 @@</span><br><span> }</span><br><span> </span><br><span> static int append_source_streams(struct ast_stream_topology *dest,</span><br><span style="color: hsl(0, 100%, 40%);">- const char *channel_name,</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *channel_name, const char *sdp_label,</span><br><span> const struct ast_stream_topology *source)</span><br><span> {</span><br><span> int i;</span><br><span>@@ -523,6 +523,12 @@</span><br><span> if (!stream_clone) {</span><br><span> return -1;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Sends an "a:label" attribute in the SDP for participant event correlation */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(sdp_label)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_stream_set_metadata(stream_clone, "SDP:LABEL", sdp_label);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if (ast_stream_topology_append_stream(dest, stream_clone) < 0) {</span><br><span> ast_stream_free(stream_clone);</span><br><span> return -1;</span><br><span>@@ -585,9 +591,11 @@</span><br><span> * \param joiner The channel that is joining the softmix bridge</span><br><span> * \param participants The current participants in the softmix bridge</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-static void sfu_topologies_on_join(struct ast_bridge_channel *joiner, struct ast_bridge_channels_list *participants)</span><br><span style="color: hsl(120, 100%, 40%);">+static void sfu_topologies_on_join(struct ast_bridge *bridge,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_bridge_channel *joiner)</span><br><span> {</span><br><span> struct ast_stream_topology *joiner_video = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_bridge_channels_list *participants = &bridge->channels;</span><br><span> struct ast_bridge_channel *participant;</span><br><span> int res;</span><br><span> struct softmix_channel *sc;</span><br><span>@@ -600,7 +608,9 @@</span><br><span> sc = joiner->tech_pvt;</span><br><span> </span><br><span> ast_channel_lock(joiner->chan);</span><br><span style="color: hsl(0, 100%, 40%);">- res = append_source_streams(joiner_video, ast_channel_name(joiner->chan), ast_channel_get_stream_topology(joiner->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ res = append_source_streams(joiner_video, ast_channel_name(joiner->chan),</span><br><span style="color: hsl(120, 100%, 40%);">+ bridge->softmix.send_sdp_label ? ast_channel_uniqueid(joiner->chan) : NULL,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_get_stream_topology(joiner->chan));</span><br><span> sc->topology = ast_stream_topology_clone(ast_channel_get_stream_topology(joiner->chan));</span><br><span> ast_channel_unlock(joiner->chan);</span><br><span> </span><br><span>@@ -614,7 +624,8 @@</span><br><span> }</span><br><span> ast_channel_lock(participant->chan);</span><br><span> res = append_source_streams(sc->topology, ast_channel_name(participant->chan),</span><br><span style="color: hsl(0, 100%, 40%);">- ast_channel_get_stream_topology(participant->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ bridge->softmix.send_sdp_label ? ast_channel_uniqueid(participant->chan) : NULL,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_get_stream_topology(participant->chan));</span><br><span> ast_channel_unlock(participant->chan);</span><br><span> if (res) {</span><br><span> goto cleanup;</span><br><span>@@ -704,7 +715,7 @@</span><br><span> bridge_channel, 0, set_binaural, pos_id, is_announcement);</span><br><span> </span><br><span> if (bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_SFU) {</span><br><span style="color: hsl(0, 100%, 40%);">- sfu_topologies_on_join(bridge_channel, &bridge->channels);</span><br><span style="color: hsl(120, 100%, 40%);">+ sfu_topologies_on_join(bridge, bridge_channel);</span><br><span> }</span><br><span> </span><br><span> softmix_poke_thread(softmix_data);</span><br><span>@@ -1063,9 +1074,11 @@</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static void sfu_topologies_on_source_change(struct ast_bridge_channel *source, struct ast_bridge_channels_list *participants)</span><br><span style="color: hsl(120, 100%, 40%);">+static void sfu_topologies_on_source_change(struct ast_bridge *bridge,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_bridge_channel *source)</span><br><span> {</span><br><span> struct ast_stream_topology *source_video = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_bridge_channels_list *participants = &bridge->channels;</span><br><span> struct ast_bridge_channel *participant;</span><br><span> int res;</span><br><span> </span><br><span>@@ -1075,7 +1088,9 @@</span><br><span> }</span><br><span> </span><br><span> ast_channel_lock(source->chan);</span><br><span style="color: hsl(0, 100%, 40%);">- res = append_source_streams(source_video, ast_channel_name(source->chan), ast_channel_get_stream_topology(source->chan));</span><br><span style="color: hsl(120, 100%, 40%);">+ res = append_source_streams(source_video, ast_channel_name(source->chan),</span><br><span style="color: hsl(120, 100%, 40%);">+ bridge->softmix.send_sdp_label ? ast_channel_uniqueid(source->chan) : NULL,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_channel_get_stream_topology(source->chan));</span><br><span> ast_channel_unlock(source->chan);</span><br><span> if (res) {</span><br><span> goto cleanup;</span><br><span>@@ -1198,7 +1213,7 @@</span><br><span> break;</span><br><span> case AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED:</span><br><span> if (bridge->softmix.video_mode.mode == AST_BRIDGE_VIDEO_MODE_SFU) {</span><br><span style="color: hsl(0, 100%, 40%);">- sfu_topologies_on_source_change(bridge_channel, &bridge->channels);</span><br><span style="color: hsl(120, 100%, 40%);">+ sfu_topologies_on_source_change(bridge, bridge_channel);</span><br><span> }</span><br><span> break;</span><br><span> default:</span><br><span>@@ -2383,7 +2398,7 @@</span><br><span> goto end;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (append_source_streams(topology_alice, "PJSIP/Bob-00000001", topology_bob)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (append_source_streams(topology_alice, "PJSIP/Bob-00000001", NULL, topology_bob)) {</span><br><span> ast_test_status_update(test, "Failed to append Bob's streams to Alice\n");</span><br><span> goto end;</span><br><span> }</span><br><span>@@ -2402,7 +2417,7 @@</span><br><span> goto end;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (append_source_streams(topology_bob, "PJSIP/Alice-00000000", topology_alice)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (append_source_streams(topology_bob, "PJSIP/Alice-00000000", NULL, topology_alice)) {</span><br><span> ast_test_status_update(test, "Failed to append Alice's streams to Bob\n");</span><br><span> goto end;</span><br><span> }</span><br><span>diff --git a/include/asterisk/bridge.h b/include/asterisk/bridge.h</span><br><span>index 3584085..f4b1df8 100644</span><br><span>--- a/include/asterisk/bridge.h</span><br><span>+++ b/include/asterisk/bridge.h</span><br><span>@@ -290,6 +290,11 @@</span><br><span> unsigned int internal_mixing_interval;</span><br><span> /*! TRUE if binaural convolve is activated in configuration. */</span><br><span> unsigned int binaural_active;</span><br><span style="color: hsl(120, 100%, 40%);">+ /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * Add a "label" attribute to each stream in the SDP containing</span><br><span style="color: hsl(120, 100%, 40%);">+ * the channel uniqueid. Used for participant info correlation.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ unsigned int send_sdp_label;</span><br><span> };</span><br><span> </span><br><span> AST_LIST_HEAD_NOLOCK(ast_bridge_channels_list, ast_bridge_channel);</span><br><span>@@ -986,6 +991,20 @@</span><br><span> const char *ast_bridge_video_mode_to_string(enum ast_bridge_video_mode_type video_mode);</span><br><span> </span><br><span> /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Controls whether to send a "label" attribute in each stream in an SDP</span><br><span style="color: hsl(120, 100%, 40%);">+ * \since 16.1.0</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param bridge The bridge</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param send_sdp_label Whether to send the labels or not</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \note The label will contain the uniqueid of the channel related to the stream.</span><br><span style="color: hsl(120, 100%, 40%);">+ * This is used to allow the recipient to correlate the stream to the participant</span><br><span style="color: hsl(120, 100%, 40%);">+ * information events sent by app_confbridge.</span><br><span style="color: hsl(120, 100%, 40%);">+ * The bridge will be locked in this function.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_bridge_set_send_sdp_label(struct ast_bridge *bridge, unsigned int send_sdp_label);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span> * \brief Acquire the channel's bridge for transfer purposes.</span><br><span> * \since 13.21.0</span><br><span> *</span><br><span>diff --git a/main/bridge.c b/main/bridge.c</span><br><span>index db49180..d6e7a51 100644</span><br><span>--- a/main/bridge.c</span><br><span>+++ b/main/bridge.c</span><br><span>@@ -4018,6 +4018,13 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+void ast_bridge_set_send_sdp_label(struct ast_bridge *bridge, unsigned int send_sdp_label)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_bridge_lock(bridge);</span><br><span style="color: hsl(120, 100%, 40%);">+ bridge->softmix.send_sdp_label = send_sdp_label;</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_bridge_unlock(bridge);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int channel_hash(const void *obj, int flags)</span><br><span> {</span><br><span> const struct ast_channel *chan = obj;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10485">change 10485</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10485"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ieddeca5799d710cad083af3fcc3e677fa2a2a499 </div>
<div style="display:none"> Gerrit-Change-Number: 10485 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>