[asterisk-commits] trunk r24621 - in /trunk: channels/chan_zap.c
funcs/func_channel.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed May 3 15:02:51 MST 2006
Author: bweschke
Date: Wed May 3 17:02:50 2006
New Revision: 24621
URL: http://svn.digium.com/view/asterisk?rev=24621&view=rev
Log:
Provide the ability to adjust txgain/rxgain on a channel level via the CHANNEL() function
Modified:
trunk/channels/chan_zap.c
trunk/funcs/func_channel.c
Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?rev=24621&r1=24620&r2=24621&view=diff
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Wed May 3 17:02:50 2006
@@ -698,6 +698,7 @@
static int zt_indicate(struct ast_channel *chan, int condition);
static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static int zt_setoption(struct ast_channel *chan, int option, void *data, int datalen);
+static int zt_func_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len);
static const struct ast_channel_tech zap_tech = {
.type = "Zap",
@@ -716,6 +717,7 @@
.indicate = zt_indicate,
.fixup = zt_fixup,
.setoption = zt_setoption,
+ .func_channel_read = zt_func_read,
};
#ifdef HAVE_LIBPRI
@@ -2903,6 +2905,25 @@
return 0;
}
+
+static int zt_func_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len)
+{
+ struct zt_pvt *p = chan->tech_pvt;
+
+ if (!strcasecmp(data, "rxgain")) {
+ ast_mutex_lock(&p->lock);
+ snprintf(buf, len, "%f", p->rxgain);
+ ast_mutex_unlock(&p->lock);
+ } else if (!strcasecmp(data, "txgain")) {
+ ast_mutex_lock(&p->lock);
+ snprintf(buf, len, "%f", p->txgain);
+ ast_mutex_unlock(&p->lock);
+ } else {
+ ast_copy_string(buf, "", len);
+ }
+ return 0;
+}
+
static void zt_unlink(struct zt_pvt *slave, struct zt_pvt *master, int needlock)
{
Modified: trunk/funcs/func_channel.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_channel.c?rev=24621&r1=24620&r2=24621&view=diff
==============================================================================
--- trunk/funcs/func_channel.c (original)
+++ trunk/funcs/func_channel.c Wed May 3 17:02:50 2006
@@ -23,6 +23,7 @@
*/
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@@ -93,6 +94,7 @@
char *data, const char *value)
{
int ret = 0;
+ signed char gainset;
if (!strcasecmp(data, "language"))
locked_string_field_set(chan, language, value);
@@ -100,7 +102,13 @@
locked_string_field_set(chan, musicclass, value);
else if (!strcasecmp(data, "callgroup"))
chan->callgroup = ast_get_group(data);
- else if (!chan->tech->func_channel_write
+ else if (!strcasecmp(data, "txgain")) {
+ sscanf(value, "%hhd", &gainset);
+ ast_channel_setoption(chan, AST_OPTION_TXGAIN, &gainset, sizeof(gainset), 0);
+ } else if (!strcasecmp(data, "rxgain")) {
+ sscanf(value, "%hhd", &gainset);
+ ast_channel_setoption(chan, AST_OPTION_RXGAIN, &gainset, sizeof(gainset), 0);
+ } else if (!chan->tech->func_channel_write
|| chan->tech->func_channel_write(chan, function, data, value)) {
ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n",
data);
@@ -123,8 +131,10 @@
"R/O channeltype technology used for channel\n"
"R/W language language for sounds played\n"
"R/W musicclass class (from musiconhold.conf) for hold music\n"
+ "R/W rxgain set rxgain level on channel drivers that support it\n"
"R/O state state for channel\n"
"R/O tonezone zone for indications played\n"
+ "R/W txgain set txgain level on channel drivers that support it\n"
"R/O videonativeformat format used natively for video\n"
"\n"
"Additional items may be available from the channel driver providing\n"
More information about the asterisk-commits
mailing list