From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Mar 20 23:10:06 2007 Return-Path: X-Original-To: freebsd-ports-bugs@hub.freebsd.org Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 782AB16A402 for ; Tue, 20 Mar 2007 23:10:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 46DF413C468 for ; Tue, 20 Mar 2007 23:10:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l2KNA6MM072674 for ; Tue, 20 Mar 2007 23:10:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l2KNA6Bi072673; Tue, 20 Mar 2007 23:10:06 GMT (envelope-from gnats) Resent-Date: Tue, 20 Mar 2007 23:10:06 GMT Resent-Message-Id: <200703202310.l2KNA6Bi072673@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dan Lukes Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 993C816A401 for ; Tue, 20 Mar 2007 23:08:41 +0000 (UTC) (envelope-from dan@kulesh.obluda.cz) Received: from smtp1.kolej.mff.cuni.cz (smtp1.kolej.mff.cuni.cz [195.113.24.4]) by mx1.freebsd.org (Postfix) with ESMTP id 6F71813C458 for ; Tue, 20 Mar 2007 23:08:38 +0000 (UTC) (envelope-from dan@kulesh.obluda.cz) Received: from kulesh.obluda.cz (openvpn.ms.mff.cuni.cz [195.113.20.87]) by smtp1.kolej.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id l2KMokwG059872 for ; Tue, 20 Mar 2007 23:50:48 +0100 (CET) (envelope-from dan@kulesh.obluda.cz) Received: from kulesh.obluda.cz (localhost. [127.0.0.1]) by kulesh.obluda.cz (8.13.8/8.13.8) with ESMTP id l2KMokAC077111 for ; Tue, 20 Mar 2007 23:50:46 +0100 (CET) (envelope-from dan@kulesh.obluda.cz) Received: (from root@localhost) by kulesh.obluda.cz (8.13.8/8.13.8/Submit) id l2KMokuT077110; Tue, 20 Mar 2007 23:50:46 +0100 (CET) (envelope-from dan) Message-Id: <200703202250.l2KMokuT077110@kulesh.obluda.cz> Date: Tue, 20 Mar 2007 23:50:46 +0100 (CET) From: Dan Lukes To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: ports/110601: [ PATCH ] do you know net/asterisk 1.2.14, 15, 16 has been released ? X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dan Lukes List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Mar 2007 23:10:06 -0000 >Number: 110601 >Category: ports >Synopsis: [ PATCH ] do you know net/asterisk 1.2.14,15,16 has been released ? >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Mar 20 23:10:05 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Dan Lukes >Release: FreeBSD 6.2-STABLE i386 >Organization: Obludarium >Environment: >Description: port net/asterisk is 1.2.13 but current version is 1.2.16 >How-To-Repeat: N/A >Fix: 1. Remove files/patch-rtp.c (it's changes are in base sources already) 2. replace patch-Makefile patch-cdr::Makefile patch-channels::chan_sip.c patch-utils::Makefile in files/ 3. replace Makefile distinfo pkg-plist in port base dir 4. make decision: the recent EXTRA_PATCH incorporate codec negotiation extension This patch seems to be unmaintained - the latest version is for 1.2.12 I modified it for 1.2.16, but I did it without deep understanding the code of the patch. Althought it should work, it may not. If you decide the patch shall be included, add patch-zzz-asterisk-1.2.16.1-codec-negotiation-20070319 to files. This patch must be applied after all other patches, thus -zzz- in name. If you decide this unmaintained patch will not be supported anymore then don't add the file. Thank you for maintaining the port. The attached files follows: --- Makefile begins here --- # New ports collection makefile for: asterisk # Date created: 17 October 2003 # Whom: Maxim Sobolev # # $FreeBSD: ports/net/asterisk/Makefile,v 1.65 2007/02/23 22:51:11 mezz Exp $ # PORTNAME= asterisk PORTVERSION= 1.2.16 #PORTREVISION= 1 CATEGORIES= net MASTER_SITES= http://ftp.digium.com/pub/asterisk/ \ http://ftp.digium.com/pub/asterisk/old-releases/ # Originaly obtained from http://unofficial.portaone.com/~bamby/public/ #EXTRA_PATCHES= ${FILESDIR}/extra-asterisk-1.2.16.1-codec-negotiation-20070319 # ${PORTNAME}-1.2.4-${BRIVER}.patch.gz:bristuff # ${MASTER_SITE_LOCAL:S,$,:bristuff,} #PATCH_SITE_SUBDIR= fjoe/:bristuff #BRIVER= bristuff-0.3.0-PRE-1l MAINTAINER= sobomax@FreeBSD.org COMMENT= An Open Source PBX and telephony toolkit BUILD_DEPENDS= mpg123:${PORTSDIR}/audio/mpg123 LIB_DEPENDS= speex.1:${PORTSDIR}/audio/speex \ newt.51:${PORTSDIR}/devel/newt \ curl.4:${PORTSDIR}/ftp/curl RUN_DEPENDS= mpg123:${PORTSDIR}/audio/mpg123 ONLY_FOR_ARCHS= i386 sparc64 amd64 GNU_CONFIGURE= yes CONFIGURE_WRKSRC= ${WRKSRC}/editline USE_GMAKE= yes USE_BISON= yes USE_RC_SUBR= asterisk.sh MAKE_ENV= PTHREAD_CFLAGS="${PTHREAD_CFLAGS}" \ PTHREAD_LIBS="${PTHREAD_LIBS}" \ MKDIR="${MKDIR}" \ PWLIBDIR=${LOCALBASE}/share/pwlib \ OPENH323DIR=${LOCALBASE}/share/openh323 \ OSVERSION=${OSVERSION} \ CXX="${CXX}" PLIST_SUB= BRISTUFF="@comment " MAN8= asterisk.8 astgenkey.8 autosupport.8 safe_asterisk.8 .include .if ${ARCH} != "i386" WITHOUT_H323= 1 WITHOUT_ZAPTEL= 1 .endif .if defined(WITHOUT_H323) PLIST_SUB+= WITH_H323="@comment " .else LIB_DEPENDS+= pt_r.1:${PORTSDIR}/devel/pwlib\ h323_r.1:${PORTSDIR}/net/openh323 PLIST_SUB+= WITH_H323="" MAKE_ENV+= WITH_H323=1 .endif .if defined(WITHOUT_ZAPTEL) PLIST_SUB+= WITH_ZAPTEL="@comment " MAKE_ENV+= WITHOUT_ZAPTEL=1 .else BUILD_DEPENDS+= libpri>=1.2.0:${PORTSDIR}/misc/libpri \ ${LOCALBASE}/include/zaptel.h:${PORTSDIR}/misc/zaptel LIB_DEPENDS+= pri.1:${PORTSDIR}/misc/libpri RUN_DEPENDS+= ${LOCALBASE}/include/zaptel.h:${PORTSDIR}/misc/zaptel PLIST_SUB+= WITH_ZAPTEL="" MAKE_ENV+= WITH_ZAPTEL=1 .endif # # WITH_FREETDS, WITH_PGSQL and WITH_SQLITE can also be added to MAKE_ENV # similarly .if defined(WITHOUT_ODBC) PLIST_SUB+= WITH_ODBC="@comment " .else LIB_DEPENDS+= odbc.1:${PORTSDIR}/databases/unixODBC PLIST_SUB+= WITH_ODBC="" MAKE_ENV+= WITH_ODBC=1 .endif .if defined(WITHOUT_FAX) PLIST_SUB+= WITH_FAX="@comment " .else MAKE_ENV+= WITH_FAX=1 LIB_DEPENDS+= spandsp.0:${PORTSDIR}/comms/spandsp PLIST_SUB+= WITH_FAX="" .endif .if ${OSVERSION} >= 500036 PLIST_SUB+= NEWGCC="" .else PLIST_SUB+= NEWGCC="@comment " .endif post-patch: ${REINPLACE_CMD} -e 's|/var/lib|${PREFIX}/share|g' ${WRKSRC}/configs/musiconhold.conf.sample .include --- Makefile ends here --- --- distinfo begins here --- MD5 (asterisk-1.2.16.tar.gz) = 88cfcd5c3b2a8f2504e561cb93546299 SHA256 (asterisk-1.2.16.tar.gz) = cc70d2ff8a2cafe3c7cce10dc5e90146111bc686ed6e08fc753e950c7050611e SIZE (asterisk-1.2.16.tar.gz) = 10612921 --- distinfo ends here --- --- pkg-plist begins here --- @unexec if cmp -s %D/etc/asterisk/adsi.conf %D/etc/asterisk/adsi.conf-dist; then rm -f %D/etc/asterisk/adsi.conf; fi etc/asterisk/adsi.conf-dist @exec [ -f %B/adsi.conf ] || cp %B/%f %B/adsi.conf @unexec if cmp -s %D/etc/asterisk/adtranvofr.conf %D/etc/asterisk/adtranvofr.conf-dist; then rm -f %D/etc/asterisk/adtranvofr.conf; fi etc/asterisk/adtranvofr.conf-dist @exec [ -f %B/adtranvofr.conf ] || cp %B/%f %B/adtranvofr.conf @unexec if cmp -s %D/etc/asterisk/agents.conf %D/etc/asterisk/agents.conf-dist; then rm -f %D/etc/asterisk/agents.conf; fi etc/asterisk/agents.conf-dist @exec [ -f %B/agents.conf ] || cp %B/%f %B/agents.conf @unexec if cmp -s %D/etc/asterisk/alarmreceiver.conf %D/etc/asterisk/alarmreceiver.conf-dist; then rm -f %D/etc/asterisk/alarmreceiver.conf; fi etc/asterisk/alarmreceiver.conf-dist @exec [ -f %B/alarmreceiver.conf ] || cp %B/%f %B/alarmreceiver.conf @unexec if cmp -s %D/etc/asterisk/alsa.conf %D/etc/asterisk/alsa.conf-dist; then rm -f %D/etc/asterisk/alsa.conf; fi etc/asterisk/alsa.conf-dist @exec [ -f %B/alsa.conf ] || cp %B/%f %B/alsa.conf @unexec if cmp -s %D/etc/asterisk/asterisk.adsi %D/etc/asterisk/asterisk.adsi-dist; then rm -f %D/etc/asterisk/asterisk.adsi; fi etc/asterisk/asterisk.adsi-dist @exec [ -f %B/asterisk.adsi ] || cp %B/%f %B/asterisk.adsi @unexec if cmp -s %D/etc/asterisk/asterisk.conf %D/etc/asterisk/asterisk.conf-dist; then rm -f %D/etc/asterisk/asterisk.conf; fi etc/asterisk/asterisk.conf-dist @exec [ -f %B/asterisk.conf ] || cp %B/%f %B/asterisk.conf %%BRISTUFF%%@unexec if cmp -s %D/etc/asterisk/capi.conf %D/etc/asterisk/capi.conf-dist; then rm -f %D/etc/asterisk/capi.conf; fi %%BRISTUFF%%etc/asterisk/capi.conf-dist %%BRISTUFF%%@exec [ -f %B/capi.conf ] || cp %B/%f %B/capi.conf @unexec if cmp -s %D/etc/asterisk/cdr.conf %D/etc/asterisk/cdr.conf-dist; then rm -f %D/etc/asterisk/cdr.conf; fi etc/asterisk/cdr.conf-dist @exec [ -f %B/cdr.conf ] || cp %B/%f %B/cdr.conf @unexec if cmp -s %D/etc/asterisk/cdr_custom.conf %D/etc/asterisk/cdr_custom.conf-dist; then rm -f %D/etc/asterisk/cdr_custom.conf; fi etc/asterisk/cdr_custom.conf-dist @exec [ -f %B/cdr_custom.conf ] || cp %B/%f %B/cdr_custom.conf @unexec if cmp -s %D/etc/asterisk/cdr_manager.conf %D/etc/asterisk/cdr_manager.conf-dist; then rm -f %D/etc/asterisk/cdr_manager.conf; fi etc/asterisk/cdr_manager.conf-dist @exec [ -f %B/cdr_manager.conf ] || cp %B/%f %B/cdr_manager.conf @unexec if cmp -s %D/etc/asterisk/cdr_odbc.conf %D/etc/asterisk/cdr_odbc.conf-dist; then rm -f %D/etc/asterisk/cdr_odbc.conf; fi etc/asterisk/cdr_odbc.conf-dist @exec [ -f %B/cdr_odbc.conf ] || cp %B/%f %B/cdr_odbc.conf @unexec if cmp -s %D/etc/asterisk/cdr_pgsql.conf %D/etc/asterisk/cdr_pgsql.conf-dist; then rm -f %D/etc/asterisk/cdr_pgsql.conf; fi etc/asterisk/cdr_pgsql.conf-dist @exec [ -f %B/cdr_pgsql.conf ] || cp %B/%f %B/cdr_pgsql.conf @unexec if cmp -s %D/etc/asterisk/cdr_tds.conf %D/etc/asterisk/cdr_tds.conf-dist; then rm -f %D/etc/asterisk/cdr_tds.conf; fi etc/asterisk/cdr_tds.conf-dist @exec [ -f %B/cdr_tds.conf ] || cp %B/%f %B/cdr_tds.conf @unexec if cmp -s %D/etc/asterisk/codecs.conf %D/etc/asterisk/codecs.conf-dist; then rm -f %D/etc/asterisk/codecs.conf; fi etc/asterisk/codecs.conf-dist @exec [ -f %B/codecs.conf ] || cp %B/%f %B/codecs.conf @unexec if cmp -s %D/etc/asterisk/dnsmgr.conf %D/etc/asterisk/dnsmgr.conf-dist; then rm -f %D/etc/asterisk/dnsmgr.conf; fi etc/asterisk/dnsmgr.conf-dist @exec [ -f %B/dnsmgr.conf ] || cp %B/%f %B/dnsmgr.conf @unexec if cmp -s %D/etc/asterisk/dundi.conf %D/etc/asterisk/dundi.conf-dist; then rm -f %D/etc/asterisk/dundi.conf; fi etc/asterisk/dundi.conf-dist @exec [ -f %B/dundi.conf ] || cp %B/%f %B/dundi.conf @unexec if cmp -s %D/etc/asterisk/enum.conf %D/etc/asterisk/enum.conf-dist; then rm -f %D/etc/asterisk/enum.conf; fi etc/asterisk/enum.conf-dist @exec [ -f %B/enum.conf ] || cp %B/%f %B/enum.conf @unexec if cmp -s %D/etc/asterisk/extconfig.conf %D/etc/asterisk/extconfig.conf-dist; then rm -f %D/etc/asterisk/extconfig.conf; fi etc/asterisk/extconfig.conf-dist @exec [ -f %B/extconfig.conf ] || cp %B/%f %B/extconfig.conf @unexec if cmp -s %D/etc/asterisk/extensions.ael %D/etc/asterisk/extensions.ael-dist; then rm -f %D/etc/asterisk/extensions.ael; fi etc/asterisk/extensions.ael-dist @exec [ -f %B/extensions.ael ] || cp %B/%f %B/extensions.ael @unexec if cmp -s %D/etc/asterisk/extensions.conf %D/etc/asterisk/extensions.conf-dist; then rm -f %D/etc/asterisk/extensions.conf; fi etc/asterisk/extensions.conf-dist @exec [ -f %B/extensions.conf ] || cp %B/%f %B/extensions.conf @unexec if cmp -s %D/etc/asterisk/features.conf %D/etc/asterisk/features.conf-dist; then rm -f %D/etc/asterisk/features.conf; fi etc/asterisk/features.conf-dist @exec [ -f %B/features.conf ] || cp %B/%f %B/features.conf @unexec if cmp -s %D/etc/asterisk/festival.conf %D/etc/asterisk/festival.conf-dist; then rm -f %D/etc/asterisk/festival.conf; fi etc/asterisk/festival.conf-dist @exec [ -f %B/festival.conf ] || cp %B/%f %B/festival.conf @unexec if cmp -s %D/etc/asterisk/iax.conf %D/etc/asterisk/iax.conf-dist; then rm -f %D/etc/asterisk/iax.conf; fi etc/asterisk/iax.conf-dist @exec [ -f %B/iax.conf ] || cp %B/%f %B/iax.conf @unexec if cmp -s %D/etc/asterisk/iaxprov.conf %D/etc/asterisk/iaxprov.conf-dist; then rm -f %D/etc/asterisk/iaxprov.conf; fi etc/asterisk/iaxprov.conf-dist @exec [ -f %B/iaxprov.conf ] || cp %B/%f %B/iaxprov.conf @unexec if cmp -s %D/etc/asterisk/indications.conf %D/etc/asterisk/indications.conf-dist; then rm -f %D/etc/asterisk/indications.conf; fi etc/asterisk/indications.conf-dist @exec [ -f %B/indications.conf ] || cp %B/%f %B/indications.conf @unexec if cmp -s %D/etc/asterisk/logger.conf %D/etc/asterisk/logger.conf-dist; then rm -f %D/etc/asterisk/logger.conf; fi etc/asterisk/logger.conf-dist @exec [ -f %B/logger.conf ] || cp %B/%f %B/logger.conf @unexec if cmp -s %D/etc/asterisk/manager.conf %D/etc/asterisk/manager.conf-dist; then rm -f %D/etc/asterisk/manager.conf; fi etc/asterisk/manager.conf-dist @exec [ -f %B/manager.conf ] || cp %B/%f %B/manager.conf @unexec if cmp -s %D/etc/asterisk/meetme.conf %D/etc/asterisk/meetme.conf-dist; then rm -f %D/etc/asterisk/meetme.conf; fi etc/asterisk/meetme.conf-dist @exec [ -f %B/meetme.conf ] || cp %B/%f %B/meetme.conf @unexec if cmp -s %D/etc/asterisk/mgcp.conf %D/etc/asterisk/mgcp.conf-dist; then rm -f %D/etc/asterisk/mgcp.conf; fi etc/asterisk/mgcp.conf-dist @exec [ -f %B/mgcp.conf ] || cp %B/%f %B/mgcp.conf @unexec if cmp -s %D/etc/asterisk/misdn.conf %D/etc/asterisk/misdn.conf-dist; then rm -f %D/etc/asterisk/misdn.conf; fi etc/asterisk/misdn.conf-dist @exec [ -f %B/misdn.conf ] || cp %B/%f %B/misdn.conf @unexec if cmp -s %D/etc/asterisk/modem.conf %D/etc/asterisk/modem.conf-dist; then rm -f %D/etc/asterisk/modem.conf; fi etc/asterisk/modem.conf-dist @exec [ -f %B/modem.conf ] || cp %B/%f %B/modem.conf @unexec if cmp -s %D/etc/asterisk/modules.conf %D/etc/asterisk/modules.conf-dist; then rm -f %D/etc/asterisk/modules.conf; fi etc/asterisk/modules.conf-dist @exec [ -f %B/modules.conf ] || cp %B/%f %B/modules.conf @unexec if cmp -s %D/etc/asterisk/musiconhold.conf %D/etc/asterisk/musiconhold.conf-dist; then rm -f %D/etc/asterisk/musiconhold.conf; fi etc/asterisk/musiconhold.conf-dist @exec [ -f %B/musiconhold.conf ] || cp %B/%f %B/musiconhold.conf @unexec if cmp -s %D/etc/asterisk/osp.conf %D/etc/asterisk/osp.conf-dist; then rm -f %D/etc/asterisk/osp.conf; fi etc/asterisk/osp.conf-dist @exec [ -f %B/osp.conf ] || cp %B/%f %B/osp.conf @unexec if cmp -s %D/etc/asterisk/oss.conf %D/etc/asterisk/oss.conf-dist; then rm -f %D/etc/asterisk/oss.conf; fi etc/asterisk/oss.conf-dist @exec [ -f %B/oss.conf ] || cp %B/%f %B/oss.conf @unexec if cmp -s %D/etc/asterisk/phone.conf %D/etc/asterisk/phone.conf-dist; then rm -f %D/etc/asterisk/phone.conf; fi etc/asterisk/phone.conf-dist @exec [ -f %B/phone.conf ] || cp %B/%f %B/phone.conf @unexec if cmp -s %D/etc/asterisk/privacy.conf %D/etc/asterisk/privacy.conf-dist; then rm -f %D/etc/asterisk/privacy.conf; fi etc/asterisk/privacy.conf-dist @exec [ -f %B/privacy.conf ] || cp %B/%f %B/privacy.conf @unexec if cmp -s %D/etc/asterisk/queues.conf %D/etc/asterisk/queues.conf-dist; then rm -f %D/etc/asterisk/queues.conf; fi etc/asterisk/queues.conf-dist @exec [ -f %B/queues.conf ] || cp %B/%f %B/queues.conf @unexec if cmp -s %D/etc/asterisk/res_odbc.conf %D/etc/asterisk/res_odbc.conf-dist; then rm -f %D/etc/asterisk/res_odbc.conf; fi etc/asterisk/res_odbc.conf-dist @exec [ -f %B/res_odbc.conf ] || cp %B/%f %B/res_odbc.conf @unexec if cmp -s %D/etc/asterisk/rpt.conf %D/etc/asterisk/rpt.conf-dist; then rm -f %D/etc/asterisk/rpt.conf; fi etc/asterisk/rpt.conf-dist @exec [ -f %B/rpt.conf ] || cp %B/%f %B/rpt.conf @unexec if cmp -s %D/etc/asterisk/rtp.conf %D/etc/asterisk/rtp.conf-dist; then rm -f %D/etc/asterisk/rtp.conf; fi etc/asterisk/rtp.conf-dist @exec [ -f %B/rtp.conf ] || cp %B/%f %B/rtp.conf @unexec if cmp -s %D/etc/asterisk/sip.conf %D/etc/asterisk/sip.conf-dist; then rm -f %D/etc/asterisk/sip.conf; fi etc/asterisk/sip.conf-dist @exec [ -f %B/sip.conf ] || cp %B/%f %B/sip.conf @unexec if cmp -s %D/etc/asterisk/sip_notify.conf %D/etc/asterisk/sip_notify.conf-dist; then rm -f %D/etc/asterisk/sip_notify.conf; fi etc/asterisk/sip_notify.conf-dist @exec [ -f %B/sip_notify.conf ] || cp %B/%f %B/sip_notify.conf @unexec if cmp -s %D/etc/asterisk/skinny.conf %D/etc/asterisk/skinny.conf-dist; then rm -f %D/etc/asterisk/skinny.conf; fi etc/asterisk/skinny.conf-dist @exec [ -f %B/skinny.conf ] || cp %B/%f %B/skinny.conf @unexec if cmp -s %D/etc/asterisk/telcordia-1.adsi %D/etc/asterisk/telcordia-1.adsi-dist; then rm -f %D/etc/asterisk/telcordia-1.adsi; fi etc/asterisk/telcordia-1.adsi-dist @exec [ -f %B/telcordia-1.adsi ] || cp %B/%f %B/telcordia-1.adsi @unexec if cmp -s %D/etc/asterisk/voicemail.conf %D/etc/asterisk/voicemail.conf-dist; then rm -f %D/etc/asterisk/voicemail.conf; fi etc/asterisk/voicemail.conf-dist @exec [ -f %B/voicemail.conf ] || cp %B/%f %B/voicemail.conf @unexec if cmp -s %D/etc/asterisk/vpb.conf %D/etc/asterisk/vpb.conf-dist; then rm -f %D/etc/asterisk/vpb.conf; fi etc/asterisk/vpb.conf-dist @exec [ -f %B/vpb.conf ] || cp %B/%f %B/vpb.conf %%BRISTUFF%%@unexec if cmp -s %D/etc/asterisk/watchdog.conf %D/etc/asterisk/watchdog.conf-dist; then rm -f %D/etc/asterisk/watchdog.conf; fi %%BRISTUFF%%etc/asterisk/watchdog.conf-dist %%BRISTUFF%%@exec [ -f %B/watchdog.conf ] || cp %B/%f %B/watchdog.conf @unexec if cmp -s %D/etc/asterisk/zapata.conf %D/etc/asterisk/zapata.conf-dist; then rm -f %D/etc/asterisk/zapata.conf; fi etc/asterisk/zapata.conf-dist @exec [ -f %B/zapata.conf ] || cp %B/%f %B/zapata.conf include/asterisk/acl.h include/asterisk/adsi.h include/asterisk/aes.h include/asterisk/agi.h include/asterisk/alaw.h include/asterisk/app.h include/asterisk/ast_expr.h include/asterisk/astdb.h include/asterisk/astmm.h include/asterisk/astobj.h include/asterisk/astosp.h include/asterisk/build.h include/asterisk/callerid.h include/asterisk/causes.h include/asterisk/cdr.h %%BRISTUFF%%include/asterisk/chan_capi.h %%BRISTUFF%%include/asterisk/chan_capi_app.h include/asterisk/channel.h include/asterisk/chanspy.h include/asterisk/chanvars.h include/asterisk/cli.h include/asterisk/compat.h include/asterisk/compiler.h include/asterisk/config.h include/asterisk/crypto.h include/asterisk/devicestate.h include/asterisk/dlfcn-compat.h include/asterisk/dns.h include/asterisk/dnsmgr.h include/asterisk/doxyref.h include/asterisk/dsp.h include/asterisk/dundi.h include/asterisk/endian.h include/asterisk/enum.h include/asterisk/features.h include/asterisk/file.h include/asterisk/frame.h include/asterisk/fskmodem.h include/asterisk/image.h include/asterisk/indications.h include/asterisk/inline_api.h include/asterisk/io.h include/asterisk/linkedlists.h include/asterisk/localtime.h include/asterisk/lock.h include/asterisk/logger.h include/asterisk/manager.h include/asterisk/md5.h include/asterisk/module.h include/asterisk/monitor.h include/asterisk/musiconhold.h include/asterisk/netsock.h include/asterisk/options.h include/asterisk/pbx.h include/asterisk/plc.h include/asterisk/poll-compat.h include/asterisk/privacy.h include/asterisk/res_odbc.h include/asterisk/rtp.h include/asterisk/say.h include/asterisk/sched.h include/asterisk/slinfactory.h include/asterisk/srv.h include/asterisk/strings.h include/asterisk/tdd.h include/asterisk/term.h include/asterisk/time.h include/asterisk/transcap.h include/asterisk/translate.h include/asterisk/ulaw.h include/asterisk/unaligned.h include/asterisk/utils.h include/asterisk/version.h include/asterisk/vmodem.h %%BRISTUFF%%include/asterisk/xlaw.h lib/asterisk/modules/app_adsiprog.so lib/asterisk/modules/app_alarmreceiver.so lib/asterisk/modules/app_authenticate.so %%BRISTUFF%%lib/asterisk/modules/app_callingpres.so lib/asterisk/modules/app_cdr.so lib/asterisk/modules/app_chanisavail.so lib/asterisk/modules/app_chanspy.so lib/asterisk/modules/app_controlplayback.so lib/asterisk/modules/app_curl.so lib/asterisk/modules/app_cut.so lib/asterisk/modules/app_db.so %%BRISTUFF%%lib/asterisk/modules/app_devstate.so lib/asterisk/modules/app_dial.so lib/asterisk/modules/app_dictate.so lib/asterisk/modules/app_directed_pickup.so lib/asterisk/modules/app_directory.so lib/asterisk/modules/app_disa.so lib/asterisk/modules/app_dumpchan.so lib/asterisk/modules/app_echo.so lib/asterisk/modules/app_enumlookup.so lib/asterisk/modules/app_eval.so lib/asterisk/modules/app_exec.so lib/asterisk/modules/app_externalivr.so lib/asterisk/modules/app_festival.so %%WITH_ZAPTEL%%lib/asterisk/modules/app_flash.so lib/asterisk/modules/app_forkcdr.so lib/asterisk/modules/app_getcpeid.so lib/asterisk/modules/app_groupcount.so lib/asterisk/modules/app_hasnewvoicemail.so lib/asterisk/modules/app_ices.so lib/asterisk/modules/app_image.so lib/asterisk/modules/app_lookupblacklist.so lib/asterisk/modules/app_lookupcidname.so lib/asterisk/modules/app_macro.so lib/asterisk/modules/app_math.so lib/asterisk/modules/app_md5.so %%WITH_ZAPTEL%%lib/asterisk/modules/app_meetme.so lib/asterisk/modules/app_milliwatt.so lib/asterisk/modules/app_mixmonitor.so lib/asterisk/modules/app_mp3.so lib/asterisk/modules/app_nbscat.so %%WITH_ZAPTEL%%lib/asterisk/modules/app_page.so lib/asterisk/modules/app_parkandannounce.so %%BRISTUFF%%lib/asterisk/modules/app_pickup.so lib/asterisk/modules/app_playback.so lib/asterisk/modules/app_privacy.so lib/asterisk/modules/app_queue.so lib/asterisk/modules/app_random.so lib/asterisk/modules/app_read.so lib/asterisk/modules/app_readfile.so lib/asterisk/modules/app_realtime.so lib/asterisk/modules/app_record.so %%WITH_FAX%%lib/asterisk/modules/app_rxfax.so lib/asterisk/modules/app_sayunixtime.so %%BRISTUFF%%lib/asterisk/modules/app_segfault.so lib/asterisk/modules/app_senddtmf.so lib/asterisk/modules/app_sendtext.so lib/asterisk/modules/app_setcallerid.so lib/asterisk/modules/app_setcdruserfield.so lib/asterisk/modules/app_setcidname.so lib/asterisk/modules/app_setcidnum.so lib/asterisk/modules/app_setrdnis.so lib/asterisk/modules/app_settransfercapability.so lib/asterisk/modules/app_sms.so lib/asterisk/modules/app_softhangup.so lib/asterisk/modules/app_stack.so lib/asterisk/modules/app_system.so lib/asterisk/modules/app_talkdetect.so lib/asterisk/modules/app_test.so lib/asterisk/modules/app_transfer.so %%WITH_FAX%%lib/asterisk/modules/app_txfax.so lib/asterisk/modules/app_txtcidname.so lib/asterisk/modules/app_url.so lib/asterisk/modules/app_userevent.so lib/asterisk/modules/app_verbose.so lib/asterisk/modules/app_voicemail.so lib/asterisk/modules/app_waitforring.so lib/asterisk/modules/app_waitforsilence.so lib/asterisk/modules/app_while.so lib/asterisk/modules/app_zapateller.so %%WITH_ZAPTEL%%lib/asterisk/modules/app_zapbarge.so %%WITH_ZAPTEL%%lib/asterisk/modules/app_zapras.so %%WITH_ZAPTEL%%lib/asterisk/modules/app_zapscan.so lib/asterisk/modules/cdr_csv.so lib/asterisk/modules/cdr_custom.so lib/asterisk/modules/cdr_manager.so %%WITH_ODBC%%lib/asterisk/modules/cdr_odbc.so lib/asterisk/modules/cdr_tds.so lib/asterisk/modules/chan_agent.so lib/asterisk/modules/chan_features.so %%WITH_H323%%lib/asterisk/modules/chan_h323.so lib/asterisk/modules/chan_iax2.so lib/asterisk/modules/chan_local.so lib/asterisk/modules/chan_mgcp.so lib/asterisk/modules/chan_oss.so lib/asterisk/modules/chan_sip.so lib/asterisk/modules/chan_skinny.so %%WITH_ZAPTEL%%lib/asterisk/modules/chan_zap.so lib/asterisk/modules/codec_a_mu.so lib/asterisk/modules/codec_adpcm.so lib/asterisk/modules/codec_alaw.so lib/asterisk/modules/codec_g726.so lib/asterisk/modules/codec_gsm.so lib/asterisk/modules/codec_ilbc.so lib/asterisk/modules/codec_lpc10.so lib/asterisk/modules/codec_speex.so lib/asterisk/modules/codec_ulaw.so lib/asterisk/modules/format_au.so lib/asterisk/modules/format_g723_1.so lib/asterisk/modules/format_g726.so lib/asterisk/modules/format_g729.so lib/asterisk/modules/format_gsm.so lib/asterisk/modules/format_h263.so lib/asterisk/modules/format_ilbc.so lib/asterisk/modules/format_jpeg.so lib/asterisk/modules/format_pcm.so lib/asterisk/modules/format_pcm_alaw.so lib/asterisk/modules/format_sln.so lib/asterisk/modules/format_vox.so lib/asterisk/modules/format_wav.so lib/asterisk/modules/format_wav_gsm.so lib/asterisk/modules/func_callerid.so lib/asterisk/modules/func_enum.so lib/asterisk/modules/func_uri.so lib/asterisk/modules/pbx_ael.so lib/asterisk/modules/pbx_config.so lib/asterisk/modules/pbx_dundi.so lib/asterisk/modules/pbx_functions.so lib/asterisk/modules/pbx_loopback.so lib/asterisk/modules/pbx_realtime.so lib/asterisk/modules/pbx_spool.so lib/asterisk/modules/res_adsi.so lib/asterisk/modules/res_agi.so %%WITH_ODBC%%lib/asterisk/modules/res_config_odbc.so lib/asterisk/modules/res_crypto.so lib/asterisk/modules/res_features.so lib/asterisk/modules/res_indications.so lib/asterisk/modules/res_monitor.so lib/asterisk/modules/res_musiconhold.so %%WITH_ODBC%%lib/asterisk/modules/res_odbc.so %%BRISTUFF%%lib/asterisk/modules/res_watchdog.so sbin/asterisk sbin/astgenkey sbin/astman sbin/autosupport sbin/rasterisk sbin/safe_asterisk sbin/smsq sbin/stereorize sbin/streamplayer %%DATADIR%%/agi-bin/agi-test.agi %%DATADIR%%/agi-bin/eagi-sphinx-test %%DATADIR%%/agi-bin/eagi-test %%BRISTUFF%%%%DATADIR%%/agi-bin/xagi-test %%DATADIR%%/firmware/iax/iaxy.bin %%DATADIR%%/images/asterisk-intro.jpg %%DATADIR%%/keys/freeworlddialup.pub %%DATADIR%%/keys/iaxtel.pub %%DATADIR%%/mohmp3/fpm-calm-river.mp3 %%DATADIR%%/mohmp3/fpm-sunshine.mp3 %%DATADIR%%/mohmp3/fpm-world-mix.mp3 %%DATADIR%%/sounds/agent-alreadyon.gsm %%DATADIR%%/sounds/agent-incorrect.gsm %%DATADIR%%/sounds/agent-loggedoff.gsm %%DATADIR%%/sounds/agent-loginok.gsm %%DATADIR%%/sounds/agent-newlocation.gsm %%DATADIR%%/sounds/agent-pass.gsm %%DATADIR%%/sounds/agent-user.gsm %%DATADIR%%/sounds/auth-incorrect.gsm %%DATADIR%%/sounds/auth-thankyou.gsm %%DATADIR%%/sounds/beep.gsm %%DATADIR%%/sounds/beeperr.gsm %%DATADIR%%/sounds/conf-adminmenu.gsm %%DATADIR%%/sounds/conf-enteringno.gsm %%DATADIR%%/sounds/conf-errormenu.gsm %%DATADIR%%/sounds/conf-getchannel.gsm %%DATADIR%%/sounds/conf-getconfno.gsm %%DATADIR%%/sounds/conf-getpin.gsm %%DATADIR%%/sounds/conf-hasjoin.gsm %%DATADIR%%/sounds/conf-hasleft.gsm %%DATADIR%%/sounds/conf-invalid.gsm %%DATADIR%%/sounds/conf-invalidpin.gsm %%DATADIR%%/sounds/conf-kicked.gsm %%DATADIR%%/sounds/conf-leaderhasleft.gsm %%DATADIR%%/sounds/conf-locked.gsm %%DATADIR%%/sounds/conf-lockednow.gsm %%DATADIR%%/sounds/conf-muted.gsm %%DATADIR%%/sounds/conf-noempty.gsm %%DATADIR%%/sounds/conf-onlyone.gsm %%DATADIR%%/sounds/conf-onlyperson.gsm %%DATADIR%%/sounds/conf-otherinparty.gsm %%DATADIR%%/sounds/conf-placeintoconf.gsm %%DATADIR%%/sounds/conf-thereare.gsm %%DATADIR%%/sounds/conf-unlockednow.gsm %%DATADIR%%/sounds/conf-unmuted.gsm %%DATADIR%%/sounds/conf-usermenu.gsm %%DATADIR%%/sounds/conf-userswilljoin.gsm %%DATADIR%%/sounds/conf-userwilljoin.gsm %%DATADIR%%/sounds/conf-waitforleader.gsm %%DATADIR%%/sounds/demo-abouttotry.gsm %%DATADIR%%/sounds/demo-congrats.gsm %%DATADIR%%/sounds/demo-echodone.gsm %%DATADIR%%/sounds/demo-echotest.gsm %%DATADIR%%/sounds/demo-enterkeywords.gsm %%DATADIR%%/sounds/demo-instruct.gsm %%DATADIR%%/sounds/demo-moreinfo.gsm %%DATADIR%%/sounds/demo-nogo.gsm %%DATADIR%%/sounds/demo-nomatch.gsm %%DATADIR%%/sounds/demo-thanks.gsm %%DATADIR%%/sounds/dictate/both_help.gsm %%DATADIR%%/sounds/dictate/enter_filename.gsm %%DATADIR%%/sounds/dictate/forhelp.gsm %%DATADIR%%/sounds/dictate/pause.gsm %%DATADIR%%/sounds/dictate/paused.gsm %%DATADIR%%/sounds/dictate/play_help.gsm %%DATADIR%%/sounds/dictate/playback.gsm %%DATADIR%%/sounds/dictate/playback_mode.gsm %%DATADIR%%/sounds/dictate/record.gsm %%DATADIR%%/sounds/dictate/record_help.gsm %%DATADIR%%/sounds/dictate/record_mode.gsm %%DATADIR%%/sounds/dictate/truncating_audio.gsm %%DATADIR%%/sounds/digits/0.gsm %%DATADIR%%/sounds/digits/1.gsm %%DATADIR%%/sounds/digits/10.gsm %%DATADIR%%/sounds/digits/11.gsm %%DATADIR%%/sounds/digits/12.gsm %%DATADIR%%/sounds/digits/13.gsm %%DATADIR%%/sounds/digits/14.gsm %%DATADIR%%/sounds/digits/15.gsm %%DATADIR%%/sounds/digits/16.gsm %%DATADIR%%/sounds/digits/17.gsm %%DATADIR%%/sounds/digits/18.gsm %%DATADIR%%/sounds/digits/19.gsm %%DATADIR%%/sounds/digits/2.gsm %%DATADIR%%/sounds/digits/20.gsm %%DATADIR%%/sounds/digits/3.gsm %%DATADIR%%/sounds/digits/30.gsm %%DATADIR%%/sounds/digits/4.gsm %%DATADIR%%/sounds/digits/40.gsm %%DATADIR%%/sounds/digits/5.gsm %%DATADIR%%/sounds/digits/50.gsm %%DATADIR%%/sounds/digits/6.gsm %%DATADIR%%/sounds/digits/60.gsm %%DATADIR%%/sounds/digits/7.gsm %%DATADIR%%/sounds/digits/70.gsm %%DATADIR%%/sounds/digits/8.gsm %%DATADIR%%/sounds/digits/80.gsm %%DATADIR%%/sounds/digits/9.gsm %%DATADIR%%/sounds/digits/90.gsm %%DATADIR%%/sounds/digits/a-m.gsm %%DATADIR%%/sounds/digits/at.gsm %%DATADIR%%/sounds/digits/day-0.gsm %%DATADIR%%/sounds/digits/day-1.gsm %%DATADIR%%/sounds/digits/day-2.gsm %%DATADIR%%/sounds/digits/day-3.gsm %%DATADIR%%/sounds/digits/day-4.gsm %%DATADIR%%/sounds/digits/day-5.gsm %%DATADIR%%/sounds/digits/day-6.gsm %%DATADIR%%/sounds/digits/dollars.gsm %%DATADIR%%/sounds/digits/h-1.gsm %%DATADIR%%/sounds/digits/h-10.gsm %%DATADIR%%/sounds/digits/h-11.gsm %%DATADIR%%/sounds/digits/h-12.gsm %%DATADIR%%/sounds/digits/h-13.gsm %%DATADIR%%/sounds/digits/h-14.gsm %%DATADIR%%/sounds/digits/h-15.gsm %%DATADIR%%/sounds/digits/h-16.gsm %%DATADIR%%/sounds/digits/h-17.gsm %%DATADIR%%/sounds/digits/h-18.gsm %%DATADIR%%/sounds/digits/h-19.gsm %%DATADIR%%/sounds/digits/h-2.gsm %%DATADIR%%/sounds/digits/h-20.gsm %%DATADIR%%/sounds/digits/h-3.gsm %%DATADIR%%/sounds/digits/h-30.gsm %%DATADIR%%/sounds/digits/h-4.gsm %%DATADIR%%/sounds/digits/h-5.gsm %%DATADIR%%/sounds/digits/h-6.gsm %%DATADIR%%/sounds/digits/h-7.gsm %%DATADIR%%/sounds/digits/h-8.gsm %%DATADIR%%/sounds/digits/h-9.gsm %%DATADIR%%/sounds/digits/hundred.gsm %%DATADIR%%/sounds/digits/million.gsm %%DATADIR%%/sounds/digits/minus.gsm %%DATADIR%%/sounds/digits/mon-0.gsm %%DATADIR%%/sounds/digits/mon-1.gsm %%DATADIR%%/sounds/digits/mon-10.gsm %%DATADIR%%/sounds/digits/mon-11.gsm %%DATADIR%%/sounds/digits/mon-2.gsm %%DATADIR%%/sounds/digits/mon-3.gsm %%DATADIR%%/sounds/digits/mon-4.gsm %%DATADIR%%/sounds/digits/mon-5.gsm %%DATADIR%%/sounds/digits/mon-6.gsm %%DATADIR%%/sounds/digits/mon-7.gsm %%DATADIR%%/sounds/digits/mon-8.gsm %%DATADIR%%/sounds/digits/mon-9.gsm %%DATADIR%%/sounds/digits/oclock.gsm %%DATADIR%%/sounds/digits/oh.gsm %%DATADIR%%/sounds/digits/p-m.gsm %%DATADIR%%/sounds/digits/pound.gsm %%DATADIR%%/sounds/digits/star.gsm %%DATADIR%%/sounds/digits/thousand.gsm %%DATADIR%%/sounds/digits/today.gsm %%DATADIR%%/sounds/digits/tomorrow.gsm %%DATADIR%%/sounds/digits/yesterday.gsm %%DATADIR%%/sounds/dir-instr.gsm %%DATADIR%%/sounds/dir-intro-fn.gsm %%DATADIR%%/sounds/dir-intro.gsm %%DATADIR%%/sounds/dir-nomatch.gsm %%DATADIR%%/sounds/dir-nomore.gsm %%DATADIR%%/sounds/hello-world.gsm %%DATADIR%%/sounds/hours.gsm %%DATADIR%%/sounds/invalid.gsm %%DATADIR%%/sounds/letters/a.gsm %%DATADIR%%/sounds/letters/at.gsm %%DATADIR%%/sounds/letters/b.gsm %%DATADIR%%/sounds/letters/c.gsm %%DATADIR%%/sounds/letters/d.gsm %%DATADIR%%/sounds/letters/dash.gsm %%DATADIR%%/sounds/letters/dollar.gsm %%DATADIR%%/sounds/letters/dot.gsm %%DATADIR%%/sounds/letters/e.gsm %%DATADIR%%/sounds/letters/equals.gsm %%DATADIR%%/sounds/letters/exclaimation-point.gsm %%DATADIR%%/sounds/letters/f.gsm %%DATADIR%%/sounds/letters/g.gsm %%DATADIR%%/sounds/letters/h.gsm %%DATADIR%%/sounds/letters/i.gsm %%DATADIR%%/sounds/letters/j.gsm %%DATADIR%%/sounds/letters/k.gsm %%DATADIR%%/sounds/letters/l.gsm %%DATADIR%%/sounds/letters/m.gsm %%DATADIR%%/sounds/letters/n.gsm %%DATADIR%%/sounds/letters/o.gsm %%DATADIR%%/sounds/letters/p.gsm %%DATADIR%%/sounds/letters/plus.gsm %%DATADIR%%/sounds/letters/q.gsm %%DATADIR%%/sounds/letters/r.gsm %%DATADIR%%/sounds/letters/s.gsm %%DATADIR%%/sounds/letters/slash.gsm %%DATADIR%%/sounds/letters/space.gsm %%DATADIR%%/sounds/letters/t.gsm %%DATADIR%%/sounds/letters/u.gsm %%DATADIR%%/sounds/letters/v.gsm %%DATADIR%%/sounds/letters/w.gsm %%DATADIR%%/sounds/letters/x.gsm %%DATADIR%%/sounds/letters/y.gsm %%DATADIR%%/sounds/letters/z.gsm %%DATADIR%%/sounds/letters/zed.gsm %%DATADIR%%/sounds/minutes.gsm %%DATADIR%%/sounds/pbx-invalid.gsm %%DATADIR%%/sounds/pbx-invalidpark.gsm %%DATADIR%%/sounds/pbx-transfer.gsm %%DATADIR%%/sounds/phonetic/9_p.gsm %%DATADIR%%/sounds/phonetic/a_p.gsm %%DATADIR%%/sounds/phonetic/b_p.gsm %%DATADIR%%/sounds/phonetic/c_p.gsm %%DATADIR%%/sounds/phonetic/d_p.gsm %%DATADIR%%/sounds/phonetic/e_p.gsm %%DATADIR%%/sounds/phonetic/f_p.gsm %%DATADIR%%/sounds/phonetic/g_p.gsm %%DATADIR%%/sounds/phonetic/h_p.gsm %%DATADIR%%/sounds/phonetic/i_p.gsm %%DATADIR%%/sounds/phonetic/j_p.gsm %%DATADIR%%/sounds/phonetic/k_p.gsm %%DATADIR%%/sounds/phonetic/l_p.gsm %%DATADIR%%/sounds/phonetic/m_p.gsm %%DATADIR%%/sounds/phonetic/n_p.gsm %%DATADIR%%/sounds/phonetic/o_p.gsm %%DATADIR%%/sounds/phonetic/p_p.gsm %%DATADIR%%/sounds/phonetic/q_p.gsm %%DATADIR%%/sounds/phonetic/r_p.gsm %%DATADIR%%/sounds/phonetic/s_p.gsm %%DATADIR%%/sounds/phonetic/t_p.gsm %%DATADIR%%/sounds/phonetic/u_p.gsm %%DATADIR%%/sounds/phonetic/v_p.gsm %%DATADIR%%/sounds/phonetic/w_p.gsm %%DATADIR%%/sounds/phonetic/x_p.gsm %%DATADIR%%/sounds/phonetic/y_p.gsm %%DATADIR%%/sounds/phonetic/z_p.gsm %%DATADIR%%/sounds/priv-callee-options.gsm %%DATADIR%%/sounds/priv-callpending.gsm %%DATADIR%%/sounds/priv-introsaved.gsm %%DATADIR%%/sounds/priv-recordintro.gsm %%DATADIR%%/sounds/privacy-incorrect.gsm %%DATADIR%%/sounds/privacy-prompt.gsm %%DATADIR%%/sounds/privacy-thankyou.gsm %%DATADIR%%/sounds/privacy-unident.gsm %%DATADIR%%/sounds/queue-callswaiting.gsm %%DATADIR%%/sounds/queue-holdtime.gsm %%DATADIR%%/sounds/queue-less-than.gsm %%DATADIR%%/sounds/queue-minutes.gsm %%DATADIR%%/sounds/queue-periodic-announce.gsm %%DATADIR%%/sounds/queue-reporthold.gsm %%DATADIR%%/sounds/queue-seconds.gsm %%DATADIR%%/sounds/queue-thankyou.gsm %%DATADIR%%/sounds/queue-thereare.gsm %%DATADIR%%/sounds/queue-youarenext.gsm %%DATADIR%%/sounds/screen-callee-options.gsm %%DATADIR%%/sounds/seconds.gsm %%DATADIR%%/sounds/silence/1.gsm %%DATADIR%%/sounds/silence/10.gsm %%DATADIR%%/sounds/silence/2.gsm %%DATADIR%%/sounds/silence/3.gsm %%DATADIR%%/sounds/silence/4.gsm %%DATADIR%%/sounds/silence/5.gsm %%DATADIR%%/sounds/silence/6.gsm %%DATADIR%%/sounds/silence/7.gsm %%DATADIR%%/sounds/silence/8.gsm %%DATADIR%%/sounds/silence/9.gsm %%DATADIR%%/sounds/spy-agent.gsm %%DATADIR%%/sounds/spy-h323.gsm %%DATADIR%%/sounds/spy-iax.gsm %%DATADIR%%/sounds/spy-iax2.gsm %%DATADIR%%/sounds/spy-mgcp.gsm %%DATADIR%%/sounds/spy-sip.gsm %%DATADIR%%/sounds/spy-skinny.gsm %%DATADIR%%/sounds/spy-zap.gsm %%DATADIR%%/sounds/ss-noservice.gsm %%DATADIR%%/sounds/transfer.gsm %%DATADIR%%/sounds/tt-allbusy.gsm %%DATADIR%%/sounds/tt-monkeys.gsm %%DATADIR%%/sounds/tt-monkeysintro.gsm %%DATADIR%%/sounds/tt-somethingwrong.gsm %%DATADIR%%/sounds/tt-weasels.gsm %%DATADIR%%/sounds/vm-Cust1.gsm %%DATADIR%%/sounds/vm-Cust2.gsm %%DATADIR%%/sounds/vm-Cust3.gsm %%DATADIR%%/sounds/vm-Cust4.gsm %%DATADIR%%/sounds/vm-Cust5.gsm %%DATADIR%%/sounds/vm-Family.gsm %%DATADIR%%/sounds/vm-Friends.gsm %%DATADIR%%/sounds/vm-INBOX.gsm %%DATADIR%%/sounds/vm-Old.gsm %%DATADIR%%/sounds/vm-Work.gsm %%DATADIR%%/sounds/vm-advopts.gsm %%DATADIR%%/sounds/vm-and.gsm %%DATADIR%%/sounds/vm-calldiffnum.gsm %%DATADIR%%/sounds/vm-changeto.gsm %%DATADIR%%/sounds/vm-delete.gsm %%DATADIR%%/sounds/vm-deleted.gsm %%DATADIR%%/sounds/vm-dialout.gsm %%DATADIR%%/sounds/vm-enter-num-to-call.gsm %%DATADIR%%/sounds/vm-extension.gsm %%DATADIR%%/sounds/vm-first.gsm %%DATADIR%%/sounds/vm-for.gsm %%DATADIR%%/sounds/vm-forward.gsm %%DATADIR%%/sounds/vm-forwardoptions.gsm %%DATADIR%%/sounds/vm-from-extension.gsm %%DATADIR%%/sounds/vm-from-phonenumber.gsm %%DATADIR%%/sounds/vm-from.gsm %%DATADIR%%/sounds/vm-goodbye.gsm %%DATADIR%%/sounds/vm-helpexit.gsm %%DATADIR%%/sounds/vm-incorrect-mailbox.gsm %%DATADIR%%/sounds/vm-incorrect.gsm %%DATADIR%%/sounds/vm-instructions.gsm %%DATADIR%%/sounds/vm-intro.gsm %%DATADIR%%/sounds/vm-isonphone.gsm %%DATADIR%%/sounds/vm-isunavail.gsm %%DATADIR%%/sounds/vm-last.gsm %%DATADIR%%/sounds/vm-leavemsg.gsm %%DATADIR%%/sounds/vm-login.gsm %%DATADIR%%/sounds/vm-mailboxfull.gsm %%DATADIR%%/sounds/vm-message.gsm %%DATADIR%%/sounds/vm-messages.gsm %%DATADIR%%/sounds/vm-minutes.gsm %%DATADIR%%/sounds/vm-mismatch.gsm %%DATADIR%%/sounds/vm-msginstruct.gsm %%DATADIR%%/sounds/vm-msgsaved.gsm %%DATADIR%%/sounds/vm-newpassword.gsm %%DATADIR%%/sounds/vm-newuser.gsm %%DATADIR%%/sounds/vm-next.gsm %%DATADIR%%/sounds/vm-no.gsm %%DATADIR%%/sounds/vm-nobodyavail.gsm %%DATADIR%%/sounds/vm-nobox.gsm %%DATADIR%%/sounds/vm-nomore.gsm %%DATADIR%%/sounds/vm-nonumber.gsm %%DATADIR%%/sounds/vm-num-i-have.gsm %%DATADIR%%/sounds/vm-onefor.gsm %%DATADIR%%/sounds/vm-options.gsm %%DATADIR%%/sounds/vm-opts.gsm %%DATADIR%%/sounds/vm-passchanged.gsm %%DATADIR%%/sounds/vm-password.gsm %%DATADIR%%/sounds/vm-press.gsm %%DATADIR%%/sounds/vm-prev.gsm %%DATADIR%%/sounds/vm-reachoper.gsm %%DATADIR%%/sounds/vm-rec-busy.gsm %%DATADIR%%/sounds/vm-rec-name.gsm %%DATADIR%%/sounds/vm-rec-temp.gsm %%DATADIR%%/sounds/vm-rec-unv.gsm %%DATADIR%%/sounds/vm-received.gsm %%DATADIR%%/sounds/vm-reenterpassword.gsm %%DATADIR%%/sounds/vm-repeat.gsm %%DATADIR%%/sounds/vm-review.gsm %%DATADIR%%/sounds/vm-saved.gsm %%DATADIR%%/sounds/vm-savedto.gsm %%DATADIR%%/sounds/vm-savefolder.gsm %%DATADIR%%/sounds/vm-savemessage.gsm %%DATADIR%%/sounds/vm-saveoper.gsm %%DATADIR%%/sounds/vm-sorry.gsm %%DATADIR%%/sounds/vm-star-cancel.gsm %%DATADIR%%/sounds/vm-starmain.gsm %%DATADIR%%/sounds/vm-tempgreeting.gsm %%DATADIR%%/sounds/vm-tempgreeting2.gsm %%DATADIR%%/sounds/vm-tempremoved.gsm %%DATADIR%%/sounds/vm-then-pound.gsm %%DATADIR%%/sounds/vm-theperson.gsm %%DATADIR%%/sounds/vm-tocallback.gsm %%DATADIR%%/sounds/vm-tocallnum.gsm %%DATADIR%%/sounds/vm-tocancel.gsm %%DATADIR%%/sounds/vm-tocancelmsg.gsm %%DATADIR%%/sounds/vm-toenternumber.gsm %%DATADIR%%/sounds/vm-toforward.gsm %%DATADIR%%/sounds/vm-tohearenv.gsm %%DATADIR%%/sounds/vm-tomakecall.gsm %%DATADIR%%/sounds/vm-tooshort.gsm %%DATADIR%%/sounds/vm-toreply.gsm %%DATADIR%%/sounds/vm-torerecord.gsm %%DATADIR%%/sounds/vm-undelete.gsm %%DATADIR%%/sounds/vm-undeleted.gsm %%DATADIR%%/sounds/vm-unknown-caller.gsm %%DATADIR%%/sounds/vm-whichbox.gsm %%DATADIR%%/sounds/vm-youhave.gsm @exec mkdir -p %%DATADIR%%/sounds/priv-callerintros @dirrm %%DATADIR%%/sounds/silence @dirrm %%DATADIR%%/sounds/priv-callerintros @dirrm %%DATADIR%%/sounds/phonetic @dirrm %%DATADIR%%/sounds/letters @dirrm %%DATADIR%%/sounds/digits @dirrm %%DATADIR%%/sounds/dictate @dirrm %%DATADIR%%/sounds @dirrm %%DATADIR%%/mohmp3 @dirrm %%DATADIR%%/keys @dirrm %%DATADIR%%/images @dirrm %%DATADIR%%/firmware/iax @dirrm %%DATADIR%%/firmware @dirrm %%DATADIR%%/agi-bin @dirrm %%DATADIR%% @dirrm lib/asterisk/modules @dirrm lib/asterisk @dirrm include/asterisk @dirrm etc/asterisk @cwd /var spool/asterisk/voicemail/default/1234/busy.gsm spool/asterisk/voicemail/default/1234/unavail.gsm @exec mkdir -p %D/log/asterisk/cdr-csv @exec mkdir -p %D/log/asterisk/cdr-custom @exec mkdir -p %D/spool/asterisk/voicemail/default/1234/INBOX @exec mkdir -p %D/spool/asterisk/dictate @exec mkdir -p %D/spool/asterisk/meetme @exec mkdir -p %D/spool/asterisk/monitor @exec mkdir -p %D/spool/asterisk/system @exec mkdir -p %D/spool/asterisk/tmp @dirrm spool/asterisk/dictate @dirrm spool/asterisk/meetme @dirrm spool/asterisk/monitor @dirrm spool/asterisk/system @dirrm spool/asterisk/voicemail/default/1234/INBOX @dirrm spool/asterisk/voicemail/default/1234 @dirrm spool/asterisk/voicemail/default @dirrm spool/asterisk/voicemail @dirrm spool/asterisk/tmp @dirrm spool/asterisk @dirrm log/asterisk/cdr-csv @dirrm log/asterisk/cdr-custom @dirrm log/asterisk --- pkg-plist ends here --- --- patch-Makefile begins here --- --- Makefile.orig Wed Jan 10 03:16:45 2007 +++ Makefile Mon Mar 19 19:39:45 2007 @@ -19,8 +19,8 @@ # CROSS_COMPILE=/opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be- # CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/ # CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target -CC=$(CROSS_COMPILE)gcc -HOST_CC=gcc +CC?=$(CROSS_COMPILE)gcc +HOST_CC=${CC} # CROSS_ARCH=Linux # CROSS_PROC=arm # SUB_PROC=xscale # or maverick @@ -47,14 +47,14 @@ #K6OPT = -DK6OPT #Tell gcc to optimize the code -OPTIMIZE+=-O6 +#OPTIMIZE+=-O6 endif #Overwite config files on "make samples" -OVERWRITE=y +OVERWRITE=n #Include debug and macro symbols in the executables (-g) and profiling info (-pg) -DEBUG=-g3 #-pg +#DEBUG=-g3 #-pg #Set NOCRYPTO to yes if you do not want to have crypto support or #dependencies @@ -88,7 +88,7 @@ # Where to install asterisk after compiling # Default -> leave empty -INSTALL_PREFIX?= +INSTALL_PREFIX=$(PREFIX) # Staging directory # Files are copied here temporarily during the install process @@ -111,17 +111,17 @@ BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE ifneq ($(OSARCH),SunOS) - ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk - ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk + ASTLIBDIR=$(INSTALL_PREFIX)/lib/asterisk + ASTVARLIBDIR=$(INSTALL_PREFIX)/share/asterisk ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk - ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk - ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk - ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk + ASTSPOOLDIR=/var/spool/asterisk + ASTLOGDIR=/var/log/asterisk + ASTHEADERDIR=$(INSTALL_PREFIX)/include/asterisk ASTCONFPATH=$(ASTETCDIR)/asterisk.conf - ASTBINDIR=$(INSTALL_PREFIX)/usr/bin - ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin - ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run - ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man + ASTBINDIR=$(INSTALL_PREFIX)/bin + ASTSBINDIR=$(INSTALL_PREFIX)/sbin + ASTVARRUNDIR=/var/run + ASTMANDIR=$(INSTALL_PREFIX)/man MODULES_DIR=$(ASTLIBDIR)/modules AGI_DIR=$(ASTVARLIBDIR)/agi-bin else @@ -226,25 +226,25 @@ endif INCLUDE+=-Iinclude -I../include -ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY -ASTCFLAGS+=$(OPTIMIZE) +ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE -DMAKE_VALGRIND_HAPPY +#ASTCFLAGS+=$(OPTIMIZE) ASTOBJ=-o asterisk ifeq ($(findstring BSD,$(OSARCH)),BSD) PROC=$(shell uname -m) - ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib + ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)$(LOCALBASE)/include -L$(CROSS_COMPILE_TARGET)$(LOCALBASE)/lib endif ifneq ($(PROC),ultrasparc) - ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) +# ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi) endif ifeq ($(PROC),ppc) ASTCFLAGS+=-fsigned-char endif -ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/osp/osp.h),) - ASTCFLAGS+=-DOSP_SUPPORT -I$(CROSS_COMPILE_TARGET)/usr/local/include/osp +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/osp/osp.h),) + ASTCFLAGS+=-DOSP_SUPPORT -I$(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/osp else ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h),) ASTCFLAGS+=-DOSP_SUPPORT -I$(CROSS_COMPILE_TARGET)/usr/include/osp @@ -253,27 +253,24 @@ ifeq ($(OSARCH),FreeBSD) BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk) - ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi) - LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi) - ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/spandsp),) - ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/spandsp + ASTCFLAGS+=$(PTHREAD_CFLAGS) + LIBS+=$(PTHREAD_LIBS) + ifneq ($(wildcard $(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/spandsp),) + ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/spandsp endif MPG123TARG=freebsd - # XXX FreeBSD paths - PREFIX?=/usr/local - ASTLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/lib/asterisk - ASTVARLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/share/asterisk - ASTETCDIR=$(INSTALL_PREFIX)$(PREFIX)/etc/asterisk - ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk - ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk - ASTHEADERDIR=$(INSTALL_PREFIX)$(PREFIX)/include/asterisk + ASTLIBDIR=$(INSTALL_PREFIX)/lib/asterisk + ASTVARLIBDIR=$(INSTALL_PREFIX)/share/asterisk + ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk + ASTSPOOLDIR=/var/spool/asterisk + ASTLOGDIR=/var/log/asterisk + ASTHEADERDIR=$(INSTALL_PREFIX)/include/asterisk ASTCONFPATH=$(ASTETCDIR)/asterisk.conf - ASTBINDIR=$(INSTALL_PREFIX)$(PREFIX)/bin - ASTSBINDIR=$(INSTALL_PREFIX)$(PREFIX)/sbin - ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run - ASTMANDIR=$(INSTALL_PREFIX)$(PREFIX)/man - # XXX end FreeBSD paths + ASTBINDIR=$(INSTALL_PREFIX)/bin + ASTSBINDIR=$(INSTALL_PREFIX)/sbin + ASTVARRUNDIR=/var/run + ASTMANDIR=$(INSTALL_PREFIX)/man endif # FreeBSD @@ -307,7 +304,7 @@ ifndef WITHOUT_ZAPTEL -ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/pkg/include/zaptel.h),) +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/pkg/include/zaptel.h),) ASTCFLAGS+=-DZAPTEL_OPTIMIZATIONS endif @@ -414,7 +411,7 @@ endif # This is used when generating the doxygen documentation -ifneq ($(wildcard /usr/local/bin/dot)$(wildcard /usr/bin/dot),) +ifneq ($(wildcard $(LOCALBASE)/bin/dot)$(wildcard /usr/bin/dot),) HAVEDOT=yes else HAVEDOT=no @@ -431,7 +428,7 @@ @echo " + $(MAKE) install +" @echo " +-------------------------------------------+" -all: cleantest depend asterisk subdirs +all: cleantest depend asterisk subdirs manpage #ifneq ($(wildcard tags),) ctags: tags @@ -450,13 +447,13 @@ cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure $(MAKE) -C editline libedit.a -db1-ast/libdb1.a: FORCE - @if [ -d db1-ast ]; then \ - $(MAKE) -C db1-ast libdb1.a ; \ - else \ - echo "You need to do a cvs update -d not just cvs update"; \ - exit 1; \ - fi +#db1-ast/libdb1.a: FORCE +# @if [ -d db1-ast ]; then \ +# $(MAKE) -C db1-ast libdb1.a ; \ +# else \ +# echo "You need to do a cvs update -d not just cvs update"; \ +# exit 1; \ +# fi ifneq ($(wildcard .depend),) include .depend @@ -480,10 +477,10 @@ manpage: asterisk.8 -asterisk.8: asterisk.sgml - rm -f asterisk.8 - docbook2man asterisk.sgml - mv ./*.8 asterisk.8 +#asterisk.8: asterisk.sgml +# rm -f asterisk.8 +# docbook2man asterisk.sgml +# mv ./*.8 asterisk.8 asterisk.pdf: asterisk.sgml docbook2pdf asterisk.sgml @@ -523,14 +520,14 @@ cygwin_a: $(MAKE) -C cygwin all -asterisk: $(CYGLOADER) editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS) +asterisk: $(CYGLOADER) editline/libedit.a stdtime/libtime.a $(OBJS) build_tools/make_build_h > include/asterisk/build.h.tmp if cmp -s include/asterisk/build.h.tmp include/asterisk/build.h ; then echo ; else \ mv include/asterisk/build.h.tmp include/asterisk/build.h ; \ fi rm -f include/asterisk/build.h.tmp $(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c - $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS) + $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) stdtime/libtime.a $(LIBS) muted: muted.o $(CC) $(AUDIO_LIBS) -o muted muted.o @@ -552,12 +549,12 @@ datafiles: all if [ x`$(ID) -un` = xroot ]; then sh mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/silence - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/priv-callerintros + $(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits + $(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/sounds/silence + $(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/sounds/priv-callerintros for x in sounds/digits/*.gsm; do \ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \ + $(BSD_INSTALL_DATA) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \ else \ echo "No description for $$x"; \ exit 1; \ @@ -565,34 +562,34 @@ done for x in sounds/silence/*.gsm; do \ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/silence ; \ + $(BSD_INSTALL_DATA) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/silence ; \ else \ echo "No description for $$x"; \ exit 1; \ fi; \ done - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate + ${MKDIR} $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate for x in sounds/dictate/*.gsm; do \ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate ; \ + $(BSD_INSTALL_DATA) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate ; \ else \ echo "No description for $$x"; \ exit 1; \ fi; \ done - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters + ${MKDIR} $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters for x in sounds/letters/*.gsm; do \ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \ + $(BSD_INSTALL_DATA) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \ else \ echo "No description for $$x"; \ exit 1; \ fi; \ done - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic + ${MKDIR} $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic for x in sounds/phonetic/*.gsm; do \ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \ + $(BSD_INSTALL_DATA) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \ else \ echo "No description for $$x"; \ exit 1; \ @@ -600,18 +597,18 @@ done for x in sounds/demo-* sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-* sounds/agent-* sounds/invalid* sounds/tt-* sounds/auth-* sounds/privacy-* sounds/queue-* sounds/spy-* sounds/priv-* sounds/screen-* sounds/hello-* sounds/hours* sounds/minute* sounds/second* ; do \ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \ + $(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \ else \ echo "No description for $$x"; \ exit 1; \ fi; \ done - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/images + $(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 + $(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/images for x in images/*.jpg; do \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \ + $(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \ done - mkdir -p $(DESTDIR)$(AGI_DIR) + $(MKDIR) $(DESTDIR)$(AGI_DIR) update: @if [ -d .svn ]; then \ @@ -640,47 +637,47 @@ OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h))) bininstall: all - mkdir -p $(DESTDIR)$(MODULES_DIR) - mkdir -p $(DESTDIR)$(ASTSBINDIR) - mkdir -p $(DESTDIR)$(ASTETCDIR) - mkdir -p $(DESTDIR)$(ASTBINDIR) - mkdir -p $(DESTDIR)$(ASTVARRUNDIR) - mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail - mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate - mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system - mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp - mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme - mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor - if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi - if [ -f cygwin/asterisk.exe ]; then $(INSTALL) -m 755 cygwin/asterisk.exe $(DESTDIR)$(ASTSBINDIR)/; fi - if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi + $(MKDIR) $(DESTDIR)$(MODULES_DIR) + $(MKDIR) $(DESTDIR)$(ASTSBINDIR) + $(MKDIR) $(DESTDIR)$(ASTETCDIR) + $(MKDIR) $(DESTDIR)$(ASTBINDIR) + $(MKDIR) $(DESTDIR)$(ASTVARRUNDIR) + $(MKDIR) $(DESTDIR)$(ASTSPOOLDIR)/voicemail + $(MKDIR) $(DESTDIR)$(ASTSPOOLDIR)/dictate + $(MKDIR) $(DESTDIR)$(ASTSPOOLDIR)/system + $(MKDIR) $(DESTDIR)$(ASTSPOOLDIR)/tmp + $(MKDIR) $(DESTDIR)$(ASTSPOOLDIR)/meetme + $(MKDIR) $(DESTDIR)$(ASTSPOOLDIR)/monitor + if [ -f asterisk ]; then $(BSD_INSTALL_PROGRAM) asterisk $(DESTDIR)$(ASTSBINDIR)/; fi + if [ -f cygwin/asterisk.exe ]; then $(BSD_INSTALL_PROGRAM) cygwin/asterisk.exe $(DESTDIR)$(ASTSBINDIR)/; fi + if [ -f asterisk.dll ]; then $(BSD_INSTALL_PROGRAM) asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk - $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/ - $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/ + $(BSD_INSTALL_SCRIPT) contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/ + $(BSD_INSTALL_SCRIPT) contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/ if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \ cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\ chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\ fi - $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR) - $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR) + $(MKDIR) $(DESTDIR)$(ASTHEADERDIR) + $(BSD_INSTALL_DATA) include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR) if [ -n "$(OLDHEADERS)" ]; then \ rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\ fi - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds - mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv - mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax - mkdir -p $(DESTDIR)$(ASTMANDIR)/man8 - $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTVARLIBDIR)/keys - $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTVARLIBDIR)/keys - $(INSTALL) -m 644 asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8 - $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8 - $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8 - $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8 + $(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/sounds + $(MKDIR) $(DESTDIR)$(ASTLOGDIR)/cdr-csv + $(MKDIR) $(DESTDIR)$(ASTLOGDIR)/cdr-custom + $(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/keys + $(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/firmware + $(MKDIR) $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax + $(MKDIR) $(DESTDIR)$(ASTMANDIR)/man8 + $(BSD_INSTALL_DATA) keys/iaxtel.pub $(DESTDIR)$(ASTVARLIBDIR)/keys + $(BSD_INSTALL_DATA) keys/freeworlddialup.pub $(DESTDIR)$(ASTVARLIBDIR)/keys + $(BSD_INSTALL_DATA) asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8 + $(BSD_INSTALL_DATA) contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8 + $(BSD_INSTALL_DATA) contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8 + $(BSD_INSTALL_DATA) contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8 if [ -d contrib/firmware/iax ]; then \ - $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax/iaxy.bin; \ + $(BSD_INSTALL_DATA) contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax/iaxy.bin; \ else \ echo "You need to do cvs update -d not just cvs update" ; \ fi @@ -710,46 +707,28 @@ echo " WARNING WARNING WARNING" ;\ fi -install: all datafiles bininstall install-subdirs +install: all datafiles bininstall install-subdirs samples @if [ -x /usr/sbin/asterisk-post-install ]; then \ /usr/sbin/asterisk-post-install $(DESTDIR) . ; \ fi - @echo " +---- Asterisk Installation Complete -------+" - @echo " + +" - @echo " + YOU MUST READ THE SECURITY DOCUMENT +" - @echo " + +" - @echo " + Asterisk has successfully been installed. +" - @echo " + If you would like to install the sample +" - @echo " + configuration files (overwriting any +" - @echo " + existing config files), run: +" - @echo " + +" - @echo " + $(MAKE) samples +" - @echo " + +" - @echo " +----------------- or ---------------------+" - @echo " + +" - @echo " + You can go ahead and install the asterisk +" - @echo " + program documentation now or later run: +" - @echo " + +" - @echo " + $(MAKE) progdocs +" - @echo " + +" - @echo " + **Note** This requires that you have +" - @echo " + doxygen installed on your local system +" - @echo " +-------------------------------------------+" @$(MAKE) -s oldmodcheck upgrade: all bininstall adsi: - mkdir -p $(DESTDIR)$(ASTETCDIR) + $(MKDIR) $(DESTDIR)$(ASTETCDIR) for x in configs/*.adsi; do \ + $(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x`-dist; \ if [ ! -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \ + $(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \ fi ; \ done samples: adsi - mkdir -p $(DESTDIR)$(ASTETCDIR) + echo ADSI INSTALL $(BSD_INSTALL_DATA) + $(MKDIR) $(DESTDIR)$(ASTETCDIR) for x in configs/*.sample; do \ + $(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`-dist;\ if [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \ if [ "$(OVERWRITE)" = "y" ]; then \ if cmp -s $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $$x ; then \ @@ -762,9 +741,9 @@ continue; \ fi ;\ fi ; \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\ + $(BSD_INSTALL_DATA) $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\ done - if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \ + if true ; then \ ( \ echo "[directories]" ; \ echo "astetcdir => $(ASTETCDIR)" ; \ @@ -781,25 +760,25 @@ echo ";astctlowner = root" ; \ echo ";astctlgroup = apache" ; \ echo ";astctl = asterisk.ctl" ; \ - ) > $(DESTDIR)$(ASTCONFPATH) ; \ + ) > $(DESTDIR)$(ASTCONFPATH)-dist ; \ else \ echo "Skipping asterisk.conf creation"; \ fi - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \ + ${MKDIR} $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \ for x in sounds/demo-*; do \ if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \ + $(BSD_INSTALL_DATA) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \ else \ echo "No description for $$x"; \ exit 1; \ fi; \ done - mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \ + ${MKDIR} $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \ for x in sounds/*.mp3; do \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \ + $(BSD_INSTALL_DATA) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \ done rm -f $(DESTDIR)$(ASTVARLIBDIR)/mohmp3/sample-hold.mp3 - mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX + ${MKDIR} $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \ cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \ @@ -813,9 +792,9 @@ @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 ) @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 ) $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi - mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk + $(MKDIR) $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk for x in images/*.gif; do \ - $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \ + $(BSD_INSTALL_DATA) $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \ done @echo " +--------- Asterisk Web Voicemail ----------+" @echo " + +" @@ -842,10 +821,10 @@ __rpm: include/asterisk/version.h spec rm -rf /tmp/asterisk ; \ - mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \ + $(MKDIR) /tmp/asterisk/redhat/RPMS/i386 ; \ $(MAKE) DESTDIR=/tmp/asterisk install ; \ $(MAKE) DESTDIR=/tmp/asterisk samples ; \ - mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \ + $(MKDIR) /tmp/asterisk/etc/rc.d/init.d ; \ cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \ rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec --- patch-Makefile ends here --- --- patch-cdr::Makefile begins here --- --- cdr/Makefile.orig Thu Nov 16 21:29:28 2006 +++ cdr/Makefile Mon Mar 19 19:49:53 2007 @@ -21,8 +21,8 @@ endif ifeq ($(findstring BSD,${OSARCH}),BSD) - CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include - SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib + CFLAGS+=-I$(CROSS_COMPILE_TARGET)$(LOCALBASE)/include + SOLINK+=-L$(CROSS_COMPILE_TARGET)$(LOCALBASE)/lib endif #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only. @@ -38,21 +38,21 @@ # # unixODBC stuff... # -ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),) +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/odbcinst.h),) MODS+=cdr_odbc.so endif # # FreeTDS stuff... # -ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/tds.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/tds.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/freetds/tds.h),) - ifeq ($(shell grep -s TDS_VERSION_NO $(CROSS_COMPILE_TARGET)/usr/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/local/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/include/freetds/tdsver.h | grep -c 0.64),1) +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/tds.h)$(wildcard $(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/tds.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/freetds/tds.h),) + ifeq ($(shell grep -s TDS_VERSION_NO $(CROSS_COMPILE_TARGET)/usr/include/tdsver.h $(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/include/freetds/tdsver.h | grep -c 0.64),1) CFLAGS += -DFREETDS_0_64 else - ifeq ($(shell grep -s TDS_VERSION_NO $(CROSS_COMPILE_TARGET)/usr/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/local/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/include/freetds/tdsver.h | grep -c 0.63),1) + ifeq ($(shell grep -s TDS_VERSION_NO $(CROSS_COMPILE_TARGET)/usr/include/tdsver.h $(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/include/freetds/tdsver.h | grep -c 0.63),1) CFLAGS += -DFREETDS_0_63 else - ifeq ($(shell grep -s TDS_VERSION_NO $(CROSS_COMPILE_TARGET)/usr/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/local/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/include/freetds/tdsver.h | grep -c 0.62),1) + ifeq ($(shell grep -s TDS_VERSION_NO $(CROSS_COMPILE_TARGET)/usr/include/tdsver.h $(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/include/freetds/tdsver.h | grep -c 0.62),1) CFLAGS += -DFREETDS_0_62 else CFLAGS += -DFREETDS_PRE_0_62 @@ -65,7 +65,7 @@ # # PGSQL stuff... Autoconf anyone?? # -ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/pgsql/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/libpq-fe.h),) +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/pgsql/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)${LOCALBASE}/include/pgsql/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include/libpq-fe.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/libpq-fe.h),) MODS+=cdr_pgsql.so endif @@ -86,9 +86,9 @@ MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib/pgsql endif -ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql),) - CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/pgsql - MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib/pgsql +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/pgsql),) + CFLAGS+=-I$(CROSS_COMPILE_TARGET)$(LOCALBASE)/include/pgsql + MLFLAGS+=-L$(CROSS_COMPILE_TARGET)$(LOCALBASE)/lib/pgsql endif ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include),) @@ -114,7 +114,7 @@ all: depend $(MODS) install: all - for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done + for x in $(MODS); do $(BSD_INSTALL_PROGRAM) $$x $(DESTDIR)$(MODULES_DIR) ; done clean: rm -f *.so *.o .depend --- patch-cdr::Makefile ends here --- --- patch-channels::chan_sip.c begins here --- --- channels/chan_sip.c.orig Fri Mar 2 18:02:46 2007 +++ channels/chan_sip.c Mon Mar 19 19:57:05 2007 @@ -339,7 +339,7 @@ static char default_language[MAX_LANGUAGE] = ""; -#define DEFAULT_CALLERID "asterisk" +#define DEFAULT_CALLERID "Unknown" static char default_callerid[AST_MAX_EXTENSION] = DEFAULT_CALLERID; static char default_fromdomain[AST_MAX_EXTENSION] = ""; @@ -483,6 +483,7 @@ struct sip_route { struct sip_route *next; + int lr; char hop[0]; }; @@ -2807,6 +2808,8 @@ tmp->nativeformats = ast_codec_choose(&i->prefs, global_capability, 1); fmt = ast_best_codec(tmp->nativeformats); + pbx_builtin_setvar_helper(tmp, "SIP_CODEC_USED", ast_getformatname(fmt)); + if (title) snprintf(tmp->name, sizeof(tmp->name), "SIP/%s-%08x", title, (int)(long) i); else if (strchr(i->fromdomain,':')) @@ -6226,6 +6229,7 @@ /* Make a struct route */ thishop = malloc(sizeof(*thishop) + len); if (thishop) { + thishop->lr = (strnstr(rr, ";lr", len) != NULL ? 1 : 0); ast_copy_string(thishop->hop, rr, len); ast_log(LOG_DEBUG, "build_route: Record-Route hop: <%s>\n", thishop->hop); /* Link in */ @@ -6251,31 +6255,41 @@ /* Only append the contact if we are dealing with a strict router */ if (!head || (!ast_strlen_zero(head->hop) && strstr(head->hop,";lr") == NULL) ) { - /* 2nd append the Contact: if there is one */ - /* Can be multiple Contact headers, comma separated values - we just take the first */ - contact = get_header(req, "Contact"); - if (!ast_strlen_zero(contact)) { - ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact); - /* Look for <: delimited address */ - c = strchr(contact, '<'); - if (c) { - /* Take to > */ - ++c; - len = strcspn(c, ">") + 1; - } else { - /* No <> - just take the lot */ - c = contact; - len = strlen(contact) + 1; - } - thishop = malloc(sizeof(*thishop) + len); + /* Duplicate first route from the list */ + if (head && head->lr) { + thishop = (struct sip_route *)malloc(sizeof(struct sip_route)+strlen(head->hop)+1); if (thishop) { - ast_copy_string(thishop->hop, c, len); - thishop->next = NULL; - /* Goes at the end */ - if (tail) - tail->next = thishop; - else - head = thishop; + memcpy(thishop, head, sizeof(struct sip_route)+strlen(head->hop)+1); + thishop->next = head; + head = thishop; + } + } else { + /* Append the Contact: if there is one and first route is w/o `lr' param */ + /* Can be multiple Contact headers, comma separated values - we just take the first */ + contact = get_header(req, "Contact"); + if (!ast_strlen_zero(contact)) { + ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact); + /* Look for <: delimited address */ + c = strchr(contact, '<'); + if (c) { + /* Take to > */ + ++c; + len = strcspn(c, ">") + 1; + } else { + /* No <> - just take the lot */ + c = contact; + len = strlen(contact) + 1; + } + thishop = malloc(sizeof(*thishop) + len); + if (thishop) { + ast_copy_string(thishop->hop, c, len); + thishop->next = NULL; + /* Goes at the end */ + if (tail) + tail->next = thishop; + else + head = thishop; + } } } } @@ -9278,6 +9292,13 @@ secret = p->peersecret; md5secret = p->peermd5secret; } + /* No authentication. Try to get auth info from channel vars */ + if (ast_strlen_zero(username)) + { + username = pbx_builtin_getvar_helper(p->owner, "SIP_AUTH_NAME"); + secret = pbx_builtin_getvar_helper(p->owner, "SIP_AUTH_SECRET"); + md5secret = pbx_builtin_getvar_helper(p->owner, "SIP_AUTH_MD5SECRET"); + } if (ast_strlen_zero(username)) /* We have no authentication */ return -1; @@ -10671,7 +10692,11 @@ gotdest = get_destination(p, NULL); get_rdnis(p, NULL); - extract_uri(p, req); + build_route(p, req, 0); + if (!p->route->lr) + strncpy(p->uri, p->route->hop, sizeof(p->uri) - 1); + else + extract_uri(p, req); build_contact(p); if (gotdest) { @@ -10692,7 +10717,6 @@ c = sip_new(p, AST_STATE_DOWN, ast_strlen_zero(p->username) ? NULL : p->username ); *recount = 1; /* Save Record-Route for any later requests we make on this dialogue */ - build_route(p, req, 0); if (c) { /* Pre-lock the call */ ast_mutex_lock(&c->lock); @@ -10778,6 +10802,12 @@ transmit_response(p, "180 Ringing", req); break; case AST_STATE_UP: + /* Assuming this to be reinvite, process new SDP portion */ + if (!ast_strlen_zero(get_header(req, "Content-Type"))) { + process_sdp(p, req); + } else { + ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n"); + } transmit_response_with_sdp(p, "200 OK", req, 1); break; default: --- patch-channels::chan_sip.c ends here --- --- patch-utils::Makefile begins here --- --- utils/Makefile.orig Wed Jan 24 18:43:50 2007 +++ utils/Makefile Mon Mar 19 20:07:50 2007 @@ -17,17 +17,17 @@ CFLAGS+=-DNO_AST_MM ifeq ($(findstring BSD,${OSARCH}),BSD) - CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib + CFLAGS+=-I$(CROSS_COMPILE_TARGET)${LOCALBASE}/include -L$(CROSS_COMPILE_TARGET)${LOCALBASE}/lib endif # to get check_expr, add it to the TARGET list TARGET=stereorize streamplayer -ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/popt.h)$(wildcard -f $(CROSS_COMPILE_TARGET)/usr/local/include/popt.h),) +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/popt.h)$(wildcard -f $(CROSS_COMPILE_TARGET)${LOCALBASE}/include/popt.h),) TARGET+=smsq endif -ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/newt.h)$(wildcard -f $(CROSS_COMPILE_TARGET)/usr/local/include/newt.h),) +ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/newt.h)$(wildcard -f $(CROSS_COMPILE_TARGET)${LOCALBASE}/include/newt.h),) TARGET+=astman endif @@ -41,7 +41,7 @@ install: for x in $(TARGET); do \ if [ "$$x" != "none" ]; then \ - $(INSTALL) -m 755 $$x $(DESTDIR)$(ASTSBINDIR)/$$x; \ + $(BSD_INSTALL_PROGRAM) $$x $(DESTDIR)$(ASTSBINDIR)/$$x; \ fi; \ done --- patch-utils::Makefile ends here --- --- patch-zzz-asterisk-1.2.16.1-codec-negotiation-20070319 begins here --- --- Makefile.orig Wed Sep 6 23:09:10 2006 +++ ./Makefile Mon Oct 9 13:01:08 2006 @@ -772,6 +772,47 @@ echo ";astctlowner = root" ; \ echo ";astctlgroup = apache" ; \ echo ";astctl = asterisk.ctl" ; \ + echo ";"; \ + echo "; The following section allows to choose the translation and the codec"; \ + echo "; negotiation algorithms"; \ + echo ";"; \ + echo "[codec_negotiation]"; \ + echo ";"; \ + echo "; The translation_algorithm option allows to choose between two"; \ + echo "; algorythms:"; \ + echo ";"; \ + echo "; 1. Always follow the format of data that the peer sends in."; \ + echo "; For example suppose the peer announced support for G729 and ULAW and"; \ + echo "; sends data in G729. Then Asterisk will translate all outgoing frames"; \ + echo "; to G729 regardless of initial format of the outgoing frames even if"; \ + echo "; they are in ULAW format. Outgoing G729 frames of course will not be"; \ + echo "; translated."; \ + echo ";"; \ + echo "; The name of this algorithm is:"; \ + echo "; strict"; \ + echo ";"; \ + echo "; Synonyms are:"; \ + echo "; follow_peer"; \ + echo "; avoid_asymmetry"; \ + echo ";"; \ + echo "; 2. Avoid translations if possible."; \ + echo "; For example suppose the peer announced support for G729 and ULAW and"; \ + echo "; sends data in G729. If Asterisk is to send the frame in G729 or ULAW"; \ + echo "; format then no translation will be performed and so frame is sent"; \ + echo "; unchanged. If the outgoing frame is in other format (not G729 or ULAW)"; \ + echo "; then the frame will be translated to G729 format."; \ + echo ";"; \ + echo "; The name of the algorithm is:"; \ + echo "; loose"; \ + echo ";"; \ + echo "; Synonyms are:"; \ + echo "; save_cpu"; \ + echo "; avoid_translation"; \ + echo "; asymmetric"; \ + echo ";"; \ + echo "; Default: strict"; \ + echo ";"; \ + echo ";translation_algorithm = strict"; \ ) > $(DESTDIR)$(ASTCONFPATH)-dist ; \ else \ echo "Skipping asterisk.conf creation"; \ --- apps/app_chanisavail.c.orig Tue Nov 29 20:24:39 2005 +++ apps/app_chanisavail.c Mon Oct 9 13:01:08 2006 @@ -118,7 +118,7 @@ snprintf(trychan, sizeof(trychan), "%s/%s",cur,number); status = inuse = ast_device_state(trychan); } - if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, number, &status))) { + if ((inuse <= 1) && (tempchan = ast_request(tech, &chan->nativeformats, number, &status))) { pbx_builtin_setvar_helper(chan, "AVAILCHAN", tempchan->name); /* Store the originally used channel too */ snprintf(tmp, sizeof(tmp), "%s/%s", tech, number); --- apps/app_dial.c.orig Sat Aug 5 09:37:59 2006 +++ apps/app_dial.c Mon Oct 9 13:01:08 2006 @@ -469,7 +469,7 @@ if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name); /* Setup parameters */ - o->chan = ast_request(tech, in->nativeformats, stuff, &cause); + o->chan = ast_request(tech, &in->nativeformats, stuff, &cause); if (!o->chan) ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause); else @@ -1050,7 +1050,7 @@ ast_log(LOG_DEBUG, "Dialing by extension %s\n", numsubst); } /* Request the peer */ - tmp->chan = ast_request(tech, chan->nativeformats, numsubst, &cause); + tmp->chan = ast_request(tech, &chan->nativeformats, numsubst, &cause); if (!tmp->chan) { /* If we can't, just go on to the next call */ ast_log(LOG_NOTICE, "Unable to create channel of type '%s' (cause %d - %s)\n", tech, cause, ast_cause2str(cause)); @@ -1081,7 +1081,7 @@ ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name); ast_hangup(tmp->chan); /* Setup parameters */ - tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause); + tmp->chan = ast_request(tech, &chan->nativeformats, stuff, &cause); if (!tmp->chan) ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause); else --- apps/app_dumpchan.c.orig Wed Jun 14 17:07:53 2006 +++ apps/app_dumpchan.c Mon Oct 9 13:01:08 2006 @@ -113,7 +113,7 @@ ast_state2str(c->_state), c->_state, c->rings, - c->nativeformats, + ast_codec_pref_bits(&c->nativeformats), c->writeformat, c->readformat, c->fds[0], c->fin & 0x7fffffff, (c->fin & 0x80000000) ? " (DEBUGGED)" : "", --- apps/app_echo.c.orig Tue Nov 29 20:24:39 2005 +++ apps/app_echo.c Mon Oct 9 13:01:08 2006 @@ -60,8 +60,8 @@ struct localuser *u; struct ast_frame *f; LOCAL_USER_ADD(u); - ast_set_write_format(chan, ast_best_codec(chan->nativeformats)); - ast_set_read_format(chan, ast_best_codec(chan->nativeformats)); + ast_set_write_format(chan, ast_best_codec(ast_codec_pref_bits(&chan->nativeformats))); + ast_set_read_format(chan, ast_best_codec(ast_codec_pref_bits(&chan->nativeformats))); /* Do our thing here */ while(ast_waitfor(chan, -1) > -1) { f = ast_read(chan); --- apps/app_meetme.c.orig Tue Sep 12 00:47:23 2006 +++ apps/app_meetme.c Mon Oct 9 13:01:08 2006 @@ -454,11 +454,15 @@ /* Make a new one */ cnf = calloc(1, sizeof(*cnf)); if (cnf) { + struct ast_codec_pref formats; + ast_codec_pref_init(&formats); + ast_codec_pref_append(&formats, AST_FORMAT_ULAW); + ast_copy_string(cnf->confno, confno, sizeof(cnf->confno)); ast_copy_string(cnf->pin, pin, sizeof(cnf->pin)); ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin)); cnf->markedusers = 0; - cnf->chan = ast_request("zap", AST_FORMAT_ULAW, "pseudo", NULL); + cnf->chan = ast_request("zap", &formats, "pseudo", NULL); if (cnf->chan) { cnf->fd = cnf->chan->fds[0]; /* for use by conf_play() */ } else { --- apps/app_page.c.orig Tue Sep 12 00:47:23 2006 +++ apps/app_page.c Mon Oct 9 13:01:08 2006 @@ -84,7 +84,10 @@ static void *page_thread(void *data) { struct calloutdata *cd = data; - ast_pbx_outgoing_app(cd->tech, AST_FORMAT_SLINEAR, cd->resource, 30000, + struct ast_codec_pref slin; + ast_codec_pref_init(&slin); + ast_codec_pref_append(&slin, AST_FORMAT_SLINEAR); + ast_pbx_outgoing_app(cd->tech, &slin, cd->resource, 30000, "MeetMe", cd->meetmeopts, NULL, 0, cd->cidnum, cd->cidname, cd->variables, NULL, NULL); free(cd); return NULL; --- apps/app_parkandannounce.c.orig Tue Nov 29 20:24:39 2005 +++ apps/app_parkandannounce.c Mon Oct 9 13:01:08 2006 @@ -84,6 +84,11 @@ struct localuser *u; + struct ast_codec_pref formats; + + ast_codec_pref_init(&formats); + ast_codec_pref_append(&formats, AST_FORMAT_SLINEAR); + if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n"); return -1; @@ -183,7 +188,7 @@ memset(&oh, 0, sizeof(oh)); oh.parent_channel = chan; - dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh); + dchan = __ast_request_and_dial(dialtech, &formats, dialstr,30000, &outstate, chan->cid.cid_num, chan->cid.cid_name, &oh); if(dchan) { if(dchan->_state == AST_STATE_UP) { --- apps/app_queue.c.orig Sun Sep 3 20:38:22 2006 +++ apps/app_queue.c Mon Oct 9 13:01:08 2006 @@ -1509,7 +1509,7 @@ location = ""; /* Request the peer */ - tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status); + tmp->chan = ast_request(tech, &qe->chan->nativeformats, location, &status); if (!tmp->chan) { /* If we can't, just go on to the next call */ #if 0 ast_log(LOG_NOTICE, "Unable to create channel of type '%s' for Queue\n", cur->tech); @@ -1821,7 +1821,7 @@ if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name); /* Setup parameters */ - o->chan = ast_request(tech, in->nativeformats, stuff, &status); + o->chan = ast_request(tech, &in->nativeformats, stuff, &status); if (status != o->oldstatus) update_dial_status(qe->parent, o->member, status); if (!o->chan) { --- asterisk.c.orig Tue Aug 22 01:34:26 2006 +++ ./asterisk.c Mon Oct 9 13:01:08 2006 @@ -177,6 +177,7 @@ int fully_booted = 0; char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR; char debug_filename[AST_FILENAME_MAX] = ""; +enum ast_trans_algorithm option_translation_algorithm = AST_TRANS_ALG_STRICT; static int ast_socket = -1; /*!< UNIX Socket for allowing remote control */ static int ast_consock = -1; /*!< UNIX Socket for controlling another asterisk */ @@ -1993,6 +1994,30 @@ ast_copy_string(ast_config_AST_RUN_GROUP, v->value, sizeof(ast_config_AST_RUN_GROUP)); } v = v->next; + } + option_translation_algorithm = AST_TRANS_ALG_STRICT; + for (v = ast_variable_browse(cfg, "codec_negotiation"); v; v = v->next) + { + if (!strcasecmp(v->name, "translation_algorithm")) { + if (!strcasecmp(v->value, "loose") || + !strcasecmp(v->value, "save_cpu") || + !strcasecmp(v->value, "avoid_translation") || + !strcasecmp(v->value, "asymmetric")) + { + option_translation_algorithm = AST_TRANS_ALG_LOOSE; + } +/* + else if (!strcasecmp(v->value, "strict") || + !strcasecmp(v->value, "follow_peer") || + !strcasecmp(v->value, "avoid_asymmetry")) + { + option_translation_algorithm = AST_TRANS_ALG_STRICT; + } +*/ + else { + option_translation_algorithm = AST_TRANS_ALG_STRICT; + } + } } ast_config_destroy(cfg); } --- channel.c.orig Sat Sep 9 23:24:19 2006 +++ ./channel.c Mon Oct 9 13:01:08 2006 @@ -927,10 +927,7 @@ ast_moh_cleanup(chan); /* Free translatosr */ - if (chan->readtrans) - ast_translator_free_path(chan->readtrans); - if (chan->writetrans) - ast_translator_free_path(chan->writetrans); + ast_translator_free_translations(chan); if (chan->pbx) ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name); free_cid(&chan->cid); @@ -1299,14 +1296,9 @@ static void free_translation(struct ast_channel *clone) { - if (clone->writetrans) - ast_translator_free_path(clone->writetrans); - if (clone->readtrans) - ast_translator_free_path(clone->readtrans); - clone->writetrans = NULL; - clone->readtrans = NULL; - clone->rawwriteformat = clone->nativeformats; - clone->rawreadformat = clone->nativeformats; + ast_translator_free_translations(clone); + clone->rawwriteformat = clone->nativeformats.audio_bits; + clone->rawreadformat = clone->nativeformats.audio_bits; } /*--- ast_hangup: Hangup a channel */ @@ -1950,10 +1942,11 @@ if (f && (f->frametype == AST_FRAME_VOICE)) { - if (!(f->subclass & chan->nativeformats)) { + if (!(f->subclass & chan->nativeformats.audio_bits)) { + char buf[512]; /* This frame can't be from the current native formats -- drop it on the floor */ - ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n", chan->name, ast_getformatname(f->subclass), ast_getformatname(chan->nativeformats)); + ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n", chan->name, ast_getformatname(f->subclass), ast_codec_pref_dump(buf, sizeof(buf), &chan->nativeformats)); ast_frfree(f); f = &null_frame; } else { @@ -1981,11 +1974,9 @@ if (ast_writestream(chan->monitor->read_stream, f) < 0) ast_log(LOG_WARNING, "Failed to write data to channel monitor read stream\n"); } - if (chan->readtrans) { - f = ast_translate(chan->readtrans, f, 1); - if (!f) - f = &null_frame; - } + f = ast_translate_read(chan, f, 1); + if (!f) + f = &null_frame; } } @@ -2304,7 +2295,7 @@ break; default: if (chan->tech->write) { - f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr; + f = ast_translate_write(chan, fr, 0); if (f) { if (f->frametype == AST_FRAME_VOICE && chan->spies) queue_frame_to_spies(chan, f, SPY_WRITE); @@ -2362,12 +2353,12 @@ } static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *format, - struct ast_trans_pvt **trans, const int direction) + const int direction) { int native; int res; - native = chan->nativeformats; + native = ast_codec_pref_index_audio(&chan->nativeformats, 0); /* Find a translation path from the native format to one of the desired formats */ if (!direction) /* reading */ @@ -2377,33 +2368,26 @@ res = ast_translator_best_choice(&native, &fmt); if (res < 0) { + char buf[512]; ast_log(LOG_WARNING, "Unable to find a codec translation path from %s to %s\n", - ast_getformatname(native), ast_getformatname(fmt)); + ast_getformatname_multiple(buf, sizeof(buf), native), ast_getformatname(fmt)); +/* return -1; +*/ } /* Now we have a good choice for both. */ ast_mutex_lock(&chan->lock); - if ((*rawformat == native) && (*format == fmt) && ((*rawformat == *format) || (*trans))) { + if ((*rawformat == native) && (*format == fmt) && ((*rawformat == *format))) { /* the channel is already in these formats, so nothing to do */ ast_mutex_unlock(&chan->lock); return 0; } - *rawformat = native; + *rawformat = chan->lastreadformat = native; /* User perspective is fmt */ *format = fmt; - /* Free any read translation we have right now */ - if (*trans) - ast_translator_free_path(*trans); - /* Build a translation path from the raw format to the desired format */ - if (!direction) - /* reading */ - *trans = ast_translator_build_path(*format, *rawformat); - else - /* writing */ - *trans = ast_translator_build_path(*rawformat, *format); ast_mutex_unlock(&chan->lock); if (option_debug) ast_log(LOG_DEBUG, "Set channel %s to %s format %s\n", chan->name, @@ -2413,17 +2397,15 @@ int ast_set_read_format(struct ast_channel *chan, int fmt) { - return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat, - &chan->readtrans, 0); + return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat, 0); } int ast_set_write_format(struct ast_channel *chan, int fmt) { - return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat, - &chan->writetrans, 1); + return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat, 1); } -struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh) +struct ast_channel *__ast_request_and_dial(const char *type, const struct ast_codec_pref *formats, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh) { int state = 0; int cause = 0; @@ -2431,7 +2413,7 @@ struct ast_frame *f; int res = 0; - chan = ast_request(type, format, data, &cause); + chan = ast_request(type, formats, data, &cause); if (chan) { if (oh) { if (oh->vars) @@ -2537,20 +2519,20 @@ return chan; } -struct ast_channel *ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname) +struct ast_channel *ast_request_and_dial(const char *type, const struct ast_codec_pref *formats, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname) { - return __ast_request_and_dial(type, format, data, timeout, outstate, cidnum, cidname, NULL); + return __ast_request_and_dial(type, formats, data, timeout, outstate, cidnum, cidname, NULL); } -struct ast_channel *ast_request(const char *type, int format, void *data, int *cause) +struct ast_channel *ast_request(const char *type, const struct ast_codec_pref *requested_formats, void *data, int *cause) { struct chanlist *chan; struct ast_channel *c; - int capabilities; - int fmt; - int res; int foo; + struct ast_codec_pref formats; + memcpy(&formats, requested_formats, sizeof(formats)); + ast_codec_pref_append_missing2(&formats, ast_compatible_audio_formats(formats.audio_bits)); if (!cause) cause = &foo; *cause = AST_CAUSE_NOTDEFINED; @@ -2561,22 +2543,25 @@ } for (chan = backends; chan; chan = chan->next) { + struct ast_codec_pref tmp_formats; if (strcasecmp(type, chan->tech->type)) continue; - capabilities = chan->tech->capabilities; - fmt = format; - res = ast_translator_best_choice(&fmt, &capabilities); - if (res < 0) { - ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %d) to %d\n", type, chan->tech->capabilities, format); + if (!(chan->tech->capabilities & ast_codec_pref_bits(&formats))) + { + char buf[512]; + ast_log(LOG_WARNING, "Channel %s does not support requested formats %s\n", type, ast_codec_pref_dump(buf, sizeof(buf), &formats)); ast_mutex_unlock(&chlock); return NULL; } ast_mutex_unlock(&chlock); - if (!chan->tech->requester) + if (!chan->tech->requester) { + ast_log(LOG_WARNING, "Cannot allocate channel %s because it hasn't registered the requester function\n", type); return NULL; - - if (!(c = chan->tech->requester(type, capabilities, data, cause))) + } + memcpy(&tmp_formats, &formats, sizeof(formats)); + ast_codec_pref_remove2(&tmp_formats, ~chan->tech->capabilities); + if (!(c = chan->tech->requester(type, &tmp_formats, data, cause))) return NULL; if (c->_state == AST_STATE_DOWN) { @@ -2744,15 +2729,31 @@ { int src; int dst; + int res = -1; + int i, j, done; /* Set up translation from the chan to the peer */ - src = chan->nativeformats; - dst = peer->nativeformats; - if (ast_translator_best_choice(&dst, &src) < 0) { - ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", chan->name, src, peer->name, dst); + done = 0; + for (i = 0; i < 32 && !done; ++i) { + dst = ast_codec_pref_index_audio(&peer->nativeformats, i); + if (!dst) break; + for (j = 0; j < 32 && !done; ++j) { + src = ast_codec_pref_index_audio(&chan->nativeformats, j); + if (!src) break; + res = ast_translator_best_choice(&dst, &src); + if (res >= 0) + done = 1; + } + } + if (res < 0) { + char buf[512], buf2[512]; + ast_log(LOG_WARNING, "No path to translate from %s %s to %s %s\n", + chan->name, + ast_codec_pref_dump(buf, sizeof(buf), &chan->nativeformats), + peer->name, + ast_codec_pref_dump(buf2, sizeof(buf2), &peer->nativeformats)); return -1; } - /* if the best path is not 'pass through', then transcoding is needed; if desired, force transcode path to use SLINEAR between channels */ @@ -2768,10 +2769,25 @@ } /* Set up translation from the peer to the chan */ - src = peer->nativeformats; - dst = chan->nativeformats; - if (ast_translator_best_choice(&dst, &src) < 0) { - ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", peer->name, src, chan->name, dst); + done = 0; + for (i = 0; i < 32 && !done; ++i) { + dst = ast_codec_pref_index_audio(&peer->nativeformats, i); + if (!dst) break; + for (j = 0; j < 32 && !done; ++j) { + src = ast_codec_pref_index_audio(&chan->nativeformats, j); + if (!src) break; + res = ast_translator_best_choice(&src, &dst); + if (res >= 0) + done = 1; + } + } + if (res < 0) { + char buf[512], buf2[512]; + ast_log(LOG_WARNING, "No path to translate from %s %s to %s %s\n", + peer->name, + ast_codec_pref_dump(buf2, sizeof(buf2), &peer->nativeformats), + chan->name, + ast_codec_pref_dump(buf, sizeof(buf), &chan->nativeformats)); return -1; } /* if the best path is not 'pass through', then @@ -3137,7 +3153,7 @@ original->fds[AST_MAX_FDS - 2] = original->timingfd; /* Our native formats are different now */ - original->nativeformats = clone->nativeformats; + memcpy(&original->nativeformats, &clone->nativeformats, sizeof(struct ast_codec_pref)); /* Context, extension, priority, app data, jump table, remain the same */ /* pvt switches. pbx stays the same, as does next */ @@ -3335,15 +3351,16 @@ cs[1] = c1; pvt0 = c0->tech_pvt; pvt1 = c1->tech_pvt; - o0nativeformats = c0->nativeformats; - o1nativeformats = c1->nativeformats; + o0nativeformats = ast_codec_pref_bits(&c0->nativeformats); + o1nativeformats = ast_codec_pref_bits(&c1->nativeformats); watch_c0_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_0; watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1; for (;;) { if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) || - (o0nativeformats != c0->nativeformats) || - (o1nativeformats != c1->nativeformats)) { + (o0nativeformats != ast_codec_pref_bits(&c0->nativeformats)) || + (o1nativeformats != ast_codec_pref_bits(&c1->nativeformats))) + { /* Check for Masquerade, codec changes, etc */ res = AST_BRIDGE_RETRY; break; @@ -3490,8 +3507,8 @@ "CallerID2: %s\r\n", c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); - o0nativeformats = c0->nativeformats; - o1nativeformats = c1->nativeformats; + o1nativeformats = ast_codec_pref_bits(&c1->nativeformats); + o0nativeformats = ast_codec_pref_bits(&c0->nativeformats); if (config->feature_timer) { nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->feature_timer, 1000)); @@ -3624,7 +3641,8 @@ } if (((c0->writeformat != c1->readformat) || (c0->readformat != c1->writeformat) || - (c0->nativeformats != o0nativeformats) || (c1->nativeformats != o1nativeformats)) && + (ast_codec_pref_bits(&c0->nativeformats) != o0nativeformats) || + (ast_codec_pref_bits(&c1->nativeformats) != o1nativeformats)) && !(c0->generator || c1->generator)) { if (ast_channel_make_compatible(c0, c1)) { ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name); @@ -3638,8 +3656,8 @@ c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); return AST_BRIDGE_FAILED; } - o0nativeformats = c0->nativeformats; - o1nativeformats = c1->nativeformats; + o0nativeformats = ast_codec_pref_bits(&c0->nativeformats); + o1nativeformats = ast_codec_pref_bits(&c1->nativeformats); } res = ast_generic_bridge(c0, c1, config, fo, rc, nexteventts); if (res != AST_BRIDGE_RETRY) --- channels/chan_agent.c.orig Wed Sep 6 21:16:41 2006 +++ channels/chan_agent.c Mon Oct 9 13:01:08 2006 @@ -209,10 +209,10 @@ #define CHECK_FORMATS(ast, p) do { \ if (p->chan) {\ - if (ast->nativeformats != p->chan->nativeformats) { \ - ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \ + if (!ast_codec_pref_eq_noorder(&ast->nativeformats, &p->chan->nativeformats)) { \ + ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", ast_codec_pref_bits(&ast->nativeformats), ast_codec_pref_bits(&p->chan->nativeformats)); \ /* Native formats changed, reset things */ \ - ast->nativeformats = p->chan->nativeformats; \ + memcpy(&ast->nativeformats, &p->chan->nativeformats, sizeof(ast->nativeformats)); \ ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\ ast_set_read_format(ast, ast->readformat); \ ast_set_write_format(ast, ast->writeformat); \ @@ -239,7 +239,7 @@ } \ } while(0) -static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *agent_request(const char *type, const struct ast_codec_pref *format, void *data, int *cause); static int agent_devicestate(void *data); static int agent_digit(struct ast_channel *ast, char digit); static int agent_call(struct ast_channel *ast, char *dest, int timeout); @@ -678,20 +678,20 @@ ast_log( LOG_DEBUG, "Waited for stream, result '%d'\n", res); } if (!res) { - res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats)); + res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats.audio_bits)); ast_log( LOG_DEBUG, "Set read format, result '%d'\n", res); if (res) - ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats))); + ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats.audio_bits))); } else { /* Agent hung-up */ p->chan = NULL; } if (!res) { - ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats)); + ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats.audio_bits)); ast_log( LOG_DEBUG, "Set write format, result '%d'\n", res); if (res) - ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats))); + ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats.audio_bits))); } if( !res ) { @@ -945,7 +945,7 @@ ast_copy_string(tmp->context, p->chan->context, sizeof(tmp->context)); ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten)); } else { - tmp->nativeformats = AST_FORMAT_SLINEAR; + ast_codec_pref_append(&tmp->nativeformats, AST_FORMAT_SLINEAR); tmp->writeformat = AST_FORMAT_SLINEAR; tmp->rawwriteformat = AST_FORMAT_SLINEAR; tmp->readformat = AST_FORMAT_SLINEAR; @@ -1272,7 +1272,7 @@ } /*--- agent_request: Part of the Asterisk PBX interface ---*/ -static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *agent_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { struct agent_pvt *p; struct ast_channel *chan = NULL; @@ -1336,7 +1336,7 @@ chan = agent_new(p, AST_STATE_DOWN); } else if (!p->owner && !ast_strlen_zero(p->loginchan)) { /* Adjustable agent */ - p->chan = ast_request("Local", format, p->loginchan, cause); + p->chan = ast_request("Local", formats, p->loginchan, cause); if (p->chan) chan = agent_new(p, AST_STATE_DOWN); } @@ -1903,14 +1903,14 @@ ast_mutex_lock(&agentlock); ast_mutex_lock(&p->lock); if (!res) { - res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats)); + res = ast_set_read_format(chan, ast_best_codec(chan->nativeformats.audio_bits)); if (res) - ast_log(LOG_WARNING, "Unable to set read format to %d\n", ast_best_codec(chan->nativeformats)); + ast_log(LOG_WARNING, "Unable to set read format to %d\n", ast_best_codec(chan->nativeformats.audio_bits)); } if (!res) { - res = ast_set_write_format(chan, ast_best_codec(chan->nativeformats)); + res = ast_set_write_format(chan, ast_best_codec(chan->nativeformats.audio_bits)); if (res) - ast_log(LOG_WARNING, "Unable to set write format to %d\n", ast_best_codec(chan->nativeformats)); + ast_log(LOG_WARNING, "Unable to set write format to %d\n", ast_best_codec(chan->nativeformats.audio_bits)); } /* Check once more just in case */ if (p->chan) --- channels/chan_alsa.c.orig Wed Dec 21 22:01:16 2005 +++ channels/chan_alsa.c Mon Oct 9 13:01:08 2006 @@ -785,7 +785,7 @@ snprintf(tmp->name, sizeof(tmp->name), "ALSA/%s", indevname); tmp->type = type; tmp->fds[0] = readdev; - tmp->nativeformats = AST_FORMAT_SLINEAR; + ast_codec_pref_set2(&tmp->nativeformats, AST_FORMAT_SLINEAR); tmp->readformat = AST_FORMAT_SLINEAR; tmp->writeformat = AST_FORMAT_SLINEAR; tmp->tech_pvt = p; --- channels/chan_features.c.orig Wed Aug 30 21:59:44 2006 +++ channels/chan_features.c Mon Oct 9 13:01:08 2006 @@ -94,7 +94,7 @@ #define SUB_CALLWAIT 1 /* Call-Waiting call on hold */ #define SUB_THREEWAY 2 /* Three-way call */ -static struct ast_channel *features_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *features_request(const char *type, const struct ast_codec_pref *format, void *data, int *cause); static int features_digit(struct ast_channel *ast, char digit); static int features_call(struct ast_channel *ast, char *dest, int timeout); static int features_hangup(struct ast_channel *ast); @@ -188,8 +188,8 @@ p->subs[index].owner->timingfd = p->subchan->timingfd; p->subs[index].owner->alertpipe[0] = p->subchan->alertpipe[0]; p->subs[index].owner->alertpipe[1] = p->subchan->alertpipe[1]; - if (p->subs[index].owner->nativeformats != p->subchan->readformat) { - p->subs[index].owner->nativeformats = p->subchan->readformat; + if (!(ast_codec_pref_bits(&p->subs[index].owner->nativeformats) & p->subchan->readformat)) { + ast_codec_pref_append(&p->subs[index].owner->nativeformats, p->subchan->readformat); if (p->subs[index].owner->readformat) ast_set_read_format(p->subs[index].owner, p->subs[index].owner->readformat); if (p->subs[index].owner->writeformat) @@ -396,7 +396,7 @@ return 0; } -static struct feature_pvt *features_alloc(char *data, int format) +static struct feature_pvt *features_alloc(char *data, const struct ast_codec_pref *formats) { struct feature_pvt *tmp; char *dest=NULL; @@ -427,7 +427,7 @@ } ast_mutex_unlock(&featurelock); if (!tmp) { - chan = ast_request(tech, format, dest, &status); + chan = ast_request(tech, formats, dest, &status); if (!chan) { ast_log(LOG_NOTICE, "Unable to allocate subchannel '%s/%s'\n", tech, dest); return NULL; @@ -485,7 +485,7 @@ tmp->rawwriteformat = p->subchan->rawwriteformat; tmp->readformat = p->subchan->readformat; tmp->rawreadformat = p->subchan->rawreadformat; - tmp->nativeformats = p->subchan->readformat; + ast_codec_pref_append(&tmp->nativeformats, p->subchan->readformat); tmp->tech_pvt = p; p->subs[index].owner = tmp; if (!p->owner) @@ -498,12 +498,12 @@ } -static struct ast_channel *features_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *features_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { struct feature_pvt *p; struct ast_channel *chan = NULL; - p = features_alloc(data, format); + p = features_alloc(data, formats); if (p && !p->subs[SUB_REAL].owner) chan = features_new(p, AST_STATE_DOWN, SUB_REAL); if (chan) --- channels/chan_h323.c.orig Wed Aug 30 21:59:44 2006 +++ channels/chan_h323.c Mon Oct 9 13:01:08 2006 @@ -193,7 +193,7 @@ static int restart_monitor(void); static int h323_do_reload(void); -static struct ast_channel *oh323_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *oh323_request(const char *type, const struct ast_codec_pref *format, void *data, int *cause); static int oh323_digit(struct ast_channel *c, char digit); static int oh323_call(struct ast_channel *c, char *dest, int timeout); static int oh323_hangup(struct ast_channel *c); @@ -226,10 +226,11 @@ /* Channel and private structures should be already locked */ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt) { - if (c->nativeformats != pvt->nativeformats) { + if (ast_codec_pref_bits(&c->nativeformats) != pvt->nativeformats) { if (h323debug) ast_log(LOG_DEBUG, "Preparing %s for new native format\n", c->name); - c->nativeformats = pvt->nativeformats; + ast_codec_pref_init(&c->nativeformats); + ast_codec_pref_append_missing2(&c->nativeformats, pvt->nativeformats); ast_set_read_format(c, c->readformat); ast_set_write_format(c, c->writeformat); } @@ -557,15 +558,15 @@ if (pvt->owner) { /* We already hold the channel lock */ if (f->frametype == AST_FRAME_VOICE) { - if (f->subclass != pvt->owner->nativeformats) { + if (!(f->subclass & pvt->owner->nativeformats.audio_bits)) { /* Try to avoid deadlock */ if (ast_mutex_trylock(&pvt->owner->lock)) { ast_log(LOG_NOTICE, "Format changed but channel is locked. Ignoring frame...\n"); return &null_frame; } ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); - pvt->owner->nativeformats = f->subclass; - pvt->nativeformats = f->subclass; + ast_codec_pref_append(&pvt->owner->nativeformats, f->subclass); + pvt->nativeformats |= f->subclass; ast_set_read_format(pvt->owner, pvt->owner->readformat); ast_set_write_format(pvt->owner, pvt->owner->writeformat); ast_mutex_unlock(&pvt->owner->lock); @@ -610,9 +611,9 @@ return 0; } } else { - if (!(frame->subclass & c->nativeformats)) { + if (!(frame->subclass & c->nativeformats.audio_bits)) { ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n", - frame->subclass, c->nativeformats, c->readformat, c->writeformat); + frame->subclass, ast_codec_pref_bits(&c->nativeformats), c->readformat, c->writeformat); return 0; } } @@ -735,12 +736,12 @@ if (ch) { ch->tech = &oh323_tech; snprintf(ch->name, sizeof(ch->name), "H323/%s", host); - ch->nativeformats = pvt->options.capability; - if (!ch->nativeformats) { - ch->nativeformats = global_options.capability; + ast_codec_pref_append_missing2(&ch->nativeformats, pvt->options.capability); + if (!ast_codec_pref_bits(&ch->nativeformats)) { + ast_codec_pref_append(&ch->nativeformats, global_options.capability); } - pvt->nativeformats = ch->nativeformats; - fmt = ast_best_codec(ch->nativeformats); + pvt->nativeformats = ast_codec_pref_bits(&ch->nativeformats); + fmt = ast_best_codec(ch->nativeformats.audio_bits); ch->type = type; ch->fds[0] = ast_rtp_fd(pvt->rtp); if (state == AST_STATE_RING) { @@ -1006,9 +1007,8 @@ return 0; } } -static struct ast_channel *oh323_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *oh323_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { - int oldformat; struct oh323_pvt *pvt; struct ast_channel *tmpc = NULL; char *dest = (char *)data; @@ -1016,18 +1016,12 @@ char *h323id = NULL; char tmp[256], tmp1[256]; - ast_log(LOG_DEBUG, "type=%s, format=%d, data=%s.\n", type, format, (char *)data); + ast_log(LOG_DEBUG, "type=%s, format=%s, data=%s.\n", type, ast_codec_pref_dump(tmp, sizeof(tmp), formats), (char *)data); pvt = oh323_alloc(0); if (!pvt) { ast_log(LOG_WARNING, "Unable to build pvt data for '%s'\n", (char *)data); return NULL; } - oldformat = format; - format &= ((AST_FORMAT_MAX_AUDIO << 1) - 1); - if (!format) { - ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format); - return NULL; - } strncpy(tmp, dest, sizeof(tmp) - 1); host = strchr(tmp, '@'); if (host) { @@ -1163,14 +1157,6 @@ } /** - * Definition taken from rtp.c for rtpPayloadType because we need it here. - */ -struct rtpPayloadType { - int isAstFormat; /* whether the following code is an AST_FORMAT */ - int code; -}; - -/** * Call-back function passing remote ip/port information from H.323 to asterisk * * Returns nothing @@ -1197,7 +1183,8 @@ rtptype = ast_rtp_lookup_pt(pvt->rtp, pt); pvt->nativeformats = rtptype.code; if (pvt->owner && !ast_mutex_trylock(&pvt->owner->lock)) { - pvt->owner->nativeformats = pvt->nativeformats; + ast_codec_pref_init(&pvt->owner->nativeformats); + ast_codec_pref_append_missing2(&pvt->owner->nativeformats, pvt->nativeformats); ast_set_read_format(pvt->owner, pvt->owner->readformat); ast_set_write_format(pvt->owner, pvt->owner->writeformat); if (pvt->options.progress_audio) @@ -2277,7 +2264,7 @@ } } -static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active) +static int oh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, const struct ast_codec_pref *codecs, int nat_active) { /* XXX Deal with Video */ struct oh323_pvt *pvt; --- channels/chan_iax2.c.orig Wed Sep 6 18:55:20 2006 +++ channels/chan_iax2.c Mon Oct 9 13:01:08 2006 @@ -742,7 +742,7 @@ static int iax2_poke_peer(struct iax2_peer *peer, int heldcall); static int iax2_provision(struct sockaddr_in *end, int sockfd, char *dest, const char *template, int force); -static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *iax2_request(const char *type, const struct ast_codec_pref *format, void *data, int *cause); static int iax2_devicestate(void *data); static int iax2_digit(struct ast_channel *c, char digit); static int iax2_sendtext(struct ast_channel *c, const char *text); @@ -1959,7 +1959,7 @@ char iabuf[INET_ADDRSTRLEN]; struct iax2_peer *peer; char codec_buf[512]; - int x = 0, codec = 0, load_realtime = 0; + int load_realtime = 0; if (argc < 4) return RESULT_SHOWUSAGE; @@ -1984,19 +1984,9 @@ ast_getformatname_multiple(codec_buf, sizeof(codec_buf) -1, peer->capability); ast_cli(fd, "%s\n", codec_buf); - ast_cli(fd, " Codec Order : ("); - for(x = 0; x < 32 ; x++) { - codec = ast_codec_pref_index(&peer->prefs,x); - if(!codec) - break; - ast_cli(fd, "%s", ast_getformatname(codec)); - if(x < 31 && ast_codec_pref_index(&peer->prefs,x+1)) - ast_cli(fd, "|"); - } - - if (!x) - ast_cli(fd, "none"); - ast_cli(fd, ")\n"); + ast_cli(fd, " Codec Order : "); + ast_codec_pref_dump(codec_buf, sizeof(codec_buf), &peer->prefs); + ast_cli(fd, "%s\n", codec_buf); ast_cli(fd, " Status : "); peer_status(peer, status, sizeof(status)); @@ -2787,7 +2777,7 @@ memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr)); sin->sin_port = htons(IAX_DEFAULT_PORTNO); /* use global iax prefs for unknown peer/user */ - ast_codec_pref_convert(&prefs, cai->prefs, sizeof(cai->prefs), 1); + ast_codec_pref_convert_to_buf(&prefs, cai->prefs, sizeof(cai->prefs)); return 0; } else { ast_log(LOG_WARNING, "No such host: %s\n", peername); @@ -2816,7 +2806,7 @@ cai->capability = peer->capability; cai->encmethods = peer->encmethods; cai->sockfd = peer->sockfd; - ast_codec_pref_convert(&peer->prefs, cai->prefs, sizeof(cai->prefs), 1); + ast_codec_pref_convert_to_buf(&peer->prefs, cai->prefs, sizeof(cai->prefs)); ast_copy_string(cai->context, peer->context, sizeof(cai->context)); ast_copy_string(cai->peercontext, peer->peercontext, sizeof(cai->peercontext)); ast_copy_string(cai->username, peer->username, sizeof(cai->username)); @@ -3065,7 +3055,7 @@ if (pds.password) ast_copy_string(iaxs[callno]->secret, pds.password, sizeof(iaxs[callno]->secret)); - iax_ie_append_int(&ied, IAX_IE_FORMAT, c->nativeformats); + iax_ie_append_int(&ied, IAX_IE_FORMAT, ast_codec_pref_bits(&c->nativeformats)); iax_ie_append_int(&ied, IAX_IE_CAPABILITY, iaxs[callno]->capability); iax_ie_append_short(&ied, IAX_IE_ADSICPE, c->adsicpe); iax_ie_append_int(&ied, IAX_IE_DATETIME, iax2_datetime(cai.timezone)); @@ -3236,13 +3226,13 @@ } return AST_BRIDGE_FAILED_NOWARN; } - if (c0->nativeformats != c1->nativeformats) { + if (!ast_codec_pref_eq_noorder(&c0->nativeformats, &c1->nativeformats)) { if (option_verbose > 2) { char buf0[255]; char buf1[255]; - ast_getformatname_multiple(buf0, sizeof(buf0) -1, c0->nativeformats); - ast_getformatname_multiple(buf1, sizeof(buf1) -1, c1->nativeformats); - ast_verbose(VERBOSE_PREFIX_3 "Operating with different codecs %d[%s] %d[%s] , can't native bridge...\n", c0->nativeformats, buf0, c1->nativeformats, buf1); + ast_codec_pref_dump(buf0, sizeof(buf0), &c0->nativeformats); + ast_codec_pref_dump(buf1, sizeof(buf1), &c1->nativeformats); + ast_verbose(VERBOSE_PREFIX_3 "Operating with different codecs %d[%s] %d[%s] , can't native bridge...\n", ast_codec_pref_bits(&c0->nativeformats), buf0, ast_codec_pref_bits(&c1->nativeformats), buf1); } /* Remove from native mode */ lock_both(callno0, callno1); @@ -3435,7 +3425,7 @@ snprintf(tmp->name, sizeof(tmp->name), "IAX2/%s-%d", i->host, i->callno); tmp->type = channeltype; /* We can support any format by default, until we get restricted */ - tmp->nativeformats = capability; + ast_codec_pref_set2(&tmp->nativeformats, capability); tmp->readformat = ast_best_codec(capability); tmp->writeformat = ast_best_codec(capability); tmp->tech_pvt = CALLNO_TO_PTR(i->callno); @@ -4786,8 +4776,8 @@ /* Use provided preferences until told otherwise for actual preferences */ if(ies->codec_prefs) { - ast_codec_pref_convert(&iaxs[callno]->rprefs, ies->codec_prefs, 32, 0); - ast_codec_pref_convert(&iaxs[callno]->prefs, ies->codec_prefs, 32, 0); + ast_codec_pref_convert_from_buf(&iaxs[callno]->rprefs, ies->codec_prefs, 32); + ast_codec_pref_convert_from_buf(&iaxs[callno]->prefs, ies->codec_prefs, 32); } if (!gotcapability) @@ -6785,11 +6775,11 @@ } if (iaxs[fr->callno]) { if (iaxs[fr->callno]->owner) { - orignative = iaxs[fr->callno]->owner->nativeformats; - iaxs[fr->callno]->owner->nativeformats = f.subclass; + orignative = ast_codec_pref_bits(&iaxs[fr->callno]->owner->nativeformats); + ast_codec_pref_set2(&iaxs[fr->callno]->owner->nativeformats, f.subclass); if (iaxs[fr->callno]->owner->readformat) ast_set_read_format(iaxs[fr->callno]->owner, iaxs[fr->callno]->owner->readformat); - iaxs[fr->callno]->owner->nativeformats = orignative; + ast_codec_pref_set2(&iaxs[fr->callno]->owner->nativeformats, orignative); ast_mutex_unlock(&iaxs[fr->callno]->owner->lock); } } else { @@ -6934,8 +6924,8 @@ using_prefs = "mine"; /* If the information elements are in here... use them */ if (ies.codec_prefs) - ast_codec_pref_convert(&iaxs[fr->callno]->rprefs, ies.codec_prefs, 32, 0); - if (ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0)) { + ast_codec_pref_convert_from_buf(&iaxs[fr->callno]->rprefs, ies.codec_prefs, 32); + if (ast_codec_pref_index_audio(&iaxs[fr->callno]->rprefs, 0)) { /* If we are codec_first_choice we let the caller have the 1st shot at picking the codec.*/ if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_USER_FIRST)) { pref = iaxs[fr->callno]->rprefs; @@ -6978,7 +6968,7 @@ strcpy(host_pref_buf,"disabled"); } else { using_prefs = "mine"; - if (ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0)) { + if (ast_codec_pref_index_audio(&iaxs[fr->callno]->rprefs, 0)) { /* Do the opposite of what we tried above. */ if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_USER_FIRST)) { pref = iaxs[fr->callno]->prefs; @@ -7132,7 +7122,7 @@ iaxs[fr->callno]->peerformat = ies.format; } else { if (iaxs[fr->callno]->owner) - iaxs[fr->callno]->peerformat = iaxs[fr->callno]->owner->nativeformats; + iaxs[fr->callno]->peerformat = ast_codec_pref_bits(&iaxs[fr->callno]->owner->nativeformats); else iaxs[fr->callno]->peerformat = iaxs[fr->callno]->capability; } @@ -7149,9 +7139,11 @@ ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED); if (iaxs[fr->callno]->owner) { /* Switch us to use a compatible format */ - iaxs[fr->callno]->owner->nativeformats = iaxs[fr->callno]->peerformat; - if (option_verbose > 2) - ast_verbose(VERBOSE_PREFIX_3 "Format for call is %s\n", ast_getformatname(iaxs[fr->callno]->owner->nativeformats)); + ast_codec_pref_set2(&iaxs[fr->callno]->owner->nativeformats, iaxs[fr->callno]->peerformat); + if (option_verbose > 2) { + char buf[512]; + ast_verbose(VERBOSE_PREFIX_3 "Format for call is %s\n", ast_codec_pref_dump(buf, sizeof(buf), &iaxs[fr->callno]->owner->nativeformats)); + } retryowner2: if (ast_mutex_trylock(&iaxs[fr->callno]->owner->lock)) { ast_mutex_unlock(&iaxsl[fr->callno]); @@ -7340,8 +7332,8 @@ } else { using_prefs = "mine"; if (ies.codec_prefs) - ast_codec_pref_convert(&iaxs[fr->callno]->rprefs, ies.codec_prefs, 32, 0); - if (ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0)) { + ast_codec_pref_convert_from_buf(&iaxs[fr->callno]->rprefs, ies.codec_prefs, 32); + if (ast_codec_pref_index_audio(&iaxs[fr->callno]->rprefs, 0)) { if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_USER_FIRST)) { pref = iaxs[fr->callno]->rprefs; using_prefs = "caller"; @@ -7386,7 +7378,7 @@ strcpy(host_pref_buf,"disabled"); } else { using_prefs = "mine"; - if (ast_codec_pref_index(&iaxs[fr->callno]->rprefs, 0)) { + if (ast_codec_pref_index_audio(&iaxs[fr->callno]->rprefs, 0)) { /* Do the opposite of what we tried above. */ if (ast_test_flag(iaxs[fr->callno], IAX_CODEC_USER_FIRST)) { pref = iaxs[fr->callno]->prefs; @@ -7955,11 +7947,9 @@ } } -static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *iax2_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { int callno; - int res; - int fmt, native; struct sockaddr_in sin; struct ast_channel *c; struct parsed_dial_string pds; @@ -8013,22 +8003,8 @@ if (c) { /* Choose a format we can live with */ - if (c->nativeformats & format) - c->nativeformats &= format; - else { - native = c->nativeformats; - fmt = format; - res = ast_translator_best_choice(&fmt, &native); - if (res < 0) { - ast_log(LOG_WARNING, "Unable to create translator path for %s to %s on %s\n", - ast_getformatname(c->nativeformats), ast_getformatname(fmt), c->name); - ast_hangup(c); - return NULL; - } - c->nativeformats = native; - } - c->readformat = ast_best_codec(c->nativeformats); - c->writeformat = c->readformat; + ast_codec_pref_remove2(&c->nativeformats, ~ast_codec_pref_bits(formats)); + c->readformat = c->writeformat = ast_codec_pref_index_audio(&c->nativeformats, 0); } return c; @@ -9390,7 +9366,7 @@ *ptr = '\0'; } index = atoi(codecnum); - if((codec = ast_codec_pref_index(&peer->prefs, index))) { + if((codec = ast_codec_pref_index_audio(&peer->prefs, index))) { ast_copy_string(buf, ast_getformatname(codec), len); } } --- channels/chan_local.c.orig Fri Sep 8 07:37:07 2006 +++ channels/chan_local.c Mon Oct 9 13:01:08 2006 @@ -70,7 +70,7 @@ /* Protect the interface list (of sip_pvt's) */ AST_MUTEX_DEFINE_STATIC(locallock); -static struct ast_channel *local_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *local_request(const char *type, const struct ast_codec_pref *format, void *data, int *cause); static int local_digit(struct ast_channel *ast, char digit); static int local_call(struct ast_channel *ast, char *dest, int timeout); static int local_hangup(struct ast_channel *ast); @@ -468,7 +468,7 @@ } /*--- local_alloc: Create a call structure */ -static struct local_pvt *local_alloc(char *data, int format) +static struct local_pvt *local_alloc(char *data, const struct ast_codec_pref *formats) { struct local_pvt *tmp; char *c; @@ -493,7 +493,7 @@ strncpy(tmp->context, c, sizeof(tmp->context) - 1); } else strncpy(tmp->context, "default", sizeof(tmp->context) - 1); - tmp->reqformat = format; + tmp->reqformat = ast_codec_pref_bits(formats); if (!ast_exists_extension(NULL, tmp->context, tmp->exten, 1, NULL)) { ast_log(LOG_NOTICE, "No such extension/context %s@%s creating local channel\n", tmp->exten, tmp->context); ast_mutex_destroy(&tmp->lock); @@ -529,8 +529,8 @@ } tmp2->tech = tmp->tech = &local_tech; - tmp->nativeformats = p->reqformat; - tmp2->nativeformats = p->reqformat; + ast_codec_pref_append_missing2(&tmp->nativeformats, p->reqformat); + ast_codec_pref_append_missing2(&tmp2->nativeformats, p->reqformat); snprintf(tmp->name, sizeof(tmp->name), "Local/%s@%s-%04x,1", p->exten, p->context, randnum); snprintf(tmp2->name, sizeof(tmp2->name), "Local/%s@%s-%04x,2", p->exten, p->context, randnum); tmp->type = type; @@ -566,12 +566,12 @@ /*--- local_request: Part of PBX interface */ -static struct ast_channel *local_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *local_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { struct local_pvt *p; struct ast_channel *chan = NULL; - p = local_alloc(data, format); + p = local_alloc(data, formats); if (p) chan = local_new(p, AST_STATE_DOWN); return chan; --- channels/chan_mgcp.c.orig Wed Aug 30 21:59:44 2006 +++ channels/chan_mgcp.c Mon Oct 9 13:01:08 2006 @@ -487,7 +487,7 @@ static int mgcp_do_reload(void); static int mgcp_reload(int fd, int argc, char *argv[]); -static struct ast_channel *mgcp_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *mgcp_request(const char *type, const struct ast_codec_pref *format, void *data, int *cause); static int mgcp_call(struct ast_channel *ast, char *dest, int timeout); static int mgcp_hangup(struct ast_channel *ast); static int mgcp_answer(struct ast_channel *ast); @@ -1222,9 +1222,10 @@ if (sub->owner) { /* We already hold the channel lock */ if (f->frametype == AST_FRAME_VOICE) { - if (f->subclass != sub->owner->nativeformats) { + if (f->subclass != sub->owner->nativeformats.audio_bits) { ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); - sub->owner->nativeformats = f->subclass; +/* ast_codec_pref_init(&sub->owner->nativeformats);*/ + ast_codec_pref_append(&sub->owner->nativeformats, f->subclass); ast_set_read_format(sub->owner, sub->owner->readformat); ast_set_write_format(sub->owner, sub->owner->writeformat); } @@ -1263,9 +1264,9 @@ return 0; } } else { - if (!(frame->subclass & ast->nativeformats)) { + if (!(frame->subclass & ast_codec_pref_bits(&ast->nativeformats))) { ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n", - frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat); + frame->subclass, ast_codec_pref_bits(&ast->nativeformats), ast->readformat, ast->writeformat); return -1; } } @@ -1388,10 +1389,10 @@ tmp = ast_channel_alloc(1); if (tmp) { tmp->tech = &mgcp_tech; - tmp->nativeformats = i->capability; - if (!tmp->nativeformats) - tmp->nativeformats = capability; - fmt = ast_best_codec(tmp->nativeformats); + ast_codec_pref_set2(&tmp->nativeformats, i->capability); + if (!ast_codec_pref_bits(&tmp->nativeformats)) + ast_codec_pref_set2(&tmp->nativeformats, capability); + fmt = ast_best_codec(tmp->nativeformats.audio_bits); snprintf(tmp->name, sizeof(tmp->name), "MGCP/%s@%s-%d", i->name, i->parent->name, sub->id); if (sub->rtp) tmp->fds[0] = ast_rtp_fd(sub->rtp); @@ -3477,20 +3478,13 @@ return 0; } -static struct ast_channel *mgcp_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *mgcp_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { - int oldformat; struct mgcp_subchannel *sub; struct ast_channel *tmpc = NULL; char tmp[256]; char *dest = data; - oldformat = format; - format &= capability; - if (!format) { - ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format); - return NULL; - } strncpy(tmp, dest, sizeof(tmp) - 1); if (ast_strlen_zero(tmp)) { ast_log(LOG_NOTICE, "MGCP Channels require an endpoint\n"); @@ -3920,13 +3914,13 @@ return NULL; } -static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active) +static int mgcp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, const struct ast_codec_pref *codecs, int nat_active) { /* XXX Is there such thing as video support with MGCP? XXX */ struct mgcp_subchannel *sub; sub = chan->tech_pvt; if (sub) { - transmit_modify_with_sdp(sub, rtp, codecs); + transmit_modify_with_sdp(sub, rtp, ast_codec_pref_bits(codecs)); return 0; } return -1; --- channels/chan_modem.c.orig Sat Aug 5 08:08:50 2006 +++ channels/chan_modem.c Mon Oct 9 13:01:08 2006 @@ -114,7 +114,7 @@ int dep_warning = 0; -static struct ast_channel *modem_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *modem_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause); static int modem_digit(struct ast_channel *ast, char digit); static int modem_call(struct ast_channel *ast, char *idest, int timeout); static int modem_hangup(struct ast_channel *ast); @@ -566,7 +566,7 @@ snprintf(tmp->name, sizeof(tmp->name), "Modem[%s]/%s", i->mc->name, i->dev + 5); tmp->type = type; tmp->fds[0] = i->fd; - tmp->nativeformats = i->mc->formats; + ast_codec_pref_append_missing2(&tmp->nativeformats, i->mc->formats); ast_setstate(tmp, state); if (state == AST_STATE_RING) tmp->rings = 1; @@ -814,9 +814,8 @@ return tmp; } -static struct ast_channel *modem_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *modem_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { - int oldformat; struct ast_modem_pvt *p; struct ast_channel *tmp = NULL; char dev[80]; @@ -826,7 +825,6 @@ strncpy(dev, (char *)data, sizeof(dev)-1); stringp=dev; strsep(&stringp, ":"); - oldformat = format; if (!dep_warning) { ast_log(LOG_WARNING, "This channel driver is deprecated. Please see the UPGRADE.txt file.\n"); @@ -853,7 +851,7 @@ /* if it belongs to the proper group, and the format matches * and it is not in use, we found a candidate! */ if (p->group & group && - p->mc->formats & format && + p->mc->formats & formats->bits && !p->owner) { /* XXX Not quite sure that not having an owner is * sufficient evidence of beeing a free device XXX */ @@ -863,7 +861,7 @@ } } else { if (!strcmp(dev, p->dev + 5)) { - if (p->mc->formats & format) { + if (p->mc->formats & formats->bits) { if (!p->owner) { tmp = ast_modem_new(p, AST_STATE_DOWN); restart_monitor(); @@ -871,7 +869,7 @@ } else ast_log(LOG_WARNING, "Device '%s' is busy\n", p->dev); } else - ast_log(LOG_WARNING, "Asked for a format %s line on %s\n", ast_getformatname(format), p->dev); + ast_log(LOG_WARNING, "Asked for a format %s line on %s\n", ast_getformatname(formats->bits), p->dev); break; } } --- channels/chan_oss.c.orig Wed Jul 5 18:31:01 2006 +++ channels/chan_oss.c Mon Oct 9 13:01:08 2006 @@ -315,7 +315,7 @@ static int setformat(struct chan_oss_pvt *o, int mode); -static struct ast_channel *oss_request(const char *type, int format, void *data +static struct ast_channel *oss_request(const char *type, const struct ast_codec_pref *formats, void *data , int *cause); static int oss_digit(struct ast_channel *c, char digit); static int oss_text(struct ast_channel *c, const char *text); @@ -881,7 +881,7 @@ snprintf(c->name, sizeof(c->name), "OSS/%s", o->device + 5); c->type = o->type; c->fds[0] = o->sounddev; /* -1 if device closed, override later */ - c->nativeformats = AST_FORMAT_SLINEAR; + ast_codec_pref_append(&c->nativeformats, AST_FORMAT_SLINEAR); c->readformat = AST_FORMAT_SLINEAR; c->writeformat = AST_FORMAT_SLINEAR; c->tech_pvt = o; @@ -912,7 +912,7 @@ } static struct ast_channel *oss_request(const char *type, - int format, void *data, int *cause) + const struct ast_codec_pref *formats, void *data, int *cause) { struct ast_channel *c; struct chan_oss_pvt *o = find_desc(data); @@ -922,10 +922,6 @@ if (o == NULL) { ast_log(LOG_NOTICE, "Device %s not found\n", (char *)data); /* XXX we could default to 'dsp' perhaps ? */ - return NULL; - } - if ((format & AST_FORMAT_SLINEAR) == 0) { - ast_log(LOG_NOTICE, "Format 0x%x unsupported\n", format); return NULL; } if (o->owner) { --- channels/chan_phone.c.orig Wed Aug 30 21:59:44 2006 +++ channels/chan_phone.c Mon Oct 9 13:01:08 2006 @@ -148,7 +148,7 @@ static char cid_num[AST_MAX_EXTENSION]; static char cid_name[AST_MAX_EXTENSION]; -static struct ast_channel *phone_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *phone_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause); static int phone_digit(struct ast_channel *ast, char digit); static int phone_call(struct ast_channel *ast, char *dest, int timeout); static int phone_hangup(struct ast_channel *ast); @@ -797,20 +797,20 @@ /* XXX Switching formats silently causes kernel panics XXX */ if (i->mode == MODE_FXS && ioctl(i->fd, PHONE_QUERY_CODEC, &codec) == 0) { - if (codec.type == LINEAR16) - tmp->nativeformats = + if (codec.type == LINEAR16) { + ast_codec_pref_append(&tmp->nativeformats, AST_FORMAT_SLINEAR); tmp->rawreadformat = tmp->rawwriteformat = AST_FORMAT_SLINEAR; - else { - tmp->nativeformats = + } else { + ast_codec_pref_append_missing2(&tmp->nativeformats, prefformat & ~AST_FORMAT_SLINEAR); tmp->rawreadformat = tmp->rawwriteformat = prefformat & ~AST_FORMAT_SLINEAR; } } else { - tmp->nativeformats = prefformat; + ast_codec_pref_append_missing2(&tmp->nativeformats, prefformat); tmp->rawreadformat = prefformat; tmp->rawwriteformat = prefformat; } @@ -1171,9 +1171,8 @@ return tmp; } -static struct ast_channel *phone_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *phone_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { - int oldformat; struct phone_pvt *p; struct ast_channel *tmp = NULL; char *name = data; @@ -1186,7 +1185,7 @@ p = iflist; while(p) { if (p->mode == MODE_FXS || - format & (AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW)) { + formats->audio_bits & (AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW)) { size_t length = strlen(p->dev + 5); if (strncmp(name, p->dev + 5, length) == 0 && !isalnum(name[length])) { @@ -1201,14 +1200,6 @@ } ast_mutex_unlock(&iflock); restart_monitor(); - if (tmp == NULL) { - oldformat = format; - format &= (AST_FORMAT_G723_1 | AST_FORMAT_SLINEAR | AST_FORMAT_ULAW); - if (!format) { - ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat); - return NULL; - } - } return tmp; } --- channels/chan_sip.c.orig Mon Mar 19 22:20:26 2007 +++ channels/chan_sip.c Tue Mar 20 22:19:38 2007 @@ -447,7 +447,7 @@ #define DEC_CALL_LIMIT 0 #define INC_CALL_LIMIT 1 -static struct ast_codec_pref prefs; +static struct ast_codec_pref global_prefs; /*! \brief sip_request: The data grabbed from the UDP socket */ @@ -596,7 +596,9 @@ int method; /*!< SIP method of this packet */ char callid[128]; /*!< Global CallID */ char randdata[80]; /*!< Random data */ - struct ast_codec_pref prefs; /*!< codec prefs */ + struct ast_codec_pref userprefs; /*!< codec prefs */ + int usercapability; /*!< user capabilities */ + struct ast_codec_pref formats; /*!< current channel formats */ unsigned int ocseq; /*!< Current outgoing seqno */ unsigned int icseq; /*!< Current incoming seqno */ ast_group_t callgroup; /*!< Call group */ @@ -605,10 +607,6 @@ unsigned int flags; /*!< SIP_ flags */ int timer_t1; /*!< SIP timer T1, ms rtt */ unsigned int sipoptions; /*!< Supported SIP sipoptions on the other end */ - int capability; /*!< Special capability (codec) */ - int jointcapability; /*!< Supported capability at both ends (codecs ) */ - int peercapability; /*!< Supported peer capability */ - int prefcodec; /*!< Preferred codec (outbound only) */ int noncodeccapability; int jointnoncodeccapability; int callingpres; /*!< Calling presentation */ @@ -621,7 +619,7 @@ struct sockaddr_in sa; /*!< Our peer */ struct sockaddr_in redirip; /*!< Where our RTP should be going if not to us */ struct sockaddr_in vredirip; /*!< Where our Video RTP should be going if not to us */ - int redircodecs; /*!< Redirect codecs */ + struct ast_codec_pref redircodecs; /*!< Redirect codecs */ struct sockaddr_in recv; /*!< Received as */ struct in_addr ourip; /*!< Our IP */ struct ast_channel *owner; /*!< Who owns us */ @@ -911,7 +909,7 @@ static int expire_register(void *data); static int callevents = 0; -static struct ast_channel *sip_request_call(const char *type, int format, void *data, int *cause); +static struct ast_channel *sip_request_call(const char *type, const struct ast_codec_pref *format, void *data, int *cause); static int sip_devicestate(void *data); static int sip_sendtext(struct ast_channel *ast, const char *text); static int sip_call(struct ast_channel *ast, char *dest, int timeout); @@ -929,6 +927,7 @@ static int check_sip_domain(const char *domain, char *context, size_t len); /* Check if domain is one of our local domains */ static void append_date(struct sip_request *req); /* Append date to SIP packet */ static int determine_firstline_parts(struct sip_request *req); +static void sip_fixup_codecs(struct ast_channel *chan, const struct ast_codec_pref *peer_codecs); static void sip_dump_history(struct sip_pvt *dialog); /* Dump history to LOG_DEBUG at end of dialog, before destroying data */ static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype); static int transmit_state_notify(struct sip_pvt *p, int state, int full, int substate, int timeout); @@ -938,7 +937,7 @@ static const struct ast_channel_tech sip_tech = { .type = channeltype, .description = "Session Initiation Protocol (SIP)", - .capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1), + .capabilities = ((AST_FORMAT_MAX_VIDEO << 1) - 1), .properties = AST_CHAN_TP_WANTSJITTER, .requester = sip_request_call, .devicestate = sip_devicestate, @@ -954,6 +953,7 @@ .send_digit = sip_senddigit, .bridge = ast_rtp_bridge, .send_text = sip_sendtext, + .fixup_codecs = sip_fixup_codecs, }; #ifdef __AST_DEBUG_MALLOC @@ -1884,8 +1884,7 @@ } ast_copy_flags(r, peer, SIP_FLAGS_TO_COPY); - r->capability = peer->capability; - r->prefs = peer->prefs; + r->userprefs = peer->prefs; if (r->rtp) { ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE)); ast_rtp_setnat(r->rtp, (ast_test_flag(r, SIP_NAT) & SIP_NAT_ROUTE)); @@ -2084,8 +2083,25 @@ ast_log(LOG_DEBUG, "Outgoing Call for %s\n", p->username); res = update_call_counter(p, INC_CALL_LIMIT); if ( res != -1 ) { + int x; + int codec_index = 0; + int codec_pt_order[256]; + p->callingpres = ast->cid.cid_pres; - p->jointcapability = p->capability; + ast_codec_pref_init(&p->formats); + ast_rtp_offered_from_local(p->rtp, 0); + if (p->vrtp) + ast_rtp_offered_from_local(p->vrtp, 0); + for (x = 0; x < codec_index; ++x) { + struct rtpPayloadType pt; + pt = ast_rtp_lookup_pt(p->rtp, codec_pt_order[x]); + if (!pt.isAstFormat && !pt.code && p->vrtp) + pt = ast_rtp_lookup_pt(p->vrtp, codec_pt_order[x]); + if (pt.isAstFormat) { + ast_codec_pref_append(&p->formats, pt.code); + } + } + ast_codec_pref_remove2(&p->formats, ~p->usercapability); p->jointnoncodeccapability = p->noncodeccapability; transmit_invite(p, SIP_INVITE, 1, 2); if (p->maxtime) { @@ -2541,12 +2557,18 @@ fmt = ast_getformatbyname(codec); if (fmt) { - ast_log(LOG_NOTICE, "Changing codec to '%s' for this call because of ${SIP_CODEC) variable\n",codec); - if (p->jointcapability & fmt) { - p->jointcapability &= fmt; - p->capability &= fmt; + if (fmt & p->usercapability) + { + ast_log(LOG_NOTICE, "Changing codec to '%s' for this call because of ${SIP_CODEC) variable\n",codec); + if (ast_codec_pref_bits(&p->formats) & fmt) { + ast_codec_pref_set2(&p->formats, fmt); + if (p->owner) { + memcpy(&p->owner->nativeformats, &p->formats, sizeof(p->formats)); + } + } else + ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because it is not shared by both ends.\n"); } else - ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because it is not shared by both ends.\n"); + ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because codec %s is disallowed by user preferences.\n", codec); } else ast_log(LOG_NOTICE, "Ignoring ${SIP_CODEC} variable because of unrecognized/not configured codec (check allow/disallow in sip.conf): %s\n",codec); return; @@ -2582,9 +2604,9 @@ int res = 0; switch (frame->frametype) { case AST_FRAME_VOICE: - if (!(frame->subclass & ast->nativeformats)) { + if (!(frame->subclass & ast->nativeformats.audio_bits)) { ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n", - frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat); + frame->subclass, ast->nativeformats.audio_bits, ast->readformat, ast->writeformat); return 0; } if (p) { @@ -2592,6 +2614,9 @@ if (p->rtp) { /* If channel is not up, activate early media session */ if ((ast->_state != AST_STATE_UP) && !ast_test_flag(p, SIP_PROGRESS_SENT) && !ast_test_flag(p, SIP_OUTGOING)) { + int compatible_codecs = ast_compatible_audio_formats(frame->subclass) | ast->nativeformats.video_bits; + ast_codec_pref_remove2(&ast->nativeformats, ~compatible_codecs); + ast_codec_pref_remove2(&p->formats, ~compatible_codecs); transmit_response_with_sdp(p, "183 Session Progress", &p->initreq, 0); ast_set_flag(p, SIP_PROGRESS_SENT); } @@ -2775,7 +2800,29 @@ return res; } - +/*--- sip_fixup_codecs: try to fixup codec list +*/ +static void sip_fixup_codecs(struct ast_channel *chan, const struct ast_codec_pref *peer_codecs) +{ + struct sip_pvt *p = chan->tech_pvt; + int codecs_to_preserve; + ast_mutex_lock(&p->lock); + if (!ast_test_flag(p, SIP_OUTGOING)) { + /* This is incoming call so its codec list is to be reordered */ + codecs_to_preserve = ast_codec_pref_bits(&chan->nativeformats); + memcpy(&chan->nativeformats, peer_codecs, sizeof(chan->nativeformats)); + } + else { + codecs_to_preserve = ast_codec_pref_bits(peer_codecs); + } + ast_codec_pref_remove2(&chan->nativeformats, ~codecs_to_preserve); + memcpy(&p->formats, &chan->nativeformats, sizeof(chan->nativeformats)); + ast_codec_pref_remove2(&p->formats, ~p->usercapability); + if (AST_STATE_UP == chan->_state) { + transmit_reinvite_with_sdp(p); + } + ast_mutex_unlock(&p->lock); +} /*! \brief sip_new: Initiate a call in the SIP channel */ /* called from sip_request_call (calls from the pbx ) */ @@ -2800,13 +2847,10 @@ tmp->tech = &sip_tech; /* Select our native format based on codec preference until we receive something from another device to the contrary. */ - if (i->jointcapability) - tmp->nativeformats = ast_codec_choose(&i->prefs, i->jointcapability, 1); - else if (i->capability) - tmp->nativeformats = ast_codec_choose(&i->prefs, i->capability, 1); - else - tmp->nativeformats = ast_codec_choose(&i->prefs, global_capability, 1); - fmt = ast_best_codec(tmp->nativeformats); + memcpy(&tmp->nativeformats, &i->formats, sizeof(i->formats)); + + ast_codec_pref_remove2(&tmp->nativeformats, ~i->usercapability); + fmt = ast_codec_pref_index_audio(&tmp->nativeformats, 0); pbx_builtin_setvar_helper(tmp, "SIP_CODEC_USED", ast_getformatname(fmt)); @@ -3045,14 +3089,14 @@ if (p->owner) { /* We already hold the channel lock */ if (f->frametype == AST_FRAME_VOICE) { - if (f->subclass != p->owner->nativeformats) { - if (!(f->subclass & p->jointcapability)) { + if (!(f->subclass & p->owner->nativeformats.audio_bits)) { + if (!(f->subclass & ast_codec_pref_bits(&p->formats))) { ast_log(LOG_DEBUG, "Bogus frame of format '%s' received from '%s'!\n", ast_getformatname(f->subclass), p->owner->name); return &null_frame; } ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); - p->owner->nativeformats = f->subclass; + ast_codec_pref_append(&p->owner->nativeformats, f->subclass); ast_set_read_format(p->owner, p->owner->readformat); ast_set_write_format(p->owner, p->owner->writeformat); } @@ -3118,7 +3162,8 @@ p->autokillid = -1; p->subscribed = NONE; p->stateid = -1; - p->prefs = prefs; + p->userprefs = global_prefs; + p->usercapability = global_capability; if (intended_method != SIP_OPTIONS) /* Peerpoke has it's own system */ p->timer_t1 = 500; /* Default SIP retransmission timer T1 (RFC 3261) */ #ifdef OSP_SUPPORT @@ -3180,7 +3225,6 @@ ast_copy_flags(p, &global_flags, SIP_FLAGS_TO_COPY); /* Assign default music on hold class */ strcpy(p->musicclass, global_musicclass); - p->capability = global_capability; if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO)) p->noncodeccapability |= AST_RTP_DTMF; strcpy(p->context, default_context); @@ -3584,6 +3628,8 @@ int x,y; int debug=sip_debug_test_pvt(p); struct ast_channel *bridgepeer = NULL; + int codec_index = 0; + int codec_pt_order[256]; if (!p->rtp) { ast_log(LOG_ERROR, "Got SDP but have no RTP session allocated.\n"); @@ -3613,6 +3659,12 @@ } sdpLineNum_iterator_init(&iterator, req); ast_set_flag(p, SIP_NOVIDEO); + /* + * We have to scan m= line first, remember codec order then scan a= lines + * and only then build prefs. This is because there is no way to identify dynamic + * payload types before processing a= lines. At the same time we cannot rely + * on a= lines completely since UA may omit them for static payloads. + */ while ((m = get_sdp_iterate(&iterator, req, "m"))[0] != '\0') { int found = 0; if ((sscanf(m, "audio %d/%d RTP/AVP %n", &x, &y, &len) == 2) || @@ -3630,6 +3682,7 @@ if (debug) ast_verbose("Found RTP audio format %d\n", codec); ast_rtp_set_m_type(p->rtp, codec); + codec_pt_order[codec_index++] = codec; codecs = ast_skip_blanks(codecs + len); } } @@ -3650,6 +3703,7 @@ if (debug) ast_verbose("Found RTP video format %d\n", codec); ast_rtp_set_m_type(p->vrtp, codec); + codec_pt_order[codec_index++] = codec; codecs = ast_skip_blanks(codecs + len); } } @@ -3730,6 +3784,20 @@ if (p->vrtp) ast_rtp_set_rtpmap_type(p->vrtp, codec, "video", mimeSubtype); } + ast_codec_pref_init(&p->formats); + ast_rtp_offered_from_local(p->rtp, 0); + if (p->vrtp) + ast_rtp_offered_from_local(p->vrtp, 0); + for (x = 0; x < codec_index; ++x) { + struct rtpPayloadType pt; + pt = ast_rtp_lookup_pt(p->rtp, codec_pt_order[x]); + if (!pt.isAstFormat && !pt.code && p->vrtp) + pt = ast_rtp_lookup_pt(p->vrtp, codec_pt_order[x]); + if (pt.isAstFormat) { + ast_codec_pref_append(&p->formats, pt.code); + } + } + ast_codec_pref_remove2(&p->formats, ~p->usercapability); /* Now gather all of the codecs that were asked for: */ ast_rtp_get_current_formats(p->rtp, @@ -3737,8 +3805,6 @@ if (p->vrtp) ast_rtp_get_current_formats(p->vrtp, &vpeercapability, &vpeernoncodeccapability); - p->jointcapability = p->capability & (peercapability | vpeercapability); - p->peercapability = (peercapability | vpeercapability); p->jointnoncodeccapability = p->noncodeccapability & peernoncodeccapability; if (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO) { @@ -3757,17 +3823,17 @@ char s1[slen], s2[slen], s3[slen], s4[slen]; ast_verbose("Capabilities: us - %s, peer - audio=%s/video=%s, combined - %s\n", - ast_getformatname_multiple(s1, slen, p->capability), + ast_getformatname_multiple(s1, slen, p->usercapability), ast_getformatname_multiple(s2, slen, peercapability), ast_getformatname_multiple(s3, slen, vpeercapability), - ast_getformatname_multiple(s4, slen, p->jointcapability)); + ast_codec_pref_dump(s4, slen, &p->formats)); ast_verbose("Non-codec capabilities: us - %s, peer - %s, combined - %s\n", ast_rtp_lookup_mime_multiple(s1, slen, p->noncodeccapability, 0), ast_rtp_lookup_mime_multiple(s2, slen, peernoncodeccapability, 0), ast_rtp_lookup_mime_multiple(s3, slen, p->jointnoncodeccapability, 0)); } - if (!p->jointcapability) { + if (!ast_codec_pref_bits(&p->formats)) { ast_log(LOG_NOTICE, "No compatible codecs!\n"); return -1; } @@ -3775,16 +3841,7 @@ if (!p->owner) /* There's no open channel owning us */ return 0; - if (!(p->owner->nativeformats & p->jointcapability)) { - const unsigned slen=512; - char s1[slen], s2[slen]; - ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %s and not %s\n", - ast_getformatname_multiple(s1, slen, p->jointcapability), - ast_getformatname_multiple(s2, slen, p->owner->nativeformats)); - p->owner->nativeformats = ast_codec_choose(&p->prefs, p->jointcapability, 1); - ast_set_read_format(p->owner, p->owner->readformat); - ast_set_write_format(p->owner, p->owner->writeformat); - } + memcpy(&p->owner->nativeformats, &p->formats, sizeof(p->formats)); if ((bridgepeer=ast_bridged_channel(p->owner))) { /* We have a bridge */ /* Turn on/off music on hold if we are holding/unholding */ @@ -4481,8 +4538,10 @@ if (debug) ast_verbose("Adding codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec)); - if ((rtp_code = ast_rtp_lookup_code(p->rtp, 1, codec)) == -1) - return; + if ((rtp_code = ast_rtp_lookup_code(p->rtp, 1, codec)) == -1) { + if (!p->vrtp || (rtp_code = ast_rtp_lookup_code(p->vrtp, 1, codec)) == -1) + return; + } ast_build_string(m_buf, m_size, " %d", rtp_code); ast_build_string(a_buf, a_size, "a=rtpmap:%d %s/%d\r\n", rtp_code, @@ -4540,7 +4599,7 @@ size_t a_video_left = sizeof(a_video); char iabuf[INET_ADDRSTRLEN]; int x; - int capability; + const struct ast_codec_pref *capability; struct sockaddr_in dest; struct sockaddr_in vdest = { 0, }; int debug; @@ -4552,7 +4611,7 @@ ast_log(LOG_WARNING, "No way to add SDP without an RTP structure\n"); return -1; } - capability = p->jointcapability; + capability = &p->formats; if (!p->sessionid) { p->sessionid = getpid(); @@ -4565,14 +4624,21 @@ if (p->redirip.sin_addr.s_addr) { dest.sin_port = p->redirip.sin_port; - dest.sin_addr = p->redirip.sin_addr; - if (p->redircodecs) - capability = p->redircodecs; + if (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE) { + dest.sin_port = sin.sin_port; + dest.sin_addr = p->ourip; + } else { + dest.sin_port = p->redirip.sin_port; + dest.sin_addr = p->redirip.sin_addr; + } + if (ast_codec_pref_bits(&p->redircodecs)) { + /* We are to get all compatible with redircodecs codecs */ + capability = &p->redircodecs; + } } else { dest.sin_addr = p->ourip; dest.sin_port = sin.sin_port; } - /* Determine video destination */ if (p->vrtp) { if (p->vredirip.sin_addr.s_addr) { @@ -4602,62 +4668,78 @@ ast_build_string(&m_video_next, &m_video_left, "m=video %d RTP/AVP", ntohs(vdest.sin_port)); /* Prefer the codec we were requested to use, first, no matter what */ - if (capability & p->prefcodec) { - if (p->prefcodec <= AST_FORMAT_MAX_AUDIO) - add_codec_to_sdp(p, p->prefcodec, 8000, - &m_audio_next, &m_audio_left, - &a_audio_next, &a_audio_left, - debug); - else - add_codec_to_sdp(p, p->prefcodec, 90000, - &m_video_next, &m_video_left, - &a_video_next, &a_video_left, - debug); - alreadysent |= p->prefcodec; + pref_codec = ast_codec_pref_index_audio(capability, 0); + if (pref_codec) { + add_codec_to_sdp(p, pref_codec, 8000, + &m_audio_next, &m_audio_left, + &a_audio_next, &a_audio_left, + debug); + alreadysent |= pref_codec; + } + pref_codec = ast_codec_pref_index_video(capability, 0); + if (pref_codec) { + add_codec_to_sdp(p, pref_codec, 90000, + &m_video_next, &m_video_left, + &a_video_next, &a_video_left, + debug); + alreadysent |= pref_codec; } /* Start by sending our preferred codecs */ for (x = 0; x < 32; x++) { - if (!(pref_codec = ast_codec_pref_index(&p->prefs, x))) + if (!(pref_codec = ast_codec_pref_index_audio(&p->userprefs, x))) break; - if (!(capability & pref_codec)) + if (!(capability->audio_bits & pref_codec) || + (alreadysent & pref_codec)) + { continue; + } + add_codec_to_sdp(p, pref_codec, 8000, + &m_audio_next, &m_audio_left, + &a_audio_next, &a_audio_left, + debug); + alreadysent |= pref_codec; + } + for (x = 0; x < 32; x++) { + if (!(pref_codec = ast_codec_pref_index_video(&p->userprefs, x))) + break; - if (alreadysent & pref_codec) + if (!(capability->video_bits & pref_codec) || + (alreadysent & pref_codec)) + { continue; - - if (pref_codec <= AST_FORMAT_MAX_AUDIO) - add_codec_to_sdp(p, pref_codec, 8000, - &m_audio_next, &m_audio_left, - &a_audio_next, &a_audio_left, - debug); - else - add_codec_to_sdp(p, pref_codec, 90000, - &m_video_next, &m_video_left, - &a_video_next, &a_video_left, - debug); + } + add_codec_to_sdp(p, pref_codec, 90000, + &m_video_next, &m_video_left, + &a_video_next, &a_video_left, + debug); alreadysent |= pref_codec; } - /* Now send any other common codecs, and non-codec formats: */ - for (x = 1; x <= ((videosupport && p->vrtp) ? AST_FORMAT_MAX_VIDEO : AST_FORMAT_MAX_AUDIO); x <<= 1) { - if (!(capability & x)) + for (x = 0 ; x < 32 ; x++) { + if(!(pref_codec = ast_codec_pref_index_audio(capability, x))) + break; + if (alreadysent & pref_codec) continue; - if (alreadysent & x) + add_codec_to_sdp(p, pref_codec, 8000, + &m_audio_next, &m_audio_left, + &a_audio_next, &a_audio_left, + debug); + alreadysent |= pref_codec; + } + for (x = 0 ; x < 32 ; x++) { + if(!(pref_codec = ast_codec_pref_index_video(capability, x))) + break; + if (alreadysent & pref_codec) continue; - if (x <= AST_FORMAT_MAX_AUDIO) - add_codec_to_sdp(p, x, 8000, - &m_audio_next, &m_audio_left, - &a_audio_next, &a_audio_left, - debug); - else - add_codec_to_sdp(p, x, 90000, - &m_video_next, &m_video_left, - &a_video_next, &a_video_left, - debug); + add_codec_to_sdp(p, pref_codec, 90000, + &m_video_next, &m_video_left, + &a_video_next, &a_video_left, + debug); + alreadysent |= pref_codec; } for (x = 1; x <= AST_RTP_MAX; x <<= 1) { @@ -4679,7 +4761,7 @@ ast_build_string(&m_video_next, &m_video_left, "\r\n"); len = strlen(v) + strlen(s) + strlen(o) + strlen(c) + strlen(t) + strlen(m_audio) + strlen(a_audio); - if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && (capability & VIDEO_CODEC_MASK)) /* only if video response is appropriate */ + if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && capability->video_bits) /* only if video response is appropriate */ len += strlen(m_video) + strlen(a_video); add_header(resp, "Content-Type", "application/sdp"); @@ -4691,7 +4773,7 @@ add_line(resp, t); add_line(resp, m_audio); add_line(resp, a_audio); - if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && (capability & VIDEO_CODEC_MASK)) { /* only if video response is appropriate */ + if ((p->vrtp) && (!ast_test_flag(p, SIP_NOVIDEO)) && capability->video_bits) { /* only if video response is appropriate */ add_line(resp, m_video); add_line(resp, a_video); } @@ -4729,7 +4811,6 @@ } respprep(&resp, p, msg, req); if (p->rtp) { - ast_rtp_offered_from_local(p->rtp, 0); try_suggested_sip_codec(p); add_sdp(&resp, p); } else { @@ -4804,7 +4885,6 @@ add_header(&req, "Allow", ALLOWED_METHODS); if (sipdebug) add_header(&req, "X-asterisk-info", "SIP re-invite (RTP bridge)"); - ast_rtp_offered_from_local(p->rtp, 1); add_sdp(&req, p); /* Use this as the basis */ copy_request(&p->initreq, &req); @@ -5146,7 +5226,6 @@ } } if (sdp && p->rtp) { - ast_rtp_offered_from_local(p->rtp, 1); add_sdp(&req, p); } else { add_header_contentLength(&req, 0); @@ -7283,7 +7362,8 @@ p->chanvars = tmpvar; } } - p->prefs = user->prefs; + p->usercapability = user->capability; + p->userprefs = user->prefs; /* replace callerid if rpid found, and not restricted */ if (!ast_strlen_zero(rpid_num) && ast_test_flag(p, SIP_TRUSTRPID)) { if (*calleridname) @@ -7331,10 +7411,7 @@ p->pickupgroup = user->pickupgroup; if (user->callingpres) p->callingpres = user->callingpres; - p->capability = user->capability; - p->jointcapability = user->capability; - if (p->peercapability) - p->jointcapability &= p->peercapability; + ast_codec_pref_remove2(&p->formats, ~user->capability); if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO)) p->noncodeccapability |= AST_RTP_DTMF; else @@ -7439,11 +7516,8 @@ p->amaflags = peer->amaflags; p->callgroup = peer->callgroup; p->pickupgroup = peer->pickupgroup; - p->capability = peer->capability; - p->prefs = peer->prefs; - p->jointcapability = peer->capability; - if (p->peercapability) - p->jointcapability &= p->peercapability; + ast_codec_pref_remove2(&p->formats, ~peer->capability); + p->userprefs = peer->prefs; if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(p, SIP_DTMF) == SIP_DTMF_AUTO)) p->noncodeccapability |= AST_RTP_DTMF; else @@ -8052,18 +8126,9 @@ /*! \brief print_codec_to_cli: Print codec list from preference to CLI/manager */ static void print_codec_to_cli(int fd, struct ast_codec_pref *pref) { - int x, codec; - - for(x = 0; x < 32 ; x++) { - codec = ast_codec_pref_index(pref, x); - if (!codec) - break; - ast_cli(fd, "%s", ast_getformatname(codec)); - if (x < 31 && ast_codec_pref_index(pref, x + 1)) - ast_cli(fd, ","); - } - if (!x) - ast_cli(fd, "none"); + char buf[512]; + ast_codec_pref_dump(buf, sizeof(buf), pref); + ast_cli(fd, "%s", buf); } static const char *domain_mode_to_text(const enum domain_mode mode) @@ -8230,10 +8295,9 @@ ast_cli(fd, " Codecs : "); ast_getformatname_multiple(codec_buf, sizeof(codec_buf) -1, peer->capability); ast_cli(fd, "%s\n", codec_buf); - ast_cli(fd, " Codec Order : ("); + ast_cli(fd, " Codec Order : "); print_codec_to_cli(fd, &peer->prefs); - - ast_cli(fd, ")\n"); + ast_cli(fd, "\n"); ast_cli(fd, " Status : "); peer_status(peer, status, sizeof(status)); @@ -8293,11 +8357,19 @@ ast_cli(fd, "CodecOrder: "); pref = &peer->prefs; for(x = 0; x < 32 ; x++) { - codec = ast_codec_pref_index(pref,x); + codec = ast_codec_pref_index_audio(pref,x); + if (!codec) + break; + ast_cli(fd, "%s", ast_getformatname(codec)); + if (x < 31 && ast_codec_pref_index_audio(pref,x+1)) + ast_cli(fd, ","); + } + for(x = 0; x < 32 ; x++) { + codec = ast_codec_pref_index_video(pref,x); if (!codec) break; ast_cli(fd, "%s", ast_getformatname(codec)); - if (x < 31 && ast_codec_pref_index(pref,x+1)) + if (x < 31 && ast_codec_pref_index_video(pref,x+1)) ast_cli(fd, ","); } @@ -8329,9 +8401,8 @@ { char cbuf[256]; struct sip_user *user; - struct ast_codec_pref *pref; struct ast_variable *v; - int x = 0, codec = 0, load_realtime = 0; + int load_realtime = 0; if (argc < 4) return RESULT_SHOWUSAGE; @@ -8358,20 +8429,9 @@ print_group(fd, user->pickupgroup, 0); ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), user->cid_name, user->cid_num, "")); ast_cli(fd, " ACL : %s\n", (user->ha?"Yes":"No")); - ast_cli(fd, " Codec Order : ("); - pref = &user->prefs; - for(x = 0; x < 32 ; x++) { - codec = ast_codec_pref_index(pref,x); - if (!codec) - break; - ast_cli(fd, "%s", ast_getformatname(codec)); - if (x < 31 && ast_codec_pref_index(pref,x+1)) - ast_cli(fd, "|"); - } - - if (!x) - ast_cli(fd, "none"); - ast_cli(fd, ")\n"); + ast_cli(fd, " Codec Order : "); + print_codec_to_cli(fd, &user->prefs); + ast_cli(fd, "\n"); if (user->chanvars) { ast_cli(fd, " Variables :\n"); @@ -8456,7 +8516,7 @@ ast_cli(fd, "\nGlobal Signalling Settings:\n"); ast_cli(fd, "---------------------------\n"); ast_cli(fd, " Codecs: "); - print_codec_to_cli(fd, &prefs); + print_codec_to_cli(fd, &global_prefs); ast_cli(fd, "\n"); ast_cli(fd, " Relax DTMF: %s\n", relaxdtmf ? "Yes" : "No"); ast_cli(fd, " Compact SIP headers: %s\n", compactheaders ? "Yes" : "No"); @@ -8558,7 +8618,7 @@ ast_strlen_zero(cur->username) ? ( ast_strlen_zero(cur->cid_num) ? "(None)" : cur->cid_num ) : cur->username, cur->callid, cur->ocseq, cur->icseq, - ast_getformatname(cur->owner ? cur->owner->nativeformats : 0), + ast_getformatname(cur->owner ? ast_codec_pref_index_audio(&cur->owner->nativeformats, 0) : 0), ast_test_flag(cur, SIP_CALL_ONHOLD) ? "Yes" : "No", ast_test_flag(cur, SIP_NEEDDESTROY) ? "(d)" : "", cur->lastmsg ); @@ -8730,6 +8790,7 @@ char iabuf[INET_ADDRSTRLEN]; size_t len; int found = 0; + char buf[512]; if (argc != 4) return RESULT_SHOWUSAGE; @@ -8745,11 +8806,8 @@ ast_cli(fd, " * SIP Call\n"); ast_cli(fd, " Direction: %s\n", ast_test_flag(cur, SIP_OUTGOING)?"Outgoing":"Incoming"); ast_cli(fd, " Call-ID: %s\n", cur->callid); - ast_cli(fd, " Our Codec Capability: %d\n", cur->capability); ast_cli(fd, " Non-Codec Capability: %d\n", cur->noncodeccapability); - ast_cli(fd, " Their Codec Capability: %d\n", cur->peercapability); - ast_cli(fd, " Joint Codec Capability: %d\n", cur->jointcapability); - ast_cli(fd, " Format %s\n", ast_getformatname(cur->owner ? cur->owner->nativeformats : 0) ); + ast_cli(fd, " Formats %s\n", cur->owner ? ast_codec_pref_dump(buf, sizeof(buf), &cur->owner->nativeformats) : "Unknown"); ast_cli(fd, " Theoretical Address: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), cur->sa.sin_addr), ntohs(cur->sa.sin_port)); ast_cli(fd, " Received Address: %s:%d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), cur->recv.sin_addr), ntohs(cur->recv.sin_port)); ast_cli(fd, " NAT Support: %s\n", nat2str(ast_test_flag(cur, SIP_NAT))); @@ -9559,7 +9617,7 @@ *ptr = '\0'; } index = atoi(codecnum); - if((codec = ast_codec_pref_index(&peer->prefs, index))) { + if((codec = ast_codec_pref_index_audio(&peer->prefs, index))) { ast_copy_string(buf, ast_getformatname(codec), len); } } @@ -10583,7 +10641,6 @@ char *supported; char *required; unsigned int required_profile = 0; - /* Find out what they support */ if (!p->sipoptions) { supported = get_header(req, "Supported"); @@ -10636,7 +10693,6 @@ return -1; } } else { - p->jointcapability = p->capability; ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n"); } } @@ -10668,7 +10724,6 @@ return -1; } } else { - p->jointcapability = p->capability; ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n"); } /* Queue NULL frame to prod ast_rtp_bridge if appropriate */ @@ -10816,7 +10871,7 @@ } } else { if (p && !ast_test_flag(p, SIP_NEEDDESTROY) && !ignore) { - if (!p->jointcapability) { + if (!ast_codec_pref_bits(&p->formats)) { transmit_response_reliable(p, "488 Not Acceptable Here (codec error)", req, 1); } else { ast_log(LOG_NOTICE, "Unable to create/find channel\n"); @@ -11907,22 +11962,14 @@ /*! \brief sip_request: PBX interface function -build SIP pvt structure ---*/ /* SIP calls initiated by the PBX arrive here */ -static struct ast_channel *sip_request_call(const char *type, int format, void *data, int *cause) +static struct ast_channel *sip_request_call(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { - int oldformat; struct sip_pvt *p; struct ast_channel *tmpc = NULL; char *ext, *host; char tmp[256]; char *dest = data; - oldformat = format; - format &= ((AST_FORMAT_MAX_AUDIO << 1) - 1); - if (!format) { - ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format %s while capability is %s\n", ast_getformatname(oldformat), ast_getformatname(global_capability)); - *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; /* Can't find codec to connect to host */ - return NULL; - } p = sip_alloc(NULL, NULL, 0, SIP_INVITE); if (!p) { ast_log(LOG_ERROR, "Unable to build sip pvt data for '%s' (Out of memory)\n", (char *)data); @@ -11955,6 +12002,7 @@ ext = NULL; } } + ast_codec_pref_combine(&p->formats, formats, global_capability); if (create_addr(p, host)) { *cause = AST_CAUSE_UNREGISTERED; @@ -11980,7 +12028,6 @@ #if 0 printf("Setting up to call extension '%s' at '%s'\n", ext ? ext : "", host); #endif - p->prefcodec = format; ast_mutex_lock(&p->lock); tmpc = sip_new(p, AST_STATE_DOWN, host); /* Place the call */ ast_mutex_unlock(&p->lock); @@ -12288,7 +12335,7 @@ user->ha = NULL; ast_copy_flags(user, &global_flags, SIP_FLAGS_TO_COPY); user->capability = global_capability; - user->prefs = prefs; + user->prefs = global_prefs; /* set default context */ strcpy(user->context, default_context); strcpy(user->language, default_language); @@ -12391,7 +12438,7 @@ peer->rtpkeepalive = global_rtpkeepalive; ast_set_flag(peer, SIP_SELFDESTRUCT); ast_set_flag(&peer->flags_page2, SIP_PAGE2_DYNAMIC); - peer->prefs = prefs; + peer->prefs = global_prefs; reg_source_db(peer); return peer; @@ -12473,7 +12520,7 @@ peer->pickupgroup = 0; peer->rtpkeepalive = global_rtpkeepalive; peer->maxms = default_qualify; - peer->prefs = prefs; + peer->prefs = global_prefs; oldha = peer->ha; peer->ha = NULL; peer->addr.sin_family = AF_INET; @@ -12696,7 +12743,7 @@ memset(&bindaddr, 0, sizeof(bindaddr)); memset(&localaddr, 0, sizeof(localaddr)); memset(&externip, 0, sizeof(externip)); - memset(&prefs, 0 , sizeof(prefs)); + memset(&global_prefs, 0 , sizeof(global_prefs)); sipdebug &= ~SIP_DEBUG_CONFIG; /* Initialize some reasonable defaults at SIP reload */ @@ -12894,9 +12941,9 @@ externrefresh = 10; } } else if (!strcasecmp(v->name, "allow")) { - ast_parse_allow_disallow(&prefs, &global_capability, v->value, 1); + ast_parse_allow_disallow(&global_prefs, &global_capability, v->value, 1); } else if (!strcasecmp(v->name, "disallow")) { - ast_parse_allow_disallow(&prefs, &global_capability, v->value, 0); + ast_parse_allow_disallow(&global_prefs, &global_capability, v->value, 0); } else if (!strcasecmp(v->name, "allowexternaldomains")) { allow_external_domains = ast_true(v->value); } else if (!strcasecmp(v->name, "autodomain")) { @@ -13103,7 +13150,7 @@ } /*! \brief sip_set_rtp_peer: Set the RTP peer for this call ---*/ -static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active) +static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, const struct ast_codec_pref *codecs, int nat_active) { struct sip_pvt *p; int changed = 0; @@ -13124,8 +13171,10 @@ memset(&p->vredirip, 0, sizeof(p->vredirip)); changed = 1; } - if (codecs && (p->redircodecs != codecs)) { - p->redircodecs = codecs; + if (codecs && ast_codec_pref_bits(codecs) && + !ast_codec_pref_eq_noorder(codecs, &p->redircodecs)) + { + memcpy(&p->redircodecs, codecs, sizeof(p->redircodecs)); changed = 1; } if (changed && !ast_test_flag(p, SIP_GOTREFER)) { @@ -13393,20 +13442,12 @@ return -1; } -/*! \brief sip_get_codec: Return SIP UA's codec (part of the RTP interface) ---*/ -static int sip_get_codec(struct ast_channel *chan) -{ - struct sip_pvt *p = chan->tech_pvt; - return p->peercapability; -} - /*! \brief sip_rtp: Interface structure with callbacks used to connect to rtp module --*/ static struct ast_rtp_protocol sip_rtp = { type: channeltype, get_rtp_info: sip_get_rtp_peer, get_vrtp_info: sip_get_vrtp_peer, set_rtp_peer: sip_set_rtp_peer, - get_codec: sip_get_codec, }; /*! \brief sip_poke_all_peers: Send a poke to all known peers */ --- channels/chan_skinny.c.orig Wed Aug 30 21:59:44 2006 +++ channels/chan_skinny.c Mon Oct 9 13:01:08 2006 @@ -897,7 +897,7 @@ struct skinnysession *next; } *sessions = NULL; -static struct ast_channel *skinny_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *skinny_request(const char *type, const struct ast_codec_pref *format, void *data, int *cause); static int skinny_call(struct ast_channel *ast, char *dest, int timeout); static int skinny_hangup(struct ast_channel *ast); static int skinny_answer(struct ast_channel *ast); @@ -1343,7 +1343,7 @@ return NULL; } -static int skinny_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active) +static int skinny_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, const struct ast_codec_pref *codecs, int nat_active) { struct skinny_subchannel *sub; sub = chan->tech_pvt; @@ -2050,9 +2050,9 @@ if (sub->owner) { /* We already hold the channel lock */ if (f->frametype == AST_FRAME_VOICE) { - if (f->subclass != sub->owner->nativeformats) { + if (!(f->subclass & ast_codec_pref_bits(&sub->owner->nativeformats))) { ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); - sub->owner->nativeformats = f->subclass; + ast_codec_pref_append(&sub->owner->nativeformats, f->subclass); ast_set_read_format(sub->owner, sub->owner->readformat); ast_set_write_format(sub->owner, sub->owner->writeformat); } @@ -2083,9 +2083,9 @@ return 0; } } else { - if (!(frame->subclass & ast->nativeformats)) { + if (!(frame->subclass & ast_codec_pref_bits(&ast->nativeformats))) { ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n", - frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat); + frame->subclass, ast_codec_pref_bits(&ast->nativeformats), ast->readformat, ast->writeformat); return -1; } } @@ -2241,11 +2241,11 @@ tmp = ast_channel_alloc(1); if (tmp) { tmp->tech = &skinny_tech; - tmp->nativeformats = l->capability; - if (!tmp->nativeformats) - tmp->nativeformats = capability; - fmt = ast_best_codec(tmp->nativeformats); - ast_verbose("skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt); + ast_codec_pref_append_missing2(&tmp->nativeformats, l->capability); + if (!ast_codec_pref_bits(&tmp->nativeformats)) + ast_codec_pref_append_missing2(&tmp->nativeformats, capability); + fmt = ast_best_codec(ast_codec_pref_bits(&tmp->nativeformats)); + ast_verbose("skinny_new: tmp->nativeformats=%d fmt=%d\n", ast_codec_pref_bits(&tmp->nativeformats), fmt); snprintf(tmp->name, sizeof(tmp->name), "Skinny/%s@%s-%d", l->name, l->parent->name, sub->callid); if (sub->rtp) { tmp->fds[0] = ast_rtp_fd(sub->rtp); @@ -3032,20 +3032,13 @@ return 0; } -static struct ast_channel *skinny_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *skinny_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { - int oldformat; struct skinny_subchannel *sub; struct ast_channel *tmpc = NULL; char tmp[256]; char *dest = data; - oldformat = format; - format &= capability; - if (!format) { - ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format); - return NULL; - } strncpy(tmp, dest, sizeof(tmp) - 1); if (ast_strlen_zero(tmp)) { ast_log(LOG_NOTICE, "Skinny channels require a device\n"); --- channels/chan_zap.c.orig Fri Aug 25 18:21:18 2006 +++ channels/chan_zap.c Mon Oct 9 13:01:08 2006 @@ -689,7 +689,7 @@ } *iflist = NULL, *ifend = NULL; -static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause); +static struct ast_channel *zt_request(const char *type, const struct ast_codec_pref *format, void *data, int *cause); static int zt_digit(struct ast_channel *ast, char digit); static int zt_sendtext(struct ast_channel *c, const char *text); static int zt_call(struct ast_channel *ast, char *rdest, int timeout); @@ -5022,7 +5022,7 @@ } while (x < 3); tmp->type = type; tmp->fds[0] = i->subs[index].zfd; - tmp->nativeformats = AST_FORMAT_SLINEAR | deflaw; + ast_codec_pref_append_missing2(&tmp->nativeformats, AST_FORMAT_SLINEAR | deflaw); /* Start out assuming ulaw since it's smaller :) */ tmp->rawreadformat = deflaw; tmp->readformat = deflaw; @@ -7443,9 +7443,8 @@ } #endif -static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause) +static struct ast_channel *zt_request(const char *type, const struct ast_codec_pref *formats, void *data, int *cause) { - int oldformat; int groupmatch = 0; int channelmatch = -1; int roundrobin = 0; @@ -7474,13 +7473,6 @@ lock = &iflock; start = iflist; end = ifend; - /* We do signed linear */ - oldformat = format; - format &= (AST_FORMAT_SLINEAR | AST_FORMAT_ULAW); - if (!format) { - ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", oldformat); - return NULL; - } if (data) { dest = ast_strdupa((char *)data); } else { @@ -8103,9 +8095,12 @@ } if (nextidle > -1) { if (ast_tvdiff_ms(ast_tvnow(), lastidle) > 1000) { + struct ast_codec_pref ulaw; + ast_codec_pref_init(&ulaw); + ast_codec_pref_append(&ulaw, AST_FORMAT_ULAW); /* Don't create a new idle call more than once per second */ snprintf(idlen, sizeof(idlen), "%d/%s", pri->pvts[nextidle]->channel, pri->idledial); - idle = zt_request("Zap", AST_FORMAT_ULAW, idlen, &cause); + idle = zt_request("Zap", &ulaw, idlen, &cause); if (idle) { pri->pvts[nextidle]->isidlecall = 1; if (ast_pthread_create(&p, NULL, do_idle_thread, idle)) { --- channels/iax2-parser.c.orig Tue Nov 29 20:24:39 2005 +++ channels/iax2-parser.c Mon Oct 9 13:01:08 2006 @@ -94,7 +94,7 @@ strncpy(output, value, maxlen); output[maxlen] = '\0'; - ast_codec_pref_convert(&pref, output, total_len, 0); + ast_codec_pref_convert_from_buf(&pref, output, total_len); memset(output,0,total_len); ast_codec_pref_string(&pref, output, total_len); } --- cli.c.orig Mon Feb 27 17:20:48 2006 +++ ./cli.c Mon Oct 9 13:01:08 2006 @@ -780,7 +780,7 @@ c->name, c->type, c->uniqueid, (c->cid.cid_num ? c->cid.cid_num : "(N/A)"), (c->cid.cid_name ? c->cid.cid_name : "(N/A)"), - (c->cid.cid_dnid ? c->cid.cid_dnid : "(N/A)" ), ast_state2str(c->_state), c->_state, c->rings, c->nativeformats, c->writeformat, c->readformat, + (c->cid.cid_dnid ? c->cid.cid_dnid : "(N/A)" ), ast_state2str(c->_state), c->_state, c->rings, ast_codec_pref_bits(&c->nativeformats), c->writeformat, c->readformat, c->fds[0], c->fin & 0x7fffffff, (c->fin & 0x80000000) ? " (DEBUGGED)" : "", c->fout & 0x7fffffff, (c->fout & 0x80000000) ? " (DEBUGGED)" : "", (long)c->whentohangup, cdrtime, c->_bridge ? c->_bridge->name : "", ast_bridged_channel(c) ? ast_bridged_channel(c)->name : "", --- file.c.orig Wed Jun 14 05:20:22 2006 +++ ./file.c Mon Oct 9 13:01:08 2006 @@ -801,6 +801,7 @@ { struct ast_filestream *fs; struct ast_filestream *vfs; + char buf[512]; fs = ast_openstream(chan, filename, preflang); vfs = ast_openvstream(chan, filename, preflang); @@ -821,7 +822,7 @@ #endif return 0; } - ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname(chan->nativeformats), strerror(errno)); + ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_codec_pref_dump(buf, sizeof(buf), &chan->nativeformats), strerror(errno)); return -1; } --- frame.c.orig Mon Jul 31 07:06:16 2006 +++ ./frame.c Mon Oct 9 13:01:08 2006 @@ -870,30 +870,54 @@ return 0; } -void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size, int right) +void ast_codec_pref_convert_to_buf(const struct ast_codec_pref *pref, char *buf, size_t size) { - int x = 0, differential = (int) 'A', mem = 0; - char *from = NULL, *to = NULL; - - if(right) { - from = pref->order; - to = buf; - mem = size; - } else { - to = pref->order; - from = buf; - mem = 32; + int limit = size < 32 ? size : 32; + int i; + int x = 0; + + memset(buf, 0, size); + for (i = 0; i < limit; ++i) + { + if (!pref->audio_order[i]) + break; + buf[i] = pref->audio_order[i] + (int) 'A'; + } + x = i; + for (i = 0; (i + x) < limit; ++i) + { + if (!pref->video_order[i]) + break; + buf[i + x] = pref->video_order[i] + (int) 'A'; } +} - memset(to, 0, mem); - for (x = 0; x < 32 ; x++) { - if(!from[x]) +void ast_codec_pref_convert_from_buf(struct ast_codec_pref *pref, char *buf, size_t size) +{ + int i; + int limit = size < 32 ? size : 32; + int slot; + static int max_slot = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list); + + ast_codec_pref_init(pref); + for (i = 0; i < limit; ++i) + { + if (!buf[i]) break; - to[x] = right ? (from[x] + differential) : (from[x] - differential); + slot = buf[i] - 1 - (int) 'A'; + if (slot >= 0 && slot < max_slot) { + ast_codec_pref_append(pref, AST_FORMAT_LIST[slot].bits); + } } } -int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size) +char *ast_codec_pref_dump(char *buf, size_t size, const struct ast_codec_pref *pref) +{ + ast_codec_pref_string(pref, buf, size); + return buf; +} + +int ast_codec_pref_string(const struct ast_codec_pref *pref, char *buf, size_t size) { int x = 0, codec = 0; size_t total_len = 0, slen = 0; @@ -906,7 +930,7 @@ for(x = 0; x < 32 ; x++) { if(total_len <= 0) break; - if(!(codec = ast_codec_pref_index(pref,x))) + if(!(codec = ast_codec_pref_index_audio(pref,x))) break; if((formatname = ast_getformatname(codec))) { slen = strlen(formatname); @@ -915,7 +939,28 @@ strncat(buf,formatname,total_len); total_len -= slen; } - if(total_len && x < 31 && ast_codec_pref_index(pref , x + 1)) { + if(total_len && x < 31 && ast_codec_pref_index_audio(pref , x + 1)) { + strncat(buf,"|",total_len); + total_len--; + } + } + if ((slen <= total_len) && pref->video_bits) { + strncat(buf,"|",total_len); + total_len--; + } + for(x = 0; x < 32 ; x++) { + if(total_len <= 0) + break; + if(!(codec = ast_codec_pref_index_video(pref,x))) + break; + if((formatname = ast_getformatname(codec))) { + slen = strlen(formatname); + if(slen > total_len) + break; + strncat(buf,formatname,total_len); + total_len -= slen; + } + if(total_len && x < 31 && ast_codec_pref_index_video(pref , x + 1)) { strncat(buf,"|",total_len); total_len--; } @@ -928,18 +973,34 @@ return size - total_len; } -int ast_codec_pref_index(struct ast_codec_pref *pref, int index) +int ast_codec_pref_index_audio(const struct ast_codec_pref *pref, int index) { int slot = 0; - if((index >= 0) && (index < sizeof(pref->order))) { - slot = pref->order[index]; + if((index >= 0) && (index < sizeof(pref->audio_order))) { + slot = pref->audio_order[index]; } return slot ? AST_FORMAT_LIST[slot-1].bits : 0; } +int ast_codec_pref_index_video(const struct ast_codec_pref *pref, int index) +{ + int slot = 0; + + + if((index >= 0) && (index < sizeof(pref->video_order))) { + slot = pref->video_order[index]; + } + + return slot ? AST_FORMAT_LIST[slot-1].bits : 0; +} + +int ast_codec_pref_bits(const struct ast_codec_pref *pref) { + return pref->audio_bits | pref->video_bits; +} + /*! \brief ast_codec_pref_remove: Remove codec from pref list ---*/ void ast_codec_pref_remove(struct ast_codec_pref *pref, int format) { @@ -948,29 +1009,49 @@ size_t size = 0; int slot = 0; - if(!pref->order[0]) + if (!(pref->audio_order[0] + pref->video_order[0]) || + !(ast_codec_pref_bits(pref) & format)) + { return; - + } size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list); memcpy(&oldorder,pref,sizeof(struct ast_codec_pref)); memset(pref,0,sizeof(struct ast_codec_pref)); for (x = 0; x < size; x++) { - slot = oldorder.order[x]; + slot = oldorder.audio_order[x]; if(! slot) break; - if(AST_FORMAT_LIST[slot-1].bits != format) - pref->order[y++] = slot; + if(AST_FORMAT_LIST[slot-1].bits != format) { + pref->audio_order[y++] = slot; + pref->audio_bits |= AST_FORMAT_LIST[slot - 1].bits; + } + } + for (y = 0, x = 0; x < size; x++) { + slot = oldorder.video_order[x]; + if(! slot) + break; + if(AST_FORMAT_LIST[slot-1].bits != format) { + pref->video_order[y++] = slot; + pref->video_bits |= AST_FORMAT_LIST[slot - 1].bits; + } } - } /*! \brief ast_codec_pref_append: Append codec to list ---*/ int ast_codec_pref_append(struct ast_codec_pref *pref, int format) { size_t size = 0; - int x = 0, newindex = -1; + int x = 0, newindex = 0; + char *order = format < AST_FORMAT_MAX_AUDIO ? + pref->audio_order : + pref->video_order; + int *bits = format < AST_FORMAT_MAX_AUDIO ? + &pref->audio_bits : + &pref->video_bits; + if (!format) + return 0; ast_codec_pref_remove(pref, format); size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list); @@ -984,8 +1065,9 @@ if(newindex) { for (x = 0; x < size; x++) { - if(!pref->order[x]) { - pref->order[x] = newindex; + if(!order[x]) { + order[x] = newindex; + *bits |= format; break; } } @@ -1003,7 +1085,20 @@ size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list); for (x = 0; x < size; x++) { - slot = pref->order[x]; + slot = pref->audio_order[x]; + + if(!slot) + break; + if ( formats & AST_FORMAT_LIST[slot-1].bits ) { + ret = AST_FORMAT_LIST[slot-1].bits; + break; + } + } + if(ret) + return ret; + + for (x = 0; x < size; x++) { + slot = pref->video_order[x]; if(!slot) break; @@ -1048,6 +1143,108 @@ memset(pref, 0, sizeof(*pref)); } } + } +} + +void ast_codec_pref_append_missing2(struct ast_codec_pref *pref, int newformats) +{ + int i; + int format; + + for (i = 0; i < 32; ++i) { + format = (1 << i); + if (!(format & ast_codec_pref_bits(pref)) && + (format & newformats)) + { + ast_codec_pref_append(pref, format); + } + } +} + +void ast_codec_pref_append_missing(struct ast_codec_pref *pref, const struct ast_codec_pref *newformats) +{ + int i; + int format; + const int size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list); + int slot; + + for (i = 0; i < size; i++) { + if (!(slot = newformats->audio_order[i])) + break; + format = AST_FORMAT_LIST[slot - 1].bits; + if (!(format & pref->audio_bits)) + ast_codec_pref_append(pref, format); + } + for (i = 0; i < size; i++) { + if (!(slot = newformats->video_order[i])) + break; + format = AST_FORMAT_LIST[slot - 1].bits; + if (!(format & pref->video_bits)) + ast_codec_pref_append(pref, format); + } +} + +void ast_codec_pref_init(struct ast_codec_pref *pref) +{ + memset(pref, 0, sizeof(*pref)); +} + +void ast_codec_pref_set2(struct ast_codec_pref *pref, int formats) +{ + ast_codec_pref_init(pref); + ast_codec_pref_append_missing2(pref, formats); +} + +int ast_codec_pref_intersect(const struct ast_codec_pref *pref1, const struct ast_codec_pref *pref2) +{ + return (pref1->video_bits | pref1->audio_bits) & + (pref2->video_bits | pref2->audio_bits); +} + +int ast_codec_pref_eq_noorder(const struct ast_codec_pref *pref1, const struct ast_codec_pref *pref2) +{ + return (pref1->video_bits | pref1->audio_bits) == + (pref2->video_bits | pref2->audio_bits); +} + +void ast_codec_pref_combine(struct ast_codec_pref *dest, + const struct ast_codec_pref *main, + const int mask) +{ + const int size = sizeof(AST_FORMAT_LIST) / sizeof(struct ast_format_list); + int i; + int slot; + int format; + + ast_codec_pref_init(dest); + for (i = 0; i < size; ++i) + { + if (!(slot = main->audio_order[i])) + break; + format = AST_FORMAT_LIST[slot - 1].bits; + if (mask & format) + ast_codec_pref_append(dest, format); + } + for (i = 0; i < size; ++i) + { + if (!(slot = main->video_order[i])) + break; + format = AST_FORMAT_LIST[slot - 1].bits; + if (mask & format) + ast_codec_pref_append(dest, format); + } +} + +void ast_codec_pref_remove2(struct ast_codec_pref *pref, int formats) +{ + int i; + int format; + + for (i = 0; i < 32; ++i) + { + format = (1 << i); + if (format & formats & ast_codec_pref_bits(pref)) + ast_codec_pref_remove(pref, format); } } --- include/asterisk/channel.h.orig Thu Jun 1 23:27:50 2006 +++ include/asterisk/channel.h Mon Oct 9 13:01:08 2006 @@ -114,6 +114,7 @@ #include "asterisk/cdr.h" #include "asterisk/utils.h" #include "asterisk/linkedlists.h" +#include "asterisk/translate.h" #define MAX_LANGUAGE 20 @@ -182,7 +183,7 @@ int properties; /*! Requester - to set up call data structures (pvt's) */ - struct ast_channel *(* const requester)(const char *type, int format, void *data, int *cause); + struct ast_channel *(* const requester)(const char *type, const struct ast_codec_pref *format, void *data, int *cause); /*! Devicestate call back */ int (* const devicestate)(void *data); @@ -242,6 +243,9 @@ /*! Find bridged channel */ struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge); + + /*! Try to fixup codecs */ + void (*fixup_codecs)(struct ast_channel *chan, const struct ast_codec_pref *peer_codecs); }; struct ast_channel_spy_list; @@ -328,9 +332,11 @@ int rings; /*! Kinds of data this channel can natively handle */ - int nativeformats; + struct ast_codec_pref nativeformats; /*! Requested read format */ int readformat; + /*! Format of last frame read */ + int lastreadformat; /*! Requested write format */ int writeformat; @@ -401,9 +407,9 @@ struct ast_frame *readq; int alertpipe[2]; /*! Write translation path */ - struct ast_trans_pvt *writetrans; + struct ast_trans_pvt *writetrans_matrix[MAX_FORMAT][MAX_FORMAT]; /*! Read translation path */ - struct ast_trans_pvt *readtrans; + struct ast_trans_pvt *readtrans_matrix[MAX_FORMAT][MAX_FORMAT]; /*! Raw read format */ int rawreadformat; /*! Raw write format */ @@ -570,7 +576,7 @@ * by the low level module * \return Returns an ast_channel on success, NULL on failure. */ -struct ast_channel *ast_request(const char *type, int format, void *data, int *status); +struct ast_channel *ast_request(const char *type, const struct ast_codec_pref *formats, void *data, int *status); /*! * \brief Request a channel of a given type, with data as optional information used @@ -585,9 +591,9 @@ * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state * to know if the call was answered or not. */ -struct ast_channel *ast_request_and_dial(const char *type, int format, void *data, int timeout, int *reason, const char *cidnum, const char *cidname); +struct ast_channel *ast_request_and_dial(const char *type, const struct ast_codec_pref *format, void *data, int timeout, int *reason, const char *cidnum, const char *cidname); -struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *reason, const char *cidnum, const char *cidname, struct outgoing_helper *oh); +struct ast_channel *__ast_request_and_dial(const char *type, const struct ast_codec_pref *format, void *data, int timeout, int *reason, const char *cidnum, const char *cidname, struct outgoing_helper *oh); /*!\brief Register a channel technology (a new channel driver) * Called by a channel module to register the kind of channels it supports. --- include/asterisk/frame.h.orig Tue Nov 29 20:24:39 2005 +++ include/asterisk/frame.h Mon Oct 9 13:01:08 2006 @@ -34,7 +34,10 @@ #include "asterisk/endian.h" struct ast_codec_pref { - char order[32]; + char audio_order[32]; + char video_order[32]; + int audio_bits; + int video_bits; }; /*! \page Def_Frame AST Multimedia and signalling frames @@ -191,6 +194,8 @@ #define AST_FORMAT_SPEEX (1 << 9) /*! iLBC Free Compression */ #define AST_FORMAT_ILBC (1 << 10) +/*! ADPCM (G.726, 40kbps) */ +#define AST_FORMAT_G726_40 (1 << 11) /*! Maximum audio format */ #define AST_FORMAT_MAX_AUDIO (1 << 15) /*! JPEG Images */ @@ -423,12 +428,24 @@ /*! \brief Initialize a codec preference to "no preference" */ extern void ast_codec_pref_init(struct ast_codec_pref *pref); -/*! \brief Codec located at a particular place in the preference index */ -extern int ast_codec_pref_index(struct ast_codec_pref *pref, int index); +/*! \brief Return bitmap of common codecs of the two preferences */ +extern int ast_codec_pref_intersect(const struct ast_codec_pref *pref1, const struct ast_codec_pref *pref2); + +/*! \brief Returns true if both prefs consists of the same set of codecs disregarding their order */ +extern int ast_codec_pref_eq_noorder(const struct ast_codec_pref *pref1, const struct ast_codec_pref *pref2); + +/*! \brief Audio codec located at a particular place in the preference index */ +extern int ast_codec_pref_index_audio(const struct ast_codec_pref *pref, int index); + +/*! \brief Video codec located at a particular place in the preference index */ +extern int ast_codec_pref_index_video(const struct ast_codec_pref *pref, int index); /*! \brief Remove a codec from a preference list */ extern void ast_codec_pref_remove(struct ast_codec_pref *pref, int format); +/*! \brief Returns the full bitmap of all codecs */ +extern int ast_codec_pref_bits(const struct ast_codec_pref *pref); + /*! \brief Append a codec to a preference list, removing it first if it was already there */ extern int ast_codec_pref_append(struct ast_codec_pref *pref, int format); @@ -441,10 +458,15 @@ extern void ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char *list, int allowing); /*! \brief Dump codec preference list into a string */ -extern int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size); +extern int ast_codec_pref_string(const struct ast_codec_pref *pref, char *buf, size_t size); + +/*! \brief Dump codec preference list into a string */ +extern char *ast_codec_pref_dump(char *buf, size_t size, const struct ast_codec_pref *pref); -/*! \brief Shift a codec preference list up or down 65 bytes so that it becomes an ASCII string */ -extern void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size, int right); +/*! \brief Shift a codec preference list up 65 bytes so that it becomes an ASCII string */ +extern void ast_codec_pref_convert_to_buf(const struct ast_codec_pref *pref, char *buf, size_t size); +/*! \brief Shift a codec preference list down 65 bytes so that it becomes an codec set */ +extern void ast_codec_pref_convert_from_buf(struct ast_codec_pref *pref, char *buf, size_t size); /*! \brief Returns the number of samples contained in the frame */ extern int ast_codec_get_samples(struct ast_frame *f); @@ -457,6 +479,57 @@ { return (format == AST_FORMAT_ILBC) ? 30 : 20; } + +/*! + * \brief Append codecs. + * \param pref Codec set to be modified. + * \param newformats Bitmap of codecs to be appended. + * + * Append codecs from newformats to pref but only those that are not + * already in the pref. + */ +void ast_codec_pref_append_missing2(struct ast_codec_pref *pref, int newformats); + +/*! + * \brief Append codecs. + * \param pref Codec set to be modified. + * \param newformats Codecs to be appended. + * + * Append codecs from newformats to pref but only those that are not + * already in the pref. Codecs appended after last codec in pref using + * order from newformats. + */ +void ast_codec_pref_append_missing(struct ast_codec_pref *pref, const struct ast_codec_pref *newformats); + +/*! + * \brief Clear the pref then append formats given. + * \param pref Codec set to be set. + * \param formats Bitmap of codecs to be put to pref. + * + * Clears pref and puts given formats into it. Codec order is not well + * predictable so avoid using this function if codec order is important. + */ +void ast_codec_pref_set2(struct ast_codec_pref *pref, int formats); + +/*! + * \brief Combine codecs from main and mask and put them to dest. + * \param dest Codec set to be modified. + * \param main Source codec set. + * \param mask Bitmap of formats. + * + * Set dest to all codecs from main (in that order) but only + * those that exist in mask. Previous content of dest is destroyed. + */ +void ast_codec_pref_combine(struct ast_codec_pref *dest, const struct ast_codec_pref *main, const int mask); + +/*! + * \brief Remove codecs. + * \param pref Codec set to be modified. + * \param formats Bitmap of codecs to be removed. + * + * Removes codecs that passed in bitmap formats from codec set pref. + */ +void ast_codec_pref_remove2(struct ast_codec_pref *pref, int formats); /*! \brief Adjusts the volume of the audio samples contained in a frame. --- include/asterisk/options.h.orig Mon May 1 23:44:24 2006 +++ include/asterisk/options.h Mon Oct 9 13:01:08 2006 @@ -60,6 +60,9 @@ #define VERBOSE_PREFIX_3 " -- " #define VERBOSE_PREFIX_4 " > " +enum ast_trans_algorithm { AST_TRANS_ALG_STRICT, AST_TRANS_ALG_LOOSE }; +extern enum ast_trans_algorithm option_translation_algorithm; + #if defined(__cplusplus) || defined(c_plusplus) } #endif --- include/asterisk/pbx.h.orig Wed Mar 29 22:11:18 2006 +++ include/asterisk/pbx.h Mon Oct 9 13:01:08 2006 @@ -563,11 +563,11 @@ /* Synchronously or asynchronously make an outbound call and send it to a particular extension */ -int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel); +int ast_pbx_outgoing_exten(const char *type, const struct ast_codec_pref *formats, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel); /* Synchronously or asynchronously make an outbound call and send it to a particular application with given extension */ -int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel); +int ast_pbx_outgoing_app(const char *type, const struct ast_codec_pref *formats, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel); /* Evaluate a condition for non-falseness and return a boolean */ int pbx_checkcondition(char *condition); --- include/asterisk/rtp.h.orig Fri Sep 1 20:35:06 2006 +++ include/asterisk/rtp.h Mon Oct 9 13:01:08 2006 @@ -53,10 +53,16 @@ /* Get RTP struct, or NULL if unwilling to transfer */ struct ast_rtp *(* const get_vrtp_info)(struct ast_channel *chan); /* Set RTP peer */ - int (* const set_rtp_peer)(struct ast_channel *chan, struct ast_rtp *peer, struct ast_rtp *vpeer, int codecs, int nat_active); - int (* const get_codec)(struct ast_channel *chan); + int (* const set_rtp_peer)(struct ast_channel *chan, struct ast_rtp *peer, struct ast_rtp *vpeer, const struct ast_codec_pref *codecs, int nat_active); +/* int (* const get_codec)(struct ast_channel *chan);*/ const char * const type; struct ast_rtp_protocol *next; +}; + +/* The value of each payload format mapping: */ +struct rtpPayloadType { + int isAstFormat; /* whether the following code is an AST_FORMAT */ + int code; }; /*! --- include/asterisk/translate.h.orig Tue Nov 29 20:24:39 2005 +++ include/asterisk/translate.h Mon Oct 9 13:01:08 2006 @@ -34,6 +34,7 @@ /* Declared by individual translators */ struct ast_translator_pvt; +struct ast_channel; /*! data structure associated with a translator */ struct ast_translator { @@ -102,6 +103,13 @@ */ extern void ast_translator_free_path(struct ast_trans_pvt *tr); +/*! Frees a translation path matrix assosiated with channel */ +/*! + * \param chan channel to free translation path matrix + * Frees the translation matrix in the given channel + */ +extern void ast_translator_free_translations(struct ast_channel *chan); + /*! translates one or more frames */ /*! * \param tr translator structure to use for translation @@ -112,6 +120,35 @@ * Returns an ast_frame of the new translation format on success, NULL on failure */ extern struct ast_frame *ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume); +/*! translates read frames */ +/*! + * \param chan channel through which the frame comes in + * \param f frame to translate + * \param consume Whether or not to free the original frame + * Translate frame into the readformat of the channel from any format and receive + * zero or one output frames. Consume determines whether the original frame + * should be freed. + * Returns an ast_frame of the new translation format on success, NULL on failure + */ +extern struct ast_frame *ast_translate_read(struct ast_channel *chan, struct ast_frame *f, int consume); +/*! translates frames for writing */ +/*! + * \param chan channel through which the frame comes out + * \param f frame to translate + * \param consume Whether or not to free the original frame + * Translate frame into the writeformat of the channel from any format and receive + * zero or one output frames. Consume determines whether the original frame + * should be freed. + * Returns an ast_frame of the new translation format on success, NULL on failure + */ +extern struct ast_frame *ast_translate_write(struct ast_channel *chan, struct ast_frame *f, int consume); + +/*! + * Returns all formats that can be converted by asterisk from/to supplied format + * plus the format itself. + * \param formats formats for which to search compatible formats + */ +extern int ast_compatible_audio_formats(int format); #if defined(__cplusplus) || defined(c_plusplus) } --- manager.c.orig Sat Feb 11 20:15:00 2006 +++ ./manager.c Mon Oct 9 13:01:08 2006 @@ -935,14 +935,18 @@ int res; int reason = 0; struct ast_channel *chan = NULL; + struct ast_codec_pref slin; + + ast_codec_pref_init(&slin); + ast_codec_pref_append(&slin, AST_FORMAT_SLINEAR); if (!ast_strlen_zero(in->app)) { - res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1, + res = ast_pbx_outgoing_app(in->tech, &slin, in->data, in->timeout, in->app, in->appdata, &reason, 1, !ast_strlen_zero(in->cid_num) ? in->cid_num : NULL, !ast_strlen_zero(in->cid_name) ? in->cid_name : NULL, in->vars, in->account, &chan); } else { - res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, + res = ast_pbx_outgoing_exten(in->tech, &slin, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, !ast_strlen_zero(in->cid_num) ? in->cid_num : NULL, !ast_strlen_zero(in->cid_name) ? in->cid_name : NULL, in->vars, in->account, &chan); @@ -1016,6 +1020,11 @@ pthread_t th; pthread_attr_t attr; + struct ast_codec_pref slin; + + memset(&slin, 0, sizeof(&slin)); + ast_codec_pref_append(&slin, AST_FORMAT_SLINEAR); + if (!name) { astman_send_error(s, m, "Channel not specified"); return 0; @@ -1079,10 +1088,10 @@ } } } else if (!ast_strlen_zero(app)) { - res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL); + res = ast_pbx_outgoing_app(tech, &slin, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL); } else { if (exten && context && pi) - res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL); + res = ast_pbx_outgoing_exten(tech, &slin, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL); else { astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'"); return 0; --- pbx.c.orig Thu Aug 24 22:41:26 2006 +++ ./pbx.c Mon Oct 9 13:01:08 2006 @@ -4981,7 +4981,7 @@ return 0; /* success */ } -int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel) +int ast_pbx_outgoing_exten(const char *type, const struct ast_codec_pref *formats, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel) { struct ast_channel *chan; struct async_stat *as; @@ -4991,7 +4991,7 @@ if (sync) { LOAD_OH(oh); - chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh); + chan = __ast_request_and_dial(type, formats, data, timeout, reason, cid_num, cid_name, &oh); if (channel) { *channel = chan; if (chan) @@ -5093,7 +5093,7 @@ goto outgoing_exten_cleanup; } memset(as, 0, sizeof(struct async_stat)); - chan = ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name); + chan = ast_request_and_dial(type, formats, data, timeout, reason, cid_num, cid_name); if (channel) { *channel = chan; if (chan) @@ -5155,7 +5155,7 @@ return NULL; } -int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel) +int ast_pbx_outgoing_app(const char *type, const struct ast_codec_pref *formats, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel) { struct ast_channel *chan; struct async_stat *as; @@ -5175,7 +5175,7 @@ goto outgoing_app_cleanup; } if (sync) { - chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh); + chan = __ast_request_and_dial(type, formats, data, timeout, reason, cid_num, cid_name, &oh); if (chan) { if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */ ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name); @@ -5262,7 +5262,7 @@ goto outgoing_app_cleanup; } memset(as, 0, sizeof(struct async_stat)); - chan = __ast_request_and_dial(type, format, data, timeout, reason, cid_num, cid_name, &oh); + chan = __ast_request_and_dial(type, formats, data, timeout, reason, cid_num, cid_name, &oh); if (!chan) { free(as); res = -1; --- pbx/pbx_spool.c.orig Sat Feb 11 20:15:00 2006 +++ pbx/pbx_spool.c Mon Oct 9 13:01:08 2006 @@ -256,14 +256,19 @@ { struct outgoing *o = data; int res, reason; + struct ast_codec_pref slin; + + ast_codec_pref_init(&slin); + ast_codec_pref_append(&slin, AST_FORMAT_SLINEAR); + if (!ast_strlen_zero(o->app)) { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries); - res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL); + res = ast_pbx_outgoing_app(o->tech, &slin, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL); } else { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries); - res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL); + res = ast_pbx_outgoing_exten(o->tech, &slin, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL); } if (res) { ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason); --- res/res_features.c.orig Wed Aug 2 02:07:06 2006 +++ res/res_features.c Mon Oct 9 13:01:08 2006 @@ -211,7 +211,7 @@ } } -static struct ast_channel *ast_feature_request_and_dial(struct ast_channel *caller, const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name); +static struct ast_channel *ast_feature_request_and_dial(struct ast_channel *caller, const char *type, const struct ast_codec_pref *formats, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name); static void *ast_bridge_call_thread(void *data) @@ -721,7 +721,7 @@ cid_name = transferer->cid.cid_name; if (ast_exists_extension(transferer, transferer_real_context,xferto, 1, cid_num)) { snprintf(dialstr, sizeof(dialstr), "%s@%s/n", xferto, transferer_real_context); - newchan = ast_feature_request_and_dial(transferer, "Local", ast_best_codec(transferer->nativeformats), dialstr, 15000, &outstate, cid_num, cid_name); + newchan = ast_feature_request_and_dial(transferer, "Local", &transferer->nativeformats, dialstr, 15000, &outstate, cid_num, cid_name); ast_indicate(transferer, -1); if (newchan) { res = ast_channel_make_compatible(transferer, newchan); @@ -1088,7 +1088,7 @@ } -static struct ast_channel *ast_feature_request_and_dial(struct ast_channel *caller, const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name) +static struct ast_channel *ast_feature_request_and_dial(struct ast_channel *caller, const char *type, const struct ast_codec_pref *formats, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name) { int state = 0; int cause = 0; @@ -1099,7 +1099,7 @@ struct ast_frame *f = NULL; int res = 0, ready = 0; - if ((chan = ast_request(type, format, data, &cause))) { + if ((chan = ast_request(type, formats, data, &cause))) { ast_set_callerid(chan, cid_num, cid_name, cid_num); ast_channel_inherit_variables(caller, chan); if (!ast_call(chan, data, timeout)) { @@ -1304,6 +1304,27 @@ set_config_flags(chan, peer, config); config->firstpass = 1; + if (ast_codec_pref_intersect(&chan->nativeformats, &peer->nativeformats)) + { + if (chan->tech->fixup_codecs && + ast_codec_pref_intersect(&chan->nativeformats, &peer->nativeformats) != ast_codec_pref_bits(&chan->nativeformats)) + { + struct ast_codec_pref tmp; + memcpy(&tmp, &peer->nativeformats, sizeof(tmp)); + /* Provide all compatible formats also */ + ast_codec_pref_append_missing2(&tmp, ast_compatible_audio_formats(tmp.audio_bits)); + chan->tech->fixup_codecs(chan, &tmp); + } + if (peer->tech->fixup_codecs && + ast_codec_pref_intersect(&chan->nativeformats, &peer->nativeformats) != ast_codec_pref_bits(&peer->nativeformats)) + { + struct ast_codec_pref tmp; + memcpy(&tmp, &peer->nativeformats, sizeof(tmp)); + /* Provide all compatible formats also */ + ast_codec_pref_append_missing2(&tmp, ast_compatible_audio_formats(tmp.audio_bits)); + peer->tech->fixup_codecs(peer, &tmp); + } + } /* Answer if need be */ if (ast_answer(chan)) return -1; --- rtp.c.orig Fri Sep 1 20:35:06 2006 +++ ./rtp.c Mon Oct 9 13:01:08 2006 @@ -53,6 +53,7 @@ #include "asterisk/cli.h" #include "asterisk/unaligned.h" #include "asterisk/utils.h" +#include "asterisk/translate.h" #define MAX_TIMESTAMP_SKEW 640 @@ -70,13 +71,13 @@ static int nochecksums = 0; #endif -/* The value of each payload format mapping: */ -struct rtpPayloadType { - int isAstFormat; /* whether the following code is an AST_FORMAT */ - int code; -}; - #define MAX_RTP_PT 256 +/* + * RFC3551, Section 6: + * "...payload type values in the range 96-127 MAY be defined dynamically..." + */ +#define MAX_RTP_STATIC_PT 95 + #define FLAG_3389_WARNING (1 << 0) #define FLAG_NAT_ACTIVE (3 << 1) @@ -740,8 +741,11 @@ /* By default, use the well-known value for this type (although it may */ /* still be set to a different value by a subsequent "a=rtpmap:" line): */ void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt) { - if (pt < 0 || pt > MAX_RTP_PT) - return; /* bogus payload type */ + /* + * Get only static payload types here + */ + if (pt < 0 || pt > MAX_RTP_STATIC_PT) + return; /* non-static payload type */ if (static_RTP_PT[pt].code != 0) { rtp->current_RTP_PT[pt] = static_RTP_PT[pt]; @@ -801,8 +805,9 @@ if (!rtp->rtp_offered_from_local) result = rtp->current_RTP_PT[pt]; - /* If it doesn't exist, check our static RTP type list, just in case */ - if (!result.code) + /* If it doesn't exist, check our static RTP type list, just in case + (and only for static payload types). */ + if (!result.code && pt <= (rtp->rtp_offered_from_local ? MAX_RTP_PT : MAX_RTP_STATIC_PT)) result = static_RTP_PT[pt]; return result; } @@ -1536,11 +1541,15 @@ void *pvt0, *pvt1; int codec0,codec1, oldcodec0, oldcodec1; + struct ast_codec_pref codecs0; + struct ast_codec_pref codecs1; memset(&vt0, 0, sizeof(vt0)); memset(&vt1, 0, sizeof(vt1)); memset(&vac0, 0, sizeof(vac0)); memset(&vac1, 0, sizeof(vac1)); + ast_codec_pref_init(&codecs0); + ast_codec_pref_init(&codecs1); /* if need DTMF, cant native bridge */ if (flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1)) @@ -1593,28 +1602,21 @@ ast_mutex_unlock(&c1->lock); return AST_BRIDGE_FAILED_NOWARN; } - /* Get codecs from both sides */ - if (pr0->get_codec) - codec0 = pr0->get_codec(c0); - else - codec0 = 0; - if (pr1->get_codec) - codec1 = pr1->get_codec(c1); - else - codec1 = 0; - if (pr0->get_codec && pr1->get_codec) { - /* Hey, we can't do reinvite if both parties speak different codecs */ - if (!(codec0 & codec1)) { - if (option_debug) - ast_log(LOG_DEBUG, "Channel codec0 = %d is not codec1 = %d, cannot native bridge in RTP.\n", codec0, codec1); - ast_mutex_unlock(&c0->lock); - ast_mutex_unlock(&c1->lock); - return AST_BRIDGE_FAILED_NOWARN; - } + codec0 = ast_codec_pref_bits(&c0->nativeformats); + codec1 = ast_codec_pref_bits(&c1->nativeformats); + memcpy(&codecs0, &c0->nativeformats, sizeof(codecs0)); + memcpy(&codecs1, &c1->nativeformats, sizeof(codecs1)); + /* Hey, we can't do reinvite if both parties speak different codecs */ + if (!(codec0 & codec1)) { + if (option_debug) + ast_log(LOG_DEBUG, "Channel codec0 = %d is not codec1 = %d, cannot native bridge in RTP.\n", codec0, codec1); + ast_mutex_unlock(&c0->lock); + ast_mutex_unlock(&c1->lock); + return AST_BRIDGE_FAILED_NOWARN; } /* Ok, we should be able to redirect the media. Start with one channel */ - if (pr0->set_rtp_peer(c0, p1, vp1, codec1, ast_test_flag(p1, FLAG_NAT_ACTIVE))) + if (pr0->set_rtp_peer(c0, p1, vp1, &codecs1, ast_test_flag(p1, FLAG_NAT_ACTIVE))) ast_log(LOG_WARNING, "Channel '%s' failed to talk to '%s'\n", c0->name, c1->name); else { /* Store RTP peer */ @@ -1623,7 +1625,7 @@ ast_rtp_get_peer(vp1, &vac1); } /* Then test the other channel */ - if (pr1->set_rtp_peer(c1, p0, vp0, codec0, ast_test_flag(p0, FLAG_NAT_ACTIVE))) + if (pr1->set_rtp_peer(c1, p0, vp0, &codecs0, ast_test_flag(p0, FLAG_NAT_ACTIVE))) ast_log(LOG_WARNING, "Channel '%s' failed to talk back to '%s'\n", c1->name, c0->name); else { /* Store RTP peer */ @@ -1647,11 +1649,11 @@ (c0->masq || c0->masqr || c1->masq || c1->masqr)) { ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); if (c0->tech_pvt == pvt0) { - if (pr0->set_rtp_peer(c0, NULL, NULL, 0, 0)) + if (pr0->set_rtp_peer(c0, NULL, NULL, NULL, 0)) ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name); } if (c1->tech_pvt == pvt1) { - if (pr1->set_rtp_peer(c1, NULL, NULL, 0, 0)) + if (pr1->set_rtp_peer(c1, NULL, NULL, NULL, 0)) ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c1->name); } return AST_BRIDGE_RETRY; @@ -1659,10 +1661,8 @@ /* Now check if they have changed address */ ast_rtp_get_peer(p1, &t1); ast_rtp_get_peer(p0, &t0); - if (pr0->get_codec) - codec0 = pr0->get_codec(c0); - if (pr1->get_codec) - codec1 = pr1->get_codec(c1); + codec0 = ast_codec_pref_bits(&c0->nativeformats); + codec1 = ast_codec_pref_bits(&c1->nativeformats); if (vp1) ast_rtp_get_peer(vp1, &vt1); if (vp0) @@ -1678,7 +1678,9 @@ ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n", c1->name, ast_inet_ntoa(iabuf, sizeof(iabuf), vac1.sin_addr), ntohs(vac1.sin_port), oldcodec1); } - if (pr0->set_rtp_peer(c0, t1.sin_addr.s_addr ? p1 : NULL, vt1.sin_addr.s_addr ? vp1 : NULL, codec1, ast_test_flag(p1, FLAG_NAT_ACTIVE))) + memcpy(&codecs1, &c1->nativeformats, sizeof(codecs1)); + ast_codec_pref_append_missing2(&codecs1, ast_compatible_audio_formats(codecs1.audio_bits)); + if (pr0->set_rtp_peer(c0, t1.sin_addr.s_addr ? p1 : NULL, vt1.sin_addr.s_addr ? vp1 : NULL, &codecs1, ast_test_flag(p1, FLAG_NAT_ACTIVE))) ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c0->name, c1->name); memcpy(&ac1, &t1, sizeof(ac1)); memcpy(&vac1, &vt1, sizeof(vac1)); @@ -1691,7 +1693,9 @@ ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d/(format %d)\n", c0->name, ast_inet_ntoa(iabuf, sizeof(iabuf), ac0.sin_addr), ntohs(ac0.sin_port), oldcodec0); } - if (pr1->set_rtp_peer(c1, t0.sin_addr.s_addr ? p0 : NULL, vt0.sin_addr.s_addr ? vp0 : NULL, codec0, ast_test_flag(p0, FLAG_NAT_ACTIVE))) + memcpy(&codecs0, &c0->nativeformats, sizeof(codecs0)); + ast_codec_pref_append_missing2(&codecs0, ast_compatible_audio_formats(codecs0.audio_bits)); + if (pr1->set_rtp_peer(c1, t0.sin_addr.s_addr ? p0 : NULL, vt0.sin_addr.s_addr ? vp0 : NULL, &codecs0, ast_test_flag(p0, FLAG_NAT_ACTIVE))) ast_log(LOG_WARNING, "Channel '%s' failed to update to '%s'\n", c1->name, c0->name); memcpy(&ac0, &t0, sizeof(ac0)); memcpy(&vac0, &vt0, sizeof(vac0)); --- translate.c.orig Sat Feb 25 21:54:40 2006 +++ ./translate.c Mon Oct 9 13:02:01 2006 @@ -89,6 +89,23 @@ return -1; } +void ast_translator_free_translations(struct ast_channel *chan) +{ + int x, y; + for (x = 0; x < MAX_FORMAT; ++x) { + for (y = 0; y < MAX_FORMAT; ++y) { + if (chan->readtrans_matrix[x][y]) { + ast_translator_free_path(chan->readtrans_matrix[x][y]); + chan->readtrans_matrix[x][y] = NULL; + } + if (chan->writetrans_matrix[x][y]) { + ast_translator_free_path(chan->writetrans_matrix[x][y]); + chan->writetrans_matrix[x][y] = NULL; + } + } + } +} + void ast_translator_free_path(struct ast_trans_pvt *p) { struct ast_trans_pvt *pl, *pn; @@ -152,6 +169,67 @@ return tmpr; } +struct ast_frame *ast_translate_read(struct ast_channel *chan, struct ast_frame *f, int consume) +{ + int dest_codec; + int dest_codec_idx; + int src_codec_idx; + struct ast_trans_pvt *trans; + + chan->lastreadformat = f->subclass; + /* If the user perspective is this codec then do not translate */ + if (chan->readformat & f->subclass) { + return f; + } + /* Otherwise translate into the user perspective codec */ + dest_codec = chan->readformat; + dest_codec_idx = powerof(dest_codec); + src_codec_idx = powerof(f->subclass); + ast_mutex_lock(&chan->lock); + trans = chan->readtrans_matrix[src_codec_idx][dest_codec_idx]; + if (NULL == trans) { + trans = ast_translator_build_path(dest_codec, f->subclass); + chan->readtrans_matrix[src_codec_idx][dest_codec_idx] = trans; + } + ast_mutex_unlock(&chan->lock); + if (trans) + f = ast_translate(trans, f, consume); + return f; +} + +struct ast_frame *ast_translate_write(struct ast_channel *chan, struct ast_frame *f, int consume) +{ + int dest_codec; + int dest_codec_idx; + int src_codec_idx; + struct ast_trans_pvt *trans; + /* If channel supports this codec then do not translate */ + if ((chan->nativeformats.audio_bits & f->subclass) && + ((option_translation_algorithm == AST_TRANS_ALG_LOOSE) || + (f->subclass & chan->lastreadformat)) || + (chan->lastreadformat == NULL)) + { + return f; + } + /* + * Use the codec that the UA is using currently + * (faxing does not work without this for example) + */ + dest_codec = chan->lastreadformat; + dest_codec_idx = powerof(dest_codec); + src_codec_idx = powerof(f->subclass); + ast_mutex_lock(&chan->lock); + trans = chan->writetrans_matrix[src_codec_idx][dest_codec_idx]; + if (NULL == trans) { + trans = ast_translator_build_path(dest_codec, f->subclass); + chan->writetrans_matrix[src_codec_idx][dest_codec_idx] = trans; + } + ast_mutex_unlock(&chan->lock); + if (trans) + f = ast_translate(trans, f, consume); + return f; +} + struct ast_frame *ast_translate(struct ast_trans_pvt *path, struct ast_frame *f, int consume) { struct ast_trans_pvt *p; @@ -506,4 +584,26 @@ } return best; +} + +int ast_compatible_audio_formats(int formats) +{ + int retval = formats; + int x, y; + + for (x = 0; x < MAX_FORMAT; ++x) + { + if ((1 << x) & formats) + { + for (y = 0; y < MAX_FORMAT; ++y) + { + if (tr_matrix[x][y].step) + { + retval |= (1 << y); + } + } + } + } + return retval; + } --- patch-zzz-asterisk-1.2.16.1-codec-negotiation-20070319 ends here --- >Release-Note: >Audit-Trail: >Unformatted: