Asterisk - The Open Source Telephony Project  GIT-master-1f78ee9
Data Structures | Macros | Enumerations | Functions
translate.h File Reference

Support for translation of data formats. translate.c. More...

#include "asterisk/frame.h"
#include "asterisk/plc.h"
#include "asterisk/linkedlists.h"
#include "asterisk/format_cap.h"
#include "asterisk/format_cache.h"

Go to the source code of this file.

Data Structures

struct  ast_trans_pvt
 Default structure for translators, with the basic fields and buffers, all allocated as part of the same chunk of memory. The buffer is preceded by AST_FRIENDLY_OFFSET bytes in front of the user portion. 'buf' points right after this space. More...
 
struct  ast_translator
 Descriptor of a translator. More...
 

Macros

#define ast_register_translator(t)   __ast_register_translator(t, AST_MODULE_SELF)
 See __ast_register_translator() More...
 

Enumerations

enum  ast_trans_cost_table {
  AST_TRANS_COST_LL_LL_ORIGSAMP = 400000, AST_TRANS_COST_LL_LY_ORIGSAMP = 600000, AST_TRANS_COST_LL_LL_UPSAMP = 800000, AST_TRANS_COST_LL_LY_UPSAMP = 825000,
  AST_TRANS_COST_LL_LL_DOWNSAMP = 850000, AST_TRANS_COST_LL_LY_DOWNSAMP = 875000, AST_TRANS_COST_LL_UNKNOWN = 885000, AST_TRANS_COST_LY_LL_ORIGSAMP = 900000,
  AST_TRANS_COST_LY_LY_ORIGSAMP = 915000, AST_TRANS_COST_LY_LL_UPSAMP = 930000, AST_TRANS_COST_LY_LY_UPSAMP = 945000, AST_TRANS_COST_LY_LL_DOWNSAMP = 960000,
  AST_TRANS_COST_LY_LY_DOWNSAMP = 975000, AST_TRANS_COST_LY_UNKNOWN = 985000
}
 Translator Cost Table definition. More...
 

Functions

int __ast_register_translator (struct ast_translator *t, struct ast_module *module)
 Register a translator This registers a codec translator with asterisk. More...
 
struct ast_frameast_trans_frameout (struct ast_trans_pvt *pvt, int datalen, int samples)
 generic frameout function More...
 
struct ast_frameast_translate (struct ast_trans_pvt *tr, struct ast_frame *f, int consume)
 translates one or more frames Apply an input frame into the translator and receive zero or one output frames. Consume determines whether the original frame should be freed. In case the frame type is AST_FRAME_RTCP, the frame is not translated but passed to the translator codecs via the feedback callback, and a pointer to ast_null_frame is returned after that. More...
 
void ast_translate_available_formats (struct ast_format_cap *dest, struct ast_format_cap *src, struct ast_format_cap *result)
 Find available formats. More...
 
int ast_translate_init (void)
 Initialize the translation matrix and index to format conversion table. More...
 
unsigned int ast_translate_path_steps (struct ast_format *dest, struct ast_format *src)
 Returns the number of steps required to convert from 'src' to 'dest'. More...
 
const char * ast_translate_path_to_str (struct ast_trans_pvt *t, struct ast_str **str)
 Puts a string representation of the translation path into outbuf. More...
 
void ast_translator_activate (struct ast_translator *t)
 Activate a previously deactivated translator. More...
 
int ast_translator_best_choice (struct ast_format_cap *dst_cap, struct ast_format_cap *src_cap, struct ast_format **dst_fmt_out, struct ast_format **src_fmt_out)
 Chooses the best translation path. More...
 
struct ast_trans_pvtast_translator_build_path (struct ast_format *dest, struct ast_format *source)
 Builds a translator path Build a path (possibly NULL) from source to dest. More...
 
void ast_translator_deactivate (struct ast_translator *t)
 Deactivate a translator. More...
 
void ast_translator_free_path (struct ast_trans_pvt *tr)
 Frees a translator path Frees the given translator path structure. More...
 
int ast_unregister_translator (struct ast_translator *t)
 Unregister a translator Unregisters the given tranlator. More...
 

Detailed Description

Support for translation of data formats. translate.c.

Definition in file translate.h.

Macro Definition Documentation

◆ ast_register_translator

#define ast_register_translator (   t)    __ast_register_translator(t, AST_MODULE_SELF)

See __ast_register_translator()

Definition at line 257 of file translate.h.

Referenced by load_module(), and register_translator().

Enumeration Type Documentation

◆ ast_trans_cost_table

Translator Cost Table definition.

Note
The defined values in this table must be used to set the translator's table_cost value.
The cost value of the first two values must always add up to be greater than the largest value defined in this table. This is done to guarantee a direct translation will always have precedence over a multi step translation.

This table is built in a way that allows translation paths to be built that guarantee the best possible balance between performance and quality. With this table direct translation paths between two formats will always take precedence over multi step paths, lossless intermediate steps will always be chosen over lossy intermediate steps, and preservation of sample rate across the translation will always have precedence over a path that involves any re-sampling.

Enumerator
AST_TRANS_COST_LL_LL_ORIGSAMP 

[lossless -> lossless] original sampling

AST_TRANS_COST_LL_LY_ORIGSAMP 

[lossless -> lossy] original sampling

AST_TRANS_COST_LL_LL_UPSAMP 

[lossless -> lossless] up sample

AST_TRANS_COST_LL_LY_UPSAMP 

[lossless -> lossy] up sample

AST_TRANS_COST_LL_LL_DOWNSAMP 

