[asterisk-commits] branch kpfleming/chanfunc r9473 - /team/kpfleming/chanfunc/funcs/func_channel.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Feb 10 20:35:20 MST 2006


Author: kpfleming
Date: Fri Feb 10 21:35:19 2006
New Revision: 9473

URL: http://svn.digium.com/view/asterisk?rev=9473&view=rev
Log:
actually implement something useful

Modified:
    team/kpfleming/chanfunc/funcs/func_channel.c

Modified: team/kpfleming/chanfunc/funcs/func_channel.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_channel.c?rev=9473&r1=9472&r2=9473&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_channel.c (original)
+++ team/kpfleming/chanfunc/funcs/func_channel.c Fri Feb 10 21:35:19 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2006, Digium, Inc.
+ * Copyright (C) 2006, Digium, Inc.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -17,6 +17,8 @@
 /*! \file
  *
  * \brief Channel info dialplan function
+ *
+ * \author Kevin P. Fleming <kpfleming at digium.com>
  * 
  */
 
@@ -26,25 +28,33 @@
 
 #include "asterisk.h"
 
-/* ASTERISK_FILE_VERSION(__FILE__, "$Revision:  $") */
+ASTERISK_FILE_VERSION(__FILE__, "$Revision:  $")
 
+#include "asterisk/module.h"
 #include "asterisk/channel.h"
 #include "asterisk/pbx.h"
 #include "asterisk/logger.h"
 #include "asterisk/utils.h"
 #include "asterisk/app.h"
+#include "asterisk/indications.h"
 
 static char *func_channel(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
-	ast_copy_string(buf, chan->language, len);
+        if (!strcasecmp(data, "audionativeformat"))
+                ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_AUDIO_MASK);
+        else if (!strcasecmp(data, "videonativeformat"))
+                ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_VIDEO_MASK);
+        else if (!strcasecmp(data, "audioreadformat"))
+                ast_copy_string(buf, ast_getformatname(chan->readformat), len);
+        else if (!strcasecmp(data, "audiowriteformat"))
+                ast_copy_string(buf, ast_getformatname(chan->writeformat), len);
+        else if (!strcasecmp(data, "tonezone"))
+                ast_copy_string(buf, chan->zone->country, len);
 
 	return buf;
 }
 
-#ifndef BUILTIN_FUNC
-static
-#endif
-struct ast_custom_function channel_function = {
+static struct ast_custom_function channel_function = {
 	.name = "CHANNEL",
 	.synopsis = "Gets various pieces of information about the channel.",
 	.syntax = "CHANNEL(item)",
@@ -64,6 +74,33 @@
 	.read = func_channel,
 };
 
+static char *tdesc = "Channel information dialplan function";
+
+int unload_module(void)
+{
+        return ast_custom_function_unregister(&channel_function);
+}
+
+int load_module(void)
+{
+        return ast_custom_function_register(&channel_function);
+}
+
+char *description(void)
+{
+	return tdesc;
+}
+
+int usecount(void)
+{
+	return 0;
+}
+
+char *key()
+{
+	return ASTERISK_GPL_KEY;
+}
+
 /*
 Local Variables:
 mode: C



More information about the asterisk-commits mailing list