Thu Mar 25 10:39:30 2010

Asterisk developer's documentation


translate.h File Reference

Support for translation of data formats. More...

#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. Name, callbacks, and various options related to run-time operation (size of buffers, auxiliary descriptors, etc). More...

Defines

#define ast_register_translator(t)   __ast_register_translator(t, ast_module_info->self)
#define MAX_AUDIO_FORMAT   15
#define MAX_FORMAT   32

Functions

int __ast_register_translator (struct ast_translator *t, struct ast_module *module)
 Register a translator This registers a codec translator with asterisk.
ast_frameast_trans_frameout (struct ast_trans_pvt *pvt, int datalen, int samples)
 generic frameout function
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
unsigned int ast_translate_available_formats (unsigned int dest, unsigned int src)
 Mask off unavailable formats from a format bitmask.
unsigned int ast_translate_path_steps (unsigned int dest, unsigned int src)
 Returns the number of steps required to convert from 'src' to 'dest'.
void ast_translator_activate (struct ast_translator *t)
 Activate a previously deactivated translator.
int ast_translator_best_choice (int *dsts, int *srcs)
 Chooses the best translation path.
ast_trans_pvtast_translator_build_path (int dest, int 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.


Detailed Description

Support for translation of data formats.

Definition in file translate.h.


Define Documentation

#define ast_register_translator ( t   )     __ast_register_translator(t, ast_module_info->self)

Definition at line 164 of file translate.h.

Referenced by load_module(), and register_translator().

#define MAX_AUDIO_FORMAT   15

Definition at line 26 of file translate.h.

Referenced by ast_translator_best_choice().

#define MAX_FORMAT   32

Definition at line 27 of file translate.h.

Referenced by __ast_register_translator(), and rebuild_matrix().


Function Documentation

int __ast_register_translator ( struct ast_translator t,
struct ast_module module 
)

Register a translator This registers a codec translator with asterisk.

Parameters:
t populated ast_translator structure
module handle to the module that owns this translator
Returns:
0 on success, -1 on failure

Definition at line 668 of file translate.c.

References ast_cli_register_multiple(), AST_FORMAT_SLINEAR, ast_getformatname(), AST_LIST_INSERT_BEFORE_CURRENT, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log(), ast_verbose(), calc_cost(), cli_translate, COLOR_BLACK, COLOR_MAGENTA, ast_translator::cost, default_frameout(), ast_translator::dstfmt, LOG_WARNING, MAX_FORMAT, option_verbose, powerof(), rebuild_matrix(), ast_translator::srcfmt, t, term_color(), and VERBOSE_PREFIX_2.

00669 {
00670    static int added_cli = 0;
00671    struct ast_translator *u;
00672 
00673    if (!mod) {
00674       ast_log(LOG_WARNING, "Missing module pointer, you need to supply one\n");
00675       return -1;
00676    }
00677 
00678    if (!t->buf_size) {
00679       ast_log(LOG_WARNING, "empty buf size, you need to supply one\n");
00680       return -1;
00681    }
00682 
00683    t->module = mod;
00684 
00685    t->srcfmt = powerof(t->srcfmt);
00686    t->dstfmt = powerof(t->dstfmt);
00687    t->active = 1;
00688 
00689    if (t->srcfmt == -1 || t->dstfmt == -1) {
00690       ast_log(LOG_WARNING, "Invalid translator path: (%s codec is not valid)\n", t->srcfmt == -1 ? "starting" : "ending");
00691       return -1;
00692    }
00693    if (t->plc_samples) {
00694       if (t->buffer_samples < t->plc_samples) {
00695          ast_log(LOG_WARNING, "plc_samples %d buffer_samples %d\n",
00696             t->plc_samples, t->buffer_samples);
00697          return -1;
00698       }
00699       if (t->dstfmt != powerof(AST_FORMAT_SLINEAR))
00700          ast_log(LOG_WARNING, "plc_samples %d format %x\n",
00701             t->plc_samples, t->dstfmt);
00702    }
00703    if (t->srcfmt >= MAX_FORMAT) {
00704       ast_log(LOG_WARNING, "Source format %s is larger than MAX_FORMAT\n", ast_getformatname(t->srcfmt));
00705       return -1;
00706    }
00707 
00708    if (t->dstfmt >= MAX_FORMAT) {
00709       ast_log(LOG_WARNING, "Destination format %s is larger than MAX_FORMAT\n", ast_getformatname(t->dstfmt));
00710       return -1;
00711    }
00712 
00713    if (t->buf_size) {
00714                /*
00715       * Align buf_size properly, rounding up to the machine-specific
00716       * alignment for pointers.
00717       */
00718       struct _test_align { void *a, *b; } p;
00719       int align = (char *)&p.b - (char *)&p.a;
00720 
00721       t->buf_size = ((t->buf_size + align - 1) / align) * align;
00722    }
00723 
00724    if (t->frameout == NULL)
00725       t->frameout = default_frameout;
00726   
00727    calc_cost(t, 1);
00728 
00729    if (option_verbose > 1) {
00730       char tmp[80];
00731 
00732       ast_verbose(VERBOSE_PREFIX_2 "Registered translator '%s' from format %s to %s, cost %d\n",
00733              term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)),
00734              ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt), t->cost);
00735    }
00736 
00737    if (!added_cli) {
00738       ast_cli_register_multiple(cli_translate, sizeof(cli_translate) / sizeof(struct ast_cli_entry));
00739       added_cli++;
00740    }
00741 
00742    AST_LIST_LOCK(&translators);
00743 
00744    /* find any existing translators that provide this same srcfmt/dstfmt,
00745       and put this one in order based on cost */
00746    AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) {
00747       if ((u->srcfmt == t->srcfmt) &&
00748           (u->dstfmt == t->dstfmt) &&
00749           (u->cost > t->cost)) {
00750          AST_LIST_INSERT_BEFORE_CURRENT(&translators, t, list);
00751          t = NULL;
00752       }
00753    }
00754    AST_LIST_TRAVERSE_SAFE_END;
00755 
00756    /* if no existing translator was found for this format combination,
00757       add it to the beginning of the list */
00758    if (t)
00759       AST_LIST_INSERT_HEAD(&translators, t, list);
00760 
00761    rebuild_matrix(0);
00762 
00763    AST_LIST_UNLOCK(&translators);
00764 
00765    return 0;
00766 }

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

