[svn-commits] kpfleming: branch 1.4 r46082 - in /branches/1.4: include/asterisk/ main/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Oct 23 20:45:42 MST 2006


Author: kpfleming
Date: Mon Oct 23 22:45:42 2006
New Revision: 46082

URL: http://svn.digium.com/view/asterisk?rev=46082&view=rev
Log:
add an API call to allow channel drivers to determine which media formats are compatible (passthrough or transcode) with the format an existing channel is already using

Modified:
    branches/1.4/include/asterisk/translate.h
    branches/1.4/main/translate.c

Modified: branches/1.4/include/asterisk/translate.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/translate.h?rev=46082&r1=46081&r2=46082&view=diff
==============================================================================
--- branches/1.4/include/asterisk/translate.h (original)
+++ branches/1.4/include/asterisk/translate.h Mon Oct 23 22:45:42 2006
@@ -205,11 +205,25 @@
 
 /*!
  * \brief Returns the number of steps required to convert from 'src' to 'dest'.
- * \param dest Destination format
- * \param src Source format
+ * \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);
+
+/*!
+ * \brief Mask off unavailable formats from a format bitmask
+ * \param dest possible destination formats
+ * \param src source formats
+ * \return 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.
+ */
+unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: branches/1.4/main/translate.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/translate.c?rev=46082&r1=46081&r2=46082&view=diff
==============================================================================
--- branches/1.4/main/translate.c (original)
+++ branches/1.4/main/translate.c Mon Oct 23 22:45:42 2006
@@ -777,3 +777,45 @@
 		return tr_matrix[src][dest].multistep + 1;
 }
 
+unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src)
+{
+	unsigned int res = dest;
+	unsigned int x;
+	unsigned int src_audio = powerof(src & AST_FORMAT_AUDIO_MASK);
+	unsigned int src_video = powerof(src & AST_FORMAT_VIDEO_MASK);
+
+	for (x = 1; x < AST_FORMAT_MAX_AUDIO; x <<= 1) {
+		/* if this is not a desired format, nothing to do */
+		if (!dest & x)
+			continue;
+
+		/* if the source is supplying this format, then
+		   we can leave it in the result */
+		if (src & x)
+			continue;
+
+		/* if we don't have a translation path from the src
+		   to this format, remove it from the result */
+		if (!tr_matrix[src_audio][powerof(x)].step)
+			res &= ~x;
+	}
+
+	/* roll over into video formats */
+	for (; x < AST_FORMAT_MAX_VIDEO; x <<= 1) {
+		/* if this is not a desired format, nothing to do */
+		if (!dest & x)
+			continue;
+
+		/* if the source is supplying this format, then
+		   we can leave it in the result */
+		if (src & x)
+			continue;
+
+		/* if we don't have a translation path from the src
+		   to this format, remove it from the result */
+		if (!tr_matrix[src_video][powerof(x)].step)
+			res &= ~x;
+	}
+
+	return res;
+}



More information about the svn-commits mailing list