]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
stream.c: Added 2 more debugging utils and added pos to stream string
authorGeorge Joseph <gjoseph@digium.com>
Thu, 20 Aug 2020 13:32:03 +0000 (07:32 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Thu, 20 Aug 2020 13:46:11 +0000 (07:46 -0600)
 * Added ast_stream_to_stra and ast_stream_topology_to_stra() macros
   which are shortcuts for
      ast_str_tmp(256, ast_stream_to_str(stream, &STR_TMP))

 * Added the stream position to the string representation of the
   stream.

 * Fixed some formatting in ast_stream_to_str().

Change-Id: Idaf4cb0affa46d4dce58a73a111f35435331cc4b

include/asterisk/stream.h
main/stream.c

index ca637be3fd34124728bacf377e7e8dbbe77680bc..205feeb9c4dc1ba0a56db1e98fee27bc0e3a2c3d 100644 (file)
@@ -473,6 +473,19 @@ const struct ast_format_cap *ast_stream_get_formats(const struct ast_stream *str
  */
 const char *ast_stream_to_str(const struct ast_stream *stream, struct ast_str **buf);
 
+/*!
+ * \brief Get a stack allocated string representing the stream for debugging/display purposes
+ *
+ * \param stream A stream
+ *
+ * \returns a stack allocated pointer to a string representing the stream.
+ *
+ * \warning No attempt should ever be made to free the returned
+ * char* as it is allocated from the stack.
+ *
+ */
+#define ast_stream_to_stra(__stream) ast_str_tmp(128, ast_stream_to_str(__stream, &STR_TMP))
+
 /*!
  * \brief Get the count of the current negotiated formats of a stream
  *
@@ -954,4 +967,17 @@ struct ast_stream_topology *ast_stream_topology_create_resolved(
        struct ast_stream_codec_negotiation_prefs *prefs,
        struct ast_str **error_message);
 
+/*!
+ * \brief Get a stack allocated string representing the topology for debugging/display purposes
+ *
+ * \param topology A topology
+ *
+ * \returns a stack allocated pointer to a string representing the topology.
+ *
+ * \warning No attempt should ever be made to free the returned
+ * char* as it is allocated from the stack.
+ *
+ */
+#define ast_stream_topology_to_stra(__topology) ast_str_tmp(256, ast_stream_topology_to_str(__topology, &STR_TMP))
+
 #endif /* _AST_STREAM_H */
index 01b07cad1904070dbc02cd13be54f4de416250a1..c97ae484c8f3bdc894e3576ef1b9fc4032d39038 100644 (file)
@@ -343,7 +343,8 @@ const char *ast_stream_to_str(const struct ast_stream *stream, struct ast_str **
                return ast_str_buffer(*buf);
        }
 
-       ast_str_append(buf, 0, "%s:%s:%s ",
+       ast_str_append(buf, 0, "%d:%s:%s:%s ",
+               stream->position,
                S_OR(stream->name, "noname"),
                ast_codec_media_type2str(stream->type),
                ast_stream_state_map[stream->state]);