Have IAX2 optimize the codec translation path just like chan_sip does it. If

the caller's codec is in our codec list, move it to the top to avoid transcoding.

(closes issue #10500)
Reported by: stevedavies
Patches:
      iax-prefer-current-codec.patch uploaded by stevedavies (license 184)
      iax-prefer-current-codec.1.4.patch uploaded by stevedavies (license 184)
Tested by: stevedavies, pj, sheldonh


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@99004 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2008-01-17 22:37:22 +00:00
parent af7670bca8
commit 6d0ee62540
3 changed files with 59 additions and 8 deletions

View File

@@ -1149,7 +1149,7 @@ void ast_codec_pref_remove(struct ast_codec_pref *pref, int format)
/*! \brief Append codec to list */
int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
{
int x, newindex = -1;
int x, newindex = 0;
ast_codec_pref_remove(pref, format);
@@ -1172,6 +1172,42 @@ int ast_codec_pref_append(struct ast_codec_pref *pref, int format)
return x;
}
/*! \brief Prepend codec to list */
void ast_codec_pref_prepend(struct ast_codec_pref *pref, int format, int only_if_existing)
{
int x, newindex = 0;
/* First step is to get the codecs "index number" */
for (x = 0; x < ARRAY_LEN(AST_FORMAT_LIST); x++) {
if (AST_FORMAT_LIST[x].bits == format) {
newindex = x + 1;
break;
}
}
/* Done if its unknown */
if (!newindex)
return;
/* Now find any existing occurrence, or the end */
for (x = 0; x < 32; x++) {
if (!pref->order[x] || pref->order[x] == newindex)
break;
}
if (only_if_existing && !pref->order[x])
return;
/* Move down to make space to insert - either all the way to the end,
or as far as the existing location (which will be overwritten) */
for (; x > 0; x--) {
pref->order[x] = pref->order[x - 1];
pref->framing[x] = pref->framing[x - 1];
}
/* And insert the new entry */
pref->order[0] = newindex;
pref->framing[0] = 0; /* ? */
}
/*! \brief Set packet size for codec */
int ast_codec_pref_setsize(struct ast_codec_pref *pref, int format, int framems)