@@ -59,6 +59,7 @@ static AST_RWLIST_HEAD_STATIC(translators, ast_translator);
59
59
struct translator_path {
60
60
struct ast_translator * step ; /*!< Next step translator */
61
61
uint32_t table_cost ; /*!< Complete table cost to destination */
62
+ uint32_t comp_cost ; /*!< Complete table cost to destination */
62
63
uint8_t multistep ; /*!< Multiple conversions required for this translation */
63
64
};
64
65
@@ -858,6 +859,7 @@ static void matrix_rebuild(int samples)
858
859
859
860
matrix_get (x , z )-> step = t ;
860
861
matrix_get (x , z )-> table_cost = t -> table_cost ;
862
+ matrix_get (x , z )-> comp_cost = t -> comp_cost ;
861
863
}
862
864
}
863
865
@@ -987,7 +989,7 @@ static void handle_cli_recalc(struct ast_cli_args *a)
987
989
988
990
static char * handle_show_translation_table (struct ast_cli_args * a )
989
991
{
990
- int x , y , i , k ;
992
+ int x , y , i , k , compCost ;
991
993
int longest = 7 ; /* slin192 */
992
994
int max_codec_index = 0 , curlen = 0 ;
993
995
struct ast_str * out = ast_str_create (1024 );
@@ -1056,7 +1058,16 @@ static char *handle_show_translation_table(struct ast_cli_args *a)
1056
1058
1057
1059
if (x >= 0 && y >= 0 && matrix_get (x , y )-> step ) {
1058
1060
/* Actual codec output */
1059
- ast_str_append (& out , 0 , "%*u" , curlen + 1 , (matrix_get (x , y )-> table_cost /100 ));
1061
+ if (a -> argv [3 ] && !strcasecmp (a -> argv [3 ], "comp" )) {
1062
+ compCost = matrix_get (x , y )-> comp_cost ;
1063
+ if (compCost == 0 || compCost == 999999 ) {
1064
+ ast_str_append (& out , 0 , "%*s" , curlen + 1 , "-" );
1065
+ } else {
1066
+ ast_str_append (& out , 0 , "%*u" , curlen + 1 , compCost );
1067
+ }
1068
+ } else {
1069
+ ast_str_append (& out , 0 , "%*u" , curlen + 1 , (matrix_get (x , y )-> table_cost / 100 ));
1070
+ }
1060
1071
} else if (i == 0 && k > 0 ) {
1061
1072
/* Top row - use a dynamic size */
1062
1073
if (!strcmp (col -> name , "slin" ) ||
@@ -1163,22 +1174,28 @@ static char *handle_show_translation_path(struct ast_cli_args *a, const char *co
1163
1174
1164
1175
static char * handle_cli_core_show_translation (struct ast_cli_entry * e , int cmd , struct ast_cli_args * a )
1165
1176
{
1166
- static const char * const option [] = { "recalc" , "paths" , NULL };
1177
+ static const char * const option [] = { "recalc" , "paths" , "comp" , NULL };
1167
1178
1168
1179
switch (cmd ) {
1169
1180
case CLI_INIT :
1170
1181
e -> command = "core show translation" ;
1171
1182
e -> usage =
1172
- "Usage: 'core show translation' can be used in two ways.\n"
1173
- " 1. 'core show translation [recalc [<recalc seconds>]] \n"
1183
+ "Usage: 'core show translation' can be used in three ways.\n"
1184
+ " 1. 'core show translation [recalc [<recalc seconds>]\n"
1174
1185
" Displays known codec translators and the cost associated\n"
1175
1186
" with each conversion. If the argument 'recalc' is supplied along\n"
1176
1187
" with optional number of seconds to test a new test will be performed\n"
1177
1188
" as the chart is being displayed.\n"
1178
1189
" 2. 'core show translation paths [codec [sample_rate]]'\n"
1179
1190
" This will display all the translation paths associated with a codec.\n"
1180
1191
" If a codec has multiple sample rates, the sample rate must be\n"
1181
- " provided as well.\n" ;
1192
+ " provided as well.\n"
1193
+ " 3. 'core show translation comp [<recalc seconds>]'\n"
1194
+ " Displays known codec translators and the cost associated\n"
1195
+ " with each conversion. If the argument 'recalc' is supplied along\n"
1196
+ " with optional number of seconds to test a new test will be performed\n"
1197
+ " as the chart is being displayed. The resulting numbers in the table\n"
1198
+ " give the actual computational costs in microseconds.\n" ;
1182
1199
return NULL ;
1183
1200
case CLI_GENERATE :
1184
1201
if (a -> pos == 3 ) {
@@ -1203,7 +1220,7 @@ static char *handle_cli_core_show_translation(struct ast_cli_entry *e, int cmd,
1203
1220
return CLI_FAILURE ;
1204
1221
}
1205
1222
return handle_show_translation_path (a , a -> argv [4 ], sample_rate );
1206
- } else if (a -> argv [3 ] && !strcasecmp (a -> argv [3 ], option [0 ])) { /* recalc and then fall through to show table */
1223
+ } else if (a -> argv [3 ] && ( !strcasecmp (a -> argv [3 ], option [0 ]) || ! strcasecmp ( a -> argv [ 3 ], option [ 2 ]) )) { /* recalc and then fall through to show table */
1207
1224
handle_cli_recalc (a );
1208
1225
} else if (a -> argc > 3 ) { /* wrong input */
1209
1226
return CLI_SHOWUSAGE ;
0 commit comments