*/
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
*
*/
const char *ast_stream_topology_to_str(const struct ast_stream_topology *topology, struct ast_str **buf);
+/*!
+ * \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 */
const char *ast_stream_to_str(const struct ast_stream *stream, struct ast_str **buf)
{
- if (!buf || !*buf) {
- return "";
- }
+ if (!buf || !*buf) {
+ return "";
+ }
- if (!stream) {
- ast_str_append(buf, 0, "(null stream)");
- return ast_str_buffer(*buf);
- }
+ if (!stream) {
+ ast_str_append(buf, 0, "(null stream)");
+ return ast_str_buffer(*buf);
+ }
- ast_str_append(buf, 0, "%s:%s:%s ",
- S_OR(stream->name, "noname"),
- ast_codec_media_type2str(stream->type),
- ast_stream_state_map[stream->state]);
- ast_format_cap_append_names(stream->formats, buf);
+ 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]);
+ ast_format_cap_append_names(stream->formats, buf);
- return ast_str_buffer(*buf);
+ return ast_str_buffer(*buf);
}
int ast_stream_get_format_count(const struct ast_stream *stream)