[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase2 r306212 - in /team/dvossel/fixthew...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Feb 3 15:58:14 CST 2011
Author: dvossel
Date: Thu Feb 3 15:58:11 2011
New Revision: 306212
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=306212
Log:
introduction of the SILK format with attribute interface module
Added:
team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c (with props)
Modified:
team/dvossel/fixtheworld_phase2/include/asterisk/format.h
team/dvossel/fixtheworld_phase2/main/format.c
Added: team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c?view=auto&rev=306212
==============================================================================
--- team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c (added)
+++ team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c Thu Feb 3 15:58:11 2011
@@ -1,0 +1,121 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2011, 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 SILK format attribute interface
+ *
+ * \author David Vossel <dvossel at digium.com>
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/module.h"
+#include "asterisk/format.h"
+
+enum silk_attr_keys {
+ SILK_ATTR_KEY_SAMP_RATE,
+};
+
+enum silk_attr_vals {
+ SILK_ATTR_VAL_SAMP_8KHZ = (1 << 0),
+ SILK_ATTR_VAL_SAMP_12KHZ = (2 << 0),
+ SILK_ATTR_VAL_SAMP_16KHZ = (3 << 0),
+ SILK_ATTR_VAL_SAMP_24KHZ = (4 << 0),
+};
+
+struct silk_attr {
+ int samplerate;
+};
+
+static enum ast_format_cmp_res silk_cmp(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2)
+{
+ struct silk_attr *attr1 = (struct silk_attr *) fattr1;
+ struct silk_attr *attr2 = (struct silk_attr *) fattr2;
+
+ if (attr1->samplerate == attr2->samplerate) {
+ return AST_FORMAT_CMP_EQUAL;
+ }
+ if (attr1->samplerate != (attr1->samplerate & attr2->samplerate)) {
+ return AST_FORMAT_CMP_NOT_EQUAL;
+ }
+ return AST_FORMAT_CMP_SUBSET;
+
+}
+static int silk_getjoint(const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2, struct ast_format_attr *result)
+{
+ struct silk_attr *attr1 = (struct silk_attr *) fattr1;
+ struct silk_attr *attr2 = (struct silk_attr *) fattr2;
+ struct silk_attr *attr_res = (struct silk_attr *) result;
+ int joint = -1;
+
+ attr_res->samplerate = attr1->samplerate & attr2->samplerate;
+ if (attr_res->samplerate) {
+ joint = 0;
+ }
+ return joint;
+}
+
+static void silk_set(struct ast_format_attr *fattr, va_list ap)
+{
+ enum silk_attr_keys key;
+ struct silk_attr *attr = (struct silk_attr *) fattr;
+
+ for (key = va_arg(ap, int);
+ key != AST_FORMAT_ATTR_END;
+ key = va_arg(ap, int))
+ {
+ switch (key) {
+ case SILK_ATTR_KEY_SAMP_RATE:
+ attr->samplerate = (va_arg(ap, int) | attr->samplerate);
+ break;
+ default:
+ ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
+ }
+ }
+}
+
+static struct ast_format_attr_interface silk_interface = {
+ .id = AST_FORMAT_SILK,
+ .format_attr_cmp = silk_cmp,
+ .format_attr_get_joint = silk_getjoint,
+ .format_attr_set = silk_set
+};
+
+static int load_module(void)
+{
+ if (ast_format_attr_reg_interface(&silk_interface)) {
+ return AST_MODULE_LOAD_FAILURE;
+ }
+
+ return AST_MODULE_LOAD_SUCCESS;
+}
+
+static int unload_module(void)
+{
+ ast_format_attr_unreg_interface(&silk_interface);
+ return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "SILK Format Attribute Module",
+ .load = load_module,
+ .unload = unload_module,
+ .load_pri = AST_MODPRI_CHANNEL_DEPEND,
+);
Propchange: team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/dvossel/fixtheworld_phase2/formats/format_attr_silk.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/dvossel/fixtheworld_phase2/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/include/asterisk/format.h?view=diff&rev=306212&r1=306211&r2=306212
==============================================================================
--- team/dvossel/fixtheworld_phase2/include/asterisk/format.h (original)
+++ team/dvossel/fixtheworld_phase2/include/asterisk/format.h Thu Feb 3 15:58:11 2011
@@ -81,6 +81,8 @@
AST_FORMAT_SPEEX16 = 18 + AST_FORMAT_TYPE_AUDIO,
/*! Raw mu-law data (G.711) */
AST_FORMAT_TESTLAW = 19 + AST_FORMAT_TYPE_AUDIO,
+ /*! SILK format */
+ AST_FORMAT_SILK = 20 + AST_FORMAT_TYPE_AUDIO,
/*! H.261 Video */
AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO,
Modified: team/dvossel/fixtheworld_phase2/main/format.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase2/main/format.c?view=diff&rev=306212&r1=306211&r2=306212
==============================================================================
--- team/dvossel/fixtheworld_phase2/main/format.c (original)
+++ team/dvossel/fixtheworld_phase2/main/format.c Thu Feb 3 15:58:11 2011
@@ -388,6 +388,8 @@
/*! T.140 Text format - ITU T.140, RFC 4103 */
case AST_FORMAT_T140:
return (1ULL << 27);
+ case AST_FORMAT_SILK:
+ return 0; /* SILK IS NOT SUPPORTED BY OLD BITFIELD */
}
return 0;
More information about the asterisk-commits
mailing list