[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step1 r298324 - in /team/dvossel/f...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 13 17:00:20 CST 2010
Author: dvossel
Date: Mon Dec 13 17:00:16 2010
New Revision: 298324
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=298324
Log:
Ast Format API definition
Added:
team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h (with props)
team/dvossel/fixtheworld_phase1_step1/main/format.c (with props)
Added: team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h?view=auto&rev=298324
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h (added)
+++ team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h Mon Dec 13 17:00:16 2010
@@ -1,0 +1,127 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2009-2010, Digium, Inc.
+ *
+ * David Vossel <dvossel at digium.com>
+ * Russell Bryant <russell at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief Format API
+ *
+ * \author David Vossel <dvossel at digium.com>
+ */
+
+#ifndef _AST_FORMAT_H_
+#define _AST_FORMAT_H_
+
+#define AST_FORMAT_ATTR_SIZE 128
+
+/*! \brief This structure contains the buffer used for format attributes */
+struct ast_format_attr {
+ uint8_t format_attr[AST_FORMAT_ATTR_SIZE];
+};
+
+/*! \brief Represents a media format within Asterisk. */
+struct ast_format {
+ /*! The unique id representing this format from all the other formats. */
+ unsigned int uid;
+ /*! Attribute structure used to associate attributes with a format. */
+ struct ast_format_attr *fattr;
+};
+
+/*! \brief A format must register an attribute interface if it requires the use of the format attributes void pointer */
+struct ast_format_attr_interface {
+ /*! format type */
+ unsigned int id;
+
+ /*! \brief Determine if format_attr 1 is a subset of format_attr 2.
+ *
+ * \retval 0, structure 1 has capabilities not present in structure 2
+ * \retval 1, structures are identical
+ * \retval 2, structure 1 is a subset of the capabilities in structure 2.*/
+ int (* const format_attr_cmp)(struct ast_format_attr *fattr1, struct ast_format_attr *fattr2);
+
+ /*! \brief Get joint attributes of same format type if they exist.
+ *
+ * \retval !NULL if joint attributes exist.
+ * \retval NULL if no joint attributes are present
+ */
+ struct ast_format_attr *(* const format_attr_get_joint)(struct ast_format_attr *fattr1, struct ast_format_attr *fattr2);
+
+ /*! \brief Set format capabilities based on format specific key value pairs. */
+ void (* const format_attr_set)(struct ast_format_attr *format_attr, va_list ap);
+};
+
+/*! \brief This function is used to set an ast_format object to represent a media format
+ * with optional format attributes represented by format specific key value pairs.
+ *
+ * \details Example usage.
+ * ast_format_set(format, AST_FORMAT_ULAW); // no capability attributes are needed for ULAW
+ *
+ * ast_format_set(format, AST_FORMAT_SILK, // SILK has capability attributes.
+ * AST_FORMAT_SILK_RATE, 24000,
+ * AST_FORMAT_SILK_RATE, 16000,
+ * AST_FORMAT_SILK_RATE, 12000,
+ * AST_FORMAT_SILK_RATE, 8000,
+ * AST_FORMAT_ATTR_END);
+ *
+ * \return Pointer to ast_format object.
+ */
+struct ast_format *ast_format_set(struct ast_format *format, unsigned int id, va_list ap);
+
+/*! \brief This function is used to set an ast_format object to represent a media format
+ * with optional capability attributes represented by format specific key value pairs.
+ *
+ * \details Example usage. Is this SILK format capable of 8khz
+ * is_8khz = ast_format_isset(format, AST_FORMAT_SILK_CAP_RATE, 8000);
+ *
+ * \return 0, The format key value pairs are within the capabilities defined in this structure.
+ * \return -1, The format key value pairs are _NOT_ within the capabilities of this structure.
+ */
+int ast_format_isset(struct ast_format *format, va_list ap);
+
+/*! \brief Compare ast_formats structures
+ *
+ * retval -1, format1 is not identical to format2.
+ * retval 0, both structures are identical
+ * retval 1, Of same format type, and format2 is a subset of the attributes present in format1
+ */
+int ast_format_cmp(struct ast_format *format1, struct ast_format format2);
+
+/*! \brief Find joint format attributes of two ast_format
+ * structures containing the same uid and return the union in the
+ * result structure.
+ *
+ * retval 0, joint attribute capabilities exist.
+ * retval -1, no joint attribute capabilities exist.
+ */
+int ast_format_joint(struct ast_format *format1, struct ast_format_attr *format2, struct ast_format_attr *result);
+
+/*! \brief register ast_format_attr_interface with core.
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_format_attr_reg_interface(struct ast_format_attr_interface *interface);
+
+/*! \brief unregister format_attr interface with core.
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ */
+int ast_format_attr_unreg_interface(struct ast_format_attr_interface *interface);
+
+#endif /* _AST_FORMAT_H */
Propchange: team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/dvossel/fixtheworld_phase1_step1/include/asterisk/format.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/dvossel/fixtheworld_phase1_step1/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/main/format.c?view=auto&rev=298324
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/main/format.c (added)
+++ team/dvossel/fixtheworld_phase1_step1/main/format.c Mon Dec 13 17:00:16 2010
@@ -1,0 +1,62 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2009-2010, Digium, Inc.
+ *
+ * David Vossel <dvossel at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief Format API
+ *
+ * \author David Vossel <dvossel at digium.com>
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
+
+#include "asterisk/_private.h"
+#include "asterisk/version.h"
+#include "asterisk/format.h"
+
+struct ast_format *ast_format_set(struct ast_format *format, unsigned int id, va_list ap)
+{
+ return NULL;
+}
+
+int ast_format_isset(struct ast_format *format, va_list ap)
+{
+ return 0;
+}
+
+int ast_format_cmp(struct ast_format *format1, struct ast_format format2)
+{
+ return 0;
+}
+
+int ast_format_joint(struct ast_format *format1, struct ast_format_attr *format2, struct ast_format_attr *result)
+{
+ return 0;
+}
+
+int ast_format_attr_reg_interface(struct ast_format_attr_interface *interface)
+{
+ return 0;
+}
+
+int ast_format_attr_unreg_interface(struct ast_format_attr_interface *interface)
+{
+ return 0;
+}
Propchange: team/dvossel/fixtheworld_phase1_step1/main/format.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/dvossel/fixtheworld_phase1_step1/main/format.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/dvossel/fixtheworld_phase1_step1/main/format.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the asterisk-commits
mailing list