generic frameout function

Definition at line 209 of file translate.c.

References AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_frisolate(), ast_trans_pvt::datalen, ast_translator::dstfmt, ast_trans_pvt::f, 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().

00211 {
00212    struct ast_frame *f = &pvt->f;
00213 
00214         if (samples)
00215       f->samples = samples;
00216    else {
00217       if (pvt->samples == 0)
00218          return NULL;
00219       f->samples = pvt->samples;
00220       pvt->samples = 0;
00221    }
00222    if (datalen)
00223       f->datalen = datalen;
00224    else {
00225       f->datalen = pvt->datalen;
00226       pvt->datalen = 0;
00227    }
00228 
00229    f->frametype = AST_FRAME_VOICE;
00230    f->subclass = 1 << (pvt->t->dstfmt);
00231    f->mallocd = 0;
00232    f->offset = AST_FRIENDLY_OFFSET;
00233    f->src = pvt->t->name;
00234    f->data = pvt->outbuf;
00235 
00236    return ast_frisolate(f);
00237 }

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

Parameters:
tr translator structure to use for translation
f frame to translate
consume Whether or not to free the original frame
Returns:
an ast_frame of the new translation format on success, NULL on failure

Definition at line 301 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::delivery, f, framein(), ast_frame::frametype, ast_frame::len, 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(), conf_run(), and process_ast_dsp().

