[asterisk-commits] core: Show streams in "core show channel". (asterisk[master])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Feb 22 11:40:02 CST 2017
Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5059 )
Change subject: core: Show streams in "core show channel".
......................................................................
core: Show streams in "core show channel".
The "core show channel" CLI command will now output the streams
present on the channel with their details.
ASTERISK-26811
Change-Id: I9c95b57aa09415005f0677a1949a0feb07e4987a
---
M include/asterisk/stream.h
M main/cli.c
M main/stream.c
3 files changed, 48 insertions(+), 0 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, approved
Anonymous Coward #1000019: Verified
Matthew Fredrickson: Looks good to me, but someone else must approve
diff --git a/include/asterisk/stream.h b/include/asterisk/stream.h
index edb00b9..48ee883 100644
--- a/include/asterisk/stream.h
+++ b/include/asterisk/stream.h
@@ -191,6 +191,17 @@
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state);
/*!
+ * \brief Convert the state of a stream into a string
+ *
+ * \param state The stream state
+ *
+ * \return The state of the stream in string format
+ *
+ * \since 15
+ */
+const char *ast_stream_state2str(enum ast_stream_state state);
+
+/*!
* \brief Get the position of the stream in the topology
*
* \param stream The media stream
diff --git a/main/cli.c b/main/cli.c
index ccdbb97..06f2d55 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -61,6 +61,7 @@
#include "asterisk/stasis_channels.h"
#include "asterisk/stasis_bridges.h"
#include "asterisk/vector.h"
+#include "asterisk/stream.h"
/*!
* \brief List of restrictions per user.
@@ -1542,6 +1543,7 @@
struct ast_bridge *bridge;
ast_callid callid;
char callid_buf[32];
+ int stream_num;
switch (cmd) {
case CLI_INIT:
@@ -1668,6 +1670,7 @@
S_OR(ast_channel_data(chan), "(Empty)"),
S_OR(callid_buf, "(None)")
);
+
ast_str_append(&output, 0, " Variables:\n");
AST_LIST_TRAVERSE(ast_channel_varshead(chan), var, entries) {
@@ -1679,6 +1682,22 @@
ast_str_append(&output, 0, " CDR Variables:\n%s\n", ast_str_buffer(obuf));
}
+ ast_str_append(&output, 0, " -- Streams --\n");
+ for (stream_num = 0; stream_num < ast_stream_topology_get_count(ast_channel_get_stream_topology(chan)); stream_num++) {
+ struct ast_stream *stream = ast_stream_topology_get_stream(ast_channel_get_stream_topology(chan), stream_num);
+
+ ast_str_append(&output, 0,
+ "Name: %s\n"
+ " Type: %s\n"
+ " State: %s\n"
+ " Formats: %s\n",
+ ast_stream_get_name(stream),
+ ast_codec_media_type2str(ast_stream_get_type(stream)),
+ ast_stream_state2str(ast_stream_get_state(stream)),
+ ast_format_cap_get_names(ast_stream_get_formats(stream), &codec_buf)
+ );
+ }
+
ast_channel_unlock(chan);
ast_cli(a->fd, "%s", ast_str_buffer(output));
diff --git a/main/stream.c b/main/stream.c
index aacd33f..8bee2fd 100644
--- a/main/stream.c
+++ b/main/stream.c
@@ -168,6 +168,24 @@
stream->state = state;
}
+const char *ast_stream_state2str(enum ast_stream_state state)
+{
+ switch (state) {
+ case AST_STREAM_STATE_REMOVED:
+ return "removed";
+ case AST_STREAM_STATE_SENDRECV:
+ return "sendrecv";
+ case AST_STREAM_STATE_SENDONLY:
+ return "sendonly";
+ case AST_STREAM_STATE_RECVONLY:
+ return "recvonly";
+ case AST_STREAM_STATE_INACTIVE:
+ return "inactive";
+ default:
+ return "<unknown>";
+ }
+}
+
int ast_stream_get_position(const struct ast_stream *stream)
{
ast_assert(stream != NULL);
--
To view, visit https://gerrit.asterisk.org/5059
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9c95b57aa09415005f0677a1949a0feb07e4987a
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
More information about the asterisk-commits
mailing list