[asterisk-commits] file: branch group/pimp_my_sip r378999 - /team/group/pimp_my_sip/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 14 06:28:59 CST 2013


Author: file
Date: Mon Jan 14 06:28:54 2013
New Revision: 378999

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378999
Log:
Add skeleton channel driver.

Added:
    team/group/pimp_my_sip/channels/chan_gulp.c   (with props)

Added: team/group/pimp_my_sip/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/channels/chan_gulp.c?view=auto&rev=378999
==============================================================================
--- team/group/pimp_my_sip/channels/chan_gulp.c (added)
+++ team/group/pimp_my_sip/channels/chan_gulp.c Mon Jan 14 06:28:54 2013
@@ -1,0 +1,229 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2013, Digium, Inc.
+ *
+ * Joshua Colp <jcolp 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
+ *
+ * \author Joshua Colp <jcolp at digium.com>
+ *
+ * \brief Gulp SIP Channel Driver
+ *
+ * \ingroup channel_drivers
+ */
+
+/*** MODULEINFO
+	<depend>res_sip</depend>
+	<depend>res_sip_session</depend>
+	<support_level>core</support_level>
+ ***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include "asterisk/lock.h"
+#include "asterisk/channel.h"
+#include "asterisk/module.h"
+#include "asterisk/pbx.h"
+#include "asterisk/rtp_engine.h"
+#include "asterisk/acl.h"
+#include "asterisk/callerid.h"
+#include "asterisk/file.h"
+#include "asterisk/cli.h"
+#include "asterisk/app.h"
+#include "asterisk/musiconhold.h"
+#include "asterisk/causes.h"
+
+static const char desc[] = "Gulp SIP Channel";
+static const char channel_type[] = "Gulp";
+
+static struct ast_sched_context *sched; /*!< Scheduling context for RTCP */
+
+/* \brief Asterisk core interaction functions */
+static struct ast_channel *gulp_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause);
+static int gulp_sendtext(struct ast_channel *ast, const char *text);
+static int gulp_digit_begin(struct ast_channel *ast, char digit);
+static int gulp_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
+static int gulp_call(struct ast_channel *ast, const char *dest, int timeout);
+static int gulp_hangup(struct ast_channel *ast);
+static int gulp_answer(struct ast_channel *ast);
+static struct ast_frame *gulp_read(struct ast_channel *ast);
+static int gulp_write(struct ast_channel *ast, struct ast_frame *f);
+static int gulp_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
+static int gulp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static struct gulp_session *gulp_alloc(struct gulp_endpoint *endpoint, const char *from, const char *sid);
+
+/*! \brief PBX interface structure for channel registration */
+static struct ast_channel_tech gulp_tech = {
+	.type = channel_type,
+	.description = "Gulp SIP Channel Driver",
+	.requester = gulp_request,
+	.send_text = gulp_sendtext,
+	.send_digit_begin = gulp_digit_begin,
+	.send_digit_end = gulp_digit_end,
+	.bridge = ast_rtp_instance_bridge,
+	.call = gulp_call,
+	.hangup = gulp_hangup,
+	.answer = gulp_answer,
+	.read = gulp_read,
+	.write = gulp_write,
+	.write_video = gulp_write,
+	.exception = gulp_read,
+	.indicate = gulp_indicate,
+	.fixup = gulp_fixup,
+	.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER
+};
+
+/*! \brief Function called by RTP engine to get local RTP peer */
+static enum ast_rtp_glue_result gulp_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
+{
+	return AST_RTP_GLUE_RESULT_FORBID;
+}
+
+/*! \brief Function called by RTP engine to get peer capabilities */
+static void gulp_get_codec(struct ast_channel *chan, struct ast_format_cap *result)
+{
+}
+
+/*! \brief Function called by RTP engine to change where the remote party should send media */
+static int gulp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *tpeer, const struct ast_format_cap *cap, int nat_active)
+{
+	return -1;
+}
+
+/*! \brief Local glue for interacting with the RTP engine core */
+static struct ast_rtp_glue gulp_rtp_glue = {
+	.type = "Gulp",
+	.get_rtp_info = gulp_get_rtp_peer,
+	.get_codec = gulp_get_codec,
+	.update_peer = gulp_set_rtp_peer,
+};
+
+/*! \brief Function called by core when we should answer a Gulp session */
+static int gulp_answer(struct ast_channel *ast)
+{
+	return -1;
+}
+
+/*! \brief Function called by core to read any waiting frames */
+static struct ast_frame *gulp_read(struct ast_channel *ast)
+{
+	return NULL;
+}
+
+/*! \brief Function called by core to write frames */
+static int gulp_write(struct ast_channel *ast, struct ast_frame *frame)
+{
+	return -1;
+}
+
+/*! \brief Function called by core to change the underlying owner channel */
+static int gulp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
+{
+	return -1;
+}
+
+/*! \brief Function called by core to ask the channel to indicate some sort of condition */
+static int gulp_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
+{
+	return -1;
+}
+
+/*! \brief Function called by core to start a DTMF digit */
+static int gulp_digit_begin(struct ast_channel *chan, char digit)
+{
+	return -1;
+}
+
+/*! \brief Function called by core to stop a DTMF digit */
+static int gulp_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
+{
+	return -1;
+}
+
+/*! \brief Function called by core to actually start calling a remote party */
+static int gulp_call(struct ast_channel *ast, const char *dest, int timeout)
+{
+	return -1;
+}
+
+/*! \brief Function called by core to hang up a Gulp session */
+static int gulp_hangup(struct ast_channel *ast)
+{
+	return -1;
+}
+
+/*! \brief Function called by core to create a new outgoing Gulp session */
+static struct ast_channel *gulp_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause)
+{
+	return NULL;
+}
+
+/*!
+ * \brief Load the module
+ *
+ * Module loading including tests for configuration or dependencies.
+ * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE,
+ * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails
+ * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the 
+ * configuration file or other non-critical problem return 
+ * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.
+ */
+static int load_module(void)
+{
+	if (!(gulp_tech.capabilities = ast_format_cap_alloc())) {
+		return AST_MODULE_LOAD_DECLINE;
+	}
+
+	ast_format_cap_add_all_by_type(gulp_tech.capabilities, AST_FORMAT_TYPE_AUDIO);
+
+	ast_rtp_glue_register(&gulp_rtp_glue);
+
+	if (ast_channel_register(&gulp_tech)) {
+		ast_log(LOG_ERROR, "Unable to register channel class %s\n", channel_type);
+		goto end;
+	}
+
+	return 0;
+
+end:
+	ast_rtp_glue_unregister(&gulp_rtp_glue);
+
+	return AST_MODULE_LOAD_FAILURE;
+}
+
+/*! \brief Reload module */
+static int reload(void)
+{
+	return -1;
+}
+
+/*! \brief Unload the Gulp channel from Asterisk */
+static int unload_module(void)
+{
+	ast_channel_unregister(&gulp_tech);
+	ast_rtp_glue_unregister(&gulp_rtp_glue);
+
+	return 0;
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Gulp SIP Channel Driver",
+		.load = load_module,
+		.unload = unload_module,
+		.reload = reload,
+		.load_pri = AST_MODPRI_CHANNEL_DRIVER,
+	       );

Propchange: team/group/pimp_my_sip/channels/chan_gulp.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/group/pimp_my_sip/channels/chan_gulp.c
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/group/pimp_my_sip/channels/chan_gulp.c
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list