00302 {
00303    struct ast_trans_pvt *p = path;
00304    struct ast_frame *out = f;
00305    struct timeval delivery;
00306    int has_timing_info;
00307    long ts;
00308    long len;
00309    int seqno;
00310 
00311    has_timing_info = ast_test_flag(f, AST_FRFLAG_HAS_TIMING_INFO);
00312    ts = f->ts;
00313    len = f->len;
00314    seqno = f->seqno;
00315 
00316    /* XXX hmmm... check this below */
00317    if (!ast_tvzero(f->delivery)) {
00318       if (!ast_tvzero(path->nextin)) {
00319          /* Make sure this is in line with what we were expecting */
00320          if (!ast_tveq(path->nextin, f->delivery)) {
00321             /* The time has changed between what we expected and this
00322                most recent time on the new packet.  If we have a
00323                valid prediction adjust our output time appropriately */
00324             if (!ast_tvzero(path->nextout)) {
00325                path->nextout = ast_tvadd(path->nextout,
00326                           ast_tvsub(f->delivery, path->nextin));
00327             }
00328             path->nextin = f->delivery;
00329          }
00330       } else {
00331          /* This is our first pass.  Make sure the timing looks good */
00332          path->nextin = f->delivery;
00333          path->nextout = f->delivery;
00334       }
00335       /* Predict next incoming sample */
00336       path->nextin = ast_tvadd(path->nextin, ast_samp2tv(f->samples, ast_format_rate(f->subclass)));
00337    }
00338    delivery = f->delivery;
00339    for ( ; out && p ; p = p->next) {
00340       framein(p, out);
00341       if (out != f)
00342          ast_frfree(out);
00343       out = p->t->frameout(p);
00344    }
00345    if (consume)
00346       ast_frfree(f);
00347    if (out == NULL)
00348       return NULL;
00349    /* we have a frame, play with times */
00350    if (!ast_tvzero(delivery)) {
00351       /* Regenerate prediction after a discontinuity */
00352       if (ast_tvzero(path->nextout))
00353          path->nextout = ast_tvnow();
00354 
00355       /* Use next predicted outgoing timestamp */
00356       out->delivery = path->nextout;
00357       
00358       /* Predict next outgoing timestamp from samples in this
00359          frame. */
00360       path->nextout = ast_tvadd(path->nextout, ast_samp2tv(out->samples, ast_format_rate(out->subclass)));
00361    } else {
00362       out->delivery = ast_tv(0, 0);
00363       ast_set2_flag(out, has_timing_info, AST_FRFLAG_HAS_TIMING_INFO);
00364       if (has_timing_info) {
00365          out->ts = ts;
00366          out->len = len;
00367          out->seqno = seqno;
00368       }
00369    }
00370    /* Invalidate prediction if we're entering a silence period */
00371    if (out->frametype == AST_FRAME_CNG)
00372       path->nextout = ast_tv(0, 0);
00373    return out;
00374 }

unsigned int ast_translate_available_formats ( unsigned int  dest,
unsigned int  src 
)

Mask off unavailable formats from a format bitmask.

Parameters:
dest possible destination formats
src source formats
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 that 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 881 of file translate.c.

References AST_FORMAT_AUDIO_MASK, AST_FORMAT_MAX_AUDIO, AST_FORMAT_MAX_VIDEO, AST_FORMAT_VIDEO_MASK, AST_LIST_LOCK, AST_LIST_UNLOCK, powerof(), and tr_matrix.

Referenced by sip_call().

00882 {
00883    unsigned int res = dest;
00884    unsigned int x;
00885    unsigned int src_audio = src & AST_FORMAT_AUDIO_MASK;
00886    unsigned int src_video = src & AST_FORMAT_VIDEO_MASK;
00887 
00888    /* if we don't have a source format, we just have to try all
00889       possible destination formats */
00890    if (!src)
00891       return dest;
00892 
00893    /* If we have a source audio format, get its format index */
00894    if (src_audio)
00895       src_audio = powerof(src_audio);
00896 
00897    /* If we have a source video format, get its format index */
00898    if (src_video)
00899       src_video = powerof(src_video);
00900 
00901    AST_LIST_LOCK(&translators);
00902 
00903    /* For a given source audio format, traverse the list of
00904       known audio formats to determine whether there exists
00905       a translation path from the source format to the
00906       destination format. */
00907    for (x = 1; src_audio && x < AST_FORMAT_MAX_AUDIO; x <<= 1) {
00908       /* if this is not a desired format, nothing to do */
00909       if (!(dest & x))
00910          continue;
00911 
00912       /* if the source is supplying this format, then
00913          we can leave it in the result */
00914       if (src & x)
00915          continue;
00916 
00917       /* if we don't have a translation path from the src
00918          to this format, remove it from the result */
00919       if (!tr_matrix[src_audio][powerof(x)].step) {
00920          res &= ~x;
00921          continue;
00922       }
00923 
00924       /* now check the opposite direction */
00925       if (!tr_matrix[powerof(x)][src_audio].step)
00926          res &= ~x;
00927    }
00928 
00929    /* For a given source video format, traverse the list of
00930       known video formats to determine whether there exists
00931       a translation path from the source format to the
00932       destination format. */
00933    for (; src_video && x < AST_FORMAT_MAX_VIDEO; x <<= 1) {
00934       /* if this is not a desired format, nothing to do */
00935       if (!(dest & x))
00936          continue;
00937 
00938       /* if the source is supplying this format, then
00939          we can leave it in the result */
00940       if (src & x)
00941          continue;
00942 
00943       /* if we don't have a translation path from the src
00944          to this format, remove it from the result */
00945       if (!tr_matrix[src_video][powerof(x)].step) {
00946          res &= ~x;
00947          continue;
00948       }
00949 
00950       /* now check the opposite direction */
00951       if (!tr_matrix[powerof(x)][src_video].step)
00952          res &= ~x;
00953    }
00954 
00955    AST_LIST_UNLOCK(&translators);
00956 
00957    return res;
00958 }

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

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

