<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14784">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Benjamin Keith Ford: 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;">stream.c: Added 2 more debugging utils and added pos to stream string<br><br> * Added ast_stream_to_stra and ast_stream_topology_to_stra() macros<br> which are shortcuts for<br> ast_str_tmp(256, ast_stream_to_str(stream, &STR_TMP))<br><br> * Added the stream position to the string representation of the<br> stream.<br><br> * Fixed some formatting in ast_stream_to_str().<br><br>Change-Id: Idaf4cb0affa46d4dce58a73a111f35435331cc4b<br>---<br>M include/asterisk/stream.h<br>M main/stream.c<br>2 files changed, 40 insertions(+), 13 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/stream.h b/include/asterisk/stream.h</span><br><span>index 3578100..1c8e875 100644</span><br><span>--- a/include/asterisk/stream.h</span><br><span>+++ b/include/asterisk/stream.h</span><br><span>@@ -198,6 +198,19 @@</span><br><span> const char *ast_stream_to_str(const struct ast_stream *stream, struct ast_str **buf);</span><br><span> </span><br><span> /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Get a stack allocated string representing the stream for debugging/display purposes</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param stream A stream</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \returns a stack allocated pointer to a string representing the stream.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \warning No attempt should ever be made to free the returned</span><br><span style="color: hsl(120, 100%, 40%);">+ * char* as it is allocated from the stack.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ast_stream_to_stra(__stream) ast_str_tmp(128, ast_stream_to_str(__stream, &STR_TMP))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span> * \brief Get the count of the current negotiated formats of a stream</span><br><span> *</span><br><span> * \param stream The media stream</span><br><span>@@ -610,4 +623,17 @@</span><br><span> */</span><br><span> const char *ast_stream_topology_to_str(const struct ast_stream_topology *topology, struct ast_str **buf);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Get a stack allocated string representing the topology for debugging/display purposes</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param topology A topology</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \returns a stack allocated pointer to a string representing the topology.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \warning No attempt should ever be made to free the returned</span><br><span style="color: hsl(120, 100%, 40%);">+ * char* as it is allocated from the stack.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ast_stream_topology_to_stra(__topology) ast_str_tmp(256, ast_stream_topology_to_str(__topology, &STR_TMP))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #endif /* _AST_STREAM_H */</span><br><span>diff --git a/main/stream.c b/main/stream.c</span><br><span>index 9c764d0..5141ca3 100644</span><br><span>--- a/main/stream.c</span><br><span>+++ b/main/stream.c</span><br><span>@@ -206,22 +206,23 @@</span><br><span> </span><br><span> const char *ast_stream_to_str(const struct ast_stream *stream, struct ast_str **buf)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- if (!buf || !*buf) {</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(120, 100%, 40%);">+ if (!buf || !*buf) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return "";</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (!stream) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(buf, 0, "(null stream)");</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_str_buffer(*buf);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!stream) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(buf, 0, "(null stream)");</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_str_buffer(*buf);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_append(buf, 0, "%s:%s:%s ",</span><br><span style="color: hsl(0, 100%, 40%);">- S_OR(stream->name, "noname"),</span><br><span style="color: hsl(0, 100%, 40%);">- ast_codec_media_type2str(stream->type),</span><br><span style="color: hsl(0, 100%, 40%);">- ast_stream_state_map[stream->state]);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_format_cap_append_names(stream->formats, buf);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_append(buf, 0, "%d:%s:%s:%s ",</span><br><span style="color: hsl(120, 100%, 40%);">+ stream->position,</span><br><span style="color: hsl(120, 100%, 40%);">+ S_OR(stream->name, "noname"),</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_codec_media_type2str(stream->type),</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_stream_state_map[stream->state]);</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_format_cap_append_names(stream->formats, buf);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- return ast_str_buffer(*buf);</span><br><span style="color: hsl(120, 100%, 40%);">+ return ast_str_buffer(*buf);</span><br><span> }</span><br><span> </span><br><span> int ast_stream_get_format_count(const struct ast_stream *stream)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14784">change 14784</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/c/asterisk/+/14784"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Idaf4cb0affa46d4dce58a73a111f35435331cc4b </div>
<div style="display:none"> Gerrit-Change-Number: 14784 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>