[Asterisk-code-review] translate: Show sample rate for silk, speex, and slin in tra... (asterisk[master])

Joshua Colp asteriskteam at digium.com
Tue Nov 28 12:37:52 CST 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/7364 )

Change subject: translate: Show sample rate for silk, speex, and slin in translation table.
......................................................................

translate: Show sample rate for silk, speex, and slin in translation table.

ASTERISK-24662

Change-Id: I3822956984292c99c48bca8e97807e498ccc0e88
---
M main/translate.c
1 file changed, 26 insertions(+), 3 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/main/translate.c b/main/translate.c
index f2aa588..30f1649 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -945,7 +945,8 @@
 static char *handle_show_translation_table(struct ast_cli_args *a)
 {
 	int x, y, i, k;
-	int longest = 0, num_codecs = 0, curlen = 0;
+	int longest = 7; /* slin192 */
+	int num_codecs = 0, curlen = 0;
 	struct ast_str *out = ast_str_create(1024);
 	struct ast_codec *codec;
 
@@ -982,6 +983,7 @@
 
 		ast_str_set(&out, 0, " ");
 		for (k = 0; k < num_codecs; k++) {
+			int adjust = 0;
 			struct ast_codec *col = k ? ast_codec_get_by_id(k) : NULL;
 
 			y = -1;
@@ -997,6 +999,12 @@
 
 			if (k > 0) {
 				curlen = strlen(col->name);
+				if (!strcmp(col->name, "slin") ||
+					!strcmp(col->name, "speex") ||
+					!strcmp(col->name, "silk")) {
+					adjust = log10(col->sample_rate / 1000) + 1;
+					curlen = curlen + adjust;
+				}
 			}
 
 			if (curlen < 5) {
@@ -1008,10 +1016,25 @@
 				ast_str_append(&out, 0, "%*u", curlen + 1, (matrix_get(x, y)->table_cost/100));
 			} else if (i == 0 && k > 0) {
 				/* Top row - use a dynamic size */
-				ast_str_append(&out, 0, "%*s", curlen + 1, col->name);
+				if (!strcmp(col->name, "slin") ||
+					!strcmp(col->name, "speex") ||
+					!strcmp(col->name, "silk")) {
+					ast_str_append(&out, 0, "%*s%u", curlen - adjust + 1,
+						col->name, col->sample_rate / 1000);
+				} else {
+					ast_str_append(&out, 0, "%*s", curlen + 1, col->name);
+				}
 			} else if (k == 0 && i > 0) {
 				/* Left column - use a static size. */
-				ast_str_append(&out, 0, "%*s", longest, row->name);
+				if (!strcmp(row->name, "slin") ||
+					!strcmp(row->name, "speex") ||
+					!strcmp(row->name, "silk")) {
+					int adjust_row = log10(row->sample_rate / 1000) + 1;
+					ast_str_append(&out, 0, "%*s%u", longest - adjust_row,
+						row->name, row->sample_rate / 1000);
+				} else {
+					ast_str_append(&out, 0, "%*s", longest, row->name);
+				}
 			} else if (x >= 0 && y >= 0) {
 				/* Codec not supported */
 				ast_str_append(&out, 0, "%*s", curlen + 1, "-");

-- 
To view, visit https://gerrit.asterisk.org/7364
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3822956984292c99c48bca8e97807e498ccc0e88
Gerrit-Change-Number: 7364
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171128/d8e99be0/attachment.html>


More information about the asterisk-code-review mailing list