[lossless -> lossless] down sample

AST_TRANS_COST_LL_LY_DOWNSAMP 

[lossless -> lossy] down sample

AST_TRANS_COST_LL_UNKNOWN 

[lossless -> unknown] unknown. This value is for a lossless source translation with an unknown destination and or sample rate conversion.

AST_TRANS_COST_LY_LL_ORIGSAMP 

[lossy -> lossless] original sampling

AST_TRANS_COST_LY_LY_ORIGSAMP 

[lossy -> lossy] original sampling

AST_TRANS_COST_LY_LL_UPSAMP 

[lossy -> lossless] up sample

AST_TRANS_COST_LY_LY_UPSAMP 

[lossy -> lossy] up sample

AST_TRANS_COST_LY_LL_DOWNSAMP 

[lossy -> lossless] down sample

AST_TRANS_COST_LY_LY_DOWNSAMP 

[lossy -> lossy] down sample

AST_TRANS_COST_LY_UNKNOWN 

[lossy -> unknown] unknown. This value is for a lossy source translation with an unknown destination and or sample rate conversion.

Definition at line 61 of file translate.h.

61  {
62 
63  /* Lossless Source Translation Costs */
64 
65  /*! [lossless -> lossless] original sampling */
67  /*! [lossless -> lossy] original sampling */
69 
70  /*! [lossless -> lossless] up sample */
72  /*! [lossless -> lossy] up sample */
74 
75  /*! [lossless -> lossless] down sample */
77  /*! [lossless -> lossy] down sample */
79 
80  /*! [lossless -> unknown] unknown.
81  * This value is for a lossless source translation
82  * with an unknown destination and or sample rate conversion. */
84 
85  /* Lossy Source Translation Costs */
86 
87  /*! [lossy -> lossless] original sampling */
89  /*! [lossy -> lossy] original sampling */
91 
92  /*! [lossy -> lossless] up sample */
94  /*! [lossy -> lossy] up sample */
96 
97  /*! [lossy -> lossless] down sample */
99  /*! [lossy -> lossy] down sample */
101 
102  /*! [lossy -> unknown] unknown.
103  * This value is for a lossy source translation
104  * with an unknown destination and or sample rate conversion. */
105  AST_TRANS_COST_LY_UNKNOWN = 985000,
106 
107 };

Function Documentation

◆ __ast_register_translator()

int __ast_register_translator ( struct ast_translator t,
struct ast_module mod 
)

Register a translator This registers a codec translator with asterisk.

Parameters
tpopulated ast_translator structure
modmodule handle to the module that owns this translator
Returns
0 on success, -1 on failure

Register a translator This registers a codec translator with asterisk.

Definition at line 1214 of file translate.c.

References a, ast_translator::active, add_codec2index(), ao2_cleanup, ast_assert, ast_codec_get(), ast_log, AST_RWLIST_INSERT_BEFORE_CURRENT, AST_RWLIST_INSERT_HEAD, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, b, ast_translator::buf_size, codec2index(), COLOR_BLACK, COLOR_MAGENTA, ast_translator::comp_cost, cur_max_index, default_frameout(), ast_translator::dst_codec, ast_translator::dst_fmt_index, ast_translator::frameout, generate_computational_cost(), generate_table_cost(), LOG_WARNING, matrix_rebuild(), matrix_resize(), ast_translator::module, ast_codec::name, ast_translator::name, NULL, RAII_VAR, ast_codec::sample_rate, ast_translator::src_codec, ast_translator::src_fmt_index, ast_translator::table_cost, term_color(), tmp(), and ast_codec::type.

