[asterisk-commits] file: branch group/media_formats r406148 - /team/group/media_formats/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jan 21 16:24:58 CST 2014
Author: file
Date: Tue Jan 21 16:24:55 2014
New Revision: 406148
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=406148
Log:
Move "core show codec" over to the new codec API.
Modified:
team/group/media_formats/main/codec.c
team/group/media_formats/main/format.c
Modified: team/group/media_formats/main/codec.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/codec.c?view=diff&rev=406148&r1=406147&r2=406148
==============================================================================
--- team/group/media_formats/main/codec.c (original)
+++ team/group/media_formats/main/codec.c Tue Jan 21 16:24:55 2014
@@ -165,9 +165,56 @@
return CLI_SUCCESS;
}
+/*! \brief Callback function for getting a codec based on unique identifier */
+static int codec_id_cmp(void *obj, void *arg, int flags)
+{
+ struct ast_codec *codec = obj;
+ int *id = arg;
+
+ return (codec->id == *id) ? CMP_MATCH | CMP_STOP : 0;
+}
+
+static char *show_codec(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ int type_punned_codec;
+ struct ast_codec *codec;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "core show codec";
+ e->usage =
+ "Usage: core show codec <number>\n"
+ " Displays codec mapping\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc != 4) {
+ return CLI_SHOWUSAGE;
+ }
+
+ if (sscanf(a->argv[3], "%30d", &type_punned_codec) != 1) {
+ return CLI_SHOWUSAGE;
+ }
+
+ codec = ao2_callback(codecs, 0, codec_id_cmp, &type_punned_codec);
+ if (!codec) {
+ ast_cli(a->fd, "Codec %d not found\n", type_punned_codec);
+ return CLI_SUCCESS;
+ }
+
+ ast_cli(a->fd, "%11u %s\n", (unsigned int) codec->id, codec->description);
+
+ ao2_ref(codec, -1);
+
+ return CLI_SUCCESS;
+}
+
/* Builtin Asterisk CLI-commands for debugging */
static struct ast_cli_entry codec_cli[] = {
AST_CLI_DEFINE(show_codecs, "Displays a list of registered codecs"),
+ AST_CLI_DEFINE(show_codec, "Shows a specific codec"),
};
/*! \brief Function called when the process is shutting down */
Modified: team/group/media_formats/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/format.c?view=diff&rev=406148&r1=406147&r2=406148
==============================================================================
--- team/group/media_formats/main/format.c (original)
+++ team/group/media_formats/main/format.c Tue Jan 21 16:24:55 2014
@@ -812,55 +812,6 @@
}
}
-static char *show_codec_n(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
- enum ast_format_id format_id;
- int x, found = 0;
- int type_punned_codec;
- size_t f_len;
- const struct ast_format_list *f_list;
-
- switch (cmd) {
- case CLI_INIT:
- e->command = "core show codec";
- e->usage =
- "Usage: core show codec <number>\n"
- " Displays codec mapping\n";
- return NULL;
- case CLI_GENERATE:
- return NULL;
- }
-
- if (a->argc != 4) {
- return CLI_SHOWUSAGE;
- }
-
- if (sscanf(a->argv[3], "%30d", &type_punned_codec) != 1) {
- return CLI_SHOWUSAGE;
- }
- format_id = type_punned_codec;
-
- f_list = ast_format_list_get(&f_len);
- for (x = 0; x < f_len; x++) {
- if (f_list[x].format.id == format_id) {
- found = 1;
- ast_cli(a->fd, "%11u %s\n", (unsigned int) format_id, f_list[x].desc);
- }
- }
-
- if (!found) {
- ast_cli(a->fd, "Codec %d not found\n", format_id);
- }
-
- f_list = ast_format_list_destroy(f_list);
- return CLI_SUCCESS;
-}
-
-/* Builtin Asterisk CLI-commands for debugging */
-static struct ast_cli_entry my_clis[] = {
- AST_CLI_DEFINE(show_codec_n, "Shows a specific codec"),
-};
-
static int format_list_add_custom(struct ast_format_list *new)
{
RAII_VAR(struct ast_format_list *, entry, NULL, ao2_cleanup);
@@ -1069,7 +1020,6 @@
*/
static void format_attr_shutdown(void)
{
- ast_cli_unregister_multiple(my_clis, ARRAY_LEN(my_clis));
if (interfaces) {
ao2_ref(interfaces, -1);
interfaces = NULL;
@@ -1084,7 +1034,6 @@
return -1;
}
- ast_cli_register_multiple(my_clis, ARRAY_LEN(my_clis));
ast_register_atexit(format_attr_shutdown);
return 0;
}
More information about the asterisk-commits
mailing list