<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8772">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_sdp_rtp: Save track label to stream opaque data<br><br>Save the track label to the stream so it can be used as a correlation<br>id on events to a client.<br><br>Also added a unit test for stream opaque data.<br><br>Change-Id: I48ab35c5e72f5ee53fa06cf9a5af5a88a1e3b1c9<br>---<br>M include/asterisk/stream.h<br>M res/res_pjsip_sdp_rtp.c<br>M tests/test_stream.c<br>3 files changed, 65 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/72/8772/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/include/asterisk/stream.h b/include/asterisk/stream.h<br>index bbde73d..13f8d71 100644<br>--- a/include/asterisk/stream.h<br>+++ b/include/asterisk/stream.h<br>@@ -86,6 +86,10 @@<br>       */<br>   AST_STREAM_DATA_RTP_CODECS = 0,<br>       /*!<br>+   * \brief Data slot for the track label part of the msid<br>+      */<br>+  AST_STREAM_DATA_TRACK_LABEL,<br>+ /*!<br>    * \brief Controls the size of the data pointer array<br>          */<br>   AST_STREAM_DATA_SLOT_MAX<br>diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c<br>index 11ab726..bc6218d 100644<br>--- a/res/res_pjsip_sdp_rtp.c<br>+++ b/res/res_pjsip_sdp_rtp.c<br>@@ -1050,6 +1050,7 @@<br>  pj_str_t stmp;<br>        pjmedia_sdp_attr *attr;<br>       char msid[(AST_UUID_STR_LEN * 2) + 2];<br>+       char *track_label;<br> <br>         if (!session->endpoint->media.webrtc) {<br>                 return;<br>@@ -1075,6 +1076,21 @@<br>       snprintf(msid, sizeof(msid), "%s %s", session_media->mslabel, session_media->label);<br>  attr = pjmedia_sdp_attr_create(pool, "msid", pj_cstr(&stmp, msid));<br>     pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);<br>+<br>+    /*<br>+    * Get the stream's current track label, if any.<br>+  * If it's not there or it doesn't match the current label,<br>+   * reset it.<br>+  */<br>+  track_label = ast_stream_get_data(stream, AST_STREAM_DATA_TRACK_LABEL);<br>+      if (!track_label || strcmp(track_label, session_media->label) != 0) {<br>+             ast_free(track_label);<br>+               track_label = ast_strdup(session_media->label);<br>+           if (!track_label) {<br>+                  return;<br>+              }<br>+            ast_stream_set_data(stream, AST_STREAM_DATA_TRACK_LABEL, track_label, ast_free_ptr);<br>+ }<br> }<br> <br> static void add_rtcp_fb_to_stream(struct ast_sip_session *session,<br>diff --git a/tests/test_stream.c b/tests/test_stream.c<br>index 8c88704..9c2b15d 100644<br>--- a/tests/test_stream.c<br>+++ b/tests/test_stream.c<br>@@ -38,6 +38,7 @@<br> #include "asterisk/format_cap.h"<br> #include "asterisk/format_cache.h"<br> #include "asterisk/channel.h"<br>+#include "asterisk/uuid.h"<br> <br> AST_TEST_DEFINE(stream_create)<br> {<br>@@ -218,6 +219,48 @@<br> <br>   if (ast_stream_get_state(stream) != AST_STREAM_STATE_SENDRECV) {<br>              ast_test_status_update(test, "Changed stream does not have expected sendrecv state\n");<br>+            return AST_TEST_FAIL;<br>+        }<br>+<br>+ return AST_TEST_PASS;<br>+}<br>+<br>+AST_TEST_DEFINE(stream_set_data)<br>+{<br>+  RAII_VAR(struct ast_stream *, stream, NULL, ast_stream_free);<br>+        char track_label[AST_UUID_STR_LEN + 1];<br>+      const char *stream_track_label;<br>+<br>+   switch (cmd) {<br>+       case TEST_INIT:<br>+              info->name = "stream_set_data";<br>+         info->category = "/main/stream/";<br>+               info->summary = "stream data setting unit test";<br>+                info->description =<br>+                       "Test that changing the opaque data of a stream works";<br>+            return AST_TEST_NOT_RUN;<br>+     case TEST_EXECUTE:<br>+           break;<br>+       }<br>+<br>+ stream = ast_stream_alloc("test", AST_MEDIA_TYPE_AUDIO);<br>+   if (!stream) {<br>+               ast_test_status_update(test, "Failed to create media stream given proper arguments\n");<br>+            return AST_TEST_FAIL;<br>+        }<br>+<br>+ ast_uuid_generate_str(track_label, sizeof(track_label));<br>+<br>+  ast_stream_set_data(stream, AST_STREAM_DATA_TRACK_LABEL, track_label, ast_free_ptr);<br>+<br>+      stream_track_label = ast_stream_get_data(stream, AST_STREAM_DATA_TRACK_LABEL);<br>+       if (!stream_track_label) {<br>+           ast_test_status_update(test, "Changed stream does not have a track label\n");<br>+              return AST_TEST_FAIL;<br>+        }<br>+<br>+ if (strcmp(stream_track_label, track_label) != 0) {<br>+          ast_test_status_update(test, "Changed stream did not return same track label\n");<br>           return AST_TEST_FAIL;<br>         }<br> <br>@@ -2139,6 +2182,7 @@<br>   AST_TEST_UNREGISTER(stream_set_type);<br>         AST_TEST_UNREGISTER(stream_set_formats);<br>      AST_TEST_UNREGISTER(stream_set_state);<br>+       AST_TEST_UNREGISTER(stream_set_data);<br>         AST_TEST_UNREGISTER(stream_topology_create);<br>  AST_TEST_UNREGISTER(stream_topology_clone);<br>   AST_TEST_UNREGISTER(stream_topology_clone);<br>@@ -2169,6 +2213,7 @@<br>    AST_TEST_REGISTER(stream_set_type);<br>   AST_TEST_REGISTER(stream_set_formats);<br>        AST_TEST_REGISTER(stream_set_state);<br>+ AST_TEST_REGISTER(stream_set_data);<br>   AST_TEST_REGISTER(stream_topology_create);<br>    AST_TEST_REGISTER(stream_topology_clone);<br>     AST_TEST_REGISTER(stream_topology_append_stream);<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8772">change 8772</a>. To unsubscribe, 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/8772"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I48ab35c5e72f5ee53fa06cf9a5af5a88a1e3b1c9 </div>
<div style="display:none"> Gerrit-Change-Number: 8772 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>