1215 {
1216  struct ast_translator *u;
1217  char tmp[80];
1220 
1222  if (!src_codec) {
1223  ast_assert(0);
1224  ast_log(LOG_WARNING, "Failed to register translator: unknown source codec %s\n", t->src_codec.name);
1225  return -1;
1226  }
1227 
1229  if (!dst_codec) {
1230  ast_log(LOG_WARNING, "Failed to register translator: unknown destination codec %s\n", t->dst_codec.name);
1231  return -1;
1232  }
1233 
1235  if (matrix_resize(0)) {
1236  ast_log(LOG_WARNING, "Translator matrix can not represent any more translators. Out of resources.\n");
1237  return -1;
1238  }
1241  }
1242 
1243  if (!mod) {
1244  ast_log(LOG_WARNING, "Missing module pointer, you need to supply one\n");
1245  return -1;
1246  }
1247 
1248  if (!t->buf_size) {
1249  ast_log(LOG_WARNING, "empty buf size, you need to supply one\n");
1250  return -1;
1251  }
1253  ast_log(LOG_WARNING, "Table cost could not be generated for %s, "
1254  "Please set table_cost variable on translator.\n", t->name);
1255  return -1;
1256  }
1257 
1258  t->module = mod;
1261  t->active = 1;
1262 
1263  if (t->src_fmt_index < 0 || t->dst_fmt_index < 0) {
1264  ast_log(LOG_WARNING, "Invalid translator path: (%s codec is not valid)\n", t->src_fmt_index < 0 ? "starting" : "ending");
1265  return -1;
1266  }
1267  if (t->src_fmt_index >= cur_max_index) {
1268  ast_log(LOG_WARNING, "Source codec %s is larger than cur_max_index\n", t->src_codec.name);
1269  return -1;
1270  }
1271 
1272  if (t->dst_fmt_index >= cur_max_index) {
1273  ast_log(LOG_WARNING, "Destination codec %s is larger than cur_max_index\n", t->dst_codec.name);
1274  return -1;
1275  }
1276 
1277  if (t->buf_size) {
1278  /*
1279  * Align buf_size properly, rounding up to the machine-specific
1280  * alignment for pointers.
1281  */
1282  struct _test_align { void *a, *b; } p;
1283  int align = (char *)&p.b - (char *)&p.a;
1284 
1285  t->buf_size = ((t->buf_size + align - 1) / align) * align;
1286  }
1287 
1288  if (t->frameout == NULL) {
1290  }
1291 
1293 
1294  ast_verb(2, "Registered translator '%s' from codec %s to %s, table cost, %d, computational cost %d\n",
1295  term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)),
1296  t->src_codec.name, t->dst_codec.name, t->table_cost, t->comp_cost);
1297 
1299 
1300  /* find any existing translators that provide this same srcfmt/dstfmt,
1301  and put this one in order based on computational cost */
1303  if ((u->src_fmt_index == t->src_fmt_index) &&
1304  (u->dst_fmt_index == t->dst_fmt_index) &&
1305  (u->comp_cost > t->comp_cost)) {
1307  t = NULL;
1308  break;
1309  }
1310  }
1312 
1313  /* if no existing translator was found for this codec combination,
1314  add it to the beginning of the list */
1315  if (t) {
1317  }
1318 
1319  matrix_rebuild(0);
1320 
1322 
1323  return 0;
1324 }
const char * name
Name for this codec.
Definition: codec.h:46
static int matrix_resize(int init)
Definition: translate.c:194
static void matrix_rebuild(int samples)
rebuild a translation matrix.
Definition: translate.c:818
Descriptor of a translator.
Definition: translate.h:137
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
static struct ast_frame * default_frameout(struct ast_trans_pvt *pvt)
Definition: translate.c:462
#define ast_assert(a)
Definition: utils.h:650
static int add_codec2index(struct ast_codec *codec)
Definition: translate.c:147
struct ast_codec * ast_codec_get(const char *name, enum ast_media_type type, unsigned int sample_rate)
Retrieve a codec given a name, type, and sample rate.
Definition: codec.c:326
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:455
struct ast_module * module
Definition: translate.h:187
#define AST_RWLIST_INSERT_HEAD
Definition: linkedlists.h:717
#define ast_log
Definition: astobj2.c:42
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:851
#define AST_RWLIST_INSERT_BEFORE_CURRENT
Definition: linkedlists.h:609
int buf_size
size of outbuf, in bytes. Mandatory. The wrapper code will also allocate an AST_FRIENDLY_OFFSET space...
Definition: translate.h:182
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:544
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
Definition: term.c:184
#define COLOR_BLACK
Definition: term.h:47
the list of translators
Definition: codec_dahdi.c:281
struct ast_codec dst_codec
Definition: translate.h:140
static int codec2index(struct ast_codec *codec)
Definition: translate.c:124
struct ast_codec src_codec
Definition: translate.h:139
unsigned int sample_rate
Sample rate (number of samples carried in a second)
Definition: codec.h:52
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
struct ast_frame *(* frameout)(struct ast_trans_pvt *pvt)
Definition: translate.h:158
static void generate_computational_cost(struct ast_translator *t, int seconds)
Definition: translate.c:684
enum ast_media_type type
Type of media this codec contains.
Definition: codec.h:50
static struct test_val b
static int cur_max_index
Definition: translate.c:94
static int generate_table_cost(struct ast_codec *src, struct ast_codec *dst)
Definition: translate.c:762
Represents a media codec within Asterisk.
Definition: codec.h:42
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:616
char name[80]
Definition: translate.h:138
#define COLOR_MAGENTA
Definition: term.h:57
static struct test_val a

◆ ast_trans_frameout()

struct ast_frame* ast_trans_frameout ( struct ast_trans_pvt pvt,
int  datalen,
int  samples 
)

generic frameout function

generic frameout function

Definition at line 432 of file translate.c.

References ast_frisolate, ast_trans_pvt::c, ast_frame::data, ast_frame::datalen, ast_trans_pvt::datalen, ast_trans_pvt::f, NULL, ast_trans_pvt::outbuf, ast_frame::ptr, ast_frame::samples, and ast_trans_pvt::samples.

Referenced by default_frameout(), lintoadpcm_frameout(), lintocodec2_frameout(), lintogsm_frameout(), lintoilbc_frameout(), lintolpc10_frameout(), and lintospeex_frameout().

434 {
435  struct ast_frame *f = &pvt->f;
436 
437  if (samples) {
438  f->samples = samples;
439  } else {
440  if (pvt->samples == 0) {
441  return NULL;
442  }
443  f->samples = pvt->samples;
444  pvt->samples = 0;
445  }
446  if (datalen) {
447  f->datalen = datalen;
448  f->data.ptr = pvt->outbuf.c;
449  } else {
450  f->datalen = pvt->datalen;
451  if (!f->datalen) {
452  f->data.ptr = NULL;
453  } else {
454  f->data.ptr = pvt->outbuf.c;
455  }
456  pvt->datalen = 0;
457  }
458 
459  return ast_frisolate(f);
460 }
int datalen
actual space used in outbuf
Definition: translate.h:218
struct ast_frame f
Definition: translate.h:215
#define NULL
Definition: resample.c:96
union ast_frame::@255 data
union ast_trans_pvt::@319 outbuf
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
Data structure associated with a single frame of data.

◆ ast_translate()

struct ast_frame* ast_translate ( struct ast_trans_pvt path,
struct ast_frame f,
int  consume 
)

