[svn-commits] dvossel: branch dvossel/jb_ftw r311857 - /team/dvossel/jb_ftw/funcs/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Mar 29 16:48:59 CDT 2011
Author: dvossel
Date: Tue Mar 29 16:48:55 2011
New Revision: 311857
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311857
Log:
Introduction of func_jitterbuffer
Added:
team/dvossel/jb_ftw/funcs/func_jitterbuffer.c (with props)
Added: team/dvossel/jb_ftw/funcs/func_jitterbuffer.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/jb_ftw/funcs/func_jitterbuffer.c?view=auto&rev=311857
==============================================================================
--- team/dvossel/jb_ftw/funcs/func_jitterbuffer.c (added)
+++ team/dvossel/jb_ftw/funcs/func_jitterbuffer.c Tue Mar 29 16:48:55 2011
@@ -1,0 +1,130 @@
+/*
+ * 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 Put a jitterbuffer on the read side of a channel
+ *
+ * \author David Vossel <dvossel at digium.com>
+ *
+ * \ingroup functions
+ */
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/module.h"
+#include "asterisk/channel.h"
+#include "asterisk/framehook.h"
+#include "asterisk/pbx.h"
+
+
+struct jb_framedata {
+ /*jb stuff todohere, don't know what this is yet */
+ int data;
+};
+
+static void datastore_destroy_cb(void *data) {
+ ast_free(data);
+}
+
+static const struct ast_datastore_info jb_datastore = {
+ .type = "jitterbuffer",
+ .destroy = datastore_destroy_cb
+};
+
+static void hook_destroy_cb(void *framedata)
+{
+ ast_free(framedata);
+}
+
+static struct ast_frame *hook_event_cb(struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *data)
+{
+ //struct jb_framedata *framedata = data;
+ /* todohere add jb logic, just passing frame through right now. */
+ return frame;
+}
+
+static int jb_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value)
+{
+ struct jb_framedata *framedata;
+ struct ast_datastore *datastore = NULL;
+ struct ast_framehook_interface interface = {
+ .version = AST_FRAMEHOOK_INTERFACE_VERSION,
+ .event_cb = hook_event_cb,
+ .destroy_cb = hook_destroy_cb,
+ };
+ int i = 0;
+
+ if (!(framedata = ast_calloc(1, sizeof(*framedata)))) {
+ return 0;
+ }
+
+ interface.data = framedata;
+
+ ast_channel_lock(chan);
+ i = ast_framehook_attach(chan, &interface);
+ if (i >= 0) {
+ int *id;
+ if ((datastore = ast_channel_datastore_find(chan, &jb_datastore, NULL))) {
+ id = datastore->data;
+ ast_framehook_detach(chan, *id);
+ ast_channel_datastore_remove(chan, datastore);
+ }
+
+ if (!(datastore = ast_datastore_alloc(&jb_datastore, NULL))) {
+ ast_framehook_detach(chan, i);
+ ast_channel_unlock(chan);
+ return 0;
+ }
+
+ if (!(id = ast_calloc(1, sizeof(int)))) {
+ ast_datastore_free(datastore);
+ ast_framehook_detach(chan, i);
+ ast_channel_unlock(chan);
+ return 0;
+ }
+
+ *id = i; /* Store off the id. The channel is still locked so it is safe to access this ptr. */
+ datastore->data = id;
+ ast_channel_datastore_add(chan, datastore);
+ }
+ ast_channel_unlock(chan);
+
+ return 0;
+}
+
+static struct ast_custom_function jb_function = {
+ .name = "JITTERBUFFER",
+ .write = jb_helper,
+};
+
+static int unload_module(void)
+{
+ return ast_custom_function_unregister(&jb_function);
+}
+
+static int load_module(void)
+{
+ int res = ast_custom_function_register(&jb_function);
+ return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Jitter buffer for read side of channel.");
+
Propchange: team/dvossel/jb_ftw/funcs/func_jitterbuffer.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/dvossel/jb_ftw/funcs/func_jitterbuffer.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/dvossel/jb_ftw/funcs/func_jitterbuffer.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the svn-commits
mailing list