[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r303852 - in /team/dvossel/f...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jan 25 12:34:06 CST 2011
Author: dvossel
Date: Tue Jan 25 12:34:01 2011
New Revision: 303852
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=303852
Log:
Addition of the ast_format_append function so ast_format_set initialize the ast_format structure
Modified:
team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h
team/dvossel/fixtheworld_phase1_step3/main/format.c
team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c
Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h?view=diff&rev=303852&r1=303851&r2=303852
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format.h Tue Jan 25 12:34:01 2011
@@ -175,10 +175,33 @@
* AST_FORMAT_SILK_ATTR_RATE, 8000,
* AST_FORMAT_ATTR_END);
*
+ * \note This function will initialize the ast_format structure.
+ *
* \return Pointer to ast_format object, same pointer that is passed in
* by the first argument.
*/
struct ast_format *ast_format_set(struct ast_format *format, enum ast_format_id id, int set_attributes, ... );
+
+/*!
+ * \brief After ast_format_set has been used on a function, this function can be used to
+ * set additional format attributes to the structure.
+ *
+ * \param format to set
+ * \param var list of attribute key value pairs, must end with AST_FORMAT_ATTR_END;
+ *
+ * \details Example usage.
+ * ast_format_set(format, AST_FORMAT_SILK, 0);
+ * ast_format_append(format, // SILK has capability attributes.
+ * AST_FORMAT_SILK_ATTR_RATE, 24000,
+ * AST_FORMAT_SILK_ATTR_RATE, 16000,
+ * AST_FORMAT_SILK_ATTR_RATE, 12000,
+ * AST_FORMAT_SILK_ATTR_RATE, 8000,
+ * AST_FORMAT_ATTR_END);
+ *
+ * \return Pointer to ast_format object, same pointer that is passed in
+ * by the first argument.
+ */
+struct ast_format *ast_format_append(struct ast_format *format, ... );
/*!
* \brief Clears the format stucture.
Modified: team/dvossel/fixtheworld_phase1_step3/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format.c?view=diff&rev=303852&r1=303851&r2=303852
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format.c Tue Jan 25 12:34:01 2011
@@ -130,11 +130,21 @@
return 0;
}
+struct ast_format *ast_format_append(struct ast_format *format, ... )
+{
+ va_list ap;
+ va_start(ap, format);
+ format_set_helper(format, ap);
+ va_end(ap);
+
+ return format;
+}
+
struct ast_format *ast_format_set(struct ast_format *format, enum ast_format_id id, int set_attributes, ... )
{
- if (format->id != id) {
- memset(&format->fattr, 0, sizeof(format->fattr));
- }
+ /* initialize the structure before setting it. */
+ ast_format_clear(format);
+
format->id = id;
if (set_attributes) {
@@ -146,7 +156,6 @@
return format;
}
-
void ast_format_clear(struct ast_format *format)
{
Modified: team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c?view=diff&rev=303852&r1=303851&r2=303852
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/tests/test_format_api.c Tue Jan 25 12:34:01 2011
@@ -176,7 +176,7 @@
}
/* append the string attribute to a format with previous attributes already set */
- ast_format_set(&format1, AST_FORMAT_TESTLAW, 1,
+ ast_format_append(&format1,
TEST_ATTR_KEY_STRING,"String",
AST_FORMAT_ATTR_END);
if (ast_format_isset(&format1, TEST_ATTR_KEY_STRING, "String", AST_FORMAT_ATTR_END)) {
More information about the asterisk-commits
mailing list