translates one or more frames Apply an input frame into the translator and receive zero or one output frames. Consume determines whether the original frame should be freed. In case the frame type is AST_FRAME_RTCP, the frame is not translated but passed to the translator codecs via the feedback callback, and a pointer to ast_null_frame is returned after that.

Parameters
pathtr translator structure to use for translation
fframe to translate
consumeWhether or not to free the original frame
Returns
an ast_frame of the new translation format on success, NULL on failure

translates one or more frames Apply an input frame into the translator and receive zero or one output frames. Consume determines whether the original frame should be freed. In case the frame type is AST_FRAME_RTCP, the frame is not translated but passed to the translator codecs via the feedback callback, and a pointer to ast_null_frame is returned after that.

Definition at line 559 of file translate.c.

References ast_clear_flag, ast_debug, ast_format_get_sample_rate(), AST_FRAME_CNG, AST_FRAME_RTCP, AST_FRFLAG_HAS_TIMING_INFO, ast_frfree, AST_LIST_NEXT, ast_null_frame, ast_samp2tv(), ast_set2_flag, ast_test_flag, ast_tv(), ast_tvadd(), ast_tveq(), ast_tvnow(), ast_tvsub(), ast_tvzero(), ast_frame::delivery, ast_translator::feedback, ast_frame_subclass::format, framein(), ast_frame::frametype, generate_interpolated_slin(), ast_frame::len, len(), ast_trans_pvt::next, ast_trans_pvt::nextin, ast_trans_pvt::nextout, out, ast_frame::samples, ast_frame::seqno, ast_frame::subclass, ast_trans_pvt::t, and ast_frame::ts.

Referenced by __ast_read(), ast_slinfactory_feed(), ast_write_stream(), ast_writestream(), audiohook_list_translate_to_native(), audiohook_list_translate_to_slin(), audiohook_read_frame_helper(), conf_run(), fax_gateway_framehook(), and softmix_process_write_audio().

560 {
561  struct ast_trans_pvt *p = path;
562  struct ast_frame *out;
563  struct timeval delivery;
564  int has_timing_info;
565  long ts;
566  long len;
567  int seqno;
568 
569  if (f->frametype == AST_FRAME_RTCP) {
570  /* Just pass the feedback to the right callback, if it exists.
571  * This "translation" does nothing so return a null frame. */
572  struct ast_trans_pvt *tp;
573  for (tp = p; tp; tp = tp->next) {
574  if (tp->t->feedback)
575  tp->t->feedback(tp, f);
576  }
577  return &ast_null_frame;
578  }
579 
580  has_timing_info = ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO);
581  ts = f->ts;
582  len = f->len;
583  seqno = f->seqno;
584 
585  if (!ast_tvzero(f->delivery)) {
586  if (!ast_tvzero(path->nextin)) {
587  /* Make sure this is in line with what we were expecting */
588  if (!ast_tveq(path->nextin, f->delivery)) {
589  /* The time has changed between what we expected and this
590  most recent time on the new packet. If we have a
591  valid prediction adjust our output time appropriately */
592  if (!ast_tvzero(path->nextout)) {
593  path->nextout = ast_tvadd(path->nextout,
594  ast_tvsub(f->delivery, path->nextin));
595  }
596  path->nextin = f->delivery;
597  }
598  } else {
599  /* This is our first pass. Make sure the timing looks good */
600  path->nextin = f->delivery;
601  path->nextout = f->delivery;
602  }
603  /* Predict next incoming sample */
604  path->nextin = ast_tvadd(path->nextin, ast_samp2tv(
606  }
607  delivery = f->delivery;
608  for (out = f; out && p ; p = p->next) {
609  struct ast_frame *current = out;
610 
611  do {
612  framein(p, current);
613  current = AST_LIST_NEXT(current, frame_list);
614  } while (current);
615  if (out != f) {
616  ast_frfree(out);
617  }
618  out = p->t->frameout(p);
619  }
620 
621  if (!out) {
622  out = generate_interpolated_slin(path, f);
623  }
624 
625  if (out) {
626  /* we have a frame, play with times */
627  if (!ast_tvzero(delivery)) {
628  struct ast_frame *current = out;
629 
630  do {
631  /* Regenerate prediction after a discontinuity */
632  if (ast_tvzero(path->nextout)) {
633  path->nextout = ast_tvnow();
634  }
635 
636  /* Use next predicted outgoing timestamp */
637  current->delivery = path->nextout;
638 
639  /* Invalidate prediction if we're entering a silence period */
640  if (current->frametype == AST_FRAME_CNG) {
641  path->nextout = ast_tv(0, 0);
642  /* Predict next outgoing timestamp from samples in this
643  frame. */
644  } else {
645  path->nextout = ast_tvadd(path->nextout, ast_samp2tv(
646  current->samples, ast_format_get_sample_rate(current->subclass.format)));
647  }
648 
649  if (f->samples != current->samples && ast_test_flag(current, AST_FRFLAG_HAS_TIMING_INFO)) {
650  ast_debug(4, "Sample size different %d vs %d\n", f->samples, current->samples);
652  }
653  current = AST_LIST_NEXT(current, frame_list);
654  } while (current);
655  } else {
656  out->delivery = ast_tv(0, 0);
657  ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO);
658  if (has_timing_info) {
659  out->ts = ts;
660  out->len = len;
661  out->seqno = seqno;
662  }
663  /* Invalidate prediction if we're entering a silence period */
664  if (out->frametype == AST_FRAME_CNG) {
665  path->nextout = ast_tv(0, 0);
666  }
667  }
668  }
669  if (consume) {
670  ast_frfree(f);
671  }
672  return out;
673 }
#define ast_set2_flag(p, value, flag)
Definition: utils.h:94
#define ast_test_flag(p, flag)
Definition: utils.h:63
int ast_tveq(struct timeval _a, struct timeval _b)
Returns true if the two struct timeval arguments are equal.
Definition: time.h:138
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:108
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
struct ast_trans_pvt * next
Definition: translate.h:227
struct timeval nextin
Definition: translate.h:228
struct ast_frame_subclass subclass
static int framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
framein wrapper, deals with bound checks.
Definition: translate.c:396
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
Definition: time.h:238
void(* feedback)(struct ast_trans_pvt *pvt, struct ast_frame *feedback)
Definition: translate.h:162
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:213
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct timeval nextout
Definition: translate.h:229
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2283
#define ast_clear_flag(p, flag)
Definition: utils.h:77
struct timeval delivery
struct ast_frame ast_null_frame
Definition: main/frame.c:79
FILE * out
Definition: utils/frame.c:33
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
Definition: time.h:226
#define ast_frfree(fr)
unsigned int ast_format_get_sample_rate(const struct ast_format *format)
Get the sample rate of a media format.
Definition: format.c:379
Data structure associated with a single frame of data.
struct ast_translator * t
Definition: translate.h:214
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
Definition: extconf.c:2298
enum ast_frame_type frametype
struct ast_format * format
static struct ast_frame * generate_interpolated_slin(struct ast_trans_pvt *p, struct ast_frame *f)
Definition: translate.c:530

◆ ast_translate_available_formats()

void ast_translate_available_formats ( struct ast_format_cap dest,
struct ast_format_cap src,
struct ast_format_cap result 
)

Find available formats.

Parameters
destpossible destination formats
srcsource formats
resultcapabilities structure to store available formats in
Returns
the destination formats that are available in the source or translatable

The result will include all formats from 'dest' that are either present in 'src' or translatable from a format present in 'src'.

Note
Only a single audio format and a single video format can be present in 'src', or the function will produce unexpected results.

Definition at line 1553 of file translate.c.

References ao2_ref, ast_format_cap_append, ast_format_cap_count(), ast_format_cap_get_compatible_format(), ast_format_cap_get_format(), AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_VIDEO, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, and check_translation_path().

Referenced by ast_rtp_instance_available_formats().

1554 {
1555  struct ast_format *cur_dest, *cur_src;
1556  int index;
1557 
1558  for (index = 0; index < ast_format_cap_count(dest); ++index) {
1559  if (!(cur_dest = ast_format_cap_get_format(dest, index))) {
1560  continue;
1561  }
1562 
1563  /* We give preference to a joint format structure if possible */
1564  if ((cur_src = ast_format_cap_get_compatible_format(src, cur_dest))) {
1565  ast_format_cap_append(result, cur_src, 0);
1566  ao2_ref(cur_src, -1);
1567  } else {
1568  /* Otherwise we just use the destination format */
1569  ast_format_cap_append(result, cur_dest, 0);
1570  }
1571  ao2_ref(cur_dest, -1);
1572  }
1573 
1574  /* if we don't have a source format, we just have to try all
1575  possible destination formats */
1576  if (!src) {
1577  return;
1578  }
1579 
1580  for (index = 0; index < ast_format_cap_count(src); ++index) {
1581  if (!(cur_src = ast_format_cap_get_format(src, index))) {
1582  continue;
1583  }
1584 
1586  check_translation_path(dest, src, result,
1587  cur_src, AST_MEDIA_TYPE_AUDIO);
1588  check_translation_path(dest, src, result,
1589  cur_src, AST_MEDIA_TYPE_VIDEO);
1591  ao2_ref(cur_src, -1);
1592  }
1593 }
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Definition of a media format.
Definition: format.c:43
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition: format_cap.c:395
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_format * ast_format_cap_get_compatible_format(const struct ast_format_cap *cap, const struct ast_format *format)
Find if input ast_format is within the capabilities of the ast_format_cap object then return the comp...
Definition: format_cap.c:548
static void check_translation_path(struct ast_format_cap *dest, struct ast_format_cap *src, struct ast_format_cap *result, struct ast_format *src_fmt, enum ast_media_type type)
Definition: translate.c:1507
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
the list of translators
Definition: codec_dahdi.c:281
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400

◆ ast_translate_init()

int ast_translate_init ( void  )

Initialize the translation matrix and index to format conversion table.

Return values
0on success
-1on failure

Definition at line 1612 of file translate.c.

References ARRAY_LEN, ast_cli_register_multiple, ast_register_cleanup(), ast_rwlock_init, matrix_resize(), and translate_shutdown().

Referenced by asterisk_daemon().

