[asterisk-commits] trunk r20962 - in /trunk: channel.c
include/asterisk/translate.h translate.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Apr 17 09:42:04 MST 2006
Author: kpfleming
Date: Mon Apr 17 11:42:03 2006
New Revision: 20962
URL: http://svn.digium.com/view/asterisk?rev=20962&view=rev
Log:
add an API so that the number of steps required for a translation path can be acquired
don't transcode via SLINEAR when the option is enabled but there is a direct path from the source to the destination
Modified:
trunk/channel.c
trunk/include/asterisk/translate.h
trunk/translate.c
Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=20962&r1=20961&r2=20962&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Mon Apr 17 11:42:03 2006
@@ -2744,8 +2744,9 @@
/* if the best path is not 'pass through', then
transcoding is needed; if desired, force transcode path
- to use SLINEAR between channels */
- if ((src != dst) && ast_opt_transcode_via_slin)
+ to use SLINEAR between channels, but only if there is
+ no direct conversion available */
+ if ((src != dst) && ast_opt_transcode_via_slin && ast_translate_path_steps(dst, src))
dst = AST_FORMAT_SLINEAR;
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, dst);
@@ -2763,10 +2764,12 @@
ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", peer->name, src, chan->name, dst);
return -1;
}
+
/* if the best path is not 'pass through', then
transcoding is needed; if desired, force transcode path
- to use SLINEAR between channels */
- if ((src != dst) && ast_opt_transcode_via_slin)
+ to use SLINEAR between channels, but only if there is
+ no direct conversion available */
+ if ((src != dst) && ast_opt_transcode_via_slin && ast_translate_path_steps(dst, src))
dst = AST_FORMAT_SLINEAR;
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, dst);
Modified: trunk/include/asterisk/translate.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/translate.h?rev=20962&r1=20961&r2=20962&view=diff
==============================================================================
--- trunk/include/asterisk/translate.h (original)
+++ trunk/include/asterisk/translate.h Mon Apr 17 11:42:03 2006
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
*
@@ -145,7 +145,7 @@
* \brief Register a translator
* \param t populated ast_translator structure
* This registers a codec translator with asterisk
- * Returns 0 on success, -1 on failure
+ * \return 0 on success, -1 on failure
*/
int ast_register_translator(struct ast_translator *t, void *module);
@@ -153,7 +153,7 @@
* \brief Unregister a translator
* \param t translator to unregister
* Unregisters the given tranlator
- * Returns 0 on success, -1 on failure
+ * \return 0 on success, -1 on failure
*/
int ast_unregister_translator(struct ast_translator *t);
@@ -171,7 +171,7 @@
* \param dest destination format
* \param source source format
* Build a path (possibly NULL) from source to dest
- * Returns ast_trans_pvt on success, NULL on failure
+ * \return ast_trans_pvt on success, NULL on failure
* */
struct ast_trans_pvt *ast_translator_build_path(int dest, int source);
@@ -189,9 +189,17 @@
* \param consume Whether or not to free the original frame
* Apply an input frame into the translator and receive zero or one output frames. Consume
* determines whether the original frame should be freed
- * Returns an ast_frame of the new translation format on success, NULL on failure
+ * \return an ast_frame of the new translation format on success, NULL on failure
*/
struct ast_frame *ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume);
+
+/*!
+ * \brief Returns the number of steps required to convert from 'src' to 'dest'.
+ * \param dest Destination format
+ * \param src Source format
+ * \return the number of translation steps required, or -1 if no path is available
+ */
+unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src);
#if defined(__cplusplus) || defined(c_plusplus)
}
Modified: trunk/translate.c
URL: http://svn.digium.com/view/asterisk/trunk/translate.c?rev=20962&r1=20961&r2=20962&view=diff
==============================================================================
--- trunk/translate.c (original)
+++ trunk/translate.c Mon Apr 17 11:42:03 2006
@@ -62,6 +62,8 @@
* indicates the total cost of translation and the first step.
* The full path can be reconstricted iterating on the matrix
* until step->dstfmt == desired_format.
+ *
+ * Array indexes are 'src' and 'dest', in that order.
*/
static struct translator_path tr_matrix[MAX_FORMAT][MAX_FORMAT];
@@ -651,3 +653,11 @@
return best;
}
}
+
+unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src)
+{
+ if (!tr_matrix[src][dest].step)
+ return -1;
+ else
+ return tr_matrix[src][dest].multistep;
+}
More information about the asterisk-commits
mailing list