[asterisk-commits] file: branch group/media_formats r407184 - in /team/group/media_formats: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 3 08:59:56 CST 2014


Author: file
Date: Mon Feb  3 08:59:54 2014
New Revision: 407184

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407184
Log:
Return more detail about how compatible a format is with a capabilities structure.

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=407184&r1=407183&r2=407184
==============================================================================
--- team/group/media_formats/include/asterisk/format_cap_ng.h (original)
+++ team/group/media_formats/include/asterisk/format_cap_ng.h Mon Feb  3 08:59:54 2014
@@ -175,10 +175,9 @@
 /*!
  * \brief Find if ast_format is within the capabilities of the ast_format_cap object.
  *
- * \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_ng_iscompatible_format(const struct ast_format_cap *cap, const struct ast_format *format);
+* \retval ast_format_cmp_res representing the result of the compatibility check between cap and format.
+ */
+enum ast_format_cmp_res ast_format_cap_ng_iscompatible_format(const struct ast_format_cap *cap, const struct ast_format *format);
 
 /*!
  * \brief Find the compatible formats between two capabilities structures

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=407184&r1=407183&r2=407184
==============================================================================
--- team/group/media_formats/main/format_cap_ng.c (original)
+++ team/group/media_formats/main/format_cap_ng.c Mon Feb  3 08:59:54 2014
@@ -366,24 +366,34 @@
 	return result;
 }
 
-int ast_format_cap_ng_iscompatible_format(const struct ast_format_cap *cap, const struct ast_format *format)
-{
+enum ast_format_cmp_res ast_format_cap_ng_iscompatible_format(const struct ast_format_cap *cap,
+	const struct ast_format *format)
+{
+	enum ast_format_cmp_res res = AST_FORMAT_CMP_NOT_EQUAL;
 	struct format_cap_framed_list *list;
 	struct format_cap_framed *framed;
 
 	if (format->codec->id >= cap->formats.current) {
-		return 0;
+		return AST_FORMAT_CMP_NOT_EQUAL;
 	}
 
 	list = AST_VECTOR_GET_ADDR(&cap->formats, format->codec->id);
 
 	AST_LIST_TRAVERSE(list, framed, entry) {
-		if (ast_format_ng_cmp(format, framed->format) != AST_FORMAT_CMP_NOT_EQUAL) {
-			return 1;
-		}
-	}
-
-	return 0;
+		enum ast_format_cmp_res cmp = ast_format_ng_cmp(format, framed->format);
+
+		if (cmp == AST_FORMAT_CMP_NOT_EQUAL) {
+			continue;
+		}
+
+		res = cmp;
+
+		if (res == AST_FORMAT_CMP_EQUAL) {
+			break;
+		}
+	}
+
+	return res;
 }
 
 int ast_format_cap_ng_has_type(const struct ast_format_cap *cap, enum ast_media_type type)




More information about the asterisk-commits mailing list