1613 {
1614  int res = 0;
1616  res = matrix_resize(1);
1619  return res;
1620 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static int matrix_resize(int init)
Definition: translate.c:194
static struct ast_cli_entry cli_translate[]
Definition: translate.c:1209
static ast_rwlock_t tablelock
Definition: translate.c:86
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ast_rwlock_init(rwlock)
wrapper for rwlock with tracking enabled
Definition: lock.h:222
static void translate_shutdown(void)
Definition: translate.c:1595

◆ ast_translate_path_steps()

unsigned int ast_translate_path_steps ( struct ast_format dest,
struct ast_format src 
)

Returns the number of steps required to convert from 'src' to 'dest'.

Parameters
destdestination format
srcsource format
Returns
the number of translation steps required, or -1 if no path is available

Definition at line 1485 of file translate.c.

References ast_log, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, format2index(), LOG_WARNING, matrix_get(), translator_path::multistep, and translator_path::step.

Referenced by ast_channel_make_compatible_helper().

1486 {
1487  unsigned int res = -1;
1488  /* convert bitwise format numbers into array indices */
1489  int src = format2index(src_format);
1490  int dest = format2index(dst_format);
1491 
1492  if (src < 0 || dest < 0) {
1493  ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", src < 0 ? "starting" : "ending");
1494  return -1;
1495  }
1497 
1498  if (matrix_get(src, dest)->step) {
1499  res = matrix_get(src, dest)->multistep + 1;
1500  }
1501 
1503 
1504  return res;
1505 }
#define LOG_WARNING
Definition: logger.h:274
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
static int format2index(struct ast_format *format)
Definition: translate.c:133
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define ast_log
Definition: astobj2.c:42
static struct translator_path * matrix_get(unsigned int x, unsigned int y)
Definition: translate.c:282
the list of translators
Definition: codec_dahdi.c:281
uint8_t multistep
Definition: translate.c:62

◆ ast_translate_path_to_str()

const char* ast_translate_path_to_str ( struct ast_trans_pvt t,
struct ast_str **  str 
)

Puts a string representation of the translation path into outbuf.

Parameters
ttranslator structure containing the translation path
strast_str output buffer
Return values
onsuccess pointer to beginning of outbuf. on failure "".

Definition at line 922 of file translate.c.

References ast_str_append(), ast_str_buffer(), ast_str_reset(), codec_append_name(), ast_translator::dst_codec, ast_trans_pvt::next, ast_translator::src_codec, and ast_trans_pvt::t.

Referenced by chan_pjsip_write_stream(), generate_status(), handle_showchan(), and serialize_showchan().

923 {
924  if (!p || !p->t) {
925  return "";
926  }
927 
928  ast_str_reset(*str);
929  codec_append_name(&p->t->src_codec, str);
930  while (p) {
931  ast_str_append(str, 0, "->");
932  codec_append_name(&p->t->dst_codec, str);
933  p = p->next;
934  }
935 
936  return ast_str_buffer(*str);
937 }
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1091
static void codec_append_name(const struct ast_codec *codec, struct ast_str **buf)
Definition: translate.c:913
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition: strings.h:653

◆ ast_translator_activate()

void ast_translator_activate ( struct ast_translator t)

Activate a previously deactivated translator.

Parameters
ttranslator to activate
Returns
nothing

Enables the specified translator for use.

Definition at line 1355 of file translate.c.

References ast_translator::active, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and matrix_rebuild().

1356 {
1358  t->active = 1;
1359  matrix_rebuild(0);
1361 }
static void matrix_rebuild(int samples)
rebuild a translation matrix.
Definition: translate.c:818
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
the list of translators
Definition: codec_dahdi.c:281

◆ ast_translator_best_choice()

int ast_translator_best_choice ( struct ast_format_cap dst_cap,
struct ast_format_cap src_cap,
struct ast_format **  dst_fmt_out,
struct ast_format **  src_fmt_out 
)

Chooses the best translation path.

Given a list of sources, and a designed destination format, which should I choose?

Parameters
dst_capdestination capabilities
src_capsource capabilities
dst_fmt_outdestination format chosen out of destination capabilities
src_fmt_outsource format chosen out of source capabilities
Returns
Returns 0 on success, -1 if no path could be found.
Note
dst_cap and src_cap are not mondified.

Chooses the best translation path.

Definition at line 1379 of file translate.c.

References ao2_cleanup, ao2_ref, ao2_replace, ast_format_cap_alloc, ast_format_cap_count(), ast_format_cap_empty(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_compatible(), ast_format_cap_get_format(), ast_format_get_sample_rate(), ast_format_get_type(), ast_log, AST_MEDIA_TYPE_AUDIO, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, format2index(), format_sample_rate_absdiff, LOG_ERROR, matrix_get(), translator_path::multistep, NULL, RAII_VAR, translator_path::step, and translator_path::table_cost.

Referenced by ast_channel_make_compatible_helper(), iax2_request(), local_request_with_stream_topology(), request_channel(), and set_format().

1383 {
1384  unsigned int besttablecost = INT_MAX;
1385  unsigned int beststeps = INT_MAX;
1386  struct ast_format *fmt;
1387  struct ast_format *dst;
1388  struct ast_format *src;
1389  RAII_VAR(struct ast_format *, best, NULL, ao2_cleanup);
1390  RAII_VAR(struct ast_format *, bestdst, NULL, ao2_cleanup);
1391  struct ast_format_cap *joint_cap;
1392  int i;
1393  int j;
1394 
1395  if (ast_format_cap_empty(dst_cap) || ast_format_cap_empty(src_cap)) {
1396  ast_log(LOG_ERROR, "Cannot determine best translation path since one capability supports no formats\n");
1397  return -1;
1398  }
1399 
1401  if (!joint_cap) {
1402  return -1;
1403  }
1404  ast_format_cap_get_compatible(dst_cap, src_cap, joint_cap);
1405 
1406  for (i = 0; i < ast_format_cap_count(joint_cap); ++i, ao2_cleanup(fmt)) {
1407  fmt = ast_format_cap_get_format(joint_cap, i);
1408  if (!fmt
1410  continue;
1411  }
1412 
1413  if (!best
1415  ao2_replace(best, fmt);
1416  }
1417  }
1418  ao2_ref(joint_cap, -1);
1419 
1420  if (best) {
1421  ao2_replace(*dst_fmt_out, best);
1422  ao2_replace(*src_fmt_out, best);
1423  return 0;
1424  }
1425 
1426  /* need to translate */
1428  for (i = 0; i < ast_format_cap_count(dst_cap); ++i, ao2_cleanup(dst)) {
1429  dst = ast_format_cap_get_format(dst_cap, i);
1430  if (!dst
1432  continue;
1433  }
1434 
1435  for (j = 0; j < ast_format_cap_count(src_cap); ++j, ao2_cleanup(src)) {
1436  int x;
1437  int y;
1438 
1439  src = ast_format_cap_get_format(src_cap, j);
1440  if (!src
1442  continue;
1443  }
1444 
1445  x = format2index(src);
1446  y = format2index(dst);
1447  if (x < 0 || y < 0) {
1448  continue;
1449  }
1450  if (!matrix_get(x, y) || !(matrix_get(x, y)->step)) {
1451  continue;
1452  }
1453  if (matrix_get(x, y)->table_cost < besttablecost
1454  || matrix_get(x, y)->multistep < beststeps) {
1455  /* better than what we have so far */
1456  ao2_replace(best, src);
1457  ao2_replace(bestdst, dst);
1458  besttablecost = matrix_get(x, y)->table_cost;
1459  beststeps = matrix_get(x, y)->multistep;
1460  } else if (matrix_get(x, y)->table_cost == besttablecost
1461  && matrix_get(x, y)->multistep == beststeps) {
1462  unsigned int gap_selected = format_sample_rate_absdiff(best, bestdst);
1463  unsigned int gap_current = format_sample_rate_absdiff(src, dst);
1464 
1465  if (gap_current < gap_selected) {
1466  /* better than what we have so far */
1467  ao2_replace(best, src);
1468  ao2_replace(bestdst, dst);
1469  besttablecost = matrix_get(x, y)->table_cost;
1470  beststeps = matrix_get(x, y)->multistep;
1471  }
1472  }
1473  }
1474  }
1476 
1477  if (!best) {
1478  return -1;
1479  }
1480  ao2_replace(*dst_fmt_out, bestdst);
1481  ao2_replace(*src_fmt_out, best);
1482  return 0;
1483 }
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Definition of a media format.
Definition: format.c:43
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition: format_cap.c:395
#define NULL
Definition: resample.c:96
static int format2index(struct ast_format *format)
Definition: translate.c:133
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define ast_log
Definition: astobj2.c:42
#define format_sample_rate_absdiff(fmt1, fmt2)
Definition: translate.c:1372
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:851
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct translator_path * matrix_get(unsigned int x, unsigned int y)
Definition: translate.c:282
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
the list of translators
Definition: codec_dahdi.c:281
#define LOG_ERROR
Definition: logger.h:285
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
uint32_t table_cost
Definition: translate.c:61
uint8_t multistep
Definition: translate.c:62
#define ao2_replace(dst, src)
Definition: astobj2.h:517
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
unsigned int ast_format_get_sample_rate(const struct ast_format *format)
Get the sample rate of a media format.
Definition: format.c:379
int ast_format_cap_empty(const struct ast_format_cap *cap)
Determine if a format cap has no formats in it.
Definition: format_cap.c:746
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400
int ast_format_cap_get_compatible(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result)
Find the compatible formats between two capabilities structures.
Definition: format_cap.c:630

◆ ast_translator_build_path()

struct ast_trans_pvt* ast_translator_build_path ( struct ast_format dst,
struct ast_format src 
)

Builds a translator path Build a path (possibly NULL) from source to dest.

Parameters
dstdest destination format
srcsource source format
Returns
ast_trans_pvt on success, NULL on failure

Builds a translator path Build a path (possibly NULL) from source to dest.

Definition at line 479 of file translate.c.

References ast_format_get_name(), ast_format_get_sample_rate(), ast_format_get_type(), ast_log, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_translator_free_path(), ast_tv(), ast_translator::dst_codec, ast_translator::dst_fmt_index, format2index(), LOG_WARNING, matrix_get(), newpvt(), ast_trans_pvt::next, ast_trans_pvt::nextin, ast_trans_pvt::nextout, NULL, ast_codec::sample_rate, translator_path::step, ast_trans_pvt::t, and ast_codec::type.

Referenced by ast_set_read_format_path(), ast_set_write_format_path(), ast_slinfactory_feed(), ast_writestream(), audiohook_list_translate_to_native(), audiohook_list_translate_to_slin(), audiohook_read_frame_helper(), conf_run(), set_format(), softmix_process_write_audio(), and softmix_translate_helper_change_rate().

480 {
481  struct ast_trans_pvt *head = NULL, *tail = NULL;
482  int src_index, dst_index;
483 
484  src_index = format2index(src);
485  dst_index = format2index(dst);
486 
487  if (src_index < 0 || dst_index < 0) {
488  ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", src_index < 0 ? "starting" : "ending");
489  return NULL;
490  }
491 
493 
494  while (src_index != dst_index) {
495  struct ast_trans_pvt *cur;
496  struct ast_format *explicit_dst = NULL;
497  struct ast_translator *t = matrix_get(src_index, dst_index)->step;
498  if (!t) {
499  ast_log(LOG_WARNING, "No translator path from %s to %s\n",
503  return NULL;
504  }
506  explicit_dst = dst;
507  }
508  if (!(cur = newpvt(t, explicit_dst))) {
509  ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n",
513  return NULL;
514  }
515  if (!head) {
516  head = cur;
517  } else {
518  tail->next = cur;
519  }
520  tail = cur;
521  cur->nextin = cur->nextout = ast_tv(0, 0);
522  /* Keep going if this isn't the final destination */
523  src_index = cur->t->dst_fmt_index;
524  }
525 
527  return head;
528 }
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
Descriptor of a translator.
Definition: translate.h:137
#define LOG_WARNING
Definition: logger.h:274
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
Definition of a media format.
Definition: format.c:43
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
struct ast_trans_pvt * next
Definition: translate.h:227
#define NULL
Definition: resample.c:96
struct ast_translator * step
Definition: translate.c:60
struct timeval nextin
Definition: translate.h:228
static int format2index(struct ast_format *format)
Definition: translate.c:133
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
#define ast_log
Definition: astobj2.c:42
void ast_translator_free_path(struct ast_trans_pvt *p)
Frees a translator path Frees the given translator path structure.
Definition: translate.c:469
static struct translator_path * matrix_get(unsigned int x, unsigned int y)
Definition: translate.c:282
static struct ast_trans_pvt * newpvt(struct ast_translator *t, struct ast_format *explicit_dst)
Allocate the descriptor, required outbuf space, and possibly desc.
Definition: translate.c:311
the list of translators
Definition: codec_dahdi.c:281
struct ast_codec dst_codec
Definition: translate.h:140
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:213
struct timeval nextout
Definition: translate.h:229
unsigned int sample_rate
Sample rate (number of samples carried in a second)
Definition: codec.h:52
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
Definition: time.h:226
unsigned int ast_format_get_sample_rate(const struct ast_format *format)
Get the sample rate of a media format.
Definition: format.c:379
enum ast_media_type type
Type of media this codec contains.
Definition: codec.h:50
struct ast_translator * t
Definition: translate.h:214

◆ ast_translator_deactivate()

void ast_translator_deactivate ( struct ast_translator t)

Deactivate a translator.

Parameters
ttranslator to deactivate
Returns
nothing

Disables the specified translator from being used.

Definition at line 1363 of file translate.c.

References ast_translator::active, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and matrix_rebuild().

1364 {
1366  t->active = 0;
1367  matrix_rebuild(0);
1369 }
static void matrix_rebuild(int samples)
rebuild a translation matrix.
Definition: translate.c:818
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
the list of translators
Definition: codec_dahdi.c:281

◆ ast_translator_free_path()

void ast_translator_free_path ( struct ast_trans_pvt tr)

Frees a translator path Frees the given translator path structure.

Parameters
trtranslator path to get rid of

Definition at line 469 of file translate.c.

References destroy(), and ast_trans_pvt::next.

Referenced by ast_audiohook_destroy(), ast_audiohook_detach_list(), ast_channel_destructor(), ast_set_read_format_path(), ast_set_write_format_path(), ast_slinfactory_destroy(), ast_slinfactory_feed(), ast_slinfactory_flush(), ast_translator_build_path(), ast_writestream(), audiohook_list_translate_to_native(), audiohook_list_translate_to_slin(), audiohook_read_frame_helper(), conf_free(), filestream_destructor(), free_translation(), set_format(), softmix_translate_helper_change_rate(), softmix_translate_helper_cleanup(), and softmix_translate_helper_free_entry().

470 {
471  struct ast_trans_pvt *pn = p;
472  while ( (p = pn) ) {
473  pn = p->next;
474  destroy(p);
475  }
476 }
struct ast_trans_pvt * next
Definition: translate.h:227
Default structure for translators, with the basic fields and buffers, all allocated as part of the sa...
Definition: translate.h:213
static void destroy(struct ast_trans_pvt *pvt)
Definition: translate.c:291

◆ ast_unregister_translator()

int ast_unregister_translator ( struct ast_translator t)

Unregister a translator Unregisters the given tranlator.

Parameters
ttranslator to unregister
Returns
0 on success, -1 on failure

Unregister a translator Unregisters the given tranlator.

Definition at line 1327 of file translate.c.

References AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_shutting_down(), ast_verb, COLOR_BLACK, COLOR_MAGENTA, ast_translator::dst_codec, ast_translator::list, matrix_rebuild(), ast_codec::name, ast_translator::name, ast_translator::src_codec, term_color(), and tmp().

Referenced by unload_module(), and unregister_translators().

1328 {
1329  char tmp[80];
1330  struct ast_translator *u;
1331  int found = 0;
1332 
1335  if (u == t) {
1337  ast_verb(2, "Unregistered translator '%s' from codec %s to %s\n",
1338  term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)),
1339  t->src_codec.name, t->dst_codec.name);
1340  found = 1;
1341  break;
1342  }
1343  }
1345 
1346  if (found && !ast_shutting_down()) {
1347  matrix_rebuild(0);
1348  }
1349 
1351 
1352  return (u ? 0 : -1);
1353 }
const char * name
Name for this codec.
Definition: codec.h:46
int ast_shutting_down(void)
Definition: asterisk.c:1834
static void matrix_rebuild(int samples)
rebuild a translation matrix.
Definition: translate.c:818
Descriptor of a translator.
Definition: translate.h:137
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
static int tmp()
Definition: bt_open.c:389
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_verb(level,...)
Definition: logger.h:455
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:569
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:544
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
Definition: term.c:184
#define COLOR_BLACK
Definition: term.h:47
the list of translators
Definition: codec_dahdi.c:281
struct ast_codec dst_codec
Definition: translate.h:140
struct ast_translator::@318 list
struct ast_codec src_codec
Definition: translate.h:139
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:616
char name[80]
Definition: translate.h:138
#define COLOR_MAGENTA
Definition: term.h:57