automerge commit

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@11088 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Automerge script 20 years ago
parent 2dc3679b6e
commit 2719e0aa02

@ -1164,7 +1164,12 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
trans->last_format = f->subclass; trans->last_format = f->subclass;
} }
} }
translated_frame = ast_translate(trans->path, f, 0); if (!(translated_frame = ast_translate(trans->path, f, 0))) {
ast_log(LOG_ERROR, "Translation to %s failed, dropping frame for spies\n",
ast_getformatname(AST_FORMAT_SLINEAR));
ast_mutex_unlock(&spy->lock);
break;
}
} }
for (last = queue->head; last && last->next; last = last->next); for (last = queue->head; last && last->next; last = last->next);

@ -55,7 +55,8 @@ static struct ast_translator *list = NULL;
struct ast_translator_dir { struct ast_translator_dir {
struct ast_translator *step; /*!< Next step translator */ struct ast_translator *step; /*!< Next step translator */
int cost; /*!< Complete cost to destination */ unsigned int cost; /*!< Complete cost to destination */
unsigned int multistep; /*!< Multiple conversions required for this translation */
}; };
struct ast_frame_delivery { struct ast_frame_delivery {
@ -271,57 +272,63 @@ static void rebuild_matrix(int samples)
{ {
struct ast_translator *t; struct ast_translator *t;
int changed; int changed;
int x,y,z; int x, y, z;
if (option_debug) if (option_debug)
ast_log(LOG_DEBUG, "Resetting translation matrix\n"); ast_log(LOG_DEBUG, "Resetting translation matrix\n");
bzero(tr_matrix, sizeof(tr_matrix)); bzero(tr_matrix, sizeof(tr_matrix));
t = list;
while(t) { for (t = list; t; t = t->next) {
if(samples) if (samples)
calc_cost(t, samples); calc_cost(t, samples);
if (!tr_matrix[t->srcfmt][t->dstfmt].step || if (!tr_matrix[t->srcfmt][t->dstfmt].step ||
tr_matrix[t->srcfmt][t->dstfmt].cost > t->cost) { tr_matrix[t->srcfmt][t->dstfmt].cost > t->cost) {
tr_matrix[t->srcfmt][t->dstfmt].step = t; tr_matrix[t->srcfmt][t->dstfmt].step = t;
tr_matrix[t->srcfmt][t->dstfmt].cost = t->cost; tr_matrix[t->srcfmt][t->dstfmt].cost = t->cost;
} }
t = t->next;
} }
do { do {
changed = 0; changed = 0;
/* Don't you just love O(N^3) operations? */ /* Don't you just love O(N^3) operations? */
for (x=0; x< MAX_FORMAT; x++) /* For each source format */ for (x = 0; x< MAX_FORMAT; x++) { /* For each source format */
for (y=0; y < MAX_FORMAT; y++) /* And each destination format */ for (y = 0; y < MAX_FORMAT; y++) { /* And each destination format */
if (x != y) /* Except ourselves, of course */ if (x == y) /* Except ourselves, of course */
for (z=0; z < MAX_FORMAT; z++) /* And each format it might convert to */ continue;
if ((x!=z) && (y!=z)) /* Don't ever convert back to us */
if (tr_matrix[x][y].step && /* We can convert from x to y */ for (z=0; z < MAX_FORMAT; z++) { /* And each format it might convert to */
tr_matrix[y][z].step && /* And from y to z and... */ if ((x == z) || (y == z)) /* Don't ever convert back to us */
(!tr_matrix[x][z].step || /* Either there isn't an x->z conversion */ continue;
(tr_matrix[x][y].cost +
tr_matrix[y][z].cost < /* Or we're cheaper than the existing */ if (tr_matrix[x][y].step && /* We can convert from x to y */
tr_matrix[x][z].cost) /* solution */ tr_matrix[y][z].step && /* And from y to z and... */
)) { (!tr_matrix[x][z].step || /* Either there isn't an x->z conversion */
/* We can get from x to z via y with a cost that (tr_matrix[x][y].cost +
is the sum of the transition from x to y and tr_matrix[y][z].cost < /* Or we're cheaper than the existing */
from y to z */ tr_matrix[x][z].cost) /* solution */
)) {
tr_matrix[x][z].step = tr_matrix[x][y].step; /* We can get from x to z via y with a cost that
tr_matrix[x][z].cost = tr_matrix[x][y].cost + is the sum of the transition from x to y and
tr_matrix[y][z].cost; from y to z */
if (option_debug)
ast_log(LOG_DEBUG, "Discovered %d cost path from %s to %s, via %d\n", tr_matrix[x][z].cost, ast_getformatname(x), ast_getformatname(z), y); tr_matrix[x][z].step = tr_matrix[x][y].step;
changed++; tr_matrix[x][z].cost = tr_matrix[x][y].cost +
} tr_matrix[y][z].cost;
tr_matrix[x][z].multistep = 1;
if (option_debug)
ast_log(LOG_DEBUG, "Discovered %d cost path from %s to %s, via %d\n", tr_matrix[x][z].cost, ast_getformatname(x), ast_getformatname(z), y);
changed++;
}
}
}
}
} while (changed); } while (changed);
} }
/*! \brief CLI "show translation" command handler */ /*! \brief CLI "show translation" command handler */
static int show_translation(int fd, int argc, char *argv[]) static int show_translation(int fd, int argc, char *argv[])
{ {

Loading…
Cancel
Save