Merge "core: Show streams in "core show channel"."
This commit is contained in:
commit
6c22d4b320
|
@ -190,6 +190,17 @@ enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream);
|
|||
*/
|
||||
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
|
||||
*
|
||||
|
|
19
main/cli.c
19
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 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
|
|||
struct ast_bridge *bridge;
|
||||
ast_callid callid;
|
||||
char callid_buf[32];
|
||||
int stream_num;
|
||||
|
||||
switch (cmd) {
|
||||
case CLI_INIT:
|
||||
|
@ -1668,6 +1670,7 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
|
|||
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 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
|
|||
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));
|
||||
|
|
|
@ -168,6 +168,24 @@ void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue