aboutsummaryrefslogtreecommitdiffstats
path: root/main/frame.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-18 19:54:18 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-18 19:54:18 +0000
commit5aacb6a82d4cf625774fa1ea39ca193a3be73b35 (patch)
treecf63baa167f81c95d3dbf417f83681851decad80 /main/frame.c
parent4de5810a0530bca0665eadcfb06ef06fd2e86758 (diff)
merge qwell's CLI verbification work
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@43212 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/frame.c')
-rw-r--r--main/frame.c159
1 files changed, 145 insertions, 14 deletions
diff --git a/main/frame.c b/main/frame.c
index 5650df475..07714e07f 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -595,7 +595,7 @@ char *ast_codec2str(int codec)
return ret;
}
-static int show_codecs(int fd, int argc, char *argv[])
+static int show_codecs_deprecated(int fd, int argc, char *argv[])
{
int i, found=0;
char hex[25];
@@ -639,11 +639,55 @@ static int show_codecs(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int show_codecs(int fd, int argc, char *argv[])
+{
+ int i, found=0;
+ char hex[25];
+
+ if ((argc < 3) || (argc > 4))
+ return RESULT_SHOWUSAGE;
+
+ if (!ast_opt_dont_warn)
+ ast_cli(fd, "Disclaimer: this command is for informational purposes only.\n"
+ "\tIt does not indicate anything about your configuration.\n");
+
+ ast_cli(fd, "%11s %9s %10s TYPE %8s %s\n","INT","BINARY","HEX","NAME","DESC");
+ ast_cli(fd, "--------------------------------------------------------------------------------\n");
+ if ((argc == 3) || (!strcasecmp(argv[3],"audio"))) {
+ found = 1;
+ for (i=0;i<12;i++) {
+ snprintf(hex,25,"(0x%x)",1<<i);
+ ast_cli(fd, "%11u (1 << %2d) %10s audio %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ }
+ }
+
+ if ((argc == 3) || (!strcasecmp(argv[3],"image"))) {
+ found = 1;
+ for (i=16;i<18;i++) {
+ snprintf(hex,25,"(0x%x)",1<<i);
+ ast_cli(fd, "%11u (1 << %2d) %10s image %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ }
+ }
+
+ if ((argc == 3) || (!strcasecmp(argv[3],"video"))) {
+ found = 1;
+ for (i=18;i<22;i++) {
+ snprintf(hex,25,"(0x%x)",1<<i);
+ ast_cli(fd, "%11u (1 << %2d) %10s video %8s (%s)\n",1 << i,i,hex,ast_getformatname(1<<i),ast_codec2str(1<<i));
+ }
+ }
+
+ if (! found)
+ return RESULT_SHOWUSAGE;
+ else
+ return RESULT_SUCCESS;
+}
+
static char frame_show_codecs_usage[] =
-"Usage: show [audio|video|image] codecs\n"
+"Usage: core list codecs [audio|video|image]\n"
" Displays codec mapping\n";
-static int show_codec_n(int fd, int argc, char *argv[])
+static int show_codec_n_deprecated(int fd, int argc, char *argv[])
{
int codec, i, found=0;
@@ -665,8 +709,30 @@ static int show_codec_n(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int show_codec_n(int fd, int argc, char *argv[])
+{
+ int codec, i, found=0;
+
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+
+ if (sscanf(argv[3],"%d",&codec) != 1)
+ return RESULT_SHOWUSAGE;
+
+ for (i = 0; i < 32; i++)
+ if (codec & (1 << i)) {
+ found = 1;
+ ast_cli(fd, "%11u (1 << %2d) %s\n",1 << i,i,ast_codec2str(1<<i));
+ }
+
+ if (!found)
+ ast_cli(fd, "Codec %d not found\n", codec);
+
+ return RESULT_SUCCESS;
+}
+
static char frame_show_codec_n_usage[] =
-"Usage: show codec <number>\n"
+"Usage: core show codec <number>\n"
" Displays codec mapping\n";
/*! Dump a frame for debugging purposes */
@@ -851,7 +917,7 @@ void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
#ifdef TRACE_FRAMES
-static int show_frame_stats(int fd, int argc, char *argv[])
+static int show_frame_stats_deprecated(int fd, int argc, char *argv[])
{
struct ast_frame *f;
int x=1;
@@ -868,27 +934,92 @@ static int show_frame_stats(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+static int show_frame_stats(int fd, int argc, char *argv[])
+{
+ struct ast_frame *f;
+ int x=1;
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+ AST_LIST_LOCK(&headerlist);
+ ast_cli(fd, " Framer Statistics \n");
+ ast_cli(fd, "---------------------------\n");
+ ast_cli(fd, "Total allocated headers: %d\n", headers);
+ ast_cli(fd, "Queue Dump:\n");
+ AST_LIST_TRAVERSE(&headerlist, f, frame_list)
+ ast_cli(fd, "%d. Type %d, subclass %d from %s\n", x++, f->frametype, f->subclass, f->src ? f->src : "<Unknown>");
+ AST_LIST_UNLOCK(&headerlist);
+ return RESULT_SUCCESS;
+}
+
static char frame_stats_usage[] =
-"Usage: show frame stats\n"
+"Usage: core show frame stats\n"
" Displays debugging statistics from framer\n";
#endif
/* Builtin Asterisk CLI-commands for debugging */
+static struct ast_cli_entry cli_show_codecs = {
+ { "show", "codecs", NULL },
+ show_codecs_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_audio_codecs = {
+ { "show", "audio", "codecs", NULL },
+ show_codecs_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_video_codecs = {
+ { "show", "video", "codecs", NULL },
+ show_codecs_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_image_codecs = {
+ { "show", "image", "codecs", NULL },
+ show_codecs_deprecated, NULL,
+ NULL };
+
+static struct ast_cli_entry cli_show_codec = {
+ { "show", "codec", NULL },
+ show_codec_n_deprecated, NULL,
+ NULL };
+
+#ifdef TRACE_FRAMES
+static struct ast_cli_entry cli_show_frame_stats = {
+ { "show", "frame", "stats", NULL },
+ show_frame_stats, NULL,
+ NULL };
+#endif
+
static struct ast_cli_entry my_clis[] = {
-{ { "show", "codecs", NULL }, show_codecs, "Shows codecs", frame_show_codecs_usage },
-{ { "show", "audio", "codecs", NULL }, show_codecs, "Shows audio codecs", frame_show_codecs_usage },
-{ { "show", "video", "codecs", NULL }, show_codecs, "Shows video codecs", frame_show_codecs_usage },
-{ { "show", "image", "codecs", NULL }, show_codecs, "Shows image codecs", frame_show_codecs_usage },
-{ { "show", "codec", NULL }, show_codec_n, "Shows a specific codec", frame_show_codec_n_usage },
+ { { "core", "list", "codecs", NULL },
+ show_codecs, "Displays a list of codecs",
+ frame_show_codecs_usage, NULL, &cli_show_codecs },
+
+ { { "core", "list", "codecs", "audio", NULL },
+ show_codecs, "Displays a list of audio codecs",
+ frame_show_codecs_usage, NULL, &cli_show_audio_codecs },
+
+ { { "core", "list", "codecs", "video", NULL },
+ show_codecs, "Displays a list of video codecs",
+ frame_show_codecs_usage, NULL, &cli_show_video_codecs },
+
+ { { "core", "list", "codecs", "image", NULL },
+ show_codecs, "Displays a list of image codecs",
+ frame_show_codecs_usage, NULL, &cli_show_image_codecs },
+
+ { { "core", "show", "codec", NULL },
+ show_codec_n, "Shows a specific codec",
+ frame_show_codec_n_usage, NULL, &cli_show_codec },
+
#ifdef TRACE_FRAMES
-{ { "show", "frame", "stats", NULL }, show_frame_stats, "Shows frame statistics", frame_stats_usage },
+ { { "core", "show", "frame", "stats", NULL },
+ show_frame_stats, "Shows frame statistics",
+ frame_stats_usage, NULL, &cli_show_frame_stats },
#endif
};
-
int init_framer(void)
{
- ast_cli_register_multiple(my_clis, sizeof(my_clis)/sizeof(my_clis[0]) );
+ ast_cli_register_multiple(my_clis, sizeof(my_clis) / sizeof(struct ast_cli_entry));
return 0;
}