[asterisk-commits] kpfleming: trunk r37988 - in /trunk: ./ apps/
channels/ configs/ include/aste...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Jul 19 13:44:39 MST 2006
Author: kpfleming
Date: Wed Jul 19 15:44:39 2006
New Revision: 37988
URL: http://svn.digium.com/view/asterisk?rev=37988&view=rev
Log:
merge Russell's 'hold_handling' branch, finally implementing music-on-hold handling the way it was decided at AstriDevCon Europe 2006 (and the way people really want it to be)
Modified:
trunk/apps/app_dial.c
trunk/apps/app_followme.c
trunk/apps/app_meetme.c
trunk/apps/app_queue.c
trunk/channel.c
trunk/channels/chan_agent.c
trunk/channels/chan_alsa.c
trunk/channels/chan_h323.c
trunk/channels/chan_iax2.c
trunk/channels/chan_jingle.c
trunk/channels/chan_mgcp.c
trunk/channels/chan_misdn.c
trunk/channels/chan_oss.c
trunk/channels/chan_phone.c
trunk/channels/chan_sip.c
trunk/channels/chan_skinny.c
trunk/channels/chan_vpb.cc
trunk/channels/chan_zap.c
trunk/configs/alsa.conf.sample
trunk/configs/features.conf.sample
trunk/configs/iax.conf.sample
trunk/configs/queues.conf.sample
trunk/configs/sip.conf.sample
trunk/configs/skinny.conf.sample
trunk/configs/zapata.conf.sample
trunk/include/asterisk/musiconhold.h
trunk/pbx.c
trunk/res/res_agi.c
trunk/res/res_features.c
trunk/res/res_musiconhold.c
Modified: trunk/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_dial.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Wed Jul 19 15:44:39 2006
@@ -1214,8 +1214,8 @@
/* Our status will at least be NOANSWER */
strcpy(status, "NOANSWER");
if (ast_test_flag(outgoing, OPT_MUSICBACK)) {
- moh=1;
- ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK]);
+ moh = 1;
+ ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK], NULL);
} else if (ast_test_flag(outgoing, OPT_RINGBACK)) {
ast_indicate(chan, AST_CONTROL_RINGING);
sentringing++;
@@ -1273,7 +1273,7 @@
if (ast_test_flag(&opts, OPT_MUSICBACK) && !ast_strlen_zero(opt_args[OPT_ARG_MUSICBACK])) {
ast_indicate(chan, -1);
- ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK]);
+ ast_moh_start(chan, opt_args[OPT_ARG_MUSICBACK], NULL);
} else if (ast_test_flag(&opts, OPT_RINGBACK)) {
ast_indicate(chan, AST_CONTROL_RINGING);
sentringing++;
@@ -1701,7 +1701,7 @@
res = ast_waitstream(chan, AST_DIGIT_ANY);
if (!res && sleep) {
if (!ast_test_flag(chan, AST_FLAG_MOH))
- ast_moh_start(chan, NULL);
+ ast_moh_start(chan, NULL, NULL);
res = ast_waitfordigit(chan, sleep);
}
} else {
@@ -1709,7 +1709,7 @@
res = ast_waitstream(chan, "");
if (sleep) {
if (!ast_test_flag(chan, AST_FLAG_MOH))
- ast_moh_start(chan, NULL);
+ ast_moh_start(chan, NULL, NULL);
if (!res)
res = ast_waitfordigit(chan, sleep);
}
Modified: trunk/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_followme.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/apps/app_followme.c (original)
+++ trunk/apps/app_followme.c Wed Jul 19 15:44:39 2006
@@ -1010,10 +1010,7 @@
goto outrun;
if (ast_waitstream(chan, "") < 0)
goto outrun;
- if (!strcmp(targs.mohclass, ""))
- ast_moh_start(chan, NULL);
- else
- ast_moh_start(chan, targs.mohclass);
+ ast_moh_start(chan, S_OR(targs.mohclass, NULL), NULL);
targs.status = 0;
Modified: trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_meetme.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Wed Jul 19 15:44:39 2006
@@ -1407,7 +1407,7 @@
}
}
if (musiconhold == 0 && (confflags & CONFFLAG_MOH)) {
- ast_moh_start(chan, NULL);
+ ast_moh_start(chan, NULL, NULL);
musiconhold = 1;
} else {
ztc.confmode = ZT_CONF_CONF;
@@ -1445,7 +1445,7 @@
if ((confflags & CONFFLAG_MOH) && !(confflags & CONFFLAG_WAITMARKED)) {
if (conf->users == 1) {
if (musiconhold == 0) {
- ast_moh_start(chan, NULL);
+ ast_moh_start(chan, NULL, NULL);
musiconhold = 1;
}
} else {
@@ -1749,7 +1749,7 @@
}
}
if (musiconhold)
- ast_moh_start(chan, NULL);
+ ast_moh_start(chan, NULL, NULL);
if (ioctl(fd, ZT_SETCONF, &ztc)) {
ast_log(LOG_WARNING, "Error setting conference\n");
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Wed Jul 19 15:44:39 2006
@@ -761,7 +761,8 @@
char *c, *lastc;
char buff[80];
- if (!strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) {
+ if (!strcasecmp(param, "musicclass") ||
+ !strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) {
ast_copy_string(q->moh, val, sizeof(q->moh));
} else if (!strcasecmp(param, "announce")) {
ast_copy_string(q->announce, val, sizeof(q->announce));
@@ -1343,7 +1344,7 @@
/* Don't restart music on hold if we're about to exit the caller from the queue */
if (!res)
- ast_moh_start(qe->chan, qe->moh);
+ ast_moh_start(qe->chan, qe->moh, NULL);
return res;
}
@@ -1782,7 +1783,7 @@
/* Resume Music on Hold if the caller is going to stay in the queue */
if (!res)
- ast_moh_start(qe->chan, qe->moh);
+ ast_moh_start(qe->chan, qe->moh, NULL);
/* update last_periodic_announce_time */
qe->last_periodic_announce_time = now;
@@ -3311,7 +3312,7 @@
if (ringing) {
ast_indicate(chan, AST_CONTROL_RINGING);
} else {
- ast_moh_start(chan, qe.moh);
+ ast_moh_start(chan, qe.moh, NULL);
}
for (;;) {
/* This is the wait loop for callers 2 through maxlen */
Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Wed Jul 19 15:44:39 2006
@@ -3881,11 +3881,11 @@
return group;
}
-static int (*ast_moh_start_ptr)(struct ast_channel *, const char *) = NULL;
+static int (*ast_moh_start_ptr)(struct ast_channel *, const char *, const char *) = NULL;
static void (*ast_moh_stop_ptr)(struct ast_channel *) = NULL;
static void (*ast_moh_cleanup_ptr)(struct ast_channel *) = NULL;
-void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, const char *),
+void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, const char *, const char *),
void (*stop_ptr)(struct ast_channel *),
void (*cleanup_ptr)(struct ast_channel *))
{
@@ -3902,14 +3902,16 @@
}
/*! \brief Turn on music on hold on a given channel */
-int ast_moh_start(struct ast_channel *chan, const char *mclass)
+int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
{
if (ast_moh_start_ptr)
- return ast_moh_start_ptr(chan, mclass);
-
- if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "Music class %s requested but no musiconhold loaded.\n", mclass ? mclass : "default");
-
+ return ast_moh_start_ptr(chan, mclass, interpclass);
+
+ if (option_verbose > 2) {
+ ast_verbose(VERBOSE_PREFIX_3 "Music class %s requested but no musiconhold loaded.\n",
+ mclass ? mclass : (interpclass ? interpclass : "default"));
+ }
+
return 0;
}
Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Wed Jul 19 15:44:39 2006
@@ -595,7 +595,7 @@
int res = -1;
ast_mutex_lock(&p->lock);
if (p->chan)
- res = ast_indicate(p->chan, condition);
+ res = ast_indicate_data(p->chan, condition, data, datalen);
else
res = 0;
ast_mutex_unlock(&p->lock);
@@ -773,7 +773,9 @@
ast_channel_unlock(p->chan);
} else if (p->loginstart) {
ast_channel_lock(p->chan);
- ast_moh_start(p->chan, p->moh);
+ ast_indicate_data(p->chan, AST_CONTROL_HOLD,
+ S_OR(p->moh, NULL),
+ !ast_strlen_zero(p->moh) ? strlen(p->moh) + 1 : 0);
ast_channel_unlock(p->chan);
}
}
@@ -965,7 +967,7 @@
ast_log( LOG_ERROR, "A blocker exists after agent channel ownership acquired\n" );
CRASH;
}
- ast_moh_stop(p->chan);
+ ast_indicate(p->chan, AST_CONTROL_UNHOLD);
}
return tmp;
}
@@ -1964,12 +1966,9 @@
res = ast_safe_sleep(chan, 500);
ast_mutex_unlock(&p->lock);
} else if (!res) {
-#ifdef HONOR_MUSIC_CLASS
- /* check if the moh class was changed with setmusiconhold */
- if (*(chan->musicclass))
- ast_copy_string(p->moh, chan->musicclass, sizeof(p->moh));
-#endif
- ast_moh_start(chan, p->moh);
+ ast_indicate_data(chan, AST_CONTROL_HOLD,
+ S_OR(p->moh, NULL),
+ !ast_strlen_zero(p->moh) ? strlen(p->moh) + 1 : 0);
if (p->loginstart == 0)
time(&p->loginstart);
manager_event(EVENT_FLAG_AGENT, "Agentlogin",
Modified: trunk/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_alsa.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/channels/chan_alsa.c (original)
+++ trunk/channels/chan_alsa.c Wed Jul 19 15:44:39 2006
@@ -61,6 +61,7 @@
#include "asterisk/endian.h"
#include "asterisk/stringfields.h"
#include "asterisk/abstract_jb.h"
+#include "asterisk/musiconhold.h"
#include "busy.h"
#include "ringtone.h"
@@ -127,6 +128,7 @@
static char context[AST_MAX_CONTEXT] = "default";
static char language[MAX_LANGUAGE] = "";
static char exten[AST_MAX_EXTENSION] = "s";
+static char mohinterpret[MAX_MUSICCLASS];
static int hookstate=0;
@@ -764,7 +766,9 @@
static int alsa_indicate(struct ast_channel *chan, int cond, const void *data, size_t datalen)
{
int res = 0;
- ast_mutex_lock(&alsalock);
+
+ ast_mutex_lock(&alsalock);
+
switch(cond) {
case AST_CONTROL_BUSY:
res = 1;
@@ -773,7 +777,6 @@
res = 2;
break;
case AST_CONTROL_RINGING:
- res = 0;
break;
case -1:
res = -1;
@@ -781,14 +784,24 @@
case AST_CONTROL_VIDUPDATE:
res = -1;
break;
+ case AST_CONTROL_HOLD:
+ ast_verbose( " << Console Has Been Placed on Hold >> \n");
+ ast_moh_start(chan, data, mohinterpret);
+ 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);
res = -1;
}
- if (res > -1) {
+
+ if (res > -1)
write(sndcmd[1], &res, sizeof(res));
- }
- ast_mutex_unlock(&alsalock);
+
+ ast_mutex_unlock(&alsalock);
+
return res;
}
@@ -1068,14 +1081,15 @@
/* Copy the default jb config over global_jbconf */
memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
+ strcpy(mohinterpret, "default");
+
if ((cfg = ast_config_load(config))) {
v = ast_variable_browse(cfg, "general");
- while(v) {
+ for (; v; v = v->next) {
/* handle jb conf */
- if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
- v = v->next;
+ if (!ast_jb_read_conf(&global_jbconf, v->name, v->value))
continue;
- }
+
if (!strcasecmp(v->name, "autoanswer"))
autoanswer = ast_true(v->value);
else if (!strcasecmp(v->name, "silencesuppression"))
@@ -1083,16 +1097,17 @@
else if (!strcasecmp(v->name, "silencethreshold"))
silencethreshold = atoi(v->value);
else if (!strcasecmp(v->name, "context"))
- strncpy(context, v->value, sizeof(context)-1);
+ ast_copy_string(context, v->value, sizeof(context));
else if (!strcasecmp(v->name, "language"))
- strncpy(language, v->value, sizeof(language)-1);
+ ast_copy_string(language, v->value, sizeof(language));
else if (!strcasecmp(v->name, "extension"))
- strncpy(exten, v->value, sizeof(exten)-1);
+ ast_copy_string(exten, v->value, sizeof(exten));
else if (!strcasecmp(v->name, "input_device"))
- strncpy(indevname, v->value, sizeof(indevname)-1);
+ ast_copy_string(indevname, v->value, sizeof(indevname));
else if (!strcasecmp(v->name, "output_device"))
- strncpy(outdevname, v->value, sizeof(outdevname)-1);
- v=v->next;
+ ast_copy_string(outdevname, v->value, sizeof(outdevname));
+ else if (!strcasecmp(v->name, "mohinterpret"))
+ ast_copy_string(mohinterpret, v->value, sizeof(mohinterpret));
}
ast_config_destroy(cfg);
}
Modified: trunk/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_h323.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Wed Jul 19 15:44:39 2006
@@ -702,6 +702,16 @@
if (token)
free(token);
return -1;
+ case AST_CONTROL_HOLD:
+ ast_moh_start(c, data, NULL);
+ if (token)
+ free(token);
+ return 0;
+ case AST_CONTROL_UNHOLD:
+ ast_moh_stop(c);
+ if (token)
+ free(token);
+ return 0;
case AST_CONTROL_PROCEEDING:
case -1:
if (token)
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Wed Jul 19 15:44:39 2006
@@ -217,6 +217,8 @@
#endif /* IAXTESTS */
static char accountcode[AST_MAX_ACCOUNT_CODE];
+static char mohinterpret[MAX_MUSICCLASS];
+static char mohsuggest[MAX_MUSICCLASS];
static int amaflags = 0;
static int adsi = 0;
static int delayreject = 0;
@@ -283,6 +285,8 @@
int authmethods;
int encmethods;
char accountcode[AST_MAX_ACCOUNT_CODE];
+ char mohinterpret[MAX_MUSICCLASS];
+ char mohsuggest[MAX_MUSICCLASS];
char inkeys[80]; /*!< Key(s) this user can use to authenticate to us */
char language[MAX_LANGUAGE];
int amaflags;
@@ -310,6 +314,8 @@
char regexten[AST_MAX_EXTENSION]; /*!< Extension to register (if regcontext is used) */
char peercontext[AST_MAX_EXTENSION]; /*!< Context to pass to peer */
char mailbox[AST_MAX_EXTENSION]; /*!< Mailbox */
+ char mohinterpret[MAX_MUSICCLASS];
+ char mohsuggest[MAX_MUSICCLASS];
struct ast_codec_pref prefs;
struct ast_dnsmgr_entry *dnsmgr; /*!< DNS refresh manager */
struct sockaddr_in addr;
@@ -590,6 +596,8 @@
int calling_pres;
char dproot[AST_MAX_EXTENSION];
char accountcode[AST_MAX_ACCOUNT_CODE];
+ char mohinterpret[MAX_MUSICCLASS];
+ char mohsuggest[MAX_MUSICCLASS];
int amaflags;
struct iax2_dpcache *dpentries;
struct ast_variable *vars;
@@ -1226,6 +1234,8 @@
iaxs[x]->amaflags = amaflags;
ast_copy_flags(iaxs[x], (&globalflags), IAX_NOTRANSFER | IAX_TRANSFERMEDIA | IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
ast_copy_string(iaxs[x]->accountcode, accountcode, sizeof(iaxs[x]->accountcode));
+ ast_copy_string(iaxs[x]->mohinterpret, mohinterpret, sizeof(iaxs[x]->mohinterpret));
+ ast_copy_string(iaxs[x]->mohsuggest, mohsuggest, sizeof(iaxs[x]->mohsuggest));
} else {
ast_log(LOG_WARNING, "Out of resources\n");
ast_mutex_unlock(&iaxsl[x]);
@@ -2577,6 +2587,8 @@
char prefs[32];
char context[AST_MAX_CONTEXT];
char peercontext[AST_MAX_CONTEXT];
+ char mohinterpret[MAX_MUSICCLASS];
+ char mohsuggest[MAX_MUSICCLASS];
};
static int create_addr(const char *peername, struct sockaddr_in *sin, struct create_addr_info *cai)
@@ -2634,6 +2646,8 @@
ast_copy_string(cai->username, peer->username, sizeof(cai->username));
ast_copy_string(cai->timezone, peer->zonetag, sizeof(cai->timezone));
ast_copy_string(cai->outkey, peer->outkey, sizeof(cai->outkey));
+ ast_copy_string(cai->mohinterpret, peer->mohinterpret, sizeof(cai->mohinterpret));
+ ast_copy_string(cai->mohsuggest, peer->mohsuggest, sizeof(cai->mohsuggest));
if (ast_strlen_zero(peer->dbsecret)) {
ast_copy_string(cai->secret, peer->secret, sizeof(cai->secret));
} else {
@@ -2881,6 +2895,9 @@
iaxs[callno]->encmethods = cai.encmethods;
iaxs[callno]->adsi = cai.adsi;
+
+ ast_copy_string(iaxs[callno]->mohinterpret, cai.mohinterpret, sizeof(iaxs[callno]->mohinterpret));
+ ast_copy_string(iaxs[callno]->mohsuggest, cai.mohsuggest, sizeof(iaxs[callno]->mohsuggest));
if (pds.key)
ast_copy_string(iaxs[callno]->outkey, pds.key, sizeof(iaxs[callno]->outkey));
@@ -3168,9 +3185,23 @@
static int iax2_indicate(struct ast_channel *c, int condition, const void *data, size_t datalen)
{
unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
+
if (option_debug && iaxdebug)
ast_log(LOG_DEBUG, "Indicating condition %d\n", condition);
- return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, data, datalen, -1);
+
+ if (!strcasecmp(iaxs[callno]->mohinterpret, "passthrough"))
+ return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, data, datalen, -1);
+
+ switch (condition) {
+ case AST_CONTROL_HOLD:
+ ast_moh_start(c, data, iaxs[callno]->mohinterpret);
+ return 0;
+ case AST_CONTROL_UNHOLD:
+ ast_moh_stop(c);
+ return 0;
+ default:
+ return send_command_locked(callno, AST_FRAME_CONTROL, condition, 0, data, datalen, -1);
+ }
}
static int iax2_transfer(struct ast_channel *c, const char *dest)
@@ -4703,6 +4734,10 @@
}
if (!ast_strlen_zero(user->accountcode))
ast_copy_string(iaxs[callno]->accountcode, user->accountcode, sizeof(iaxs[callno]->accountcode));
+ if (!ast_strlen_zero(user->mohinterpret))
+ ast_copy_string(iaxs[callno]->mohinterpret, user->mohinterpret, sizeof(iaxs[callno]->mohinterpret));
+ if (!ast_strlen_zero(user->mohsuggest))
+ ast_copy_string(iaxs[callno]->mohsuggest, user->mohsuggest, sizeof(iaxs[callno]->mohsuggest));
if (user->amaflags)
iaxs[callno]->amaflags = user->amaflags;
if (!ast_strlen_zero(user->language))
@@ -6668,9 +6703,12 @@
ast_set_flag(iaxs[fr->callno], IAX_QUELCH);
if (ies.musiconhold) {
- if (iaxs[fr->callno]->owner &&
- ast_bridged_channel(iaxs[fr->callno]->owner))
- ast_moh_start(ast_bridged_channel(iaxs[fr->callno]->owner), NULL);
+ if (iaxs[fr->callno]->owner && ast_bridged_channel(iaxs[fr->callno]->owner)) {
+ const char *mohsuggest = iaxs[fr->callno]->mohsuggest;
+ ast_queue_control_data(iaxs[fr->callno]->owner, AST_CONTROL_HOLD,
+ S_OR(mohsuggest, NULL),
+ !ast_strlen_zero(mohsuggest) ? strlen(mohsuggest) + 1 : 0);
+ }
}
}
break;
@@ -6686,9 +6724,8 @@
}
ast_clear_flag(iaxs[fr->callno], IAX_QUELCH);
- if (iaxs[fr->callno]->owner &&
- ast_bridged_channel(iaxs[fr->callno]->owner))
- ast_moh_stop(ast_bridged_channel(iaxs[fr->callno]->owner));
+ if (iaxs[fr->callno]->owner && ast_bridged_channel(iaxs[fr->callno]->owner))
+ ast_queue_control(iaxs[fr->callno]->owner, AST_CONTROL_UNHOLD);
}
break;
case IAX_COMMAND_TXACC:
@@ -8244,6 +8281,10 @@
ast_copy_string(peer->secret, v->value, sizeof(peer->secret));
} else if (!strcasecmp(v->name, "mailbox")) {
ast_copy_string(peer->mailbox, v->value, sizeof(peer->mailbox));
+ } else if (!strcasecmp(v->name, "mohinterpret")) {
+ ast_copy_string(peer->mohinterpret, v->value, sizeof(peer->mohinterpret));
+ } else if (!strcasecmp(v->name, "mohsuggest")) {
+ ast_copy_string(peer->mohsuggest, v->value, sizeof(peer->mohsuggest));
} else if (!strcasecmp(v->name, "dbsecret")) {
ast_copy_string(peer->dbsecret, v->value, sizeof(peer->dbsecret));
} else if (!strcasecmp(v->name, "trunk")) {
@@ -8502,6 +8543,10 @@
ast_set_flag(user, IAX_HASCALLERID);
} else if (!strcasecmp(v->name, "accountcode")) {
ast_copy_string(user->accountcode, v->value, sizeof(user->accountcode));
+ } else if (!strcasecmp(v->name, "mohinterpret")) {
+ ast_copy_string(user->mohinterpret, v->value, sizeof(user->mohinterpret));
+ } else if (!strcasecmp(v->name, "mohsuggest")) {
+ ast_copy_string(user->mohsuggest, v->value, sizeof(user->mohsuggest));
} else if (!strcasecmp(v->name, "language")) {
ast_copy_string(user->language, v->value, sizeof(user->language));
} else if (!strcasecmp(v->name, "amaflags")) {
@@ -8878,6 +8923,10 @@
ast_log(LOG_WARNING, "Invalid tos value at line %d, see doc/ip-tos.txt for more information.'\n", v->lineno);
} else if (!strcasecmp(v->name, "accountcode")) {
ast_copy_string(accountcode, v->value, sizeof(accountcode));
+ } else if (!strcasecmp(v->name, "mohinterpret")) {
+ ast_copy_string(mohinterpret, v->value, sizeof(user->mohinterpret));
+ } else if (!strcasecmp(v->name, "mohsuggest")) {
+ ast_copy_string(mohsuggest, v->value, sizeof(user->mohsuggest));
} else if (!strcasecmp(v->name, "amaflags")) {
format = ast_cdr_amaflags2int(v->value);
if (format < 0) {
@@ -8956,8 +9005,10 @@
struct iax2_registry *reg;
struct iax2_peer *peer = NULL;
- ast_copy_string(accountcode, "", sizeof(accountcode));
- ast_copy_string(language, "", sizeof(language));
+ strcpy(accountcode, "");
+ strcpy(language, "");
+ strcpy(mohinterpret, "default");
+ strcpy(mohsuggest, "");
amaflags = 0;
delayreject = 0;
ast_clear_flag((&globalflags), IAX_NOTRANSFER);
Modified: trunk/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_jingle.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/channels/chan_jingle.c (original)
+++ trunk/channels/chan_jingle.c Wed Jul 19 15:44:39 2006
@@ -1116,9 +1116,21 @@
static int jingle_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
{
- ast_log(LOG_NOTICE, "XXX Implement jingle indicate XXX\n");
-
- return -1;
+ int res = 0;
+
+ switch (condition) {
+ case AST_CONTROL_HOLD:
+ ast_moh_start(ast, data, NULL);
+ break;
+ case AST_CONTROL_UNHOLD:
+ ast_moh_stop(ast);
+ break;
+ default:
+ ast_log(LOG_NOTICE, "Don't know how to indicate condition '%d'\n", condition);
+ res = -1;
+ }
+
+ return res;
}
static int jingle_digit(struct ast_channel *ast, char digit)
Modified: trunk/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_mgcp.c?rev=37988&r1=37987&r2=37988&view=diff
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Wed Jul 19 15:44:39 2006
@@ -27,48 +27,6 @@
*
* \ingroup channel_drivers
*/
-
-/* FO: Changes
- * -- add distinctive ring signalling (part of RFC 3660)
- */
-
-/* JS: Changes
- -- add support for the wildcard endpoint
- -- seteable wildcard with wcardep on mgcp.conf
- -- added package indicator on RQNT, i.e "dl" --> "L/dl"
- -- removed MDCX just before DLCX, do we need this ?
-*/
-
-/* JS: TODO
- -- reload for wildcard endpoint probably buggy
- -- when hf is notified we're sending CRCX after MDCX, without waiting for
- OK on the MDCX which fails on Cisco IAD 24XX
- -- honour codec order, by now the lowest codec number in "allow" is the prefered
-*/
-
-/* SC: Changes
- -- packet retransmit mechanism (simplistic)
- -- per endpoint/subchannel mgcp command sequencing.
- -- better transaction handling
- -- fixed some mem leaks
- -- run-time configuration reload
- -- distinguish CA and GW default MGCP ports
- -- prevent clipping of DTMF tones in an established call
- -- fixed a few crash scenarios in 3-way
- -- fix for a few cases where asterisk and MGW end-up in conflicting ep states
- -- enclose numeric IP in [] for outgoing requests
-*/
-
-/* SC: TODO
- -- piggyback support
- -- responseAck support
- -- enhance retransmit mechanism (RTO calc. etc.)
- -- embedded command support
-*/
-
-/* FS: Changes
- -- fixed reload_config() / do_monitor to stay responsive during reloads
-*/
#include "asterisk.h"
@@ -155,13 +113,13 @@
#define MGCP_DTMF_INBAND (1 << 1)
#define MGCP_DTMF_HYBRID (1 << 2)
-#define DEFAULT_MGCP_GW_PORT 2427 /* From RFC 2705 */
-#define DEFAULT_MGCP_CA_PORT 2727 /* From RFC 2705 */
-#define MGCP_MAX_PACKET 1500 /* Also from RFC 2543, should sub headers tho */
-#define DEFAULT_RETRANS 1000 /* How frequently to retransmit */
-#define MAX_RETRANS 5 /* Try only 5 times for retransmissions */
-
-/* MGCP rtp stream modes */
+#define DEFAULT_MGCP_GW_PORT 2427 /*!< From RFC 2705 */
+#define DEFAULT_MGCP_CA_PORT 2727 /*!< From RFC 2705 */
+#define MGCP_MAX_PACKET 1500 /*!< Also from RFC 2543, should sub headers tho */
+#define DEFAULT_RETRANS 1000 /*!< How frequently to retransmit */
+#define MAX_RETRANS 5 /*!< Try only 5 times for retransmissions */
+
+/*! MGCP rtp stream modes { */
#define MGCP_CX_SENDONLY 0
#define MGCP_CX_RECVONLY 1
#define MGCP_CX_SENDRECV 2
@@ -169,6 +127,7 @@
#define MGCP_CX_CONFERENCE 3
#define MGCP_CX_MUTE 4
#define MGCP_CX_INACTIVE 4
+/*! } */
static char *mgcp_cxmodes[] = {
"sendonly",
@@ -178,16 +137,17 @@
"inactive"
};
-/* SC: MGCP commands */
-#define MGCP_CMD_EPCF 0
-#define MGCP_CMD_CRCX 1
-#define MGCP_CMD_MDCX 2
-#define MGCP_CMD_DLCX 3
-#define MGCP_CMD_RQNT 4
-#define MGCP_CMD_NTFY 5
-#define MGCP_CMD_AUEP 6
-#define MGCP_CMD_AUCX 7
-#define MGCP_CMD_RSIP 8
+enum {
+ MGCP_CMD_EPCF,
+ MGCP_CMD_CRCX,
+ MGCP_CMD_MDCX,
+ MGCP_CMD_DLCX,
+ MGCP_CMD_RQNT,
+ MGCP_CMD_NTFY,
+ MGCP_CMD_AUEP,
+ MGCP_CMD_AUCX,
+ MGCP_CMD_RSIP
+};
static char context[AST_MAX_EXTENSION] = "default";
@@ -199,39 +159,22 @@
static int dtmfmode = 0;
static int nat = 0;
-/* Not used. Dosn't hurt for us to always send cid */
-/* to the mgcp box. */
-/*static int use_callerid = 1;*/
-/*static int cur_signalling = -1;*/
-
-/*static unsigned int cur_group = 0;*/
static ast_group_t cur_callergroup = 0;
static ast_group_t cur_pickupgroup = 0;
-/* XXX Is this needed? */
-/* Doesn't look like the dsp stuff for */
-/* dtmfmode is actually hooked up. */
-/*static int relaxdtmf = 0;*/
-
static int tos = 0;
static int immediate = 0;
static int callwaiting = 0;
-/* Not used. Dosn't hurt for us to always send cid */
-/* to the mgcp box. */
-/*static int callwaitingcallerid = 0;*/
-
-/*static int hidecallerid = 0;*/
-
static int callreturn = 0;
static int slowsequence = 0;
static int threewaycalling = 0;
-/* This is for flashhook transfers */
+/*! This is for flashhook transfers */
static int transfer = 0;
static int cancallforward = 0;
@@ -240,10 +183,6 @@
static int canreinvite = CANREINVITE;
-/*static int busycount = 3;*/
-
-/*static int callprogress = 0;*/
-
static char accountcode[AST_MAX_ACCOUNT_CODE] = "";
static char mailbox[AST_MAX_EXTENSION];
@@ -252,26 +191,25 @@
static int adsi = 0;
-/* SC: transaction id should always be positive */
static unsigned int oseq;
-/* Wait up to 16 seconds for first digit (FXO logic) */
+/*! Wait up to 16 seconds for first digit (FXO logic) */
static int firstdigittimeout = 16000;
-/* How long to wait for following digits (FXO logic) */
+/*! How long to wait for following digits (FXO logic) */
static int gendigittimeout = 8000;
-/* How long to wait for an extra digit, if there is an ambiguous match */
+/*! How long to wait for an extra digit, if there is an ambiguous match */
static int matchdigittimeout = 3000;
-/* Protect the monitoring thread, so only one process can kill or start it, and not
- when it's doing something critical. */
+/*! Protect the monitoring thread, so only one process can kill or start it, and not
+ when it's doing something critical. */
AST_MUTEX_DEFINE_STATIC(netlock);
AST_MUTEX_DEFINE_STATIC(monlock);
-/* This is the thread for the monitor which checks for input on the channels
- which are not currently in use. */
+/*! This is the thread for the monitor which checks for input on the channels
+ which are not currently in use. */
static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
@@ -287,8 +225,8 @@
static struct sched_context *sched;
static struct io_context *io;
-/* The private structures of the mgcp channels are linked for
- selecting outgoing channels */
+/*! The private structures of the mgcp channels are linked for
+ ! selecting outgoing channels */
#define MGCP_MAX_HEADERS 64
#define MGCP_MAX_LINES 64
@@ -304,20 +242,10 @@
int lines; /*!< SDP Content */
char *line[MGCP_MAX_LINES];
char data[MGCP_MAX_PACKET];
- int cmd; /*!< SC: int version of verb = command */
- unsigned int trid; /*!< SC: int version of identifier = transaction id */
- struct mgcp_request *next; /*!< SC: next in the queue */
+ int cmd; /*!< int version of verb = command */
+ unsigned int trid; /*!< int version of identifier = transaction id */
+ struct mgcp_request *next; /*!< next in the queue */
};
-
-/* SC: obsolete
-static struct mgcp_pkt {
- int retrans;
- struct mgcp_endpoint *owner;
- int packetlen;
- char data[MGCP_MAX_PACKET];
- struct mgcp_pkt *next;
-} *packets = NULL;
-*/
/*! \brief mgcp_message: MGCP message for queuing up */
struct mgcp_message {
@@ -331,7 +259,7 @@
char buf[0];
};
-#define RESPONSE_TIMEOUT 30 /* in seconds */
+#define RESPONSE_TIMEOUT 30 /*!< in seconds */
struct mgcp_response {
time_t whensent;
@@ -347,7 +275,7 @@
#define SUB_ALT 1
struct mgcp_subchannel {
- /* SC: subchannel magic string.
+ /*! subchannel magic string.
Needed to prove that any subchannel pointer passed by asterisk
really points to a valid subchannel memory area.
Ugly.. But serves the purpose for the time being.
@@ -360,18 +288,18 @@
struct mgcp_endpoint *parent;
struct ast_rtp *rtp;
struct sockaddr_in tmpdest;
- char txident[80]; /* FIXME SC: txident is replaced by rqnt_ident in endpoint.
+ char txident[80]; /*! \todo FIXME txident is replaced by rqnt_ident in endpoint.
This should be obsoleted */
char cxident[80];
char callid[80];
int cxmode;
- struct mgcp_request *cx_queue; /*!< SC: pending CX commands */
- ast_mutex_t cx_queue_lock; /*!< SC: CX queue lock */
+ struct mgcp_request *cx_queue; /*!< pending CX commands */
+ ast_mutex_t cx_queue_lock; /*!< CX queue lock */
int nat;
- int iseq; /* Not used? RTP? */
+ int iseq; /*!< Not used? RTP? */
int outgoing;
int alreadygone;
- struct mgcp_subchannel *next; /* for out circular linked list */
+ struct mgcp_subchannel *next; /*!< for out circular linked list */
};
#define MGCP_ONHOOK 1
@@ -423,13 +351,13 @@
int immediate;
int hookstate;
int adsi;
- char rqnt_ident[80]; /*!< SC: request identifier */
- struct mgcp_request *rqnt_queue; /*!< SC: pending RQNT commands */
+ char rqnt_ident[80]; /*!< request identifier */
+ struct mgcp_request *rqnt_queue; /*!< pending RQNT commands */
ast_mutex_t rqnt_queue_lock;
- struct mgcp_request *cmd_queue; /*!< SC: pending commands other than RQNT */
+ struct mgcp_request *cmd_queue; /*!< pending commands other than RQNT */
ast_mutex_t cmd_queue_lock;
- int delme; /*!< SC: needed for reload */
- int needaudit; /*!< SC: needed for reload */
+ int delme; /*!< needed for reload */
+ int needaudit; /*!< needed for reload */
struct ast_dsp *dsp; /*!< XXX Should there be a dsp/subchannel? XXX */
/* owner is tracked on the subchannels, and the *sub indicates whos in charge */
/* struct ast_channel *owner; */
@@ -443,7 +371,7 @@
static struct mgcp_gateway {
/* A gateway containing one or more endpoints */
char name[80];
- int isnamedottedip; /*!< SC: is the name FQDN or dotted ip */
+ int isnamedottedip; /*!< is the name FQDN or dotted ip */
struct sockaddr_in addr;
struct sockaddr_in defaddr;
struct in_addr ourip;
@@ -451,17 +379,17 @@
int expire; /*!< XXX Should we ever expire dynamic registrations? XXX */
struct mgcp_endpoint *endpoints;
struct ast_ha *ha;
-/* SC: obsolete
+/* obsolete
time_t lastouttime;
int lastout;
int messagepending;
*/
-/* JS: Wildcard endpoint name */
+/* Wildcard endpoint name */
char wcardep[30];
- struct mgcp_message *msgs; /*!< SC: gw msg queue */
- ast_mutex_t msgs_lock; /*!< SC: queue lock */
- int retransid; /*!< SC: retrans timer id */
- int delme; /*!< SC: needed for reload */
+ struct mgcp_message *msgs; /*!< gw msg queue */
+ ast_mutex_t msgs_lock; /*!< queue lock */
+ int retransid; /*!< retrans timer id */
+ int delme; /*!< needed for reload */
struct mgcp_response *responses;
struct mgcp_gateway *next;
} *gateways;
@@ -552,7 +480,7 @@
return 0;
}
-/* SC: modified for new transport mechanism */
+/* modified for new transport mechanism */
static int __mgcp_xmit(struct mgcp_gateway *gw, char *data, int len)
{
int res;
@@ -594,7 +522,7 @@
return res;
}
-/* SC: modified for new transport framework */
+/* modified for new transport framework */
static void dump_queue(struct mgcp_gateway *gw, struct mgcp_endpoint *p)
{
struct mgcp_message *cur, *q = NULL, *w, *prev;
@@ -736,7 +664,7 @@
return res;
}
-/* SC: modified for the new transaction mechanism */
+/* modified for the new transaction mechanism */
static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
char *data, int len, unsigned int seqno)
{
@@ -802,7 +730,7 @@
return 0;
}
-/* SC: modified for new transport */
+/* modified for new transport */
static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
struct mgcp_request *req, unsigned int seqno)
{
@@ -875,7 +803,7 @@
}
}
- /* XXX SC: find tail. We could also keep tail in the data struct for faster access */
+ /* XXX find tail. We could also keep tail in the data struct for faster access */
for (t = *queue; t && t->next; t = t->next);
r->next = NULL;
@@ -1004,7 +932,7 @@
}
if ((p->dtmfmode & MGCP_DTMF_INBAND) && p->dsp) {
- /* SC: check whether other channel is active. */
+ /* check whether other channel is active. */
if (!sub->next->owner) {
if (p->dtmfmode & MGCP_DTMF_HYBRID)
p->dtmfmode &= ~MGCP_DTMF_INBAND;
@@ -1056,10 +984,10 @@
sub->rtp = NULL;
}
- /* SC: Decrement use count */
+ /* Decrement use count */
ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
ast_update_use_count();
- /* SC: Decrement use count */
+ /* Decrement use count */
if ((p->hookstate == MGCP_ONHOOK) && (!sub->next->rtp)) {
p->hidecallerid = 0;
@@ -1101,7 +1029,7 @@
e = g->endpoints;
ast_cli(fd, "Gateway '%s' at %s (%s)\n", g->name, g->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), g->addr.sin_addr) : ast_inet_ntoa(iabuf, sizeof(iabuf), g->defaddr.sin_addr), g->dynamic ? "Dynamic" : "Static");
while(e) {
- /* JS: Don't show wilcard endpoint */
+ /* Don't show wilcard endpoint */
if (strcmp(e->name, g->wcardep) !=0)
ast_cli(fd, " -- '%s@%s in '%s' is %s\n", e->name, g->name, e->context, e->sub->owner ? "active" : "idle");
hasendpoints = 1;
@@ -1197,7 +1125,7 @@
} else {
transmit_modify_request(sub);
}
- /* SC: verbose level check */
+ /* verbose level check */
if (option_verbose > 2) {
ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_answer(%s) on %s@%s-%d\n",
ast->name, p->name, p->parent->name, sub->id);
@@ -1428,9 +1356,15 @@
case AST_CONTROL_CONGESTION:
transmit_notify_request(sub, "G/cg");
break;
+ case AST_CONTROL_HOLD:
+ ast_moh_start(ast, data, NULL);
+ break;
+ case AST_CONTROL_UNHOLD:
+ ast_moh_stop(ast);
+ break;
case -1:
transmit_notify_request(sub, "");
- break;
+ break;
default:
ast_log(LOG_WARNING, "Don't know how to indicate condition %d\n", ind);
res = -1;
@@ -1458,7 +1392,7 @@
if (i->dtmfmode & (MGCP_DTMF_INBAND | MGCP_DTMF_HYBRID)) {
i->dsp = ast_dsp_new();
ast_dsp_set_features(i->dsp,DSP_FEATURE_DTMF_DETECT);
- /* SC: this is to prevent clipping of dtmf tones during dsp processing */
+ /* this is to prevent clipping of dtmf tones during dsp processing */
ast_dsp_digitmode(i->dsp, DSP_DIGITMODE_NOQUELCH);
} else {
i->dsp = NULL;
@@ -1496,7 +1430,7 @@
tmp = NULL;
}
}
- /* SC: verbose level check */
+ /* verbose level check */
if (option_verbose > 2) {
ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_new(%s) created in state: %s\n",
tmp->name, ast_state2str(state));
@@ -1637,14 +1571,14 @@
ast_verbose(VERBOSE_PREFIX_3 "Registered MGCP gateway '%s' at %s port %d\n", g->name, ast_inet_ntoa(iabuf, sizeof(iabuf), g->addr.sin_addr), ntohs(g->addr.sin_port));
}
}
- /* SC: not dynamic, check if the name matches */
+ /* not dynamic, check if the name matches */
else if (name) {
if (strcasecmp(g->name, at)) {
g = g->next;
continue;
}
}
- /* SC: not dynamic, no name, check if the addr matches */
+ /* not dynamic, no name, check if the addr matches */
else if (!name && sin) {
if ((g->addr.sin_addr.s_addr != sin->sin_addr.s_addr) ||
(g->addr.sin_port != sin->sin_port)) {
@@ -1662,7 +1596,7 @@
ast_log(LOG_DEBUG, "Searching on %s@%s for subchannel\n",
p->name, g->name);
if (msgid) {
-#if 0 /* SC: new transport mech */
+#if 0 /* new transport mech */
sub = p->sub;
do {
if (option_debug)
@@ -1971,7 +1905,7 @@
return -1;
}
req->header[req->headers] = req->data + req->len;
- /* SC: check if we need brackets around the gw name */
+ /* check if we need brackets around the gw name */
if (p->parent->isnamedottedip)
snprintf(req->header[req->headers], sizeof(req->data) - req->len, "%s %d %s@[%s] MGCP 1.0\r\n", verb, oseq, p->name, p->parent->name);
else
@@ -2148,12 +2082,12 @@
add_header(&resp, "C", sub->callid);
add_header(&resp, "L", local);
add_header(&resp, "M", mgcp_cxmodes[sub->cxmode]);
- /* SC: X header should not be sent. kept for compatibility */
+ /* X header should not be sent. kept for compatibility */
add_header(&resp, "X", sub->txident);
add_header(&resp, "I", sub->cxident);
/*add_header(&resp, "S", "");*/
add_sdp(&resp, sub, rtp);
- /* SC: fill in new fields */
+ /* fill in new fields */
resp.cmd = MGCP_CMD_MDCX;
resp.trid = oseq;
return send_request(p, sub, &resp, oseq); /* SC */
@@ -2182,11 +2116,11 @@
add_header(&resp, "C", sub->callid);
add_header(&resp, "L", local);
add_header(&resp, "M", mgcp_cxmodes[sub->cxmode]);
- /* SC: X header should not be sent. kept for compatibility */
+ /* X header should not be sent. kept for compatibility */
add_header(&resp, "X", sub->txident);
/*add_header(&resp, "S", "");*/
add_sdp(&resp, sub, rtp);
- /* SC: fill in new fields */
+ /* fill in new fields */
resp.cmd = MGCP_CMD_CRCX;
resp.trid = oseq;
return send_request(p, sub, &resp, oseq); /* SC */
@@ -2215,7 +2149,7 @@
if (!ast_strlen_zero(tone)) {
add_header(&resp, "S", tone);
}
- /* SC: fill in new fields */
+ /* fill in new fields */
resp.cmd = MGCP_CMD_RQNT;
resp.trid = oseq;
return send_request(p, NULL, &resp, oseq); /* SC */
@@ -2262,7 +2196,7 @@
ast_verbose(VERBOSE_PREFIX_3 "MGCP Asked to indicate tone: %s on %s@%s-%d in cxmode: %s\n",
tone2, p->name, p->parent->name, sub->id, mgcp_cxmodes[sub->cxmode]);
}
- /* SC: fill in new fields */
+ /* fill in new fields */
resp.cmd = MGCP_CMD_RQNT;
resp.trid = oseq;
return send_request(p, NULL, &resp, oseq); /* SC */
[... 1616 lines stripped ...]
More information about the asterisk-commits
mailing list