mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
don't force transcoding through SLINEAR when transcoding is not needed at all
clean up formatting and variable names in ast_channel_make_compatible git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5483 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
66
channel.c
66
channel.c
@@ -2242,54 +2242,48 @@ int ast_channel_sendurl(struct ast_channel *chan, const char *url)
|
|||||||
|
|
||||||
int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer)
|
int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer)
|
||||||
{
|
{
|
||||||
int peerf;
|
int src;
|
||||||
int chanf;
|
int dst;
|
||||||
int res;
|
|
||||||
|
|
||||||
/* Set up translation from the chan to the peer */
|
/* Set up translation from the chan to the peer */
|
||||||
peerf = peer->nativeformats;
|
src = chan->nativeformats;
|
||||||
chanf = chan->nativeformats;
|
dst = peer->nativeformats;
|
||||||
res = ast_translator_best_choice(&peerf, &chanf);
|
if (ast_translator_best_choice(&dst, &src) < 0) {
|
||||||
if (res < 0) {
|
ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", chan->name, src, peer->name, dst);
|
||||||
ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", chan->name, chanf, peer->name, peerf);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* if desired, force all transcode paths to use SLINEAR between channels */
|
/* if the best path is not 'pass through', then
|
||||||
if (option_transcode_slin)
|
transcoding is needed; if desired, force transcode path
|
||||||
peerf = AST_FORMAT_SLINEAR;
|
to use SLINEAR between channels */
|
||||||
/* Set read format on chan */
|
if ((src != dst) && option_transcode_slin)
|
||||||
res = ast_set_read_format(chan, peerf);
|
dst = AST_FORMAT_SLINEAR;
|
||||||
if (res < 0) {
|
if (ast_set_read_format(chan, dst) < 0) {
|
||||||
ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", chan->name, chanf);
|
ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", chan->name, dst);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Set write format on peer */
|
if (ast_set_write_format(peer, dst) < 0) {
|
||||||
res = ast_set_write_format(peer, peerf);
|
ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", peer->name, dst);
|
||||||
if (res < 0) {
|
|
||||||
ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", peer->name, peerf);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Now we go the other way (peer to chan) */
|
|
||||||
peerf = peer->nativeformats;
|
/* Set up translation from the peer to the chan */
|
||||||
chanf = chan->nativeformats;
|
src = peer->nativeformats;
|
||||||
res = ast_translator_best_choice(&chanf, &peerf);
|
dst = chan->nativeformats;
|
||||||
if (res < 0) {
|
if (ast_translator_best_choice(&dst, &src) < 0) {
|
||||||
ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", peer->name, peerf, chan->name, chanf);
|
ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", peer->name, src, chan->name, dst);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* if desired, force all transcode paths to use SLINEAR between channels */
|
/* if the best path is not 'pass through', then
|
||||||
if (option_transcode_slin)
|
transcoding is needed; if desired, force transcode path
|
||||||
chanf = AST_FORMAT_SLINEAR;
|
to use SLINEAR between channels */
|
||||||
/* Set read format on peer */
|
if ((src != dst) && option_transcode_slin)
|
||||||
res = ast_set_read_format(peer, chanf);
|
dst = AST_FORMAT_SLINEAR;
|
||||||
if (res < 0) {
|
if (ast_set_read_format(peer, dst) < 0) {
|
||||||
ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", peer->name, peerf);
|
ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", peer->name, dst);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Set write format on chan */
|
if (ast_set_write_format(chan, dst) < 0) {
|
||||||
res = ast_set_write_format(chan, chanf);
|
ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", chan->name, dst);
|
||||||
if (res < 0) {
|
|
||||||
ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", chan->name, chanf);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user