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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 27 11:59:59 CST 2014


Author: file
Date: Mon Jan 27 11:59:57 2014
New Revision: 406642

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=406642
Log:
Implement ast_getformatname_multiple.

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=406642&r1=406641&r2=406642
==============================================================================
--- team/group/media_formats/include/asterisk/format_cap_ng.h (original)
+++ team/group/media_formats/include/asterisk/format_cap_ng.h Mon Jan 27 11:59:57 2014
@@ -218,4 +218,14 @@
  */
 int ast_format_cap_has_type(const struct ast_format_cap *cap, enum ast_media_type type);
 
+/*! \brief Get the names of a set of formats
+ * \param buf a buffer for the output string
+ * \param size size of buf (bytes)
+ * \param cap format the format (combined IDs of codecs)
+ * Prints a list of readable codec names corresponding to "format".
+ * ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)"
+ * \return The return value is buf.
+ */
+char *ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap);
+
 #endif /* _AST_FORMAT_CAP_H */

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=406642&r1=406641&r2=406642
==============================================================================
--- team/group/media_formats/main/format_cap_ng.c (original)
+++ team/group/media_formats/main/format_cap_ng.c Mon Jan 27 11:59:57 2014
@@ -439,4 +439,38 @@
 	}
 
 	return 0;
+}
+
+char *ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap)
+{
+	int idx;
+	unsigned len;
+	char *start, *end = buf;
+
+	if (!size) {
+		return buf;
+	}
+
+	snprintf(end, size, "(");
+	len = strlen(end);
+	end += len;
+	size -= len;
+	start = end;
+
+	for (idx = 0; idx < AST_VECTOR_SIZE(&cap->preference_order); ++idx) {
+		struct format_cap_framed *framed = AST_VECTOR_GET(&cap->preference_order, idx);
+
+		snprintf(end, size, "%s|", framed->format->codec->name);
+		len = strlen(end);
+		end += len;
+		size -= len;
+	}
+
+	if (start == end) {
+		ast_copy_string(start, "nothing)", size);
+	} else if (size > 1) {
+		*(end - 1) = ')';
+	}
+
+	return buf;
 }




More information about the asterisk-commits mailing list