Parameters:
dest destination format
src source format
Returns:
the number of translation steps required, or -1 if no path is available

Definition at line 859 of file translate.c.

References AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log(), LOG_WARNING, translator_path::multistep, powerof(), and tr_matrix.

Referenced by ast_channel_make_compatible().

00860 {
00861    unsigned int res = -1;
00862 
00863    /* convert bitwise format numbers into array indices */
00864    src = powerof(src);
00865    dest = powerof(dest);
00866 
00867    if (src == -1 || dest == -1) {
00868       ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", src == -1 ? "starting" : "ending");
00869       return -1;
00870    }
00871    AST_LIST_LOCK(&translators);
00872 
00873    if (tr_matrix[src][dest].step)
00874       res = tr_matrix[src][dest].multistep + 1;
00875 
00876    AST_LIST_UNLOCK(&translators);
00877 
00878    return res;
00879 }

void ast_translator_activate ( struct ast_translator t  ) 

Activate a previously deactivated translator.

Parameters:
t translator to activate
Returns:
nothing
Enables the specified translator for use.

Definition at line 795 of file translate.c.

References AST_LIST_LOCK, AST_LIST_UNLOCK, rebuild_matrix(), and t.

00796 {
00797    AST_LIST_LOCK(&translators);
00798    t->active = 1;
00799    rebuild_matrix(0);
00800    AST_LIST_UNLOCK(&translators);
00801 }

int ast_translator_best_choice ( int *  dsts,
int *  srcs 
)

Chooses the best translation path.

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

Returns:
Returns 0 on success, -1 if no path could be found.
Note:
Modifies dests and srcs in place

Definition at line 812 of file translate.c.

References AST_FORMAT_AUDIO_MASK, AST_LIST_LOCK, AST_LIST_UNLOCK, translator_path::cost, ast_translator::cost, MAX_AUDIO_FORMAT, translator_path::multistep, and tr_matrix.

Referenced by ast_channel_make_compatible(), ast_request(), iax2_request(), and set_format().

00813 {
00814    int x,y;
00815    int best = -1;
00816    int bestdst = 0;
00817    int cur, cursrc;
00818    int besttime = INT_MAX;
00819    int beststeps = INT_MAX;
00820    int common = ((*dst) & (*srcs)) & AST_FORMAT_AUDIO_MASK; /* are there common formats ? */
00821 
00822    if (common) { /* yes, pick one and return */
00823       for (cur = 1, y = 0; y <= MAX_AUDIO_FORMAT; cur <<= 1, y++) {
00824          if (cur & common) /* guaranteed to find one */
00825             break;
00826       }
00827       /* We are done, this is a common format to both. */
00828       *srcs = *dst = cur;
00829       return 0;
00830    } else { /* No, we will need to translate */
00831       AST_LIST_LOCK(&translators);
00832       for (cur = 1, y = 0; y <= MAX_AUDIO_FORMAT; cur <<= 1, y++) {
00833          if (! (cur & *dst))
00834             continue;
00835          for (cursrc = 1, x = 0; x <= MAX_AUDIO_FORMAT; cursrc <<= 1, x++) {
00836             if (!(*srcs & cursrc) || !tr_matrix[x][y].step ||
00837                 tr_matrix[x][y].cost >  besttime)
00838                continue;   /* not existing or no better */
00839             if (tr_matrix[x][y].cost < besttime ||
00840                 tr_matrix[x][y].multistep < beststeps) {
00841                /* better than what we have so far */
00842                best = cursrc;
00843                bestdst = cur;
00844                besttime = tr_matrix[x][y].cost;
00845                beststeps = tr_matrix[x][y].multistep;
00846             }
00847          }
00848       }
00849       AST_LIST_UNLOCK(&translators);
00850       if (best > -1) {
00851          *srcs = best;
00852          *dst = bestdst;
00853          best = 0;
00854       }
00855       return best;
00856    }
00857 }

struct ast_trans_pvt* ast_translator_build_path ( int  dest,
int  source 
)

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

Parameters:
dest destination format
source source format
Returns:
ast_trans_pvt on success, NULL on failure

Definition at line 256 of file translate.c.

References ast_getformatname(), AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log(), 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, t, and tr_matrix.

