[asterisk-commits] file: branch group/media_formats r406632 - in /team/group/media_formats: incl...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jan 27 07:43:59 CST 2014
Author: file
Date: Mon Jan 27 07:43:56 2014
New Revision: 406632
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=406632
Log:
More compatibility functions!
Modified:
team/group/media_formats/include/asterisk/format_cap_ng.h
team/group/media_formats/main/format_cap_ng.c
Modified: team/group/media_formats/include/asterisk/format_cap_ng.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/format_cap_ng.h?view=diff&rev=406632&r1=406631&r2=406632
==============================================================================
--- team/group/media_formats/include/asterisk/format_cap_ng.h (original)
+++ team/group/media_formats/include/asterisk/format_cap_ng.h Mon Jan 27 07:43:56 2014
@@ -156,7 +156,35 @@
* \retval 1 format is compatible with formats held in ast_format_cap object.
* \retval 0 format is not compatible with any formats in ast_format_cap object.
*/
-int ast_format_cap_iscompatible(const struct ast_format_cap *cap, const struct ast_format *format);
+int ast_format_cap_iscompatible_format(const struct ast_format_cap *cap, const struct ast_format *format);
+
+/*!
+ * \brief Find the compatible formats between two capabilities structures
+ *
+ * \param cap1 The first capabilities structure
+ * \param cap2 The second capabilities structure
+ * \param result The capabilities structure to place the results into
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ *
+ * \note The preference order of cap1 is respected.
+ *
+ * \note If failure occurs the result format capabilities structure may contain a partial result.
+ */
+int ast_format_cap_get_compatible(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2,
+ struct ast_format_cap *result);
+
+/*!
+ * \brief Determine if any joint capabilities exist between two capabilities structures
+ *
+ * \param cap1 The first capabilities structure
+ * \param cap2 The second capabilities structure
+ *
+ * \retval 0 no joint capabilities exist
+ * \retval 1 joint capabilities exist
+ */
+int ast_format_cap_iscompatible(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2);
/*!
* \brief Find out if the capabilities structure has any formats
Modified: team/group/media_formats/main/format_cap_ng.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/format_cap_ng.c?view=diff&rev=406632&r1=406631&r2=406632
==============================================================================
--- team/group/media_formats/main/format_cap_ng.c (original)
+++ team/group/media_formats/main/format_cap_ng.c Mon Jan 27 07:43:56 2014
@@ -276,7 +276,7 @@
return result;
}
-int ast_format_cap_iscompatible(const struct ast_format_cap *cap, const struct ast_format *format)
+int ast_format_cap_iscompatible_format(const struct ast_format_cap *cap, const struct ast_format *format)
{
struct format_cap_framed_list *list;
struct format_cap_framed *framed;
@@ -309,4 +309,44 @@
}
return 0;
+}
+
+int ast_format_cap_get_compatible(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2,
+ struct ast_format_cap *result)
+{
+ int idx, res = 0;
+
+ for (idx = 0; idx < AST_VECTOR_SIZE(&cap1->preference_order); ++idx) {
+ struct format_cap_framed *framed = AST_VECTOR_GET(&cap1->preference_order, idx);
+ struct ast_format *format;
+
+ format = ast_format_cap_get_compatible_format(cap2, framed->format);
+ if (!format) {
+ continue;
+ }
+
+ res = ast_format_cap_add(result, format);
+ ao2_ref(format, -1);
+
+ if (res) {
+ break;
+ }
+ }
+
+ return res;
+}
+
+int ast_format_cap_iscompatible(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2)
+{
+ int idx;
+
+ for (idx = 0; idx < AST_VECTOR_SIZE(&cap1->preference_order); ++idx) {
+ struct format_cap_framed *framed = AST_VECTOR_GET(&cap1->preference_order, idx);
+
+ if (ast_format_cap_iscompatible_format(cap2, framed->format) != AST_FORMAT_CMP_NOT_EQUAL) {
+ return 1;
+ }
+ }
+
+ return 0;
}
More information about the asterisk-commits
mailing list