[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase2 r306428 - in /team/dvossel/fixthew...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Feb 4 15:58:12 CST 2011
Author: dvossel
Date: Fri Feb 4 15:58:08 2011
New Revision: 306428
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=306428
Log:
modifications to translator output to handle custom formats with translation
Modified:
team/dvossel/fixtheworld_phase2/codecs/Makefile
team/dvossel/fixtheworld_phase2/include/asterisk/format.h
team/dvossel/fixtheworld_phase2/main/format.c
team/dvossel/fixtheworld_phase2/main/format_cap.c
team/dvossel/fixtheworld_phase2/main/translate.c
Modified: team/dvossel/fixtheworld_phase2/codecs/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/codecs/Makefile?view=diff&rev=306428&r1=306427&r2=306428
==============================================================================
--- team/dvossel/fixtheworld_phase2/codecs/Makefile (original)
+++ team/dvossel/fixtheworld_phase2/codecs/Makefile Fri Feb 4 15:58:08 2011
@@ -19,6 +19,7 @@
LIBILBC:=ilbc/libilbc.a
LIBLPC10:=lpc10/liblpc10.a
+LIBS:=/usr/src/SILK_SDK_SRC_v1.0.7/SILK_SDK_SRC_FIX_v1.0.7/libSKP_SILK_SDK.a
all: _all
@@ -51,3 +52,6 @@
$(if $(filter codec_g722,$(EMBEDDED_MODS)),modules.link,codec_g722.so): g722/g722_encode.o g722/g722_decode.o
g722/g722_encode.o g722/g722_decode.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,codec_g722)
+
+
+codec_silk.o: _ASTCFLAGS+=-I /usr/src/SILK_SDK_SRC_v1.0.7/SILK_SDK_SRC_FIX_v1.0.7/interface
Modified: team/dvossel/fixtheworld_phase2/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/include/asterisk/format.h?view=diff&rev=306428&r1=306427&r2=306428
==============================================================================
--- team/dvossel/fixtheworld_phase2/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase2/include/asterisk/format.h Fri Feb 4 15:58:08 2011
@@ -323,7 +323,15 @@
* \param format id of format
* \return A static string containing the name of the format or "unknown" if unknown.
*/
-const char* ast_getformatname(struct ast_format *format);
+const char* ast_getformatname(const struct ast_format *format);
+
+/*! \brief Returns a string containing all formats pertaining to an format id.
+ * \param buf a buffer for the output string
+ * \param size size of buf (bytes)
+ * \param format id.
+ * \return The return value is buf.
+ */
+char* ast_getformatname_multiple_byid(char *buf, size_t size, enum ast_format_id id);
/*!
* \brief Gets a format from a name.
Modified: team/dvossel/fixtheworld_phase2/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/format.c?view=diff&rev=306428&r1=306427&r2=306428
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/format.c (original)
+++ team/dvossel/fixtheworld_phase2/main/format.c Fri Feb 4 15:58:08 2011
@@ -525,7 +525,7 @@
return 0;
}
-const char* ast_getformatname(struct ast_format *format)
+const char* ast_getformatname(const struct ast_format *format)
{
int x;
const char *ret = "unknown";
@@ -541,12 +541,12 @@
return ret;
}
-char *ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap)
+
+char *ast_getformatname_multiple_byid(char *buf, size_t size, enum ast_format_id id)
{
int x;
unsigned len;
char *start, *end = buf;
- struct ast_format tmp_fmt;
size_t f_len;
const struct ast_format_list *f_list = ast_format_list_get(&f_len);
@@ -560,8 +560,7 @@
size -= len;
start = end;
for (x = 0; x < f_len; x++) {
- ast_format_copy(&tmp_fmt, &f_list[x].format);
- if (ast_format_cap_iscompatible(cap, &tmp_fmt)) {
+ if (f_list[x].format.id == id) {
snprintf(end, size, "%s|", f_list[x].name);
len = strlen(end);
end += len;
Modified: team/dvossel/fixtheworld_phase2/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/format_cap.c?view=diff&rev=306428&r1=306427&r2=306428
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase2/main/format_cap.c Fri Feb 4 15:58:08 2011
@@ -514,6 +514,42 @@
return 0;
}
+char *ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap)
+{
+ int x;
+ unsigned len;
+ char *start, *end = buf;
+ struct ast_format tmp_fmt;
+ size_t f_len;
+ const struct ast_format_list *f_list = ast_format_list_get(&f_len);
+
+ if (!size) {
+ f_list = ast_format_list_destroy(f_list);
+ return buf;
+ }
+ snprintf(end, size, "(");
+ len = strlen(end);
+ end += len;
+ size -= len;
+ start = end;
+ for (x = 0; x < f_len; x++) {
+ ast_format_copy(&tmp_fmt, &f_list[x].format);
+ if (ast_format_cap_iscompatible(cap, &tmp_fmt)) {
+ snprintf(end, size, "%s|", f_list[x].name);
+ len = strlen(end);
+ end += len;
+ size -= len;
+ }
+ }
+ if (start == end) {
+ ast_copy_string(start, "nothing)", size);
+ } else if (size > 1) {
+ *(end - 1) = ')';
+ }
+ f_list = ast_format_list_destroy(f_list);
+ return buf;
+}
+
uint64_t ast_format_cap_to_old_bitfield(const struct ast_format_cap *cap)
{
uint64_t res = 0;
Modified: team/dvossel/fixtheworld_phase2/main/translate.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/translate.c?view=diff&rev=306428&r1=306427&r2=306428
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/translate.c (original)
+++ team/dvossel/fixtheworld_phase2/main/translate.c Fri Feb 4 15:58:08 2011
@@ -836,46 +836,56 @@
static char *handle_show_translation_table(struct ast_cli_args *a)
{
- int x, y;
+ int x, y, i, k;
int curlen = 0, longest = 0;
- struct ast_format tmp_fmt;
+ int f_len = 0;
+ const struct ast_format_list *f_list = ast_format_list_get((size_t *) &f_len);
+
AST_RWLIST_RDLOCK(&translators);
ast_cli(a->fd, " Translation times between formats (in microseconds) for one second of data\n");
ast_cli(a->fd, " Source Format (Rows) Destination Format (Columns)\n\n");
/* Get the length of the longest (usable?) codec name, so we know how wide the left side should be */
- for (x = 0; x < cur_max_index; x++) {
+ for (i = 0; i < f_len; i++) {
/* translation only applies to audio right now. */
- if (AST_FORMAT_GET_TYPE(index2format(x)) != AST_FORMAT_TYPE_AUDIO)
+ if (AST_FORMAT_GET_TYPE(f_list[i].format.id) != AST_FORMAT_TYPE_AUDIO)
continue;
- curlen = strlen(ast_getformatname(ast_format_set(&tmp_fmt, index2format(x), 0)));
+ curlen = strlen(ast_getformatname(&f_list[i].format));
if (curlen > longest) {
longest = curlen;
}
}
- for (x = -1; x < cur_max_index; x++) {
+ for (i = -1; i < f_len; i++) {
struct ast_str *out = ast_str_alloca(256);
+ x = -1;
+ if ((i >= 0) && ((x = format2index(f_list[i].format.id)) == -1)) {
+ continue;
+ }
/* translation only applies to audio right now. */
- if (x >= 0 && (AST_FORMAT_GET_TYPE(index2format(x)) != AST_FORMAT_TYPE_AUDIO)) {
+ if (i >= 0 && (AST_FORMAT_GET_TYPE(f_list[i].format.id) != AST_FORMAT_TYPE_AUDIO)) {
continue;
}
/*Go ahead and move to next iteration if dealing with an unknown codec*/
- if (x >= 0 && !strcmp(ast_getformatname(ast_format_set(&tmp_fmt, index2format(x), 0)), "unknown")) {
+ if (i >= 0 && !strcmp(ast_getformatname(&f_list[i].format), "unknown")) {
continue;
}
ast_str_set(&out, -1, " ");
- for (y = -1; y < cur_max_index; y++) {
+ for (k = -1; k < f_len; k++) {
+ y = -1;
+ if ((k >= 0) && ((y = format2index(f_list[k].format.id)) == -1)) {
+ continue;
+ }
/* translation only applies to audio right now. */
- if (y >= 0 && (AST_FORMAT_GET_TYPE(index2format(y)) != AST_FORMAT_TYPE_AUDIO)) {
+ if (k >= 0 && (AST_FORMAT_GET_TYPE(f_list[k].format.id) != AST_FORMAT_TYPE_AUDIO)) {
continue;
}
/*Go ahead and move to next iteration if dealing with an unknown codec*/
- if (y >= 0 && !strcmp(ast_getformatname(ast_format_set(&tmp_fmt, index2format(y), 0)), "unknown")) {
+ if (k >= 0 && !strcmp(ast_getformatname(&f_list[k].format), "unknown")) {
continue;
}
- if (y >= 0) {
- curlen = strlen(ast_getformatname(ast_format_set(&tmp_fmt, index2format(y), 0)));
+ if (k >= 0) {
+ curlen = strlen(ast_getformatname(&f_list[k].format));
}
if (curlen < 5) {
curlen = 5;
@@ -884,12 +894,12 @@
if (x >= 0 && y >= 0 && matrix_get(x, y)->step) {
/* Actual codec output */
ast_str_append(&out, -1, "%*d", curlen + 1, (matrix_get(x, y)->table_cost/100));
- } else if (x == -1 && y >= 0) {
+ } else if (i == -1 && k >= 0) {
/* Top row - use a dynamic size */
- ast_str_append(&out, -1, "%*s", curlen + 1, ast_getformatname(ast_format_set(&tmp_fmt, index2format(y), 0)));
- } else if (y == -1 && x >= 0) {
+ ast_str_append(&out, -1, "%*s", curlen + 1, ast_getformatname(&f_list[k].format));
+ } else if (k == -1 && i >= 0) {
/* Left column - use a static size. */
- ast_str_append(&out, -1, "%*s", longest, ast_getformatname(ast_format_set(&tmp_fmt, index2format(x), 0)));
+ ast_str_append(&out, -1, "%*s", longest, ast_getformatname(&f_list[i].format));
} else if (x >= 0 && y >= 0) {
/* Codec not supported */
ast_str_append(&out, -1, "%*s", curlen + 1, "-");
@@ -902,6 +912,7 @@
ast_cli(a->fd, "%s", ast_str_buffer(out));
}
AST_RWLIST_UNLOCK(&translators);
+ ast_format_list_destroy(f_list);
return CLI_SUCCESS;
}
@@ -913,6 +924,7 @@
const struct ast_format_list *format_list = ast_format_list_get(&len);
struct ast_str *str = ast_str_alloca(256);
struct ast_translator *step;
+ char tmp[256];
ast_format_clear(&input_src_format);
for (i = 0; i < len; i++) {
@@ -942,14 +954,14 @@
src = format2index(input_src_format.id);
ast_str_reset(str);
if ((len >= cur_max_index) && (src != -1) && (dst != -1) && matrix_get(src, dst)->step) {
- ast_str_append(&str, 0, "%s", ast_getformatname(&matrix_get(src, dst)->step->src_format));
+ ast_str_append(&str, 0, "%s", ast_getformatname_multiple_byid(tmp, sizeof(tmp), matrix_get(src, dst)->step->src_format.id));
while (src != dst) {
step = matrix_get(src, dst)->step;
if (!step) {
ast_str_reset(str);
break;
}
- ast_str_append(&str, 0, "->%s", ast_getformatname(&step->dst_format));
+ ast_str_append(&str, 0, "->%s", ast_getformatname_multiple_byid(tmp, sizeof(tmp), step->dst_format.id));
src = step->dst_fmt_index;
}
}
More information about the asterisk-commits
mailing list