diff options
author | Tony Vroon <chainsaw@gentoo.org> | 2010-02-10 22:25:30 +0000 |
---|---|---|
committer | Tony Vroon <chainsaw@gentoo.org> | 2010-02-10 22:25:30 +0000 |
commit | 1980b9d6360627c271bbd1b7e5786a11ce01ef8b (patch) | |
tree | 5ae42f5d6bcfe88e6d07b7bb1e1cfc7a400de957 /net-misc/asterisk | |
parent | Fix poppler depend. (diff) | |
download | gentoo-2-1980b9d6360627c271bbd1b7e5786a11ce01ef8b.tar.gz gentoo-2-1980b9d6360627c271bbd1b7e5786a11ce01ef8b.tar.bz2 gentoo-2-1980b9d6360627c271bbd1b7e5786a11ce01ef8b.zip |
Add nv_faxdetect as scavenged by Cory Coager in bug #298328. Trim unnecessary parts from parallel make patch, upstream bug #16489. Stop segfaulting on a graceful restart, upstream bugs #16062 & #16470.
(Portage version: 2.2_rc62/cvs/Linux x86_64)
Diffstat (limited to 'net-misc/asterisk')
5 files changed, 1127 insertions, 1 deletions
diff --git a/net-misc/asterisk/ChangeLog b/net-misc/asterisk/ChangeLog index 364d0cf1167c..9dfc860d5a2a 100644 --- a/net-misc/asterisk/ChangeLog +++ b/net-misc/asterisk/ChangeLog @@ -1,6 +1,16 @@ # ChangeLog for net-misc/asterisk # Copyright 1999-2010 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/ChangeLog,v 1.246 2010/02/02 22:54:51 chainsaw Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/ChangeLog,v 1.247 2010/02/10 22:25:29 chainsaw Exp $ + +*asterisk-1.6.2.2-r1 (10 Feb 2010) + + 10 Feb 2010; <chainsaw@gentoo.org> +asterisk-1.6.2.2-r1.ebuild, + +files/1.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch, + +files/1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch, + +files/1.6.2/asterisk-1.6.2.2-parallel-make.patch: + Add nv_faxdetect as scavenged by Cory Coager in bug #298328. Trim + unnecessary parts from parallel make patch, upstream bug #16489. Stop + segfaulting on a graceful restart, upstream bugs #16062 & #16470. *asterisk-1.6.1.14 (02 Feb 2010) diff --git a/net-misc/asterisk/asterisk-1.6.2.2-r1.ebuild b/net-misc/asterisk/asterisk-1.6.2.2-r1.ebuild new file mode 100644 index 000000000000..4deff5cd0b1a --- /dev/null +++ b/net-misc/asterisk/asterisk-1.6.2.2-r1.ebuild @@ -0,0 +1,370 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/asterisk-1.6.2.2-r1.ebuild,v 1.1 2010/02/10 22:25:29 chainsaw Exp $ + +EAPI=1 +inherit eutils autotools linux-info + +MY_P="${PN}-${PV/_/-}" + +DESCRIPTION="Asterisk: A Modular Open Source PBX System" +HOMEPAGE="http://www.asterisk.org/" +SRC_URI="http://downloads.digium.com/pub/asterisk/releases/${MY_P}.tar.gz" +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +IUSE="alsa +caps curl dahdi debug freetds iconv jabber ldap keepsrc misdn newt nosamples oss postgres radius snmp span speex ssl sqlite static vorbis" + +RDEPEND="sys-libs/ncurses + dev-libs/popt + sys-libs/zlib + alsa? ( media-libs/alsa-lib ) + caps? ( sys-libs/libcap ) + curl? ( net-misc/curl ) + dahdi? ( >=net-libs/libpri-1.4.7 + net-misc/dahdi-tools ) + freetds? ( dev-db/freetds ) + iconv? ( virtual/libiconv ) + jabber? ( dev-libs/iksemel ) + ldap? ( net-nds/openldap ) + misdn? ( net-dialup/misdnuser ) + newt? ( dev-libs/newt ) + postgres? ( virtual/postgresql-base ) + radius? ( net-dialup/radiusclient-ng ) + snmp? ( net-analyzer/net-snmp ) + span? ( media-libs/spandsp ) + speex? ( media-libs/speex ) + sqlite? ( dev-db/sqlite ) + ssl? ( dev-libs/openssl ) + vorbis? ( media-libs/libvorbis )" + +DEPEND="${RDEPEND} + !<net-misc/asterisk-addons-1.6 + !net-misc/asterisk-chan_unistim + !net-misc/zaptel" + +S="${WORKDIR}/${MY_P}" + +get_available_modules() { + local modules mod x + + # build list of available modules... + for x in app cdr codec format func pbx res; do + + for mod in $(find "${S}" -type f -name "${x}_*.c*" -print) + do + modules="${modules} $(basename ${mod/%.c*})" + done + done + + echo "${modules}" +} + +pkg_setup() { + if [[ -n "${ASTERISK_MODULES}" ]] ; then + ewarn "You are overriding ASTERISK_MODULES. We will assume you know what you are doing. There is no support for this option, try without if you see breakage." + fi + CONFIG_CHECK="~!NF_CONNTRACK_SIP" + local WARNING_NF_CONNTRACK_SIP="SIP (NAT) connection tracking is a module written for a single SIP client talking to a + remote server. It is not able to track multiple remote SIP clients registering with + a local server. Critical SIP packets may be dropped." + check_extra_config +} + +src_unpack() { + unpack ${A} + cd "${S}" + + # + # fix gsm codec cflags (e.g. i586 core epias) and disable + # assembler optimizations + # + epatch "${FILESDIR}"/1.6.1/${PN}-1.6.1-gsm-pic.patch || die "patch failed" + + # + # add missing LIBS for uclibc + # + epatch "${FILESDIR}"/1.6.1/${PN}-1.6.1-uclibc.patch || die "patch failed" + + # + # make sure FXO ports are usable immediately, without requiring an inbound call first + # https://issues.asterisk.org/view.php?id=14577 + # + epatch "${FILESDIR}"/1.6.1/${PN}-1.6.1.6-fxsks-hookstate.patch || die "patch failed" + + # + # do not ignore alarm-cleared event while V23 caller ID detection is in progress + # otherwise automated British Telecom line test causes permanent red alarm + # https://issues.asterisk.org/view.php?id=14163 + # + epatch "${FILESDIR}"/1.6.2/${PN}-1.6.2.0-bt-line-test.patch || die "patch failed" + + # + # sprinkle some plus signs in strategic locations for maximum parallel make happiness + # https://issues.asterisk.org/view.php?id=16489 + # + epatch "${FILESDIR}"/1.6.2/${P}-parallel-make.patch || die "patch failed" + + # + # do not segfault when asked to restart gracefully + # https://issues.asterisk.org/view.php?id=16062 + # https://issues.asterisk.org/view.php?id=16470 + # + epatch "${FILESDIR}"/1.6.2/${P}-graceful-restart-segfault.patch + + # + # add special playback with fax detection + # Code by NewMan telecom, patch scavenged + # by Cory Coager + # http://bugs.gentoo.org/show_bug.cgi?id=298328 + # + epatch "${FILESDIR}"/1.6.2/${P}-nv-faxdetect.patch + + AT_M4DIR=autoconf eautoreconf + + # parse modules list + if [[ -n "${ASTERISK_MODULES}" ]]; then + local x modules="$(get_available_modules)" + + einfo "Custom list of modules specified, checking..." + + use debug && { + einfo "Available modules: ${modules}" + einfo " Selected modules: ${ASTERISK_MODULES}" + } + + for x in ${ASTERISK_MODULES}; do + if [[ "${x}" = "-*" ]]; then + MODULES_LIST="" + else + if has ${x} ${modules} + then + MODULES_LIST="${MODULES_LIST} ${x}" + else + eerror "Unknown module: ${x}" + fi + fi + done + + export MODULES_LIST + fi +} + +src_compile() { + # + # start with configure + # + econf \ + --libdir="/usr/$(get_libdir)" \ + --localstatedir="/var" \ + --with-gsm=internal \ + --with-popt \ + --with-z \ + $(use_with alsa asound) \ + $(use_with caps cap) \ + $(use_with curl) \ + $(use_with dahdi pri) \ + $(use_with dahdi tonezone) \ + $(use_with dahdi) \ + $(use_with freetds tds) \ + $(use_with iconv) \ + $(use_with jabber iksemel) \ + $(use_with misdn isdnnet) \ + $(use_with misdn suppserv) \ + $(use_with misdn) \ + $(use_with newt) \ + $(use_with oss) \ + $(use_with postgres) \ + $(use_with radius) \ + $(use_with snmp netsnmp) \ + $(use_with span spandsp) \ + $(use_with speex) \ + $(use_with speex speexdsp) \ + $(use_with sqlite sqlite3) \ + $(use_with ssl crypto) \ + $(use_with ssl) \ + $(use_with vorbis ogg) \ + $(use_with vorbis) || die "econf failed" + + # + # custom module filter + # run menuselect to evaluate the list of modules + # and rewrite the list afterwards + # + if [[ -n "${MODULES_LIST}" ]] + then + local mod category tmp_list failed_list + + ### + # run menuselect + + emake menuselect.makeopts || die "emake menuselect.makeopts failed" + + ### + # get list of modules with failed dependencies + + failed_list="$(awk -F= '/^MENUSELECT_DEPSFAILED=/{ print $3 }' menuselect.makeopts)" + + ### + # traverse our list of modules + + for category in app cdr codec format func pbx res; do + tmp_list="" + + # search list of modules for matching ones first... + for mod in ${MODULES_LIST}; do + # module is from current category? + if [[ "${mod/%_*}" = "${category}" ]] + then + # check menuselect thinks the dependencies are met + if has ${mod} ${failed_list} + then + eerror "${mod}: dependencies required to build this module are not met, NOT BUILDING!" + else + tmp_list="${tmp_list} ${mod}" + fi + fi + done + + use debug && echo "${category} tmp: ${tmp_list}" + + # replace the module list for $category with our custom one + if [[ -n "${tmp_list}" ]] + then + category="$(echo ${category} | tr '[:lower:]' '[:upper:]')" + sed -i -e "s:^\(MENUSELECT_${category}S?\):\1=${tmp_list}:" \ + menuselect.makeopts || die "failed to set list of ${category} applications" + fi + done + fi + + ASTLDFLAGS="${LDFLAGS}" emake || die "emake failed" +} + +src_install() { + # setup directory structure + # + mkdir -p "${D}"usr/lib/pkgconfig + + emake DESTDIR="${D}" install || die "emake install failed" + emake DESTDIR="${D}" samples || die "emake samples failed" + + # remove installed sample files if nosamples flag is set + if use nosamples; then + einfo "Skipping installation of sample files..." + rm -f "${D}"var/lib/asterisk/mohmp3/* + rm -f "${D}"var/lib/asterisk/sounds/demo-* + rm -f "${D}"var/lib/asterisk/agi-bin/* + else + einfo "Sample files have been installed" + fi + rm -rf "${D}"var/spool/asterisk/voicemail/default + + einfo "Configuration samples have been moved to: "${ROOT}"/usr/share/doc/${PF}/conf" + insinto /usr/share/doc/${PF}/conf + doins "${D}"etc/asterisk/*.conf* + + cd "${D}" + for conffile in etc/asterisk/*.* + do + fowners asterisk:asterisk $conffile + fperms 0660 $conffile + done + cd "${S}" + + # keep directories + diropts -m 0770 -o asterisk -g asterisk + keepdir /etc/asterisk + keepdir /var/lib/asterisk + keepdir /var/run/asterisk + keepdir /var/spool/asterisk + keepdir /var/spool/asterisk/{system,tmp,meetme,monitor,dictate,voicemail} + diropts -m 0750 -o asterisk -g asterisk + keepdir /var/log/asterisk/{cdr-csv,cdr-custom} + + newinitd "${FILESDIR}"/1.6.1/asterisk.initd3 asterisk + newconfd "${FILESDIR}"/1.6.0/asterisk.confd asterisk + + # some people like to keep the sources around for custom patching + # copy the whole source tree to /usr/src/asterisk-${PVF} and run make clean there + if use keepsrc + then + dodir /usr/src + + ebegin "Copying sources into /usr/src" + cp -dPR "${S}" "${D}"/usr/src/${PF} || die "Unable to copy sources" + eend $? + + ebegin "Cleaning source tree" + emake -C "${D}"/usr/src/${PF} clean &>/dev/null || die "Unable to clean sources" + eend $? + + einfo "Clean sources are available in "${ROOT}"usr/src/${PF}" + fi + + # install the upgrade documentation + # + dodoc README UPGRADE* BUGS CREDITS + + # install snmp mib files + # + if use snmp + then + insinto /usr/share/snmp/mibs/ + doins doc/digium-mib.txt doc/asterisk-mib.txt + fi +} + +pkg_preinst() { + enewgroup asterisk + enewuser asterisk -1 -1 /var/lib/asterisk "asterisk,dialout" +} + +pkg_postinst() { + # + # Announcements, warnings, reminders... + # + einfo "Asterisk has been installed" + echo + elog "If you want to know more about asterisk, visit these sites:" + elog "http://www.asteriskdocs.org/" + elog "http://www.voip-info.org/wiki-Asterisk" + echo + elog "http://www.automated.it/guidetoasterisk.htm" + echo + elog "Gentoo VoIP IRC Channel:" + elog "#gentoo-voip @ irc.freenode.net" + echo + echo + elog "1.6.1 -> 1.6.2 changes that you may care about:" + elog "canreinvite -> directmedia (sip.conf)" + elog "extensive T.38 (fax) changes" + elog "http://svn.asterisk.org/svn/${PN}/tags/${PV}/UPGRADE.txt" + elog "or: bzless ${ROOT}usr/share/doc/${PF}/UPGRADE.txt.bz2" +} + +pkg_config() { + einfo "Do you want to reset file permissions and ownerships (y/N)?" + + read tmp + tmp="$(echo $tmp | tr '[:upper:]' '[:lower:]')" + + if [[ "$tmp" = "y" ]] ||\ + [[ "$tmp" = "yes" ]] + then + einfo "Resetting permissions to defaults..." + + for x in spool run lib log; do + chown -R asterisk:asterisk "${ROOT}"var/${x}/asterisk + chmod -R u=rwX,g=rwX,o= "${ROOT}"var/${x}/asterisk + done + + chown -R root:asterisk "${ROOT}"etc/asterisk + chmod -R u=rwX,g=rwX,o= "${ROOT}"etc/asterisk + + einfo "done" + else + einfo "skipping" + fi +} diff --git a/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch new file mode 100644 index 000000000000..2962cc6a023f --- /dev/null +++ b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-graceful-restart-segfault.patch @@ -0,0 +1,75 @@ +diff -uNr asterisk-1.6.2.2.ORIG/main/event.c asterisk-1.6.2.2/main/event.c +--- asterisk-1.6.2.2.ORIG/main/event.c 2010-02-10 21:05:55.278139356 +0000 ++++ asterisk-1.6.2.2/main/event.c 2010-02-10 21:06:58.008198202 +0000 +@@ -841,6 +841,11 @@ + struct ast_event_iterator iterator; + int res = 0; + ++ /* Event has no IEs allocated */ ++ if (event->event_len < sizeof(*event) + sizeof(ie_type)) { ++ return NULL; ++ } ++ + for (ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) { + if (ast_event_iterator_get_ie_type(&iterator) == ie_type) + return ast_event_iterator_get_ie_raw(&iterator); +diff -uNr asterisk-1.6.2.2.ORIG/main/loader.c asterisk-1.6.2.2/main/loader.c +--- asterisk-1.6.2.2.ORIG/main/loader.c 2010-02-10 21:05:55.273223462 +0000 ++++ asterisk-1.6.2.2/main/loader.c 2010-02-10 21:06:58.006203410 +0000 +@@ -444,26 +444,39 @@ + void ast_module_shutdown(void) + { + struct ast_module *mod; +- AST_LIST_HEAD_NOLOCK_STATIC(local_module_list, ast_module); +- +- /* We have to call the unload() callbacks in reverse order that the modules +- * exist in the module list so it is the reverse order of how they were +- * loaded. */ ++ int somethingchanged = 1, final = 0; + + AST_LIST_LOCK(&module_list); +- while ((mod = AST_LIST_REMOVE_HEAD(&module_list, entry))) +- AST_LIST_INSERT_HEAD(&local_module_list, mod, entry); +- AST_LIST_UNLOCK(&module_list); + +- while ((mod = AST_LIST_REMOVE_HEAD(&local_module_list, entry))) { +- if (mod->info->unload) +- mod->info->unload(); +- /* Since this should only be called when shutting down "gracefully", +- * all channels should be down before we get to this point, meaning +- * there will be no module users left. */ +- AST_LIST_HEAD_DESTROY(&mod->users); +- free(mod); +- } ++ /*!\note Some resources, like timers, are started up dynamically, and thus ++ * may be still in use, even if all channels are dead. We must therefore ++ * check the usecount before asking modules to unload. */ ++ do { ++ if (!somethingchanged) { ++ /*!\note If we go through the entire list without changing ++ * anything, ignore the usecounts and unload, then exit. */ ++ final = 1; ++ } ++ ++ /* Reset flag before traversing the list */ ++ somethingchanged = 0; ++ ++ AST_LIST_TRAVERSE_SAFE_BEGIN(&module_list, mod, entry) { ++ if (!final && mod->usecount) { ++ continue; ++ } ++ AST_LIST_REMOVE_CURRENT(entry); ++ if (mod->info->unload) { ++ mod->info->unload(); ++ } ++ AST_LIST_HEAD_DESTROY(&mod->users); ++ free(mod); ++ somethingchanged = 1; ++ } ++ AST_LIST_TRAVERSE_SAFE_END; ++ } while (somethingchanged && !final); ++ ++ AST_LIST_UNLOCK(&module_list); + } + + int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode force) diff --git a/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch new file mode 100644 index 000000000000..ee2ef4408cf6 --- /dev/null +++ b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-nv-faxdetect.patch @@ -0,0 +1,650 @@ +diff -uNr apps/app_nv_backgrounddetect.c apps/app_nv_backgrounddetect.c +--- apps/app_nv_backgrounddetect.c 1970-01-01 01:00:00.000000000 +0100 ++++ apps/app_nv_backgrounddetect.c 2010-02-10 22:09:40.118390386 +0000 +@@ -0,0 +1,325 @@ ++/* ++ * Asterisk -- A telephony toolkit for Linux. ++ * ++ * Playback a file with audio detect ++ * ++ * Copyright (C) 2004-2005, Newman Telecom, Inc. and Newman Ventures, Inc. ++ * ++ * Justin Newman <jnewman@newmantelecom.com> ++ * ++ * We would like to thank Newman Ventures, Inc. for funding this ++ * Asterisk project. ++ * ++ * Newman Ventures <info@newmanventures.com> ++ * ++ * Portions Copyright: ++ * Copyright (C) 2001, Linux Support Services, Inc. ++ * Copyright (C) 2004, Digium, Inc. ++ * ++ * Matthew Fredrickson <creslin@linux-support.net> ++ * Mark Spencer <markster@digium.com> ++ * ++ * This program is free software, distributed under the terms of ++ * the GNU General Public License ++ */ ++ ++#include "asterisk.h" ++ ++#include <asterisk/lock.h> ++#include <asterisk/file.h> ++#include <asterisk/logger.h> ++#include <asterisk/channel.h> ++#include <asterisk/pbx.h> ++#include <asterisk/module.h> ++#include <asterisk/translate.h> ++#include <asterisk/utils.h> ++#include <asterisk/dsp.h> ++ ++static char *app = "NVBackgroundDetect"; ++ ++static char *synopsis = "Background a file with talk and fax detect (IAX and SIP too)"; ++ ++static char *descrip = ++" NVBackgroundDetect(filename[|options[|sildur[|mindur|[maxdur]]]]):\n" ++"Plays filename, waiting for interruption from fax tones (on IAX and SIP too),\n" ++"a digit, or non-silence. Audio is monitored in the receive direction. If\n" ++"digits interrupt, they must be the start of a valid extension unless the\n" ++"option is included to ignore. If fax is detected, it will jump to the\n" ++"'fax' extension. If a period of non-silence is greater than 'mindur' ms,\n" ++"yet less than 'maxdur' ms is followed by silence at least 'sildur' ms\n" ++"then the app is aborted and processing jumps to the 'talk' extension.\n" ++"If all undetected, control will continue at the next priority.\n" ++" options:\n" ++" 'n': Attempt on-hook if unanswered (default=no)\n" ++" 'x': DTMF digits terminate without extension (default=no)\n" ++" 'd': Ignore DTMF digit detection (default=no)\n" ++" 'f': Ignore fax detection (default=no)\n" ++" 't': Ignore talk detection (default=no)\n" ++" sildur: Silence ms after mindur/maxdur before aborting (default=1000)\n" ++" mindur: Minimum non-silence ms needed (default=100)\n" ++" maxdur: Maximum non-silence ms allowed (default=0/forever)\n" ++"Returns -1 on hangup, and 0 on successful completion with no exit conditions.\n\n" ++"For questions or comments, please e-mail support@newmantelecom.com.\n"; ++ ++// Use the second one for recent Asterisk releases ++#define CALLERID_FIELD cid.cid_num ++//#define CALLERID_FIELD callerid ++ ++static int nv_background_detect_exec(struct ast_channel *chan, void *data) ++{ ++ int res = 0; ++ char tmp[256] = "\0"; ++ char *p = NULL; ++ char *filename = NULL; ++ char *options = NULL; ++ char *silstr = NULL; ++ char *minstr = NULL; ++ char *maxstr = NULL; ++ struct ast_frame *fr = NULL; ++ struct ast_frame *fr2 = NULL; ++ int notsilent = 0; ++ struct timeval start = {0, 0}, end = {0, 0}; ++ int sildur = 1000; ++ int mindur = 100; ++ int maxdur = -1; ++ int skipanswer = 0; ++ int noextneeded = 0; ++ int ignoredtmf = 0; ++ int ignorefax = 0; ++ int ignoretalk = 0; ++ int x = 0; ++ int origrformat = 0; ++ int features = 0; ++ struct ast_dsp *dsp = NULL; ++ ++ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", ""); ++ pbx_builtin_setvar_helper(chan, "FAXEXTEN", ""); ++ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", ""); ++ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", ""); ++ ++ if (!data || ast_strlen_zero((char *)data)) { ++ ast_log(LOG_WARNING, "NVBackgroundDetect requires an argument (filename)\n"); ++ return -1; ++ } ++ ++ strncpy(tmp, (char *)data, sizeof(tmp)-1); ++ p = tmp; ++ ++ filename = strsep(&p, "|"); ++ options = strsep(&p, "|"); ++ silstr = strsep(&p, "|"); ++ minstr = strsep(&p, "|"); ++ maxstr = strsep(&p, "|"); ++ ++ if (options) { ++ if (strchr(options, 'n')) ++ skipanswer = 1; ++ if (strchr(options, 'x')) ++ noextneeded = 1; ++ if (strchr(options, 'd')) ++ ignoredtmf = 1; ++ if (strchr(options, 'f')) ++ ignorefax = 1; ++ if (strchr(options, 't')) ++ ignoretalk = 1; ++ } ++ ++ if (silstr) { ++ if ((sscanf(silstr, "%d", &x) == 1) && (x > 0)) ++ sildur = x; ++ } ++ ++ if (minstr) { ++ if ((sscanf(minstr, "%d", &x) == 1) && (x > 0)) ++ mindur = x; ++ } ++ ++ if (maxstr) { ++ if ((sscanf(maxstr, "%d", &x) == 1) && (x > 0)) ++ maxdur = x; ++ } ++ ++ ast_log(LOG_DEBUG, "Preparing detect of '%s' (sildur=%dms, mindur=%dms, maxdur=%dms)\n", ++ tmp, sildur, mindur, maxdur); ++ ++ // LOCAL_USER_ADD(u); ++ if (chan->_state != AST_STATE_UP && !skipanswer) { ++ /* Otherwise answer unless we're supposed to send this while on-hook */ ++ res = ast_answer(chan); ++ } ++ if (!res) { ++ origrformat = chan->readformat; ++ if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR))) ++ ast_log(LOG_WARNING, "Unable to set read format to linear!\n"); ++ } ++ if (!(dsp = ast_dsp_new())) { ++ ast_log(LOG_WARNING, "Unable to allocate DSP!\n"); ++ res = -1; ++ } ++ ++ if (dsp) { ++ if (!ignoretalk) ++ ; /* features |= DSP_FEATURE_SILENCE_SUPPRESS; */ ++ if (!ignorefax) ++ features |= DSP_FEATURE_FAX_DETECT; ++ //if (!ignoredtmf) ++ features |= DSP_FEATURE_DIGIT_DETECT; ++ ++ ast_dsp_set_threshold(dsp, 256); ++ ast_dsp_set_features(dsp, features | DSP_DIGITMODE_RELAXDTMF); ++ ast_dsp_set_digitmode(dsp, DSP_DIGITMODE_DTMF); ++ } ++ ++ if (!res) { ++ ast_stopstream(chan); ++ res = ast_streamfile(chan, tmp, chan->language); ++ if (!res) { ++ while(chan->stream) { ++ res = ast_sched_wait(chan->sched); ++ if ((res < 0) && !chan->timingfunc) { ++ res = 0; ++ break; ++ } ++ if (res < 0) ++ res = 1000; ++ res = ast_waitfor(chan, res); ++ if (res < 0) { ++ ast_log(LOG_WARNING, "Waitfor failed on %s\n", chan->name); ++ break; ++ } else if (res > 0) { ++ fr = ast_read(chan); ++ if (!fr) { ++ ast_log(LOG_DEBUG, "Got hangup\n"); ++ res = -1; ++ break; ++ } ++ ++ fr2 = ast_dsp_process(chan, dsp, fr); ++ if (!fr2) { ++ ast_log(LOG_WARNING, "Bad DSP received (what happened!!)\n"); ++ fr2 = fr; ++ } ++ ++ if (fr2->frametype == AST_FRAME_DTMF) { ++ if (fr2->subclass == 'f' && !ignorefax) { ++ /* Fax tone -- Handle and return NULL */ ++ ast_log(LOG_DEBUG, "Fax detected on %s\n", chan->name); ++ if (strcmp(chan->exten, "fax")) { ++ ast_log(LOG_NOTICE, "Redirecting %s to fax extension\n", chan->name); ++ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", "1"); ++ pbx_builtin_setvar_helper(chan,"FAXEXTEN",chan->exten); ++ if (ast_exists_extension(chan, chan->context, "fax", 1, chan->CALLERID_FIELD)) { ++ /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */ ++ strncpy(chan->exten, "fax", sizeof(chan->exten)-1); ++ chan->priority = 0; ++ } else ++ ast_log(LOG_WARNING, "Fax detected, but no fax extension\n"); ++ } else ++ ast_log(LOG_WARNING, "Already in a fax extension, not redirecting\n"); ++ ++ res = 0; ++ ast_frfree(fr); ++ break; ++ } else if (!ignoredtmf) { ++ ast_log(LOG_DEBUG, "DTMF detected on %s\n", chan->name); ++ char t[2]; ++ t[0] = fr2->subclass; ++ t[1] = '\0'; ++ if (noextneeded || ast_canmatch_extension(chan, chan->context, t, 1, chan->CALLERID_FIELD)) { ++ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", "1"); ++ /* They entered a valid extension, or might be anyhow */ ++ if (noextneeded) { ++ ast_log(LOG_NOTICE, "DTMF received (not matching to exten)\n"); ++ res = 0; ++ } else { ++ ast_log(LOG_NOTICE, "DTMF received (matching to exten)\n"); ++ res = fr2->subclass; ++ } ++ ast_frfree(fr); ++ break; ++ } else ++ ast_log(LOG_DEBUG, "Valid extension requested and DTMF did not match\n"); ++ } ++ } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass == AST_FORMAT_SLINEAR) && !ignoretalk) { ++ int totalsilence; ++ int ms; ++ res = ast_dsp_silence(dsp, fr, &totalsilence); ++ if (res && (totalsilence > sildur)) { ++ /* We've been quiet a little while */ ++ if (notsilent) { ++ /* We had heard some talking */ ++ gettimeofday(&end, NULL); ++ ms = (end.tv_sec - start.tv_sec) * 1000; ++ ms += (end.tv_usec - start.tv_usec) / 1000; ++ ms -= sildur; ++ if (ms < 0) ++ ms = 0; ++ if ((ms > mindur) && ((maxdur < 0) || (ms < maxdur))) { ++ char ms_str[10]; ++ ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms); ++ ast_log(LOG_NOTICE, "Redirecting %s to talk extension\n", chan->name); ++ ++ /* Save detected talk time (in milliseconds) */ ++ sprintf(ms_str, "%d", ms); ++ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", ms_str); ++ ++ if (ast_exists_extension(chan, chan->context, "talk", 1, chan->CALLERID_FIELD)) { ++ strncpy(chan->exten, "talk", sizeof(chan->exten) - 1); ++ chan->priority = 0; ++ } else ++ ast_log(LOG_WARNING, "Talk detected, but no talk extension\n"); ++ res = 0; ++ ast_frfree(fr); ++ break; ++ } else ++ ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms); ++ notsilent = 0; ++ } ++ } else { ++ if (!notsilent) { ++ /* Heard some audio, mark the begining of the token */ ++ gettimeofday(&start, NULL); ++ ast_log(LOG_DEBUG, "Start of voice token!\n"); ++ notsilent = 1; ++ } ++ } ++ } ++ ast_frfree(fr); ++ } ++ ast_sched_runq(chan->sched); ++ } ++ ast_stopstream(chan); ++ } else { ++ ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data); ++ res = 0; ++ } ++ } else ++ ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name); ++ ++ if (res > -1) { ++ if (origrformat && ast_set_read_format(chan, origrformat)) { ++ ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n", ++ chan->name, ast_getformatname(origrformat)); ++ } ++ } ++ ++ if (dsp) ++ ast_dsp_free(dsp); ++ ++ // LOCAL_USER_REMOVE(u); ++ ++ return res; ++} ++ ++static int unload_module(void) ++{ ++ // STANDARD_HANGUP_LOCALUSERS; ++ return ast_unregister_application(app); ++} ++ ++static int load_module(void) ++{ ++ return ast_register_application(app, nv_background_detect_exec, synopsis, descrip); ++} ++ ++AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Fax playing Background Music Detection Application"); +diff -uNr apps/app_nv_faxdetect.c apps/app_nv_faxdetect.c +--- apps/app_nv_faxdetect.c 1970-01-01 01:00:00.000000000 +0100 ++++ apps/app_nv_faxdetect.c 2010-02-10 22:09:40.119390638 +0000 +@@ -0,0 +1,317 @@ ++/* ++ * Asterisk -- A telephony toolkit for Linux. ++ * ++ * Fax detection application for all channel types. ++ * ++ * Copyright (C) 2004-2005, Newman Telecom, Inc. and Newman Ventures, Inc. ++ * ++ * Justin Newman <jnewman@newmantelecom.com> ++ * ++ * We would like to thank Newman Ventures, Inc. for funding this ++ * Asterisk project. ++ * ++ * Newman Ventures <info@newmanventures.com> ++ * ++ * Portions Copyright: ++ * Copyright (C) 2001, Linux Support Services, Inc. ++ * Copyright (C) 2004, Digium, Inc. ++ * ++ * Matthew Fredrickson <creslin@linux-support.net> ++ * Mark Spencer <markster@digium.com> ++ * ++ * This program is free software, distributed under the terms of ++ * the GNU General Public License ++ */ ++ ++#include "asterisk.h" ++ ++#include <asterisk/lock.h> ++#include <asterisk/file.h> ++#include <asterisk/logger.h> ++#include <asterisk/channel.h> ++#include <asterisk/pbx.h> ++#include <asterisk/module.h> ++#include <asterisk/translate.h> ++#include <asterisk/dsp.h> ++#include <asterisk/utils.h> ++ ++static char *app = "NVFaxDetect"; ++ ++static char *synopsis = "Detects fax sounds on all channel types (IAX and SIP too)"; ++ ++static char *descrip = ++" NVFaxDetect([waitdur[|options[|sildur[|mindur[|maxdur]]]]]):\n" ++"This application listens for fax tones (on IAX and SIP channels too)\n" ++"for waitdur seconds of time. In addition, it can be interrupted by digits,\n" ++"or non-silence. Audio is only monitored in the receive direction. If\n" ++"digits interrupt, they must be the start of a valid extension unless the\n" ++"option is included to ignore. If fax is detected, it will jump to the\n" ++"'fax' extension. If a period of non-silence greater than 'mindur' ms,\n" ++"yet less than 'maxdur' ms is followed by silence at least 'sildur' ms\n" ++"then the app is aborted and processing jumps to the 'talk' extension.\n" ++"If all undetected, control will continue at the next priority.\n" ++" waitdur: Maximum number of seconds to wait (default=4)\n" ++" options:\n" ++" 'n': Attempt on-hook if unanswered (default=no)\n" ++" 'x': DTMF digits terminate without extension (default=no)\n" ++" 'd': Ignore DTMF digit detection (default=no)\n" ++" 'f': Ignore fax detection (default=no)\n" ++" 't': Ignore talk detection (default=no)\n" ++" sildur: Silence ms after mindur/maxdur before aborting (default=1000)\n" ++" mindur: Minimum non-silence ms needed (default=100)\n" ++" maxdur: Maximum non-silence ms allowed (default=0/forever)\n" ++"Returns -1 on hangup, and 0 on successful completion with no exit conditions.\n\n" ++"For questions or comments, please e-mail support@newmantelecom.com.\n"; ++ ++// Use the second one for recent Asterisk releases ++#define CALLERID_FIELD cid.cid_num ++//#define CALLERID_FIELD callerid ++ ++static int nv_detectfax_exec(struct ast_channel *chan, void *data) ++{ ++ int res = 0; ++ char tmp[256] = "\0"; ++ char *p = NULL; ++ char *waitstr = NULL; ++ char *options = NULL; ++ char *silstr = NULL; ++ char *minstr = NULL; ++ char *maxstr = NULL; ++ struct ast_frame *fr = NULL; ++ struct ast_frame *fr2 = NULL; ++ int notsilent = 0; ++ struct timeval start = {0, 0}, end = {0, 0}; ++ int waitdur = 4; ++ int sildur = 1000; ++ int mindur = 100; ++ int maxdur = -1; ++ int skipanswer = 0; ++ int noextneeded = 0; ++ int ignoredtmf = 0; ++ int ignorefax = 0; ++ int ignoretalk = 0; ++ int x = 0; ++ int origrformat = 0; ++ int features = 0; ++ time_t timeout = 0; ++ struct ast_dsp *dsp = NULL; ++ ++ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", ""); ++ pbx_builtin_setvar_helper(chan, "FAXEXTEN", ""); ++ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", ""); ++ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", ""); ++ ++ if (data || !ast_strlen_zero((char *)data)) { ++ strncpy(tmp, (char *)data, sizeof(tmp)-1); ++ } ++ ++ p = tmp; ++ ++ waitstr = strsep(&p, "|"); ++ options = strsep(&p, "|"); ++ silstr = strsep(&p, "|"); ++ minstr = strsep(&p, "|"); ++ maxstr = strsep(&p, "|"); ++ ++ if (waitstr) { ++ if ((sscanf(waitstr, "%d", &x) == 1) && (x > 0)) ++ waitdur = x; ++ } ++ ++ if (options) { ++ if (strchr(options, 'n')) ++ skipanswer = 1; ++ if (strchr(options, 'x')) ++ noextneeded = 1; ++ if (strchr(options, 'd')) ++ ignoredtmf = 1; ++ if (strchr(options, 'f')) ++ ignorefax = 1; ++ if (strchr(options, 't')) ++ ignoretalk = 1; ++ } ++ ++ if (silstr) { ++ if ((sscanf(silstr, "%d", &x) == 1) && (x > 0)) ++ sildur = x; ++ } ++ ++ if (minstr) { ++ if ((sscanf(minstr, "%d", &x) == 1) && (x > 0)) ++ mindur = x; ++ } ++ ++ if (maxstr) { ++ if ((sscanf(maxstr, "%d", &x) == 1) && (x > 0)) ++ maxdur = x; ++ } ++ ++ ast_log(LOG_DEBUG, "Preparing detect of fax (waitdur=%dms, sildur=%dms, mindur=%dms, maxdur=%dms)\n", ++ waitdur, sildur, mindur, maxdur); ++ ++ // LOCAL_USER_ADD(u); ++ if (chan->_state != AST_STATE_UP && !skipanswer) { ++ /* Otherwise answer unless we're supposed to send this while on-hook */ ++ res = ast_answer(chan); ++ } ++ if (!res) { ++ origrformat = chan->readformat; ++ if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR))) ++ ast_log(LOG_WARNING, "Unable to set read format to linear!\n"); ++ } ++ if (!(dsp = ast_dsp_new())) { ++ ast_log(LOG_WARNING, "Unable to allocate DSP!\n"); ++ res = -1; ++ } ++ ++ if (dsp) { ++ if (!ignoretalk) ++ ; /* features |= DSP_FEATURE_SILENCE_SUPPRESS; */ ++ if (!ignorefax) ++ features |= DSP_FEATURE_FAX_DETECT; ++ //if (!ignoredtmf) ++ features |= DSP_FEATURE_DIGIT_DETECT; ++ ++ ast_dsp_set_threshold(dsp, 256); ++ ast_dsp_set_features(dsp, features | DSP_DIGITMODE_RELAXDTMF); ++ ast_dsp_set_digitmode(dsp, DSP_DIGITMODE_DTMF); ++ } ++ ++ if (!res) { ++ if (waitdur > 0) ++ timeout = time(NULL) + (time_t)waitdur; ++ ++ while(ast_waitfor(chan, -1) > -1) { ++ if (waitdur > 0 && time(NULL) > timeout) { ++ res = 0; ++ break; ++ } ++ ++ fr = ast_read(chan); ++ if (!fr) { ++ ast_log(LOG_DEBUG, "Got hangup\n"); ++ res = -1; ++ break; ++ } ++ ++ fr2 = ast_dsp_process(chan, dsp, fr); ++ if (!fr2) { ++ ast_log(LOG_WARNING, "Bad DSP received (what happened?)\n"); ++ fr2 = fr; ++ } ++ ++ if (fr2->frametype == AST_FRAME_DTMF) { ++ if (fr2->subclass == 'f' && !ignorefax) { ++ /* Fax tone -- Handle and return NULL */ ++ ast_log(LOG_DEBUG, "Fax detected on %s\n", chan->name); ++ if (strcmp(chan->exten, "fax")) { ++ ast_log(LOG_NOTICE, "Redirecting %s to fax extension\n", chan->name); ++ pbx_builtin_setvar_helper(chan, "FAX_DETECTED", "1"); ++ pbx_builtin_setvar_helper(chan,"FAXEXTEN",chan->exten); ++ if (ast_exists_extension(chan, chan->context, "fax", 1, chan->CALLERID_FIELD)) { ++ /* Save the DID/DNIS when we transfer the fax call to a "fax" extension */ ++ strncpy(chan->exten, "fax", sizeof(chan->exten)-1); ++ chan->priority = 0; ++ } else ++ ast_log(LOG_WARNING, "Fax detected, but no fax extension\n"); ++ } else ++ ast_log(LOG_WARNING, "Already in a fax extension, not redirecting\n"); ++ ++ res = 0; ++ ast_frfree(fr); ++ break; ++ } else if (!ignoredtmf) { ++ ast_log(LOG_DEBUG, "DTMF detected on %s\n", chan->name); ++ char t[2]; ++ t[0] = fr2->subclass; ++ t[1] = '\0'; ++ if (noextneeded || ast_canmatch_extension(chan, chan->context, t, 1, chan->CALLERID_FIELD)) { ++ pbx_builtin_setvar_helper(chan, "DTMF_DETECTED", "1"); ++ /* They entered a valid extension, or might be anyhow */ ++ if (noextneeded) { ++ ast_log(LOG_NOTICE, "DTMF received (not matching to exten)\n"); ++ res = 0; ++ } else { ++ ast_log(LOG_NOTICE, "DTMF received (matching to exten)\n"); ++ res = fr2->subclass; ++ } ++ ast_frfree(fr); ++ break; ++ } else ++ ast_log(LOG_DEBUG, "Valid extension requested and DTMF did not match\n"); ++ } ++ } else if ((fr->frametype == AST_FRAME_VOICE) && (fr->subclass == AST_FORMAT_SLINEAR) && !ignoretalk) { ++ int totalsilence; ++ int ms; ++ res = ast_dsp_silence(dsp, fr, &totalsilence); ++ if (res && (totalsilence > sildur)) { ++ /* We've been quiet a little while */ ++ if (notsilent) { ++ /* We had heard some talking */ ++ gettimeofday(&end, NULL); ++ ms = (end.tv_sec - start.tv_sec) * 1000; ++ ms += (end.tv_usec - start.tv_usec) / 1000; ++ ms -= sildur; ++ if (ms < 0) ++ ms = 0; ++ if ((ms > mindur) && ((maxdur < 0) || (ms < maxdur))) { ++ char ms_str[10]; ++ ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms); ++ ast_log(LOG_NOTICE, "Redirecting %s to talk extension\n", chan->name); ++ ++ /* Save detected talk time (in milliseconds) */ ++ sprintf(ms_str, "%d", ms); ++ pbx_builtin_setvar_helper(chan, "TALK_DETECTED", ms_str); ++ ++ if (ast_exists_extension(chan, chan->context, "talk", 1, chan->CALLERID_FIELD)) { ++ strncpy(chan->exten, "talk", sizeof(chan->exten) - 1); ++ chan->priority = 0; ++ } else ++ ast_log(LOG_WARNING, "Talk detected, but no talk extension\n"); ++ res = 0; ++ ast_frfree(fr); ++ break; ++ } else ++ ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms); ++ notsilent = 0; ++ } ++ } else { ++ if (!notsilent) { ++ /* Heard some audio, mark the begining of the token */ ++ gettimeofday(&start, NULL); ++ ast_log(LOG_DEBUG, "Start of voice token!\n"); ++ notsilent = 1; ++ } ++ } ++ } ++ ast_frfree(fr); ++ } ++ } else ++ ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name); ++ ++ if (res > -1) { ++ if (origrformat && ast_set_read_format(chan, origrformat)) { ++ ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n", ++ chan->name, ast_getformatname(origrformat)); ++ } ++ } ++ ++ if (dsp) ++ ast_dsp_free(dsp); ++ ++ // LOCAL_USER_REMOVE(u); ++ ++ return res; ++} ++ ++static int unload_module(void) ++{ ++ return ast_unregister_application(app); ++} ++ ++static int load_module(void) ++{ ++ return ast_register_application(app, nv_detectfax_exec, synopsis, descrip); ++} ++ ++AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Fax Detection Application"); diff --git a/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-parallel-make.patch b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-parallel-make.patch new file mode 100644 index 000000000000..122dc1d2f78f --- /dev/null +++ b/net-misc/asterisk/files/1.6.2/asterisk-1.6.2.2-parallel-make.patch @@ -0,0 +1,21 @@ +diff -uNr asterisk-1.6.2.1.ORIG/Makefile asterisk-1.6.2.1/Makefile +--- asterisk-1.6.2.1.ORIG/Makefile 2010-01-19 17:06:47.000000000 +0000 ++++ asterisk-1.6.2.1/Makefile 2010-01-19 17:08:15.000000000 +0000 +@@ -590,7 +590,7 @@ + fi + + $(SUBDIRS_INSTALL): +- @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install ++ +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install + + NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so))) + OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so))) +@@ -852,7 +852,7 @@ + @cmp -s .cleancount .lastclean || $(MAKE) clean + + $(SUBDIRS_UNINSTALL): +- @$(SUBMAKE) -C $(@:-uninstall=) uninstall ++ +@$(SUBMAKE) -C $(@:-uninstall=) uninstall + + _uninstall: $(SUBDIRS_UNINSTALL) + rm -f $(DESTDIR)$(MODULES_DIR)/* |