Referenced by ast_audiohook_read_frame(), ast_slinfactory_feed(), ast_writestream(), audio_audiohook_write_list(), conf_run(), misdn_set_opt_exec(), read_config(), and set_format().

00257 {
00258    struct ast_trans_pvt *head = NULL, *tail = NULL;
00259    
00260    source = powerof(source);
00261    dest = powerof(dest);
00262 
00263    if (source == -1 || dest == -1) {
00264       ast_log(LOG_WARNING, "No translator path: (%s codec is not valid)\n", source == -1 ? "starting" : "ending");
00265       return NULL;
00266    }
00267 
00268    AST_LIST_LOCK(&translators);
00269 
00270    while (source != dest) {
00271       struct ast_trans_pvt *cur;
00272       struct ast_translator *t = tr_matrix[source][dest].step;
00273       if (!t) {
00274          ast_log(LOG_WARNING, "No translator path from %s to %s\n", 
00275             ast_getformatname(source), ast_getformatname(dest));
00276          AST_LIST_UNLOCK(&translators);
00277          return NULL;
00278       }
00279       if (!(cur = newpvt(t))) {
00280          ast_log(LOG_WARNING, "Failed to build translator step from %d to %d\n", source, dest);
00281          if (head)
00282             ast_translator_free_path(head);  
00283          AST_LIST_UNLOCK(&translators);
00284          return NULL;
00285       }
00286       if (!head)
00287          head = cur;
00288       else
00289          tail->next = cur;
00290       tail = cur;
00291       cur->nextin = cur->nextout = ast_tv(0, 0);
00292       /* Keep going if this isn't the final destination */
00293       source = cur->t->dstfmt;
00294    }
00295 
00296    AST_LIST_UNLOCK(&translators);
00297    return head;
00298 }

void ast_translator_deactivate ( struct ast_translator t  ) 

Deactivate a translator.

Parameters:
t translator to deactivate
Returns:
nothing
Disables the specified translator from being used.

Definition at line 803 of file translate.c.

References AST_LIST_LOCK, AST_LIST_UNLOCK, rebuild_matrix(), and t.

00804 {
00805    AST_LIST_LOCK(&translators);
00806    t->active = 0;
00807    rebuild_matrix(0);
00808    AST_LIST_UNLOCK(&translators);
00809 }

void ast_translator_free_path ( struct ast_trans_pvt tr  ) 

Frees a translator path Frees the given translator path structure.

Parameters:
tr translator path to get rid of

Definition at line 246 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_free(), ast_slinfactory_destroy(), ast_slinfactory_feed(), ast_slinfactory_flush(), ast_translator_build_path(), ast_writestream(), audio_audiohook_write_list(), cl_dequeue_chan(), conf_free(), filestream_destructor(), free_translation(), and set_format().

00247 {
00248    struct ast_trans_pvt *pn = p;
00249    while ( (p = pn) ) {
00250       pn = p->next;
00251       destroy(p);
00252    }
00253 }

int ast_unregister_translator ( struct ast_translator t  ) 

Unregister a translator Unregisters the given tranlator.

Parameters:
t translator to unregister
Returns:
0 on success, -1 on failure

Definition at line 769 of file translate.c.

References ast_getformatname(), AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_verbose(), COLOR_BLACK, COLOR_MAGENTA, ast_translator::list, option_verbose, rebuild_matrix(), t, term_color(), and VERBOSE_PREFIX_2.

Referenced by drop_translator(), load_module(), unload_module(), and unregister_translators().

00770 {
00771    char tmp[80];
00772    struct ast_translator *u;
00773    int found = 0;
00774 
00775    AST_LIST_LOCK(&translators);
00776    AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, u, list) {
00777       if (u == t) {
00778          AST_LIST_REMOVE_CURRENT(&translators, list);
00779          if (option_verbose > 1)
00780             ast_verbose(VERBOSE_PREFIX_2 "Unregistered translator '%s' from format %s to %s\n", term_color(tmp, t->name, COLOR_MAGENTA, COLOR_BLACK, sizeof(tmp)), ast_getformatname(1 << t->srcfmt), ast_getformatname(1 << t->dstfmt));
00781          found = 1;
00782          break;
00783       }
00784    }
00785    AST_LIST_TRAVERSE_SAFE_END;
00786 
00787    if (found)
00788       rebuild_matrix(0);
00789 
00790    AST_LIST_UNLOCK(&translators);
00791 
00792    return (u ? 0 : -1);
00793 }


Generated on Thu Mar 25 10:39:31 2010 for Asterisk - the Open Source PBX by  doxygen 1.4.7