[asterisk-commits] russell: branch russell/chan_console r49021 - in /team/russell/chan_console: ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Dec 28 12:36:40 MST 2006


Author: russell
Date: Thu Dec 28 13:36:39 2006
New Revision: 49021

URL: http://svn.digium.com/view/asterisk?view=rev&rev=49021
Log:
- add a configuration file
- add support for hold/unhold
- add support for the generic jitterbuffer
- comment on a workaround for a potential deadlock

Added:
    team/russell/chan_console/configs/console.conf.sample   (with props)
Modified:
    team/russell/chan_console/channels/chan_console.c

Modified: team/russell/chan_console/channels/chan_console.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_console.c?view=diff&rev=49021&r1=49020&r2=49021
==============================================================================
--- team/russell/chan_console/channels/chan_console.c (original)
+++ team/russell/chan_console/channels/chan_console.c Thu Dec 28 13:36:39 2006
@@ -48,11 +48,14 @@
 #include "asterisk/pbx.h"
 #include "asterisk/causes.h"
 #include "asterisk/cli.h"
+#include "asterisk/musiconhold.h"
 
 #define SAMPLE_RATE      8000
 #define NUM_SAMPLES      160
 #define INPUT_CHANNELS   1
 #define OUTPUT_CHANNELS  1
+
+#define CONFIG_FILE      "console.conf"
 
 static struct console_pvt {
 	struct ast_channel *owner;
@@ -73,6 +76,15 @@
 
 AST_MUTEX_DEFINE_STATIC(console_lock);
 
+/*! Global jitterbuffer configuration - by default, jb is disabled */
+static struct ast_jb_conf default_jbconf = {
+	.flags = 0,
+	.max_size = -1,
+	.resync_threshold = -1,
+	.impl = ""
+};
+static struct ast_jb_conf global_jbconf;
+
 static int start_stream(void);
 static int stop_stream(void);
 
@@ -260,6 +272,27 @@
 
 static int console_indicate(struct ast_channel *chan, int cond, const void *data, size_t datalen)
 {
+	switch (cond) {
+	case AST_CONTROL_BUSY:
+	case AST_CONTROL_CONGESTION:
+	case AST_CONTROL_RINGING:
+		/* \todo Play appropriate sound to console */
+		break;
+	case AST_CONTROL_VIDUPDATE:
+		break;
+	case AST_CONTROL_HOLD:
+		ast_verbose(" << Console Has Been Placed on Hold >> \n");
+		ast_moh_start(chan, data, NULL);
+		break;
+	case AST_CONTROL_UNHOLD:
+		ast_verbose(" << Console Has Been Retrieved from Hold >> \n");
+		ast_moh_stop(chan);
+		break;
+	default:
+		ast_log(LOG_WARNING, "Don't know how to display condition %d on %s\n", cond, chan->name);
+		return -1;
+	}
+
 	return 0;
 }
 
@@ -330,6 +363,12 @@
 		fr->samples = NUM_SAMPLES;
 		fr->datalen = NUM_SAMPLES * 2;
 		memcpy(fr->data, input, NUM_SAMPLES * 2);
+		/* If the channel is in the process of being hung up, then it will be
+		 * locked while calling the console_hangup callback, and that could be
+		 * waiting to stop the audio stream, which will block until this
+		 * function returns.  Thus, locking the channel could result in a
+		 * deadlock.  So, we use the fact that the locks are recursive to test
+		 * locking the channel before queueing the frame. */
 		while (ast_channel_trylock(pvt.owner)) {
 			if (++count == 100) {
 				ast_log(LOG_DEBUG, "Dropping frame\n");
@@ -495,6 +534,30 @@
 	return 0;
 }
 
+static int load_config(int reload)
+{
+	struct ast_config *cfg;
+	struct ast_variable *v;
+
+	memcpy(&global_jbconf, &default_jbconf, sizeof(global_jbconf));
+
+	if (!(cfg = ast_config_load(CONFIG_FILE))) {
+		ast_log(LOG_NOTICE, "Unable to open configuration file %s!\n", CONFIG_FILE);
+		return -1;
+	}
+	v = ast_variable_browse(cfg, "general");
+	for (; v; v = v->next) {
+		if (!ast_jb_read_conf(&global_jbconf, v->name, v->value))
+				continue;
+
+		ast_log(LOG_WARNING, "Unknown option '%s' on line '%d' of '%s'!\n",
+			v->name, v->lineno, CONFIG_FILE);
+	}
+	ast_config_destroy(cfg);
+
+	return 0;
+}
+
 static int unload_module(void)
 {
 	ast_mutex_lock(&console_lock);
@@ -513,6 +576,9 @@
 static int load_module(void)
 {
 	PaError res;
+
+	if (load_config(0))
+		return AST_MODULE_LOAD_DECLINE;
 
 	ast_cond_init(&pvt.cond, NULL);
 
@@ -534,4 +600,13 @@
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Generic Console Channel Driver");
+static int reload(void)
+{
+	return load_config(1);
+}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Generic Console Channel Driver",
+		.load = load_module,
+		.unload = unload_module,
+		.reload = reload,
+);

Added: team/russell/chan_console/configs/console.conf.sample
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/configs/console.conf.sample?view=auto&rev=49021
==============================================================================
--- team/russell/chan_console/configs/console.conf.sample (added)
+++ team/russell/chan_console/configs/console.conf.sample Thu Dec 28 13:36:39 2006
@@ -1,0 +1,28 @@
+;
+; Configuration for chan_console
+;
+
+[general]
+
+;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
+; jbenable = yes              ; Enables the use of a jitterbuffer on the receiving side of an
+                              ; Console channel. Defaults to "no". An enabled jitterbuffer will
+                              ; be used only if the sending side can create and the receiving
+                              ; side can not accept jitter. The Console channel can't accept jitter,
+                              ; thus an enabled jitterbuffer on the receive Console side will always
+                              ; be used if the sending side can create jitter.
+
+; jbmaxsize = 200             ; Max length of the jitterbuffer in milliseconds.
+
+; jbresyncthreshold = 1000    ; Jump in the frame timestamps over which the jitterbuffer is
+                              ; resynchronized. Useful to improve the quality of the voice, with
+                              ; big jumps in/broken timestamps, usually sent from exotic devices
+                              ; and programs. Defaults to 1000.
+
+; jbimpl = fixed              ; Jitterbuffer implementation, used on the receiving side of a Console
+                              ; channel. Two implementations are currently available - "fixed"
+                              ; (with size always equals to jbmax-size) and "adaptive" (with
+                              ; variable size, actually the new jb of IAX2). Defaults to fixed.
+
+; jblog = no                  ; Enables jitterbuffer frame logging. Defaults to "no".
+;-----------------------------------------------------------------------------------

Propchange: team/russell/chan_console/configs/console.conf.sample
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/russell/chan_console/configs/console.conf.sample
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/russell/chan_console/configs/console.conf.sample
------------------------------------------------------------------------------
    svn:mime-type = text/plain



More information about the asterisk-commits mailing list