#include "asterisk/frame.h"
#include "asterisk/plc.h"
#include "asterisk/linkedlists.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... | |
Defines | |
#define | ast_register_translator(t) __ast_register_translator(t, ast_module_info->self) |
See __ast_register_translator(). | |
#define | MAX_AUDIO_FORMAT 47 |
#define | MAX_FORMAT 64 |
Functions | |
int | __ast_register_translator (struct ast_translator *t, struct ast_module *module) |
Register a translator This registers a codec translator with asterisk. | |
ast_frame * | ast_trans_frameout (struct ast_trans_pvt *pvt, int datalen, int samples) |
generic frameout function | |
ast_frame * | ast_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 | |
format_t | ast_translate_available_formats (format_t dest, format_t src) |
Mask off unavailable formats from a format bitmask. | |
unsigned int | ast_translate_path_steps (format_t dest, format_t src) |
Returns the number of steps required to convert from 'src' to 'dest'. | |
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. | |
void | ast_translator_activate (struct ast_translator *t) |
Activate a previously deactivated translator. | |
format_t | ast_translator_best_choice (format_t *dsts, format_t *srcs) |
Chooses the best translation path. | |
ast_trans_pvt * | ast_translator_build_path (format_t dest, format_t source) |
Builds a translator path Build a path (possibly NULL) from source to dest. | |
void | ast_translator_deactivate (struct ast_translator *t) |
Deactivate a translator. | |
void | ast_translator_free_path (struct ast_trans_pvt *tr) |
Frees a translator path Frees the given translator path structure. | |
int | ast_unregister_translator (struct ast_translator *t) |
Unregister a translator Unregisters the given tranlator. |
Definition in file translate.h.
#define ast_register_translator | ( | t | ) | __ast_register_translator(t, ast_module_info->self) |
See __ast_register_translator().
Definition at line 170 of file translate.h.
Referenced by load_module(), and register_translator().
#define MAX_AUDIO_FORMAT 47 |
#define MAX_FORMAT 64 |
Definition at line 28 of file translate.h.
Referenced by __ast_register_translator(), and rebuild_matrix().
int __ast_register_translator | ( | struct ast_translator * | t, | |
struct ast_module * | module | |||
) |
Register a translator This registers a codec translator with asterisk.
t | populated ast_translator structure | |
module | handle to the module that owns this translator |
Definition at line 846 of file translate.c.
References ast_translator::active, ARRAY_LEN, ast_cli_register_multiple(), ast_getformatname(), 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, ast_translator::buf_size, calc_cost(), cli_translate, COLOR_BLACK, COLOR_MAGENTA, ast_translator::cost, default_frameout(), ast_translator::dstfmt, ast_translator::frameout, LOG_WARNING, MAX_FORMAT, ast_translator::module, ast_translator::name, powerof(), rebuild_matrix(), ast_translator::srcfmt, and term_color().
00847 { 00848 static int added_cli = 0; 00849 struct ast_translator *u; 00850 char tmp[80]; 00851 00852 if (!mod) { 00853 ast_log(LOG_WARNING, "Missing module pointer, you need to supply one\n"); 00854 return -1; 00855 } 00856 00857 if (!t->buf_size) { 00858 ast_log(LOG_WARNING, "empty buf size, you need to supply one\n"); 00859 return -1; 00860 } 00861 00862 t->module = mod; 00863 00864 t->srcfmt = powerof(t->srcfmt); 00865 t->dstfmt = powerof(t->dstfmt); 00866 t->active = 1; 00867 00868 if (t->srcfmt == -1 || t->dstfmt == -1) { 00869 ast_log(LOG_WARNING, "Invalid translator path: (%s codec is not valid)\n", t->srcfmt == -1 ? "starting" : "ending"); 00870 return -1; 00871 } 00872 if (t->srcfmt >= MAX_FORMAT) { 00873 ast_log(LOG_WARNING, "Source format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt)); 00874 return -1; 00875 } 00876 00877 if (t->dstfmt >= MAX_FORMAT) { 00878 ast_log(LOG_WARNING, "Destination format %s is larger than MAX_FORMAT\n", ast_getformatname(t->dstfmt)); 00879 return -1; 00880 } 00881 00882 if (t->buf_size) { 00883 /* 00884 * Align buf_size properly, rounding up to the machine-specific 00885 * alignment for pointers. 00886 */ 00887 struct _test_align { void *a, *b; } p; 00888 int align = (char *)&p.b - (char *)&p.a; 00889 00890 t->buf_size = ((t->buf_size + align - 1) / align) * align; 00891 } 00892 00893 if (t->frameout == NULL) 00894 t->frameout = default_frameout; 00895 00896 calc_cost(t, 1); 00897 00898 ast_verb(2, "Registered translator '%s' from format %s to %s, cost %d\n", 00899 term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), 00900 ast_getformatname(1LL << t->srcfmt), ast_getformatname(1LL << t->dstfmt), t->cost); 00901 00902 if (!added_cli) { 00903 ast_cli_register_multiple(cli_translate, ARRAY_LEN(cli_translate)); 00904 added_cli++; 00905 } 00906 00907 AST_RWLIST_WRLOCK(&translators); 00908 00909 /* find any existing translators that provide this same srcfmt/dstfmt, 00910 and put this one in order based on cost */ 00911 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) { 00912 if ((u->srcfmt == t->srcfmt) && 00913 (u->dstfmt == t->dstfmt) && 00914 (u->cost > t->cost)) { 00915 AST_RWLIST_INSERT_BEFORE_CURRENT(t, list); 00916 t = NULL; 00917 break; 00918 } 00919 } 00920 AST_RWLIST_TRAVERSE_SAFE_END; 00921 00922 /* if no existing translator was found for this format combination, 00923 add it to the beginning of the list */ 00924 if (t) 00925 AST_RWLIST_INSERT_HEAD(&translators, t, list); 00926 00927 rebuild_matrix(0); 00928 00929 AST_RWLIST_UNLOCK(&translators); 00930 00931 return 0; 00932 }
struct ast_frame* ast_trans_frameout | ( | struct ast_trans_pvt * | pvt, | |
int | datalen, | |||
int | samples | |||
) |
generic frameout function
Definition at line 235 of file translate.c.
References AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_frisolate(), ast_trans_pvt::c, ast_trans_pvt::datalen, ast_translator::dstfmt, f, ast_trans_pvt::f, ast_translator::name, ast_trans_pvt::outbuf, ast_trans_pvt::samples, and ast_trans_pvt::t.
Referenced by default_frameout(), lintoadpcm_frameout(), lintogsm_frameout(), lintoilbc_frameout(), and lintolpc10_frameout().
00237 { 00238 struct ast_frame *f = &pvt->f; 00239 00240 if (samples) 00241 f->samples = samples; 00242 else { 00243 if (pvt->samples == 0) 00244 return NULL; 00245 f->samples = pvt->samples; 00246 pvt->samples = 0; 00247 } 00248 if (datalen) 00249 f->datalen = datalen; 00250 else { 00251 f->datalen = pvt->datalen; 00252 pvt->datalen = 0; 00253 } 00254 00255 f->frametype = AST_FRAME_VOICE; 00256 f->subclass.codec = 1LL << (pvt->t->dstfmt); 00257 f->mallocd = 0; 00258 f->offset = AST_FRIENDLY_OFFSET; 00259 f->src = pvt->t->name; 00260 f->data.ptr = pvt->outbuf.c; 00261 00262 return ast_frisolate(f); 00263 }
struct ast_frame* ast_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
tr | translator structure to use for translation | |
f | frame to translate | |
consume | Whether or not to free the original frame |
Definition at line 328 of file translate.c.
References ast_format_rate(), AST_FRAME_CNG, AST_FRFLAG_HAS_TIMING_INFO, ast_frfree, ast_samp2tv(), ast_set2_flag, ast_test_flag, ast_tv(), ast_tvadd(), ast_tveq(), ast_tvnow(), ast_tvsub(), ast_tvzero(), ast_frame_subclass::codec, ast_frame::delivery, f, framein(), ast_frame::frametype, len(), ast_frame::len, ast_trans_pvt::next, ast_trans_pvt::nextin, ast_trans_pvt::nextout, ast_frame::samples, ast_frame::seqno, ast_frame::subclass, and ast_frame::ts.
Referenced by __ast_read(), ast_audiohook_read_frame(), ast_slinfactory_feed(), ast_write(), ast_writestream(), audio_audiohook_write_list(), and conf_run().
00329 { 00330 struct ast_trans_pvt *p = path; 00331 struct ast_frame *out = f; 00332 struct timeval delivery; 00333 int has_timing_info; 00334 long ts; 00335 long len; 00336 int seqno; 00337 00338 has_timing_info = ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO); 00339 ts = f->ts; 00340 len = f->len; 00341 seqno = f->seqno; 00342 00343 /* XXX hmmm... check this below */ 00344 if (!ast_tvzero(f->delivery)) { 00345 if (!ast_tvzero(path->nextin)) { 00346 /* Make sure this is in line with what we were expecting */ 00347 if (!ast_tveq(path->nextin, f->delivery)) { 00348 /* The time has changed between what we expected and this 00349 most recent time on the new packet. If we have a 00350 valid prediction adjust our output time appropriately */ 00351 if (!ast_tvzero(path->nextout)) { 00352 path->nextout = ast_tvadd(path->nextout, 00353 ast_tvsub(f->delivery, path->nextin)); 00354 } 00355 path->nextin = f->delivery; 00356 } 00357 } else { 00358 /* This is our first pass. Make sure the timing looks good */ 00359 path->nextin = f->delivery; 00360 path->nextout = f->delivery; 00361 } 00362 /* Predict next incoming sample */ 00363 path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(f->subclass.codec))); 00364 } 00365 delivery = f->delivery; 00366 for ( ; out && p ; p = p->next) { 00367 framein(p, out); 00368 if (out != f) 00369 ast_frfree(out); 00370 out = p->t->frameout(p); 00371 } 00372 if (consume) 00373 ast_frfree(f); 00374 if (out == NULL) 00375 return NULL; 00376 /* we have a frame, play with times */ 00377 if (!ast_tvzero(delivery)) { 00378 /* Regenerate prediction after a discontinuity */ 00379 if (ast_tvzero(path->nextout)) 00380 path->nextout = ast_tvnow(); 00381 00382 /* Use next predicted outgoing timestamp */ 00383 out->delivery = path->nextout; 00384 00385 /* Predict next outgoing timestamp from samples in this 00386 frame. */ 00387 path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass.codec))); 00388 } else { 00389 out->delivery = ast_tv(0, 0); 00390 ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO); 00391 if (has_timing_info) { 00392 out->ts = ts; 00393 out->len = len; 00394 out->seqno = seqno; 00395 } 00396 } 00397 /* Invalidate prediction if we're entering a silence period */ 00398 if (out->frametype == AST_FRAME_CNG) 00399 path->nextout = ast_tv(0, 0); 00400 return out; 00401 }
Mask off unavailable formats from a format bitmask.
dest | possible destination formats | |
src | source formats |
Definition at line 1074 of file translate.c.
References AST_FORMAT_AUDIO_MASK, AST_FORMAT_VIDEO_MASK, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, powerof(), and tr_matrix.
Referenced by ast_rtp_instance_available_formats().
01075 { 01076 format_t res = dest; 01077 format_t x; 01078 format_t src_audio = src & AST_FORMAT_AUDIO_MASK; 01079 format_t src_video = src & AST_FORMAT_VIDEO_MASK; 01080 format_t x_bits; 01081 01082 /* if we don't have a source format, we just have to try all 01083 possible destination formats */ 01084 if (!src) 01085 return dest; 01086 01087 /* If we have a source audio format, get its format index */ 01088 if (src_audio) { 01089 src_audio = powerof(src_audio); 01090 } 01091 01092 /* If we have a source video format, get its format index */ 01093 if (src_video) { 01094 src_video = powerof(src_video); 01095 } 01096 01097 /* Note that src_audio and src_video are guaranteed to not be 01098 * negative at this point, as we ensured they were non-zero. It is 01099 * safe to use the return value of powerof as an index into tr_matrix. 01100 */ 01101 01102 AST_RWLIST_RDLOCK(&translators); 01103 01104 /* For a given source audio format, traverse the list of 01105 known audio formats to determine whether there exists 01106 a translation path from the source format to the 01107 destination format. */ 01108 for (x = 1LL; src_audio && x > 0; x <<= 1) { 01109 if (!(x & AST_FORMAT_AUDIO_MASK)) { 01110 continue; 01111 } 01112 01113 /* if this is not a desired format, nothing to do */ 01114 if (!(dest & x)) 01115 continue; 01116 01117 /* if the source is supplying this format, then 01118 we can leave it in the result */ 01119 if (src & x) 01120 continue; 01121 01122 /* if we don't have a translation path from the src 01123 to this format, remove it from the result. Note that x_bits 01124 cannot be less than 0 as x will always have one bit set to 1 */ 01125 x_bits = powerof(x); 01126 if (!tr_matrix[src_audio][x_bits].step) { 01127 res &= ~x; 01128 continue; 01129 } 01130 01131 /* now check the opposite direction */ 01132 if (!tr_matrix[x_bits][src_audio].step) 01133 res &= ~x; 01134 } 01135 01136 /* For a given source video format, traverse the list of 01137 known video formats to determine whether there exists 01138 a translation path from the source format to the 01139 destination format. */ 01140 for (x = 1LL; src_video && x > 0; x <<= 1) { 01141 if (!(x & AST_FORMAT_VIDEO_MASK)) { 01142 continue; 01143 } 01144 01145 /* if this is not a desired format, nothing to do */ 01146 if (!(dest & x)) 01147 continue; 01148 01149 /* if the source is supplying this format, then 01150 we can leave it in the result */ 01151 if (src & x) 01152 continue; 01153 01154 /* if we don't have a translation path from the src 01155 to this format, remove it from the result. Note that x_bits 01156 cannot be less than 0 as x will always have one bit set to 1 */ 01157 x_bits = powerof(x); 01158 if (!tr_matrix[src_video][x_bits].step) { 01159 res &= ~x; 01160 continue; 01161 } 01162 01163 /* now check the opposite direction */ 01164 if (!tr_matrix[x_bits][src_video].step) 01165 res &= ~x; 01166 } 01167 01168 AST_RWLIST_UNLOCK(&translators); 01169 01170 return res; 01171 }
Returns the number of steps required to convert from 'src' to 'dest'.
dest | destination format | |
src | source format |
Definition at line 1052 of file translate.c.
References ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, LOG_WARNING, translator_path::multistep, powerof(), and tr_matrix.
Referenced by ast_channel_make_compatible_helper().
01053 { 01054 unsigned int res = -1; 01055 01056 /* convert bitwise format numbers into array indices */ 01057 src = powerof(src); 01058 dest = powerof(dest); 01059 01060 if (src == -1 || dest == -1) { 01061 ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", src == -1 ? "starting" : "ending"); 01062 return -1; 01063 } 01064 AST_RWLIST_RDLOCK(&translators); 01065 01066 if (tr_matrix[src][dest].step) 01067 res = tr_matrix[src][dest].multistep + 1; 01068 01069 AST_RWLIST_UNLOCK(&translators); 01070 01071 return res; 01072 }
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.
translator | structure containing the translation path | |
ast_str | output buffer |
on | success pointer to beginning of outbuf. on failure "". |
Definition at line 623 of file translate.c.
References ast_getformatname(), ast_str_append(), ast_str_buffer(), ast_str_set(), ast_translator::dstfmt, ast_trans_pvt::next, ast_translator::srcfmt, str, and ast_trans_pvt::t.
Referenced by handle_showchan(), and serialize_showchan().
00624 { 00625 struct ast_trans_pvt *pn = p; 00626 00627 if (!p || !p->t) { 00628 return ""; 00629 } 00630 00631 ast_str_set(str, 0, "%s", ast_getformatname(1LL << p->t->srcfmt)); 00632 00633 while ( (p = pn) ) { 00634 pn = p->next; 00635 ast_str_append(str, 0, "->%s", ast_getformatname(1LL << p->t->dstfmt)); 00636 } 00637 00638 return ast_str_buffer(*str); 00639 }
void ast_translator_activate | ( | struct ast_translator * | t | ) |
Activate a previously deactivated translator.
t | translator to activate |
Definition at line 960 of file translate.c.
References ast_translator::active, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and rebuild_matrix().
00961 { 00962 AST_RWLIST_WRLOCK(&translators); 00963 t->active = 1; 00964 rebuild_matrix(0); 00965 AST_RWLIST_UNLOCK(&translators); 00966 }
Chooses the best translation path.
Given a list of sources, and a designed destination format, which should I choose?
Definition at line 977 of file translate.c.
References AST_FORMAT_AUDIO_MASK, ast_format_rate(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_translator::cost, translator_path::cost, MAX_AUDIO_FORMAT, translator_path::multistep, translator_path::rate_change, and tr_matrix.
Referenced by ast_channel_make_compatible_helper(), ast_request(), iax2_request(), and set_format().
00978 { 00979 int x,y; 00980 int better = 0; 00981 int besttime = INT_MAX; 00982 int beststeps = INT_MAX; 00983 unsigned int best_rate_change = INT_MAX; 00984 format_t best = -1; 00985 format_t bestdst = 0; 00986 format_t cur, cursrc; 00987 format_t common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK; /* are there common formats ? */ 00988 00989 if (common) { /* yes, pick one and return */ 00990 for (cur = 1, y = 0; y <= MAX_AUDIO_FORMAT; cur <<= 1, y++) { 00991 if (!(cur & common)) { 00992 continue; 00993 } 00994 00995 /* We are guaranteed to find one common format. */ 00996 if (best == -1) { 00997 best = cur; 00998 continue; 00999 } 01000 /* If there are multiple common formats, pick the one with the highest sample rate */ 01001 if (ast_format_rate(best) < ast_format_rate(cur)) { 01002 best = cur; 01003 continue; 01004 } 01005 } 01006 /* We are done, this is a common format to both. */ 01007 *srcs = *dst = best; 01008 return 0; 01009 } else { /* No, we will need to translate */ 01010 AST_RWLIST_RDLOCK(&translators); 01011 for (cur = 1, y = 0; y <= MAX_AUDIO_FORMAT; cur <<= 1, y++) { 01012 if (! (cur & *dst)) { 01013 continue; 01014 } 01015 for (cursrc = 1, x = 0; x <= MAX_AUDIO_FORMAT; cursrc <<= 1, x++) { 01016 if (!(*srcs & cursrc) || !tr_matrix[x][y].step) { 01017 continue; 01018 } 01019 01020 /* This is a better choice if any of the following are true. 01021 * 1. The sample rate conversion is better than the current pick. 01022 * 2. the sample rate conversion is no worse than the current pick and the cost or multistep is better 01023 */ 01024 better = 0; 01025 if (tr_matrix[x][y].rate_change < best_rate_change) { 01026 better = 1; /* this match has a better rate conversion */ 01027 } 01028 if ((tr_matrix[x][y].rate_change <= best_rate_change) && 01029 (tr_matrix[x][y].cost < besttime || tr_matrix[x][y].multistep < beststeps)) { 01030 better = 1; /* this match has no worse rate conversion and the conversion cost is less */ 01031 } 01032 if (better) { 01033 /* better than what we have so far */ 01034 best = cursrc; 01035 bestdst = cur; 01036 besttime = tr_matrix[x][y].cost; 01037 beststeps = tr_matrix[x][y].multistep; 01038 best_rate_change = tr_matrix[x][y].rate_change; 01039 } 01040 } 01041 } 01042 AST_RWLIST_UNLOCK(&translators); 01043 if (best > -1) { 01044 *srcs = best; 01045 *dst = bestdst; 01046 best = 0; 01047 } 01048 return best; 01049 } 01050 }
struct ast_trans_pvt* ast_translator_build_path | ( | format_t | dest, | |
format_t | source | |||
) |
Builds a translator path Build a path (possibly NULL) from source to dest.
dest | destination format | |
source | source format |
Definition at line 282 of file translate.c.
References ast_getformatname(), ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_translator_free_path(), ast_tv(), ast_translator::dstfmt, LOG_WARNING, newpvt(), ast_trans_pvt::next, ast_trans_pvt::nextin, ast_trans_pvt::nextout, powerof(), translator_path::step, ast_trans_pvt::t, and tr_matrix.
Referenced by ast_audiohook_read_frame(), ast_slinfactory_feed(), ast_writestream(), audio_audiohook_write_list(), conf_run(), and set_format().
00283 { 00284 struct ast_trans_pvt *head = NULL, *tail = NULL; 00285 00286 source = powerof(source); 00287 dest = powerof(dest); 00288 00289 if (source == -1 || dest == -1) { 00290 ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", source == -1 ? "starting" : "ending"); 00291 return NULL; 00292 } 00293 00294 AST_RWLIST_RDLOCK(&translators); 00295 00296 while (source != dest) { 00297 struct ast_trans_pvt *cur; 00298 struct ast_translator *t = tr_matrix[source][dest].step; 00299 if (!t) { 00300 ast_log(LOG_WARNING, "No translator path from %s to %s\n", 00301 ast_getformatname(source), ast_getformatname(dest)); 00302 AST_RWLIST_UNLOCK(&translators); 00303 return NULL; 00304 } 00305 if (!(cur = newpvt(t))) { 00306 ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n", 00307 ast_getformatname(source), ast_getformatname(dest)); 00308 if (head) 00309 ast_translator_free_path(head); 00310 AST_RWLIST_UNLOCK(&translators); 00311 return NULL; 00312 } 00313 if (!head) 00314 head = cur; 00315 else 00316 tail->next = cur; 00317 tail = cur; 00318 cur->nextin = cur->nextout = ast_tv(0, 0); 00319 /* Keep going if this isn't the final destination */ 00320 source = cur->t->dstfmt; 00321 } 00322 00323 AST_RWLIST_UNLOCK(&translators); 00324 return head; 00325 }
void ast_translator_deactivate | ( | struct ast_translator * | t | ) |
Deactivate a translator.
t | translator to deactivate |
Definition at line 968 of file translate.c.
References ast_translator::active, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and rebuild_matrix().
00969 { 00970 AST_RWLIST_WRLOCK(&translators); 00971 t->active = 0; 00972 rebuild_matrix(0); 00973 AST_RWLIST_UNLOCK(&translators); 00974 }
void ast_translator_free_path | ( | struct ast_trans_pvt * | tr | ) |
Frees a translator path Frees the given translator path structure.
tr | translator path to get rid of |
Definition at line 272 of file translate.c.
References destroy(), and ast_trans_pvt::next.
Referenced by ast_audiohook_destroy(), ast_audiohook_detach_list(), ast_audiohook_read_frame(), ast_channel_destructor(), ast_slinfactory_destroy(), ast_slinfactory_feed(), ast_slinfactory_flush(), ast_translator_build_path(), ast_writestream(), audio_audiohook_write_list(), conf_free(), filestream_destructor(), free_translation(), and set_format().
00273 { 00274 struct ast_trans_pvt *pn = p; 00275 while ( (p = pn) ) { 00276 pn = p->next; 00277 destroy(p); 00278 } 00279 }
int ast_unregister_translator | ( | struct ast_translator * | t | ) |
Unregister a translator Unregisters the given tranlator.
t | translator to unregister |
Definition at line 935 of file translate.c.
References ast_getformatname(), AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, COLOR_BLACK, COLOR_MAGENTA, ast_translator::dstfmt, ast_translator::list, ast_translator::name, rebuild_matrix(), ast_translator::srcfmt, and term_color().
Referenced by drop_translator(), load_module(), unload_module(), and unregister_translators().
00936 { 00937 char tmp[80]; 00938 struct ast_translator *u; 00939 int found = 0; 00940 00941 AST_RWLIST_WRLOCK(&translators); 00942 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) { 00943 if (u == t) { 00944 AST_RWLIST_REMOVE_CURRENT(list); 00945 ast_verb(2, "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1LL << t->srcfmt), ast_getformatname(1LL << t->dstfmt)); 00946 found = 1; 00947 break; 00948 } 00949 } 00950 AST_RWLIST_TRAVERSE_SAFE_END; 00951 00952 if (found) 00953 rebuild_matrix(0); 00954 00955 AST_RWLIST_UNLOCK(&translators); 00956 00957 return (u ? 0 : -1); 00958 }