#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 785 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().
00786 { 00787 static int added_cli = 0; 00788 struct ast_translator *u; 00789 char tmp[80]; 00790 00791 if (!mod) { 00792 ast_log(LOG_WARNING, "Missing module pointer, you need to supply one\n"); 00793 return -1; 00794 } 00795 00796 if (!t->buf_size) { 00797 ast_log(LOG_WARNING, "empty buf size, you need to supply one\n"); 00798 return -1; 00799 } 00800 00801 t->module = mod; 00802 00803 t->srcfmt = powerof(t->srcfmt); 00804 t->dstfmt = powerof(t->dstfmt); 00805 t->active = 1; 00806 00807 if (t->srcfmt == -1 || t->dstfmt == -1) { 00808 ast_log(LOG_WARNING, "Invalid translator path: (%s codec is not valid)\n", t->srcfmt == -1 ? "starting" : "ending"); 00809 return -1; 00810 } 00811 if (t->srcfmt >= MAX_FORMAT) { 00812 ast_log(LOG_WARNING, "Source format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt)); 00813 return -1; 00814 } 00815 00816 if (t->dstfmt >= MAX_FORMAT) { 00817 ast_log(LOG_WARNING, "Destination format %s is larger than MAX_FORMAT\n", ast_getformatname(t->dstfmt)); 00818 return -1; 00819 } 00820 00821 if (t->buf_size) { 00822 /* 00823 * Align buf_size properly, rounding up to the machine-specific 00824 * alignment for pointers. 00825 */ 00826 struct _test_align { void *a, *b; } p; 00827 int align = (char *)&p.b - (char *)&p.a; 00828 00829 t->buf_size = ((t->buf_size + align - 1) / align) * align; 00830 } 00831 00832 if (t->frameout == NULL) 00833 t->frameout = default_frameout; 00834 00835 calc_cost(t, 1); 00836 00837 ast_verb(2, "Registered translator '%s' from format %s to %s, cost %d\n", 00838 term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), 00839 ast_getformatname(1LL << t->srcfmt), ast_getformatname(1LL << t->dstfmt), t->cost); 00840 00841 if (!added_cli) { 00842 ast_cli_register_multiple(cli_translate, ARRAY_LEN(cli_translate)); 00843 added_cli++; 00844 } 00845 00846 AST_RWLIST_WRLOCK(&translators); 00847 00848 /* find any existing translators that provide this same srcfmt/dstfmt, 00849 and put this one in order based on cost */ 00850 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) { 00851 if ((u->srcfmt == t->srcfmt) && 00852 (u->dstfmt == t->dstfmt) && 00853 (u->cost > t->cost)) { 00854 AST_RWLIST_INSERT_BEFORE_CURRENT(t, list); 00855 t = NULL; 00856 break; 00857 } 00858 } 00859 AST_RWLIST_TRAVERSE_SAFE_END; 00860 00861 /* if no existing translator was found for this format combination, 00862 add it to the beginning of the list */ 00863 if (t) 00864 AST_RWLIST_INSERT_HEAD(&translators, t, list); 00865 00866 rebuild_matrix(0); 00867 00868 AST_RWLIST_UNLOCK(&translators); 00869 00870 return 0; 00871 }
struct ast_frame* ast_trans_frameout | ( | struct ast_trans_pvt * | pvt, | |
int | datalen, | |||
int | samples | |||
) |
generic frameout function
Definition at line 191 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().
00193 { 00194 struct ast_frame *f = &pvt->f; 00195 00196 if (samples) 00197 f->samples = samples; 00198 else { 00199 if (pvt->samples == 0) 00200 return NULL; 00201 f->samples = pvt->samples; 00202 pvt->samples = 0; 00203 } 00204 if (datalen) 00205 f->datalen = datalen; 00206 else { 00207 f->datalen = pvt->datalen; 00208 pvt->datalen = 0; 00209 } 00210 00211 f->frametype = AST_FRAME_VOICE; 00212 f->subclass.codec = 1LL << (pvt->t->dstfmt); 00213 f->mallocd = 0; 00214 f->offset = AST_FRIENDLY_OFFSET; 00215 f->src = pvt->t->name; 00216 f->data.ptr = pvt->outbuf.c; 00217 00218 return ast_frisolate(f); 00219 }
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 284 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().
00285 { 00286 struct ast_trans_pvt *p = path; 00287 struct ast_frame *out = f; 00288 struct timeval delivery; 00289 int has_timing_info; 00290 long ts; 00291 long len; 00292 int seqno; 00293 00294 has_timing_info = ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO); 00295 ts = f->ts; 00296 len = f->len; 00297 seqno = f->seqno; 00298 00299 /* XXX hmmm... check this below */ 00300 if (!ast_tvzero(f->delivery)) { 00301 if (!ast_tvzero(path->nextin)) { 00302 /* Make sure this is in line with what we were expecting */ 00303 if (!ast_tveq(path->nextin, f->delivery)) { 00304 /* The time has changed between what we expected and this 00305 most recent time on the new packet. If we have a 00306 valid prediction adjust our output time appropriately */ 00307 if (!ast_tvzero(path->nextout)) { 00308 path->nextout = ast_tvadd(path->nextout, 00309 ast_tvsub(f->delivery, path->nextin)); 00310 } 00311 path->nextin = f->delivery; 00312 } 00313 } else { 00314 /* This is our first pass. Make sure the timing looks good */ 00315 path->nextin = f->delivery; 00316 path->nextout = f->delivery; 00317 } 00318 /* Predict next incoming sample */ 00319 path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(f->subclass.codec))); 00320 } 00321 delivery = f->delivery; 00322 for ( ; out && p ; p = p->next) { 00323 framein(p, out); 00324 if (out != f) 00325 ast_frfree(out); 00326 out = p->t->frameout(p); 00327 } 00328 if (consume) 00329 ast_frfree(f); 00330 if (out == NULL) 00331 return NULL; 00332 /* we have a frame, play with times */ 00333 if (!ast_tvzero(delivery)) { 00334 /* Regenerate prediction after a discontinuity */ 00335 if (ast_tvzero(path->nextout)) 00336 path->nextout = ast_tvnow(); 00337 00338 /* Use next predicted outgoing timestamp */ 00339 out->delivery = path->nextout; 00340 00341 /* Predict next outgoing timestamp from samples in this 00342 frame. */ 00343 path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass.codec))); 00344 } else { 00345 out->delivery = ast_tv(0, 0); 00346 ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO); 00347 if (has_timing_info) { 00348 out->ts = ts; 00349 out->len = len; 00350 out->seqno = seqno; 00351 } 00352 } 00353 /* Invalidate prediction if we're entering a silence period */ 00354 if (out->frametype == AST_FRAME_CNG) 00355 path->nextout = ast_tv(0, 0); 00356 return out; 00357 }
Mask off unavailable formats from a format bitmask.
dest | possible destination formats | |
src | source formats |
Definition at line 1013 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().
01014 { 01015 format_t res = dest; 01016 format_t x; 01017 format_t src_audio = src & AST_FORMAT_AUDIO_MASK; 01018 format_t src_video = src & AST_FORMAT_VIDEO_MASK; 01019 01020 /* if we don't have a source format, we just have to try all 01021 possible destination formats */ 01022 if (!src) 01023 return dest; 01024 01025 /* If we have a source audio format, get its format index */ 01026 if (src_audio) 01027 src_audio = powerof(src_audio); 01028 01029 /* If we have a source video format, get its format index */ 01030 if (src_video) 01031 src_video = powerof(src_video); 01032 01033 AST_RWLIST_RDLOCK(&translators); 01034 01035 /* For a given source audio format, traverse the list of 01036 known audio formats to determine whether there exists 01037 a translation path from the source format to the 01038 destination format. */ 01039 for (x = 1LL; src_audio && x > 0; x <<= 1) { 01040 if (!(x & AST_FORMAT_AUDIO_MASK)) { 01041 continue; 01042 } 01043 01044 /* if this is not a desired format, nothing to do */ 01045 if (!(dest & x)) 01046 continue; 01047 01048 /* if the source is supplying this format, then 01049 we can leave it in the result */ 01050 if (src & x) 01051 continue; 01052 01053 /* if we don't have a translation path from the src 01054 to this format, remove it from the result */ 01055 if (!tr_matrix[src_audio][powerof(x)].step) { 01056 res &= ~x; 01057 continue; 01058 } 01059 01060 /* now check the opposite direction */ 01061 if (!tr_matrix[powerof(x)][src_audio].step) 01062 res &= ~x; 01063 } 01064 01065 /* For a given source video format, traverse the list of 01066 known video formats to determine whether there exists 01067 a translation path from the source format to the 01068 destination format. */ 01069 for (x = 1LL; src_video && x > 0; x <<= 1) { 01070 if (!(x & AST_FORMAT_VIDEO_MASK)) { 01071 continue; 01072 } 01073 01074 /* if this is not a desired format, nothing to do */ 01075 if (!(dest & x)) 01076 continue; 01077 01078 /* if the source is supplying this format, then 01079 we can leave it in the result */ 01080 if (src & x) 01081 continue; 01082 01083 /* if we don't have a translation path from the src 01084 to this format, remove it from the result */ 01085 if (!tr_matrix[src_video][powerof(x)].step) { 01086 res &= ~x; 01087 continue; 01088 } 01089 01090 /* now check the opposite direction */ 01091 if (!tr_matrix[powerof(x)][src_video].step) 01092 res &= ~x; 01093 } 01094 01095 AST_RWLIST_UNLOCK(&translators); 01096 01097 return res; 01098 }
Returns the number of steps required to convert from 'src' to 'dest'.
dest | destination format | |
src | source format |
Definition at line 991 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().
00992 { 00993 unsigned int res = -1; 00994 00995 /* convert bitwise format numbers into array indices */ 00996 src = powerof(src); 00997 dest = powerof(dest); 00998 00999 if (src == -1 || dest == -1) { 01000 ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", src == -1 ? "starting" : "ending"); 01001 return -1; 01002 } 01003 AST_RWLIST_RDLOCK(&translators); 01004 01005 if (tr_matrix[src][dest].step) 01006 res = tr_matrix[src][dest].multistep + 1; 01007 01008 AST_RWLIST_UNLOCK(&translators); 01009 01010 return res; 01011 }
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 567 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().
00568 { 00569 struct ast_trans_pvt *pn = p; 00570 00571 if (!p || !p->t) { 00572 return ""; 00573 } 00574 00575 ast_str_set(str, 0, "%s", ast_getformatname(1LL << p->t->srcfmt)); 00576 00577 while ( (p = pn) ) { 00578 pn = p->next; 00579 ast_str_append(str, 0, "->%s", ast_getformatname(1LL << p->t->dstfmt)); 00580 } 00581 00582 return ast_str_buffer(*str); 00583 }
void ast_translator_activate | ( | struct ast_translator * | t | ) |
Activate a previously deactivated translator.
t | translator to activate |
Definition at line 899 of file translate.c.
References ast_translator::active, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and rebuild_matrix().
00900 { 00901 AST_RWLIST_WRLOCK(&translators); 00902 t->active = 1; 00903 rebuild_matrix(0); 00904 AST_RWLIST_UNLOCK(&translators); 00905 }
Chooses the best translation path.
Given a list of sources, and a designed destination format, which should I choose?
Definition at line 916 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().
00917 { 00918 int x,y; 00919 int better = 0; 00920 int besttime = INT_MAX; 00921 int beststeps = INT_MAX; 00922 unsigned int best_rate_change = INT_MAX; 00923 format_t best = -1; 00924 format_t bestdst = 0; 00925 format_t cur, cursrc; 00926 format_t common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK; /* are there common formats ? */ 00927 00928 if (common) { /* yes, pick one and return */ 00929 for (cur = 1, y = 0; y <= MAX_AUDIO_FORMAT; cur <<= 1, y++) { 00930 if (!(cur & common)) { 00931 continue; 00932 } 00933 00934 /* We are guaranteed to find one common format. */ 00935 if (best == -1) { 00936 best = cur; 00937 continue; 00938 } 00939 /* If there are multiple common formats, pick the one with the highest sample rate */ 00940 if (ast_format_rate(best) < ast_format_rate(cur)) { 00941 best = cur; 00942 continue; 00943 } 00944 } 00945 /* We are done, this is a common format to both. */ 00946 *srcs = *dst = best; 00947 return 0; 00948 } else { /* No, we will need to translate */ 00949 AST_RWLIST_RDLOCK(&translators); 00950 for (cur = 1, y = 0; y <= MAX_AUDIO_FORMAT; cur <<= 1, y++) { 00951 if (! (cur & *dst)) { 00952 continue; 00953 } 00954 for (cursrc = 1, x = 0; x <= MAX_AUDIO_FORMAT; cursrc <<= 1, x++) { 00955 if (!(*srcs & cursrc) || !tr_matrix[x][y].step) { 00956 continue; 00957 } 00958 00959 /* This is a better choice if any of the following are true. 00960 * 1. The sample rate conversion is better than the current pick. 00961 * 2. the sample rate conversion is no worse than the current pick and the cost or multistep is better 00962 */ 00963 better = 0; 00964 if (tr_matrix[x][y].rate_change < best_rate_change) { 00965 better = 1; /* this match has a better rate conversion */ 00966 } 00967 if ((tr_matrix[x][y].rate_change <= best_rate_change) && 00968 (tr_matrix[x][y].cost < besttime || tr_matrix[x][y].multistep < beststeps)) { 00969 better = 1; /* this match has no worse rate conversion and the conversion cost is less */ 00970 } 00971 if (better) { 00972 /* better than what we have so far */ 00973 best = cursrc; 00974 bestdst = cur; 00975 besttime = tr_matrix[x][y].cost; 00976 beststeps = tr_matrix[x][y].multistep; 00977 best_rate_change = tr_matrix[x][y].rate_change; 00978 } 00979 } 00980 } 00981 AST_RWLIST_UNLOCK(&translators); 00982 if (best > -1) { 00983 *srcs = best; 00984 *dst = bestdst; 00985 best = 0; 00986 } 00987 return best; 00988 } 00989 }
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 238 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().
00239 { 00240 struct ast_trans_pvt *head = NULL, *tail = NULL; 00241 00242 source = powerof(source); 00243 dest = powerof(dest); 00244 00245 if (source == -1 || dest == -1) { 00246 ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", source == -1 ? "starting" : "ending"); 00247 return NULL; 00248 } 00249 00250 AST_RWLIST_RDLOCK(&translators); 00251 00252 while (source != dest) { 00253 struct ast_trans_pvt *cur; 00254 struct ast_translator *t = tr_matrix[source][dest].step; 00255 if (!t) { 00256 ast_log(LOG_WARNING, "No translator path from %s to %s\n", 00257 ast_getformatname(source), ast_getformatname(dest)); 00258 AST_RWLIST_UNLOCK(&translators); 00259 return NULL; 00260 } 00261 if (!(cur = newpvt(t))) { 00262 ast_log(LOG_WARNING, "Failed to build translator step from %s to %s\n", 00263 ast_getformatname(source), ast_getformatname(dest)); 00264 if (head) 00265 ast_translator_free_path(head); 00266 AST_RWLIST_UNLOCK(&translators); 00267 return NULL; 00268 } 00269 if (!head) 00270 head = cur; 00271 else 00272 tail->next = cur; 00273 tail = cur; 00274 cur->nextin = cur->nextout = ast_tv(0, 0); 00275 /* Keep going if this isn't the final destination */ 00276 source = cur->t->dstfmt; 00277 } 00278 00279 AST_RWLIST_UNLOCK(&translators); 00280 return head; 00281 }
void ast_translator_deactivate | ( | struct ast_translator * | t | ) |
Deactivate a translator.
t | translator to deactivate |
Definition at line 907 of file translate.c.
References ast_translator::active, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and rebuild_matrix().
00908 { 00909 AST_RWLIST_WRLOCK(&translators); 00910 t->active = 0; 00911 rebuild_matrix(0); 00912 AST_RWLIST_UNLOCK(&translators); 00913 }
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 228 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().
00229 { 00230 struct ast_trans_pvt *pn = p; 00231 while ( (p = pn) ) { 00232 pn = p->next; 00233 destroy(p); 00234 } 00235 }
int ast_unregister_translator | ( | struct ast_translator * | t | ) |
Unregister a translator Unregisters the given tranlator.
t | translator to unregister |
Definition at line 874 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().
00875 { 00876 char tmp[80]; 00877 struct ast_translator *u; 00878 int found = 0; 00879 00880 AST_RWLIST_WRLOCK(&translators); 00881 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) { 00882 if (u == t) { 00883 AST_RWLIST_REMOVE_CURRENT(list); 00884 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)); 00885 found = 1; 00886 break; 00887 } 00888 } 00889 AST_RWLIST_TRAVERSE_SAFE_END; 00890 00891 if (found) 00892 rebuild_matrix(0); 00893 00894 AST_RWLIST_UNLOCK(&translators); 00895 00896 return (u ? 0 : -1); 00897 }