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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 27 08:45:32 CST 2014


Author: file
Date: Mon Jan 27 08:45:30 2014
New Revision: 406634

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=406634
Log:
Add a function to retrieve the framing for a format.

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=406634&r1=406633&r2=406634
==============================================================================
--- team/group/media_formats/include/asterisk/format_cap_ng.h (original)
+++ team/group/media_formats/include/asterisk/format_cap_ng.h Mon Jan 27 08:45:30 2014
@@ -107,10 +107,22 @@
  * \retval non-NULL success
  * \retval NULL failure
  *
+ * \note Formats are returned in order of preference.
+ *
  * \note The reference count of the returned format is increased. It must be released using ao2_ref
  * or ao2_cleanup.
  */
-struct ast_format *ast_format_cap_get_format(struct ast_format_cap *cap, int position);
+struct ast_format *ast_format_cap_get_format(const struct ast_format_cap *cap, int position);
+
+/*!
+ * \brief Get the framing for a format
+ *
+ * \param cap The capabilities structure
+ * \param format The format to retrieve
+ *
+ * \return the framing (in milliseconds)
+ */
+unsigned int ast_format_cap_get_framing(const struct ast_format_cap *cap, const struct ast_format *format);
 
 /*!
  * \brief Remove format capability from capability structure.

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=406634&r1=406633&r2=406634
==============================================================================
--- team/group/media_formats/main/format_cap_ng.c (original)
+++ team/group/media_formats/main/format_cap_ng.c Mon Jan 27 08:45:30 2014
@@ -169,7 +169,7 @@
 	return AST_VECTOR_SIZE(&cap->preference_order);
 }
 
-struct ast_format *ast_format_cap_get_format(struct ast_format_cap *cap, int position)
+struct ast_format *ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
 {
 	struct format_cap_framed *framed;
 
@@ -181,6 +181,40 @@
 
 	ao2_ref(framed->format, +1);
 	return framed->format;
+}
+
+unsigned int ast_format_cap_get_framing(const struct ast_format_cap *cap, const struct ast_format *format)
+{
+	unsigned int framing;
+	struct format_cap_framed_list *list;
+	struct format_cap_framed *framed, *result = NULL;
+
+	if (format->codec->id >= cap->formats.current) {
+		return 0;
+	}
+
+	framing = cap->framing ? cap->framing : format->codec->default_ms;
+	list = AST_VECTOR_GET_ADDR(&cap->formats, format->codec->id);
+
+	AST_LIST_TRAVERSE(list, framed, entry) {
+		enum ast_format_cmp_res res = ast_format_cmp(format, framed->format);
+
+		if (res == AST_FORMAT_CMP_NOT_EQUAL) {
+			continue;
+		}
+
+		result = framed;
+
+		if (res == AST_FORMAT_CMP_EQUAL) {
+			break;
+		}
+	}
+
+	if (result && result->framing) {
+		framing = result->framing;
+	}
+
+	return framing;
 }
 
 /*!




More information about the asterisk-commits mailing list