aboutsummaryrefslogtreecommitdiffstats
path: root/frame.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-16 14:48:05 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-08-16 14:48:05 +0000
commitb7fbd14cece6a0345918a946fdba5bdc3268e539 (patch)
treefcbef020d83e4b58d4c02767b399ff6820ded89e /frame.c
parentc3ef7b672f25621ba670ba22955a3dfc0953c739 (diff)
New "show codecs" option and mysql feature requests from Tilghman
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1349 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'frame.c')
-rwxr-xr-xframe.c111
1 files changed, 111 insertions, 0 deletions
diff --git a/frame.c b/frame.c
index 2e53f8d1e..b2f6736b0 100755
--- a/frame.c
+++ b/frame.c
@@ -411,6 +411,112 @@ int ast_getformatbyname(char *name)
return 0;
}
+char *ast_codec2str(int codec) {
+ static char codecs[25][30] = {
+ /* Audio formats */
+ "G.723.1", /* 0 */
+ "GSM", /* 1 */
+ "G.711 u-law", /* 2 */
+ "G.711 A-law", /* 3 */
+ "MPEG-2 layer 3", /* 4 */
+ "ADPCM", /* 5 */
+ "16 bit Signed Linear PCM", /* 6 */
+ "LPC10", /* 7 */
+ "G.729A audio", /* 8 */
+ "SpeeX", /* 9 */
+ "iLBC", /* 10 */
+ "undefined", /* 11 */
+ "undefined", /* 12 */
+ "undefined", /* 13 */
+ "undefined", /* 14 */
+ "Maximum audio format", /* 15 */
+ /* Image formats */
+ "JPEG image", /* 16 */
+ "PNG image", /* 17 */
+ "H.261 Video", /* 18 */
+ "H.263 Video", /* 19 */
+ "undefined", /* 20 */
+ "undefined", /* 21 */
+ "undefined", /* 22 */
+ "undefined", /* 23 */
+ "Maximum video format", /* 24 */
+ };
+ return codecs[codec];
+}
+
+static int show_codecs(int fd, int argc, char *argv[])
+{
+ int i, found=0;
+
+ if ((argc < 2) || (argc > 3))
+ return RESULT_SHOWUSAGE;
+
+ if ((argc == 2) || (!strcasecmp(argv[1],"audio"))) {
+ found = 1;
+ for (i=0;i<11;i++)
+ ast_cli(fd, "%8d (1 << %2d) %s\n",1 << i,i,ast_codec2str(i));
+ }
+
+ if ((argc == 2) || (!strcasecmp(argv[1],"image"))) {
+ found = 1;
+ for (i=16;i<18;i++)
+ ast_cli(fd, "%8d (1 << %2d) %s\n",1 << i,i,ast_codec2str(i));
+ }
+
+ if ((argc == 2) || (!strcasecmp(argv[1],"video"))) {
+ found = 1;
+ for (i=18;i<20;i++)
+ ast_cli(fd, "%8d (1 << %2d) %s\n",1 << i,i,ast_codec2str(i));
+ }
+
+ if (! found)
+ return RESULT_SHOWUSAGE;
+ else
+ return RESULT_SUCCESS;
+}
+
+static char frame_show_codecs_usage[] =
+"Usage: show [audio|video|image] codecs\n"
+" Displays codec mapping\n";
+
+struct ast_cli_entry cli_show_codecs =
+{ { "show", "codecs", NULL }, show_codecs, "Shows codecs", frame_show_codecs_usage };
+struct ast_cli_entry cli_show_codecs_audio =
+{ { "show", "audio", "codecs", NULL }, show_codecs, "Shows audio codecs", frame_show_codecs_usage };
+struct ast_cli_entry cli_show_codecs_video =
+{ { "show", "video", "codecs", NULL }, show_codecs, "Shows video codecs", frame_show_codecs_usage };
+struct ast_cli_entry cli_show_codecs_image =
+{ { "show", "image", "codecs", NULL }, show_codecs, "Shows image codecs", frame_show_codecs_usage };
+
+static int show_codec_n(int fd, int argc, char *argv[])
+{
+ int codec, i, found=0;
+
+ if (argc != 3)
+ return RESULT_SHOWUSAGE;
+
+ if (sscanf(argv[2],"%d",&codec) != 1)
+ return RESULT_SHOWUSAGE;
+
+ for (i=0;i<32;i++)
+ if (codec == (1 << i)) {
+ found = 1;
+ ast_cli(fd, "%d (1 << %d) %s\n",1 << i,i,ast_codec2str(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"
+" Displays codec mapping\n";
+
+struct ast_cli_entry cli_show_codec_n =
+{ { "show", "codec", NULL }, show_codec_n, "Shows a specific codec", frame_show_codec_n_usage };
+
void ast_frame_dump(char *name, struct ast_frame *f, char *prefix)
{
char *n = "unknown";
@@ -598,5 +704,10 @@ int init_framer(void)
#ifdef TRACE_FRAMES
ast_cli_register(&cli_frame_stats);
#endif
+ ast_cli_register(&cli_show_codecs);
+ ast_cli_register(&cli_show_codecs_audio);
+ ast_cli_register(&cli_show_codecs_video);
+ ast_cli_register(&cli_show_codecs_image);
+ ast_cli_register(&cli_show_codec_n);
return 0;
}