1.1 --- a/asterisk/asterisk.patch Sun Mar 20 19:27:35 2011 +0100 1.2 +++ b/asterisk/asterisk.patch Sun Mar 20 20:00:02 2011 +0100 1.3 @@ -1,2265 +1,810 @@ 1.4 -Index: cdr/cdr_sqlite.c 1.5 -diff -Nau cdr/cdr_sqlite.c.orig cdr/cdr_sqlite.c 1.6 ---- cdr/cdr_sqlite.c.orig 2007-06-14 23:50:40.000000000 +0200 1.7 -+++ cdr/cdr_sqlite.c 2009-04-24 00:30:33.000000000 +0200 1.8 -@@ -58,7 +58,7 @@ 1.9 - #define DATE_FORMAT "%Y-%m-%d %T" 1.10 +Index: Makefile 1.11 +--- Makefile.orig 2010-06-10 22:35:06.000000000 +0200 1.12 ++++ Makefile 2010-07-24 11:16:19.000000000 +0200 1.13 +@@ -126,40 +126,18 @@ 1.14 1.15 - static char *name = "sqlite"; 1.16 --static sqlite* db = NULL; 1.17 -+static sqlite3 *db = NULL; 1.18 + # Define standard directories for various platforms 1.19 + # These apply if they are not redefined in asterisk.conf 1.20 +-ifeq ($(OSARCH),SunOS) 1.21 +- ASTETCDIR=/var/etc/asterisk 1.22 +- ASTLIBDIR=/opt/asterisk/lib 1.23 +- ASTVARLIBDIR=/var/opt/asterisk 1.24 +- ASTDBDIR=$(ASTVARLIBDIR) 1.25 +- ASTKEYDIR=$(ASTVARLIBDIR) 1.26 +- ASTSPOOLDIR=/var/spool/asterisk 1.27 +- ASTLOGDIR=/var/log/asterisk 1.28 +- ASTHEADERDIR=/opt/asterisk/include 1.29 +- ASTSBINDIR=/opt/asterisk/sbin 1.30 +- ASTVARRUNDIR=/var/run/asterisk 1.31 +- ASTMANDIR=/opt/asterisk/man 1.32 +-else 1.33 + ASTETCDIR=$(sysconfdir)/asterisk 1.34 + ASTLIBDIR=$(libdir)/asterisk 1.35 + ASTHEADERDIR=$(includedir)/asterisk 1.36 + ASTSBINDIR=$(sbindir) 1.37 +- ASTSPOOLDIR=$(localstatedir)/spool/asterisk 1.38 +- ASTLOGDIR=$(localstatedir)/log/asterisk 1.39 +- ASTVARRUNDIR=$(localstatedir)/run/asterisk 1.40 ++ ASTSPOOLDIR=$(localstatedir)/spool 1.41 ++ ASTLOGDIR=$(localstatedir)/log 1.42 ++ ASTVARRUNDIR=$(localstatedir)/run 1.43 + ASTMANDIR=$(mandir) 1.44 +-ifneq ($(findstring BSD,$(OSARCH)),) 1.45 +- ASTVARLIBDIR=$(prefix)/share/asterisk 1.46 +- ASTVARRUNDIR=$(localstatedir)/run/asterisk 1.47 +- ASTDBDIR=$(localstatedir)/db/asterisk 1.48 +-else 1.49 +- ASTVARLIBDIR=$(localstatedir)/lib/asterisk 1.50 +- ASTDBDIR=$(ASTVARLIBDIR) 1.51 +-endif 1.52 ++ ASTVARLIBDIR=$(localstatedir)/lib 1.53 ++ ASTDBDIR=$(localstatedir)/db 1.54 + ASTKEYDIR=$(ASTVARLIBDIR) 1.55 +-endif 1.56 +-ifeq ($(ASTDATADIR),) 1.57 + ASTDATADIR:=$(ASTVARLIBDIR) 1.58 +-endif 1.59 1.60 - AST_MUTEX_DEFINE_STATIC(sqlite_lock); 1.61 + # Asterisk.conf is located in ASTETCDIR or by using the -C flag 1.62 + # when starting Asterisk 1.63 +@@ -259,12 +237,6 @@ 1.64 + _ASTCFLAGS+=-fsigned-char 1.65 + endif 1.66 1.67 -@@ -92,10 +92,10 @@ 1.68 - static int sqlite_log(struct ast_cdr *cdr) 1.69 - { 1.70 - int res = 0; 1.71 -- char *zErr = 0; 1.72 - struct tm tm; 1.73 - time_t t; 1.74 - char startstr[80], answerstr[80], endstr[80]; 1.75 -+ char *cdrsql = 0; 1.76 - int count; 1.77 - 1.78 - ast_mutex_lock(&sqlite_lock); 1.79 -@@ -113,7 +113,7 @@ 1.80 - strftime(endstr, sizeof(endstr), DATE_FORMAT, &tm); 1.81 - 1.82 - for(count=0; count<5; count++) { 1.83 -- res = sqlite_exec_printf(db, 1.84 -+ cdrsql = sqlite3_mprintf( 1.85 - "INSERT INTO cdr (" 1.86 - "clid,src,dst,dcontext," 1.87 - "channel,dstchannel,lastapp,lastdata, " 1.88 -@@ -138,8 +138,7 @@ 1.89 - # if LOG_USERFIELD 1.90 - ",'%q'" 1.91 - # endif 1.92 -- ")", NULL, NULL, &zErr, 1.93 -- cdr->clid, cdr->src, cdr->dst, cdr->dcontext, 1.94 -+ ")", cdr->clid, cdr->src, cdr->dst, cdr->dcontext, 1.95 - cdr->channel, cdr->dstchannel, cdr->lastapp, cdr->lastdata, 1.96 - startstr, answerstr, endstr, 1.97 - cdr->duration, cdr->billsec, cdr->disposition, cdr->amaflags, 1.98 -@@ -151,16 +150,13 @@ 1.99 - ,cdr->userfield 1.100 - # endif 1.101 - ); 1.102 -+ res = sqlite3_exec(db, cdrsql, 0, 0, 0); 1.103 -+ sqlite3_free(cdrsql); 1.104 - if (res != SQLITE_BUSY && res != SQLITE_LOCKED) 1.105 - break; 1.106 - usleep(200); 1.107 - } 1.108 - 1.109 -- if (zErr) { 1.110 -- ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr); 1.111 -- free(zErr); 1.112 -- } 1.113 +-ifeq ($(OSARCH),FreeBSD) 1.114 +- # -V is understood by BSD Make, not by GNU make. 1.115 +- BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk) 1.116 +- _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi) 1.117 +-endif 1.118 - 1.119 - ast_mutex_unlock(&sqlite_lock); 1.120 - return res; 1.121 - } 1.122 -@@ -168,7 +164,7 @@ 1.123 - static int unload_module(void) 1.124 - { 1.125 - if (db) 1.126 -- sqlite_close(db); 1.127 -+ sqlite3_close(db); 1.128 - ast_cdr_unregister(name); 1.129 - return 0; 1.130 - } 1.131 -@@ -181,17 +177,16 @@ 1.132 - 1.133 - /* is the database there? */ 1.134 - snprintf(fn, sizeof(fn), "%s/cdr.db", ast_config_AST_LOG_DIR); 1.135 -- db = sqlite_open(fn, 0660, &zErr); 1.136 -+ sqlite3_open(fn, &db); 1.137 - if (!db) { 1.138 -- ast_log(LOG_ERROR, "cdr_sqlite: %s\n", zErr); 1.139 -- free(zErr); 1.140 -+ ast_log(LOG_ERROR, "cdr_sqlite: %s\n", sqlite3_errmsg(db)); 1.141 - return -1; 1.142 - } 1.143 - 1.144 - /* is the table there? */ 1.145 -- res = sqlite_exec(db, "SELECT COUNT(AcctId) FROM cdr;", NULL, NULL, NULL); 1.146 -+ res = sqlite3_exec(db, "SELECT COUNT(AcctId) FROM cdr;", NULL, NULL, NULL); 1.147 - if (res) { 1.148 -- res = sqlite_exec(db, sql_create_table, NULL, NULL, &zErr); 1.149 -+ res = sqlite3_exec(db, sql_create_table, NULL, NULL, &zErr); 1.150 - if (res) { 1.151 - ast_log(LOG_ERROR, "cdr_sqlite: Unable to create table 'cdr': %s\n", zErr); 1.152 - free(zErr); 1.153 -@@ -210,7 +205,7 @@ 1.154 - 1.155 - err: 1.156 - if (db) 1.157 -- sqlite_close(db); 1.158 -+ sqlite3_close(db); 1.159 - return -1; 1.160 - } 1.161 - 1.162 -Index: channels/chan_sip.c 1.163 -diff -Nau channels/chan_sip.c.orig channels/chan_sip.c 1.164 ---- channels/chan_sip.c.orig 2009-04-02 19:20:22.000000000 +0200 1.165 -+++ channels/chan_sip.c 2009-04-24 00:30:33.000000000 +0200 1.166 -@@ -7469,7 +7469,7 @@ 1.167 - 1.168 - ast_copy_string(from, get_header(&p->initreq, "From"), sizeof(from)); 1.169 - c = get_in_brackets(from); 1.170 -- if (strncasecmp(c, "sip:", 4)) { 1.171 -+ if (strncasecmp(c, "sip:", 4) && strncasecmp(c, "sips:", 5)) { 1.172 - ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", c); 1.173 - return -1; 1.174 - } 1.175 -@@ -7477,7 +7477,7 @@ 1.176 - 1.177 - ast_copy_string(to, get_header(&p->initreq, "To"), sizeof(to)); 1.178 - c = get_in_brackets(to); 1.179 -- if (strncasecmp(c, "sip:", 4)) { 1.180 -+ if (strncasecmp(c, "sip:", 4) && strncasecmp(c, "sips:", 5)) { 1.181 - ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", c); 1.182 - return -1; 1.183 - } 1.184 -@@ -8004,7 +8004,10 @@ 1.185 - of = get_in_brackets(from); 1.186 - ast_string_field_set(p, from, of); 1.187 - if (strncasecmp(of, "sip:", 4)) 1.188 -- ast_log(LOG_NOTICE, "From address missing 'sip:', using it anyway\n"); 1.189 -+ if (strncasecmp(of, "sips:", 5)) 1.190 -+ ast_log(LOG_NOTICE, "From address missing 'sip:' or 'sips:', using it anyway\n"); 1.191 -+ else 1.192 -+ of += 5; 1.193 - else 1.194 - of += 4; 1.195 - /* Get just the username part */ 1.196 -@@ -8280,7 +8283,10 @@ 1.197 - 1.198 - /* Make sure it's a SIP URL */ 1.199 - if (strncasecmp(contact, "sip:", 4)) { 1.200 -- ast_log(LOG_NOTICE, "'%s' is not a valid SIP contact (missing sip:) trying to use anyway\n", contact); 1.201 -+ if (strncasecmp(contact, "sips:", 5)) 1.202 -+ ast_log(LOG_NOTICE, "'%s' is not a valid SIP contact (missing sip: or sips:) trying to use anyway\n", contact); 1.203 -+ else 1.204 -+ contact += 5; 1.205 - } else 1.206 - contact += 4; 1.207 - 1.208 -@@ -8409,7 +8415,10 @@ 1.209 - 1.210 - /* Make sure it's a SIP URL */ 1.211 - if (strncasecmp(curi, "sip:", 4)) { 1.212 -- ast_log(LOG_NOTICE, "'%s' is not a valid SIP contact (missing sip:) trying to use anyway\n", curi); 1.213 -+ if (strncasecmp(curi, "sips:", 5)) 1.214 -+ ast_log(LOG_NOTICE, "'%s' is not a valid SIP contact (missing sip: or sips:) trying to use anyway\n", curi); 1.215 -+ else 1.216 -+ curi += 5; 1.217 - } else 1.218 - curi += 4; 1.219 - /* Ditch q */ 1.220 -@@ -9000,9 +9009,12 @@ 1.221 - 1.222 - if (!strncasecmp(c, "sip:", 4)) { 1.223 - name = c + 4; 1.224 -+ } 1.225 -+ else if (!strncasecmp(c, "sips:", 5)) { 1.226 -+ name = c + 5; 1.227 - } else { 1.228 - name = c; 1.229 -- ast_log(LOG_NOTICE, "Invalid to address: '%s' from %s (missing sip:) trying to use anyway...\n", c, ast_inet_ntoa(sin->sin_addr)); 1.230 -+ ast_log(LOG_NOTICE, "Invalid to address: '%s' from %s (missing sip: or sips:) trying to use anyway...\n", c, ast_inet_ntoa(sin->sin_addr)); 1.231 - } 1.232 - 1.233 - /* Strip off the domain name */ 1.234 -@@ -9162,10 +9174,15 @@ 1.235 - return 0; 1.236 - c = get_in_brackets(tmp); 1.237 - if (strncasecmp(c, "sip:", 4)) { 1.238 -- ast_log(LOG_WARNING, "Huh? Not an RDNIS SIP header (%s)?\n", c); 1.239 -- return -1; 1.240 -+ if (strncasecmp(c, "sips:", 5)) { 1.241 -+ ast_log(LOG_WARNING, "Huh? Not an RDNIS SIP header (%s)?\n", c); 1.242 -+ return -1; 1.243 -+ } 1.244 -+ else 1.245 -+ c += 5; 1.246 - } 1.247 -- c += 4; 1.248 -+ else 1.249 -+ c += 4; 1.250 - a = c; 1.251 - strsep(&a, "@;"); /* trim anything after @ or ; */ 1.252 - if (sip_debug_test_pvt(p)) 1.253 -@@ -9200,10 +9217,15 @@ 1.254 - uri = get_in_brackets(tmp); 1.255 - 1.256 - if (strncasecmp(uri, "sip:", 4)) { 1.257 -- ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", uri); 1.258 -- return -1; 1.259 -+ if (strncasecmp(uri, "sips:", 5)) { 1.260 -+ ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", uri); 1.261 -+ return -1; 1.262 -+ } 1.263 -+ else 1.264 -+ uri += 5; 1.265 - } 1.266 -- uri += 4; 1.267 -+ else 1.268 -+ uri += 4; 1.269 - 1.270 - /* Now find the From: caller ID and name */ 1.271 - ast_copy_string(tmpf, get_header(req, "From"), sizeof(tmpf)); 1.272 -@@ -9217,10 +9239,15 @@ 1.273 - 1.274 - if (!ast_strlen_zero(from)) { 1.275 - if (strncasecmp(from, "sip:", 4)) { 1.276 -- ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", from); 1.277 -- return -1; 1.278 -+ if (strncasecmp(from, "sips:", 5)) { 1.279 -+ ast_log(LOG_WARNING, "Huh? Not a SIP header (%s)?\n", from); 1.280 -+ return -1; 1.281 -+ } 1.282 -+ else 1.283 -+ from += 5; 1.284 - } 1.285 -- from += 4; 1.286 -+ else 1.287 -+ from += 4; 1.288 - if ((a = strchr(from, '@'))) 1.289 - *a++ = '\0'; 1.290 - else 1.291 -@@ -9397,10 +9424,15 @@ 1.292 - ast_uri_decode(refer_to); 1.293 - 1.294 - if (strncasecmp(refer_to, "sip:", 4)) { 1.295 -- ast_log(LOG_WARNING, "Can't transfer to non-sip: URI. (Refer-to: %s)?\n", refer_to); 1.296 -- return -3; 1.297 -+ if (strncasecmp(refer_to, "sips:", 5)) { 1.298 -+ ast_log(LOG_WARNING, "Can't transfer to non-sip: URI. (Refer-to: %s)?\n", refer_to); 1.299 -+ return -3; 1.300 -+ } 1.301 -+ else 1.302 -+ refer_to += 5; /* Skip sips: */ 1.303 - } 1.304 -- refer_to += 4; /* Skip sip: */ 1.305 -+ else 1.306 -+ refer_to += 4; /* Skip sip: */ 1.307 - 1.308 - /* Get referred by header if it exists */ 1.309 - p_referred_by = get_header(req, "Referred-By"); 1.310 -@@ -9417,9 +9449,13 @@ 1.311 - } 1.312 - 1.313 - referred_by_uri = get_in_brackets(h_referred_by); 1.314 -- if(strncasecmp(referred_by_uri, "sip:", 4)) { 1.315 -- ast_log(LOG_WARNING, "Huh? Not a sip: header (Referred-by: %s). Skipping.\n", referred_by_uri); 1.316 -- referred_by_uri = (char *) NULL; 1.317 -+ if (strncasecmp(referred_by_uri, "sip:", 4)) { 1.318 -+ if (strncasecmp(referred_by_uri, "sips:", 5)) { 1.319 -+ ast_log(LOG_WARNING, "Huh? Not a sip: header (Referred-by: %s). Skipping.\n", referred_by_uri); 1.320 -+ referred_by_uri = (char *) NULL; 1.321 -+ } 1.322 -+ else 1.323 -+ referred_by_uri += 5; /* Skip sips: */ 1.324 - } else { 1.325 - referred_by_uri += 4; /* Skip sip: */ 1.326 - } 1.327 -@@ -9547,10 +9583,15 @@ 1.328 - ast_uri_decode(c); 1.329 - 1.330 - if (strncasecmp(c, "sip:", 4)) { 1.331 -- ast_log(LOG_WARNING, "Huh? Not a SIP header in Also: transfer (%s)?\n", c); 1.332 -- return -1; 1.333 -+ if (strncasecmp(c, "sips:", 5)) { 1.334 -+ ast_log(LOG_WARNING, "Huh? Not a SIP header in Also: transfer (%s)?\n", c); 1.335 -+ return -1; 1.336 -+ } 1.337 -+ else 1.338 -+ c += 5; 1.339 - } 1.340 -- c += 4; 1.341 -+ else 1.342 -+ c += 4; 1.343 - if ((a = strchr(c, ';'))) /* Remove arguments */ 1.344 - *a = '\0'; 1.345 - 1.346 -@@ -9761,6 +9802,8 @@ 1.347 - t = uri2; 1.348 - if (!strncasecmp(t, "sip:", 4)) 1.349 - t+= 4; 1.350 -+ else if (!strncasecmp(t, "sips:", 5)) 1.351 -+ t+= 5; 1.352 - ast_string_field_set(p, exten, t); 1.353 - t = strchr(p->exten, '@'); 1.354 - if (t) 1.355 -@@ -9771,7 +9814,10 @@ 1.356 - /* save the URI part of the From header */ 1.357 - ast_string_field_set(p, from, of); 1.358 - if (strncasecmp(of, "sip:", 4)) { 1.359 -- ast_log(LOG_NOTICE, "From address missing 'sip:', using it anyway\n"); 1.360 -+ if (strncasecmp(of, "sips:", 5)) 1.361 -+ ast_log(LOG_NOTICE, "From address missing 'sip:' or 'sips:', using it anyway\n"); 1.362 -+ else 1.363 -+ of += 5; 1.364 - } else 1.365 - of += 4; 1.366 - /* Get just the username part */ 1.367 -@@ -12379,6 +12425,8 @@ 1.368 - if (ast_test_flag(&p->flags[0], SIP_PROMISCREDIR)) { 1.369 - if (!strncasecmp(s, "sip:", 4)) 1.370 - s += 4; 1.371 -+ else if (!strncasecmp(s, "sips:", 5)) 1.372 -+ s += 5; 1.373 - e = strchr(s, ';'); 1.374 - if (e) 1.375 - *e = '\0'; 1.376 -@@ -12404,6 +12452,8 @@ 1.377 - 1.378 - if (!strncasecmp(s, "sip:", 4)) 1.379 - s += 4; 1.380 -+ else if (!strncasecmp(s, "sips:", 5)) 1.381 -+ s += 5; 1.382 - if (option_debug > 1) 1.383 - ast_log(LOG_DEBUG, "Received 302 Redirect to extension '%s' (domain %s)\n", s, domain); 1.384 - if (p->owner) { 1.385 -Index: codecs/codec_g722.c 1.386 -diff -Nau codecs/codec_g722.c.orig codecs/codec_g722.c 1.387 ---- codecs/codec_g722.c.orig 1970-01-01 01:00:00.000000000 +0100 1.388 -+++ codecs/codec_g722.c 2009-04-24 00:30:33.000000000 +0200 1.389 -@@ -0,0 +1,306 @@ 1.390 -+/* 1.391 -+ * Asterisk -- An open source telephony toolkit. 1.392 -+ * 1.393 -+ * Copyright (C) 1999 - 2008, Digium, Inc. 1.394 -+ * 1.395 -+ * Matthew Fredrickson <creslin@digium.com> 1.396 -+ * Russell Bryant <russell@digium.com> 1.397 -+ * 1.398 -+ * Special thanks to Steve Underwood for the implementation 1.399 -+ * and for doing the 8khz<->g.722 direct translation code. 1.400 -+ * 1.401 -+ * See http://www.asterisk.org for more information about 1.402 -+ * the Asterisk project. Please do not directly contact 1.403 -+ * any of the maintainers of this project for assistance; 1.404 -+ * the project provides a web site, mailing lists and IRC 1.405 -+ * channels for your use. 1.406 -+ * 1.407 -+ * This program is free software, distributed under the terms of 1.408 -+ * the GNU General Public License Version 2. See the LICENSE file 1.409 -+ * at the top of the source tree. 1.410 -+ */ 1.411 -+ 1.412 -+/*! \file 1.413 -+ * 1.414 -+ * \brief codec_g722.c - translate between signed linear and ITU G.722-64kbps 1.415 -+ * 1.416 -+ * \author Matthew Fredrickson <creslin@digium.com> 1.417 -+ * \author Russell Bryant <russell@digium.com> 1.418 -+ * 1.419 -+ * \arg http://soft-switch.org/downloads/non-gpl-bits.tgz 1.420 -+ * \arg http://lists.digium.com/pipermail/asterisk-dev/2006-September/022866.html 1.421 -+ * 1.422 -+ * \ingroup codecs 1.423 -+ */ 1.424 + ifeq ($(OSARCH),NetBSD) 1.425 + _ASTCFLAGS+=-pthread -I/usr/pkg/include 1.426 + endif 1.427 +@@ -567,8 +539,7 @@ 1.428 + fi 1.429 + mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation 1.430 + mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation/thirdparty 1.431 +- mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv 1.432 +- mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom 1.433 ++ mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr 1.434 + mkdir -p $(DESTDIR)$(ASTDATADIR)/keys 1.435 + mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware 1.436 + mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax 1.437 +Index: apps/app_backticks.c 1.438 +--- apps/app_backticks.c.orig 2010-07-24 11:12:31.000000000 +0200 1.439 ++++ apps/app_backticks.c 2010-07-24 11:12:31.000000000 +0200 1.440 +@@ -0,0 +1,129 @@ 1.441 + 1.442 +#include "asterisk.h" 1.443 + 1.444 -+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 106501 $") 1.445 ++ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1.53 $") 1.446 + 1.447 -+#include "asterisk/linkedlists.h" 1.448 -+#include "asterisk/module.h" 1.449 -+#include "asterisk/config.h" 1.450 -+#include "asterisk/options.h" 1.451 -+#include "asterisk/translate.h" 1.452 -+#include "asterisk/utils.h" 1.453 ++#include <stdio.h> 1.454 ++#include <asterisk/file.h> 1.455 ++#include <asterisk/logger.h> 1.456 ++#include <asterisk/channel.h> 1.457 ++#include <asterisk/pbx.h> 1.458 ++#include <asterisk/module.h> 1.459 ++#include <asterisk/lock.h> 1.460 ++#include <asterisk/app.h> 1.461 ++#include <stdlib.h> 1.462 ++#include <unistd.h> 1.463 ++#include <string.h> 1.464 + 1.465 -+#define BUFFER_SAMPLES 8096 /* size for the translation buffers */ 1.466 -+#define BUF_SHIFT 5 1.467 ++static char *app = "BackTicks"; 1.468 ++static char *synopsis = "Execute a shell command and save the result as a variable."; 1.469 ++static char *desc = " Backticks(<VARNAME>|<command>)\n\n" 1.470 ++ "Be sure to include a full path to the command!\n"; 1.471 + 1.472 -+/* Sample frame data */ 1.473 ++static char *do_backticks(char *command, char *buf, size_t len) 1.474 ++{ 1.475 ++ int fds[2], pid = 0; 1.476 ++ char *ret = NULL; 1.477 + 1.478 -+#include "g722/g722.h" 1.479 -+#include "slin_g722_ex.h" 1.480 -+#include "g722_slin_ex.h" 1.481 -+ 1.482 -+struct g722_encoder_pvt { 1.483 -+ g722_encode_state_t g722; 1.484 -+}; 1.485 -+ 1.486 -+struct g722_decoder_pvt { 1.487 -+ g722_decode_state_t g722; 1.488 -+}; 1.489 -+ 1.490 -+/*! \brief init a new instance of g722_encoder_pvt. */ 1.491 -+static int lintog722_new(struct ast_trans_pvt *pvt) 1.492 -+{ 1.493 -+ struct g722_encoder_pvt *tmp = pvt->pvt; 1.494 -+ 1.495 -+ g722_encode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000); 1.496 -+ 1.497 -+ return 0; 1.498 ++ memset(buf, 0, len); 1.499 ++ if (pipe(fds)) { 1.500 ++ ast_log(LOG_WARNING, "Pipe/Exec failed\n"); 1.501 ++ } else { 1.502 ++ pid = fork(); 1.503 ++ if (pid < 0) { 1.504 ++ ast_log(LOG_WARNING, "Fork failed\n"); 1.505 ++ close(fds[0]); 1.506 ++ close(fds[1]); 1.507 ++ } else if (pid) { 1.508 ++ /* parent */ 1.509 ++ close(fds[1]); 1.510 ++ read(fds[0], buf, len); 1.511 ++ close(fds[0]); 1.512 ++ ret = buf; 1.513 ++ } else { 1.514 ++ /* child */ 1.515 ++ char *argv[255] = {0}; 1.516 ++ int argc = 0; 1.517 ++ char *p; 1.518 ++ char *mycmd = ast_strdupa(command); 1.519 ++ close(fds[0]); 1.520 ++ dup2(fds[1], STDOUT_FILENO); 1.521 ++ argv[argc++] = mycmd; 1.522 ++ do { 1.523 ++ if ((p = strchr(mycmd, ' '))) { 1.524 ++ *p = '\0'; 1.525 ++ mycmd = ++p; 1.526 ++ argv[argc++] = mycmd; 1.527 ++ } 1.528 ++ } while (p != NULL); 1.529 ++ close(fds[1]); 1.530 ++ execv(argv[0], argv); 1.531 ++ ast_log(LOG_ERROR, "exec of %s failed\n", argv[0]); 1.532 ++ exit(0); 1.533 ++ } 1.534 ++ } 1.535 ++ return ret; 1.536 +} 1.537 + 1.538 -+static int lin16tog722_new(struct ast_trans_pvt *pvt) 1.539 ++static int backticks_exec(struct ast_channel *chan, void *data) 1.540 +{ 1.541 -+ struct g722_encoder_pvt *tmp = pvt->pvt; 1.542 -+ 1.543 -+ g722_encode_init(&tmp->g722, 64000, 0); 1.544 -+ 1.545 -+ return 0; 1.546 ++ int res = 0; 1.547 ++ const char *usage = "Usage: Backticks(<VARNAME>|<command>)"; 1.548 ++ char buf[1024], *argv[2], *mydata; 1.549 ++ int argc = 0; 1.550 ++ 1.551 ++ if (!data) { 1.552 ++ ast_log(LOG_WARNING, "%s\n", usage); 1.553 ++ return -1; 1.554 ++ } 1.555 ++ ast_autoservice_start(chan); 1.556 ++ if (!(mydata = ast_strdupa(data))) { 1.557 ++ ast_log(LOG_ERROR, "Memory Error!\n"); 1.558 ++ res = -1; 1.559 ++ } else { 1.560 ++ if((argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]))) < 2) { 1.561 ++ ast_log(LOG_WARNING, "%s\n", usage); 1.562 ++ res = -1; 1.563 ++ } 1.564 ++ if (do_backticks(argv[1], buf, sizeof(buf))) 1.565 ++ pbx_builtin_setvar_helper(chan, argv[0], buf); 1.566 ++ else { 1.567 ++ ast_log(LOG_WARNING, "No Data!\n"); 1.568 ++ res = -1; 1.569 ++ } 1.570 ++ } 1.571 ++ ast_autoservice_stop(chan); 1.572 ++ return res; 1.573 +} 1.574 + 1.575 -+/*! \brief init a new instance of g722_encoder_pvt. */ 1.576 -+static int g722tolin_new(struct ast_trans_pvt *pvt) 1.577 ++static int function_backticks(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) 1.578 +{ 1.579 -+ struct g722_decoder_pvt *tmp = pvt->pvt; 1.580 -+ 1.581 -+ g722_decode_init(&tmp->g722, 64000, G722_SAMPLE_RATE_8000); 1.582 -+ 1.583 -+ return 0; 1.584 ++ if (!do_backticks(data, buf, len)) { 1.585 ++ ast_log(LOG_WARNING, "No Data!\n"); 1.586 ++ return -1; 1.587 ++ } 1.588 ++ return 0; 1.589 +} 1.590 + 1.591 -+static int g722tolin16_new(struct ast_trans_pvt *pvt) 1.592 -+{ 1.593 -+ struct g722_decoder_pvt *tmp = pvt->pvt; 1.594 -+ 1.595 -+ g722_decode_init(&tmp->g722, 64000, 0); 1.596 -+ 1.597 -+ return 0; 1.598 -+} 1.599 -+ 1.600 -+static int g722tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) 1.601 -+{ 1.602 -+ struct g722_decoder_pvt *tmp = pvt->pvt; 1.603 -+ int out_samples; 1.604 -+ int in_samples; 1.605 -+ 1.606 -+ /* g722_decode expects the samples to be in the invalid samples / 2 format */ 1.607 -+ in_samples = f->samples / 2; 1.608 -+ 1.609 -+ out_samples = g722_decode(&tmp->g722, (int16_t *) &pvt->outbuf[pvt->samples * sizeof(int16_t)], 1.610 -+ (uint8_t *) f->data, in_samples); 1.611 -+ 1.612 -+ pvt->samples += out_samples; 1.613 -+ 1.614 -+ pvt->datalen += (out_samples * sizeof(int16_t)); 1.615 -+ 1.616 -+ return 0; 1.617 -+} 1.618 -+ 1.619 -+static int lintog722_framein(struct ast_trans_pvt *pvt, struct ast_frame *f) 1.620 -+{ 1.621 -+ struct g722_encoder_pvt *tmp = pvt->pvt; 1.622 -+ int outlen; 1.623 -+ 1.624 -+ outlen = g722_encode(&tmp->g722, (uint8_t *) (&pvt->outbuf[pvt->datalen]), 1.625 -+ (int16_t *) f->data, f->samples); 1.626 -+ 1.627 -+ pvt->samples += outlen * 2; 1.628 -+ 1.629 -+ pvt->datalen += outlen; 1.630 -+ 1.631 -+ return 0; 1.632 -+} 1.633 -+ 1.634 -+static struct ast_frame *g722tolin_sample(void) 1.635 -+{ 1.636 -+ static struct ast_frame f = { 1.637 -+ .frametype = AST_FRAME_VOICE, 1.638 -+ .subclass = AST_FORMAT_G722, 1.639 -+ .datalen = sizeof(g722_slin_ex), 1.640 -+ .samples = sizeof(g722_slin_ex) * 2, 1.641 -+ .src = __PRETTY_FUNCTION__, 1.642 -+ .data = g722_slin_ex, 1.643 -+ }; 1.644 -+ 1.645 -+ return &f; 1.646 -+} 1.647 -+ 1.648 -+static struct ast_frame *g722tolin16_sample(void) 1.649 -+{ 1.650 -+ static struct ast_frame f = { 1.651 -+ .frametype = AST_FRAME_VOICE, 1.652 -+ .subclass = AST_FORMAT_G722, 1.653 -+ .datalen = sizeof(slin_g722_ex), 1.654 -+ .samples = sizeof(slin_g722_ex) * 2, 1.655 -+ .src = __PRETTY_FUNCTION__, 1.656 -+ .data = slin_g722_ex, 1.657 -+ }; 1.658 -+ 1.659 -+ return &f; 1.660 -+} 1.661 -+ 1.662 -+static struct ast_frame *lintog722_sample (void) 1.663 -+{ 1.664 -+ static struct ast_frame f = { 1.665 -+ .frametype = AST_FRAME_VOICE, 1.666 -+ .subclass = AST_FORMAT_SLINEAR, 1.667 -+ .datalen = sizeof(slin_g722_ex), 1.668 -+ .samples = sizeof(slin_g722_ex) / sizeof(slin_g722_ex[0]), 1.669 -+ .src = __PRETTY_FUNCTION__, 1.670 -+ .data = slin_g722_ex, 1.671 -+ }; 1.672 -+ 1.673 -+ return &f; 1.674 -+} 1.675 -+ 1.676 -+static struct ast_frame *lin16tog722_sample (void) 1.677 -+{ 1.678 -+ static struct ast_frame f = { 1.679 -+ .frametype = AST_FRAME_VOICE, 1.680 -+ .subclass = AST_FORMAT_SLINEAR16, 1.681 -+ .datalen = sizeof(slin_g722_ex), 1.682 -+ .samples = sizeof(slin_g722_ex) / sizeof(slin_g722_ex[0]), 1.683 -+ .src = __PRETTY_FUNCTION__, 1.684 -+ .data = slin_g722_ex, 1.685 -+ }; 1.686 -+ 1.687 -+ return &f; 1.688 -+} 1.689 -+ 1.690 -+static struct ast_translator g722tolin = { 1.691 -+ .name = "g722tolin", 1.692 -+ .srcfmt = AST_FORMAT_G722, 1.693 -+ .dstfmt = AST_FORMAT_SLINEAR, 1.694 -+ .newpvt = g722tolin_new, /* same for both directions */ 1.695 -+ .framein = g722tolin_framein, 1.696 -+ .sample = g722tolin_sample, 1.697 -+ .desc_size = sizeof(struct g722_decoder_pvt), 1.698 -+ .buffer_samples = BUFFER_SAMPLES / sizeof(int16_t), 1.699 -+ .buf_size = BUFFER_SAMPLES, 1.700 -+ .plc_samples = 160, 1.701 ++static struct ast_custom_function backticks_function = { 1.702 ++ .name = "BACKTICKS", 1.703 ++ .desc = "Executes a shell command and evaluates to the result.", 1.704 ++ .syntax = "BACKTICKS(<command>)", 1.705 ++ .synopsis = "Executes a shell command.", 1.706 ++ .read = function_backticks 1.707 +}; 1.708 + 1.709 -+static struct ast_translator lintog722 = { 1.710 -+ .name = "lintog722", 1.711 -+ .srcfmt = AST_FORMAT_SLINEAR, 1.712 -+ .dstfmt = AST_FORMAT_G722, 1.713 -+ .newpvt = lintog722_new, /* same for both directions */ 1.714 -+ .framein = lintog722_framein, 1.715 -+ .sample = lintog722_sample, 1.716 -+ .desc_size = sizeof(struct g722_encoder_pvt), 1.717 -+ .buffer_samples = BUFFER_SAMPLES * 2, 1.718 -+ .buf_size = BUFFER_SAMPLES, 1.719 -+}; 1.720 -+ 1.721 -+static struct ast_translator g722tolin16 = { 1.722 -+ .name = "g722tolin16", 1.723 -+ .srcfmt = AST_FORMAT_G722, 1.724 -+ .dstfmt = AST_FORMAT_SLINEAR16, 1.725 -+ .newpvt = g722tolin16_new, /* same for both directions */ 1.726 -+ .framein = g722tolin_framein, 1.727 -+ .sample = g722tolin16_sample, 1.728 -+ .desc_size = sizeof(struct g722_decoder_pvt), 1.729 -+ .buffer_samples = BUFFER_SAMPLES / sizeof(int16_t), 1.730 -+ .buf_size = BUFFER_SAMPLES, 1.731 -+ .plc_samples = 160, 1.732 -+}; 1.733 -+ 1.734 -+static struct ast_translator lin16tog722 = { 1.735 -+ .name = "lin16tog722", 1.736 -+ .srcfmt = AST_FORMAT_SLINEAR16, 1.737 -+ .dstfmt = AST_FORMAT_G722, 1.738 -+ .newpvt = lin16tog722_new, /* same for both directions */ 1.739 -+ .framein = lintog722_framein, 1.740 -+ .sample = lin16tog722_sample, 1.741 -+ .desc_size = sizeof(struct g722_encoder_pvt), 1.742 -+ .buffer_samples = BUFFER_SAMPLES * 2, 1.743 -+ .buf_size = BUFFER_SAMPLES, 1.744 -+}; 1.745 -+ 1.746 -+static int parse_config(int reload) 1.747 -+{ 1.748 -+ struct ast_variable *var; 1.749 -+ struct ast_config *cfg = ast_config_load("codecs.conf"); 1.750 -+ 1.751 -+ if (cfg == NULL) 1.752 -+ return 0; 1.753 -+ if (cfg == CONFIG_STATUS_FILEUNCHANGED) 1.754 -+ return 0; 1.755 -+ for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { 1.756 -+ if (!strcasecmp(var->name, "genericplc")) { 1.757 -+ g722tolin.useplc = ast_true(var->value) ? 1 : 0; 1.758 -+ if (option_verbose > 2) 1.759 -+ ast_verbose(VERBOSE_PREFIX_3 "codec_g722: %susing generic PLC\n", 1.760 -+ g722tolin.useplc ? "" : "not "); 1.761 -+ } 1.762 -+ } 1.763 -+ ast_config_destroy(cfg); 1.764 -+ return 0; 1.765 -+} 1.766 -+ 1.767 -+static int reload(void) 1.768 -+{ 1.769 -+ if (parse_config(1)) 1.770 -+ return AST_MODULE_LOAD_DECLINE; 1.771 -+ return AST_MODULE_LOAD_SUCCESS; 1.772 -+} 1.773 -+ 1.774 +static int unload_module(void) 1.775 +{ 1.776 -+ int res = 0; 1.777 -+ 1.778 -+ res |= ast_unregister_translator(&g722tolin); 1.779 -+ res |= ast_unregister_translator(&lintog722); 1.780 -+ res |= ast_unregister_translator(&g722tolin16); 1.781 -+ res |= ast_unregister_translator(&lin16tog722); 1.782 -+ 1.783 -+ return res; 1.784 ++ ast_custom_function_unregister(&backticks_function); 1.785 ++ return ast_unregister_application(app); 1.786 +} 1.787 + 1.788 +static int load_module(void) 1.789 +{ 1.790 -+ int res = 0; 1.791 -+ 1.792 -+ if (parse_config(0)) 1.793 -+ return AST_MODULE_LOAD_DECLINE; 1.794 -+ 1.795 -+ res |= ast_register_translator(&g722tolin); 1.796 -+ res |= ast_register_translator(&lintog722); 1.797 -+ res |= ast_register_translator(&g722tolin16); 1.798 -+ res |= ast_register_translator(&lin16tog722); 1.799 -+ 1.800 -+ if (res) { 1.801 -+ unload_module(); 1.802 -+ return AST_MODULE_LOAD_FAILURE; 1.803 -+ } 1.804 -+ 1.805 -+ return AST_MODULE_LOAD_SUCCESS; 1.806 ++ ast_custom_function_register(&backticks_function); 1.807 ++ return ast_register_application(app, backticks_exec, synopsis, desc); 1.808 +} 1.809 + 1.810 -+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ITU G.722-64kbps G722 Transcoder", 1.811 -+ .load = load_module, 1.812 -+ .unload = unload_module, 1.813 -+ .reload = reload, 1.814 -+ ); 1.815 -Index: codecs/g722/g722_decode.c 1.816 -diff -Nau codecs/g722/g722_decode.c.orig codecs/g722/g722_decode.c 1.817 ---- codecs/g722/g722_decode.c.orig 1970-01-01 01:00:00.000000000 +0100 1.818 -+++ codecs/g722/g722_decode.c 2009-04-24 00:30:33.000000000 +0200 1.819 -@@ -0,0 +1,398 @@ 1.820 -+/* 1.821 -+ * SpanDSP - a series of DSP components for telephony 1.822 -+ * 1.823 -+ * g722_decode.c - The ITU G.722 codec, decode part. 1.824 -+ * 1.825 -+ * Written by Steve Underwood <steveu@coppice.org> 1.826 -+ * 1.827 -+ * Copyright (C) 2005 Steve Underwood 1.828 -+ * 1.829 -+ * Despite my general liking of the GPL, I place my own contributions 1.830 -+ * to this code in the public domain for the benefit of all mankind - 1.831 -+ * even the slimy ones who might try to proprietize my work and use it 1.832 -+ * to my detriment. 1.833 -+ * 1.834 -+ * Based in part on a single channel G.722 codec which is: 1.835 -+ * 1.836 -+ * Copyright (c) CMU 1993 1.837 -+ * Computer Science, Speech Group 1.838 -+ * Chengxiang Lu and Alex Hauptmann 1.839 -+ * 1.840 -+ * $Id: g722_decode.c 48661 2006-12-21 00:08:21Z mattf $ 1.841 -+ */ 1.842 ++AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "BACKTICKS() dialplan function"); 1.843 + 1.844 -+/*! \file */ 1.845 +Index: apps/app_meetme.c 1.846 +--- apps/app_meetme.c.orig 2010-06-23 23:15:53.000000000 +0200 1.847 ++++ apps/app_meetme.c 2010-07-24 11:12:31.000000000 +0200 1.848 +@@ -522,6 +522,7 @@ 1.849 + CONFFLAG_DURATION_LIMIT = (1 << 30), 1.850 + /*! Do not write any audio to this channel until the state is up. */ 1.851 + CONFFLAG_NO_AUDIO_UNTIL_UP = (1 << 31), 1.852 ++ CONFFLAG_USERNAME = (1 << 31), 1.853 + }; 1.854 + 1.855 + enum { 1.856 +@@ -531,6 +532,7 @@ 1.857 + OPT_ARG_DURATION_LIMIT = 3, 1.858 + OPT_ARG_MOH_CLASS = 4, 1.859 + OPT_ARG_ARRAY_SIZE = 5, 1.860 ++ OPT_ARG_USERNAME = 6, 1.861 + }; 1.862 + 1.863 + AST_APP_OPTIONS(meetme_opts, BEGIN_OPTIONS 1.864 +@@ -563,6 +565,7 @@ 1.865 + AST_APP_OPTION('1', CONFFLAG_NOONLYPERSON ), 1.866 + AST_APP_OPTION_ARG('S', CONFFLAG_DURATION_STOP, OPT_ARG_DURATION_STOP), 1.867 + AST_APP_OPTION_ARG('L', CONFFLAG_DURATION_LIMIT, OPT_ARG_DURATION_LIMIT), 1.868 ++ AST_APP_OPTION_ARG('n', CONFFLAG_USERNAME, OPT_ARG_USERNAME), 1.869 + END_OPTIONS ); 1.870 + 1.871 + static const char *app = "MeetMe"; 1.872 +@@ -2243,6 +2246,12 @@ 1.873 + if (!(confflags & CONFFLAG_QUIET) && ((confflags & CONFFLAG_INTROUSER) || (confflags & CONFFLAG_INTROUSERNOREVIEW))) { 1.874 + char destdir[PATH_MAX]; 1.875 + 1.876 ++ if ( (confflags & CONFFLAG_USERNAME) 1.877 ++ && !ast_strlen_zero(optargs[OPT_ARG_USERNAME]) 1.878 ++ && ast_fileexists(optargs[OPT_ARG_USERNAME], NULL, NULL)) 1.879 ++ snprintf(destdir, sizeof(destdir), "%s", optargs[OPT_ARG_USERNAME]); 1.880 ++ else { 1.881 + 1.882 -+#ifdef HAVE_CONFIG_H 1.883 -+#include <config.h> 1.884 + snprintf(destdir, sizeof(destdir), "%s/meetme", ast_config_AST_SPOOL_DIR); 1.885 + 1.886 + if (ast_mkdir(destdir, 0777) != 0) { 1.887 +@@ -2259,6 +2268,7 @@ 1.888 + res = ast_record_review(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, NULL); 1.889 + if (res == -1) 1.890 + goto outrun; 1.891 ++ } 1.892 + } 1.893 + 1.894 + ast_mutex_lock(&conf->playlock); 1.895 +Index: build_tools/make_defaults_h 1.896 +--- build_tools/make_defaults_h.orig 2008-01-24 23:58:10.000000000 +0100 1.897 ++++ build_tools/make_defaults_h 2010-07-24 11:12:31.000000000 +0200 1.898 +@@ -17,7 +17,7 @@ 1.899 + #define DEFAULT_PID "${INSTALL_PATH}${ASTVARRUNDIR}/asterisk.pid" 1.900 + 1.901 + #define DEFAULT_VAR_DIR "${INSTALL_PATH}${ASTVARLIBDIR}" 1.902 +-#define DEFAULT_DB "${INSTALL_PATH}${ASTDBDIR}/astdb" 1.903 ++#define DEFAULT_DB "${INSTALL_PATH}${ASTDBDIR}/asterisk.db" 1.904 + 1.905 + #define DEFAULT_DATA_DIR "${INSTALL_PATH}${ASTDATADIR}" 1.906 + #define DEFAULT_KEY_DIR "${INSTALL_PATH}${ASTDATADIR}/keys" 1.907 +Index: cdr/cdr_custom.c 1.908 +--- cdr/cdr_custom.c.orig 2008-11-20 18:48:58.000000000 +0100 1.909 ++++ cdr/cdr_custom.c 2010-07-24 11:12:31.000000000 +0200 1.910 +@@ -83,7 +83,7 @@ 1.911 + ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno); 1.912 + ast_copy_string(format, var->value, sizeof(format) - 1); 1.913 + strcat(format,"\n"); 1.914 +- snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name); 1.915 ++ snprintf(master, sizeof(master),"%s/cdr/%s", ast_config_AST_LOG_DIR, var->name); 1.916 + if (var->next) { 1.917 + ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno); 1.918 + break; 1.919 +Index: cdr/cdr_sqlite3_custom.c 1.920 +--- cdr/cdr_sqlite3_custom.c.orig 2010-04-13 18:38:41.000000000 +0200 1.921 ++++ cdr/cdr_sqlite3_custom.c 2010-07-24 11:12:31.000000000 +0200 1.922 +@@ -300,7 +300,7 @@ 1.923 + } 1.924 + 1.925 + /* is the database there? */ 1.926 +- snprintf(filename, sizeof(filename), "%s/master.db", ast_config_AST_LOG_DIR); 1.927 ++ snprintf(filename, sizeof(filename), "%s/cdr/master.db", ast_config_AST_LOG_DIR); 1.928 + res = sqlite3_open(filename, &db); 1.929 + if (res != SQLITE_OK) { 1.930 + ast_log(LOG_ERROR, "Could not open database %s.\n", filename); 1.931 +Index: chan_capi-1.1.5/Makefile 1.932 +--- chan_capi-1.1.5/Makefile.orig 2010-04-06 19:33:25.000000000 +0200 1.933 ++++ chan_capi-1.1.5/Makefile 2010-07-24 11:12:31.000000000 +0200 1.934 +@@ -100,6 +100,9 @@ 1.935 + CFLAGS+=-O2 1.936 + CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) 1.937 + CFLAGS+=$(shell if uname -m | grep -q "ppc\|arm\|s390"; then echo "-fsigned-char"; fi) 1.938 ++ifeq (${USE_OWN_LIBCAPI},yes) 1.939 ++CFLAGS+=-DUSE_OWN_LIBCAPI 1.940 ++endif 1.941 + 1.942 + LIBS=-ldl -lpthread -lm 1.943 + CC=gcc 1.944 +Index: chan_capi-1.1.5/chan_capi20.h 1.945 +--- chan_capi-1.1.5/chan_capi20.h.orig 2005-09-20 20:33:40.000000000 +0200 1.946 ++++ chan_capi-1.1.5/chan_capi20.h 2010-07-24 11:12:31.000000000 +0200 1.947 +@@ -8,6 +8,8 @@ 1.948 + 1.949 + #undef CAPI_OS_HINT 1.950 + 1.951 ++#ifndef USE_OWN_LIBCAPI 1.952 ++ 1.953 + #if (defined(__FreeBSD__) || defined(__OpenBSD__) || \ 1.954 + defined(__NetBSD__) || defined(__APPLE__)) 1.955 + 1.956 +@@ -29,6 +31,8 @@ 1.957 + #include <capiutils.h> 1.958 + #endif /* BSD */ 1.959 + 1.960 +#endif 1.961 + 1.962 -+#include <stdio.h> 1.963 -+#include <inttypes.h> 1.964 -+#include <memory.h> 1.965 -+#include <stdlib.h> 1.966 + #ifndef HEADER_CID 1.967 + #define HEADER_CID(x) ((x)->adr.adrNCCI) 1.968 + #endif 1.969 +Index: chan_capi-1.1.5/chan_capi_utils.c 1.970 +--- chan_capi-1.1.5/chan_capi_utils.c.orig 2010-04-06 19:33:25.000000000 +0200 1.971 ++++ chan_capi-1.1.5/chan_capi_utils.c 2010-07-24 11:12:31.000000000 +0200 1.972 +@@ -1087,6 +1087,9 @@ 1.973 + { 1.974 + MESSAGE_EXCHANGE_ERROR error; 1.975 + int waitcount = 50; 1.976 ++#ifndef CAPI_MANUFACTURER_LEN 1.977 ++#define CAPI_MANUFACTURER_LEN 64 1.978 ++#endif 1.979 + unsigned char manbuf[CAPI_MANUFACTURER_LEN]; 1.980 + _cmsg CMSG; 1.981 + 1.982 +Index: chan_capi-1.1.5/libcapi20/capi20.c 1.983 +--- chan_capi-1.1.5/libcapi20/capi20.c.orig 2010-04-06 19:33:25.000000000 +0200 1.984 ++++ chan_capi-1.1.5/libcapi20/capi20.c 2010-07-24 11:12:31.000000000 +0200 1.985 +@@ -19,8 +19,10 @@ 1.986 + #include <stdio.h> 1.987 + #include <ctype.h> 1.988 + #include <assert.h> 1.989 ++#ifdef __linux__ 1.990 + #define _LINUX_LIST_H 1.991 + #include <linux/capi.h> 1.992 ++#endif 1.993 + 1.994 + #include <sys/socket.h> 1.995 + #include <netinet/in.h> 1.996 +@@ -48,17 +50,23 @@ 1.997 + 1.998 + #define SEND_BUFSIZ (128+2048) 1.999 + 1.1000 +#if 0 1.1001 -+#include <tgmath.h> 1.1002 + static char capidevname[] = "/dev/capi20"; 1.1003 + static char capidevnamenew[] = "/dev/isdn/capi20"; 1.1004 ++#endif 1.1005 + 1.1006 + static int capi_fd = -1; 1.1007 ++#if 0 1.1008 + static capi_ioctl_struct ioctl_data; 1.1009 ++#endif 1.1010 + 1.1011 + static int remote_capi; 1.1012 ++#if 0 1.1013 + static char *globalconfigfilename = "/etc/capi20.conf"; 1.1014 + static char *userconfigfilename = ".capi20rc"; 1.1015 + static unsigned short int port; 1.1016 + static char hostname[1024]; 1.1017 ++#endif 1.1018 + static int tracelevel; 1.1019 + static char *tracefile; 1.1020 + 1.1021 +@@ -77,17 +85,21 @@ 1.1022 + #define RCAPI_AUTH_USER_REQ CAPICMD(0xff, 0x00) 1.1023 + #define RCAPI_AUTH_USER_CONF CAPICMD(0xff, 0x01) 1.1024 + 1.1025 ++#if 0 1.1026 + static char *skip_whitespace(char *s) 1.1027 + { 1.1028 + while (*s && isspace(*s)) s++; 1.1029 + return s; 1.1030 + } 1.1031 ++#endif 1.1032 + 1.1033 ++#if 0 1.1034 + static char *skip_nonwhitespace(char *s) 1.1035 + { 1.1036 + while (*s && !isspace(*s)) s++; 1.1037 + return s; 1.1038 + } 1.1039 ++#endif 1.1040 + 1.1041 + static unsigned char get_byte(unsigned char **p) 1.1042 + { 1.1043 +@@ -95,10 +107,12 @@ 1.1044 + return((unsigned char)*(*p - 1)); 1.1045 + } 1.1046 + 1.1047 ++#if 0 1.1048 + static unsigned short get_word(unsigned char **p) 1.1049 + { 1.1050 + return(get_byte(p) | (get_byte(p) << 8)); 1.1051 + } 1.1052 ++#endif 1.1053 + 1.1054 + static unsigned short get_netword(unsigned char **p) 1.1055 + { 1.1056 +@@ -144,6 +158,7 @@ 1.1057 + * read config file 1.1058 + */ 1.1059 + 1.1060 ++#if 0 1.1061 + static int read_config(void) 1.1062 + { 1.1063 + FILE *fp = NULL; 1.1064 +@@ -197,11 +212,13 @@ 1.1065 + fclose(fp); 1.1066 + return(1); 1.1067 + } 1.1068 ++#endif 1.1069 + 1.1070 + /* 1.1071 + * socket function 1.1072 + */ 1.1073 + 1.1074 ++#if 0 1.1075 + static int open_socket(void) 1.1076 + { 1.1077 + int fd; 1.1078 +@@ -225,6 +242,7 @@ 1.1079 + close(fd); 1.1080 + return(-1); 1.1081 + } 1.1082 ++#endif 1.1083 + 1.1084 + static int socket_read(int fd, unsigned char *buf, int l) 1.1085 + { 1.1086 +@@ -328,6 +346,8 @@ 1.1087 + if (likely(capi_fd >= 0)) 1.1088 + return CapiNoError; 1.1089 + 1.1090 ++#if 0 1.1091 ++ 1.1092 + /*----- open managment link -----*/ 1.1093 + if (read_config() && (remote_capi)) { 1.1094 + capi_fd = open_socket(); 1.1095 +@@ -347,6 +367,8 @@ 1.1096 + if (ioctl(capi_fd, CAPI_INSTALLED, 0) == 0) 1.1097 + return CapiNoError; 1.1098 + 1.1099 +#endif 1.1100 + 1.1101 -+#include "g722.h" 1.1102 -+ 1.1103 -+#if !defined(FALSE) 1.1104 -+#define FALSE 0 1.1105 + return CapiRegNotInstalled; 1.1106 + } 1.1107 + 1.1108 +@@ -421,6 +443,7 @@ 1.1109 + unsigned char *bufferstart; 1.1110 + }; 1.1111 + 1.1112 ++#if 0 1.1113 + static struct applinfo *alloc_buffers( 1.1114 + unsigned MaxB3Connection, 1.1115 + unsigned MaxB3Blks, 1.1116 +@@ -459,6 +482,7 @@ 1.1117 + ap->lastfree->next = 0; 1.1118 + return ap; 1.1119 + } 1.1120 +#endif 1.1121 -+#if !defined(TRUE) 1.1122 -+#define TRUE (!FALSE) 1.1123 + 1.1124 + static void free_buffers(struct applinfo *ap) 1.1125 + { 1.1126 +@@ -576,14 +600,17 @@ 1.1127 + unsigned MaxSizeB3, 1.1128 + unsigned *ApplID) 1.1129 + { 1.1130 ++#if 0 1.1131 + int applid = 0; 1.1132 + char buf[PATH_MAX]; 1.1133 + int i, fd = -1; 1.1134 + 1.1135 + *ApplID = 0; 1.1136 ++#endif 1.1137 + 1.1138 + if (capi20_isinstalled() != CapiNoError) 1.1139 + return CapiRegNotInstalled; 1.1140 ++#if 0 1.1141 + if ((!remote_capi) || ((remote_capi) && ((fd = open_socket()) < 0))) { 1.1142 + if ((fd = open(capidevname, O_RDWR|O_NONBLOCK, 0666)) < 0 && 1.1143 + (errno == ENOENT)) { 1.1144 +@@ -621,6 +648,8 @@ 1.1145 + close(fd); 1.1146 + return(errcode); 1.1147 + } 1.1148 ++ } 1.1149 ++#if 0 1.1150 + } else if ((applid = ioctl(fd, CAPI_REGISTER, &ioctl_data)) < 0) { 1.1151 + if (errno == EIO) { 1.1152 + if (ioctl(fd, CAPI_GET_ERRCODE, &ioctl_data) < 0) { 1.1153 +@@ -666,6 +695,7 @@ 1.1154 + applid = alloc_applid(fd); 1.1155 + } // end old driver compatibility 1.1156 + } 1.1157 ++#endif 1.1158 + if (remember_applid(applid, fd) < 0) { 1.1159 + close(fd); 1.1160 + return CapiRegOSResourceErr; 1.1161 +@@ -676,6 +706,7 @@ 1.1162 + return CapiRegOSResourceErr; 1.1163 + } 1.1164 + *ApplID = applid; 1.1165 ++#endif 1.1166 + return CapiNoError; 1.1167 + } 1.1168 + 1.1169 +@@ -784,11 +815,15 @@ 1.1170 + ret = CapiIllAppNr; 1.1171 + break; 1.1172 + case EIO: 1.1173 ++#if 0 1.1174 + if (ioctl(fd, CAPI_GET_ERRCODE, &ioctl_data) < 0) { 1.1175 ++#endif 1.1176 + ret = CapiMsgOSResourceErr; 1.1177 ++#if 0 1.1178 + } else { 1.1179 + ret = (unsigned)ioctl_data.errcode; 1.1180 + } 1.1181 ++#endif 1.1182 + break; 1.1183 + default: 1.1184 + ret = CapiMsgOSResourceErr; 1.1185 +@@ -842,7 +877,7 @@ 1.1186 + rcvbuf[15] = (data >> 24) & 0xff; 1.1187 + } else { 1.1188 + u_int64_t data; 1.1189 +- ulong radr = (ulong)rcvbuf; 1.1190 ++ unsigned long radr = (unsigned long)rcvbuf; 1.1191 + if (CAPIMSG_LEN(rcvbuf) < 30) { 1.1192 + /* 1.1193 + * grr, 64bit arch, but no data64 included, 1.1194 +@@ -899,6 +934,9 @@ 1.1195 + { 1.1196 + if (capi20_isinstalled() != CapiNoError) 1.1197 + return 0; 1.1198 ++#ifndef CAPI_MANUFACTURER_LEN 1.1199 ++#define CAPI_MANUFACTURER_LEN 64 1.1200 ++#endif 1.1201 + 1.1202 + if (remote_capi) { 1.1203 + unsigned char buf[100]; 1.1204 +@@ -911,15 +949,19 @@ 1.1205 + return Buf; 1.1206 + } 1.1207 + 1.1208 ++#if 0 1.1209 + ioctl_data.contr = Ctrl; 1.1210 + 1.1211 + if (ioctl(capi_fd, CAPI_GET_MANUFACTURER, &ioctl_data) < 0) 1.1212 ++#endif 1.1213 + return 0; 1.1214 + 1.1215 ++#if 0 1.1216 + memcpy(Buf, ioctl_data.manufacturer, CAPI_MANUFACTURER_LEN); 1.1217 + Buf[CAPI_MANUFACTURER_LEN-1] = 0; 1.1218 + 1.1219 + return Buf; 1.1220 ++#endif 1.1221 + } 1.1222 + 1.1223 + unsigned char * 1.1224 +@@ -934,16 +976,20 @@ 1.1225 + set_rcapicmd_header(&p, 14, RCAPI_GET_VERSION_REQ, Ctrl); 1.1226 + if(!(remote_command(capi_fd, buf, 14, RCAPI_GET_VERSION_CONF))) 1.1227 + return 0; 1.1228 +- memcpy(Buf, buf + 1, sizeof(capi_version)); 1.1229 ++ memcpy(Buf, buf + 1, 128 /* sizeof(capi_version) */); 1.1230 + return Buf; 1.1231 + } 1.1232 + 1.1233 ++#if 0 1.1234 + ioctl_data.contr = Ctrl; 1.1235 + if (ioctl(capi_fd, CAPI_GET_VERSION, &ioctl_data) < 0) { 1.1236 ++#endif 1.1237 + return 0; 1.1238 ++#if 0 1.1239 + } 1.1240 + memcpy(Buf, &ioctl_data.version, sizeof(capi_version)); 1.1241 + return Buf; 1.1242 ++#endif 1.1243 + } 1.1244 + 1.1245 + unsigned char * 1.1246 +@@ -952,6 +998,10 @@ 1.1247 + if (capi20_isinstalled() != CapiNoError) 1.1248 + return 0; 1.1249 + 1.1250 ++#ifndef CAPI_SERIAL_LEN 1.1251 ++#define CAPI_SERIAL_LEN 8 1.1252 +#endif 1.1253 + 1.1254 -+static __inline__ int16_t saturate(int32_t amp) 1.1255 -+{ 1.1256 -+ int16_t amp16; 1.1257 -+ 1.1258 -+ /* Hopefully this is optimised for the common case - not clipping */ 1.1259 -+ amp16 = (int16_t) amp; 1.1260 -+ if (amp == amp16) 1.1261 -+ return amp16; 1.1262 -+ if (amp > INT16_MAX) 1.1263 -+ return INT16_MAX; 1.1264 -+ return INT16_MIN; 1.1265 -+} 1.1266 -+/*- End of function --------------------------------------------------------*/ 1.1267 -+ 1.1268 -+static void block4(g722_decode_state_t *s, int band, int d); 1.1269 -+ 1.1270 -+static void block4(g722_decode_state_t *s, int band, int d) 1.1271 -+{ 1.1272 -+ int wd1; 1.1273 -+ int wd2; 1.1274 -+ int wd3; 1.1275 -+ int i; 1.1276 -+ 1.1277 -+ /* Block 4, RECONS */ 1.1278 -+ s->band[band].d[0] = d; 1.1279 -+ s->band[band].r[0] = saturate(s->band[band].s + d); 1.1280 -+ 1.1281 -+ /* Block 4, PARREC */ 1.1282 -+ s->band[band].p[0] = saturate(s->band[band].sz + d); 1.1283 -+ 1.1284 -+ /* Block 4, UPPOL2 */ 1.1285 -+ for (i = 0; i < 3; i++) 1.1286 -+ s->band[band].sg[i] = s->band[band].p[i] >> 15; 1.1287 -+ wd1 = saturate(s->band[band].a[1] << 2); 1.1288 -+ 1.1289 -+ wd2 = (s->band[band].sg[0] == s->band[band].sg[1]) ? -wd1 : wd1; 1.1290 -+ if (wd2 > 32767) 1.1291 -+ wd2 = 32767; 1.1292 -+ wd3 = (s->band[band].sg[0] == s->band[band].sg[2]) ? 128 : -128; 1.1293 -+ wd3 += (wd2 >> 7); 1.1294 -+ wd3 += (s->band[band].a[2]*32512) >> 15; 1.1295 -+ if (wd3 > 12288) 1.1296 -+ wd3 = 12288; 1.1297 -+ else if (wd3 < -12288) 1.1298 -+ wd3 = -12288; 1.1299 -+ s->band[band].ap[2] = wd3; 1.1300 -+ 1.1301 -+ /* Block 4, UPPOL1 */ 1.1302 -+ s->band[band].sg[0] = s->band[band].p[0] >> 15; 1.1303 -+ s->band[band].sg[1] = s->band[band].p[1] >> 15; 1.1304 -+ wd1 = (s->band[band].sg[0] == s->band[band].sg[1]) ? 192 : -192; 1.1305 -+ wd2 = (s->band[band].a[1]*32640) >> 15; 1.1306 -+ 1.1307 -+ s->band[band].ap[1] = saturate(wd1 + wd2); 1.1308 -+ wd3 = saturate(15360 - s->band[band].ap[2]); 1.1309 -+ if (s->band[band].ap[1] > wd3) 1.1310 -+ s->band[band].ap[1] = wd3; 1.1311 -+ else if (s->band[band].ap[1] < -wd3) 1.1312 -+ s->band[band].ap[1] = -wd3; 1.1313 -+ 1.1314 -+ /* Block 4, UPZERO */ 1.1315 -+ wd1 = (d == 0) ? 0 : 128; 1.1316 -+ s->band[band].sg[0] = d >> 15; 1.1317 -+ for (i = 1; i < 7; i++) 1.1318 -+ { 1.1319 -+ s->band[band].sg[i] = s->band[band].d[i] >> 15; 1.1320 -+ wd2 = (s->band[band].sg[i] == s->band[band].sg[0]) ? wd1 : -wd1; 1.1321 -+ wd3 = (s->band[band].b[i]*32640) >> 15; 1.1322 -+ s->band[band].bp[i] = saturate(wd2 + wd3); 1.1323 -+ } 1.1324 -+ 1.1325 -+ /* Block 4, DELAYA */ 1.1326 -+ for (i = 6; i > 0; i--) 1.1327 -+ { 1.1328 -+ s->band[band].d[i] = s->band[band].d[i - 1]; 1.1329 -+ s->band[band].b[i] = s->band[band].bp[i]; 1.1330 -+ } 1.1331 -+ 1.1332 -+ for (i = 2; i > 0; i--) 1.1333 -+ { 1.1334 -+ s->band[band].r[i] = s->band[band].r[i - 1]; 1.1335 -+ s->band[band].p[i] = s->band[band].p[i - 1]; 1.1336 -+ s->band[band].a[i] = s->band[band].ap[i]; 1.1337 -+ } 1.1338 -+ 1.1339 -+ /* Block 4, FILTEP */ 1.1340 -+ wd1 = saturate(s->band[band].r[1] + s->band[band].r[1]); 1.1341 -+ wd1 = (s->band[band].a[1]*wd1) >> 15; 1.1342 -+ wd2 = saturate(s->band[band].r[2] + s->band[band].r[2]); 1.1343 -+ wd2 = (s->band[band].a[2]*wd2) >> 15; 1.1344 -+ s->band[band].sp = saturate(wd1 + wd2); 1.1345 -+ 1.1346 -+ /* Block 4, FILTEZ */ 1.1347 -+ s->band[band].sz = 0; 1.1348 -+ for (i = 6; i > 0; i--) 1.1349 -+ { 1.1350 -+ wd1 = saturate(s->band[band].d[i] + s->band[band].d[i]); 1.1351 -+ s->band[band].sz += (s->band[band].b[i]*wd1) >> 15; 1.1352 -+ } 1.1353 -+ s->band[band].sz = saturate(s->band[band].sz); 1.1354 -+ 1.1355 -+ /* Block 4, PREDIC */ 1.1356 -+ s->band[band].s = saturate(s->band[band].sp + s->band[band].sz); 1.1357 -+} 1.1358 -+/*- End of function --------------------------------------------------------*/ 1.1359 -+ 1.1360 -+g722_decode_state_t *g722_decode_init(g722_decode_state_t *s, int rate, int options) 1.1361 -+{ 1.1362 -+ if (s == NULL) 1.1363 -+ { 1.1364 -+ if ((s = (g722_decode_state_t *) malloc(sizeof(*s))) == NULL) 1.1365 -+ return NULL; 1.1366 -+ } 1.1367 -+ memset(s, 0, sizeof(*s)); 1.1368 -+ if (rate == 48000) 1.1369 -+ s->bits_per_sample = 6; 1.1370 -+ else if (rate == 56000) 1.1371 -+ s->bits_per_sample = 7; 1.1372 -+ else 1.1373 -+ s->bits_per_sample = 8; 1.1374 -+ if ((options & G722_SAMPLE_RATE_8000)) 1.1375 -+ s->eight_k = TRUE; 1.1376 -+ if ((options & G722_PACKED) && s->bits_per_sample != 8) 1.1377 -+ s->packed = TRUE; 1.1378 -+ else 1.1379 -+ s->packed = FALSE; 1.1380 -+ s->band[0].det = 32; 1.1381 -+ s->band[1].det = 8; 1.1382 -+ return s; 1.1383 -+} 1.1384 -+/*- End of function --------------------------------------------------------*/ 1.1385 -+ 1.1386 -+int g722_decode_release(g722_decode_state_t *s) 1.1387 -+{ 1.1388 -+ free(s); 1.1389 -+ return 0; 1.1390 -+} 1.1391 -+/*- End of function --------------------------------------------------------*/ 1.1392 -+ 1.1393 -+int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len) 1.1394 -+{ 1.1395 -+ static const int wl[8] = {-60, -30, 58, 172, 334, 538, 1198, 3042 }; 1.1396 -+ static const int rl42[16] = {0, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 0 }; 1.1397 -+ static const int ilb[32] = 1.1398 -+ { 1.1399 -+ 2048, 2093, 2139, 2186, 2233, 2282, 2332, 1.1400 -+ 2383, 2435, 2489, 2543, 2599, 2656, 2714, 1.1401 -+ 2774, 2834, 2896, 2960, 3025, 3091, 3158, 1.1402 -+ 3228, 3298, 3371, 3444, 3520, 3597, 3676, 1.1403 -+ 3756, 3838, 3922, 4008 1.1404 -+ }; 1.1405 -+ static const int wh[3] = {0, -214, 798}; 1.1406 -+ static const int rh2[4] = {2, 1, 2, 1}; 1.1407 -+ static const int qm2[4] = {-7408, -1616, 7408, 1616}; 1.1408 -+ static const int qm4[16] = 1.1409 -+ { 1.1410 -+ 0, -20456, -12896, -8968, 1.1411 -+ -6288, -4240, -2584, -1200, 1.1412 -+ 20456, 12896, 8968, 6288, 1.1413 -+ 4240, 2584, 1200, 0 1.1414 -+ }; 1.1415 -+ static const int qm5[32] = 1.1416 -+ { 1.1417 -+ -280, -280, -23352, -17560, 1.1418 -+ -14120, -11664, -9752, -8184, 1.1419 -+ -6864, -5712, -4696, -3784, 1.1420 -+ -2960, -2208, -1520, -880, 1.1421 -+ 23352, 17560, 14120, 11664, 1.1422 -+ 9752, 8184, 6864, 5712, 1.1423 -+ 4696, 3784, 2960, 2208, 1.1424 -+ 1520, 880, 280, -280 1.1425 -+ }; 1.1426 -+ static const int qm6[64] = 1.1427 -+ { 1.1428 -+ -136, -136, -136, -136, 1.1429 -+ -24808, -21904, -19008, -16704, 1.1430 -+ -14984, -13512, -12280, -11192, 1.1431 -+ -10232, -9360, -8576, -7856, 1.1432 -+ -7192, -6576, -6000, -5456, 1.1433 -+ -4944, -4464, -4008, -3576, 1.1434 -+ -3168, -2776, -2400, -2032, 1.1435 -+ -1688, -1360, -1040, -728, 1.1436 -+ 24808, 21904, 19008, 16704, 1.1437 -+ 14984, 13512, 12280, 11192, 1.1438 -+ 10232, 9360, 8576, 7856, 1.1439 -+ 7192, 6576, 6000, 5456, 1.1440 -+ 4944, 4464, 4008, 3576, 1.1441 -+ 3168, 2776, 2400, 2032, 1.1442 -+ 1688, 1360, 1040, 728, 1.1443 -+ 432, 136, -432, -136 1.1444 -+ }; 1.1445 -+ static const int qmf_coeffs[12] = 1.1446 -+ { 1.1447 -+ 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11, 1.1448 -+ }; 1.1449 -+ 1.1450 -+ int dlowt; 1.1451 -+ int rlow; 1.1452 -+ int ihigh; 1.1453 -+ int dhigh; 1.1454 -+ int rhigh; 1.1455 -+ int xout1; 1.1456 -+ int xout2; 1.1457 -+ int wd1; 1.1458 -+ int wd2; 1.1459 -+ int wd3; 1.1460 -+ int code; 1.1461 -+ int outlen; 1.1462 -+ int i; 1.1463 -+ int j; 1.1464 -+ 1.1465 -+ outlen = 0; 1.1466 -+ rhigh = 0; 1.1467 -+ for (j = 0; j < len; ) 1.1468 -+ { 1.1469 -+ if (s->packed) 1.1470 -+ { 1.1471 -+ /* Unpack the code bits */ 1.1472 -+ if (s->in_bits < s->bits_per_sample) 1.1473 -+ { 1.1474 -+ s->in_buffer |= (g722_data[j++] << s->in_bits); 1.1475 -+ s->in_bits += 8; 1.1476 -+ } 1.1477 -+ code = s->in_buffer & ((1 << s->bits_per_sample) - 1); 1.1478 -+ s->in_buffer >>= s->bits_per_sample; 1.1479 -+ s->in_bits -= s->bits_per_sample; 1.1480 -+ } 1.1481 -+ else 1.1482 -+ { 1.1483 -+ code = g722_data[j++]; 1.1484 -+ } 1.1485 -+ 1.1486 -+ switch (s->bits_per_sample) 1.1487 -+ { 1.1488 -+ default: 1.1489 -+ case 8: 1.1490 -+ wd1 = code & 0x3F; 1.1491 -+ ihigh = (code >> 6) & 0x03; 1.1492 -+ wd2 = qm6[wd1]; 1.1493 -+ wd1 >>= 2; 1.1494 -+ break; 1.1495 -+ case 7: 1.1496 -+ wd1 = code & 0x1F; 1.1497 -+ ihigh = (code >> 5) & 0x03; 1.1498 -+ wd2 = qm5[wd1]; 1.1499 -+ wd1 >>= 1; 1.1500 -+ break; 1.1501 -+ case 6: 1.1502 -+ wd1 = code & 0x0F; 1.1503 -+ ihigh = (code >> 4) & 0x03; 1.1504 -+ wd2 = qm4[wd1]; 1.1505 -+ break; 1.1506 -+ } 1.1507 -+ /* Block 5L, LOW BAND INVQBL */ 1.1508 -+ wd2 = (s->band[0].det*wd2) >> 15; 1.1509 -+ /* Block 5L, RECONS */ 1.1510 -+ rlow = s->band[0].s + wd2; 1.1511 -+ /* Block 6L, LIMIT */ 1.1512 -+ if (rlow > 16383) 1.1513 -+ rlow = 16383; 1.1514 -+ else if (rlow < -16384) 1.1515 -+ rlow = -16384; 1.1516 -+ 1.1517 -+ /* Block 2L, INVQAL */ 1.1518 -+ wd2 = qm4[wd1]; 1.1519 -+ dlowt = (s->band[0].det*wd2) >> 15; 1.1520 -+ 1.1521 -+ /* Block 3L, LOGSCL */ 1.1522 -+ wd2 = rl42[wd1]; 1.1523 -+ wd1 = (s->band[0].nb*127) >> 7; 1.1524 -+ wd1 += wl[wd2]; 1.1525 -+ if (wd1 < 0) 1.1526 -+ wd1 = 0; 1.1527 -+ else if (wd1 > 18432) 1.1528 -+ wd1 = 18432; 1.1529 -+ s->band[0].nb = wd1; 1.1530 -+ 1.1531 -+ /* Block 3L, SCALEL */ 1.1532 -+ wd1 = (s->band[0].nb >> 6) & 31; 1.1533 -+ wd2 = 8 - (s->band[0].nb >> 11); 1.1534 -+ wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); 1.1535 -+ s->band[0].det = wd3 << 2; 1.1536 -+ 1.1537 -+ block4(s, 0, dlowt); 1.1538 -+ 1.1539 -+ if (!s->eight_k) 1.1540 -+ { 1.1541 -+ /* Block 2H, INVQAH */ 1.1542 -+ wd2 = qm2[ihigh]; 1.1543 -+ dhigh = (s->band[1].det*wd2) >> 15; 1.1544 -+ /* Block 5H, RECONS */ 1.1545 -+ rhigh = dhigh + s->band[1].s; 1.1546 -+ /* Block 6H, LIMIT */ 1.1547 -+ if (rhigh > 16383) 1.1548 -+ rhigh = 16383; 1.1549 -+ else if (rhigh < -16384) 1.1550 -+ rhigh = -16384; 1.1551 -+ 1.1552 -+ /* Block 2H, INVQAH */ 1.1553 -+ wd2 = rh2[ihigh]; 1.1554 -+ wd1 = (s->band[1].nb*127) >> 7; 1.1555 -+ wd1 += wh[wd2]; 1.1556 -+ if (wd1 < 0) 1.1557 -+ wd1 = 0; 1.1558 -+ else if (wd1 > 22528) 1.1559 -+ wd1 = 22528; 1.1560 -+ s->band[1].nb = wd1; 1.1561 -+ 1.1562 -+ /* Block 3H, SCALEH */ 1.1563 -+ wd1 = (s->band[1].nb >> 6) & 31; 1.1564 -+ wd2 = 10 - (s->band[1].nb >> 11); 1.1565 -+ wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); 1.1566 -+ s->band[1].det = wd3 << 2; 1.1567 -+ 1.1568 -+ block4(s, 1, dhigh); 1.1569 -+ } 1.1570 -+ 1.1571 -+ if (s->itu_test_mode) 1.1572 -+ { 1.1573 -+ amp[outlen++] = (int16_t) (rlow << 1); 1.1574 -+ amp[outlen++] = (int16_t) (rhigh << 1); 1.1575 -+ } 1.1576 -+ else 1.1577 -+ { 1.1578 -+ if (s->eight_k) 1.1579 -+ { 1.1580 -+ amp[outlen++] = (int16_t) rlow; 1.1581 -+ } 1.1582 -+ else 1.1583 -+ { 1.1584 -+ /* Apply the receive QMF */ 1.1585 -+ for (i = 0; i < 22; i++) 1.1586 -+ s->x[i] = s->x[i + 2]; 1.1587 -+ s->x[22] = rlow + rhigh; 1.1588 -+ s->x[23] = rlow - rhigh; 1.1589 -+ 1.1590 -+ xout1 = 0; 1.1591 -+ xout2 = 0; 1.1592 -+ for (i = 0; i < 12; i++) 1.1593 -+ { 1.1594 -+ xout2 += s->x[2*i]*qmf_coeffs[i]; 1.1595 -+ xout1 += s->x[2*i + 1]*qmf_coeffs[11 - i]; 1.1596 -+ } 1.1597 -+ amp[outlen++] = (int16_t) (xout1 >> 12); 1.1598 -+ amp[outlen++] = (int16_t) (xout2 >> 12); 1.1599 -+ } 1.1600 -+ } 1.1601 -+ } 1.1602 -+ return outlen; 1.1603 -+} 1.1604 -+/*- End of function --------------------------------------------------------*/ 1.1605 -+/*- End of file ------------------------------------------------------------*/ 1.1606 -Index: codecs/g722/g722_encode.c 1.1607 -diff -Nau codecs/g722/g722_encode.c.orig codecs/g722/g722_encode.c 1.1608 ---- codecs/g722/g722_encode.c.orig 1970-01-01 01:00:00.000000000 +0100 1.1609 -+++ codecs/g722/g722_encode.c 2009-04-24 00:30:33.000000000 +0200 1.1610 -@@ -0,0 +1,400 @@ 1.1611 -+/* 1.1612 -+ * SpanDSP - a series of DSP components for telephony 1.1613 -+ * 1.1614 -+ * g722_encode.c - The ITU G.722 codec, encode part. 1.1615 -+ * 1.1616 -+ * Written by Steve Underwood <steveu@coppice.org> 1.1617 -+ * 1.1618 -+ * Copyright (C) 2005 Steve Underwood 1.1619 -+ * 1.1620 -+ * All rights reserved. 1.1621 -+ * 1.1622 -+ * Despite my general liking of the GPL, I place my own contributions 1.1623 -+ * to this code in the public domain for the benefit of all mankind - 1.1624 -+ * even the slimy ones who might try to proprietize my work and use it 1.1625 -+ * to my detriment. 1.1626 -+ * 1.1627 -+ * Based on a single channel 64kbps only G.722 codec which is: 1.1628 -+ * 1.1629 -+ ***** Copyright (c) CMU 1993 ***** 1.1630 -+ * Computer Science, Speech Group 1.1631 -+ * Chengxiang Lu and Alex Hauptmann 1.1632 -+ * 1.1633 -+ * $Id: g722_encode.c 48661 2006-12-21 00:08:21Z mattf $ 1.1634 -+ */ 1.1635 -+ 1.1636 -+/*! \file */ 1.1637 -+ 1.1638 -+#ifdef HAVE_CONFIG_H 1.1639 -+#include <config.h> 1.1640 + if (remote_capi) { 1.1641 + unsigned char buf[100]; 1.1642 + unsigned char *p = buf; 1.1643 +@@ -963,15 +1013,19 @@ 1.1644 + return Buf; 1.1645 + } 1.1646 + 1.1647 ++#if 0 1.1648 + ioctl_data.contr = Ctrl; 1.1649 + 1.1650 + if (ioctl(capi_fd, CAPI_GET_SERIAL, &ioctl_data) < 0) 1.1651 +#endif 1.1652 -+ 1.1653 -+#include <stdio.h> 1.1654 -+#include <inttypes.h> 1.1655 -+#include <memory.h> 1.1656 -+#include <stdlib.h> 1.1657 + return 0; 1.1658 + 1.1659 +#if 0 1.1660 -+#include <tgmath.h> 1.1661 + memcpy(Buf, &ioctl_data.serial, CAPI_SERIAL_LEN); 1.1662 + Buf[CAPI_SERIAL_LEN-1] = 0; 1.1663 + 1.1664 + return Buf; 1.1665 +#endif 1.1666 -+ 1.1667 -+#include "g722.h" 1.1668 -+ 1.1669 -+#if !defined(FALSE) 1.1670 -+#define FALSE 0 1.1671 -+#endif 1.1672 -+#if !defined(TRUE) 1.1673 -+#define TRUE (!FALSE) 1.1674 -+#endif 1.1675 -+ 1.1676 -+static __inline__ int16_t saturate(int32_t amp) 1.1677 -+{ 1.1678 -+ int16_t amp16; 1.1679 -+ 1.1680 -+ /* Hopefully this is optimised for the common case - not clipping */ 1.1681 -+ amp16 = (int16_t) amp; 1.1682 -+ if (amp == amp16) 1.1683 -+ return amp16; 1.1684 -+ if (amp > INT16_MAX) 1.1685 -+ return INT16_MAX; 1.1686 -+ return INT16_MIN; 1.1687 -+} 1.1688 -+/*- End of function --------------------------------------------------------*/ 1.1689 -+ 1.1690 -+static void block4(g722_encode_state_t *s, int band, int d) 1.1691 -+{ 1.1692 -+ int wd1; 1.1693 -+ int wd2; 1.1694 -+ int wd3; 1.1695 -+ int i; 1.1696 -+ 1.1697 -+ /* Block 4, RECONS */ 1.1698 -+ s->band[band].d[0] = d; 1.1699 -+ s->band[band].r[0] = saturate(s->band[band].s + d); 1.1700 -+ 1.1701 -+ /* Block 4, PARREC */ 1.1702 -+ s->band[band].p[0] = saturate(s->band[band].sz + d); 1.1703 -+ 1.1704 -+ /* Block 4, UPPOL2 */ 1.1705 -+ for (i = 0; i < 3; i++) 1.1706 -+ s->band[band].sg[i] = s->band[band].p[i] >> 15; 1.1707 -+ wd1 = saturate(s->band[band].a[1] << 2); 1.1708 -+ 1.1709 -+ wd2 = (s->band[band].sg[0] == s->band[band].sg[1]) ? -wd1 : wd1; 1.1710 -+ if (wd2 > 32767) 1.1711 -+ wd2 = 32767; 1.1712 -+ wd3 = (wd2 >> 7) + ((s->band[band].sg[0] == s->band[band].sg[2]) ? 128 : -128); 1.1713 -+ wd3 += (s->band[band].a[2]*32512) >> 15; 1.1714 -+ if (wd3 > 12288) 1.1715 -+ wd3 = 12288; 1.1716 -+ else if (wd3 < -12288) 1.1717 -+ wd3 = -12288; 1.1718 -+ s->band[band].ap[2] = wd3; 1.1719 -+ 1.1720 -+ /* Block 4, UPPOL1 */ 1.1721 -+ s->band[band].sg[0] = s->band[band].p[0] >> 15; 1.1722 -+ s->band[band].sg[1] = s->band[band].p[1] >> 15; 1.1723 -+ wd1 = (s->band[band].sg[0] == s->band[band].sg[1]) ? 192 : -192; 1.1724 -+ wd2 = (s->band[band].a[1]*32640) >> 15; 1.1725 -+ 1.1726 -+ s->band[band].ap[1] = saturate(wd1 + wd2); 1.1727 -+ wd3 = saturate(15360 - s->band[band].ap[2]); 1.1728 -+ if (s->band[band].ap[1] > wd3) 1.1729 -+ s->band[band].ap[1] = wd3; 1.1730 -+ else if (s->band[band].ap[1] < -wd3) 1.1731 -+ s->band[band].ap[1] = -wd3; 1.1732 -+ 1.1733 -+ /* Block 4, UPZERO */ 1.1734 -+ wd1 = (d == 0) ? 0 : 128; 1.1735 -+ s->band[band].sg[0] = d >> 15; 1.1736 -+ for (i = 1; i < 7; i++) 1.1737 -+ { 1.1738 -+ s->band[band].sg[i] = s->band[band].d[i] >> 15; 1.1739 -+ wd2 = (s->band[band].sg[i] == s->band[band].sg[0]) ? wd1 : -wd1; 1.1740 -+ wd3 = (s->band[band].b[i]*32640) >> 15; 1.1741 -+ s->band[band].bp[i] = saturate(wd2 + wd3); 1.1742 -+ } 1.1743 -+ 1.1744 -+ /* Block 4, DELAYA */ 1.1745 -+ for (i = 6; i > 0; i--) 1.1746 -+ { 1.1747 -+ s->band[band].d[i] = s->band[band].d[i - 1]; 1.1748 -+ s->band[band].b[i] = s->band[band].bp[i]; 1.1749 -+ } 1.1750 -+ 1.1751 -+ for (i = 2; i > 0; i--) 1.1752 -+ { 1.1753 -+ s->band[band].r[i] = s->band[band].r[i - 1]; 1.1754 -+ s->band[band].p[i] = s->band[band].p[i - 1]; 1.1755 -+ s->band[band].a[i] = s->band[band].ap[i]; 1.1756 -+ } 1.1757 -+ 1.1758 -+ /* Block 4, FILTEP */ 1.1759 -+ wd1 = saturate(s->band[band].r[1] + s->band[band].r[1]); 1.1760 -+ wd1 = (s->band[band].a[1]*wd1) >> 15; 1.1761 -+ wd2 = saturate(s->band[band].r[2] + s->band[band].r[2]); 1.1762 -+ wd2 = (s->band[band].a[2]*wd2) >> 15; 1.1763 -+ s->band[band].sp = saturate(wd1 + wd2); 1.1764 -+ 1.1765 -+ /* Block 4, FILTEZ */ 1.1766 -+ s->band[band].sz = 0; 1.1767 -+ for (i = 6; i > 0; i--) 1.1768 -+ { 1.1769 -+ wd1 = saturate(s->band[band].d[i] + s->band[band].d[i]); 1.1770 -+ s->band[band].sz += (s->band[band].b[i]*wd1) >> 15; 1.1771 -+ } 1.1772 -+ s->band[band].sz = saturate(s->band[band].sz); 1.1773 -+ 1.1774 -+ /* Block 4, PREDIC */ 1.1775 -+ s->band[band].s = saturate(s->band[band].sp + s->band[band].sz); 1.1776 -+} 1.1777 -+/*- End of function --------------------------------------------------------*/ 1.1778 -+ 1.1779 -+g722_encode_state_t *g722_encode_init(g722_encode_state_t *s, int rate, int options) 1.1780 -+{ 1.1781 -+ if (s == NULL) 1.1782 -+ { 1.1783 -+ if ((s = (g722_encode_state_t *) malloc(sizeof(*s))) == NULL) 1.1784 -+ return NULL; 1.1785 -+ } 1.1786 -+ memset(s, 0, sizeof(*s)); 1.1787 -+ if (rate == 48000) 1.1788 -+ s->bits_per_sample = 6; 1.1789 -+ else if (rate == 56000) 1.1790 -+ s->bits_per_sample = 7; 1.1791 -+ else 1.1792 -+ s->bits_per_sample = 8; 1.1793 -+ if ((options & G722_SAMPLE_RATE_8000)) 1.1794 -+ s->eight_k = TRUE; 1.1795 -+ if ((options & G722_PACKED) && s->bits_per_sample != 8) 1.1796 -+ s->packed = TRUE; 1.1797 -+ else 1.1798 -+ s->packed = FALSE; 1.1799 -+ s->band[0].det = 32; 1.1800 -+ s->band[1].det = 8; 1.1801 -+ return s; 1.1802 -+} 1.1803 -+/*- End of function --------------------------------------------------------*/ 1.1804 -+ 1.1805 -+int g722_encode_release(g722_encode_state_t *s) 1.1806 -+{ 1.1807 -+ free(s); 1.1808 -+ return 0; 1.1809 -+} 1.1810 -+/*- End of function --------------------------------------------------------*/ 1.1811 -+ 1.1812 -+int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len) 1.1813 -+{ 1.1814 -+ static const int q6[32] = 1.1815 -+ { 1.1816 -+ 0, 35, 72, 110, 150, 190, 233, 276, 1.1817 -+ 323, 370, 422, 473, 530, 587, 650, 714, 1.1818 -+ 786, 858, 940, 1023, 1121, 1219, 1339, 1458, 1.1819 -+ 1612, 1765, 1980, 2195, 2557, 2919, 0, 0 1.1820 -+ }; 1.1821 -+ static const int iln[32] = 1.1822 -+ { 1.1823 -+ 0, 63, 62, 31, 30, 29, 28, 27, 1.1824 -+ 26, 25, 24, 23, 22, 21, 20, 19, 1.1825 -+ 18, 17, 16, 15, 14, 13, 12, 11, 1.1826 -+ 10, 9, 8, 7, 6, 5, 4, 0 1.1827 -+ }; 1.1828 -+ static const int ilp[32] = 1.1829 -+ { 1.1830 -+ 0, 61, 60, 59, 58, 57, 56, 55, 1.1831 -+ 54, 53, 52, 51, 50, 49, 48, 47, 1.1832 -+ 46, 45, 44, 43, 42, 41, 40, 39, 1.1833 -+ 38, 37, 36, 35, 34, 33, 32, 0 1.1834 -+ }; 1.1835 -+ static const int wl[8] = 1.1836 -+ { 1.1837 -+ -60, -30, 58, 172, 334, 538, 1198, 3042 1.1838 -+ }; 1.1839 -+ static const int rl42[16] = 1.1840 -+ { 1.1841 -+ 0, 7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 0 1.1842 -+ }; 1.1843 -+ static const int ilb[32] = 1.1844 -+ { 1.1845 -+ 2048, 2093, 2139, 2186, 2233, 2282, 2332, 1.1846 -+ 2383, 2435, 2489, 2543, 2599, 2656, 2714, 1.1847 -+ 2774, 2834, 2896, 2960, 3025, 3091, 3158, 1.1848 -+ 3228, 3298, 3371, 3444, 3520, 3597, 3676, 1.1849 -+ 3756, 3838, 3922, 4008 1.1850 -+ }; 1.1851 -+ static const int qm4[16] = 1.1852 -+ { 1.1853 -+ 0, -20456, -12896, -8968, 1.1854 -+ -6288, -4240, -2584, -1200, 1.1855 -+ 20456, 12896, 8968, 6288, 1.1856 -+ 4240, 2584, 1200, 0 1.1857 -+ }; 1.1858 -+ static const int qm2[4] = 1.1859 -+ { 1.1860 -+ -7408, -1616, 7408, 1616 1.1861 -+ }; 1.1862 -+ static const int qmf_coeffs[12] = 1.1863 -+ { 1.1864 -+ 3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11, 1.1865 -+ }; 1.1866 -+ static const int ihn[3] = {0, 1, 0}; 1.1867 -+ static const int ihp[3] = {0, 3, 2}; 1.1868 -+ static const int wh[3] = {0, -214, 798}; 1.1869 -+ static const int rh2[4] = {2, 1, 2, 1}; 1.1870 -+ 1.1871 -+ int dlow; 1.1872 -+ int dhigh; 1.1873 -+ int el; 1.1874 -+ int wd; 1.1875 -+ int wd1; 1.1876 -+ int ril; 1.1877 -+ int wd2; 1.1878 -+ int il4; 1.1879 -+ int ih2; 1.1880 -+ int wd3; 1.1881 -+ int eh; 1.1882 -+ int mih; 1.1883 -+ int i; 1.1884 -+ int j; 1.1885 -+ /* Low and high band PCM from the QMF */ 1.1886 -+ int xlow; 1.1887 -+ int xhigh; 1.1888 -+ int g722_bytes; 1.1889 -+ /* Even and odd tap accumulators */ 1.1890 -+ int sumeven; 1.1891 -+ int sumodd; 1.1892 -+ int ihigh; 1.1893 -+ int ilow; 1.1894 -+ int code; 1.1895 -+ 1.1896 -+ g722_bytes = 0; 1.1897 -+ xhigh = 0; 1.1898 -+ for (j = 0; j < len; ) 1.1899 -+ { 1.1900 -+ if (s->itu_test_mode) 1.1901 -+ { 1.1902 -+ xlow = 1.1903 -+ xhigh = amp[j++] >> 1; 1.1904 -+ } 1.1905 -+ else 1.1906 -+ { 1.1907 -+ if (s->eight_k) 1.1908 -+ { 1.1909 -+ xlow = amp[j++]; 1.1910 -+ } 1.1911 -+ else 1.1912 -+ { 1.1913 -+ /* Apply the transmit QMF */ 1.1914 -+ /* Shuffle the buffer down */ 1.1915 -+ for (i = 0; i < 22; i++) 1.1916 -+ s->x[i] = s->x[i + 2]; 1.1917 -+ s->x[22] = amp[j++]; 1.1918 -+ s->x[23] = amp[j++]; 1.1919 -+ 1.1920 -+ /* Discard every other QMF output */ 1.1921 -+ sumeven = 0; 1.1922 -+ sumodd = 0; 1.1923 -+ for (i = 0; i < 12; i++) 1.1924 -+ { 1.1925 -+ sumodd += s->x[2*i]*qmf_coeffs[i]; 1.1926 -+ sumeven += s->x[2*i + 1]*qmf_coeffs[11 - i]; 1.1927 -+ } 1.1928 -+ xlow = (sumeven + sumodd) >> 13; 1.1929 -+ xhigh = (sumeven - sumodd) >> 13; 1.1930 -+ } 1.1931 -+ } 1.1932 -+ /* Block 1L, SUBTRA */ 1.1933 -+ el = saturate(xlow - s->band[0].s); 1.1934 -+ 1.1935 -+ /* Block 1L, QUANTL */ 1.1936 -+ wd = (el >= 0) ? el : -(el + 1); 1.1937 -+ 1.1938 -+ for (i = 1; i < 30; i++) 1.1939 -+ { 1.1940 -+ wd1 = (q6[i]*s->band[0].det) >> 12; 1.1941 -+ if (wd < wd1) 1.1942 -+ break; 1.1943 -+ } 1.1944 -+ ilow = (el < 0) ? iln[i] : ilp[i]; 1.1945 -+ 1.1946 -+ /* Block 2L, INVQAL */ 1.1947 -+ ril = ilow >> 2; 1.1948 -+ wd2 = qm4[ril]; 1.1949 -+ dlow = (s->band[0].det*wd2) >> 15; 1.1950 -+ 1.1951 -+ /* Block 3L, LOGSCL */ 1.1952 -+ il4 = rl42[ril]; 1.1953 -+ wd = (s->band[0].nb*127) >> 7; 1.1954 -+ s->band[0].nb = wd + wl[il4]; 1.1955 -+ if (s->band[0].nb < 0) 1.1956 -+ s->band[0].nb = 0; 1.1957 -+ else if (s->band[0].nb > 18432) 1.1958 -+ s->band[0].nb = 18432; 1.1959 -+ 1.1960 -+ /* Block 3L, SCALEL */ 1.1961 -+ wd1 = (s->band[0].nb >> 6) & 31; 1.1962 -+ wd2 = 8 - (s->band[0].nb >> 11); 1.1963 -+ wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); 1.1964 -+ s->band[0].det = wd3 << 2; 1.1965 -+ 1.1966 -+ block4(s, 0, dlow); 1.1967 -+ 1.1968 -+ if (s->eight_k) 1.1969 -+ { 1.1970 -+ /* Just leave the high bits as zero */ 1.1971 -+ code = (0xC0 | ilow) >> (8 - s->bits_per_sample); 1.1972 -+ } 1.1973 -+ else 1.1974 -+ { 1.1975 -+ /* Block 1H, SUBTRA */ 1.1976 -+ eh = saturate(xhigh - s->band[1].s); 1.1977 -+ 1.1978 -+ /* Block 1H, QUANTH */ 1.1979 -+ wd = (eh >= 0) ? eh : -(eh + 1); 1.1980 -+ wd1 = (564*s->band[1].det) >> 12; 1.1981 -+ mih = (wd >= wd1) ? 2 : 1; 1.1982 -+ ihigh = (eh < 0) ? ihn[mih] : ihp[mih]; 1.1983 -+ 1.1984 -+ /* Block 2H, INVQAH */ 1.1985 -+ wd2 = qm2[ihigh]; 1.1986 -+ dhigh = (s->band[1].det*wd2) >> 15; 1.1987 -+ 1.1988 -+ /* Block 3H, LOGSCH */ 1.1989 -+ ih2 = rh2[ihigh]; 1.1990 -+ wd = (s->band[1].nb*127) >> 7; 1.1991 -+ s->band[1].nb = wd + wh[ih2]; 1.1992 -+ if (s->band[1].nb < 0) 1.1993 -+ s->band[1].nb = 0; 1.1994 -+ else if (s->band[1].nb > 22528) 1.1995 -+ s->band[1].nb = 22528; 1.1996 -+ 1.1997 -+ /* Block 3H, SCALEH */ 1.1998 -+ wd1 = (s->band[1].nb >> 6) & 31; 1.1999 -+ wd2 = 10 - (s->band[1].nb >> 11); 1.2000 -+ wd3 = (wd2 < 0) ? (ilb[wd1] << -wd2) : (ilb[wd1] >> wd2); 1.2001 -+ s->band[1].det = wd3 << 2; 1.2002 -+ 1.2003 -+ block4(s, 1, dhigh); 1.2004 -+ code = ((ihigh << 6) | ilow) >> (8 - s->bits_per_sample); 1.2005 -+ } 1.2006 -+ 1.2007 -+ if (s->packed) 1.2008 -+ { 1.2009 -+ /* Pack the code bits */ 1.2010 -+ s->out_buffer |= (code << s->out_bits); 1.2011 -+ s->out_bits += s->bits_per_sample; 1.2012 -+ if (s->out_bits >= 8) 1.2013 -+ { 1.2014 -+ g722_data[g722_bytes++] = (uint8_t) (s->out_buffer & 0xFF); 1.2015 -+ s->out_bits -= 8; 1.2016 -+ s->out_buffer >>= 8; 1.2017 -+ } 1.2018 -+ } 1.2019 -+ else 1.2020 -+ { 1.2021 -+ g722_data[g722_bytes++] = (uint8_t) code; 1.2022 -+ } 1.2023 -+ } 1.2024 -+ return g722_bytes; 1.2025 -+} 1.2026 -+/*- End of function --------------------------------------------------------*/ 1.2027 -+/*- End of file ------------------------------------------------------------*/ 1.2028 -Index: codecs/g722/g722.h 1.2029 -diff -Nau codecs/g722/g722.h.orig codecs/g722/g722.h 1.2030 ---- codecs/g722/g722.h.orig 1970-01-01 01:00:00.000000000 +0100 1.2031 -+++ codecs/g722/g722.h 2009-04-24 00:30:33.000000000 +0200 1.2032 -@@ -0,0 +1,148 @@ 1.2033 -+/* 1.2034 -+ * SpanDSP - a series of DSP components for telephony 1.2035 -+ * 1.2036 -+ * g722.h - The ITU G.722 codec. 1.2037 -+ * 1.2038 -+ * Written by Steve Underwood <steveu@coppice.org> 1.2039 -+ * 1.2040 -+ * Copyright (C) 2005 Steve Underwood 1.2041 -+ * 1.2042 -+ * Despite my general liking of the GPL, I place my own contributions 1.2043 -+ * to this code in the public domain for the benefit of all mankind - 1.2044 -+ * even the slimy ones who might try to proprietize my work and use it 1.2045 -+ * to my detriment. 1.2046 -+ * 1.2047 -+ * Based on a single channel G.722 codec which is: 1.2048 -+ * 1.2049 -+ ***** Copyright (c) CMU 1993 ***** 1.2050 -+ * Computer Science, Speech Group 1.2051 -+ * Chengxiang Lu and Alex Hauptmann 1.2052 -+ * 1.2053 -+ * $Id: g722.h 48959 2006-12-25 06:42:15Z rizzo $ 1.2054 -+ */ 1.2055 -+ 1.2056 -+ 1.2057 -+/*! \file */ 1.2058 -+ 1.2059 -+#if !defined(_G722_H_) 1.2060 -+#define _G722_H_ 1.2061 -+ 1.2062 -+/*! \page g722_page G.722 encoding and decoding 1.2063 -+\section g722_page_sec_1 What does it do? 1.2064 -+The G.722 module is a bit exact implementation of the ITU G.722 specification for all three 1.2065 -+specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests. 1.2066 -+ 1.2067 -+To allow fast and flexible interworking with narrow band telephony, the encoder and decoder 1.2068 -+support an option for the linear audio to be an 8k samples/second stream. In this mode the 1.2069 -+codec is considerably faster, and still fully compatible with wideband terminals using G.722. 1.2070 -+ 1.2071 -+\section g722_page_sec_2 How does it work? 1.2072 -+???. 1.2073 -+*/ 1.2074 -+ 1.2075 -+enum 1.2076 -+{ 1.2077 -+ G722_SAMPLE_RATE_8000 = 0x0001, 1.2078 -+ G722_PACKED = 0x0002 1.2079 -+}; 1.2080 -+ 1.2081 -+#ifndef INT16_MAX 1.2082 -+#define INT16_MAX 32767 1.2083 -+#endif 1.2084 -+#ifndef INT16_MIN 1.2085 -+#define INT16_MIN (-32768) 1.2086 -+#endif 1.2087 -+ 1.2088 -+typedef struct 1.2089 -+{ 1.2090 -+ /*! TRUE if the operating in the special ITU test mode, with the band split filters 1.2091 -+ disabled. */ 1.2092 -+ int itu_test_mode; 1.2093 -+ /*! TRUE if the G.722 data is packed */ 1.2094 -+ int packed; 1.2095 -+ /*! TRUE if encode from 8k samples/second */ 1.2096 -+ int eight_k; 1.2097 -+ /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ 1.2098 -+ int bits_per_sample; 1.2099 -+ 1.2100 -+ /*! Signal history for the QMF */ 1.2101 -+ int x[24]; 1.2102 -+ 1.2103 -+ struct 1.2104 -+ { 1.2105 -+ int s; 1.2106 -+ int sp; 1.2107 -+ int sz; 1.2108 -+ int r[3]; 1.2109 -+ int a[3]; 1.2110 -+ int ap[3]; 1.2111 -+ int p[3]; 1.2112 -+ int d[7]; 1.2113 -+ int b[7]; 1.2114 -+ int bp[7]; 1.2115 -+ int sg[7]; 1.2116 -+ int nb; 1.2117 -+ int det; 1.2118 -+ } band[2]; 1.2119 -+ 1.2120 -+ unsigned int in_buffer; 1.2121 -+ int in_bits; 1.2122 -+ unsigned int out_buffer; 1.2123 -+ int out_bits; 1.2124 -+} g722_encode_state_t; 1.2125 -+ 1.2126 -+typedef struct 1.2127 -+{ 1.2128 -+ /*! TRUE if the operating in the special ITU test mode, with the band split filters 1.2129 -+ disabled. */ 1.2130 -+ int itu_test_mode; 1.2131 -+ /*! TRUE if the G.722 data is packed */ 1.2132 -+ int packed; 1.2133 -+ /*! TRUE if decode to 8k samples/second */ 1.2134 -+ int eight_k; 1.2135 -+ /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ 1.2136 -+ int bits_per_sample; 1.2137 -+ 1.2138 -+ /*! Signal history for the QMF */ 1.2139 -+ int x[24]; 1.2140 -+ 1.2141 -+ struct 1.2142 -+ { 1.2143 -+ int s; 1.2144 -+ int sp; 1.2145 -+ int sz; 1.2146 -+ int r[3]; 1.2147 -+ int a[3]; 1.2148 -+ int ap[3]; 1.2149 -+ int p[3]; 1.2150 -+ int d[7]; 1.2151 -+ int b[7]; 1.2152 -+ int bp[7]; 1.2153 -+ int sg[7]; 1.2154 -+ int nb; 1.2155 -+ int det; 1.2156 -+ } band[2]; 1.2157 -+ 1.2158 -+ unsigned int in_buffer; 1.2159 -+ int in_bits; 1.2160 -+ unsigned int out_buffer; 1.2161 -+ int out_bits; 1.2162 -+} g722_decode_state_t; 1.2163 -+ 1.2164 -+#ifdef __cplusplus 1.2165 -+extern "C" { 1.2166 -+#endif 1.2167 -+ 1.2168 -+g722_encode_state_t *g722_encode_init(g722_encode_state_t *s, int rate, int options); 1.2169 -+int g722_encode_release(g722_encode_state_t *s); 1.2170 -+int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len); 1.2171 -+ 1.2172 -+g722_decode_state_t *g722_decode_init(g722_decode_state_t *s, int rate, int options); 1.2173 -+int g722_decode_release(g722_decode_state_t *s); 1.2174 -+int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len); 1.2175 -+ 1.2176 -+#ifdef __cplusplus 1.2177 -+} 1.2178 -+#endif 1.2179 -+ 1.2180 -+#endif 1.2181 -Index: codecs/g722/Makefile 1.2182 -diff -Nau codecs/g722/Makefile.orig codecs/g722/Makefile 1.2183 ---- codecs/g722/Makefile.orig 1970-01-01 01:00:00.000000000 +0100 1.2184 -+++ codecs/g722/Makefile 2009-04-24 00:30:33.000000000 +0200 1.2185 -@@ -0,0 +1,18 @@ 1.2186 -+LIB=libg722.a 1.2187 -+CFLAGS+=-fPIC 1.2188 -+ 1.2189 -+include $(ASTTOPDIR)/Makefile.rules 1.2190 -+ 1.2191 -+OBJS=g722_encode.o g722_decode.o 1.2192 -+ 1.2193 -+all: $(LIB) 1.2194 -+ 1.2195 -+$(LIB): $(OBJS) 1.2196 -+ $(ECHO_PREFIX) echo " [AR] $^ -> $@" 1.2197 -+ $(CMD_PREFIX) $(AR) cr $@ $^ 1.2198 -+ $(CMD_PREFIX) $(RANLIB) $@ 1.2199 -+ 1.2200 -+clean: 1.2201 -+ rm -f $(LIB) *.o 1.2202 -+ rm -f .*.o.d 1.2203 -+ rm -f *.s *.i 1.2204 -Index: codecs/g722_slin_ex.h 1.2205 -diff -Nau codecs/g722_slin_ex.h.orig codecs/g722_slin_ex.h 1.2206 ---- codecs/g722_slin_ex.h.orig 1970-01-01 01:00:00.000000000 +0100 1.2207 -+++ codecs/g722_slin_ex.h 2009-04-24 00:30:33.000000000 +0200 1.2208 -@@ -0,0 +1,25 @@ 1.2209 -+/*! \file 1.2210 -+ * \brief g722_slin_ex.h -- 1.2211 -+ * 1.2212 -+ * 4-bit ADPCM data, 20 milliseconds worth at 8 kHz. 1.2213 -+ * 1.2214 -+ * Source: g723.example 1.2215 -+ * 1.2216 -+ * Copyright (C) 2001-2005, Digium Inc. 1.2217 -+ * 1.2218 -+ * Distributed under the terms of the GNU General Public License 1.2219 -+ * 1.2220 -+ */ 1.2221 -+ 1.2222 -+static unsigned char g722_slin_ex[] = { 1.2223 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1.2224 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1.2225 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1.2226 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1.2227 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1.2228 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1.2229 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1.2230 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1.2231 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1.2232 -+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 1.2233 -+}; 1.2234 -Index: codecs/Makefile 1.2235 -diff -Nau codecs/Makefile.orig codecs/Makefile 1.2236 ---- codecs/Makefile.orig 2008-03-26 17:42:35.000000000 +0100 1.2237 -+++ codecs/Makefile 2009-04-24 00:30:33.000000000 +0200 1.2238 -@@ -31,6 +31,7 @@ 1.2239 - 1.2240 - LIBILBC:=ilbc/libilbc.a 1.2241 - LIBLPC10:=lpc10/liblpc10.a 1.2242 -+LIBG722:=g722/libg722.a 1.2243 - 1.2244 - all: _all 1.2245 - 1.2246 -@@ -45,6 +46,7 @@ 1.2247 - $(MAKE) -C gsm clean 1.2248 - $(MAKE) -C lpc10 clean 1.2249 - $(MAKE) -C ilbc clean 1.2250 -+ $(MAKE) -C g722 clean 1.2251 - 1.2252 - gsm/lib/libgsm.a: 1.2253 - @mkdir -p gsm/lib 1.2254 -@@ -59,3 +61,8 @@ 1.2255 - @$(MAKE) -C ilbc all ASTCFLAGS="$(filter-out -Wmissing-prototypes -Wmissing-declarations,$(ASTCFLAGS)) $(AST_NO_STRICT_OVERFLOW)" 1.2256 - 1.2257 - $(if $(filter codec_ilbc,$(EMBEDDED_MODS)),modules.link,codec_ilbc.so): $(LIBILBC) 1.2258 -+ 1.2259 -+$(LIBG722): 1.2260 -+ @$(MAKE) -C g722 all 1.2261 -+ 1.2262 -+$(if $(filter codec_g722,$(EMBEDDED_MODS)),modules.link,codec_g722.so): $(LIBG722) 1.2263 -Index: codecs/slin_g722_ex.h 1.2264 -diff -Nau codecs/slin_g722_ex.h.orig codecs/slin_g722_ex.h 1.2265 ---- codecs/slin_g722_ex.h.orig 1970-01-01 01:00:00.000000000 +0100 1.2266 -+++ codecs/slin_g722_ex.h 2009-04-24 00:30:33.000000000 +0200 1.2267 -@@ -0,0 +1,25 @@ 1.2268 -+/*! \file 1.2269 -+ * \brief slin_g722_ex.h -- 1.2270 -+ * 1.2271 -+ * Signed 16-bit audio data, 10 milliseconds worth at 8 kHz. 1.2272 -+ * 1.2273 -+ * Source: g723.example 1.2274 -+ * 1.2275 -+ * Copyright (C) 2001-2005, Digium Inc. 1.2276 -+ * 1.2277 -+ * Distributed under the terms of the GNU General Public License 1.2278 -+ * 1.2279 -+ */ 1.2280 -+ 1.2281 -+static signed short slin_g722_ex[] = { 1.2282 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 1.2283 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 1.2284 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 1.2285 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 1.2286 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 1.2287 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 1.2288 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 1.2289 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 1.2290 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 1.2291 -+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 1.2292 -+}; 1.2293 -Index: configure 1.2294 -diff -Nau configure.orig configure 1.2295 ---- configure.orig 2009-02-18 21:06:45.000000000 +0100 1.2296 -+++ configure 2009-04-24 00:30:33.000000000 +0200 1.2297 -@@ -11143,6 +11143,61 @@ 1.2298 - 1.2299 - fi 1.2300 - 1.2301 -+{ echo "$as_me:$LINENO: checking for tm_gmtoff in struct tm" >&5 1.2302 -+echo $ECHO_N "checking for tm_gmtoff in struct tm... $ECHO_C" >&6; } 1.2303 -+if test "${ac_cv_struct_tm_gmtoff+set}" = set; then 1.2304 -+ echo $ECHO_N "(cached) $ECHO_C" >&6 1.2305 -+else 1.2306 -+ cat >conftest.$ac_ext <<_ACEOF 1.2307 -+/* confdefs.h. */ 1.2308 -+_ACEOF 1.2309 -+cat confdefs.h >>conftest.$ac_ext 1.2310 -+cat >>conftest.$ac_ext <<_ACEOF 1.2311 -+/* end confdefs.h. */ 1.2312 -+$ac_includes_default 1.2313 -+#include <sys/types.h> 1.2314 -+#include <$ac_cv_struct_tm> 1.2315 -+int main() { 1.2316 -+struct tm tm; tm.tm_gmtoff; 1.2317 -+; return 0; } 1.2318 -+_ACEOF 1.2319 -+rm -f conftest.$ac_objext 1.2320 -+if { (ac_try="$ac_compile" 1.2321 -+case "(($ac_try" in 1.2322 -+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; 1.2323 -+ *) ac_try_echo=$ac_try;; 1.2324 -+esac 1.2325 -+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 1.2326 -+ (eval "$ac_compile") 2>conftest.er1 1.2327 -+ ac_status=$? 1.2328 -+ grep -v '^ *+' conftest.er1 >conftest.err 1.2329 -+ rm -f conftest.er1 1.2330 -+ cat conftest.err >&5 1.2331 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 1.2332 -+ (exit $ac_status); } && { 1.2333 -+ test -z "$ac_c_werror_flag" || 1.2334 -+ test ! -s conftest.err 1.2335 -+ } && test -s conftest.$ac_objext; then 1.2336 -+ ac_cv_struct_tm_gmtoff=yes 1.2337 -+else 1.2338 -+ echo "$as_me: failed program was:" >&5 1.2339 -+sed 's/^/| /' conftest.$ac_ext >&5 1.2340 -+ 1.2341 -+ ac_cv_struct_tm_gmtoff=no 1.2342 -+fi 1.2343 -+ 1.2344 -+rm -f conftest* 1.2345 -+fi 1.2346 -+{ echo "$as_me:$LINENO: result: $ac_cv_struct_tm_gmtoff" >&5 1.2347 -+echo "${ECHO_T}$ac_cv_struct_tm_gmtoff" >&6; } 1.2348 -+if test $ac_cv_struct_tm_gmtoff = yes; then 1.2349 -+ 1.2350 -+cat >>confdefs.h <<\_ACEOF 1.2351 -+#define TM_GMTOFF 1 1.2352 -+_ACEOF 1.2353 -+ 1.2354 -+fi 1.2355 -+ 1.2356 - { echo "$as_me:$LINENO: checking for working volatile" >&5 1.2357 - echo $ECHO_N "checking for working volatile... $ECHO_C" >&6; } 1.2358 - if test "${ac_cv_c_volatile+set}" = set; then 1.2359 -Index: include/asterisk/config.h 1.2360 -diff -Nau include/asterisk/config.h.orig include/asterisk/config.h 1.2361 ---- include/asterisk/config.h.orig 2009-02-18 19:30:38.000000000 +0100 1.2362 -+++ include/asterisk/config.h 2009-04-24 00:30:33.000000000 +0200 1.2363 -@@ -33,6 +33,8 @@ 1.2364 - 1.2365 - struct ast_category; 1.2366 - 1.2367 -+#define CONFIG_STATUS_FILEUNCHANGED (void *)-1 1.2368 -+ 1.2369 - struct ast_variable { 1.2370 - char *name; 1.2371 - char *value; 1.2372 -Index: include/asterisk/frame.h 1.2373 -diff -Nau include/asterisk/frame.h.orig include/asterisk/frame.h 1.2374 ---- include/asterisk/frame.h.orig 2009-03-05 19:22:16.000000000 +0100 1.2375 -+++ include/asterisk/frame.h 2009-04-24 00:30:33.000000000 +0200 1.2376 -@@ -260,6 +260,8 @@ 1.2377 - #define AST_FORMAT_G726 (1 << 11) 1.2378 - /*! G.722 */ 1.2379 - #define AST_FORMAT_G722 (1 << 12) 1.2380 -+/*! Raw 16-bit Signed Linear (16000 Hz) PCM */ 1.2381 -+#define AST_FORMAT_SLINEAR16 (1 << 15) 1.2382 - /*! Unsupported audio bits */ 1.2383 - #define AST_FORMAT_AUDIO_UNDEFINED ((1 << 13) | (1 << 14) | (1 << 15)) 1.2384 - /*! Maximum audio format */ 1.2385 -Index: main/editline/np/vis.h 1.2386 -diff -Nau main/editline/np/vis.h.orig main/editline/np/vis.h 1.2387 ---- main/editline/np/vis.h.orig 2006-08-21 04:11:39.000000000 +0200 1.2388 -+++ main/editline/np/vis.h 2009-04-24 00:30:33.000000000 +0200 1.2389 -@@ -76,6 +76,22 @@ 1.2390 - 1.2391 - #include <sys/cdefs.h> 1.2392 - 1.2393 -+/* correct nonportable unsigned type usage */ 1.2394 -+#if !defined(__FreeBSD__) && !defined(__linux__) 1.2395 -+#ifndef u_int64_t 1.2396 -+#define u_int64_t unsigned long long 1.2397 -+#endif 1.2398 -+#ifndef u_int32_t 1.2399 -+#define u_int32_t unsigned int 1.2400 -+#endif 1.2401 -+#ifndef u_int16_t 1.2402 -+#define u_int16_t unsigned short 1.2403 -+#endif 1.2404 -+#ifndef u_int6_t 1.2405 -+#define u_int8_t unsigned char 1.2406 -+#endif 1.2407 -+#endif 1.2408 -+ 1.2409 - __BEGIN_DECLS 1.2410 - char *vis __P((char *, int, int, int)); 1.2411 - char *svis __P((char *, int, int, int, const char *)); 1.2412 -Index: main/stdtime/localtime.c 1.2413 -diff -Nau main/stdtime/localtime.c.orig main/stdtime/localtime.c 1.2414 ---- main/stdtime/localtime.c.orig 2008-09-27 17:00:48.000000000 +0200 1.2415 -+++ main/stdtime/localtime.c 2009-04-24 00:30:33.000000000 +0200 1.2416 -@@ -1134,9 +1134,9 @@ 1.2417 - */ 1.2418 - result = timesub(&t, ttisp->tt_gmtoff, sp, tmp); 1.2419 - tmp->tm_isdst = ttisp->tt_isdst; 1.2420 --#ifndef SOLARIS /* Solaris doesn't have this element */ 1.2421 -+#ifdef TM_GMTOFF 1.2422 - tmp->tm_gmtoff = ttisp->tt_gmtoff; 1.2423 --#endif 1.2424 -+#endif /* defined TM_GMTOFF */ 1.2425 - #ifdef TM_ZONE 1.2426 - tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind]; 1.2427 - #endif /* defined TM_ZONE */ 1.2428 -Index: Makefile.moddir_rules 1.2429 -diff -Nau Makefile.moddir_rules.orig Makefile.moddir_rules 1.2430 ---- Makefile.moddir_rules.orig 2008-11-26 19:36:24.000000000 +0100 1.2431 -+++ Makefile.moddir_rules 2009-04-24 00:30:33.000000000 +0200 1.2432 -@@ -69,7 +69,9 @@ 1.2433 - rm -f modules.link 1.2434 - 1.2435 - install:: all 1.2436 -+ifneq ($(LOADABLE_MODS),) 1.2437 - for x in $(LOADABLE_MODS:%=%.so); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done 1.2438 -+endif 1.2439 - 1.2440 - uninstall:: 1.2441 - 1.2442 -Index: res/res_features.c 1.2443 -diff -Nau res/res_features.c.orig res/res_features.c 1.2444 ---- res/res_features.c.orig 2009-03-03 19:27:09.000000000 +0100 1.2445 -+++ res/res_features.c 2009-04-24 00:30:33.000000000 +0200 1.2446 -@@ -732,6 +732,10 @@ 1.2447 - snprintf(args, len, "%s|%s|m", S_OR(touch_format, "wav"), touch_filename); 1.2448 - } 1.2449 - 1.2450 -+ for( x = 0; x < strlen(touch_filename); x++) { 1.2451 -+ if (touch_filename[x] == '/') 1.2452 -+ touch_filename[x] = '-'; 1.2453 -+ } 1.2454 - for( x = 0; x < strlen(args); x++) { 1.2455 - if (args[x] == '/') 1.2456 - args[x] = '-'; 1.2457 -@@ -2774,6 +2778,293 @@ 1.2458 - } 1.2459 } 1.2460 1.2461 -+static char mandescr_bridge[] = 1.2462 -+"Description: Bridge together two channels already in the PBX\n" 1.2463 -+"Variables: ( Headers marked with * are required )\n" 1.2464 -+" *Channel1: Channel to Bridge to Channel2\n" 1.2465 -+" *Channel2: Channel to Bridge to Channel1\n" 1.2466 -+" Tone: (Yes|No) Play courtesy tone to Channel 2\n" 1.2467 -+"\n"; 1.2468 -+ 1.2469 -+/*! 1.2470 -+ * \brief Actual bridge 1.2471 -+ * \param chan 1.2472 -+ * \param tmpchan 1.2473 -+ * 1.2474 -+ * Stop hold music, lock both channels, masq channels, 1.2475 -+ * after bridge return channel to next priority. 1.2476 -+*/ 1.2477 -+static void do_bridge_masquerade(struct ast_channel *chan, struct ast_channel *tmpchan) 1.2478 -+{ 1.2479 -+ ast_moh_stop(chan); 1.2480 -+ ast_channel_lock(chan); 1.2481 -+ ast_setstate(tmpchan, chan->_state); 1.2482 -+ tmpchan->readformat = chan->readformat; 1.2483 -+ tmpchan->writeformat = chan->writeformat; 1.2484 -+ ast_channel_masquerade(tmpchan, chan); 1.2485 -+ ast_channel_lock(tmpchan); 1.2486 -+ ast_do_masquerade(tmpchan); 1.2487 -+ /* when returning from bridge, the channel will continue at the next priority */ 1.2488 -+ ast_explicit_goto(tmpchan, chan->context, chan->exten, chan->priority + 1); 1.2489 -+ ast_channel_unlock(tmpchan); 1.2490 -+ ast_channel_unlock(chan); 1.2491 -+} 1.2492 -+ 1.2493 -+/*! 1.2494 -+ * \brief Bridge channels together 1.2495 -+ * \param s 1.2496 -+ * \param m 1.2497 -+ * 1.2498 -+ * Make sure valid channels were specified, 1.2499 -+ * send errors if any of the channels could not be found/locked, answer channels if needed, 1.2500 -+ * create the placeholder channels and grab the other channels 1.2501 -+ * make the channels compatible, send error if we fail doing so 1.2502 -+ * setup the bridge thread object and start the bridge. 1.2503 -+ * 1.2504 -+ * \retval 0 on success or on incorrect use. 1.2505 -+ * \retval 1 on failure to bridge channels. 1.2506 -+*/ 1.2507 -+static int action_bridge(struct mansession *s, const struct message *m) 1.2508 -+{ 1.2509 -+ const char *channela = astman_get_header(m, "Channel1"); 1.2510 -+ const char *channelb = astman_get_header(m, "Channel2"); 1.2511 -+ const char *playtone = astman_get_header(m, "Tone"); 1.2512 -+ struct ast_channel *chana = NULL, *chanb = NULL; 1.2513 -+ struct ast_channel *tmpchana = NULL, *tmpchanb = NULL; 1.2514 -+ struct ast_bridge_thread_obj *tobj = NULL; 1.2515 -+ 1.2516 -+ /* make sure valid channels were specified */ 1.2517 -+ if (!ast_strlen_zero(channela) && !ast_strlen_zero(channelb)) { 1.2518 -+ chana = ast_get_channel_by_name_prefix_locked(channela, strlen(channela)); 1.2519 -+ chanb = ast_get_channel_by_name_prefix_locked(channelb, strlen(channelb)); 1.2520 -+ if (chana) 1.2521 -+ ast_channel_unlock(chana); 1.2522 -+ if (chanb) 1.2523 -+ ast_channel_unlock(chanb); 1.2524 -+ 1.2525 -+ /* send errors if any of the channels could not be found/locked */ 1.2526 -+ if (!chana) { 1.2527 -+ char buf[256]; 1.2528 -+ snprintf(buf, sizeof(buf), "Channel1 does not exist: %s", channela); 1.2529 -+ astman_send_error(s, m, buf); 1.2530 -+ return 0; 1.2531 -+ } 1.2532 -+ if (!chanb) { 1.2533 -+ char buf[256]; 1.2534 -+ snprintf(buf, sizeof(buf), "Channel2 does not exist: %s", channelb); 1.2535 -+ astman_send_error(s, m, buf); 1.2536 -+ return 0; 1.2537 -+ } 1.2538 -+ } else { 1.2539 -+ astman_send_error(s, m, "Missing channel parameter in request"); 1.2540 -+ return 0; 1.2541 -+ } 1.2542 -+ 1.2543 -+ /* Answer the channels if needed */ 1.2544 -+ if (chana->_state != AST_STATE_UP) 1.2545 -+ ast_answer(chana); 1.2546 -+ if (chanb->_state != AST_STATE_UP) 1.2547 -+ ast_answer(chanb); 1.2548 -+ 1.2549 -+ /* create the placeholder channels and grab the other channels */ 1.2550 -+ if (!(tmpchana = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL, 1.2551 -+ NULL, NULL, 0, "Bridge/%s", chana->name))) { 1.2552 -+ astman_send_error(s, m, "Unable to create temporary channel!"); 1.2553 -+ return 1; 1.2554 -+ } 1.2555 -+ 1.2556 -+ if (!(tmpchanb = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL, 1.2557 -+ NULL, NULL, 0, "Bridge/%s", chanb->name))) { 1.2558 -+ astman_send_error(s, m, "Unable to create temporary channels!"); 1.2559 -+ ast_channel_free(tmpchana); 1.2560 -+ return 1; 1.2561 -+ } 1.2562 -+ 1.2563 -+ do_bridge_masquerade(chana, tmpchana); 1.2564 -+ do_bridge_masquerade(chanb, tmpchanb); 1.2565 -+ 1.2566 -+ /* make the channels compatible, send error if we fail doing so */ 1.2567 -+ if (ast_channel_make_compatible(tmpchana, tmpchanb)) { 1.2568 -+ ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for manager bridge\n", tmpchana->name, tmpchanb->name); 1.2569 -+ astman_send_error(s, m, "Could not make channels compatible for manager bridge"); 1.2570 -+ ast_hangup(tmpchana); 1.2571 -+ ast_hangup(tmpchanb); 1.2572 -+ return 1; 1.2573 -+ } 1.2574 -+ 1.2575 -+ /* setup the bridge thread object and start the bridge */ 1.2576 -+ if (!(tobj = ast_calloc(1, sizeof(*tobj)))) { 1.2577 -+ ast_log(LOG_WARNING, "Unable to spawn a new bridge thread on %s and %s: %s\n", tmpchana->name, tmpchanb->name, strerror(errno)); 1.2578 -+ astman_send_error(s, m, "Unable to spawn a new bridge thread"); 1.2579 -+ ast_hangup(tmpchana); 1.2580 -+ ast_hangup(tmpchanb); 1.2581 -+ return 1; 1.2582 -+ } 1.2583 -+ 1.2584 -+ tobj->chan = tmpchana; 1.2585 -+ tobj->peer = tmpchanb; 1.2586 -+ 1.2587 -+ if (ast_true(playtone)) { 1.2588 -+ if (!ast_strlen_zero(xfersound) && !ast_streamfile(tmpchanb, xfersound, tmpchanb->language)) { 1.2589 -+ if (ast_waitstream(tmpchanb, "") < 0) 1.2590 -+ ast_log(LOG_WARNING, "Failed to play a courtesy tone on chan %s\n", tmpchanb->name); 1.2591 -+ } 1.2592 -+ } 1.2593 -+ 1.2594 -+ ast_bridge_call_thread_launch(tobj); 1.2595 -+ 1.2596 -+ astman_send_ack(s, m, "Launched bridge thread with success"); 1.2597 -+ 1.2598 -+ return 0; 1.2599 -+} 1.2600 -+ 1.2601 -+static char *app_bridge = "Bridge"; 1.2602 -+static char *bridge_synopsis = "Bridge two channels"; 1.2603 -+static char *bridge_descrip = 1.2604 -+"Usage: Bridge(channel[,options])\n" 1.2605 -+" Allows the ability to bridge two channels via the dialplan.\n" 1.2606 -+"The current channel is bridged to the specified 'channel'.\n" 1.2607 -+" Options:\n" 1.2608 -+" p - Play a courtesy tone to 'channel'.\n" 1.2609 -+"This application sets the following channel variable upon completion:\n" 1.2610 -+" BRIDGERESULT The result of the bridge attempt as a text string, one of\n" 1.2611 -+" SUCCESS | FAILURE | LOOP | NONEXISTENT | INCOMPATIBLE\n"; 1.2612 -+ 1.2613 -+enum { 1.2614 -+ BRIDGE_OPT_PLAYTONE = (1 << 0), 1.2615 -+}; 1.2616 -+ 1.2617 -+AST_APP_OPTIONS(bridge_exec_options, BEGIN_OPTIONS 1.2618 -+ AST_APP_OPTION('p', BRIDGE_OPT_PLAYTONE) 1.2619 -+END_OPTIONS ); 1.2620 -+ 1.2621 -+/*! 1.2622 -+ * \brief Bridge channels 1.2623 -+ * \param chan 1.2624 -+ * \param data channel to bridge with. 1.2625 -+ * 1.2626 -+ * Split data, check we aren't bridging with ourself, check valid channel, 1.2627 -+ * answer call if not already, check compatible channels, setup bridge config 1.2628 -+ * now bridge call, if transfered party hangs up return to PBX extension. 1.2629 -+*/ 1.2630 -+static int bridge_exec(struct ast_channel *chan, void *data) 1.2631 -+{ 1.2632 -+ struct ast_channel *current_dest_chan, *final_dest_chan; 1.2633 -+ char *tmp_data = NULL; 1.2634 -+ struct ast_flags opts = { 0, }; 1.2635 -+ struct ast_bridge_config bconfig = { { 0, }, }; 1.2636 -+ 1.2637 -+ AST_DECLARE_APP_ARGS(args, 1.2638 -+ AST_APP_ARG(dest_chan); 1.2639 -+ AST_APP_ARG(options); 1.2640 -+ ); 1.2641 -+ 1.2642 -+ if (ast_strlen_zero(data)) { 1.2643 -+ ast_log(LOG_WARNING, "Bridge require at least 1 argument specifying the other end of the bridge\n"); 1.2644 -+ return -1; 1.2645 -+ } 1.2646 -+ 1.2647 -+ tmp_data = ast_strdupa(data); 1.2648 -+ AST_STANDARD_APP_ARGS(args, tmp_data); 1.2649 -+ if (!ast_strlen_zero(args.options)) 1.2650 -+ ast_app_parse_options(bridge_exec_options, &opts, NULL, args.options); 1.2651 -+ 1.2652 -+ /* avoid bridge with ourselves */ 1.2653 -+ if (!strncmp(chan->name, args.dest_chan, 1.2654 -+ strlen(chan->name) < strlen(args.dest_chan) ? 1.2655 -+ strlen(chan->name) : strlen(args.dest_chan))) { 1.2656 -+ ast_log(LOG_WARNING, "Unable to bridge channel %s with itself\n", chan->name); 1.2657 -+ manager_event(EVENT_FLAG_CALL, "BridgeExec", 1.2658 -+ "Response: Failed\r\n" 1.2659 -+ "Reason: Unable to bridge channel to itself\r\n" 1.2660 -+ "Channel1: %s\r\n" 1.2661 -+ "Channel2: %s\r\n", 1.2662 -+ chan->name, args.dest_chan); 1.2663 -+ pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "LOOP"); 1.2664 -+ return 0; 1.2665 -+ } 1.2666 -+ 1.2667 -+ /* make sure we have a valid end point */ 1.2668 -+ if (!(current_dest_chan = ast_get_channel_by_name_prefix_locked(args.dest_chan, 1.2669 -+ strlen(args.dest_chan)))) { 1.2670 -+ ast_log(LOG_WARNING, "Bridge failed because channel %s does not exist or we " 1.2671 -+ "cannot get its lock\n", args.dest_chan); 1.2672 -+ manager_event(EVENT_FLAG_CALL, "BridgeExec", 1.2673 -+ "Response: Failed\r\n" 1.2674 -+ "Reason: Cannot grab end point\r\n" 1.2675 -+ "Channel1: %s\r\n" 1.2676 -+ "Channel2: %s\r\n", chan->name, args.dest_chan); 1.2677 -+ pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "NONEXISTENT"); 1.2678 -+ return 0; 1.2679 -+ } 1.2680 -+ ast_channel_unlock(current_dest_chan); 1.2681 -+ 1.2682 -+ /* answer the channel if needed */ 1.2683 -+ if (current_dest_chan->_state != AST_STATE_UP) 1.2684 -+ ast_answer(current_dest_chan); 1.2685 -+ 1.2686 -+ /* try to allocate a place holder where current_dest_chan will be placed */ 1.2687 -+ if (!(final_dest_chan = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL, 1.2688 -+ NULL, NULL, 0, "Bridge/%s", current_dest_chan->name))) { 1.2689 -+ ast_log(LOG_WARNING, "Cannot create placeholder channel for chan %s\n", args.dest_chan); 1.2690 -+ manager_event(EVENT_FLAG_CALL, "BridgeExec", 1.2691 -+ "Response: Failed\r\n" 1.2692 -+ "Reason: cannot create placeholder\r\n" 1.2693 -+ "Channel1: %s\r\n" 1.2694 -+ "Channel2: %s\r\n", chan->name, args.dest_chan); 1.2695 -+ } 1.2696 -+ do_bridge_masquerade(current_dest_chan, final_dest_chan); 1.2697 -+ 1.2698 -+ /* now current_dest_chan is a ZOMBIE and with softhangup set to 1 and final_dest_chan is our end point */ 1.2699 -+ /* try to make compatible, send error if we fail */ 1.2700 -+ if (ast_channel_make_compatible(chan, final_dest_chan) < 0) { 1.2701 -+ ast_log(LOG_WARNING, "Could not make channels %s and %s compatible for bridge\n", chan->name, final_dest_chan->name); 1.2702 -+ manager_event(EVENT_FLAG_CALL, "BridgeExec", 1.2703 -+ "Response: Failed\r\n" 1.2704 -+ "Reason: Could not make channels compatible for bridge\r\n" 1.2705 -+ "Channel1: %s\r\n" 1.2706 -+ "Channel2: %s\r\n", chan->name, final_dest_chan->name); 1.2707 -+ ast_hangup(final_dest_chan); /* may be we should return this channel to the PBX? */ 1.2708 -+ pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "INCOMPATIBLE"); 1.2709 -+ return 0; 1.2710 -+ } 1.2711 -+ 1.2712 -+ /* Report that the bridge will be successfull */ 1.2713 -+ manager_event(EVENT_FLAG_CALL, "BridgeExec", 1.2714 -+ "Response: Success\r\n" 1.2715 -+ "Channel1: %s\r\n" 1.2716 -+ "Channel2: %s\r\n", chan->name, final_dest_chan->name); 1.2717 -+ 1.2718 -+ /* we have 2 valid channels to bridge, now it is just a matter of setting up the bridge config and starting the bridge */ 1.2719 -+ if (ast_test_flag(&opts, BRIDGE_OPT_PLAYTONE) && !ast_strlen_zero(xfersound)) { 1.2720 -+ if (!ast_streamfile(final_dest_chan, xfersound, final_dest_chan->language)) { 1.2721 -+ if (ast_waitstream(final_dest_chan, "") < 0) 1.2722 -+ ast_log(LOG_WARNING, "Failed to play courtesy tone on %s\n", final_dest_chan->name); 1.2723 -+ } 1.2724 -+ } 1.2725 -+ 1.2726 -+ /* do the bridge */ 1.2727 -+ ast_bridge_call(chan, final_dest_chan, &bconfig); 1.2728 -+ 1.2729 -+ /* the bridge has ended, set BRIDGERESULT to SUCCESS. If the other channel has not been hung up, return it to the PBX */ 1.2730 -+ pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "SUCCESS"); 1.2731 -+ if (!ast_check_hangup(final_dest_chan)) { 1.2732 -+ ast_log(LOG_EVENT, "starting new PBX in %s,%s,%d for chan %s\n", 1.2733 -+ final_dest_chan->context, final_dest_chan->exten, 1.2734 -+ final_dest_chan->priority, final_dest_chan->name); 1.2735 -+ 1.2736 -+ if (ast_pbx_start(final_dest_chan) != AST_PBX_SUCCESS) { 1.2737 -+ ast_log(LOG_WARNING, "FAILED continuing PBX on dest chan %s\n", final_dest_chan->name); 1.2738 -+ ast_hangup(final_dest_chan); 1.2739 -+ } else 1.2740 -+ ast_log(LOG_EVENT, "SUCCESS continuing PBX on chan %s\n", final_dest_chan->name); 1.2741 -+ } else { 1.2742 -+ ast_log(LOG_EVENT, "hangup chan %s since the other endpoint has hung up\n", final_dest_chan->name); 1.2743 -+ ast_hangup(final_dest_chan); 1.2744 -+ } 1.2745 -+ 1.2746 -+ return 0; 1.2747 -+} 1.2748 + unsigned 1.2749 +@@ -993,7 +1047,7 @@ 1.2750 + unsigned short* tmp = (unsigned short*)buf; 1.2751 1.2752 - static int load_config(void) 1.2753 - { 1.2754 -@@ -3034,6 +3325,8 @@ 1.2755 - { 1.2756 - int res; 1.2757 - 1.2758 -+ ast_register_application(app_bridge, bridge_exec, bridge_synopsis, bridge_descrip); 1.2759 -+ 1.2760 - memset(parking_ext, 0, sizeof(parking_ext)); 1.2761 - memset(parking_con, 0, sizeof(parking_con)); 1.2762 + if(*tmp == CapiNoError) { 1.2763 +- memcpy(Buf, buf + 2, (Ctrl) ? sizeof(struct capi_profile) : 2); 1.2764 ++ memcpy(Buf, buf + 2, (Ctrl) ? 224 /* sizeof(struct capi_profile) */ : 2); 1.2765 + } 1.2766 1.2767 -@@ -3048,6 +3341,7 @@ 1.2768 - ast_manager_register("ParkedCalls", 0, manager_parking_status, "List parked calls" ); 1.2769 - ast_manager_register2("Park", EVENT_FLAG_CALL, manager_park, 1.2770 - "Park a channel", mandescr_park); 1.2771 -+ ast_manager_register2("Bridge", EVENT_FLAG_CALL, action_bridge, "Bridge two channels already in the PBX", mandescr_bridge); 1.2772 + fret = *tmp; 1.2773 +@@ -1002,6 +1056,9 @@ 1.2774 + return (fret); 1.2775 } 1.2776 1.2777 - res |= ast_devstate_prov_add("Park", metermaidstate); 1.2778 -Index: apps/app_voicemail.c 1.2779 -diff -Nau apps/app_voicemail.c.orig apps/app_voicemail.c 1.2780 ---- apps/app_voicemail.c.orig 2009-04-25 02:38:20.343758775 +0200 1.2781 -+++ apps/app_voicemail.c 2009-04-25 19:56:25.287569363 +0200 1.2782 -@@ -115,6 +115,7 @@ 1.2783 - static char imapport[8]; 1.2784 - static char imapflags[128]; 1.2785 - static char imapfolder[64]; 1.2786 -+static int imapsubfold = 0; 1.2787 - static char authuser[32]; 1.2788 - static char authpassword[42]; 1.2789 ++#if 1 1.2790 ++ return CapiMsgOSResourceErr; 1.2791 ++#else 1.2792 + ioctl_data.contr = Ctrl; 1.2793 1.2794 -@@ -4313,6 +4314,7 @@ 1.2795 - /* we must use mbox(x) folder names, and copy the message there */ 1.2796 - /* simple. huh? */ 1.2797 - char sequence[10]; 1.2798 -+ char folder[256]; 1.2799 - /* get the real IMAP message number for this message */ 1.2800 - snprintf(sequence, sizeof(sequence), "%ld", vms->msgArray[msg]); 1.2801 - if (option_debug > 2) 1.2802 -@@ -4323,11 +4325,21 @@ 1.2803 - } else if (box == 0) { 1.2804 - mail_clearflag(vms->mailstream, sequence, "\\Seen"); 1.2805 + if (ioctl(capi_fd, CAPI_GET_PROFILE, &ioctl_data) < 0) { 1.2806 +@@ -1018,6 +1075,7 @@ 1.2807 + sizeof(ioctl_data.profile.ncontroller)); 1.2808 } 1.2809 -- if (!strcasecmp(mbox(0), vms->curbox) && (box == 0 || box == 1)) { 1.2810 -+ if ((!strcasecmp(mbox(0), vms->curbox) || \ 1.2811 -+ !strcasecmp(mbox(1), vms->curbox)) && \ 1.2812 -+ (box == 0 || box == 1)) { /* Don't copy data, just change Seen flag */ 1.2813 - ast_mutex_unlock(&vms->lock); 1.2814 - return 0; 1.2815 -- } else { 1.2816 -- int res = !mail_copy(vms->mailstream,sequence,(char *) mbox(box)); 1.2817 -+ } else if (box > 1) { /* Do copy data using INBOX or subfolder */ 1.2818 -+ if (imapsubfold == 1) 1.2819 -+ snprintf(folder, sizeof(folder), "%s%c%s", imapfolder, delimiter, mbox(box)); 1.2820 -+ else 1.2821 -+ strncpy(folder, mbox(box), sizeof(folder)); 1.2822 -+ int res = !mail_copy(vms->mailstream,sequence,folder); 1.2823 -+ ast_mutex_unlock(&vms->lock); 1.2824 -+ return res; 1.2825 -+ } else { /* Copy data to INBOX delegating new/old status to Seen flag */ 1.2826 -+ int res = !mail_copy(vms->mailstream,sequence,imapfolder); 1.2827 - ast_mutex_unlock(&vms->lock); 1.2828 - return res; 1.2829 + return CapiNoError; 1.2830 ++#endif 1.2831 + } 1.2832 + /* 1.2833 + * functions added to the CAPI2.0 spec 1.2834 +Index: chan_capi-1.1.5/libcapi20/convert.c 1.2835 +--- chan_capi-1.1.5/libcapi20/convert.c.orig 2009-07-23 16:11:08.000000000 +0200 1.2836 ++++ chan_capi-1.1.5/libcapi20/convert.c 2010-07-24 11:12:31.000000000 +0200 1.2837 +@@ -11,7 +11,14 @@ 1.2838 + #include <stddef.h> 1.2839 + #include <time.h> 1.2840 + #include <ctype.h> 1.2841 ++#ifdef __FreeBSD__ 1.2842 ++#include <sys/endian.h> 1.2843 ++#define bswap_16 bswap16 1.2844 ++#define bswap_32 bswap32 1.2845 ++#define bswap_64 bswap64 1.2846 ++#else 1.2847 + #include <byteswap.h> 1.2848 ++#endif 1.2849 + 1.2850 + #include "capi20.h" 1.2851 + 1.2852 +Index: channels/console_video.h 1.2853 +--- channels/console_video.h.orig 2008-06-30 17:45:15.000000000 +0200 1.2854 ++++ channels/console_video.h 2010-07-24 11:12:31.000000000 +0200 1.2855 +@@ -28,10 +28,7 @@ 1.2856 + "console {device}" 1.2857 + #else 1.2858 + 1.2859 +-#include <ffmpeg/avcodec.h> 1.2860 +-#ifndef OLD_FFMPEG 1.2861 +-#include <ffmpeg/swscale.h> /* requires a recent ffmpeg */ 1.2862 +-#endif 1.2863 ++#include <libavcoded/avcodec.h> 1.2864 + 1.2865 + #define CONSOLE_VIDEO_CMDS \ 1.2866 + "console {videodevice|videocodec" \ 1.2867 +Index: configure 1.2868 +--- configure.orig 2010-06-24 01:40:16.000000000 +0200 1.2869 ++++ configure 2010-07-24 11:14:22.000000000 +0200 1.2870 +@@ -4530,11 +4530,6 @@ 1.2871 + # note- does not work on FreeBSD 1.2872 + 1.2873 + case "${host_os}" in 1.2874 +- freebsd*) 1.2875 +- 1.2876 +- CPPFLAGS=-I/usr/local/include 1.2877 +- LDFLAGS=-L/usr/local/lib 1.2878 +- ;; 1.2879 + openbsd*) 1.2880 + 1.2881 + if test ${prefix} = '/usr/local' || test ${prefix} = 'NONE'; then 1.2882 +Index: main/Makefile 1.2883 +--- main/Makefile.orig 2010-06-25 20:58:37.000000000 +0200 1.2884 ++++ main/Makefile 2010-07-24 11:12:31.000000000 +0200 1.2885 +@@ -78,10 +78,7 @@ 1.2886 + endif 1.2887 + 1.2888 + ifeq ($(OSARCH),FreeBSD) 1.2889 +- # -V is understood by BSD Make, not by GNU make. 1.2890 +- BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk) 1.2891 +- AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi) 1.2892 +- AST_LIBS+=-lcrypto 1.2893 ++ AST_LIBS+=-lpthread -lcrypto 1.2894 + endif 1.2895 + 1.2896 + ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) 1.2897 +Index: main/file.c 1.2898 +--- main/file.c.orig 2010-03-25 17:26:13.000000000 +0100 1.2899 ++++ main/file.c 2010-07-24 11:12:31.000000000 +0200 1.2900 +@@ -254,7 +254,7 @@ 1.2901 + char *fn = NULL; 1.2902 + 1.2903 + if (!strcmp(ext, "wav49")) 1.2904 +- ext = "WAV"; 1.2905 ++ ext = "wav"; 1.2906 + 1.2907 + if (filename[0] == '/') { 1.2908 + if (asprintf(&fn, "%s.%s", filename, ext) < 0) { 1.2909 +Index: main/tcptls.c 1.2910 +--- main/tcptls.c.orig 2010-03-20 18:33:03.000000000 +0100 1.2911 ++++ main/tcptls.c 2010-07-24 11:12:31.000000000 +0200 1.2912 +@@ -325,6 +325,7 @@ 1.2913 + if (!ast_strlen_zero(cfg->cafile) || !ast_strlen_zero(cfg->capath)) { 1.2914 + if (SSL_CTX_load_verify_locations(cfg->ssl_ctx, S_OR(cfg->cafile, NULL), S_OR(cfg->capath,NULL)) == 0) 1.2915 + ast_verb(0, "SSL CA file(%s)/path(%s) error\n", cfg->cafile, cfg->capath); 1.2916 ++ SSL_CTX_set_client_CA_list(cfg->ssl_ctx, S_OR(cfg->cafile, NULL)); 1.2917 } 1.2918 -@@ -7686,6 +7698,10 @@ 1.2919 - #ifndef IMAP_STORAGE 1.2920 - } else if (!cmd) { 1.2921 - vms.deleted[vms.curmsg] = 1; 1.2922 -+#else 1.2923 -+ } else if (!cmd && (folder_int(vms.curbox) > 1 || box > 1)) { 1.2924 -+ vms.deleted[vms.curmsg] = 1; /* Enforce deletion after */ 1.2925 -+ deleted = 1; /* successful copy op */ 1.2926 - #endif 1.2927 - } else { 1.2928 - vms.deleted[vms.curmsg] = 0; 1.2929 -@@ -8198,6 +8214,7 @@ 1.2930 - const char *imap_port; 1.2931 - const char *imap_flags; 1.2932 - const char *imap_folder; 1.2933 -+ const char *imap_use_subfold; 1.2934 - const char *auth_user; 1.2935 - const char *auth_password; 1.2936 - const char *expunge_on_hangup; 1.2937 -@@ -8342,6 +8359,15 @@ 1.2938 - } else { 1.2939 - ast_copy_string(imapfolder,"INBOX", sizeof(imapfolder)); 1.2940 - } 1.2941 -+ /* IMAP saved (sub)folder location policy */ 1.2942 -+ if ((imap_use_subfold = ast_variable_retrieve(cfg, "general", "imapsubfold"))) { 1.2943 -+ if (ast_false(imap_use_subfold)) 1.2944 -+ imapsubfold = 0; 1.2945 -+ else 1.2946 -+ imapsubfold = 1; 1.2947 -+ } else { 1.2948 -+ imapsubfold = 0; 1.2949 -+ } 1.2950 1.2951 - /* There is some very unorthodox casting done here. This is due 1.2952 - * to the way c-client handles the argument passed in. It expects a 1.2953 + ast_verb(0, "SSL certificate ok\n"); 1.2954 +Index: menuselect-tree 1.2955 +--- menuselect-tree.orig 2010-07-22 21:20:17.000000000 +0200 1.2956 ++++ menuselect-tree 2010-07-24 11:12:31.000000000 +0200 1.2957 +@@ -153,6 +153,8 @@ 1.2958 + </member> 1.2959 + <member name="app_system" displayname="Generic System() application" remove_on_change="apps/app_system.o apps/app_system.so"> 1.2960 + </member> 1.2961 ++<member name="app_backticks" displayname="Generic Backticks() application" remove_on_change="apps/app_backticks.o apps/app_backticks.so"> 1.2962 ++</member> 1.2963 + <member name="app_talkdetect" displayname="Playback with Talk Detection" remove_on_change="apps/app_talkdetect.o apps/app_talkdetect.so"> 1.2964 + </member> 1.2965 + <member name="app_test" displayname="Interface Test Application" remove_on_change="apps/app_test.o apps/app_test.so"> 1.2966 +@@ -693,9 +695,9 @@ 1.2967 + <member name="CORE-SOUNDS-EN-ULAW" displayname="English, mu-Law format"> 1.2968 + </member> 1.2969 + <member name="CORE-SOUNDS-EN-ALAW" displayname="English, a-Law format"> 1.2970 ++ <defaultenabled>yes</defaultenabled> 1.2971 + </member> 1.2972 + <member name="CORE-SOUNDS-EN-GSM" displayname="English, GSM format" > 1.2973 +- <defaultenabled>yes</defaultenabled> 1.2974 + </member> 1.2975 + <member name="CORE-SOUNDS-EN-G729" displayname="English, G.729 format"> 1.2976 + </member> 1.2977 +@@ -771,6 +773,7 @@ 1.2978 + <member name="EXTRA-SOUNDS-EN-ULAW" displayname="English, mu-Law format"> 1.2979 + </member> 1.2980 + <member name="EXTRA-SOUNDS-EN-ALAW" displayname="English, a-Law format"> 1.2981 ++ <defaultenabled>yes</defaultenabled> 1.2982 + </member> 1.2983 + <member name="EXTRA-SOUNDS-EN-GSM" displayname="English, GSM format" > 1.2984 + </member> 1.2985 +Index: res/res_http_post.c 1.2986 +--- res/res_http_post.c.orig 2009-10-27 18:12:09.000000000 +0100 1.2987 ++++ res/res_http_post.c 2010-07-24 11:12:31.000000000 +0200 1.2988 +@@ -122,14 +122,8 @@ 1.2989 + ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MESSAGE_PARTIAL\n"); 1.2990 + return; 1.2991 + } else if (GMIME_IS_MULTIPART(part)) { 1.2992 +- GList *l; 1.2993 +- 1.2994 +- ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MULTIPART, trying to process subparts\n"); 1.2995 +- l = GMIME_MULTIPART(part)->subparts; 1.2996 +- while (l) { 1.2997 +- process_message_callback(l->data, cbinfo); 1.2998 +- l = l->next; 1.2999 +- } 1.3000 ++ ast_log(LOG_WARNING, "Got unexpected GMIME_IS_MULTIPART, trying to process subparts\n"); 1.3001 ++ g_mime_multipart_foreach(GMIME_MULTIPART(part), process_message_callback, cbinfo); 1.3002 + } else if (GMIME_IS_PART(part)) { 1.3003 + const char *filename; 1.3004 + 1.3005 +Index: sounds/sounds.xml 1.3006 +--- sounds/sounds.xml.orig 2009-08-18 22:31:40.000000000 +0200 1.3007 ++++ sounds/sounds.xml 2010-07-24 11:12:31.000000000 +0200 1.3008 +@@ -4,9 +4,9 @@ 1.3009 + <member name="CORE-SOUNDS-EN-ULAW" displayname="English, mu-Law format"> 1.3010 + </member> 1.3011 + <member name="CORE-SOUNDS-EN-ALAW" displayname="English, a-Law format"> 1.3012 ++ <defaultenabled>yes</defaultenabled> 1.3013 + </member> 1.3014 + <member name="CORE-SOUNDS-EN-GSM" displayname="English, GSM format" > 1.3015 +- <defaultenabled>yes</defaultenabled> 1.3016 + </member> 1.3017 + <member name="CORE-SOUNDS-EN-G729" displayname="English, G.729 format"> 1.3018 + </member> 1.3019 +@@ -82,6 +82,7 @@ 1.3020 + <member name="EXTRA-SOUNDS-EN-ULAW" displayname="English, mu-Law format"> 1.3021 + </member> 1.3022 + <member name="EXTRA-SOUNDS-EN-ALAW" displayname="English, a-Law format"> 1.3023 ++ <defaultenabled>yes</defaultenabled> 1.3024 + </member> 1.3025 + <member name="EXTRA-SOUNDS-EN-GSM" displayname="English, GSM format" > 1.3026 + </member>