[asterisk-commits] russell: branch russell/jack r96770 - /team/russell/jack/apps/app_jack.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jan 6 11:47:02 CST 2008


Author: russell
Date: Sun Jan  6 11:47:02 2008
New Revision: 96770

URL: http://svn.digium.com/view/asterisk?view=rev&rev=96770
Log:
Now that the application is working well, add the beginning of the audiohook
interface so that JACK can not just be the endpoint of a call, but also be
used to process audio as it flows through a channel.  This commit simply adds
the documentation for the proposed dialplan function interface.

Modified:
    team/russell/jack/apps/app_jack.c

Modified: team/russell/jack/apps/app_jack.c
URL: http://svn.digium.com/view/asterisk/team/russell/jack/apps/app_jack.c?view=diff&rev=96770&r1=96769&r2=96770
==============================================================================
--- team/russell/jack/apps/app_jack.c (original)
+++ team/russell/jack/apps/app_jack.c Sun Jan  6 11:47:02 2008
@@ -57,6 +57,7 @@
 #include "asterisk/lock.h"
 #include "asterisk/libresample.h"
 #include "asterisk/app.h"
+#include "asterisk/pbx.h"
 
 #define RESAMPLE_QUALITY 0
 
@@ -708,9 +709,62 @@
 	return 0;
 }
 
+static int jack_hook_write(struct ast_channel *chan, const char *cmd, char *data, 
+	const char *value)
+{
+	ast_log(LOG_WARNING, "JACK_HOOK() not yet implemented.\n");
+
+	return 0;
+}
+
+static struct ast_custom_function jack_hook_function = {
+	.name = "JACK_HOOK",
+	.synopsis = "Enable a jack hook on a channel",
+	.syntax = "JACK_HOOK(<mode>,[options])",
+	.desc =
+	"   The JACK_HOOK allows turning on or off jack connectivity to this channel.\n"
+	"When the JACK_HOOK is turned on, jack ports will get created that allow\n"
+	"access to the audio stream for this channel.  The mode specifies which mode\n"
+	"this hook should run in.  A mode must be specified when turning the JACK_HOOK.\n"
+	"on.  However, all arguments are optional when turning it off.\n"
+	"\n"
+	"   Valid modes are:\n"
+#if 0
+	/* XXX TODO */
+	"    spy -        Create a read-only audio hook.  Only an output jack port will\n"
+	"                 get created.\n"
+	"    whisper -    Create a write-only audio hook.  Only an input jack port will\n"
+	"                 get created.\n"
+#endif
+	"    manipulate - Create a read/write audio hook.  Both an input and an output\n"
+	"                 jack port will get created.  Audio from the channel will be\n"
+	"                 sent out the output port and will be replaced by the audio\n"
+	"                 coming in on the input port as it gets passed on.\n"
+	"\n"
+	"   Valid options are:\n"
+	"    s(<name>) - Connect to the specified jack server name.\n"
+	"    i(<name>) - Connect the output port that gets created to the specified\n"
+	"                jack input port.\n"
+	"    o(<name>) - Connect the input port that gets created to the specified\n"
+	"                jack output port.\n"
+	"\n"
+	" Examples:\n"
+	"   To turn on the JACK_HOOK,\n"
+	"     Set(JACK_HOOK(manipulate,i(pure_data_0:input0)o(pure_data_0:output0))=on)\n"
+	"   To turn off the JACK_HOOK,\n"
+	"     Set(JACK_HOOK()=off)\n"
+	"",
+	.write = jack_hook_write,
+};
+
 static int unload_module(void)
 {
-	return ast_unregister_application(jack_app);
+	int res;
+
+	res = ast_unregister_application(jack_app);
+	res |= ast_custom_function_unregister(&jack_hook_function);
+
+	return res;
 }
 
 static int load_module(void)
@@ -718,7 +772,12 @@
 	if (ast_register_application(jack_app, jack_exec, jack_synopsis, jack_desc))
 		return AST_MODULE_LOAD_DECLINE;
 
+	if (ast_custom_function_register(&jack_hook_function)) {
+		ast_unregister_application(jack_app);
+		return AST_MODULE_LOAD_DECLINE;
+	}
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Jack Application");
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "JACK Interface");




More information about the asterisk-commits mailing list