diff --git a/linphone/Makefile.am b/linphone/Makefile.am index eaf4c5bd8..caf7de77a 100644 --- a/linphone/Makefile.am +++ b/linphone/Makefile.am @@ -111,7 +111,7 @@ zip: cp -f $(top_srcdir)/COPYING $(INSTALLDIR_WITH_PREFIX)/. cd $(INSTALLDIR_WITH_PREFIX) && zip -r $(ZIPFILE) * -setup.exe: zip +filelist: zip cd $(INSTALLDIR_WITH_PREFIX) && \ rm -f $(PACKAGE_WIN32_FILELIST) && \ for file in `find` ; do \ @@ -120,6 +120,8 @@ setup.exe: zip >> $(PACKAGE_WIN32_FILELIST) ;\ fi \ done + +setup.exe: filelist cp $(ISS_SCRIPT) $(INSTALLDIR_WITH_PREFIX)/. cd $(INSTALLDIR_WITH_PREFIX) && \ $(ISCC) $(ISS_SCRIPT) diff --git a/linphone/build.mk b/linphone/build.mk deleted file mode 100755 index be5fe460d..000000000 --- a/linphone/build.mk +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/make -f -# This script "automatically" builds some binary distribution of linphone : -# debian packages (sid) and familiar (arm-linux/ipaq) packages. -# generation of rpms can be added in the future. -# it can be invoked in the following way: -# ./build.mk debs LINPHONE= -# ./build.mk all LINPHONE= GLIB=2.2's tar.gz> -# LIBOSIP= -# - - -ARMROOT=/armbuild -ARMTOOLCHAIN=/usr/local/arm/3.2.3/bin - -all: check debs ipks - - -clean: - rm -f *.stamp - rm -rf build-debs - rm -rf build-ipks - -check: - @if test -n "${LD_PRELOAD}" ; then echo "ERROR: LD_PRELOAD is set !!"; exit 1;fi - -ipks: ipkg-tools.stamp libosip.ipk linphone.ipk clean - -ipkg-tools.stamp: - if which ipkg-build ; then echo "Found ipkg-build." ;\ - else echo "** ERROR ** Cannot find ipkg-build"; exit 1; fi - if test -e $(ARMTOOLCHAIN)/arm-linux-gcc ; then \ - echo "arm toolchain seems ok.";\ - else echo "** ERROR ** Cannot find arm toolchain."; exit 1; fi - touch ipkg-tools.stamp - -glib.ipk : glib.stamp linphone-sources-ipk.stamp - rm -rf build-ipks/glib* - cp $(GLIB) build-ipks/. - export CONFIG_SITE=`pwd`/build-ipks/ipaq-config.site && \ - cd build-ipks && tar -xvzf glib*.tar.gz && rm -f glib*.tar.gz && cd glib* && \ - ./configure --prefix=$(ARMROOT)/usr --host=arm-linux --with-gnu-ld --disable-static \ - && make AM_CFLAGS=-DSSIZE_MAX=0xffffffff && make install && \ - make install prefix=`pwd`$(ARMROOT)/usr - echo "Building .ipk file..." - cd build-ipks/glib*$(ARMROOT) && mkdir CONTROL && cd CONTROL && \ - cp ../../../linphone*/ipkg/glib.control control && \ - cd ../.. && rm -rf armbuild/usr/include - cd build-ipks/glib* && ipkg-build -o root -g root armbuild/ - cp build-ipks/glib*/*.ipk . - -libosip.ipk : libosip.stamp linphone-sources-ipk.stamp - rm -rf build-ipks/libosip* - cp $(LIBOSIP) build-ipks/ - export CONFIG_SITE=`pwd`/build-ipks/ipaq-config.site && \ - cd build-ipks && tar -xvzf libosip*.tar.gz && rm -f libosip*.tar.gz && cd libosip* && \ - ./configure --prefix=$(ARMROOT)/usr --host=arm-linux --with-gnu-ld --disable-static \ - && make && make install && make install prefix=`pwd`$(ARMROOT)/usr - echo "Building .ipk file..." - cd build-ipks/libosip*$(ARMROOT) && mkdir CONTROL && cd CONTROL && \ - cp ../../../linphone*/ipkg/libosip.control control &&\ - cd ../.. && rm -rf armbuild/usr/include - cd build-ipks/libosip* && ipkg-build -o root -g root armbuild/ - cp build-ipks/libosip*/*.ipk . - - -linphone.ipk : linphone.stamp linphone-sources-ipk.stamp - export CONFIG_SITE=`pwd`/build-ipks/ipaq-config.site && \ - cd build-ipks/linphone* && export PKG_CONFIG_PATH=$(ARMROOT)/usr/lib/pkgconfig &&\ - ./configure --prefix=$(ARMROOT)/usr --with-realprefix=/usr --host=arm-linux \ - --with-gnu-ld --disable-static --disable-gnome_ui --disable-glib --with-osip=$(ARMROOT)/usr \ - --disable-ogg --disable-rtcp && make && make install prefix=`pwd`$(ARMROOT)/usr - echo "Building .ipk file..." - cd build-ipks/linphone*$(ARMROOT) && mkdir -p CONTROL && cd CONTROL && \ - cp -f ../../ipkg/linphone.control control &&\ - cd ../.. && rm -rf armbuild/usr/include armbuild/usr/share/gtk-doc \ - && cd armbuild/usr/share/sounds/linphone/rings && \ - rm -f rock.wav sweet.wav bigben.wav toy.wav tapping.wav synth.wav && cd - \ - cd build-ipks/linphone* && ipkg-build -o root -g root armbuild/ - cp -f build-ipks/linphone*/*.ipk . - -build-ipks.stamp: - -@touch $(ARMROOT)/dummy - @if test -e $(ARMROOT)/dummy ; \ - then echo "armroot is fine: $(ARMROOT)"; \ - else \ - echo "** ERROR: you need to create a $(ARMROOT) directory readable and writeable by the user running this build script.";\ - exit 1;\ - fi - rm -f $(ARMROOT)/dummy - touch build-ipks.stamp - mkdir build-ipks - - -linphone-sources-ipk.stamp: linphone.stamp build-ipks.stamp - cp $(LINPHONE) build-ipks/. - cd build-ipks && tar -xvzf linphone*.tar.gz && cp linphone*/ipkg/ipaq-config.site . \ - && rm -f linphone*.tar.gz - touch linphone-sources-ipk.stamp - -debs: linphone.stamp clean - rm -f linphone.stamp - rm -rf build-debs - mkdir build-debs - cp $(LINPHONE) build-debs/. - cd build-debs && tar -xvzf *.tar.gz && cd linphone* && dpkg-buildpackage -rfakeroot - cp build-debs/*.deb . - -linphone.stamp: - @if test -n "$(LINPHONE)" ; \ - then echo "linphone source is $(LINPHONE)" ; \ - touch linphone.stamp; \ - else \ - echo "No linphone source found." ; \ - exit 1; \ - fi - -libosip.stamp: - @if test -n "$(LIBOSIP)" ; \ - then echo "libosip source is $(LIBOSIP)" ; \ - touch libosip.stamp; \ - else \ - echo "No libosip source found." ; \ - exit 1; \ - fi - -glib.stamp: - @if test -n "$(GLIB)" ; \ - then echo "glib source is $(GLIB)" ; \ - else \ - echo "No glib source found." ; \ - exit -1; \ - fi - @if which glib-genmarshal ; \ - then \ - echo "native glib-2.2 found on build host." ; \ - touch glib.stamp ;\ - else \ - echo "** ERROR ** You need a working glib>2.2 on the build machine to be able to crosscompile it for arm." ;\ - echo "** ERROR ** Please install a glib on this machine."; exit 1; \ - fi diff --git a/linphone/debian/.gitignore b/linphone/debian/.gitignore deleted file mode 100644 index 282522db0..000000000 --- a/linphone/debian/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/linphone/debian/Makefile.am b/linphone/debian/Makefile.am deleted file mode 100644 index 6c6eb29bc..000000000 --- a/linphone/debian/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -EXTRA_DIST= copyright dirs manpage.sgml.ex rules \ - control docs manpage.1.ex menu watch.ex changelog - - -changelog: changelog.stamp - echo -n -e "linphone (">changelog - echo -n -e $(VERSION)>>changelog - echo -n -e "-1) unstable; urgency=low\n\n">>changelog - echo -n -e " * New Release.\n\n">>changelog - echo -n -e " -- Simon Morlat ">>changelog - date -R >>changelog - touch changelog.stamp - -changelog.stamp: - touch changelog.stamp diff --git a/linphone/debian/control b/linphone/debian/control deleted file mode 100644 index fef2eba9d..000000000 --- a/linphone/debian/control +++ /dev/null @@ -1,14 +0,0 @@ -Source: linphone -Section: sound -Priority: optional -Maintainer: Uwe Steinmann -Build-Depends: debhelper (>> 3.0.0), libosip0-dev (>= 0.9.6), libasound2-dev (>=0.9.4) -Standards-Version: 3.5.2 - -Package: linphone -Architecture: any -Depends: ${shlibs:Depends}, libosip0 (>= 0.9.6), libspeex1, libasound2 (>=0.9.4) -Description: A sip phone - Linphone is a web phone: it let you phone to your friends anywhere in the - whole world, freely, simply by using the internet. It is compatible with the - well known SIP protocol. diff --git a/linphone/debian/copyright b/linphone/debian/copyright deleted file mode 100644 index da0129d9f..000000000 --- a/linphone/debian/copyright +++ /dev/null @@ -1,10 +0,0 @@ -This package was debianized by Uwe Steinmann on -Thu, 28 Feb 2002 08:29:57 +0100. - -It was downloaded from http://www.linphone.org - -Upstream Author(s): Simon Morlat - -Copyright: - -GPL diff --git a/linphone/debian/dirs b/linphone/debian/dirs deleted file mode 100644 index ca882bbb7..000000000 --- a/linphone/debian/dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/bin -usr/sbin diff --git a/linphone/debian/docs b/linphone/debian/docs deleted file mode 100644 index 5203c2307..000000000 --- a/linphone/debian/docs +++ /dev/null @@ -1,3 +0,0 @@ -BUGS -NEWS -README diff --git a/linphone/debian/manpage.1.ex b/linphone/debian/manpage.1.ex deleted file mode 100644 index f872c3353..000000000 --- a/linphone/debian/manpage.1.ex +++ /dev/null @@ -1,60 +0,0 @@ -.\" Hey, EMACS: -*- nroff -*- -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH LINPHONE SECTION "February 28, 2002" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -linphone \- program to do something -.SH SYNOPSIS -.B linphone -.RI [ options ] " files" ... -.br -.B bar -.RI [ options ] " files" ... -.SH DESCRIPTION -This manual page documents briefly the -.B linphone -and -.B bar -commands. -This manual page was written for the Debian distribution -because the original program does not have a manual page. -Instead, it has documentation in the GNU Info format; see below. -.PP -.\" TeX users may be more comfortable with the \fB\fP and -.\" \fI\fP escape sequences to invode bold face and italics, -.\" respectively. -\fBlinphone\fP is a program that... -.SH OPTIONS -These programs follow the usual GNU command line syntax, with long -options starting with two dashes (`-'). -A summary of options is included below. -For a complete description, see the Info files. -.TP -.B \-h, \-\-help -Show summary of options. -.TP -.B \-v, \-\-version -Show version of program. -.SH SEE ALSO -.BR bar (1), -.BR baz (1). -.br -The programs are documented fully by -.IR "The Rise and Fall of a Fooish Bar" , -available via the Info system. -.SH AUTHOR -This manual page was written by Uwe Steinmann , -for the Debian GNU/Linux system (but may be used by others). diff --git a/linphone/debian/manpage.sgml.ex b/linphone/debian/manpage.sgml.ex deleted file mode 100644 index 0b97c1700..000000000 --- a/linphone/debian/manpage.sgml.ex +++ /dev/null @@ -1,152 +0,0 @@ - manpage.1'. You may view - the manual page with: `docbook-to-man manpage.sgml | nroff -man | - less'. A typical entry in a Makefile or Makefile.am is: - -manpage.1: manpage.sgml - docbook-to-man $< > $@ - - - The docbook-to-man binary is found in the docbook-to-man package. - Please remember that if you create the nroff version in one of the - debian/rules file targets (such as build), you will need to include - docbook-to-man in your Build-Depends control field. - - --> - - - FIRSTNAME"> - SURNAME"> - - February 28, 2002"> - - SECTION"> - uwe@steinmann.cx"> - - LINPHONE"> - - - Debian"> - GNU"> -]> - - - -
- &dhemail; -
- - &dhfirstname; - &dhsurname; - - - 2001 - &dhusername; - - &dhdate; -
- - &dhucpackage; - - &dhsection; - - - &dhpackage; - - program to do something - - - - &dhpackage; - - - - - - - - DESCRIPTION - - This manual page documents briefly the - &dhpackage; and bar - commands. - - This manual page was written for the &debian; distribution - because the original program does not have a manual page. - Instead, it has documentation in the &gnu; - Info format; see below. - - &dhpackage; is a program that... - - - - OPTIONS - - These programs follow the usual GNU command line syntax, - with long options starting with two dashes (`-'). A summary of - options is included below. For a complete description, see the - Info files. - - - - - - - - Show summary of options. - - - - - - - - Show version of program. - - - - - - SEE ALSO - - bar (1), baz (1). - - The programs are documented fully by The Rise and - Fall of a Fooish Bar available via the - Info system. - - - AUTHOR - - This manual page was written by &dhusername; &dhemail; for - the &debian; system (but may be used by others). Permission is - granted to copy, distribute and/or modify this document under - the terms of the GNU Free Documentation - License, Version 1.1 or any later version published by the Free - Software Foundation; with no Invariant Sections, no Front-Cover - Texts and no Back-Cover Texts. - - -
- - - - diff --git a/linphone/debian/menu b/linphone/debian/menu deleted file mode 100644 index b21a3934a..000000000 --- a/linphone/debian/menu +++ /dev/null @@ -1,3 +0,0 @@ -?package(linphone):needs=X11 section=Apps/Net \ - title="Linphone" command="/usr/bin/linphone" hints="Telephony"\ - icon="/usr/share/pixmaps/linphone/linphone2.xpm" diff --git a/linphone/debian/rules b/linphone/debian/rules deleted file mode 100755 index 621932a43..000000000 --- a/linphone/debian/rules +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/make -f -# Sample debian/rules that uses debhelper. -# GNU copyright 1997 to 1999 by Joey Hess. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -# This is the debhelper compatibility version to use. -export DH_COMPAT=3 - -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) -DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) - -ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) - CFLAGS += -g -endif -ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) - INSTALL_PROGRAM += -s -endif - -configure: configure-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --disable-static --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --sysconfdir=/etc - - touch configure-stamp - -build: build-stamp - -build-stamp: configure-stamp - dh_testdir - - # Add here commands to compile the package. - $(MAKE) - #/usr/bin/docbook-to-man debian/linphone.sgml > linphone.1 - - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - -make clean - -make distclean - -test -r /usr/share/misc/config.sub && \ - -cp -f /usr/share/misc/config.sub config.sub - -test -r /usr/share/misc/config.guess && \ - -cp -f /usr/share/misc/config.guess config.guess - - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/linphone. - $(MAKE) install PIXDESTDIR=$(CURDIR)/debian/linphone prefix=$(CURDIR)/debian/linphone/usr sysconfdir=$(CURDIR)/debian/linphone/etc - # remove speex libs, in order to not to conflict with speex debian package. - rm -f $(CURDIR)/debian/linphone/usr/lib/libspeex* \ - $(CURDIR)/debian/linphone/usr/bin/speex* \ - $(CURDIR)/debian/linphone/usr/include/speex* \ - $(CURDIR)/debian/linphone/usr/share/man/man1/speex* - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot -# dh_installdebconf - dh_installdocs - dh_installexamples - dh_installmenu -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_installinit - dh_installcron - dh_installman - dh_installinfo -# dh_undocumented - dh_installchangelogs ChangeLog - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_makeshlibs - dh_installdeb -# dh_perl - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/linphone/debian/watch.ex b/linphone/debian/watch.ex deleted file mode 100644 index 2002b0f76..000000000 --- a/linphone/debian/watch.ex +++ /dev/null @@ -1,5 +0,0 @@ -# Example watch control file for uscan -# Rename this file to "watch" and then you can run the "uscan" command -# to check for upstream updates and more. -# Site Directory Pattern Version Script -sunsite.unc.edu /pub/Linux/Incoming linphone-(.*)\.tar\.gz debian uupdate diff --git a/linphone/developer-docs/.gitignore b/linphone/developer-docs/.gitignore deleted file mode 100644 index 282522db0..000000000 --- a/linphone/developer-docs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/linphone/developer-docs/mediastreamer/.gitignore b/linphone/developer-docs/mediastreamer/.gitignore deleted file mode 100644 index 3dda72986..000000000 --- a/linphone/developer-docs/mediastreamer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile.in -Makefile diff --git a/linphone/exosip/.gitignore b/linphone/exosip/.gitignore deleted file mode 100644 index 09980ae6b..000000000 --- a/linphone/exosip/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/linphone/exosip/Makefile.am b/linphone/exosip/Makefile.am deleted file mode 100644 index 067b1eebd..000000000 --- a/linphone/exosip/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -noinst_LTLIBRARIES = libeXosip.la - - -AM_CFLAGS = $(EXOSIP_CFLAGS) - -libeXosip_la_SOURCES = eXosip.c \ -jrequest.c jresponse.c jcallback.c jdialog.c udp.c \ -jcall.c jreg.c jfreinds.c jidentity.c eXutils.c \ -jnotify.c jsubscribers.c jsubscribe.c jevents.c \ -sdp_offans.c misc.c eXosip2.h \ -jpipe.c jpipe.h jauth.c jpublish.c \ -eXosip.h eXosip_cfg.h - -libeXosip_la_LIBADD = $(EXOSIP_LIBS) - -INCLUDES = -I$(top_srcdir) diff --git a/linphone/exosip/eXosip.c b/linphone/exosip/eXosip.c deleted file mode 100644 index 729927b48..000000000 --- a/linphone/exosip/eXosip.c +++ /dev/null @@ -1,3192 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" -#include -#include - -#include -#include - -#ifndef WIN32 -#include -#include -#include -#include -#include -#endif - -/* Private functions */ -static int eXosip_create_transaction(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_message_t *request); -static int eXosip_create_cancel_transaction(eXosip_call_t *jc, - eXosip_dialog_t *jd, - osip_message_t *request); -static jauthinfo_t *eXosip_find_authentication_info(const char *username, - const char *realm); -static int eXosip_add_authentication_information(osip_message_t *req, - osip_message_t *last_response); -static void *eXosip_thread(void *arg); -static int eXosip_execute(void); -static osip_message_t *eXosip_prepare_request_for_auth(osip_message_t *msg); - -static int eXosip_update_top_via(osip_message_t *sip); - - -eXosip_t eXosip; - -void eXosip_set_firewallip(const char *firewall_address) -{ - if (firewall_address==NULL) return; - snprintf(eXosip.j_firewall_ip,50, "%s", firewall_address); -} - -void eXosip_set_nattype(const char *nat_type) -{ - osip_strncpy(eXosip.nat_type, (nat_type ? nat_type : ""), sizeof(eXosip.nat_type)-1); -} - -void eXosip_force_proxy(const char *proxyurl) -{ - osip_strncpy(eXosip.forced_proxy, (proxyurl ? proxyurl : ""), sizeof(eXosip.forced_proxy)-1); -} - -int eXosip_guess_localip(int family, char *address, int size) -{ - return eXosip_guess_ip_for_via(family, address, size); -} - -void eXosip_get_localip(char *ip) -{ - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip_get_localip IS DEPRECATED. Use eXosip_guess_localip!\n")); - eXosip_guess_ip_for_via(AF_INET, ip, 15); -} - -int -eXosip_is_public_address(const char *c_address) -{ - return (0!=strncmp(c_address, "192.168",7) - && 0!=strncmp(c_address, "10.",3) - && 0!=strncmp(c_address, "172.16.",7) - && 0!=strncmp(c_address, "172.17.",7) - && 0!=strncmp(c_address, "172.18.",7) - && 0!=strncmp(c_address, "172.19.",7) - && 0!=strncmp(c_address, "172.20.",7) - && 0!=strncmp(c_address, "172.21.",7) - && 0!=strncmp(c_address, "172.22.",7) - && 0!=strncmp(c_address, "172.23.",7) - && 0!=strncmp(c_address, "172.24.",7) - && 0!=strncmp(c_address, "172.25.",7) - && 0!=strncmp(c_address, "172.26.",7) - && 0!=strncmp(c_address, "172.27.",7) - && 0!=strncmp(c_address, "172.28.",7) - && 0!=strncmp(c_address, "172.29.",7) - && 0!=strncmp(c_address, "172.30.",7) - && 0!=strncmp(c_address, "172.31.",7) - && 0!=strncmp(c_address, "169.254",7)); -} - - -void __eXosip_wakeup(void) -{ - jpipe_write(eXosip.j_socketctl, "w", 1); -} - -void __eXosip_wakeup_event(void) -{ - jpipe_write(eXosip.j_socketctl_event, "w", 1); -} - - -int -eXosip_lock(void) -{ - return osip_mutex_lock((struct osip_mutex*)eXosip.j_mutexlock); -} - -int -eXosip_unlock(void) -{ - return osip_mutex_unlock((struct osip_mutex*)eXosip.j_mutexlock); -} - - -jfriend_t *jfriend_get(void) -{ - return eXosip.j_friends; -} - -void jfriend_remove(jfriend_t *fr) -{ - REMOVE_ELEMENT(eXosip.j_friends, fr); -} - -jsubscriber_t *jsubscriber_get(void) -{ - return eXosip.j_subscribers; -} - -jidentity_t *jidentity_get(void) -{ - return eXosip.j_identitys; -} - -void -eXosip_kill_transaction (osip_list_t * transactions) -{ - osip_transaction_t *transaction; - - if (!osip_list_eol (transactions, 0)) - { - /* some transaction are still used by osip, - transaction should be released by modules! */ - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "module sfp: _osip_kill_transaction transaction should be released by modules!\n")); - } - - while (!osip_list_eol (transactions, 0)) - { - transaction = osip_list_get (transactions, 0); - - __eXosip_delete_jinfo(transaction); - osip_transaction_free (transaction); - } -} - -void eXosip_quit(void) -{ - jauthinfo_t *jauthinfo; - eXosip_call_t *jc; - eXosip_notify_t *jn; - eXosip_subscribe_t *js; - eXosip_reg_t *jreg; - eXosip_pub_t *jpub; - int i; - - eXosip.j_stop_ua = 1; /* ask to quit the application */ - __eXosip_wakeup(); - __eXosip_wakeup_event(); - - i = osip_thread_join((struct osip_thread*)eXosip.j_thread); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: can't terminate thread!")); - } - osip_free((struct osip_thread*)eXosip.j_thread); - - jpipe_close(eXosip.j_socketctl); - jpipe_close(eXosip.j_socketctl_event); - - osip_free(eXosip.localip); - osip_free(eXosip.localport); - osip_free(eXosip.user_agent); - - eXosip.j_input = 0; - eXosip.j_output = 0; - - for (jc = eXosip.j_calls; jc!=NULL;jc = eXosip.j_calls) - { - REMOVE_ELEMENT(eXosip.j_calls, jc); - eXosip_call_free(jc); - } - - for (js = eXosip.j_subscribes; js!=NULL;js = eXosip.j_subscribes) - { - REMOVE_ELEMENT(eXosip.j_subscribes, js); - eXosip_subscribe_free(js); - } - - for (jn = eXosip.j_notifies; jn!=NULL;jn = eXosip.j_notifies) - { - REMOVE_ELEMENT(eXosip.j_notifies, jn); - eXosip_notify_free(jn); - } - - osip_mutex_destroy((struct osip_mutex*)eXosip.j_mutexlock); - osip_cond_destroy((struct osip_cond*)eXosip.j_cond); - - eXosip_sdp_negotiation_free(eXosip.osip_negotiation); - - if (eXosip.j_input) - fclose(eXosip.j_input); - if (eXosip.j_output) - osip_free(eXosip.j_output); - if (eXosip.j_socket) - close(eXosip.j_socket); - - for (jreg = eXosip.j_reg; jreg!=NULL; jreg = eXosip.j_reg) - { - REMOVE_ELEMENT(eXosip.j_reg, jreg); - eXosip_reg_free(jreg); - } - - for (jpub = eXosip.j_pub; jpub!=NULL; jpub = eXosip.j_pub) - { - REMOVE_ELEMENT(eXosip.j_pub, jpub); - _eXosip_pub_free(jpub); - } - - /* should be moved to method with an argument */ - jfriend_unload(); - jidentity_unload(); - jsubscriber_unload(); - - /* - for (jid = eXosip.j_identitys; jid!=NULL; jid = eXosip.j_identitys) - { - REMOVE_ELEMENT(eXosip.j_identitys, jid); - eXosip_friend_free(jid); - } - - for (jfr = eXosip.j_friends; jfr!=NULL; jfr = eXosip.j_friends) - { - REMOVE_ELEMENT(eXosip.j_friends, jfr); - eXosip_reg_free(jfr); - } - */ - - while (!osip_list_eol(eXosip.j_transactions, 0)) - { - osip_transaction_t *tr = (osip_transaction_t*) osip_list_get(eXosip.j_transactions, 0); - if (tr->state==IST_TERMINATED || tr->state==ICT_TERMINATED - || tr->state== NICT_TERMINATED || tr->state==NIST_TERMINATED) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "Release a terminated transaction\n")); - osip_list_remove(eXosip.j_transactions, 0); - __eXosip_delete_jinfo(tr); - osip_transaction_free(tr); - } - else - { - osip_list_remove(eXosip.j_transactions, 0); - __eXosip_delete_jinfo(tr); - osip_transaction_free(tr); - } - } - - osip_free(eXosip.j_transactions); - - eXosip_kill_transaction (eXosip.j_osip->osip_ict_transactions); - eXosip_kill_transaction (eXosip.j_osip->osip_nict_transactions); - eXosip_kill_transaction (eXosip.j_osip->osip_ist_transactions); - eXosip_kill_transaction (eXosip.j_osip->osip_nist_transactions); - osip_release (eXosip.j_osip); - - if (eXosip.j_events!=NULL) - { - eXosip_event_t *ev; - for(ev=osip_fifo_tryget(eXosip.j_events);ev!=NULL; - ev=osip_fifo_tryget(eXosip.j_events)) - eXosip_event_free(ev); - } - - osip_fifo_free(eXosip.j_events); - - for (jauthinfo = eXosip.authinfos; jauthinfo!=NULL; - jauthinfo = eXosip.authinfos) - { - REMOVE_ELEMENT(eXosip.authinfos, jauthinfo); - osip_free(jauthinfo); - } - - return ; -} - -static int eXosip_execute ( void ) -{ - struct timeval lower_tv; - int i; - - osip_timers_gettimeout(eXosip.j_osip, &lower_tv); - if (lower_tv.tv_sec>15) - { - lower_tv.tv_sec = 15; - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "eXosip: Reseting timer to 15s before waking up!\n")); - } - else - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "eXosip: timer sec:%i usec:%i!\n", - lower_tv.tv_sec, lower_tv.tv_usec)); - } - i = eXosip_read_message(1, lower_tv.tv_sec, lower_tv.tv_usec); - - if (i==-2) - { - return -2; - } - - eXosip_lock(); - osip_timers_ict_execute(eXosip.j_osip); - osip_timers_nict_execute(eXosip.j_osip); - osip_timers_ist_execute(eXosip.j_osip); - osip_timers_nist_execute(eXosip.j_osip); - - osip_ict_execute(eXosip.j_osip); - osip_nict_execute(eXosip.j_osip); - osip_ist_execute(eXosip.j_osip); - osip_nist_execute(eXosip.j_osip); - - /* free all Calls that are in the TERMINATED STATE? */ - eXosip_release_terminated_calls(); - - eXosip_unlock(); - - return 0; -} - -void *eXosip_thread ( void *arg ) -{ - int i; - while (eXosip.j_stop_ua==0) - { - i = eXosip_execute(); - if (i==-2) - osip_thread_exit(); - } - osip_thread_exit(); - return NULL; -} - -static int ipv6_enable = 0; - -void eXosip_enable_ipv6(int _ipv6_enable) -{ - ipv6_enable = _ipv6_enable; -} - -int eXosip_init(FILE *input, FILE *output, int port) -{ - osip_t *osip; - int i; - if (port<=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: port must be higher than 0!\n")); - return -1; - } - memset(&eXosip, 0, sizeof(eXosip)); - eXosip.localip = (char *) osip_malloc(50); - memset(eXosip.localip, '\0', 50); - - if (ipv6_enable == 0) - eXosip.ip_family = AF_INET; - else - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "IPv6 is enabled. Pls report bugs\n")); - eXosip.ip_family = AF_INET6; - } - - eXosip_guess_localip(eXosip.ip_family, eXosip.localip, 49); - if (eXosip.localip[0]=='\0') - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No ethernet interface found!\n")); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: using 127.0.0.1 (debug mode)!\n")); - strcpy(eXosip.localip, "127.0.0.1"); - /* we should always fallback on something. The linphone user will surely - start linphone BEFORE setting its dial up connection.*/ - } - eXosip.user_agent = osip_strdup("eXosip/" EXOSIP_VERSION); - - eXosip_set_mode(EVENT_MODE); - eXosip.j_input = input; - eXosip.j_output = output; - eXosip.j_calls = NULL; - eXosip.j_stop_ua = 0; - eXosip.j_thread = NULL; - eXosip.j_transactions = (osip_list_t*) osip_malloc(sizeof(osip_list_t)); - osip_list_init(eXosip.j_transactions); - eXosip.j_reg = NULL; - - eXosip.j_cond = (struct osip_cond*)osip_cond_init(); - - eXosip.j_mutexlock = (struct osip_mutex*)osip_mutex_init(); - - if (-1==osip_init(&osip)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: Cannot initialize osip!\n")); - return -1; - } - - eXosip_sdp_negotiation_init(&(eXosip.osip_negotiation)); - - eXosip_sdp_negotiation_add_codec(osip_strdup("0"), - NULL, - osip_strdup("RTP/AVP"), - NULL, NULL, NULL, - NULL,NULL, - osip_strdup("0 PCMU/8000")); - - eXosip_sdp_negotiation_add_codec(osip_strdup("8"), - NULL, - osip_strdup("RTP/AVP"), - NULL, NULL, NULL, - NULL,NULL, - osip_strdup("8 PCMA/8000")); - - osip_set_application_context(osip, &eXosip); - - eXosip_set_callbacks(osip); - - eXosip.j_osip = osip; - -#ifdef WIN32 - /* Initializing windows socket library */ - { - WORD wVersionRequested; - WSADATA wsaData; - - wVersionRequested = MAKEWORD(1,1); - if(i = WSAStartup(wVersionRequested, &wsaData)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: Unable to initialize WINSOCK, reason: %d\n",i)); - /* return -1; It might be already initilized?? */ - } - } -#endif - - /* open a TCP socket to wake up the application when needed. */ - eXosip.j_socketctl = jpipe(); - if (eXosip.j_socketctl==NULL) - return -1; - - eXosip.j_socketctl_event = jpipe(); - if (eXosip.j_socketctl_event==NULL) - return -1; - if (ipv6_enable == 0) - { - eXosip.j_socket = (int)socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (eXosip.j_socket==-1) - return -1; - - { - struct sockaddr_in raddr; - raddr.sin_addr.s_addr = htons(INADDR_ANY); - raddr.sin_port = htons((short)port); - raddr.sin_family = AF_INET; - - i = bind(eXosip.j_socket, (struct sockaddr *)&raddr, sizeof(raddr)); - if (i < 0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: Cannot bind on port: %i!\n", i)); - return -1; - } - } - } - else - { - eXosip.j_socket = (int)socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); - if (eXosip.j_socket==-1) - return -1; - - { - struct sockaddr_in6 raddr; - memset(&raddr, 0, sizeof(raddr)); - raddr.sin6_port = htons((short)port); - raddr.sin6_family = AF_INET6; - - i = bind(eXosip.j_socket, (struct sockaddr *)&raddr, sizeof(raddr)); - if (i < 0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: Cannot bind on port: %i!\n", i)); - return -1; - } - } - } - - - eXosip.localport = (char*)osip_malloc(10); - sprintf(eXosip.localport, "%i", port); - - eXosip.j_thread = (void*) osip_thread_create(20000,eXosip_thread, NULL); - if (eXosip.j_thread==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: Cannot start thread!\n")); - return -1; - } - - /* To be changed in osip! */ - eXosip.j_events = (osip_fifo_t*) osip_malloc(sizeof(osip_fifo_t)); - osip_fifo_init(eXosip.j_events); - - jfriend_load(); - jidentity_load(); - jsubscriber_load(); - return 0; -} - -int eXosip_force_localip(const char *localip){ - if (localip!=NULL){ - strcpy(eXosip.localip,localip); - eXosip.forced_localip=1; - }else { - eXosip_guess_ip_for_via(eXosip.ip_family, eXosip.localip, 49); - eXosip.forced_localip=0; - } - return 0; -} - -void -eXosip_set_mode(int mode) -{ - eXosip.j_runtime_mode = mode; -} - -void -eXosip_set_user_agent(const char *user_agent) -{ - osip_free(eXosip.user_agent); - eXosip.user_agent = osip_strdup(user_agent); -} - -void -eXosip_automatic_refresh() -{ -#if 0 - eXosip_call_t *jc; - eXosip_notify_t *jn; -#endif - eXosip_subscribe_t *js; - eXosip_dialog_t *jd; - eXosip_reg_t *jr; - int now; - - now = time(NULL); - -#if 0 - for (jc=eXosip.j_calls; jc!=NULL; jc=jc->next) - { - if (jc->c_id<1) - { - } - for (jd=jc->c_dialogs; jd!=NULL; jd=jd->next) - { - if (jd->d_dialog!=NULL) /* finished call */ - { - /* sending update for keep-alive mechanism could be done here! */ - } - } - } -#endif - - for (js=eXosip.j_subscribes; js!=NULL; js=js->next) - { - for (jd=js->s_dialogs; jd!=NULL; jd=jd->next) - { - if (jd->d_dialog!=NULL) /* finished call */ - { - if (jd->d_id>=1) - { - if (eXosip_subscribe_need_refresh(js, now)==0) - { - int i; -#ifdef LOW_EXPIRE - i = eXosip_subscribe_send_subscribe(js, jd, "120"); -#else - i = eXosip_subscribe_send_subscribe(js, jd, "3600"); -#endif - } - } - } - } - } - -#if 0 - for (jn=eXosip.j_notifies; jn!=NULL; jn=jn->next) - { - if (jn->n_id<1) - { - jn->n_id = static_id; - static_id++; - } - for (jd=jn->n_dialogs; jd!=NULL; jd=jd->next) - { - if (jd->d_dialog!=NULL) /* finished call */ - { - if (jd->d_id>=1) - { - /* keep-alive of dialog should be done by subscribe */ - /* may be we can decide to close the subscribption - if it is expired */ - } - } - } - } -#endif - - for (jr = eXosip.j_reg; jr != NULL; jr = jr->next) - { - if (jr->r_id >=1 || jr->r_last_tr!=NULL) - { - if (jr->r_reg_period==0) - { - /* skip refresh! */ - } - else if (now-jr->r_last_tr->birth_time>300) - { - /* automatic refresh */ - eXosip_register(jr->r_id, jr->r_reg_period); - } - else if (now-jr->r_last_tr->birth_time>jr->r_reg_period-60) - { - /* automatic refresh */ - eXosip_register(jr->r_id, jr->r_reg_period); - } - else if (now-jr->r_last_tr->birth_time>120 && - (jr->r_last_tr->last_response==NULL - || (!MSG_IS_STATUS_2XX(jr->r_last_tr->last_response)))) - { - /* automatic refresh */ - eXosip_register(jr->r_id, jr->r_reg_period); - } - } - } -} - -void -eXosip_update() -{ - static int static_id = 1; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - eXosip_notify_t *jn; - eXosip_dialog_t *jd; - int now; - - if (static_id>100000) - static_id = 1; /* loop */ - - now = time(NULL); - for (jc=eXosip.j_calls; jc!=NULL; jc=jc->next) - { - if (jc->c_id<1) - { - jc->c_id = static_id; - static_id++; - } - for (jd=jc->c_dialogs; jd!=NULL; jd=jd->next) - { - if (jd->d_dialog!=NULL) /* finished call */ - { - if (jd->d_id<1) - { - jd->d_id = static_id; - static_id++; - } - } - else jd->d_id = -1; - } - } - - for (js=eXosip.j_subscribes; js!=NULL; js=js->next) - { - if (js->s_id<1) - { - js->s_id = static_id; - static_id++; - } - for (jd=js->s_dialogs; jd!=NULL; jd=jd->next) - { - if (jd->d_dialog!=NULL) /* finished call */ - { - if (jd->d_id<1) - { - jd->d_id = static_id; - static_id++; - } - } - else - jd->d_id = -1; - } - } - - for (jn=eXosip.j_notifies; jn!=NULL; jn=jn->next) - { - if (jn->n_id<1) - { - jn->n_id = static_id; - static_id++; - } - for (jd=jn->n_dialogs; jd!=NULL; jd=jd->next) - { - if (jd->d_dialog!=NULL) /* finished call */ - { - if (jd->d_id<1) - { - jd->d_id = static_id; - static_id++; - } - } - else jd->d_id = -1; - } - } -} - -int eXosip_message (char *to, char *from, char *route, char *buff) -{ - /* eXosip_call_t *jc; - osip_header_t *subject; */ - osip_message_t *message; - osip_transaction_t *transaction; - osip_event_t *sipevent; - int i; - - i = generating_message(&message, to, from, route, buff); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot send message (cannot build MESSAGE)! ")); - return -1; - } - - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - message); - if (i!=0) - { - /* TODO: release the j_call.. */ - - osip_message_free(message); - return -1; - } - - osip_list_add(eXosip.j_transactions, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(message); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, NULL, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_info_call(int jid, char *content_type, char *body) -{ - osip_transaction_t *transaction; - osip_event_t *sipevent; - osip_message_t *info; - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - int i; - - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - if (jd==NULL || jd->d_dialog==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No established dialog!")); - return -1; - } - - transaction = eXosip_find_last_options(jc, jd); - if (transaction!=NULL) - { - if (transaction->state!=NICT_TERMINATED && - transaction->state!=NIST_TERMINATED) - return -1; - transaction=NULL; - } - - i = generating_info_within_dialog(&info, jd->d_dialog); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot send info message! ")); - return -2; - } - - osip_message_set_content_type(info, content_type); - osip_message_set_body(info, body, strlen(body)); - - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - info); - if (i!=0) - { - osip_message_free(info); - return -1; - } - - osip_list_add(jd->d_out_trs, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(info); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(jc, jd, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_initiate_call_with_body(osip_message_t *invite,const char *bodytype, const char*body, void *reference){ - eXosip_call_t *jc; - osip_header_t *subject; - osip_transaction_t *transaction; - osip_event_t *sipevent; - int i; - char *size; - - if (body!=NULL){ - size= (char *)osip_malloc(7*sizeof(char)); - sprintf(size,"%i",strlen(body)); - osip_message_set_content_length(invite, size); - osip_free(size); - osip_message_set_body(invite, body, strlen(body)); - osip_message_set_content_type(invite,bodytype); - } - else osip_message_set_content_length(invite, "0"); - - eXosip_call_init(&jc); - i = osip_message_get_subject(invite, 0, &subject); - if (subject!=NULL && subject->hvalue!=NULL && subject->hvalue[0]!='\0') - snprintf(jc->c_subject, 99, "%s", subject->hvalue); - - jc->c_ack_sdp = 0; - - i = osip_transaction_init(&transaction, - ICT, - eXosip.j_osip, - invite); - if (i!=0) - { - eXosip_call_free(jc); - osip_message_free(invite); - return -1; - } - - jc->c_out_tr = transaction; - - sipevent = osip_new_outgoing_sipmessage(invite); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(jc, NULL, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - - jc->external_reference = reference; - ADD_ELEMENT(eXosip.j_calls, jc); - - eXosip_update(); /* fixed? */ - __eXosip_wakeup(); - return jc->c_id; -} - -osip_message_t *eXosip_prepare_request_for_auth(osip_message_t *msg) -{ -#ifdef SM - char *locip; -#else - char locip[50]; -#endif - osip_message_t *newmsg; - int cseq; - char tmp[90]; - osip_via_t *via; - - osip_message_clone(msg,&newmsg); - if (newmsg==NULL){ - eXosip_trace(OSIP_INFO1,("eXosip_prepare_request_for_auth: could not clone msg.")); - return NULL; - } - via = (osip_via_t *) osip_list_get (newmsg->vias, 0); - if (via==NULL || newmsg->cseq==NULL || newmsg->cseq->number==NULL) { - osip_message_free(newmsg); - eXosip_trace(OSIP_INFO1,("eXosip_prepare_request_for_auth: Bad headers in previous request.")); - return NULL; - } - /* increment cseq */ - cseq=atoi(newmsg->cseq->number); - osip_free(newmsg->cseq->number); - newmsg->cseq->number=strdup_printf("%i",cseq+1); - - osip_list_remove(newmsg->vias, 0); - locip=osip_strdup(osip_via_get_host(via)); - osip_via_free(via); -#ifdef SM - -#else - eXosip_guess_ip_for_via(eXosip.ip_family, locip, 49); -#endif - if (eXosip.ip_family==AF_INET6) - sprintf(tmp, "SIP/2.0/UDP [%s]:%s;branch=z9hG4bK%u", - locip, - eXosip.localport, - via_branch_new_random()); - else - sprintf(tmp, "SIP/2.0/UDP %s:%s;rport;branch=z9hG4bK%u", - locip, - eXosip.localport, - via_branch_new_random()); - -#ifdef SM - osip_free(locip); -#endif - osip_via_init(&via); - osip_via_parse(via, tmp); - osip_list_add(newmsg->vias, via, 0); - - return newmsg; -} - -int eXosip_retry_call(int cid) -{ - eXosip_call_t *jc=NULL; - osip_transaction_t *tr,*newtr=NULL; - osip_message_t *inv=NULL; - int i; - osip_event_t *sipevent; - eXosip_call_find(cid,&jc); - if (jc==NULL) { - eXosip_trace(OSIP_INFO1,("eXosip_retry_last_invite: No such call.")); - return -1; - } - tr=eXosip_find_last_out_invite(jc,NULL); - if (tr==NULL){ - eXosip_trace(OSIP_INFO1,("eXosip_retry_last_invite: No such transaction.")); - return -1; - } - if (tr->last_response==NULL){ - eXosip_trace(OSIP_INFO1,("eXosip_retry_last_invite: transaction has not been answered.")); - return -1; - } - inv=eXosip_prepare_request_for_auth(tr->orig_request); - if (inv==NULL) return -1; - eXosip_add_authentication_information(inv,tr->last_response); - if (-1 == eXosip_update_top_via(inv)) - { - osip_message_free(inv); - return -1; - } - - - i = osip_transaction_init(&newtr, - ICT, - eXosip.j_osip, - inv); - if (i!=0) - { - osip_message_free(inv); - return -1; - } - jc->c_out_tr = newtr; - - sipevent = osip_new_outgoing_sipmessage(inv); - - osip_transaction_set_your_instance(newtr, __eXosip_new_jinfo(jc, NULL, NULL, NULL)); - osip_transaction_add_event(newtr, sipevent); - - eXosip_update(); /* fixed? */ - __eXosip_wakeup(); - return jc->c_id; -} - -extern int cb_udp_snd_message(osip_transaction_t *tr, osip_message_t *sip, - char *host, int port, int out_socket); - -int eXosip_send_ack(int did){ - eXosip_call_t *call; - eXosip_dialog_t *dialog; - eXosip_call_dialog_find(did,&call,&dialog); - if (dialog!=NULL){ - if (dialog->d_ack!=NULL){ - osip_route_t *route; - int port; - char *host; - osip_message_t *ack=dialog->d_ack; - osip_message_get_route(ack, 0, &route); - if (route!=NULL) - { - port = 5060; - if (route->url->port!=NULL) - port = osip_atoi(route->url->port); - host = route->url->host; - } - else - { - port = 5060; - if (ack->req_uri->port!=NULL) - port = osip_atoi(ack->req_uri->port); - host = ack->req_uri->host; - } - - cb_udp_snd_message(NULL, ack, host, port, eXosip.j_socket); - } - } - return 0; -} - -extern osip_list_t *supported_codec; - -int eXosip_initiate_call(osip_message_t *invite, void *reference, - void *sdp_context_reference, - char *local_sdp_port) -{ - eXosip_call_t *jc; - osip_header_t *subject; - osip_transaction_t *transaction; - osip_event_t *sipevent; - int i; - sdp_message_t *sdp; - char *body; - char *size; - - if (invite==NULL || invite->req_uri==NULL || invite->req_uri->host==NULL ) return -1; - - if (local_sdp_port!=NULL) - { - osip_negotiation_sdp_build_offer(eXosip.osip_negotiation, NULL, &sdp, local_sdp_port, NULL); - - /* - if speex codec is supported, add bandwith attribute: - b=AS:110 20 - b=AS:111 20 - */ - if (sdp!=NULL) - { - int pos=0; - while (!sdp_message_endof_media (sdp, pos)) - { - int k = 0; - char *tmp = sdp_message_m_media_get (sdp, pos); - if (0 == osip_strncasecmp (tmp, "audio", 5)) - { - char *payload = NULL; - do { - payload = sdp_message_m_payload_get (sdp, pos, k); - if (payload == NULL) - { - } - else if (0==strcmp("110",payload)) - { - sdp_message_a_attribute_add (sdp, - pos, - osip_strdup ("AS"), - osip_strdup ("110 20")); - } - else if (0==strcmp("111",payload)) - { - sdp_message_a_attribute_add (sdp, - pos, - osip_strdup ("AS"), - osip_strdup ("111 20")); - } - k++; - } while (payload != NULL); - } - pos++; - } - } - - if (eXosip.j_firewall_ip[0]!='\0') - { - char *c_address = invite->req_uri->host; - int pos=0; - struct addrinfo *addrinfo; - struct __eXosip_sockaddr addr; - i = eXosip_get_addrinfo(&addrinfo, invite->req_uri->host, 5060); - if (i==0) - { - memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen); - freeaddrinfo (addrinfo); - c_address = inet_ntoa (((struct sockaddr_in *) &addr)->sin_addr); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "eXosip: here is the resolved destination host=%s\n", c_address)); - } - - /* If remote message contains a Public IP, we have to replace the SDP - connection address */ - if (eXosip_is_public_address(c_address)) - { - /* replace the IP with our firewall ip */ - sdp_connection_t *conn = sdp_message_connection_get(sdp, -1, 0); - if (conn!=NULL && conn->c_addr!=NULL ) - { - osip_free(conn->c_addr); - conn->c_addr = osip_strdup(eXosip.j_firewall_ip); - } - pos=0; - conn = sdp_message_connection_get(sdp, pos, 0); - while (conn!=NULL) - { - if (conn!=NULL && conn->c_addr!=NULL ) - { - osip_free(conn->c_addr); - conn->c_addr = osip_strdup(eXosip.j_firewall_ip); - } - pos++; - conn = sdp_message_connection_get(sdp, pos, 0); - } - } - - } - - i = sdp_message_to_str(sdp, &body); - if (body!=NULL) - { - size= (char *)osip_malloc(7*sizeof(char)); -#ifdef __APPLE_CC__ - sprintf(size,"%li",strlen(body)); -#else - sprintf(size,"%i",strlen(body)); -#endif - osip_message_set_content_length(invite, size); - osip_free(size); - - osip_message_set_body(invite, body, strlen(body)); - osip_free(body); - osip_message_set_content_type(invite, "application/sdp"); - } - else - osip_message_set_content_length(invite, "0"); - } - - eXosip_call_init(&jc); - if (local_sdp_port!=NULL) - snprintf(jc->c_sdp_port,9, "%s", local_sdp_port); - i = osip_message_get_subject(invite, 0, &subject); - if (subject!=NULL && subject->hvalue!=NULL && subject->hvalue[0]!='\0') - snprintf(jc->c_subject, 99, "%s", subject->hvalue); - - if (sdp_context_reference==NULL) - osip_negotiation_ctx_set_mycontext(jc->c_ctx, jc); - else - osip_negotiation_ctx_set_mycontext(jc->c_ctx, sdp_context_reference); - - if (local_sdp_port!=NULL) - { - osip_negotiation_ctx_set_local_sdp(jc->c_ctx, sdp); - jc->c_ack_sdp = 0; - } - else - jc->c_ack_sdp = 1; - - i = osip_transaction_init(&transaction, - ICT, - eXosip.j_osip, - invite); - if (i!=0) - { - eXosip_call_free(jc); - osip_message_free(invite); - return -1; - } - - jc->c_out_tr = transaction; - - sipevent = osip_new_outgoing_sipmessage(invite); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(jc, NULL, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - - jc->external_reference = reference; - ADD_ELEMENT(eXosip.j_calls, jc); - - eXosip_update(); /* fixed? */ - __eXosip_wakeup(); - return jc->c_id; -} - - -int eXosip2_answer(int jid, int status, osip_message_t **answer){ - int i = -1; - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - if (status>100 && status<200) - { - i = _eXosip2_answer_invite_1xx(jc, jd, status, answer); - } - else if (status>199 && status<300) - { - i = _eXosip2_answer_invite_2xx(jc, jd, status, answer); - } - else if (status>300 && status<699) - { - i = _eXosip2_answer_invite_3456xx(jc, jd, status, answer); - } - else - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: wrong status code (1010) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - - tr = eXosip_find_last_inc_invite(jc, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return -1; - } - /* is the transaction already answered? */ - if (tr->state==IST_COMPLETED - || tr->state==IST_CONFIRMED - || tr->state==IST_TERMINATED) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: transaction already answered\n")); - return -1; - } - - if (MSG_IS_STATUS_1XX(answer)) - { - if (jd==NULL) - { - i = eXosip_dialog_init_as_uas(&jd, tr->orig_request, answer); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog!\n")); - i = 0; - } - else - { - ADD_ELEMENT(jc->c_dialogs, jd); - } - } - } - else if (MSG_IS_STATUS_2XX(answer)) - { - if (jd==NULL) - { - i = eXosip_dialog_init_as_uas(&jd, tr->orig_request, answer); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog!\n")); - return -1; - } - ADD_ELEMENT(jc->c_dialogs, jd); - } - else i = 0; - - eXosip_dialog_set_200ok(jd, answer); - osip_dialog_set_state(jd->d_dialog, DIALOG_CONFIRMED); - } - else if (answer->status_code>=300 && answer->status_code<=699) - { - i = 0; - } - else - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: wrong status code (101transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - return 0; -} - -int eXosip_answer_call_with_body(int jid, int status, const char *bodytype, const char *body){ - int i = -1; - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - if (status>100 && status<200) - { - i = eXosip_answer_invite_1xx(jc, jd, status); - } - else if (status>199 && status<300) - { - i = eXosip_answer_invite_2xx_with_body(jc, jd, status,bodytype,body); - } - else if (status>300 && status<699) - { - i = eXosip_answer_invite_3456xx(jc, jd, status); - } - else - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: wrong status code (1010) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - if (contact==NULL) - memset(jc->c_redirection, '\0', 1024); - else - snprintf(jc->c_redirection, 1024, "%s", contact); - return 0; -} - -int eXosip_answer_call (int jid, int status, char *local_sdp_port) -{ - int i = -1; - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - if (status>100 && status<200) - { - i = eXosip_answer_invite_1xx(jc, jd, status); - } - else if (status>199 && status<300) - { -#if 0 /* this seems to be useless?? */ - if (jc->c_ctx!=NULL) - osip_negotiation_ctx_set_mycontext(jc->c_ctx, jc); - else - osip_negotiation_ctx_set_mycontext(jc->c_ctx, sdp_context_reference); -#endif - if (local_sdp_port!=NULL) - { - osip_negotiation_ctx_set_mycontext(jc->c_ctx, jc); - snprintf(jc->c_sdp_port,9, "%s", local_sdp_port); - } - - i = eXosip_answer_invite_2xx(jc, jd, status, local_sdp_port); - } - else if (status>300 && status<699) - { - i = eXosip_answer_invite_3456xx(jc, jd, status); - } - else - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: wrong status code (1010) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - - pl = eXosip_retrieve_sdp_negotiation_result(jc->c_ctx, payload_name, pnsize); - - if (pl >= 0) - { - *payload = pl; - return 0; - } - - return -1; -} - -int eXosip_options_call (int jid) -{ - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - - osip_transaction_t *transaction; - osip_event_t *sipevent; - osip_message_t *options; - int i; - - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - - transaction = eXosip_find_last_options(jc, jd); - if (transaction!=NULL) - { - if (transaction->state!=NICT_TERMINATED && - transaction->state!=NIST_TERMINATED) - return -1; - transaction=NULL; - } - - i = _eXosip_build_request_within_dialog(&options, "OPTIONS", jd->d_dialog, "UDP"); - if (i!=0) - return -2; - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - options); - if (i!=0) - { - /* TODO: release the j_call.. */ - osip_message_free(options); - return -2; - } - - osip_list_add(jd->d_out_trs, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(options); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(jc, jd, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_answer_options (int cid, int jid, int status) -{ - int i = -1; - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No dialog here?\n")); - return -1; - } - } - else - { - eXosip_call_find(cid, &jc); - if (jc==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - } - if (status>100 && status<200) - { - i = eXosip_answer_options_1xx(jc, jd, status); - } - else if (status>199 && status<300) - { - i = eXosip_answer_options_2xx(jc, jd, status); - } - else if (status>300 && status<699) - { - i = eXosip_answer_options_3456xx(jc, jd, status); - } - else - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: wrong status code (1010) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jc==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - jc->external_reference = reference; - return 0; -} - -int eXosip_on_hold_call (int jid) -{ - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - - osip_transaction_t *transaction; - osip_event_t *sipevent; - osip_message_t *invite; - int i; - sdp_message_t *sdp; - char *body; - char *size; - - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - - transaction = eXosip_find_last_invite(jc, jd); - if (transaction==NULL) return -1; - if (transaction->state!=ICT_TERMINATED && - transaction->state!=IST_TERMINATED) - return -1; - - sdp = eXosip_get_local_sdp_info(transaction); - if (sdp==NULL) - return -1; - i = osip_negotiation_sdp_message_put_on_hold(sdp); - if (i!=0) - { - sdp_message_free(sdp); - return -2; - } - - i = _eXosip_build_request_within_dialog(&invite, "INVITE", jd->d_dialog, "UDP"); - if (i!=0) { - sdp_message_free(sdp); - return -2; - } - - i = sdp_message_to_str(sdp, &body); - if (body!=NULL) - { - size= (char *)osip_malloc(7*sizeof(char)); -#ifdef __APPLE_CC__ - sprintf(size,"%li",strlen(body)); -#else - sprintf(size,"%i",strlen(body)); -#endif - osip_message_set_content_length(invite, size); - osip_free(size); - - osip_message_set_body(invite, body, strlen(body)); - osip_free(body); - osip_message_set_content_type(invite, "application/sdp"); - } - else - osip_message_set_content_length(invite, "0"); - - if (jc->c_subject==NULL || jc->c_subject[0]=='\0') - { -#if 0 - osip_message_set_subject(invite, "New Call"); -#endif - } - else - osip_message_set_subject(invite, jc->c_subject); - - transaction=NULL; - i = osip_transaction_init(&transaction, - ICT, - eXosip.j_osip, - invite); - if (i!=0) - { - /* TODO: release the j_call.. */ - osip_message_free(invite); - return -2; - } - - { - sdp_message_t *old_sdp = osip_negotiation_ctx_get_local_sdp(jc->c_ctx); - sdp_message_free(old_sdp); - osip_negotiation_ctx_set_local_sdp(jc->c_ctx, sdp); - } - - osip_list_add(jd->d_out_trs, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(invite); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(jc, jd, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_off_hold_call (int jid, char *rtp_ip, int port) -{ - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - - osip_transaction_t *transaction; - osip_event_t *sipevent; - osip_message_t *invite; - int i; - sdp_message_t *sdp; - char *body; - char *size; - - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - - transaction = eXosip_find_last_invite(jc, jd); - if (transaction==NULL) return -1; - if (transaction->state!=ICT_TERMINATED && - transaction->state!=IST_TERMINATED) - return -1; - - sdp = eXosip_get_local_sdp_info(transaction); - if (sdp==NULL) - return -1; - i = osip_negotiation_sdp_message_put_off_hold(sdp); - if (i!=0) - { - sdp_message_free(sdp); - return -2; - } - - i = _eXosip_build_request_within_dialog(&invite, "INVITE", jd->d_dialog, "UDP"); - if (i!=0) { - sdp_message_free(sdp); - return -2; - } - - if (rtp_ip!=NULL) - { - /* modify the connection address of host */ - sdp_connection_t *conn; - sdp_media_t *med; - int pos_media = 0; - conn = sdp_message_connection_get(sdp, -1, 0); - if (conn!=NULL && conn->c_addr!=NULL) - { - osip_free(conn->c_addr); - conn->c_addr = osip_strdup(rtp_ip); - } - med = (sdp_media_t *) osip_list_get (sdp->m_medias, pos_media); - while (med != NULL) - { - if (med->m_media!=NULL && 0==osip_strcasecmp(med->m_media, "audio")) - { - osip_free(med->m_port); - med->m_port=(char *)osip_malloc(15); - snprintf(med->m_port, 14, "%i", port); - break; - } - pos_media++; - med = (sdp_media_t *) osip_list_get (sdp->m_medias, pos_media); - } - } - - i = sdp_message_to_str(sdp, &body); - if (body!=NULL) - { - size= (char *)osip_malloc(7*sizeof(char)); -#ifdef __APPLE_CC__ - sprintf(size,"%li",strlen(body)); -#else - sprintf(size,"%i",strlen(body)); -#endif - osip_message_set_content_length(invite, size); - osip_free(size); - - osip_message_set_body(invite, body, strlen(body)); - osip_free(body); - osip_message_set_content_type(invite, "application/sdp"); - } - else - osip_message_set_content_length(invite, "0"); - - if (jc->c_subject==NULL || jc->c_subject[0]=='\0') - { -#if 0 - osip_message_set_subject(invite, "New Call"); -#endif - } - else - osip_message_set_subject(invite, jc->c_subject); - - transaction=NULL; - i = osip_transaction_init(&transaction, - ICT, - eXosip.j_osip, - invite); - if (i!=0) - { - /* TODO: release the j_call.. */ - osip_message_free(invite); - return -2; - } - - { - sdp_message_t *old_sdp = osip_negotiation_ctx_get_local_sdp(jc->c_ctx); - sdp_message_free(old_sdp); - osip_negotiation_ctx_set_local_sdp(jc->c_ctx, sdp); - } - - osip_list_add(jd->d_out_trs, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(invite); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(jc, jd, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -static int eXosip_create_transaction(eXosip_call_t *jc, - eXosip_dialog_t *jd, - osip_message_t *request) -{ - osip_event_t *sipevent; - osip_transaction_t *tr; - int i; - i = osip_transaction_init(&tr, - NICT, - eXosip.j_osip, - request); - if (i!=0) - { - /* TODO: release the j_call.. */ - - osip_message_free(request); - return -1; - } - - if (jd!=NULL) - osip_list_add(jd->d_out_trs, tr, 0); - - sipevent = osip_new_outgoing_sipmessage(request); - sipevent->transactionid = tr->transactionid; - - osip_transaction_set_your_instance(tr, __eXosip_new_jinfo(jc, jd, NULL, NULL)); - osip_transaction_add_event(tr, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_transfer_call_out_of_dialog(char *refer_to, char *from, char *to, char *proxy) -{ - osip_message_t *refer; - osip_transaction_t *transaction; - osip_event_t *sipevent; - int i; - i = generating_refer_outside_dialog(&refer, refer_to, from, to, proxy); - if (i!=0) return -1; - - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - refer); - if (i!=0) - { - osip_message_free(refer); - return -1; - } - - osip_list_add(eXosip.j_transactions, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(refer); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, NULL, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_transfer_call(int jid, char *refer_to) -{ - int i; - osip_message_t *request; - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - if (jid<=0) - return -1; - - eXosip_call_dialog_find(jid, &jc, &jd); - if (jd==NULL || jd->d_dialog==NULL || jd->d_dialog->state==DIALOG_EARLY) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No established call here!")); - return -1; - } - - i = generating_refer(&request, jd->d_dialog, refer_to); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot generate REFER for call!")); - return -2; - } - - i = eXosip_create_transaction(jc, jd, request); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot initiate SIP transfer transaction!")); - return i; - } - return 0; -} - -static int eXosip_create_cancel_transaction(eXosip_call_t *jc, - eXosip_dialog_t *jd, - osip_message_t *request) -{ - osip_event_t *sipevent; - osip_transaction_t *tr; - int i; - i = osip_transaction_init(&tr, - NICT, - eXosip.j_osip, - request); - if (i!=0) - { - /* TODO: release the j_call.. */ - - osip_message_free(request); - return -2; - } - - osip_list_add(eXosip.j_transactions, tr, 0); - - sipevent = osip_new_outgoing_sipmessage(request); - sipevent->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_terminate_call(int cid, int jid) -{ - int i; - osip_transaction_t *tr; - osip_message_t *request; - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here? ")); - return -1; - } - } - else - { - eXosip_call_find(cid, &jc); - } - - if (jc==NULL) - { - return -1; - } - - tr=eXosip_find_last_out_invite(jc, jd); - if (tr!=NULL && tr->last_response!=NULL && MSG_IS_STATUS_1XX(tr->last_response)) - { - i = generating_cancel(&request, tr->orig_request); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot terminate this call! ")); - return -2; - } - i = eXosip_create_cancel_transaction(jc, jd, request); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot initiate SIP transaction! ")); - return i; - } - if (jd!=NULL) - { - osip_dialog_free(jd->d_dialog); - jd->d_dialog = NULL; - } - return 0; - } - - if (jd==NULL || jd->d_dialog==NULL) - { - /* Check if some dialog exists */ - jd = jc->c_dialogs; - if (jd!=NULL && jd->d_dialog!=NULL) - { - i = generating_bye(&request, jd->d_dialog); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot terminate this call! ")); - return -2; - } - - i = eXosip_create_transaction(jc, jd, request); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot initiate SIP transaction! ")); - return -2; - } - - osip_dialog_free(jd->d_dialog); - jd->d_dialog = NULL; - return 0; - } - - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No established dialog!")); - return -1; - } - - if (tr==NULL) - { - /*this may not be enough if it's a re-INVITE! */ - tr = eXosip_find_last_inc_invite(jc, jd); - if (tr!=NULL && tr->last_response!=NULL && - MSG_IS_STATUS_1XX(tr->last_response)) - { /* answer with 603 */ - i = eXosip_answer_call(jid, 603, 0); - return i; - } - } - - - i = generating_bye(&request, jd->d_dialog); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot terminate this call! ")); - return -2; - } - - i = eXosip_create_transaction(jc, jd, request); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot initiate SIP transaction! ")); - return -2; - } - - osip_dialog_free(jd->d_dialog); - jd->d_dialog = NULL; - return 0; -} - -static jauthinfo_t * -eXosip_find_authentication_info(const char *username, const char *realm) -{ - jauthinfo_t *fallback = NULL; - jauthinfo_t *authinfo; - - for (authinfo = eXosip.authinfos; - authinfo!=NULL; - authinfo = authinfo->next) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "INFO: authinfo: %s %s\n", realm, authinfo->realm)); - if (0==strcmp(authinfo->username, username)) - { - if (authinfo->realm == NULL || authinfo->realm[0] == '\0') - { - fallback = authinfo; - } - else if (strcmp(realm,authinfo->realm)==0 || 0==strncmp(realm+1, authinfo->realm, strlen(realm)-2)) - { - return authinfo; - } - } - } - return fallback; -} - - -int eXosip_clear_authentication_info(){ - jauthinfo_t *jauthinfo; - for (jauthinfo = eXosip.authinfos; jauthinfo!=NULL; - jauthinfo = eXosip.authinfos) - { - REMOVE_ELEMENT(eXosip.authinfos, jauthinfo); - osip_free(jauthinfo); - } - return 0; -} - -int -eXosip_add_authentication_info(const char *username, const char *userid, - const char *passwd, const char *ha1, - const char *realm) -{ - jauthinfo_t *authinfos; - - if (username==NULL || username[0]=='\0') return -1; - if (userid==NULL || userid[0]=='\0') return -1; - - if ( passwd!=NULL && passwd[0]!='\0') {} - else if (ha1!=NULL && ha1[0]!='\0') {} - else return -1; - - authinfos = (jauthinfo_t *) osip_malloc(sizeof(jauthinfo_t)); - if (authinfos==NULL) - return -1; - memset(authinfos, 0, sizeof(jauthinfo_t)); - - snprintf(authinfos->username, 50, "%s", username); - snprintf(authinfos->userid, 50, "%s", userid); - if ( passwd!=NULL && passwd[0]!='\0') - snprintf(authinfos->passwd, 50, "%s", passwd); - else if (ha1!=NULL && ha1[0]!='\0') - snprintf(authinfos->ha1, 50, "%s", ha1); - if(realm!=NULL && realm[0]!='\0') - snprintf(authinfos->realm, 50, "%s", realm); - - ADD_ELEMENT(eXosip.authinfos, authinfos); - return 0; -} - -static int -eXosip_add_authentication_information(osip_message_t *req, - osip_message_t *last_response) -{ - osip_authorization_t *aut = NULL; - osip_www_authenticate_t *wwwauth = NULL; - osip_proxy_authorization_t *proxy_aut = NULL; - osip_proxy_authenticate_t *proxyauth = NULL; - jauthinfo_t *authinfo = NULL; - int pos; - int i; - - if (req==NULL - ||req->from==NULL - ||req->from->url==NULL - ||req->from->url->username==NULL) - return -1; - - pos=0; - osip_message_get_www_authenticate(last_response, pos, &wwwauth); - osip_message_get_proxy_authenticate(last_response, pos, &proxyauth); - if (wwwauth==NULL && proxyauth==NULL) return -1; - - while (wwwauth!=NULL) - { - char *uri; - authinfo = eXosip_find_authentication_info(req->from->url->username, - wwwauth->realm); - if (authinfo==NULL) return -1; - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "authinfo: %s\n", authinfo->username)); - i = osip_uri_to_str (req->req_uri, &uri); - if (i!=0) return -1; - - i = __eXosip_create_authorization_header(last_response, uri, - authinfo->userid, - authinfo->passwd, - &aut); - osip_free(uri); - if (i!=0) return -1; - - if (aut != NULL) - { - osip_list_add (req->authorizations, aut, -1); - osip_message_force_update(req); - } - - pos++; - osip_message_get_www_authenticate(last_response, pos, &wwwauth); - } - - pos=0; - while (proxyauth!=NULL) - { - char *uri; - authinfo = eXosip_find_authentication_info(req->from->url->username, - proxyauth->realm); - if (authinfo==NULL) return -1; - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "authinfo: %s\n", authinfo->username)); - i = osip_uri_to_str (req->req_uri, &uri); - if (i!=0) return -1; - - i = __eXosip_create_proxy_authorization_header(last_response, uri, - authinfo->userid, - authinfo->passwd, - &proxy_aut); - osip_free(uri); - if (i!=0) return -1; - - if (proxy_aut != NULL) - { - osip_list_add (req->proxy_authorizations, proxy_aut, -1); - osip_message_force_update(req); - } - - pos++; - osip_message_get_proxy_authenticate (last_response, pos, &proxyauth); - } - - return 0; -} - - -static int -eXosip_update_top_via(osip_message_t *sip) -{ -#ifdef SM - char *locip; -#else - char locip[50]; -#endif - char *tmp = (char *)osip_malloc(256*sizeof(char)); - osip_via_t *via = (osip_via_t *) osip_list_get (sip->vias, 0); - - - osip_list_remove(sip->vias, 0); - locip=osip_strdup(osip_via_get_host(via)); - osip_via_free(via); -#ifdef SM -#else - eXosip_guess_ip_for_via(eXosip.ip_family, locip, 49); -#endif - if (eXosip.ip_family==AF_INET6) - snprintf(tmp, 256, "SIP/2.0/UDP [%s]:%s;branch=z9hG4bK%u", - locip, - eXosip.localport, - via_branch_new_random()); - else - snprintf(tmp, 256, "SIP/2.0/UDP %s:%s;rport;branch=z9hG4bK%u", - locip, - eXosip.localport, - via_branch_new_random()); - - if (eXosip.nat_type[0]) - { - strncat(tmp, ";xxx-nat-type=", 256); - strncat(tmp, eXosip.nat_type, 256); - } - - -#ifdef SM - osip_free(locip); -#endif - osip_via_init(&via); - osip_via_parse(via, tmp); - osip_list_add(sip->vias, via, 0); - osip_free(tmp); - - return 0; -} - -static eXosip_reg_t * -eXosip_reg_find(int rid) -{ - eXosip_reg_t *jr; - - for (jr = eXosip.j_reg; jr != NULL; jr = jr->next) - { - if (jr->r_id == rid) - { - return jr; - } - } - return NULL; -} - -int eXosip_register (int rid, int registration_period) -{ - osip_transaction_t *transaction; - osip_event_t *sipevent; - osip_message_t *reg; - eXosip_reg_t *jr; - int i; - - jr = eXosip_reg_find(rid); - if (jr==NULL) - { - /* fprintf(stderr, "eXosip: no registration info saved!\n"); */ - return -1; - } - if (registration_period>=0) - jr->r_reg_period = registration_period; - if (jr->r_reg_period==0) - {} /* unregistration */ - else if (jr->r_reg_period>3600) - jr->r_reg_period = 3600; - else if (jr->r_reg_period<200) /* too low */ - jr->r_reg_period = 200; - - reg = NULL; - if (jr->r_last_tr!=NULL) - { - if (jr->r_last_tr->state!=NICT_TERMINATED - && jr->r_last_tr->state!=NICT_COMPLETED) - { - /* fprintf(stderr, "eXosip: a registration is already pending!\n"); */ - return -1; - } - else - { - osip_message_t *last_response; - - reg = jr->r_last_tr->orig_request; - last_response = jr->r_last_tr->last_response; - - jr->r_last_tr->orig_request = NULL; - jr->r_last_tr->last_response = NULL; - __eXosip_delete_jinfo(jr->r_last_tr); - osip_transaction_free(jr->r_last_tr); - jr->r_last_tr = NULL; - - /* modify the REGISTER request */ - { - int osip_cseq_num = osip_atoi(reg->cseq->number); - int length = strlen(reg->cseq->number); - - - osip_authorization_t *aut; - osip_proxy_authorization_t *proxy_aut; - - aut = (osip_authorization_t *)osip_list_get(reg->authorizations, 0); - while (aut!=NULL) - { - osip_list_remove(reg->authorizations, 0); - osip_authorization_free(aut); - aut = (osip_authorization_t *)osip_list_get(reg->authorizations, 0); - } - - proxy_aut = (osip_proxy_authorization_t*)osip_list_get(reg->proxy_authorizations, 0); - while (proxy_aut!=NULL) - { - osip_list_remove(reg->proxy_authorizations, 0); - osip_proxy_authorization_free(proxy_aut); - proxy_aut = (osip_proxy_authorization_t*)osip_list_get(reg->proxy_authorizations, 0); - } - - - if (-1 == eXosip_update_top_via(reg)) - { - osip_message_free(reg); - return -1; - } - - osip_cseq_num++; - osip_free(reg->cseq->number); - reg->cseq->number = (char*)osip_malloc(length+2); /* +2 like for 9 to 10 */ - sprintf(reg->cseq->number, "%i", osip_cseq_num); - - { - osip_header_t *exp; - osip_message_header_get_byname(reg, "expires", 0, &exp); - osip_free(exp->hvalue); - exp->hvalue = (char*)osip_malloc(10); - snprintf(exp->hvalue, 9, "%i", jr->r_reg_period); - } - - osip_message_force_update(reg); - } - - if (last_response!=NULL) - { - if (MSG_IS_STATUS_4XX(last_response)) - { - eXosip_add_authentication_information(reg, last_response); - } - osip_message_free(last_response); - } - } - } - if (reg==NULL) - { - i = generating_register(®, jr->r_aor, jr->r_registrar, jr->r_contact, jr->r_reg_period); - if (i!=0) - { - /* fprintf(stderr, "eXosip: cannot register (cannot build REGISTER)! "); */ - return -2; - } - } - //!jinti! if exist outbound proxy setting ,register must use outboundproxy! - if (jr->r_route!=NULL) - { - osip_route_t *r=NULL; - osip_message_get_route(reg,0,&r); - if (r==NULL) - osip_message_set_route(reg, jr->r_route); - } - - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - reg); - if (i!=0) - { - /* TODO: release the j_call.. */ - - osip_message_free(reg); - return -2; - } - - jr->r_last_tr = transaction; - - /* send REGISTER */ - sipevent = osip_new_outgoing_sipmessage(reg); - sipevent->transactionid = transaction->transactionid; - osip_message_force_update(reg); - - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -int -eXosip_register_init(char *from, char *proxy, char *contact, char *route) -{ - eXosip_reg_t *jr; - int i; - - /* Avoid adding the same registration info twice to prevent mem leaks */ - for (jr = eXosip.j_reg; jr != NULL; jr = jr->next) - { - if (strcmp(jr->r_aor, from) == 0 - && strcmp(jr->r_registrar, proxy) == 0) - { - return jr->r_id; - } - } - - /* Add new registration info */ - i = eXosip_reg_init(&jr, from, proxy, contact, route); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot register! ")); - return i; - } - ADD_ELEMENT(eXosip.j_reg, jr); - return jr->r_id; -} - - -int eXosip_build_publish(osip_message_t **message, - char *to, - char *from, - char *route, - const char *event, - const char *expires, - const char *ctype, - const char *body) -{ - int i; - if (to==NULL || to[0]=='\0') - return -1; - if (from==NULL || from[0]=='\0') - return -1; - if (event==NULL || event[0]=='\0') - return -1; - if (ctype==NULL || ctype[0]=='\0') - { - if (body!=NULL && body[0]!='\0') - return -1; - } - else - { - if (body==NULL || body[0]=='\0') - return -1; - } - - i = generating_publish(message, to, from, route); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot send message (cannot build PUBLISH)! ")); - return -1; - } - - if (body!=NULL && body[0]!='\0' && ctype!=NULL && ctype[0]!='\0') - { - osip_message_set_content_type(*message, ctype); - osip_message_set_body(*message, body, strlen(body)); - osip_message_set_header(*message, "Content-Disposition", "render;handling=required"); - } - if (expires!=NULL && expires[0]!='\0') - osip_message_set_expires(*message, expires); - else - osip_message_set_expires(*message, "3600"); - - osip_message_set_header(*message, "Event", event); - return 0; -} - -int eXosip_publish (osip_message_t *message, const char *to) -{ - /* eXosip_call_t *jc; - osip_header_t *subject; */ - osip_transaction_t *transaction; - osip_event_t *sipevent; - int i; - eXosip_pub_t *pub=NULL; - - if (message==NULL) - return -1; - if (message->cseq==NULL||message->cseq->number==NULL) - return -1; - if (to==NULL) - { - osip_message_free(message); - return -1; - } - - i = _eXosip_pub_find_by_aor(&pub, to); - if (i!=0 || pub==NULL) - { - osip_header_t *expires; - osip_message_get_expires(message, 0, &expires); - if (expires==NULL || expires->hvalue==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: missing expires header in PUBLISH!")); - osip_message_free(message); - return -1; - } - else - { - /* start a new publication context */ - _eXosip_pub_init(&pub, to, expires->hvalue); - if (pub==NULL) return -1; - ADD_ELEMENT(eXosip.j_pub, pub); - } - } - else - { - if (pub->p_sip_etag!=NULL && pub->p_sip_etag[0]!='\0') - { - /* increase cseq */ - osip_message_set_header(message, "SIP-If-Match", pub->p_sip_etag); - } - - if (pub->p_last_tr!=NULL && pub->p_last_tr->cseq!=NULL - &&pub->p_last_tr->cseq->number!=NULL) - { - int osip_cseq_num = osip_atoi(pub->p_last_tr->cseq->number); - int length = strlen(pub->p_last_tr->cseq->number); - - osip_cseq_num++; - osip_free(message->cseq->number); - message->cseq->number = (char*)osip_malloc(length+2); /* +2 like for 9 to 10 */ - sprintf(message->cseq->number, "%i", osip_cseq_num); - } - } - - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - message); - if (i!=0) - { - osip_message_free(message); - return -1; - } - - if (pub->p_last_tr!=NULL) - osip_list_add(eXosip.j_transactions, pub->p_last_tr, 0); - pub->p_last_tr = transaction; - - sipevent = osip_new_outgoing_sipmessage(message); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, NULL, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_subscribe (char *to, char *from, char *route) -{ - eXosip_subscribe_t *js; - osip_message_t *subscribe; - osip_transaction_t *transaction; - osip_event_t *sipevent; - int i; - - i = generating_initial_subscribe(&subscribe, to, from, route); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot subscribe (cannot build SUBSCRIBE)! ")); - return -1; - } - - i = eXosip_subscribe_init(&js, to); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot subscribe.")); - return -1; - } - - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - subscribe); - if (i!=0) - { - osip_message_free(subscribe); - return -1; - } - - _eXosip_subscribe_set_refresh_interval(js, subscribe); - js->s_out_tr = transaction; - - sipevent = osip_new_outgoing_sipmessage(subscribe); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, NULL, js, NULL)); - osip_transaction_add_event(transaction, sipevent); - - ADD_ELEMENT(eXosip.j_subscribes, js); - eXosip_update(); /* fixed? */ - __eXosip_wakeup(); - return 0; -} - - -int eXosip_subscribe_refresh (int sid, char *expires) -{ - int i; - eXosip_dialog_t *jd = NULL; - eXosip_subscribe_t *js = NULL; - - if (sid>0) - { - eXosip_subscribe_dialog_find(sid, &js, &jd); - } - if (js==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No subscribe here?\n")); - return -1; - } - - if (jd==NULL) - { - osip_transaction_t *tr; - osip_transaction_t *newtr; - osip_message_t *sub; - osip_event_t *sipevent; - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No subscribe dialog here?\n")); - - tr=eXosip_find_last_out_subscribe(js,NULL); - if (tr==NULL){ - eXosip_trace(OSIP_INFO1,("eXosip_retry_last_sub: No such transaction.")); - return -1; - } - if (tr->last_response==NULL){ - eXosip_trace(OSIP_INFO1,("eXosip_retry_last_sub: transaction has not been answered.")); - return -1; - } - sub=eXosip_prepare_request_for_auth(tr->orig_request); - if (sub==NULL) return -1; - eXosip_add_authentication_information(sub,tr->last_response); - - if (expires==NULL) - osip_message_set_expires(sub, "3600"); - else - osip_message_set_expires(sub, expires); - - osip_message_force_update(sub); - i = osip_transaction_init(&newtr, - NICT, - eXosip.j_osip, - sub); - if (i!=0) - { - osip_message_free(sub); - return -1; - } - - if (jd!=NULL) - osip_list_add(jd->d_out_trs, newtr, 0); - else - { - js->s_out_tr = newtr; - /* remove old transaction */ - osip_list_add(eXosip.j_transactions, tr, 0); - } - - sipevent = osip_new_outgoing_sipmessage(sub); - - osip_transaction_set_your_instance(newtr, tr->your_instance); - osip_transaction_set_your_instance(tr, NULL); - osip_transaction_add_event(newtr, sipevent); - - eXosip_update(); /* fixed? */ - __eXosip_wakeup(); - return -1; - } - -#ifdef LOW_EXPIRE - if (expires==NULL) - i = eXosip_subscribe_send_subscribe(js, jd, "60"); - else - i = eXosip_subscribe_send_subscribe(js, jd, expires); -#else - if (expires==NULL) - i = eXosip_subscribe_send_subscribe(js, jd, "3600"); - else - i = eXosip_subscribe_send_subscribe(js, jd, expires); -#endif - return i; -} - -int eXosip_subscribe_close(int sid) -{ - int i; - eXosip_dialog_t *jd = NULL; - eXosip_subscribe_t *js = NULL; - - if (sid>0) - { - eXosip_subscribe_dialog_find(sid, &js, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No subscribe dialog here?\n")); - return -1; - } - - i = eXosip_subscribe_send_subscribe(js, jd, "0"); - return i; -} - -int eXosip_transfer_send_notify(int jid, int subscription_status, char *body) -{ - eXosip_dialog_t *jd = NULL; - eXosip_call_t *jc = NULL; - - if (jid>0) - { - eXosip_call_dialog_find(jid, &jc, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - if (jd==NULL || jd->d_dialog==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No established dialog!")); - return -1; - } - - return _eXosip_transfer_send_notify(jc, jd, subscription_status, body); -} - -int _eXosip_transfer_send_notify(eXosip_call_t *jc, - eXosip_dialog_t *jd, - int subscription_status, - char *body) -{ - osip_transaction_t *transaction; - osip_message_t *notify; - osip_event_t *sipevent; - int i; - char subscription_state[50]; - char *tmp; - - transaction = eXosip_find_last_inc_refer(jc, jd); - if (transaction==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No pending transfer!\n")); - return -1; - } - - transaction = eXosip_find_last_out_notify_for_refer(jc, jd); - if (transaction!=NULL) - { - if (transaction->state!=NICT_TERMINATED && - transaction->state!=NIST_TERMINATED) - return -1; - transaction=NULL; - } - - i = _eXosip_build_request_within_dialog(¬ify, "NOTIFY", jd->d_dialog, "UDP"); - if (i!=0) - return -2; - - if (subscription_status==EXOSIP_SUBCRSTATE_PENDING) - osip_strncpy(subscription_state, "pending;expires=", 16); - else if (subscription_status==EXOSIP_SUBCRSTATE_ACTIVE) - osip_strncpy(subscription_state, "active;expires=", 15); - else if (subscription_status==EXOSIP_SUBCRSTATE_TERMINATED) - { - int reason = NORESOURCE; - if (reason==DEACTIVATED) - osip_strncpy(subscription_state, "terminated;reason=deactivated", 29); - else if (reason==PROBATION) - osip_strncpy(subscription_state, "terminated;reason=probation", 27); - else if (reason==REJECTED) - osip_strncpy(subscription_state, "terminated;reason=rejected", 26); - else if (reason==TIMEOUT) - osip_strncpy(subscription_state, "terminated;reason=timeout", 25); - else if (reason==GIVEUP) - osip_strncpy(subscription_state, "terminated;reason=giveup", 24); - else if (reason==NORESOURCE) - osip_strncpy(subscription_state, "terminated;reason=noresource", 29); - } - tmp = subscription_state + strlen(subscription_state); - if (subscription_status!=EXOSIP_SUBCRSTATE_TERMINATED) - sprintf(tmp, "%i", 180); - osip_message_set_header(notify, "Subscription-State", - subscription_state); - - /* add a body */ - if (body!=NULL) - { - osip_message_set_body(notify, body, strlen(body)); - osip_message_set_content_type(notify, "message/sipfrag"); - } - - osip_message_set_header(notify, "Event", "refer"); - - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - notify); - if (i!=0) - { - osip_message_free(notify); - return -1; - } - - osip_list_add(jd->d_out_trs, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(notify); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(jc, jd, NULL, NULL)); - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_notify_send_notify(eXosip_notify_t *jn, - eXosip_dialog_t *jd, - int subscription_status, - int online_status) -{ - osip_transaction_t *transaction; - osip_message_t *notify; - osip_event_t *sipevent; - int i; - char subscription_state[50]; - char *tmp; - int now = time(NULL); - transaction = eXosip_find_last_out_notify(jn, jd); - if (transaction!=NULL) - { - if (transaction->state!=NICT_TERMINATED && - transaction->state!=NIST_TERMINATED) - return -1; - transaction=NULL; - } - -#ifndef SUPPORT_MSN - -#else - - /* DO NOT SEND ANY NOTIFY when the status - is not active (or terminated?) */ - if (subscription_status!=EXOSIP_SUBCRSTATE_ACTIVE - && subscription_status!=EXOSIP_SUBCRSTATE_TERMINATED) - { - /* set the new state anyway! */ - jn->n_online_status = online_status; - jn->n_ss_status = subscription_status; - return -1; - } - -#endif - - i = _eXosip_build_request_within_dialog(¬ify, "NOTIFY", jd->d_dialog, "UDP"); - if (i!=0) - return -2; - - jn->n_online_status = online_status; - jn->n_ss_status = subscription_status; - - /* add the notifications info */ - if (jn->n_ss_status==EXOSIP_SUBCRSTATE_UNKNOWN) - jn->n_online_status=EXOSIP_SUBCRSTATE_PENDING; - -#ifndef SUPPORT_MSN - if (jn->n_ss_status==EXOSIP_SUBCRSTATE_PENDING) - osip_strncpy(subscription_state, "pending;expires=", 16); - else if (jn->n_ss_status==EXOSIP_SUBCRSTATE_ACTIVE) - osip_strncpy(subscription_state, "active;expires=", 15); - else if (jn->n_ss_status==EXOSIP_SUBCRSTATE_TERMINATED) - { - if (jn->n_ss_reason==DEACTIVATED) - osip_strncpy(subscription_state, "terminated;reason=deactivated", 29); - else if (jn->n_ss_reason==PROBATION) - osip_strncpy(subscription_state, "terminated;reason=probation", 27); - else if (jn->n_ss_reason==REJECTED) - osip_strncpy(subscription_state, "terminated;reason=rejected", 26); - else if (jn->n_ss_reason==TIMEOUT) - osip_strncpy(subscription_state, "terminated;reason=timeout", 25); - else if (jn->n_ss_reason==GIVEUP) - osip_strncpy(subscription_state, "terminated;reason=giveup", 24); - else if (jn->n_ss_reason==NORESOURCE) - osip_strncpy(subscription_state, "terminated;reason=noresource", 29); - } - tmp = subscription_state + strlen(subscription_state); - if (jn->n_ss_status!=EXOSIP_SUBCRSTATE_TERMINATED) - sprintf(tmp, "%i", jn->n_ss_expires-now); - osip_message_set_header(notify, "Subscription-State", - subscription_state); -#endif - - /* add a body */ - i = _eXosip_notify_add_body(jn, notify); - if (i!=0) - { - - } - -#ifdef SUPPORT_MSN -#else - osip_message_set_header(notify, "Event", "presence"); -#endif - - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - notify); - if (i!=0) - { - /* TODO: release the j_call.. */ - osip_message_free(notify); - return -1; - } - - osip_list_add(jd->d_out_trs, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(notify); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, jd, NULL, jn)); - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - return 0; -} - -int eXosip_notify (int nid, int subscription_status, int online_status) -{ - int i; - eXosip_dialog_t *jd = NULL; - eXosip_notify_t *jn = NULL; - - if (nid>0) - { - eXosip_notify_dialog_find(nid, &jn, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No subscribe dialog here?\n")); - return -1; - } - - i = eXosip_notify_send_notify(jn, jd, subscription_status, online_status); - return i; -} - - -int eXosip_notify_accept_subscribe(int nid, int code, - int subscription_status, - int online_status) -{ - int i = 0; - eXosip_dialog_t *jd = NULL; - eXosip_notify_t *jn = NULL; - if (nid>0) - { - eXosip_notify_dialog_find(nid, &jn, &jd); - } - if (jd==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: No call here?\n")); - return -1; - } - if (code>100 && code<200) - { - eXosip_notify_answer_subscribe_1xx(jn, jd, code); - } - else if (code>199 && code<300) - { - eXosip_notify_answer_subscribe_2xx(jn, jd, code); - i = eXosip_notify(nid, subscription_status, online_status); - } - else if (code>300 && code<699) - { - eXosip_notify_answer_subscribe_3456xx(jn, jd, code); - } - else - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: wrong status code (101url!=NULL && a_from->url->username!=NULL ) - { - if (eXosip.j_firewall_ip[0]!='\0') - { - if (public_net) - { - if (eXosip.localport==NULL) - snprintf(contact, bufsize, "", a_from->url->username, - eXosip.j_firewall_ip); - else - snprintf(contact, bufsize, "", a_from->url->username, - eXosip.j_firewall_ip, - eXosip.localport); - } - else - { - if (eXosip.localport==NULL) - snprintf(contact, bufsize, "", a_from->url->username, - locip); - else - snprintf(contact, bufsize, "", a_from->url->username, - locip, - eXosip.localport); - } - } - else - { - if (eXosip.localport==NULL) - snprintf(contact, bufsize, "", a_from->url->username, - locip); - else - snprintf(contact, bufsize, "", a_from->url->username, - locip, - eXosip.localport); - } - - osip_from_free(a_from); - } -} - -void eXosip_set_answer_contact(const char *contacturl) -{ - osip_strncpy(eXosip.answer_contact, contacturl ? contacturl : "", sizeof(eXosip.answer_contact)-1); -} diff --git a/linphone/exosip/eXosip.h b/linphone/exosip/eXosip.h deleted file mode 100644 index d6881be5b..000000000 --- a/linphone/exosip/eXosip.h +++ /dev/null @@ -1,752 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#ifndef __EXOSIP_H__ -#define __EXOSIP_H__ - -#include -#include -#include - -/** - * @file eXosip.h - * @brief eXosip API - * - * eXosip is a high layer library for rfc3261: the SIP protocol. - * It has limited API and functionnalities to make it easy to use. - * If you need complexity in your SIP applications, you may prefer - * to use directly osip. - * - * eXosip capabilities: - * REGISTER to handle mobility. - * INVITE/BYE/OPTIONS to start/stop VoIP sessions. - * re-INVITE to modify VoIP sessions (On-hold/Off-hold) - * MESSAGE to send Instant Message. - * SUBSCRIBE/NOTIFY to handle presence capabilities. - * - *

- */ - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/** - * @defgroup eXosip eXosip Management - * @ingroup eXosip - * @{ - */ - -/** - * Use IPv6 instead of IPv4. - * - * @param ipv6_enable This paramter should be set to 1 to enable IPv6. - */ -void eXosip_enable_ipv6(int ipv6_enable); - -/** - * Initiate the eXtented oSIP library. - * - * @param input command input (RESERVED FOR FUTUR USE). - * @param output resulting output (RESERVED FOR FUTUR USE). - * @param port The SIP port to use. (5060 is the default) - */ -int eXosip_init(FILE *input, FILE *output, int port); - - -/** - * Force eXosip to use a specific local ip address in all its SIP message. - * - * @param localip the ip address. - * - * If set to NULL, then the local ip address will be guessed - * automatically (returns to default mode). - */ -int eXosip_force_localip(const char *localip); - -/** - * Release ressource used by the eXtented oSIP library. - * - */ -void eXosip_quit(void); - -/** - * Automatic refresh of subscription and register - * send subscribe refresh when subscription is close to expiration. - * send register refresh when registration is close to expiration. - * - */ -void eXosip_automatic_refresh(void); - -/** - * Wake Up the eXosip_event_wait method. - * - */ -void __eXosip_wakeup_event(void); - -/** - * This method is used to modify the sdp connection address - * When you are behind a NAT. (EXPERIMENTAL) - * - */ -void eXosip_set_firewallip(const char *firewall_address); - -/** - * This method is used to modify NAT firewall type - * When you are behind a NAT. (EXPERIMENTAL) - * @param nat type ("", "fcone", "rcone", "prcone", "sym") - */ -void eXosip_set_nattype(const char *nat_type); - -/** - * This method is used to force ALL SIP packets to go through given proxy - * @param proxyurl - when empty disable forced proxy behaviour - */ -void eXosip_force_proxy(const char *proxyurl); - -/** - * This method is used to set contact header on answers which establishes dialogs - * @param contacturl - the url to use for conatct SIP header, - * when empty - the contact header will be generated from 'to' - * header of the incoming request - */ -void eXosip_set_answer_contact(const char *contacturl); - -/** - * This method is used to build a contact header for SIP packets - * @param url url from wich username part will be extracted - * @param strbuf buffer where the result will be stored - * @param bufsize size of the 'strbuf' - * @param public_net when TRUE use firewall ip (if defined) as hostname part - * else use local host ip - * - */ -void eXosip_guess_contact_uri(const char *url, char *strbuf, int bufsize, int public_net); - -/** - * Find the current localip (interface with default route). - * ****DEPRECATED**** Use eXosip_guess_localip - * - * @param ip a string containing the local IP address. - */ -void eXosip_get_localip(char *ip); - -/** - * Find the current localip (interface with default route). - * - * @param family AF_INET or AF_INET6 - * @param address a string containing the local IP address. - * @param size The size of the string - */ -int eXosip_guess_localip(int family, char *address, int size); - -/** - * Find the interface to be used to reach the specified host. - * - * @param ip a string containing the local IP address. - * @param localip the local ip address to be used to reach host. - * - * You usually don't need this function at all. - */ -void eXosip_get_localip_for(char *host, char **localip); - -/** - * Add authentication credentials. These are used when an outgoing - * request comes back with an authorization required response. - * - * @param username username - * @param userid not sure what this is for - * @param passwd password - * @param ha1 currently ignored - * @param realm realm within which credentials apply, or NULL - * to apply credentials to unrecognized realms - */ -int eXosip_add_authentication_info(const char *username, const char *userid, - const char *passwd, const char *ha1, - const char *realm); - -/** - * Clear all authentication credentials stored in eXosip. - * - */ -int eXosip_clear_authentication_info(void); - -/** - * Remove an audio payload. - * - */ -void eXosip_sdp_negotiation_remove_audio_payloads(void); - -/** - * Remove an audio payload. - * - * @param payload The payload - * @param number_of_port The number of port - * @param proto The protocol - * @param c_nettype The connection type of network - * @param c_addrtype The connection type of address - * @param c_addr The connection address - * @param c_addr_multicast_ttl The multicast TTL value - * @param c_addr_multicast_int ? - * @param a_rtpmap The rtpmap of element. - */ -void eXosip_sdp_negotiation_add_codec(char *payload, char *number_of_port, - char *proto, char *c_nettype, - char *c_addrtype, char *c_addr, - char *c_addr_multicast_ttl, - char *c_addr_multicast_int, - char *a_rtpmap); - -/** - * Replace the internal SDP negociator facility. - * - * @param sn The new negociator context - */ -int eXosip_sdp_negotiation_replace(osip_negotiation_t *sn); - -struct eXosip_call_t; - -/** - * Set the reference element to be used in callback for the negociator. - * This must be done only if eXosip_sdp_negotiation_replace has been - * used and must not be done if this method has not been used. - * - * @param jc The related call. - * @param sn The new negociator context. - */ -void eXosip_sdp_negotiation_ctx_set_mycontext(struct eXosip_call_t *jc, void *arg); - -#define DEFAULT_MODE 2 -#define CALLBACK_MODE 1 -#define EVENT_MODE 2 -/** - * Set the functionnal mode of eXosip. - * The default mode is the EVENT_MODE. - * - * @param mode mode to use. - */ -void eXosip_set_mode(int mode); - -/** - * Set the SIP User-Agent: header string. - */ -void eXosip_set_user_agent(const char *user_agent); - -/** - * Lock the eXtented oSIP library. - * - */ -int eXosip_lock(void); - -/** - * UnLock the eXtented oSIP library. - * - */ -int eXosip_unlock(void); - -/** @} */ - -/** - * @defgroup eXosip_call eXosip Call Management - * @ingroup eXosip - * @{ - */ - -/** - * Build a default INVITE message for a new call. - * - * @param invite Pointer for the SIP element to hold. - * @param to SIP url for callee. - * @param from SIP url for caller. - * @param route Route header for INVITE. (optionnal) - * @param subject Subject for the call. - */ -int eXosip_build_initial_invite(osip_message_t **invite, char *to, - char *from, char *route, char *subject); -/** - * Initiate a call. - * - * @param invite SIP INVITE message to send. - * @param reference Application context. (optionnal) - * @param sdp_reference_context Sdp Application context. (optionnal) - * @param local_sdp_port The port to be used for this call. - */ -int eXosip_initiate_call (osip_message_t *invite, void *reference, - void *sdp_context_reference, char *local_sdp_port); - -/** - * Initiate a call with the specified body-type and body - * - * @param invite SIP INVITE message to send. - * @param body_type body type (ex: "application/sdp") - * @param body The body. - */ -int eXosip_initiate_call_with_body (osip_message_t *invite, const char *body_type, const char *body, void *reference); - - -/** - * When a call failed to initiate due to authorization reasons (407), retry the call using the authentication information - * previously stored in eXosip using eXosip_add_authentication_info() - * - * @param cid The eXosip call id as returned by eXosip_initiate_call*() - */ -int eXosip_retry_call (int cid); - -/** - * Initiate a blind transfer outside of a call. - * (probably not supported by many softphone...) - * - * @param refer_to SIP url for transfer. - * @param from SIP url for caller. - * @param to SIP url for callee. - * @param route Route header for REFER. (optionnal) - */ - int eXosip_transfer_call_out_of_dialog(char *refer_to, char *from, char *to, char *route); - -/** - * Set redirection url before a call to eXosip_answer_call. - * - * @param jid dialog id of call. - * @param contact contact address. - */ - int eXosip_set_redirection_address (int jid, char *contact); - -/** - * Answer call. - * - * @param jid dialog id of call. - * @param status Status code to use. - */ -int eXosip_answer_call (int jid, int status, char *local_sdp_port); - -/** - * Answer call. - * - * @param jid dialog id of call. - * @param status Status code to use. - * @param answer The resulting sip answer to send. - */ -int eXosip2_answer (int jid, int status, osip_message_t **answer); - -/** - * Answer call. - * - * @param jid dialog id of call. - * @param answer The sip answer to send. - */ -int eXosip2_answer_send(int jid, osip_message_t *answer); - -/** - * Answer call with the specified body. - * - * @param jid dialog id of call. - * @param status Status code to use. - * @param body_type body type (ex: "application/sdp") - * @param body The body. - */ -int eXosip_answer_call_with_body (int jid, int status,const char *body_type, const char*body); - - -/** - * Retreive payload negotiated for this dialog - * - * @param jid dialog id of call. - * @param payload will hold the negotited payload code - * @param payload_name will hold negotioated payload mime string - * @param pnsize size of the payload_name buffer - */ -int eXosip_retrieve_negotiated_payload(int jid, int *payload, char *payload_name, int pnsize); - -/** - * Set a new application context for an existing call - * - * @param jc Pointer to the call to modify - * @param reference New application context. - */ -int eXosip_set_call_reference(int jid, void *reference); - -/** - * Put a call on hold. - * - * @param jid dialog id of call. - */ -int eXosip_on_hold_call (int jid); -int eXosip_off_hold_call (int jid, char *rtp_ip, int port); - -/** - * Tranfer a call. - * - * @param jid dialog id of call. - * @param refer_to SIP Url for transfer. - */ -int eXosip_transfer_call(int jid, char *refer_to); - -/** - * Tranfer a call. - * - * @param jid dialog id of call. - * @param refer_to SIP Url for transfer. - */ -int eXosip_transfer_send_notify(int jid, int subscription_status, char *body); - -/** - * Terminate a call. - * - * @param cid call id of call. - * @param jid dialog id of call. - */ -int eXosip_terminate_call(int cid, int jid); - -/** - * Send an OPTIONS message within a call. - * - * @param cid call id of call. - * @param jid dialog id of call. - */ -int eXosip_options_call (int jid); - -/** - * Send an INFO message within a call. - * - * @param jid dialog id of call. - * @param content_type content-type of body. - * @param body body to attach. - */ -int eXosip_info_call(int jid, char *content_type, char *body); - -/** - * Answer an OPTIONS message. - * - * @param cid call id of call. - * @param jid dialog id of call. - */ -int eXosip_answer_options(int cid, int jid, int status); - -/** @} */ - -/** - * @defgroup eXosip_registration eXosip Registration Management - * @ingroup eXosip - * @{ - */ - -/** - * Send initial registration to a server. (REGISTER request) - * - * @param from SIP url for caller. - * @param proxy Proxy used for registration. - * @param contact Contact address. (optionnal) - * @param route Outbound proxy address. (optionnal) - */ -int eXosip_register_init (char *from, char *proxy, char *contact, char* route); - -/** - * Update the registration. (REGISTER request) - * - * @param rid . - * @param expires The expires value for registration. - */ -int eXosip_register (int rid, int expires); - -/** @} */ - -/** - * @defgroup eXosip_impp eXosip Instant Messaging and Presence Management - * @ingroup eXosip - * @{ - */ - -/** - * Send an Instant Message (MESSAGE request). - * - * @param rid . - */ -int eXosip_message (char *to, char *from, char *route, char *buff); - -/** - * build publication for a user. (PUBLISH request) - * - * @param message returned published request. - * @param to SIP url for callee. - * @param from SIP url for caller. - * @param route Route used for publication. - * @param event SIP Event header. - * @param expires SIP Expires header. - * @param ctype Content-Type of body. - * @param body body for publication. - */ -int eXosip_build_publish(osip_message_t **message, - char *to, - char *from, - char *route, - const char *event, - const char *expires, - const char *ctype, - const char *body); - -/** - * Send an Publication Message (PUBLISH request). - * - * @param message is a ready to be sent publish message . - * @param sip_if_match is the SIP-If-Match header. (NULL for initial publication) - */ -int eXosip_publish (osip_message_t *message, const char *sip_if_match); - -/** - * Send initial subscription to a user. (SUBSCRIBE request) - * - * @param to SIP url for callee. - * @param from SIP url for caller. - * @param route Route used for registration. - */ -int eXosip_subscribe(char *to, char *from, char *route); - -/** - * Update a subscription (SUBSCRIBE request). - * - * @param sid id of subscription. - * @param expires Time between updates. - */ -int eXosip_subscribe_refresh(int sid, char *expires); - -/** - * Close a subscription (SUBSCRIBE request). - * - * @param sid id of subscription. - */ -int eXosip_subscribe_close(int sid); - -typedef enum eXosip_ss { - EXOSIP_SUBCRSTATE_UNKNOWN, - EXOSIP_SUBCRSTATE_PENDING, - EXOSIP_SUBCRSTATE_ACTIVE, - EXOSIP_SUBCRSTATE_TERMINATED -} eXosip_ss_t; - -typedef enum eXosip_ss_reason { - DEACTIVATED, - PROBATION, - REJECTED, - TIMEOUT, - GIVEUP, - NORESOURCE -} eXosip_ss_reason_t; - - /* typo error */ -#define NORESSOURCE NORESOURCE - -typedef enum eXosip_ss_status { - EXOSIP_NOTIFY_UNKNOWN, - EXOSIP_NOTIFY_PENDING, /* subscription not yet accepted */ - EXOSIP_NOTIFY_ONLINE, - EXOSIP_NOTIFY_BUSY, - EXOSIP_NOTIFY_BERIGHTBACK, - EXOSIP_NOTIFY_AWAY, - EXOSIP_NOTIFY_ONTHEPHONE, - EXOSIP_NOTIFY_OUTTOLUNCH, - EXOSIP_NOTIFY_CLOSED -} eXosip_ss_status_t; - -/** - * Accept a subscription and notify state (NOTIFY request). - * - * @param nid call id of call. - * @param code code for answer to subscribe. - * @param subscription_status subscription status. - * @param online_status online status to send. - */ -int eXosip_notify_accept_subscribe (int nid, int code, int subscription_status, int online_status); - -/** - * Update a subscription and notify state (NOTIFY request). - * - * @param nid call id of call. - * @param subscription_status subscription status. - * @param online_status online status to send. - */ -int eXosip_notify(int nid, int subscription_status, int online_status); - -/** @} */ - - -int eXosip_send_ack(int did); - -/** - * @defgroup eXosip_event eXosip event Management - * @ingroup eXosip - * @{ - */ -typedef enum eXosip_event_type_t { - - /* Registration Info */ - EXOSIP_REGISTRATION_NEW, /* announce new registration. */ - EXOSIP_REGISTRATION_SUCCESS, /* user is successfully registred. */ - EXOSIP_REGISTRATION_FAILURE, /* user is not registred. */ - EXOSIP_REGISTRATION_REFRESHED, /* registration has been refreshed. */ - EXOSIP_REGISTRATION_TERMINATED, /* UA is not registred any more. */ - - /* for UAC events */ - EXOSIP_CALL_NOANSWER, /* announce no answer within the timeout */ - EXOSIP_CALL_PROCEEDING, /* announce processing by a remote app */ - EXOSIP_CALL_RINGING, /* announce ringback */ - EXOSIP_CALL_ANSWERED, /* announce start of call */ - EXOSIP_CALL_REDIRECTED, /* announce a redirection */ - EXOSIP_CALL_REQUESTFAILURE, /* announce a request failure */ - EXOSIP_CALL_SERVERFAILURE, /* announce a server failure */ - EXOSIP_CALL_GLOBALFAILURE, /* announce a global failure */ - - /* for UAS events */ - EXOSIP_CALL_NEW, /* announce a new call */ - EXOSIP_CALL_ACK, /* ACK received for 200ok to INVITE */ - EXOSIP_CALL_CANCELLED, /* announce that call has been cancelled */ - EXOSIP_CALL_TIMEOUT, /* announce that call has failed */ - EXOSIP_CALL_HOLD, /* audio must be stopped */ - EXOSIP_CALL_OFFHOLD, /* audio must be restarted */ - EXOSIP_CALL_CLOSED, /* a BYE was received for this call */ - - /* for both UAS & UAC events */ - EXOSIP_CALL_STARTAUDIO, /* audio must be established */ - EXOSIP_CALL_RELEASED, /* call context is cleared. */ - - /* for UAC events */ - EXOSIP_OPTIONS_NOANSWER, /* announce no answer within the timeout */ - EXOSIP_OPTIONS_PROCEEDING, /* announce processing by a remote app */ - EXOSIP_OPTIONS_ANSWERED, /* announce a 200ok */ - EXOSIP_OPTIONS_REDIRECTED, /* announce a redirection */ - EXOSIP_OPTIONS_REQUESTFAILURE, /* announce a request failure */ - EXOSIP_OPTIONS_SERVERFAILURE, /* announce a server failure */ - EXOSIP_OPTIONS_GLOBALFAILURE, /* announce a global failure */ - - EXOSIP_INFO_NOANSWER, /* announce no answer within the timeout */ - EXOSIP_INFO_PROCEEDING, /* announce processing by a remote app */ - EXOSIP_INFO_ANSWERED, /* announce a 200ok */ - EXOSIP_INFO_REDIRECTED, /* announce a redirection */ - EXOSIP_INFO_REQUESTFAILURE, /* announce a request failure */ - EXOSIP_INFO_SERVERFAILURE, /* announce a server failure */ - EXOSIP_INFO_GLOBALFAILURE, /* announce a global failure */ - - /* for UAS events */ - EXOSIP_OPTIONS_NEW, /* announce a new options method */ - EXOSIP_INFO_NEW, /* new info request received */ - - EXOSIP_MESSAGE_NEW, /* announce new incoming MESSAGE. */ - EXOSIP_MESSAGE_SUCCESS, /* announce a 200ok to a previous sent */ - EXOSIP_MESSAGE_FAILURE, /* announce a failure. */ - - /* Presence and Instant Messaging */ - EXOSIP_SUBSCRIPTION_NEW, /* announce new incoming SUBSCRIBE. */ - EXOSIP_SUBSCRIPTION_UPDATE, /* announce incoming SUBSCRIBE. */ - EXOSIP_SUBSCRIPTION_CLOSED, /* announce end of subscription. */ - - EXOSIP_SUBSCRIPTION_NOANSWER, /* announce no answer */ - EXOSIP_SUBSCRIPTION_PROCEEDING, /* announce a 1xx */ - EXOSIP_SUBSCRIPTION_ANSWERED, /* announce a 200ok */ - EXOSIP_SUBSCRIPTION_REDIRECTED, /* announce a redirection */ - EXOSIP_SUBSCRIPTION_REQUESTFAILURE, /* announce a request failure */ - EXOSIP_SUBSCRIPTION_SERVERFAILURE, /* announce a server failure */ - EXOSIP_SUBSCRIPTION_GLOBALFAILURE, /* announce a global failure */ - EXOSIP_SUBSCRIPTION_NOTIFY, /* announce new NOTIFY request */ - - EXOSIP_SUBSCRIPTION_RELEASED, /* call context is cleared. */ - - EXOSIP_IN_SUBSCRIPTION_NEW, /* announce new incoming SUBSCRIBE.*/ - EXOSIP_IN_SUBSCRIPTION_RELEASED, /* announce end of subscription. */ - - EXOSIP_CALL_REFERED, /* announce incoming REFER */ - EXOSIP_CALL_REFER_STATUS, /* announce incoming NOTIFY */ - - EXOSIP_CALLBACK_COUNT -} eXosip_event_type_t; - -typedef struct eXosip_event { - eXosip_event_type_t type; - void *external_reference; - char reason_phrase[50]; - int status_code; - - char textinfo[256]; - char req_uri[256]; - char local_uri[256]; - char remote_uri[256]; - char remote_contact[256]; - char refer_to[256]; - char subject[256]; - osip_content_type_t *i_ctt; - osip_list_t *i_bodies; - - char remote_sdp_audio_ip[50]; - int remote_sdp_audio_port; - int local_sdp_audio_port; - int payload; - char payload_name[50]; - char sdp_body[1000]; /* The whole SDP body */ - int online_status; - int ss_status; - int ss_reason; - - /* For a high level usage of the eXosip stack? (API is enough?) */ - int did; - int cid; - int rid; - int sid; - int nid; - - /* For a low level usage of the eXosip stack */ - struct eXosip_dialog_t *jd; - struct eXosip_call_t *jc; - struct eXosip_reg_t *jr; - struct eXosip_subscribe_t *js; - struct eXosip_notify_t *jn; - -} eXosip_event_t; - -/** - * Free ressource in an eXosip event. - * - * @param je event to work on. - */ -void eXosip_event_free(eXosip_event_t *je); - -/** - * Wait for an eXosip event. (FUTURE USE) - * - * @param tv_s timeout value (seconds). - * @param tv_ms timeout value (mseconds). - */ -eXosip_event_t *eXosip_event_wait(int tv_s, int tv_ms); - - -/** - * Wait for next eXosip event. - * - */ -eXosip_event_t *eXosip_event_get(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/linphone/exosip/eXosip2.h b/linphone/exosip/eXosip2.h deleted file mode 100644 index 5f3f32163..000000000 --- a/linphone/exosip/eXosip2.h +++ /dev/null @@ -1,510 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#ifndef __EXOSIP2_H__ -#define __EXOSIP2_H__ - -#ifdef WIN32 -#include -#include -#include -#include -#define snprintf _snprintf -#define close(s) closesocket(s) -#else -#include -#include -#include -#include -#include -#endif - -#include - -#include -#include -#include - -#include -#include - -#include "jpipe.h" - -#ifndef JD_EMPTY - -#define JD_EMPTY 0 -#define JD_INITIALIZED 1 -#define JD_TRYING 2 -#define JD_QUEUED 3 -#define JD_RINGING 4 -#define JD_ESTABLISHED 5 -#define JD_REDIRECTED 6 -#define JD_AUTH_REQUIRED 7 -#define JD_CLIENTERROR 8 -#define JD_SERVERERROR 9 -#define JD_GLOBALFAILURE 10 -#define JD_TERMINATED 11 - -#define JD_MAX 11 - -#endif - -#define EXOSIP_VERSION "0.1" - -#ifdef __cplusplus -extern "C" -{ -#endif - -void eXosip_update(void); -void __eXosip_wakeup(void); - -typedef struct eXosip_dialog_t eXosip_dialog_t; - -struct eXosip_dialog_t { - - int d_id; - int d_STATE; - osip_dialog_t *d_dialog; /* active dialog */ - - int d_timer; - osip_message_t *d_200Ok; - osip_message_t *d_ack; - osip_list_t *media_lines; - - osip_list_t *d_inc_trs; - osip_list_t *d_out_trs; - - /* struct _BodyHandler *d_bh; */ - - eXosip_dialog_t *next; - eXosip_dialog_t *parent; -}; - -typedef struct eXosip_subscribe_t eXosip_subscribe_t; - -struct eXosip_subscribe_t { - - int s_id; - char s_uri[255]; - int s_online_status; - int s_ss_status; - int s_ss_reason; - int s_ss_expires; - eXosip_dialog_t *s_dialogs; - - osip_transaction_t *s_inc_tr; - osip_transaction_t *s_out_tr; - - eXosip_subscribe_t *next; - eXosip_subscribe_t *parent; -}; - -typedef struct eXosip_notify_t eXosip_notify_t; - -struct eXosip_notify_t { - - int n_id; - char n_uri[255]; - int n_online_status; - char *n_contact_info; - - int n_ss_status; - int n_ss_reason; - int n_ss_expires; - eXosip_dialog_t *n_dialogs; - - osip_transaction_t *n_inc_tr; - osip_transaction_t *n_out_tr; - - eXosip_notify_t *next; - eXosip_notify_t *parent; -}; - -typedef struct eXosip_call_t eXosip_call_t; - -struct eXosip_call_t { - - int c_id; - char c_subject[100]; - int c_ack_sdp; /* flag for alternative SDP offer-response model */ - eXosip_dialog_t *c_dialogs; - osip_transaction_t *c_inc_tr; - osip_transaction_t *c_out_tr; - osip_transaction_t *c_inc_options_tr; - osip_transaction_t *c_out_options_tr; - void *external_reference; - - osip_negotiation_ctx_t *c_ctx; - char c_sdp_port[10]; - - char c_redirection[1024]; /* contact for 3xx answers */ - - eXosip_call_t *next; - eXosip_call_t *parent; -}; - - -#if 0 -typedef struct eXosip_realm_t eXosip_realm_t; - -struct eXosip_realm_t { - - int r_id; - - char *r_realm; - char *r_username; - char *r_passwd; - - eXosip_realm_t *next; - eXosip_realm_t *parent; -}; -#endif - -typedef struct eXosip_reg_t eXosip_reg_t; - -struct eXosip_reg_t { - - int r_id; - - int r_reg_period; /* delay between registration */ - char *r_aor; /* sip identity */ - char *r_registrar; /* registrar */ - char *r_route; /* outbound proxy */ -#if 0 - eXosip_realm_t *r_realms; /* list of realms */ -#endif - char *r_contact; /* list of contacts string */ - - osip_transaction_t *r_last_tr; - eXosip_reg_t *next; - eXosip_reg_t *parent; -}; - - -typedef struct eXosip_pub_t eXosip_pub_t; - -struct eXosip_pub_t { - int p_id; - - time_t p_expires; /* expiration date (started+period) */ - int p_period; /* delay between registration */ - char p_aor[256]; /* sip identity */ - char p_sip_etag[64]; /* sip_etag from 200ok */ - - osip_transaction_t *p_last_tr; - eXosip_pub_t *next; - eXosip_pub_t *parent; -}; - -int _eXosip_pub_update(eXosip_pub_t **pub, osip_transaction_t *tr, osip_message_t *answer); -int _eXosip_pub_find_by_aor(eXosip_pub_t **pub, const char *aor); -int _eXosip_pub_init(eXosip_pub_t **pub, const char *aor, const char *exp); -void _eXosip_pub_free(eXosip_pub_t *pub); - -typedef struct jauthinfo_t jauthinfo_t; - -struct jauthinfo_t { - char username[50]; - char userid[50]; - char passwd[50]; - char ha1[50]; - char realm[50]; - jauthinfo_t *parent; - jauthinfo_t *next; -}; - -int -__eXosip_create_authorization_header(osip_message_t *previous_answer, - const char *rquri, const char *username, - const char *passwd, - osip_authorization_t **auth); -int -__eXosip_create_proxy_authorization_header(osip_message_t *previous_answer, - const char *rquri, - const char *username, - const char *passwd, - osip_proxy_authorization_t **auth); - - -eXosip_event_t *eXosip_event_init_for_call(int type, eXosip_call_t *jc, - eXosip_dialog_t *jd); -int eXosip_event_add_sdp_info(eXosip_event_t *je, osip_message_t *message); - -int eXosip_event_add_status(eXosip_event_t *je, osip_message_t *response); -eXosip_event_t *eXosip_event_init_for_subscribe(int type, - eXosip_subscribe_t *js, - eXosip_dialog_t *jd); -eXosip_event_t *eXosip_event_init_for_notify(int type, eXosip_notify_t *jn, - eXosip_dialog_t *jd); -eXosip_event_t *eXosip_event_init_for_reg(int type, eXosip_reg_t *jr); -eXosip_event_t *eXosip_event_init_for_message(int type, osip_transaction_t - *tr, osip_message_t *sip); -int eXosip_event_init(eXosip_event_t **je, int type); -eXosip_call_t *eXosip_event_get_callinfo(eXosip_event_t *je); -eXosip_dialog_t *eXosip_event_get_dialoginfo(eXosip_event_t *je); -eXosip_reg_t *eXosip_event_get_reginfo(eXosip_event_t *je); -eXosip_notify_t *eXosip_event_get_notifyinfo(eXosip_event_t *je); -eXosip_subscribe_t *eXosip_event_get_subscribeinfo(eXosip_event_t *je); -int eXosip_event_add(eXosip_event_t *je); -eXosip_event_t *eXosip_event_wait(int tv_s, int tv_ms); -eXosip_event_t *eXosip_event_get(void); - -typedef void (* eXosip_callback_t) (int type, eXosip_event_t *); - -char *strdup_printf(const char *fmt, ...); - -jfriend_t *jfriend_get(void); -jsubscriber_t *jsubscriber_get(void); -jidentity_t *jidentity_get(void); -int jfriend_get_and_set_next_token (char **dest, char *buf, - char **next); - -#define eXosip_trace(loglevel,args) do \ -{ \ - char *__strmsg; \ - __strmsg=strdup_printf args ; \ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,(loglevel),NULL,"%s\n",__strmsg)); \ - osip_free (__strmsg); \ -}while (0); - -typedef struct eXosip_t eXosip_t; - -struct eXosip_t { - int forced_localip; /* set to 1 when we must always use the default local ip */ - char *localip; /* default local ip */ - char *localport; - - char *user_agent; - - FILE *j_input; - FILE *j_output; - eXosip_call_t *j_calls; /* my calls */ - eXosip_subscribe_t *j_subscribes; /* my friends */ - eXosip_notify_t *j_notifies; /* my susbscribers */ - osip_list_t *j_transactions; - - eXosip_reg_t *j_reg; /* my registrations */ - eXosip_pub_t *j_pub; /* my publications */ - - void *j_cond; - void *j_mutexlock; - - osip_t *j_osip; - int j_socket; - int j_stop_ua; - void *j_thread; - jpipe_t *j_socketctl; - jpipe_t *j_socketctl_event; - - jsubscriber_t *j_subscribers; - jfriend_t *j_friends; - jidentity_t *j_identitys; - - int j_runtime_mode; - eXosip_callback_t j_call_callbacks[EXOSIP_CALLBACK_COUNT]; - osip_fifo_t *j_events; - - osip_negotiation_t *osip_negotiation; - char j_firewall_ip[50]; - jauthinfo_t *authinfos; - - int ip_family; /* AF_INET6 or AF_INET */ - char nat_type[16]; - char forced_proxy[256]; - char answer_contact[256]; /* conatact header value to use in answers */ -}; - -typedef struct jinfo_t jinfo_t; - -struct jinfo_t { - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - eXosip_notify_t *jn; -}; - -int eXosip_guess_ip_for_via (int family, char *address, int size); - -int eXosip_sdp_negotiation_init(osip_negotiation_t **sn); -void eXosip_sdp_negotiation_free(osip_negotiation_t *sn); -int eXosip_retrieve_sdp_negotiation_result(osip_negotiation_ctx_t *ctx, char *payload_name, int pnsize); - - -sdp_message_t *eXosip_get_local_sdp_info(osip_transaction_t *invite_tr); -sdp_message_t *eXosip_get_remote_sdp_info(osip_transaction_t *invite_tr); -sdp_message_t *eXosip_get_local_sdp(osip_transaction_t *transaction); -sdp_message_t *eXosip_get_remote_sdp(osip_transaction_t *transaction); - - - -int eXosip_set_callbacks(osip_t *osip); -char *osip_call_id_new_random(void); -char *osip_to_tag_new_random(void); -char *osip_from_tag_new_random(void); -unsigned int via_branch_new_random(void); -void __eXosip_delete_jinfo(osip_transaction_t *transaction); -jinfo_t *__eXosip_new_jinfo(eXosip_call_t *jc, eXosip_dialog_t *jd, - eXosip_subscribe_t *js, eXosip_notify_t *jn); - -int eXosip_dialog_init_as_uac(eXosip_dialog_t **jd, osip_message_t *_200Ok); -int eXosip_dialog_init_as_uas(eXosip_dialog_t **jd, osip_message_t *_invite, osip_message_t *_200Ok); -void eXosip_dialog_free(eXosip_dialog_t *jd); -void eXosip_dialog_set_state(eXosip_dialog_t *jd, int state); -void eXosip_delete_early_dialog(eXosip_dialog_t *jd); - - -struct __eXosip_sockaddr { - u_char ss_len; - u_char ss_family; - u_char padding[128 - 2]; -}; -int eXosip_get_addrinfo (struct addrinfo **addrinfo, - char *hostname, int service); -int isrfc1918(char *ipaddr); -void eXosip_get_localip_from_via(osip_message_t *,char**localip); -int generating_initial_subscribe(osip_message_t **message, char *to, - char *from, char *route); -int generating_message(osip_message_t **message, char *to, char *from, - char *route, char *buff); -int generating_publish(osip_message_t **message, char *to, char *from, - char *route); -int generating_cancel(osip_message_t **dest, osip_message_t *request_cancelled); -int generating_options_within_dialog(osip_message_t **info, osip_dialog_t *dialog); -int generating_info_within_dialog(osip_message_t **info, osip_dialog_t *dialog); -int generating_bye(osip_message_t **bye, osip_dialog_t *dialog); -int generating_refer(osip_message_t **refer, osip_dialog_t *dialog, char *refer_to); -int generating_refer_outside_dialog(osip_message_t **refer, char *refer_to, char *from, char *to, char *proxy); -int generating_invite_on_hold(osip_message_t **invite, osip_dialog_t *dialog, - char *subject, char *sdp); -int generating_invite_off_hold(osip_message_t **invite, osip_dialog_t *dialog, - char *subject, char *sdp); -int generating_options(osip_message_t **options, char *from, char *to, char *proxy); -int generating_ack_for_2xx(osip_message_t **ack, osip_dialog_t *dialog); -int generating_info(osip_message_t **info, char *from, char *to, char *proxy); - -int _eXosip_reg_find(eXosip_reg_t **reg, osip_transaction_t *tr); -int eXosip_reg_init(eXosip_reg_t **jr, char *from, char *proxy, char *contact, char* route); -void eXosip_reg_free(eXosip_reg_t *jreg); -int generating_register(osip_message_t **reg, char *transport, char *from, char *proxy, int expires); -char *generating_sdp_answer(osip_message_t *request, osip_negotiation_ctx_t *context); - -int eXosip_call_dialog_find(int jid, eXosip_call_t **jc, eXosip_dialog_t **jd); -int eXosip_notify_dialog_find(int nid, eXosip_notify_t **jn, eXosip_dialog_t **jd); -int eXosip_subscribe_dialog_find(int nid, eXosip_subscribe_t **js, eXosip_dialog_t **jd); -int eXosip_call_find(int cid, eXosip_call_t **jc); -int eXosip_dialog_set_200ok(eXosip_dialog_t *_jd, osip_message_t *_200Ok); - -int _eXosip2_answer_invite_3456xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code, osip_message_t **answer); -int _eXosip2_answer_invite_2xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code, osip_message_t **answer); -int _eXosip2_answer_invite_1xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code, osip_message_t **answer); -int eXosip_answer_invite_1xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code); -int eXosip_answer_invite_2xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code, char *local_sdp_port); -int eXosip_answer_invite_2xx_with_body(eXosip_call_t *jc, eXosip_dialog_t *jd, int code,const char*, const char*); -int eXosip_answer_invite_3456xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code); -int eXosip_answer_options_1xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code); -int eXosip_answer_options_2xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code); -int eXosip_answer_options_3456xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code); -void eXosip_notify_answer_subscribe_1xx(eXosip_notify_t *jc, - eXosip_dialog_t *jd, int code); -void eXosip_notify_answer_subscribe_2xx(eXosip_notify_t *jn, - eXosip_dialog_t *jd, int code); -void eXosip_notify_answer_subscribe_3456xx(eXosip_notify_t *jn, - eXosip_dialog_t *jd, int code); - -int eXosip_build_response_default(int jid, int status); -int _eXosip_build_response_default(osip_message_t **dest, osip_dialog_t *dialog, - int status, osip_message_t *request); -int complete_answer_that_establish_a_dialog(osip_message_t *response, osip_message_t *request); -int _eXosip_build_request_within_dialog(osip_message_t **dest, char *method_name, - osip_dialog_t *dialog, char *transport); -int eXosip_build_initial_options(osip_message_t **options, char *to, char *from, - char *route); - -void eXosip_kill_transaction(osip_list_t * transactions); -int eXosip_remove_transaction_from_call(osip_transaction_t *tr, eXosip_call_t *jc); -osip_transaction_t *eXosip_find_last_inc_notify(eXosip_subscribe_t *jn, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_out_notify(eXosip_notify_t *jn, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_inc_subscribe(eXosip_notify_t *jn, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_out_subscribe(eXosip_subscribe_t *js, eXosip_dialog_t *jd ); - -osip_transaction_t *eXosip_find_last_out_options(eXosip_call_t *jc, eXosip_dialog_t *jd ); -osip_transaction_t *eXosip_find_last_inc_options(eXosip_call_t *jc, eXosip_dialog_t *jd ); -osip_transaction_t *eXosip_find_last_options(eXosip_call_t *jc, eXosip_dialog_t *jd ); -osip_transaction_t *eXosip_find_last_out_info(eXosip_call_t *jc, eXosip_dialog_t *jd ); -osip_transaction_t *eXosip_find_last_inc_info(eXosip_call_t *jc, eXosip_dialog_t *jd ); -osip_transaction_t *eXosip_find_last_info(eXosip_call_t *jc, eXosip_dialog_t *jd ); -osip_transaction_t *eXosip_find_last_invite(eXosip_call_t *jc, eXosip_dialog_t *jd ); -osip_transaction_t *eXosip_find_last_inc_invite(eXosip_call_t *jc, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_out_invite(eXosip_call_t *jc, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_refer(eXosip_call_t *jc, eXosip_dialog_t *jd ); -osip_transaction_t *eXosip_find_last_inc_notify_for_refer(eXosip_call_t *jc, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_out_notify_for_refer(eXosip_call_t *jc, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_inc_bye(eXosip_call_t *jc, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_out_bye(eXosip_call_t *jc, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_inc_refer(eXosip_call_t *jc, eXosip_dialog_t *jd); -osip_transaction_t *eXosip_find_last_out_refer(eXosip_call_t *jc, eXosip_dialog_t *jd); - - -int eXosip_call_init(eXosip_call_t **jc); -void eXosip_call_free(eXosip_call_t *jc); -void __eXosip_call_remove_dialog_reference_in_call(eXosip_call_t *jc, eXosip_dialog_t *jd); -void eXosip_call_set_subject(eXosip_call_t *jc, char *subject); -int eXosip_read_message(int max_message_nb, int sec_max, int usec_max); -void eXosip_release_terminated_calls ( void ); - - -int eXosip_subscribe_init(eXosip_subscribe_t **js, char *uri); -void eXosip_subscribe_free(eXosip_subscribe_t *js); -int _eXosip_subscribe_set_refresh_interval(eXosip_subscribe_t *js, osip_message_t *inc_subscribe); -int eXosip_subscribe_need_refresh(eXosip_subscribe_t *js, int now); -int eXosip_subscribe_send_subscribe(eXosip_subscribe_t *js, - eXosip_dialog_t *jd, const char *expires); - -int eXosip_notify_init(eXosip_notify_t **jn, osip_message_t *inc_subscribe); -void eXosip_notify_free(eXosip_notify_t *jn); -int _eXosip_notify_set_contact_info(eXosip_notify_t *jn, char *uri); -int _eXosip_notify_set_refresh_interval(eXosip_notify_t *jn, - osip_message_t *inc_subscribe); -void _eXosip_notify_add_expires_in_2XX_for_subscribe(eXosip_notify_t *jn, - osip_message_t *answer); -int _eXosip_notify_add_body(eXosip_notify_t *jn, osip_message_t *notify); -int eXosip_notify_add_allowed_subscriber(char *sip_url); -int _eXosip_notify_is_a_known_subscriber(osip_message_t *sip); -int eXosip_notify_send_notify(eXosip_notify_t *jn, eXosip_dialog_t *jd, - int subsciption_status, - int online_status); -int _eXosip_transfer_send_notify(eXosip_call_t *jc, - eXosip_dialog_t *jd, - int subscription_status, - char *body); - - -int eXosip_is_public_address(const char *addr); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/linphone/exosip/eXosip_cfg.h b/linphone/exosip/eXosip_cfg.h deleted file mode 100644 index b6a24f68f..000000000 --- a/linphone/exosip/eXosip_cfg.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#ifndef __EXOSIP_CFG_H__ -#define __EXOSIP_CFG_H__ - -/** - * @defgroup eXosip_cfg eXosip Configuration Management - * @ingroup eXosip - * @{ - */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef struct jfriend_t jfriend_t; - -struct jfriend_t { - int f_id; - char *f_nick; - char *f_home; - char *f_work; - char *f_email; - char *f_e164; - - jfriend_t *next; - jfriend_t *parent; -}; - -typedef struct jidentity_t jidentity_t; - -struct jidentity_t { - int i_id; - char *i_identity; - char *i_registrar; - char *i_realm; - char *i_userid; - char *i_pwd; - - jidentity_t *next; - jidentity_t *parent; -}; - -typedef struct jsubscriber_t jsubscriber_t; - -struct jsubscriber_t { - int s_id; - char *s_nick; - char *s_uri; - char *s_allow; - - jsubscriber_t *next; - jsubscriber_t *parent; -}; - -jfriend_t *jfriend_get(void); -void jfriend_remove(jfriend_t *fr); - -jsubscriber_t *jsubscriber_get(void); -jidentity_t *jidentity_get(void); - -int jfriend_load(void); -void jfriend_unload(void); -void jfriend_add(char *nickname, char *home, - char *work, char *email, char *e164); -char *jfriend_get_home(int fid); - -int jsubscriber_load(void); -void jsubscriber_unload(void); -void subscribers_add(char *nickname, char *uri, int black_list); -char *jsubscriber_get_uri(int fid); - -int jidentity_load(void); -void jidentity_unload(void); -void identitys_add(char *identity, char *registrar, char *realm, - char *userid, char *password); -char *jidentity_get_identity(int fid); -char *jidentity_get_registrar(int fid); - -#define REMOVE_ELEMENT(first_element, element) \ - if (element->parent==NULL) \ - { first_element = element->next; \ - if (first_element!=NULL) \ - first_element->parent = NULL; } \ - else \ - { element->parent->next = element->next; \ - if (element->next!=NULL) \ - element->next->parent = element->parent; \ - element->next = NULL; \ - element->parent = NULL; } - -#define ADD_ELEMENT(first_element, element) \ - if (first_element==NULL) \ - { \ - first_element = element; \ - element->next = NULL; \ - element->parent = NULL; \ - } \ - else \ - { \ - element->next = first_element; \ - element->parent = NULL; \ - element->next->parent = element; \ - first_element = element; \ - } - -#define APPEND_ELEMENT(type_of_element_t, first_element, element) \ - if (first_element==NULL) \ - { first_element = element; \ - element->next = NULL; /* useless */ \ - element->parent = NULL; /* useless */ } \ - else \ - { type_of_element_t *f; \ - for (f=first_element; f->next!=NULL; f=f->next) \ - { } \ - f->next = element; \ - element->parent = f; \ - element->next = NULL; \ - } - -#ifdef __cplusplus -} -#endif - -/** @} */ - -#endif diff --git a/linphone/exosip/eXutils.c b/linphone/exosip/eXutils.c deleted file mode 100644 index 9a7a52aab..000000000 --- a/linphone/exosip/eXutils.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include -#include "eXosip2.h" - -extern eXosip_t eXosip; - -#ifdef WIN32 -/* You need the Platform SDK to compile this. */ -#include - -#else /* sun, *BSD, linux, and other? */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#endif - -int -eXosip_guess_ip_for_via (int family, char *address, int size){ - char *res=NULL; - if (family==AF_INET6) - eXosip_get_localip_for("2001:638:500:101:2e0:81ff:fe24:37c6",&res); - else - eXosip_get_localip_for("15.128.128.93",&res); - strncpy(address,res,size); - osip_free(res); - return 0; -} - - - -#ifdef SM - -void eXosip_get_localip_from_via(osip_message_t *mesg,char **locip){ - osip_via_t *via=NULL; - char *host; - via=(osip_via_t*)osip_list_get(mesg->vias,0); - if (via==NULL) { - host="15.128.128.93"; - eXosip_trace(OSIP_ERROR,("Could not get via:%s")); - }else host=via->host; - eXosip_get_localip_for(host,locip); - -} -#endif - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 1024 -#endif - -void eXosip_get_localip_for(char *address_to_reach,char **loc){ - int err,tmp; - struct addrinfo hints; - struct addrinfo *res=NULL,*res0=NULL; - struct sockaddr_storage addr; - int sock; -#ifdef __APPLE_CC__ - int s; -#else - socklen_t s; -#endif - - if (eXosip.forced_localip){ - *loc=osip_strdup(eXosip.localip); - return; - } - - *loc=osip_malloc(MAXHOSTNAMELEN); - if (eXosip.ip_family==AF_INET) - strcpy(*loc,"127.0.0.1"); /* always fallback to local loopback */ - else strcpy(*loc,"::1"); - - memset(&hints,0,sizeof(hints)); - hints.ai_family=(eXosip.ip_family==AF_INET) ? PF_INET:PF_INET6; - hints.ai_socktype=SOCK_DGRAM; - /*hints.ai_flags=AI_NUMERICHOST|AI_CANONNAME;*/ - err=getaddrinfo(address_to_reach,"5060",&hints,&res0); - if (err!=0){ - eXosip_trace(OSIP_ERROR,("Error in getaddrinfo for %s: %s\n",address_to_reach,gai_strerror(err))); - return ; - } - if (res0==NULL){ - eXosip_trace(OSIP_ERROR,("getaddrinfo reported nothing !")); - abort(); - return ; - } - for (res=res0;res!=NULL;res=res->ai_next){ - sock=socket(res->ai_family,SOCK_DGRAM,0); - tmp=1; - err=setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof(int)); - if (err<0){ - eXosip_trace(OSIP_ERROR,("Error in setsockopt: %s\n",strerror(errno))); - abort(); - return ; - } - err=connect(sock,res->ai_addr,res->ai_addrlen); - if (err<0) { - eXosip_trace(OSIP_ERROR,("Error in connect: %s\n",strerror(errno))); - close(sock); - sock=-1; - continue; - }else break; - } - freeaddrinfo(res0); - if (sock==-1){ - eXosip_trace(OSIP_WARNING,("Could not find interface to reach %s\n",address_to_reach)); - return; - } - res0=NULL; - res=NULL; - s=sizeof(addr); - err=getsockname(sock,(struct sockaddr*)&addr,&s); - if (err!=0) { - eXosip_trace(OSIP_ERROR,("Error in getsockname: %s\n",strerror(errno))); - close(sock); - return ; - } - - err=getnameinfo((struct sockaddr *)&addr,s,*loc,MAXHOSTNAMELEN,NULL,0,NI_NUMERICHOST); - if (err!=0){ - eXosip_trace(OSIP_ERROR,("getnameinfo error:%s ; while finding local address for %s",strerror(errno), address_to_reach)); - abort(); - return ; - } - close(sock); - eXosip_trace(OSIP_INFO1,("Outgoing interface to reach %s is %s.\n",address_to_reach,*loc)); - return ; -} - -char *strdup_printf(const char *fmt, ...) -{ - /* Guess we need no more than 100 bytes. */ - int n, size = 100; - char *p; - va_list ap; - if ((p = osip_malloc (size)) == NULL) - return NULL; - while (1) - { - /* Try to print in the allocated space. */ - va_start (ap, fmt); -#ifdef WIN32 - n = _vsnprintf (p, size, fmt, ap); -#else - n = vsnprintf (p, size, fmt, ap); -#endif - va_end (ap); - /* If that worked, return the string. */ - if (n > -1 && n < size) - return p; - /* Else try again with more space. */ - if (n > -1) /* glibc 2.1 */ - size = n + 1; /* precisely what is needed */ - else /* glibc 2.0 */ - size *= 2; /* twice the old size */ - if ((p = realloc (p, size)) == NULL) - return NULL; - } -} - -int -eXosip_get_addrinfo (struct addrinfo **addrinfo, char *hostname, int service) -{ -#ifndef WIN32 - struct in_addr addr; - struct in6_addr addrv6; -#else - unsigned long int one_inet_addr; -#endif - struct addrinfo hints; - int error; - char portbuf[10]; - if (service!=0) - snprintf(portbuf, sizeof(portbuf), "%i", service); - - memset (&hints, 0, sizeof (hints)); -#ifndef WIN32 - if (inet_pton(AF_INET, hostname, &addr)>0) - { - /* ipv4 address detected */ - hints.ai_flags = AI_NUMERICHOST; - hints.ai_family = PF_INET; - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "IPv4 address detected: %s\n", hostname)); - } - else if (inet_pton(AF_INET6, hostname, &addrv6)>0) - { - /* ipv6 address detected */ - /* Do the resolution anyway */ - hints.ai_flags = AI_CANONNAME; - hints.ai_family = PF_INET6; - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "IPv6 address detected: %s\n", hostname)); - } - else - { - /* hostname must be resolved */ - hints.ai_flags = 0; - hints.ai_family = (eXosip.ip_family==AF_INET) ? PF_INET:PF_INET6; - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "Not an IPv4 or IPv6 address: %s\n", hostname)); - } -#else - if ((int)(one_inet_addr = inet_addr(hostname)) == -1) - hints.ai_flags = AI_CANONNAME; - else - hints.ai_flags = AI_NUMERICHOST; - -#ifdef IPV6_SUPPORT - hints.ai_family = PF_UNSPEC; /* ipv6 support */ -#else - hints.ai_family = PF_INET; /* ipv4 only support */ -#endif - -#endif - - hints.ai_socktype = SOCK_DGRAM; - hints.ai_protocol = IPPROTO_UDP; - if (service==0) - { - error = getaddrinfo (hostname, "sip", &hints, addrinfo); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "SRV resolution with udp-sip-%s\n", hostname)); - } - else - { - error = getaddrinfo (hostname, portbuf, &hints, addrinfo); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "DNS resolution with %s:%i\n", hostname, service)); - } - if (error || *addrinfo == NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "getaddrinfo failure. %s:%s (%s)\n", hostname, portbuf, gai_strerror(error))); - return -1; - } - - return 0; -} diff --git a/linphone/exosip/exosip.dev b/linphone/exosip/exosip.dev deleted file mode 100755 index c90fb628d..000000000 --- a/linphone/exosip/exosip.dev +++ /dev/null @@ -1,289 +0,0 @@ -[Project] -FileName=exosip.dev -Name=exosip -UnitCount=24 -Type=2 -Ver=1 -ObjFiles= -Includes=. -Libs= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Compiler=-D_WIN32_WINNT=0x501_@@_-DSM_@@_-g_@@_ -CppCompiler= -Linker= -IsCpp=0 -Icon= -ExeOutput= -ObjectOutput= -OverrideOutput=1 -OverrideOutputName=libexosip.a -HostApplication= -Folders= -CommandLine= -UseCustomMakefile=0 -CustomMakefile= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=0000000000000000000000 - -[Unit1] -FileName=udp.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] -FileName=eXosip2.h -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit3] -FileName=eXosip.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit4] -FileName=eXosip.h -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit5] -FileName=eXosip_cfg.h -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit6] -FileName=eXutils.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit7] -FileName=jauth.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit8] -FileName=jcall.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit9] -FileName=jcallback.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit10] -FileName=jdialog.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit11] -FileName=jevents.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit12] -FileName=jfreinds.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit13] -FileName=jidentity.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit14] -FileName=jnotify.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit15] -FileName=jpipe.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit16] -FileName=jpipe.h -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit17] -FileName=jpublish.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit18] -FileName=jreg.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit19] -FileName=jrequest.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit20] -FileName=jresponse.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit21] -FileName=jsubscribe.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit22] -FileName=jsubscribers.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit23] -FileName=misc.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit24] -FileName=sdp_offans.c -CompileCpp=0 -Folder=exosip -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion= -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename= -ProductName= -ProductVersion= -AutoIncBuildNr=0 - diff --git a/linphone/exosip/jauth.c b/linphone/exosip/jauth.c deleted file mode 100644 index 6a81d8f4c..000000000 --- a/linphone/exosip/jauth.c +++ /dev/null @@ -1,453 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" -#include -#include - -#include -#include - -/* #include */ -#include - -/* TAKEN from rcf2617.txt */ - -#define HASHLEN 16 -typedef char HASH[HASHLEN]; -#define HASHHEXLEN 32 -typedef char HASHHEX[HASHHEXLEN+1]; -#define IN -#define OUT - -extern eXosip_t eXosip; - -/* Private functions */ -static void CvtHex(IN HASH Bin, OUT HASHHEX Hex); -static void DigestCalcHA1(IN const char * pszAlg, IN const char * pszUserName, - IN const char * pszRealm, IN const char * pszPassword, - IN const char * pszNonce, IN const char * pszCNonce, - OUT HASHHEX SessionKey); -static void DigestCalcResponse(IN HASHHEX HA1, - IN const char * pszNonce, - IN const char * pszNonceCount, - IN const char * pszCNonce, - IN const char * pszQop, - IN const char * pszMethod, - IN const char * pszDigestUri, - IN HASHHEX HEntity, OUT HASHHEX Response); - -static void CvtHex(IN HASH Bin, - OUT HASHHEX Hex) -{ - unsigned short i; - unsigned char j; - - for (i = 0; i < HASHLEN; i++) { - j = (Bin[i] >> 4) & 0xf; - if (j <= 9) - Hex[i*2] = (j + '0'); - else - Hex[i*2] = (j + 'a' - 10); - j = Bin[i] & 0xf; - if (j <= 9) - Hex[i*2+1] = (j + '0'); - else - Hex[i*2+1] = (j + 'a' - 10); - }; - Hex[HASHHEXLEN] = '\0'; -} - -/* calculate H(A1) as per spec */ -static void DigestCalcHA1(IN const char * pszAlg, - IN const char * pszUserName, - IN const char * pszRealm, - IN const char * pszPassword, - IN const char * pszNonce, - IN const char * pszCNonce, - OUT HASHHEX SessionKey) -{ - MD5_CTX Md5Ctx; - HASH HA1; - - MD5Init(&Md5Ctx); - MD5Update(&Md5Ctx, (unsigned char *)pszUserName, strlen(pszUserName)); - MD5Update(&Md5Ctx, (unsigned char *)":", 1); - MD5Update(&Md5Ctx, (unsigned char *)pszRealm, strlen(pszRealm)); - MD5Update(&Md5Ctx, (unsigned char *)":", 1); - MD5Update(&Md5Ctx, (unsigned char *)pszPassword, strlen(pszPassword)); - MD5Final((unsigned char *)HA1, &Md5Ctx); - if ((pszAlg!=NULL)&&osip_strcasecmp(pszAlg, "md5-sess") == 0) - { - MD5Init(&Md5Ctx); - MD5Update(&Md5Ctx, (unsigned char *)HA1, HASHLEN); - MD5Update(&Md5Ctx, (unsigned char *)":", 1); - MD5Update(&Md5Ctx, (unsigned char *)pszNonce, strlen(pszNonce)); - MD5Update(&Md5Ctx, (unsigned char *)":", 1); - MD5Update(&Md5Ctx, (unsigned char *)pszCNonce, strlen(pszCNonce)); - MD5Final((unsigned char *)HA1, &Md5Ctx); - } - CvtHex(HA1, SessionKey); -} - -/* calculate request-digest/response-digest as per HTTP Digest spec */ -static void DigestCalcResponse(IN HASHHEX HA1, /* H(A1) */ - IN const char * pszNonce, /* nonce from server */ - IN const char * pszNonceCount,/* 8 hex digits */ - IN const char * pszCNonce, /* client nonce */ - IN const char * pszQop, /* qop-value: "", "auth", "auth-int" */ - IN const char * pszMethod, /* method from the request */ - IN const char * pszDigestUri, /* requested URL */ - IN HASHHEX HEntity, /* H(entity body) if qop="auth-int" */ - OUT HASHHEX Response /* request-digest or response-digest */) -{ - MD5_CTX Md5Ctx; - HASH HA2; - HASH RespHash; - HASHHEX HA2Hex; - - int auth_int_flag = 0; - - /* calculate H(A2) */ - MD5Init(&Md5Ctx); - MD5Update(&Md5Ctx, (unsigned char *)pszMethod, strlen(pszMethod)); - MD5Update(&Md5Ctx, (unsigned char *)":", 1); - MD5Update(&Md5Ctx, (unsigned char *)pszDigestUri, strlen(pszDigestUri)); - - if (pszQop!=NULL) - { - char *index = strchr(pszQop,'i'); - while (index!=NULL&&index-pszQop>=5&&strlen(index)>=3) - { - if (osip_strncasecmp(index-5, "auth-int",8) == 0) - { - auth_int_flag = 1; - goto auth_withqop; - } - index = strchr(index+1,'i'); - } - - index = strchr(pszQop,'a'); - while (index!=NULL&&strlen(index)>=4) - { - if (osip_strncasecmp(index, "auth",4) == 0) - { - /* and in the case of a unknown token - like auth1. It is not auth, but this - implementation will think it is!?? - This is may not happen but it's a bug! - */ - goto auth_withqop; - } - index = strchr(index+1,'a'); - } - goto auth_withoutqop; - } - - auth_withoutqop: - MD5Final((unsigned char*)HA2, &Md5Ctx); - CvtHex(HA2, HA2Hex); - - /* calculate response */ - MD5Init(&Md5Ctx); - MD5Update(&Md5Ctx, (unsigned char*)HA1, HASHHEXLEN); - MD5Update(&Md5Ctx, (unsigned char*)":", 1); - MD5Update(&Md5Ctx, (unsigned char*)pszNonce, strlen(pszNonce)); - MD5Update(&Md5Ctx, (unsigned char*)":", 1); - - goto end; - - auth_withqop: - - if (auth_int_flag) - { - MD5Update(&Md5Ctx, (unsigned char*)":", 1); - MD5Update(&Md5Ctx, (unsigned char*)HEntity, HASHHEXLEN); - } - - MD5Final((unsigned char*)HA2, &Md5Ctx); - CvtHex(HA2, HA2Hex); - - /* calculate response */ - MD5Init(&Md5Ctx); - MD5Update(&Md5Ctx, (unsigned char*)HA1, HASHHEXLEN); - MD5Update(&Md5Ctx, (unsigned char*)":", 1); - MD5Update(&Md5Ctx, (unsigned char*)pszNonce, strlen(pszNonce)); - MD5Update(&Md5Ctx, (unsigned char*)":", 1); - MD5Update(&Md5Ctx, (unsigned char*)pszNonceCount, strlen(pszNonceCount)); - MD5Update(&Md5Ctx, (unsigned char*)":", 1); - MD5Update(&Md5Ctx, (unsigned char*)pszCNonce, strlen(pszCNonce)); - MD5Update(&Md5Ctx, (unsigned char*)":", 1); - MD5Update(&Md5Ctx, (unsigned char*)pszQop, strlen(pszQop)); - MD5Update(&Md5Ctx, (unsigned char*)":", 1); - - end: - MD5Update(&Md5Ctx, (unsigned char*)HA2Hex, HASHHEXLEN); - MD5Final((unsigned char*)RespHash, &Md5Ctx); - CvtHex(RespHash, Response); -} - - -int -__eXosip_create_authorization_header(osip_message_t *previous_answer, - const char *rquri, const char *username, - const char *passwd, - osip_authorization_t **auth) -{ - static int nc = 1; - - osip_authorization_t *aut; - osip_www_authenticate_t *wa=NULL; - - osip_message_get_www_authenticate(previous_answer,0,&wa); - - /* make some test */ - if (passwd==NULL) - return -1; - if (wa==NULL||wa->auth_type==NULL - ||(wa->realm==NULL)||(wa->nonce==NULL)) { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "www_authenticate header is not acceptable.\n")); - return -1; - } - if (0!=osip_strcasecmp("Digest",wa->auth_type)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "Authentication method not supported. (Digest only).\n")); - return -1; - } - /* "MD5" is invalid, but some servers use it. */ - if (wa->algorithm!=NULL&&0!=osip_strcasecmp("MD5",wa->algorithm)&&0!=osip_strcasecmp("\"MD5\"",wa->algorithm)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "Authentication method not supported. (Digest only).\n")); - return -1; - } - if (0!=osip_authorization_init(&aut)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "allocation with authorization_init failed.\n")); - return -1; - } - - /* just copy some feilds from response to new request */ - osip_authorization_set_auth_type(aut,osip_strdup("Digest")); - osip_authorization_set_realm(aut,osip_strdup(osip_www_authenticate_get_realm(wa))); - osip_authorization_set_nonce(aut,osip_strdup(osip_www_authenticate_get_nonce(wa))); - if (osip_www_authenticate_get_opaque(wa)!=NULL) - osip_authorization_set_opaque(aut,osip_strdup(osip_www_authenticate_get_opaque(wa))); - /* copy the username field in new request */ - aut->username = osip_malloc(strlen(username)+3); - sprintf(aut->username,"\"%s\"",username); - - { - char *tmp = osip_malloc(strlen(rquri)+3); - sprintf(tmp,"\"%s\"",rquri); - osip_authorization_set_uri(aut,tmp); - } - - osip_authorization_set_algorithm(aut,osip_strdup("MD5")); - - { - char * pszNonce = osip_strdup_without_quote(osip_www_authenticate_get_nonce(wa)); - char * pszCNonce = osip_strdup_without_quote("abcdefghi"); - char * pszUser = osip_strdup_without_quote(username); - char * pszRealm = osip_strdup_without_quote(osip_authorization_get_realm(aut)); - const char * pszPass=NULL; - char * pszAlg = osip_strdup("MD5"); - char *szNonceCount = NULL; - char * pszMethod = osip_strdup_without_quote(previous_answer->cseq->method); - char * pszQop = NULL; - char * pszURI = osip_strdup_without_quote(rquri); - - szNonceCount = osip_strdup("00000000"); - sprintf(szNonceCount, "%08d", nc++); - - HASHHEX HA1; - HASHHEX HA2 = ""; - HASHHEX Response; - - pszPass=passwd; - - if (osip_www_authenticate_get_qop_options(wa)!=NULL) - { - pszQop = osip_strdup_without_quote(osip_www_authenticate_get_qop_options(wa)); - - osip_authorization_set_message_qop(aut,osip_strdup(pszQop)); - osip_authorization_set_nonce_count(aut,osip_strdup(szNonceCount)); - osip_authorization_set_cnonce(aut,osip_strdup("\"abcdefghi\"")); - osip_authorization_set_algorithm(aut,osip_strdup(pszAlg)); - } - - DigestCalcHA1(pszAlg, pszUser, pszRealm, pszPass, pszNonce, - pszCNonce, HA1); - DigestCalcResponse(HA1, pszNonce, szNonceCount, pszCNonce, pszQop, - pszMethod, pszURI, HA2, Response); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO4, NULL, - "Response in authorization |%s|\n", Response)); - { - char *resp = osip_malloc(35); - sprintf(resp,"\"%s\"",Response); - osip_authorization_set_response(aut,resp); - } - osip_free(pszAlg); /* xkd, 2004-5-13*/ - osip_free(pszNonce); - osip_free(pszCNonce); - osip_free(pszRealm); - osip_free(pszQop); - osip_free(szNonceCount); - osip_free(pszUser); - osip_free(pszMethod); - osip_free(pszURI); - } - - *auth = aut; - return 0; -} - -int -__eXosip_create_proxy_authorization_header(osip_message_t *previous_answer, - const char *rquri, - const char *username, - const char *passwd, - osip_proxy_authorization_t **auth) -{ - osip_proxy_authorization_t *aut; - osip_proxy_authenticate_t *wa; - - osip_message_get_proxy_authenticate(previous_answer,0,&wa); - - /* make some test */ - if (passwd==NULL) - return -1; - if (wa==NULL||wa->auth_type==NULL - ||(wa->realm==NULL)||(wa->nonce==NULL)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "www_authenticate header is not acceptable.\n")); - return -1; - } - if (0!=osip_strcasecmp("Digest",wa->auth_type)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "Authentication method not supported. (Digest only).\n")); - return -1; - } - /* "MD5" is invalid, but some servers use it. */ - if (wa->algorithm!=NULL&&0!=osip_strcasecmp("MD5",wa->algorithm)&&0!=osip_strcasecmp("\"MD5\"",wa->algorithm)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "Authentication method not supported. (MD5 Digest only).\n")); - return -1; - } - if (0!=osip_proxy_authorization_init(&aut)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "allocation with authorization_init failed.\n")); - return -1; - } - - /* just copy some feilds from response to new request */ - osip_proxy_authorization_set_auth_type(aut,osip_strdup("Digest")); - osip_proxy_authorization_set_realm(aut,osip_strdup(osip_proxy_authenticate_get_realm(wa))); - osip_proxy_authorization_set_nonce(aut,osip_strdup(osip_proxy_authenticate_get_nonce(wa))); - if (osip_proxy_authenticate_get_opaque(wa)!=NULL) - osip_proxy_authorization_set_opaque(aut,osip_strdup(osip_proxy_authenticate_get_opaque(wa))); - /* copy the username field in new request */ - aut->username = osip_malloc(strlen(username)+3); - sprintf(aut->username,"\"%s\"",username); - - { - char *tmp = osip_malloc(strlen(rquri)+3); - sprintf(tmp,"\"%s\"",rquri); - osip_proxy_authorization_set_uri(aut,tmp); - } - osip_proxy_authorization_set_algorithm(aut,osip_strdup("MD5")); - - { - char * pszNonce = NULL; - char * pszCNonce= NULL ; - const char * pszUser = username; - char * pszRealm = osip_strdup_without_quote(osip_proxy_authorization_get_realm(aut)); - const char * pszPass = NULL; - char * pszAlg = osip_strdup("MD5"); - char *szNonceCount = NULL; - char * pszMethod = previous_answer->cseq->method; - char * pszQop = NULL; - const char * pszURI = rquri; - - HASHHEX HA1; - HASHHEX HA2 = ""; - HASHHEX Response; - - pszPass=passwd; - - if (osip_www_authenticate_get_nonce(wa)==NULL) - return -1; - pszNonce = osip_strdup_without_quote(osip_www_authenticate_get_nonce(wa)); - - /* should upgrade szNonceCount */ - /* should add szNonceCount in aut*/ - /* should upgrade pszCNonce */ - /* should add pszCNonce in aut */ - - if (osip_proxy_authenticate_get_qop_options(wa)!=NULL) - { - szNonceCount = osip_strdup("00000001"); - /* MUST be incremented on each */ - pszQop = osip_strdup(osip_proxy_authenticate_get_qop_options(wa)); - pszCNonce = osip_strdup("234abcc436e2667097e7fe6eia53e8dd"); - } - DigestCalcHA1(pszAlg, pszUser, pszRealm, pszPass, pszNonce, - pszCNonce, HA1); - DigestCalcResponse(HA1, pszNonce, szNonceCount, pszCNonce, pszQop, - pszMethod, pszURI, HA2, Response); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO4, NULL, - "Response in proxy_authorization |%s|\n", Response)); - { - char *resp = osip_malloc(35); - sprintf(resp,"\"%s\"",Response); - osip_proxy_authorization_set_response(aut,resp); - } - osip_free(pszAlg); /* xkd, 2004-5-13*/ - osip_free(pszNonce); - osip_free(pszCNonce); - osip_free(pszRealm); - osip_free(pszQop); - osip_free(szNonceCount); - } - - *auth = aut; - return 0; -} diff --git a/linphone/exosip/jcall.c b/linphone/exosip/jcall.c deleted file mode 100644 index 65eae08a9..000000000 --- a/linphone/exosip/jcall.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - - -#include "eXosip2.h" -#include - -extern eXosip_t eXosip; - -int eXosip_call_find(int cid, eXosip_call_t **jc) -{ - for (*jc=eXosip.j_calls; *jc!=NULL; *jc=(*jc)->next) - { - if ((*jc)->c_id==cid) - { - return 0; - } - } - *jc = NULL; - return -1; -} - -int -eXosip_call_init(eXosip_call_t **jc) -{ - *jc = (eXosip_call_t *)osip_malloc(sizeof(eXosip_call_t)); - if (*jc == NULL) return -1; - memset(*jc, 0, sizeof(eXosip_call_t)); - - (*jc)->c_id = -1; /* make sure the eXosip_update will assign a valid id to the call */ - osip_negotiation_ctx_init(&(*jc)->c_ctx); - return 0; -} - -void -__eXosip_call_remove_dialog_reference_in_call(eXosip_call_t *jc, eXosip_dialog_t *jd) -{ - eXosip_dialog_t *_jd; - jinfo_t *ji; - if (jc==NULL) return; - if (jd==NULL) return; - - - for (_jd = jc->c_dialogs; _jd!=NULL; _jd=jc->c_dialogs) - { - if (jd==_jd) - break; - } - if (_jd==NULL) - { - /* dialog not found??? */ - } - - ji = osip_transaction_get_your_instance(jc->c_inc_tr); - if (ji!=NULL && ji->jd==jd) - ji->jd=NULL; - ji = osip_transaction_get_your_instance(jc->c_out_tr); - if (ji!=NULL && ji->jd==jd) - ji->jd=NULL; -} - -void -eXosip_call_free(eXosip_call_t *jc) -{ - /* ... */ - - eXosip_dialog_t *jd; - - for (jd = jc->c_dialogs; jd!=NULL; jd=jc->c_dialogs) - { - REMOVE_ELEMENT(jc->c_dialogs, jd); - eXosip_dialog_free(jd); - } - - __eXosip_delete_jinfo(jc->c_inc_tr); - __eXosip_delete_jinfo(jc->c_out_tr); - if (jc->c_inc_tr!=NULL) - osip_list_add(eXosip.j_transactions, jc->c_inc_tr, 0); - if (jc->c_out_tr!=NULL) - osip_list_add(eXosip.j_transactions, jc->c_out_tr, 0); - - __eXosip_delete_jinfo(jc->c_inc_options_tr); - __eXosip_delete_jinfo(jc->c_out_options_tr); - if (jc->c_inc_options_tr!=NULL) - osip_list_add(eXosip.j_transactions, jc->c_inc_options_tr, 0); - if (jc->c_out_options_tr!=NULL) - osip_list_add(eXosip.j_transactions, jc->c_out_options_tr, 0); - - - osip_negotiation_ctx_free(jc->c_ctx); - osip_free(jc); - -} - -void -eXosip_call_set_subject(eXosip_call_t *jc, char *subject) -{ - if (jc==NULL||subject==NULL||subject[0]=='\0') return; - snprintf(jc->c_subject, 99, "%s", subject); -} - diff --git a/linphone/exosip/jcallback.c b/linphone/exosip/jcallback.c deleted file mode 100644 index b8bb2bc58..000000000 --- a/linphone/exosip/jcallback.c +++ /dev/null @@ -1,1972 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include - -#ifdef WIN32 -#include -#include -#include -#else -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#endif - -#include -#include "eXosip2.h" -#include - -extern eXosip_t eXosip; - -#ifdef TEST_AUDIO -static pid_t pid = 0; -#endif - - -/* Private functions */ -static void rcvregister_failure(int type, osip_transaction_t *tr,osip_message_t *sip); -int cb_udp_snd_message(osip_transaction_t *tr, osip_message_t *sip, - char *host, int port, int out_socket); -static void cb_ict_kill_transaction(int type, osip_transaction_t *tr); -static void cb_ist_kill_transaction(int type, osip_transaction_t *tr); -static void cb_nict_kill_transaction(int type, osip_transaction_t *tr); -static void cb_nist_kill_transaction(int type, osip_transaction_t *tr); -static void cb_rcvinvite (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvack (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvack2 (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvregister(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvbye (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvcancel (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvinfo (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvoptions (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvnotify (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvsubscribe (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvunkrequest(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndinvite (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndack (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndregister(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndbye (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndcancel (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndinfo (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndoptions (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndnotify (int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndsubscribe(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_sndunkrequest(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcv1xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcv2xx_4invite(osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcv2xx_4subscribe(osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcv2xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcv3xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcv4xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcv5xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcv6xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_snd1xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_snd2xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_snd3xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_snd4xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_snd5xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_snd6xx(int type, osip_transaction_t *tr,osip_message_t *sip); -static void cb_rcvresp_retransmission(int type, osip_transaction_t *tr, osip_message_t *sip); -static void cb_sndreq_retransmission(int type, osip_transaction_t *tr, osip_message_t *sip); -static void cb_sndresp_retransmission(int type, osip_transaction_t *tr, osip_message_t *sip); -static void cb_rcvreq_retransmission(int type, osip_transaction_t *tr, osip_message_t *sip); -static void cb_transport_error(int type, osip_transaction_t *tr, int error); -static void report_call_event_with_status(int evt, eXosip_call_t *jc, eXosip_dialog_t *jd, osip_message_t *sip); -static void report_event_with_status(eXosip_event_t *je, osip_message_t *sip); - -int cb_udp_snd_message(osip_transaction_t *tr, osip_message_t *sip, char *host, - int port, int out_socket) -{ - int len = 0; - size_t length = 0; - static int num = 0; - struct addrinfo *addrinfo; - struct __eXosip_sockaddr addr; - char *message; - int i; - - if (eXosip.j_socket==0) return -1; - - if (host==NULL) - { - host = sip->req_uri->host; - if (sip->req_uri->port!=NULL) - port = osip_atoi(sip->req_uri->port); - else - port = 5060; - } - - i = eXosip_get_addrinfo(&addrinfo, host, port); - if (i!=0) - { - return -1; - } - memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen); - len = addrinfo->ai_addrlen; - - freeaddrinfo (addrinfo); - - i = osip_message_to_str(sip, &message, &length); - - if (i!=0 || length<=0) { - return -1; - } - - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "Message sent: \n%s (len=%i sizeof(addr)=%i %i)\n", - message, len, sizeof(addr), sizeof(struct sockaddr_in6))); - if (0 > sendto (eXosip.j_socket, (const void*) message, length, 0, - (struct sockaddr *) &addr, len /* sizeof(addr) */ )) - { -#ifdef WIN32 - if (WSAECONNREFUSED==WSAGetLastError()) -#else - if (ECONNREFUSED==errno) -#endif - { - /* This can be considered as an error, but for the moment, - I prefer that the application continue to try sending - message again and again... so we are not in a error case. - Nevertheless, this error should be announced! - ALSO, UAS may not have any other options than retry always - on the same port. - */ - osip_free(message); - return 1; - } - else - { - /* SIP_NETWORK_ERROR; */ - osip_free(message); - return -1; - } - } - if (strncmp(message, "INVITE", 7)==0) - { - num++; - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO4,NULL,"number of message sent: %i\n", num)); - } - - osip_free(message); - return 0; - -} - -static void cb_ict_kill_transaction(int type, osip_transaction_t *tr) -{ - int i; - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_ict_kill_transaction (id=%i)\r\n", tr->transactionid)); - - i = osip_remove_transaction(eXosip.j_osip, tr); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"cb_ict_kill_transaction Error: Could not remove transaction from the oSIP stack? (id=%i)\r\n", tr->transactionid)); - } -} - -static void cb_ist_kill_transaction(int type, osip_transaction_t *tr) -{ - int i; - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_ist_kill_transaction (id=%i)\r\n", tr->transactionid)); - i = osip_remove_transaction(eXosip.j_osip, tr); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"cb_ist_kill_transaction Error: Could not remove transaction from the oSIP stack? (id=%i)\r\n", tr->transactionid)); - } -} - -static void cb_nict_kill_transaction(int type, osip_transaction_t *tr) -{ - int i; - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - eXosip_notify_t *jn; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_nict_kill_transaction (id=%i)\r\n", tr->transactionid)); - i = osip_remove_transaction(eXosip.j_osip, tr); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"cb_nict_kill_transaction Error: Could not remove transaction from the oSIP stack? (id=%i)\r\n", tr->transactionid)); - } - - if (MSG_IS_REGISTER(tr->orig_request) - && type==OSIP_NICT_KILL_TRANSACTION - && tr->last_response==NULL) - { - eXosip_event_t *je; - eXosip_reg_t *jreg=NULL; - /* find matching j_reg */ - _eXosip_reg_find(&jreg, tr); - if (jreg!=NULL) - { - je = eXosip_event_init_for_reg(EXOSIP_REGISTRATION_FAILURE, jreg); - report_event_with_status(je, NULL); - } - return; - } - - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - jn = jinfo->jn; - js = jinfo->js; - - if (jn==NULL && js==NULL) - return; - - /* no answer to a NOTIFY request! */ - if (MSG_IS_NOTIFY(tr->orig_request) - && type==OSIP_NICT_KILL_TRANSACTION - && tr->last_response==NULL) - { - /* delete the dialog! */ - REMOVE_ELEMENT(eXosip.j_notifies, jn); - eXosip_notify_free(jn); - return; - } - - if (MSG_IS_NOTIFY(tr->orig_request) - && type==OSIP_NICT_KILL_TRANSACTION - && tr->last_response!=NULL - && tr->last_response->status_code > 299) - { - /* delete the dialog! */ - REMOVE_ELEMENT(eXosip.j_notifies, jn); - eXosip_notify_free(jn); - return; - } - - if (MSG_IS_NOTIFY(tr->orig_request) - && type==OSIP_NICT_KILL_TRANSACTION - && tr->last_response!=NULL - && tr->last_response->status_code > 199 - && tr->last_response->status_code < 300) - { - if (jn->n_ss_status==EXOSIP_SUBCRSTATE_TERMINATED) - { - /* delete the dialog! */ - REMOVE_ELEMENT(eXosip.j_notifies, jn); - eXosip_notify_free(jn); - return; - } - } - - /* no answer to a SUBSCRIBE request! */ - if (MSG_IS_SUBSCRIBE(tr->orig_request) - && type==OSIP_NICT_KILL_TRANSACTION - && tr->last_response==NULL) - { - /* delete the dialog! */ - REMOVE_ELEMENT(eXosip.j_subscribes, js); - eXosip_subscribe_free(js); - return; - } - - /* detect SUBSCRIBE request that close the dialogs! */ - /* expires=0 with MSN */ - if (MSG_IS_SUBSCRIBE(tr->orig_request) - && type==OSIP_NICT_KILL_TRANSACTION) - { - osip_header_t *expires; - osip_message_get_expires(tr->orig_request, 0, &expires); - if (expires==NULL || expires->hvalue==NULL) - { - } - else if (0==strcmp(expires->hvalue, "0")) - { - /* delete the dialog! */ - REMOVE_ELEMENT(eXosip.j_subscribes, js); - eXosip_subscribe_free(js); - return; - } - } -} - -static void cb_nist_kill_transaction(int type, osip_transaction_t *tr) -{ - int i; - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_nist_kill_transaction (id=%i)\r\n", tr->transactionid)); - i = osip_remove_transaction(eXosip.j_osip, tr); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_BUG,NULL,"cb_nist_kill_transaction Error: Could not remove transaction from the oSIP stack? (id=%i)\r\n", tr->transactionid)); - } - -} - -static void cb_rcvinvite (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvinvite (id=%i)\n", tr->transactionid)); -} - -static void cb_rcvack (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvack (id=%i)\n", tr->transactionid)); -} - -static void cb_rcvack2 (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvack2 (id=%i)\r\n", tr->transactionid)); -} - -static void cb_rcvregister(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvregister (id=%i)\r\n", tr->transactionid)); -} - -static void cb_rcvbye (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvbye (id=%i)\r\n", tr->transactionid)); -#ifdef TEST_AUDIO - if (pid!=0) - { - int i = kill(pid, SIGINT); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"audio command kill return %i %i\n", i, pid)); - pid = 0; - } -#endif -} - -static void cb_rcvcancel (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvcancel (id=%i)\r\n", tr->transactionid)); -} - -static void cb_rcvinfo (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_event_t *je; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvinfo (id=%i)\r\n", tr->transactionid)); - - if (jinfo==NULL) - return; - if (jinfo->jc==NULL) - return; - - je = eXosip_event_init_for_call(EXOSIP_INFO_NEW, jinfo->jc, jinfo->jd); - if (je!=NULL) - { - char *tmp; - osip_uri_to_str(sip->req_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->req_uri, 255, "%s", tmp); - osip_free(tmp); - } - - if (sip!=NULL) - { - int pos; - /* get content-type info */ - osip_content_type_clone(osip_message_get_content_type(sip), &(je->i_ctt)); - /* get list of bodies */ - je->i_bodies = (osip_list_t*) osip_malloc(sizeof(osip_list_t)); - osip_list_init(je->i_bodies); - for (pos=0;!osip_list_eol(sip->bodies, pos);pos++) - { - osip_body_t *body; - osip_body_t *_body; - body = (osip_body_t *)osip_list_get(sip->bodies, pos); - osip_body_clone(body, &_body); - osip_list_add(je->i_bodies, _body, -1); - } - } - } - - report_event_with_status(je, NULL); -} - -static void cb_rcvoptions (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_event_t *je; - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - eXosip_notify_t *jn; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvoptions (id=%i)\r\n", tr->transactionid)); - - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - jn = jinfo->jn; - js = jinfo->js; - if (jinfo->jc==NULL) - return; - - je = eXosip_event_init_for_call(EXOSIP_OPTIONS_NEW, jc, jd); - if (je!=NULL) - { - char *tmp; - osip_uri_to_str(sip->req_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->req_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - report_event_with_status(je, NULL); - -} - -static void cb_rcvnotify (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvnotify (id=%i)\r\n", tr->transactionid)); -} - -static void cb_rcvsubscribe (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_event_t *je; - eXosip_dialog_t *jd; - eXosip_notify_t *jn; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvsubscribe (id=%i)\r\n", tr->transactionid)); - - if (jinfo==NULL) - return; - jd = jinfo->jd; - jn = jinfo->jn; - if (jinfo->jn==NULL) - return; - - je = eXosip_event_init_for_notify(EXOSIP_IN_SUBSCRIPTION_NEW, jn, jd); - if (je!=NULL) - { - char *tmp; - osip_uri_to_str(sip->req_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->req_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - report_event_with_status(je, NULL); -} - -static void cb_rcvunkrequest(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvunkrequest (id=%i)\r\n", tr->transactionid)); - - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - if (jinfo->jc==NULL) - return; - - - if (MSG_IS_REFER(sip)) - { - eXosip_event_t *je; - - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvrefer (id=%i)\r\n", tr->transactionid)); - - je = eXosip_event_init_for_call(EXOSIP_CALL_REFERED, jc, jd); - if (je!=NULL) - { - report_event_with_status(je, NULL); - } - } - -} - -static void cb_sndinvite (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndinvite (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndack (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndack (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndregister(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndregister (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndbye (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndbye (id=%i)\r\n", tr->transactionid)); -#ifdef TEST_AUDIO - if (pid!=0) - { - int i = kill(pid, SIGINT); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"audio command kill return %i %i\n", i, pid)); - pid = 0; - } -#endif - -} - -static void cb_sndcancel (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndcancel (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndinfo (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndinfo (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndoptions (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndoptions (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndnotify (int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndnotify (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndsubscribe(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndsubscibe (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndunkrequest(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndunkrequest (id=%i)\r\n", tr->transactionid)); -} - -void __eXosip_delete_jinfo(osip_transaction_t *transaction) -{ - jinfo_t *ji; - if (transaction==NULL) - return; - ji = osip_transaction_get_your_instance(transaction); - osip_free(ji); - osip_transaction_set_your_instance(transaction, NULL); -} - -jinfo_t *__eXosip_new_jinfo(eXosip_call_t *jc, eXosip_dialog_t *jd, - eXosip_subscribe_t *js, eXosip_notify_t *jn) -{ - jinfo_t *ji = (jinfo_t *) osip_malloc(sizeof(jinfo_t)); - if (ji==NULL) return NULL; - ji->jd = jd; - ji->jc = jc; - ji->js = js; - ji->jn = jn; - return ji; -} - -static void cb_rcv1xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - eXosip_notify_t *jn; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv1xx (id=%i)\r\n", tr->transactionid)); - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - jn = jinfo->jn; - js = jinfo->js; - - if (MSG_IS_RESPONSE_FOR(sip, "OPTIONS")) - { - if (jc==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv1xx (id=%i) Error: no call or transaction info for OPTIONS transaction\r\n", tr->transactionid)); - return; - } - else if (jc->c_out_options_tr==NULL) - { - /* options is within a call */ - } - report_call_event_with_status(EXOSIP_OPTIONS_PROCEEDING, jc, jd, sip); - return; - } - - if ((MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - && !MSG_TEST_CODE(sip, 100)) - { - int i; - /* for SUBSCRIBE, test if the dialog has been already created - with a previous NOTIFY */ - if (jd==NULL && js!=NULL && js->s_dialogs!=NULL && MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - /* find if existing dialog match the to tag */ - osip_generic_param_t *tag; - int i; - i = osip_to_get_tag (sip->to, &tag); - if (i==0 && tag!=NULL && tag->gvalue!=NULL ) - { - for (jd = js->s_dialogs; jd!= NULL ; jd=jd->next) - { - if (0==strcmp(jd->d_dialog->remote_tag, tag->gvalue)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "eXosip: found established early dialog for this subscribe\n")); - jinfo->jd = jd; - break; - } - } - } - } - - if (jd == NULL) /* This transaction initiate a dialog in the case of - INVITE (else it would be attached to a "jd" element. */ - { - /* allocate a jd */ - - i = eXosip_dialog_init_as_uac(&jd, sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot establish a dialog\n")); - return; - } - if (jc!=NULL) - { - ADD_ELEMENT(jc->c_dialogs, jd); - jinfo->jd = jd; - eXosip_update(); - } - else if (js!=NULL) - { - ADD_ELEMENT(js->s_dialogs, jd); - jinfo->jd = jd; - eXosip_update(); - } - else if (jn!=NULL) - { - ADD_ELEMENT(jn->n_dialogs, jd); - jinfo->jd = jd; - eXosip_update(); - } - else - { -#ifndef WIN32 - assert(0==0); -#else - exit(0); -#endif - } - osip_transaction_set_your_instance(tr, jinfo); - } - else - { - osip_dialog_update_route_set_as_uac(jd->d_dialog, sip); - } - - if ( jd!=NULL) - jd->d_STATE = JD_TRYING; - if ( jd!=NULL && MSG_IS_RESPONSE_FOR(sip, "INVITE") - && sip->status_code < 180) - { - eXosip_event_t *je; - je = eXosip_event_init_for_call(EXOSIP_CALL_PROCEEDING, jc, jd); - if (je!=NULL) - { - if (sip->status_code>100) - eXosip_event_add_sdp_info(je, sip); - report_event_with_status(je, sip); - } - } - else if ( jd!=NULL && MSG_IS_RESPONSE_FOR(sip, "INVITE") - && sip->status_code >= 180) - { - eXosip_event_t *je; - je = eXosip_event_init_for_call(EXOSIP_CALL_RINGING, jc, jd); - if (je!=NULL) - { - eXosip_event_add_sdp_info(je, sip); - report_event_with_status(je, sip); - } - } - else if ( jd!=NULL && MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_subscribe(EXOSIP_SUBSCRIPTION_PROCEEDING, js, jd); - if (je!=NULL) - report_event_with_status(je, sip); - } - if (MSG_TEST_CODE(sip, 180) && jd!=NULL) - { - jd->d_STATE = JD_RINGING; - } - else if (MSG_TEST_CODE(sip, 183) && jd!=NULL) - { - jd->d_STATE = JD_QUEUED; - } - - } -} - -sdp_message_t *eXosip_get_remote_sdp(osip_transaction_t *transaction) -{ - osip_message_t *message; - osip_body_t *body; - sdp_message_t *sdp; - int pos = 0; - int i; - if (transaction->ist_context!=NULL) - /* remote sdp is in INVITE (or ACK!) */ - message = transaction->orig_request; - else - /* remote sdp is in response */ - message = transaction->last_response; - - if (message==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"No remote sdp body found\r\n")); - return NULL; - } - sdp=NULL; - body = (osip_body_t *)osip_list_get(message->bodies,0); - while (body!=NULL) - { - i = sdp_message_init(&sdp); - if (i!=0) - { sdp = NULL; break; } - i = sdp_message_parse(sdp,body->body); - if (i==0) - return sdp; - sdp_message_free(sdp); - sdp = NULL; - pos++; - body = (osip_body_t *)osip_list_get(message->bodies,pos); - } - return NULL; -} - -sdp_message_t *eXosip_get_local_sdp(osip_transaction_t *transaction) -{ - osip_message_t *message; - osip_body_t *body; - sdp_message_t *sdp; - int i; - int pos = 0; - if (transaction->ict_context!=NULL) - /* local sdp is in INVITE (or ACK!) */ - message = transaction->orig_request; - else - /* local sdp is in response */ - message = transaction->last_response; - - sdp=NULL; - body = (osip_body_t *)osip_list_get(message->bodies,0); - while (body!=NULL) - { - i = sdp_message_init(&sdp); - if (i!=0) - { sdp = NULL; break; } - i = sdp_message_parse(sdp,body->body); - if (i==0) - return sdp; - sdp_message_free(sdp); - sdp = NULL; - pos++; - body = (osip_body_t *)osip_list_get(message->bodies,pos); - } - return NULL; -} - - -static -void report_call_event_with_status(int evt, eXosip_call_t *jc, eXosip_dialog_t *jd, osip_message_t *sip) -{ - eXosip_event_t *je; - je = eXosip_event_init_for_call(evt, jc, jd); - if (je!=NULL) - { - if (sip != NULL) - eXosip_event_add_status(je, sip); - if (eXosip.j_call_callbacks[evt]!=NULL) - eXosip.j_call_callbacks[evt](evt, je); - else if (eXosip.j_runtime_mode==EVENT_MODE) - eXosip_event_add(je); - } - -} - -static -void report_event_with_status(eXosip_event_t *je, osip_message_t *sip) -{ - if (je!=NULL) - { - int evt = je->type; - - if (sip != NULL) - eXosip_event_add_status(je, sip); - if (eXosip.j_call_callbacks[evt]!=NULL) - eXosip.j_call_callbacks[evt](evt, je); - else if (eXosip.j_runtime_mode==EVENT_MODE) - eXosip_event_add(je); - } -} - - -#if 0 -void eXosip_update_audio_session(osip_transaction_t *transaction) -{ - char *remaddr; - sdp_message_t *remote_sdp; - sdp_message_t *local_sdp; - char *remote_port; - char *local_port; - char *payload; - char *media_type; - int pos; - /* look for the SDP informations */ - - remote_sdp = eXosip_get_remote_sdp(transaction); - if (remote_sdp==NULL) - return ; - local_sdp = eXosip_get_local_sdp(transaction); - if (local_sdp==NULL) - { - sdp_message_free(remote_sdp); - return ; - } - remaddr=sdp_message_c_addr_get(remote_sdp,-1,0); - if (remaddr==NULL){ - remaddr=sdp_message_c_addr_get(remote_sdp,0,0); - } - - pos=0; - local_port=sdp_message_m_port_get(local_sdp,pos); - media_type = sdp_message_m_media_get(local_sdp,pos); - while (local_port!=NULL && media_type!=NULL) - { /* If we have refused some media lines, the port is set to 0 */ - if (0!=strncmp(local_port,"0", 1)&&0==osip_strcasecmp(media_type,"audio")) - break; - pos++; - media_type = sdp_message_m_media_get(local_sdp,pos); - local_port=sdp_message_m_port_get(local_sdp,pos); - } - - if (media_type!=NULL && local_port!=NULL) - { - remote_port = sdp_message_m_port_get(remote_sdp,pos); - payload = sdp_message_m_payload_get(local_sdp,pos,0); - } - else - { - remote_port = NULL; - payload = NULL; - } - if (remote_port!=NULL && media_type!=NULL) /* if codec has been found */ - { - char tmp[256]; - sprintf(tmp, "mediastream --local %s --remote %s:%s --payload %s > debug_rtp 2>&1" , local_port, remaddr, remote_port, payload); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"audio command %s\n", tmp)); - -#ifdef TEST_AUDIO - if (pid!=0) - { - int i = kill(pid, SIGINT); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"audio command kill return %i %i\n", i, pid)); - pid = 0; - } - - pid = fork(); - if (pid==0) - { - int ret; -#ifndef USE_EXECL - ret = system(tmp); - if (WIFSIGNALED(ret) && - (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT)) - { - exit(-1); - } - if (ret==0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"Could not start audio\n", tmp)); - } - exit(0); -#else - char _remoteipport[100]; - snprintf(_remoteipport, 100, "%s:%s", remaddr, remote_port); - ret = execl("mediastream","--local", local_port, - "--remote", _remoteipport, "--payload", payload); -#endif - } -#endif - - } - else - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"Could not create audio session.\r\n")); - } - sdp_message_free(local_sdp); - sdp_message_free(remote_sdp); -} -#endif - -static void cb_rcv2xx_4invite(osip_transaction_t *tr,osip_message_t *sip) -{ - int i; - eXosip_dialog_t *jd; - eXosip_call_t *jc; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - if (jd == NULL) /* This transaction initiate a dialog in the case of - INVITE (else it would be attached to a "jd" element. */ - { - /* allocate a jd */ - i = eXosip_dialog_init_as_uac(&jd, sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot establish a dialog\n")); - return; - } - ADD_ELEMENT(jc->c_dialogs, jd); - jinfo->jd = jd; - eXosip_update(); - osip_transaction_set_your_instance(tr, jinfo); - } - else - { - /* Here is a special case: - We have initiated a dialog and we have received informationnal - answers from 2 or more remote SIP UA. Those answer can be - differentiated with the "To" header's tag. - - We have used the first informationnal answer to create a - dialog, but we now want to be sure the 200ok received is - for the dialog this dialog. - - We have to check the To tag and if it does not match, we - just have to modify the existing dialog and replace it. */ - osip_generic_param_t *tag; - int i; - i = osip_to_get_tag (sip->to, &tag); - i=1; /* default is the same dialog */ - - if (jd->d_dialog==NULL || jd->d_dialog->remote_tag==NULL) - { - /* There are real use-case where a BYE is received/processed before - the 200ok of the previous INVITE. In this case, jd->d_dialog is - empty and the transaction should be silently discarded. */ - /* a ACK should still be sent... -but there is no dialog built- */ - return; - } - - if (jd->d_dialog->remote_tag==NULL && tag==NULL) - { } /* non compliant remote UA -> assume it is the same dialog */ - else if (jd->d_dialog->remote_tag!=NULL && tag==NULL) - { i=0; } /* different dialog! */ - else if (jd->d_dialog->remote_tag==NULL && tag!=NULL) - { i=0; } /* different dialog! */ - else if (jd->d_dialog->remote_tag!=NULL && tag!=NULL && tag->gvalue!=NULL - && 0!=strcmp(jd->d_dialog->remote_tag, tag->gvalue)) - { i=0; } /* different dialog! */ - - if (i==1) /* just update the dialog */ - { - osip_dialog_update_route_set_as_uac(jd->d_dialog, sip); - osip_dialog_set_state(jd->d_dialog, DIALOG_CONFIRMED); - } - else - { - /* the best thing is to update the repace the current dialog - information... Much easier than creating a useless dialog! */ - osip_dialog_free(jd->d_dialog); - i = osip_dialog_init_as_uac(&(jd->d_dialog), sip); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"Cannot replace the dialog.\r\n")); - } - else - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_WARNING,NULL,"The dialog has been replaced with the new one fro 200ok.\r\n")); - } - } - } - - jd->d_STATE = JD_ESTABLISHED; - - eXosip_dialog_set_200ok(jd, sip); - - { - osip_route_t *route; - char *host; - int port; - osip_message_t *ack; - i = _eXosip_build_request_within_dialog(&ack, "ACK", jd->d_dialog, "UDP"); - if (i!=0) { - jd->d_STATE = JD_ESTABLISHED; - return ; - } - - if(jc->c_ack_sdp) /* need to build sdp answer */ - { - char *body; - char *size; - - body = generating_sdp_answer(tr->last_response, jc->c_ctx); - if (body==NULL) - { - return; - } - - i = osip_message_set_body(ack, body, strlen(body)); - if (i!=0) - { - return; - } - - size = (char *) osip_malloc(6*sizeof(char)); -#ifdef __APPLE_CC__ - sprintf(size,"%li",strlen(body)); -#else - sprintf(size,"%i",strlen(body)); -#endif - osip_free(body); - i = osip_message_set_content_length(ack, size); - osip_free(size); - if (i!=0) - { - return; - } - i = osip_message_set_content_type(ack, "application/sdp"); - if (i!=0) - { - return; - } - } - - /* SM: do not send the ack now, just prepare it. - The application will send it using eXosip_send_ack(int jid) - */ - /* - osip_message_get_route(ack, 0, &route); - if (route!=NULL) - { - port = 5060; - if (route->url->port!=NULL) - port = osip_atoi(route->url->port); - host = route->url->host; - } - else - { - port = 5060; - if (ack->req_uri->port!=NULL) - port = osip_atoi(ack->req_uri->port); - host = ack->req_uri->host; - } - - cb_udp_snd_message(NULL, ack, host, port, eXosip.j_socket); - */ - - jd->d_ack = ack; - - } - - { - eXosip_event_t *je; - je = eXosip_event_init_for_call(EXOSIP_CALL_ANSWERED, jc, jd); - if (je!=NULL) - { - eXosip_event_add_sdp_info(je, sip); - report_event_with_status(je, sip); - } - - - je = eXosip_event_init_for_call(EXOSIP_CALL_STARTAUDIO, jc, jd); - if (je!=NULL) - { - eXosip_event_add_sdp_info(je, sip); - report_event_with_status(je, sip); - } - - } - - /* look for the SDP information and decide if this answer was for - an initial INVITE, an HoldCall, or a RetreiveCall */ - - /* don't handle hold/unhold by now... */ - /* eXosip_update_audio_session(tr); */ - -} - -static void cb_rcv2xx_4subscribe(osip_transaction_t *tr,osip_message_t *sip) -{ - int i; - eXosip_dialog_t *jd; - eXosip_subscribe_t *js; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - if (jinfo==NULL) - return; - jd = jinfo->jd; - js = jinfo->js; - _eXosip_subscribe_set_refresh_interval(js, sip); - - - /* for SUBSCRIBE, test if the dialog has been already created - with a previous NOTIFY */ - if (jd==NULL && js!=NULL && js->s_dialogs!=NULL && MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - /* find if existing dialog match the to tag */ - osip_generic_param_t *tag; - int i; - i = osip_to_get_tag (sip->to, &tag); - if (i==0 && tag!=NULL && tag->gvalue!=NULL ) - { - for (jd = js->s_dialogs; jd!= NULL ; jd=jd->next) - { - if (0==strcmp(jd->d_dialog->remote_tag, tag->gvalue)) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "eXosip: found established early dialog for this subscribe\n")); - jinfo->jd = jd; - break; - } - } - } - } - - if (jd == NULL) /* This transaction initiate a dialog in the case of - SUBSCRIBE (else it would be attached to a "jd" element. */ - { - /* allocate a jd */ - i = eXosip_dialog_init_as_uac(&jd, sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot establish a dialog\n")); - return; - } - ADD_ELEMENT(js->s_dialogs, jd); - jinfo->jd = jd; - eXosip_update(); - osip_transaction_set_your_instance(tr, jinfo); - } - else - { - osip_dialog_update_route_set_as_uac(jd->d_dialog, sip); - osip_dialog_set_state(jd->d_dialog, DIALOG_CONFIRMED); - } - - jd->d_STATE = JD_ESTABLISHED; - /* look for the body information */ - - { - eXosip_event_t *je; - je = eXosip_event_init_for_subscribe(EXOSIP_SUBSCRIPTION_ANSWERED, js, jd); - if (je!=NULL) - { - report_event_with_status(je, sip); - } - } - -} - -static void cb_rcv2xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - eXosip_notify_t *jn; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv2xx (id=%i)\r\n", tr->transactionid)); - - if (MSG_IS_RESPONSE_FOR(sip, "PUBLISH")) - { - eXosip_pub_t *pub; - int i; - i = _eXosip_pub_update(&pub, tr, sip); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"cb_rcv2xx (id=%i) No publication to update\r\n", tr->transactionid)); - } - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "REGISTER")) - { - eXosip_event_t *je; - eXosip_reg_t *jreg=NULL; - /* find matching j_reg */ - _eXosip_reg_find(&jreg, tr); - if (jreg!=NULL) - { - je = eXosip_event_init_for_reg(EXOSIP_REGISTRATION_SUCCESS, jreg); - if (je!=NULL) - { - report_event_with_status(je, sip); - } - } - return; - } - - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - jn = jinfo->jn; - js = jinfo->js; - - if (MSG_IS_RESPONSE_FOR(sip, "OPTIONS")) - { - if (jc==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv2xx (id=%i) Error: no call or transaction info for OPTIONS transaction\r\n", tr->transactionid)); - return; - } - else if (jc->c_out_options_tr==NULL) - { - /* options is within a call */ - } - report_call_event_with_status(EXOSIP_OPTIONS_ANSWERED, jc, jd, sip); - return; - } - - if (MSG_IS_RESPONSE_FOR(sip, "INVITE")) - { - cb_rcv2xx_4invite(tr, sip); - } - else if (MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - cb_rcv2xx_4subscribe(tr, sip); - } - else if (MSG_IS_RESPONSE_FOR(sip, "BYE")) - { - if (jd!=NULL) - jd->d_STATE = JD_TERMINATED; - } - else if (MSG_IS_RESPONSE_FOR(sip, "MESSAGE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_message(EXOSIP_MESSAGE_SUCCESS, tr, sip); - if (je!=NULL) - report_event_with_status(je, sip); - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "NOTIFY")) - { -#ifdef SUPPORT_MSN - osip_header_t *expires; - osip_message_header_get_byname(tr->orig_request, "expires", - 0, &expires); - if (expires==NULL || expires->hvalue==NULL) - { - /* UNCOMPLIANT UA without a subscription-state header */ - } - else if (0==osip_strcasecmp(expires->hvalue, "0")) - { - /* delete the dialog! */ - if (jn!=NULL) - { - REMOVE_ELEMENT(eXosip.j_notifies, jn); - eXosip_notify_free(jn); - } - } -#else - osip_header_t *sub_state; - osip_message_header_get_byname(tr->orig_request, "subscription-state", - 0, &sub_state); - if (sub_state==NULL || sub_state->hvalue==NULL) - { - /* UNCOMPLIANT UA without a subscription-state header */ - } - else if (0==osip_strncasecmp(sub_state->hvalue, "terminated", 10)) - { - /* delete the dialog! */ - if (jn!=NULL) - { - REMOVE_ELEMENT(eXosip.j_notifies, jn); - eXosip_notify_free(jn); - } - } -#endif - } -} - -void eXosip_delete_early_dialog(eXosip_dialog_t *jd) -{ - if (jd == NULL) /* bug? */ - return; - - /* an early dialog was created, but the call is not established */ - if (jd->d_dialog!=NULL && jd->d_dialog->state==DIALOG_EARLY) - { - osip_dialog_free(jd->d_dialog); - jd->d_dialog = NULL; - eXosip_dialog_set_state(jd, JD_TERMINATED); - } -} - -static void -rcvregister_failure(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_event_t *je; - eXosip_reg_t *jreg=NULL; - /* find matching j_reg */ - _eXosip_reg_find(&jreg, tr); - if (jreg!=NULL) - { - je = eXosip_event_init_for_reg(EXOSIP_REGISTRATION_FAILURE, jreg); - report_event_with_status(je, sip); - } -} - -static void cb_rcv3xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv3xx (id=%i)\r\n", tr->transactionid)); - - if (MSG_IS_RESPONSE_FOR(sip, "PUBLISH")) - { - eXosip_pub_t *pub; - int i; - i = _eXosip_pub_update(&pub, tr, sip); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"cb_rcv3xx (id=%i) No publication to update\r\n", tr->transactionid)); - } - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "REGISTER")) - { - rcvregister_failure(type, tr, sip); - return; - } - - if (jinfo==NULL) return; - jd = jinfo->jd; - jc = jinfo->jc; - js = jinfo->js; - - if (MSG_IS_RESPONSE_FOR(sip, "OPTIONS")) - { - if (jc==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv3xx (id=%i) Error: no call or transaction info for INFO transaction\r\n", tr->transactionid)); - return; - } - else if (jc->c_out_options_tr==NULL) - { - /* options is within a call */ - } - - report_call_event_with_status(EXOSIP_OPTIONS_REDIRECTED, jc, jd, sip); - return; - } - - if (MSG_IS_RESPONSE_FOR(sip, "INVITE")) - { - report_call_event_with_status(EXOSIP_CALL_REDIRECTED, jc, jd, sip); - } - else if (MSG_IS_RESPONSE_FOR(sip, "MESSAGE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_message(EXOSIP_MESSAGE_FAILURE, tr, sip); - if (je) - report_event_with_status(je, sip); - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_subscribe(EXOSIP_SUBSCRIPTION_REDIRECTED, js, jd); - if (je) - report_event_with_status(je, sip); - } - - if (jd==NULL) return; - if (MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_delete_early_dialog(jd); - if (jd->d_dialog==NULL) - jd->d_STATE = JD_REDIRECTED; - } - -} - -static void cb_rcv4xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv4xx (id=%i)\r\n", tr->transactionid)); - - if (MSG_IS_RESPONSE_FOR(sip, "PUBLISH")) - { - eXosip_pub_t *pub; - int i; - i = _eXosip_pub_update(&pub, tr, sip); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"cb_rcv4xx (id=%i) No publication to update\r\n", tr->transactionid)); - } - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "REGISTER")) - { - rcvregister_failure(type, tr, sip); - return; - } - - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - js = jinfo->js; - - if (MSG_IS_RESPONSE_FOR(sip, "OPTIONS")) - { - if (jc==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv4xx (id=%i) Error: no call or transaction info for INFO transaction\r\n", tr->transactionid)); - return; - } - else if (jc->c_out_options_tr==NULL) - { - /* options is within a call */ - } - - report_call_event_with_status(EXOSIP_OPTIONS_REQUESTFAILURE, jc, jd, sip); - return; - } - - if (MSG_IS_RESPONSE_FOR(sip, "INVITE")) - { - report_call_event_with_status(EXOSIP_CALL_REQUESTFAILURE, jc, jd, sip); - } - else if (MSG_IS_RESPONSE_FOR(sip, "MESSAGE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_message(EXOSIP_MESSAGE_FAILURE, tr, sip); - if (je!=NULL) - report_event_with_status(je, sip); - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_subscribe(EXOSIP_SUBSCRIPTION_REQUESTFAILURE, js, jd); - if (je!=NULL) - report_event_with_status(je, sip); - } - - if (jd==NULL) return; - if (MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_delete_early_dialog(jd); - if (MSG_TEST_CODE(sip, 401) || MSG_TEST_CODE(sip, 407)) - jd->d_STATE = JD_AUTH_REQUIRED; - else - jd->d_STATE = JD_CLIENTERROR; - } - -} - -static void cb_rcv5xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv5xx (id=%i)\r\n", tr->transactionid)); - - if (MSG_IS_RESPONSE_FOR(sip, "PUBLISH")) - { - eXosip_pub_t *pub; - int i; - i = _eXosip_pub_update(&pub, tr, sip); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"cb_rcv3xx (id=%i) No publication to update\r\n", tr->transactionid)); - } - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "REGISTER")) - { - rcvregister_failure(type, tr, sip); - return; - } - - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - js = jinfo->js; - - if (MSG_IS_RESPONSE_FOR(sip, "OPTIONS")) - { - if (jc==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv5xx (id=%i) Error: no call or transaction info for INFO transaction\r\n", tr->transactionid)); - return; - } - else if (jc->c_out_options_tr==NULL) - { - /* options is within a call */ - } - - report_call_event_with_status(EXOSIP_OPTIONS_SERVERFAILURE, jc, jd, sip); - return; - } - - if (MSG_IS_RESPONSE_FOR(sip, "INVITE")) - { - report_call_event_with_status(EXOSIP_CALL_SERVERFAILURE, jc, jd, sip); - } - else if (MSG_IS_RESPONSE_FOR(sip, "MESSAGE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_message(EXOSIP_MESSAGE_FAILURE, tr, sip); - if (je!=NULL) - report_event_with_status(je, sip); - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_subscribe(EXOSIP_SUBSCRIPTION_SERVERFAILURE, js, jd); - if (je!=NULL) - report_event_with_status(je, sip); - } - - if (jd==NULL) return; - if (MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_delete_early_dialog(jd); - jd->d_STATE = JD_SERVERERROR; - } - -} - -static void cb_rcv6xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv6xx (id=%i)\r\n", tr->transactionid)); - - if (MSG_IS_RESPONSE_FOR(sip, "PUBLISH")) - { - eXosip_pub_t *pub; - int i; - i = _eXosip_pub_update(&pub, tr, sip); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"cb_rcv6xx (id=%i) No publication to update\r\n", tr->transactionid)); - } - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "REGISTER")) - { - rcvregister_failure(type, tr, sip); - return; - } - - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - js = jinfo->js; - - if (MSG_IS_RESPONSE_FOR(sip, "OPTIONS")) - { - if (jc==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcv6xx (id=%i) Error: no call or transaction info for INFO transaction\r\n", tr->transactionid)); - return; - } - else if (jc->c_out_options_tr==NULL) - { - /* options is within a call */ - } - report_call_event_with_status(EXOSIP_OPTIONS_GLOBALFAILURE, jc, jd, sip); - return; - } - - if (MSG_IS_RESPONSE_FOR(sip, "INVITE")) - { - report_call_event_with_status(EXOSIP_CALL_GLOBALFAILURE, jc, jd, sip); - } - else if (MSG_IS_RESPONSE_FOR(sip, "MESSAGE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_message(EXOSIP_MESSAGE_FAILURE, tr, sip); - if (je!=NULL) - report_event_with_status(je, sip); - return; - } - else if (MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_event_t *je; - je = eXosip_event_init_for_subscribe(EXOSIP_SUBSCRIPTION_GLOBALFAILURE, js, jd); - if (je!=NULL) - report_event_with_status(je, sip); - } - - if (jd==NULL) return; - if (MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_delete_early_dialog(jd); - jd->d_STATE = JD_GLOBALFAILURE; - } - -} - -static void cb_snd1xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_snd1xx (id=%i)\r\n", tr->transactionid)); - - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - if (jd==NULL) return; - jd->d_STATE = JD_TRYING; -} - -static void cb_snd2xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_snd2xx (id=%i)\r\n", tr->transactionid)); - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - if (jd==NULL) return; - if (MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - jd->d_STATE = JD_ESTABLISHED; - return; - } - jd->d_STATE = JD_ESTABLISHED; -} - -static void cb_snd3xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_snd3xx (id=%i)\r\n", tr->transactionid)); - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - if (jd==NULL) return; - if (MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_delete_early_dialog(jd); - } - jd->d_STATE = JD_REDIRECTED; - - if (MSG_IS_RESPONSE_FOR(sip, "INVITE")) - { - report_call_event_with_status(EXOSIP_CALL_CLOSED, jc, jd, sip); - } -} - -static void cb_snd4xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_snd4xx (id=%i)\r\n", tr->transactionid)); - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - if (jd==NULL) return; - if (MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_delete_early_dialog(jd); - } - jd->d_STATE = JD_CLIENTERROR; - - if (MSG_IS_RESPONSE_FOR(sip, "INVITE")) - { - report_call_event_with_status(EXOSIP_CALL_CLOSED, jc, jd, sip); - } - -} - -static void cb_snd5xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_snd5xx (id=%i)\r\n", tr->transactionid)); - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - if (jd==NULL) return; - if (MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_delete_early_dialog(jd); - } - jd->d_STATE = JD_SERVERERROR; - - if (MSG_IS_RESPONSE_FOR(sip, "INVITE")) - { - report_call_event_with_status(EXOSIP_CALL_CLOSED, jc, jd, sip); - } - -} - -static void cb_snd6xx(int type, osip_transaction_t *tr,osip_message_t *sip) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_snd6xx (id=%i)\r\n", tr->transactionid)); - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - if (jd==NULL) return; - if (MSG_IS_RESPONSE_FOR(sip, "INVITE") - || MSG_IS_RESPONSE_FOR(sip, "SUBSCRIBE")) - { - eXosip_delete_early_dialog(jd); - } - jd->d_STATE = JD_GLOBALFAILURE; - - if (MSG_IS_RESPONSE_FOR(sip, "INVITE")) - { - report_call_event_with_status(EXOSIP_CALL_CLOSED, jc, jd, sip); - } - -} - -static void cb_rcvresp_retransmission(int type, osip_transaction_t *tr, osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvresp_retransmission (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndreq_retransmission(int type, osip_transaction_t *tr, osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndreq_retransmission (id=%i)\r\n", tr->transactionid)); -} - -static void cb_sndresp_retransmission(int type, osip_transaction_t *tr, osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_sndresp_retransmission (id=%i)\r\n", tr->transactionid)); -} - -static void cb_rcvreq_retransmission(int type, osip_transaction_t *tr, osip_message_t *sip) -{ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_rcvreq_retransmission (id=%i)\r\n", tr->transactionid)); -} - -static void cb_transport_error(int type, osip_transaction_t *tr, int error) -{ - eXosip_dialog_t *jd; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - eXosip_notify_t *jn; - jinfo_t *jinfo = (jinfo_t *)osip_transaction_get_your_instance(tr); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"cb_transport_error (id=%i)\r\n", tr->transactionid)); - if (jinfo==NULL) - return; - jd = jinfo->jd; - jc = jinfo->jc; - jn = jinfo->jn; - js = jinfo->js; - - if (jn==NULL && js==NULL) - return; - - if (MSG_IS_NOTIFY(tr->orig_request) - && type==OSIP_NICT_TRANSPORT_ERROR) - { - /* delete the dialog! */ - REMOVE_ELEMENT(eXosip.j_notifies, jn); - eXosip_notify_free(jn); - } - - if (MSG_IS_SUBSCRIBE(tr->orig_request) - && type==OSIP_NICT_TRANSPORT_ERROR) - { - /* delete the dialog! */ - REMOVE_ELEMENT(eXosip.j_subscribes, js); - eXosip_subscribe_free(js); - } - - if (MSG_IS_OPTIONS(tr->orig_request) && jc->c_dialogs==NULL - && type==OSIP_NICT_TRANSPORT_ERROR) - { - /* delete the dialog! */ - REMOVE_ELEMENT(eXosip.j_calls, jc); - eXosip_call_free(jc); - } -} - - - -int -eXosip_set_callbacks(osip_t *osip) -{ - /* register all callbacks */ - - osip_set_cb_send_message(osip, &cb_udp_snd_message); - - osip_set_kill_transaction_callback(osip ,OSIP_ICT_KILL_TRANSACTION, - &cb_ict_kill_transaction); - osip_set_kill_transaction_callback(osip ,OSIP_IST_KILL_TRANSACTION, - &cb_ist_kill_transaction); - osip_set_kill_transaction_callback(osip ,OSIP_NICT_KILL_TRANSACTION, - &cb_nict_kill_transaction); - osip_set_kill_transaction_callback(osip ,OSIP_NIST_KILL_TRANSACTION, - &cb_nist_kill_transaction); - - osip_set_message_callback(osip ,OSIP_ICT_STATUS_2XX_RECEIVED_AGAIN, - &cb_rcvresp_retransmission); - osip_set_message_callback(osip ,OSIP_ICT_STATUS_3456XX_RECEIVED_AGAIN, - &cb_rcvresp_retransmission); - osip_set_message_callback(osip ,OSIP_ICT_INVITE_SENT_AGAIN, - &cb_sndreq_retransmission); - osip_set_message_callback(osip ,OSIP_IST_STATUS_2XX_SENT_AGAIN, - &cb_sndresp_retransmission); - osip_set_message_callback(osip ,OSIP_IST_STATUS_3456XX_SENT_AGAIN, - &cb_sndresp_retransmission); - osip_set_message_callback(osip ,OSIP_IST_INVITE_RECEIVED_AGAIN, - &cb_rcvreq_retransmission); - osip_set_message_callback(osip ,OSIP_NICT_STATUS_2XX_RECEIVED_AGAIN, - &cb_rcvresp_retransmission); - osip_set_message_callback(osip ,OSIP_NICT_STATUS_3456XX_RECEIVED_AGAIN, - &cb_rcvresp_retransmission); - osip_set_message_callback(osip ,OSIP_NICT_REQUEST_SENT_AGAIN, - &cb_sndreq_retransmission); - osip_set_message_callback(osip ,OSIP_NIST_STATUS_2XX_SENT_AGAIN, - &cb_sndresp_retransmission); - osip_set_message_callback(osip ,OSIP_NIST_STATUS_3456XX_SENT_AGAIN, - &cb_sndresp_retransmission); - osip_set_message_callback(osip ,OSIP_NIST_REQUEST_RECEIVED_AGAIN, - &cb_rcvreq_retransmission); - - osip_set_transport_error_callback(osip ,OSIP_ICT_TRANSPORT_ERROR, - &cb_transport_error); - osip_set_transport_error_callback(osip ,OSIP_IST_TRANSPORT_ERROR, - &cb_transport_error); - osip_set_transport_error_callback(osip ,OSIP_NICT_TRANSPORT_ERROR, - &cb_transport_error); - osip_set_transport_error_callback(osip ,OSIP_NIST_TRANSPORT_ERROR, - &cb_transport_error); - - osip_set_message_callback(osip ,OSIP_ICT_INVITE_SENT, &cb_sndinvite); - osip_set_message_callback(osip ,OSIP_ICT_ACK_SENT, &cb_sndack); - osip_set_message_callback(osip ,OSIP_NICT_REGISTER_SENT, &cb_sndregister); - osip_set_message_callback(osip ,OSIP_NICT_BYE_SENT, &cb_sndbye); - osip_set_message_callback(osip ,OSIP_NICT_CANCEL_SENT, &cb_sndcancel); - osip_set_message_callback(osip ,OSIP_NICT_INFO_SENT, &cb_sndinfo); - osip_set_message_callback(osip ,OSIP_NICT_OPTIONS_SENT, &cb_sndoptions); - osip_set_message_callback(osip ,OSIP_NICT_SUBSCRIBE_SENT, &cb_sndsubscribe); - osip_set_message_callback(osip ,OSIP_NICT_NOTIFY_SENT, &cb_sndnotify); - /* osip_set_cb_nict_sndprack (osip,&cb_sndprack); */ - osip_set_message_callback(osip ,OSIP_NICT_UNKNOWN_REQUEST_SENT, &cb_sndunkrequest); - - osip_set_message_callback(osip ,OSIP_ICT_STATUS_1XX_RECEIVED, &cb_rcv1xx); - osip_set_message_callback(osip ,OSIP_ICT_STATUS_2XX_RECEIVED, &cb_rcv2xx); - osip_set_message_callback(osip ,OSIP_ICT_STATUS_3XX_RECEIVED, &cb_rcv3xx); - osip_set_message_callback(osip ,OSIP_ICT_STATUS_4XX_RECEIVED, &cb_rcv4xx); - osip_set_message_callback(osip ,OSIP_ICT_STATUS_5XX_RECEIVED, &cb_rcv5xx); - osip_set_message_callback(osip ,OSIP_ICT_STATUS_6XX_RECEIVED, &cb_rcv6xx); - - osip_set_message_callback(osip ,OSIP_IST_STATUS_1XX_SENT, &cb_snd1xx); - osip_set_message_callback(osip ,OSIP_IST_STATUS_2XX_SENT, &cb_snd2xx); - osip_set_message_callback(osip ,OSIP_IST_STATUS_3XX_SENT, &cb_snd3xx); - osip_set_message_callback(osip ,OSIP_IST_STATUS_4XX_SENT, &cb_snd4xx); - osip_set_message_callback(osip ,OSIP_IST_STATUS_5XX_SENT, &cb_snd5xx); - osip_set_message_callback(osip ,OSIP_IST_STATUS_6XX_SENT, &cb_snd6xx); - - osip_set_message_callback(osip ,OSIP_NICT_STATUS_1XX_RECEIVED, &cb_rcv1xx); - osip_set_message_callback(osip ,OSIP_NICT_STATUS_2XX_RECEIVED, &cb_rcv2xx); - osip_set_message_callback(osip ,OSIP_NICT_STATUS_3XX_RECEIVED, &cb_rcv3xx); - osip_set_message_callback(osip ,OSIP_NICT_STATUS_4XX_RECEIVED, &cb_rcv4xx); - osip_set_message_callback(osip ,OSIP_NICT_STATUS_5XX_RECEIVED, &cb_rcv5xx); - osip_set_message_callback(osip ,OSIP_NICT_STATUS_6XX_RECEIVED, &cb_rcv6xx); - - osip_set_message_callback(osip ,OSIP_NIST_STATUS_1XX_SENT, &cb_snd1xx); - osip_set_message_callback(osip ,OSIP_NIST_STATUS_2XX_SENT, &cb_snd2xx); - osip_set_message_callback(osip ,OSIP_NIST_STATUS_3XX_SENT, &cb_snd3xx); - osip_set_message_callback(osip ,OSIP_NIST_STATUS_4XX_SENT, &cb_snd4xx); - osip_set_message_callback(osip ,OSIP_NIST_STATUS_5XX_SENT, &cb_snd5xx); - osip_set_message_callback(osip ,OSIP_NIST_STATUS_6XX_SENT, &cb_snd6xx); - - osip_set_message_callback(osip ,OSIP_IST_INVITE_RECEIVED, &cb_rcvinvite); - osip_set_message_callback(osip ,OSIP_IST_ACK_RECEIVED, &cb_rcvack); - osip_set_message_callback(osip ,OSIP_IST_ACK_RECEIVED_AGAIN, &cb_rcvack2); - osip_set_message_callback(osip ,OSIP_NIST_REGISTER_RECEIVED, &cb_rcvregister); - osip_set_message_callback(osip ,OSIP_NIST_BYE_RECEIVED, &cb_rcvbye); - osip_set_message_callback(osip ,OSIP_NIST_CANCEL_RECEIVED, &cb_rcvcancel); - osip_set_message_callback(osip ,OSIP_NIST_INFO_RECEIVED, &cb_rcvinfo); - osip_set_message_callback(osip ,OSIP_NIST_OPTIONS_RECEIVED, &cb_rcvoptions); - osip_set_message_callback(osip ,OSIP_NIST_SUBSCRIBE_RECEIVED, &cb_rcvsubscribe); - osip_set_message_callback(osip ,OSIP_NIST_NOTIFY_RECEIVED, &cb_rcvnotify); - osip_set_message_callback(osip ,OSIP_NIST_UNKNOWN_REQUEST_RECEIVED, &cb_rcvunkrequest); - - - return 0; -} diff --git a/linphone/exosip/jdialog.c b/linphone/exosip/jdialog.c deleted file mode 100644 index 9a8f859b6..000000000 --- a/linphone/exosip/jdialog.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" - -extern eXosip_t eXosip; - -void eXosip_dialog_set_state(eXosip_dialog_t *jd, int state) -{ - jd->d_STATE = state; -} - -int eXosip_call_dialog_find(int jid, eXosip_call_t **jc, eXosip_dialog_t **jd) -{ - for (*jc=eXosip.j_calls; *jc!=NULL; *jc=(*jc)->next) - { - for (*jd=(*jc)->c_dialogs; *jd!=NULL; *jd=(*jd)->next) - { - if ((*jd)->d_id==jid) - return 0; - } - } - *jd = NULL; - *jc = NULL; - return -1; -} - -int eXosip_notify_dialog_find(int nid, eXosip_notify_t **jn, eXosip_dialog_t **jd) -{ - for (*jn=eXosip.j_notifies; *jn!=NULL; *jn=(*jn)->next) - { - for (*jd=(*jn)->n_dialogs; *jd!=NULL; *jd=(*jd)->next) - { - if ((*jd)->d_id==nid) - return 0; - } - } - *jd = NULL; - *jn = NULL; - return -1; -} - -int eXosip_subscribe_dialog_find(int sid, eXosip_subscribe_t **js, eXosip_dialog_t **jd) -{ - for (*js=eXosip.j_subscribes; *js!=NULL; *js=(*js)->next) - { - *jd=NULL; - if ((*js)->s_id==sid) - return 0; - for (*jd=(*js)->s_dialogs; *jd!=NULL; *jd=(*jd)->next) - { - if ((*jd)->d_id==sid) - return 0; - } - } - *jd = NULL; - *js = NULL; - return -1; -} - -int eXosip_dialog_set_200ok(eXosip_dialog_t *jd, osip_message_t *_200Ok) -{ - int i; - if (jd==NULL) return -1; - i = osip_message_clone(_200Ok, &(jd->d_200Ok)); - if (i!=0) { - return -1; - } - return 0; -} - -int eXosip_dialog_init_as_uac(eXosip_dialog_t **_jd, osip_message_t *_200Ok) -{ - int i; - eXosip_dialog_t *jd; - *_jd = NULL; - jd = (eXosip_dialog_t *) osip_malloc(sizeof(eXosip_dialog_t)); - jd->d_id = -1; /* not yet available to user */ - jd->d_STATE = JD_EMPTY; - - if (MSG_IS_REQUEST(_200Ok)) - { - i = osip_dialog_init_as_uac_with_remote_request(&(jd->d_dialog), _200Ok, -1); - } - else - { /* normal usage with response */ - i = osip_dialog_init_as_uac(&(jd->d_dialog), _200Ok); - } - if (i!=0) - { - osip_free(jd); - return -1; - } - - jd->media_lines = (osip_list_t*) osip_malloc(sizeof(osip_list_t)); - osip_list_init(jd->media_lines); - - jd->d_timer = time(NULL); - jd->d_200Ok = NULL; - jd->d_ack = NULL; - jd->next = NULL; - jd->parent = NULL; - jd->d_out_trs = (osip_list_t*) osip_malloc(sizeof(osip_list_t)); - osip_list_init(jd->d_out_trs); - jd->d_inc_trs = (osip_list_t*) osip_malloc(sizeof(osip_list_t)); - osip_list_init(jd->d_inc_trs); - - /* jd->d_bh = sdp_handler_new(); */ - *_jd = jd; - return 0; -} - -int eXosip_dialog_init_as_uas(eXosip_dialog_t **_jd, osip_message_t *_invite, osip_message_t *_200Ok) -{ - int i; - eXosip_dialog_t *jd; - *_jd = NULL; - jd = (eXosip_dialog_t *) osip_malloc(sizeof(eXosip_dialog_t)); - jd->d_id = -1; /* not yet available to user */ - jd->d_STATE = JD_EMPTY; - i = osip_dialog_init_as_uas(&(jd->d_dialog), _invite, _200Ok); - if (i!=0) - { - osip_free(jd); - return -1; - } - - jd->media_lines = (osip_list_t*) osip_malloc(sizeof(osip_list_t)); - osip_list_init(jd->media_lines); - - jd->d_timer = time(NULL); - jd->d_200Ok = NULL; - jd->d_ack = NULL; - jd->next = NULL; - jd->parent = NULL; - jd->d_out_trs = (osip_list_t*) osip_malloc(sizeof(osip_list_t)); - osip_list_init(jd->d_out_trs); - jd->d_inc_trs = (osip_list_t*) osip_malloc(sizeof(osip_list_t)); - osip_list_init(jd->d_inc_trs); - -#ifdef SUPPORT_MSN - /* bugguy MSN */ - jd->d_dialog->local_cseq = 1; -#endif - - /* jd->d_bh = sdp_handler_new(); */ - *_jd = jd; - return 0; -} - -void eXosip_dialog_free(eXosip_dialog_t *jd) -{ - - while (!osip_list_eol(jd->d_inc_trs, 0)) - { - osip_transaction_t *tr; - tr = (osip_transaction_t*) osip_list_get(jd->d_inc_trs, 0); - osip_list_remove(jd->d_inc_trs, 0); - __eXosip_delete_jinfo(tr); - osip_list_add(eXosip.j_transactions, tr, 0); - } - - while (!osip_list_eol(jd->d_out_trs, 0)) - { - osip_transaction_t *tr; - tr = (osip_transaction_t*) osip_list_get(jd->d_out_trs, 0); - osip_list_remove(jd->d_out_trs, 0); - __eXosip_delete_jinfo(tr); - osip_list_add(eXosip.j_transactions, tr, 0); - } - - osip_message_free(jd->d_200Ok); - osip_message_free(jd->d_ack); - - osip_dialog_free(jd->d_dialog); - - while (!osip_list_eol(jd->media_lines, 0)) - { - char *tmp = osip_list_get(jd->media_lines, 0); - osip_list_remove(jd->media_lines, 0); - osip_free(tmp); - } - - osip_free(jd->media_lines); - osip_free(jd->d_out_trs); - osip_free(jd->d_inc_trs); - osip_free(jd); -} diff --git a/linphone/exosip/jevents.c b/linphone/exosip/jevents.c deleted file mode 100644 index a57efe8be..000000000 --- a/linphone/exosip/jevents.c +++ /dev/null @@ -1,949 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" -#include -#include - -extern eXosip_t eXosip; - - -static void fill_dialog_params(eXosip_event_t *je, osip_dialog_t *dialog) -{ - char *tmp; - if (dialog->remote_uri!=NULL){ - osip_to_to_str(dialog->remote_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->remote_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - if (dialog->local_uri!=NULL) - { - osip_to_to_str(dialog->local_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->local_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - if (dialog->remote_contact_uri!=NULL){ - osip_contact_to_str(dialog->remote_contact_uri,&tmp); - if (tmp!=NULL){ - snprintf(je->remote_contact,255,"%s",tmp); - osip_free(tmp); - } - } -} - -eXosip_event_t * -eXosip_event_init_for_call(int type, - eXosip_call_t *jc, - eXosip_dialog_t *jd) -{ - eXosip_event_t *je; - eXosip_event_init(&je, type); - if (je==NULL) return NULL; - je->jc = jc; - je->jd = jd; - - je->cid = jc->c_id; - if (jd!=NULL) - je->did = jd->d_id; - - je->external_reference = jc->external_reference; - - /* fill in usefull info */ - if (type==EXOSIP_CALL_NEW - || type==EXOSIP_CALL_ACK - || type==EXOSIP_CALL_NOANSWER - || type==EXOSIP_CALL_PROCEEDING - || type==EXOSIP_CALL_RINGING - || type==EXOSIP_CALL_ANSWERED - || type==EXOSIP_CALL_REDIRECTED - || type==EXOSIP_CALL_REQUESTFAILURE - || type==EXOSIP_CALL_SERVERFAILURE - || type==EXOSIP_CALL_GLOBALFAILURE - - || type==EXOSIP_OPTIONS_NOANSWER - || type==EXOSIP_OPTIONS_PROCEEDING - || type==EXOSIP_OPTIONS_ANSWERED - || type==EXOSIP_OPTIONS_REDIRECTED - || type==EXOSIP_OPTIONS_REQUESTFAILURE - || type==EXOSIP_OPTIONS_SERVERFAILURE - || type==EXOSIP_OPTIONS_GLOBALFAILURE - || type==EXOSIP_OPTIONS_NEW - - || type==EXOSIP_INFO_NOANSWER - || type==EXOSIP_INFO_PROCEEDING - || type==EXOSIP_INFO_ANSWERED - || type==EXOSIP_INFO_REDIRECTED - || type==EXOSIP_INFO_REQUESTFAILURE - || type==EXOSIP_INFO_SERVERFAILURE - || type==EXOSIP_INFO_GLOBALFAILURE - || type==EXOSIP_INFO_NEW - - || type==EXOSIP_CALL_CANCELLED - || type==EXOSIP_CALL_TIMEOUT - || type==EXOSIP_CALL_HOLD - || type==EXOSIP_CALL_OFFHOLD - || type==EXOSIP_CALL_CLOSED - || type==EXOSIP_CALL_STARTAUDIO - - || type==EXOSIP_CALL_REFERED - || type==EXOSIP_CALL_REFER_STATUS - - || type==EXOSIP_CALL_RELEASED) - { - if (jc->c_sdp_port[0]!='\0') - je->local_sdp_audio_port = osip_atoi(jc->c_sdp_port); - - if (jd!=NULL&&jd->d_dialog!=NULL) - { - osip_transaction_t *tr; - osip_header_t *subject; - char *tmp; - - fill_dialog_params(je,jd->d_dialog); - - if (type==EXOSIP_OPTIONS_NOANSWER - || type==EXOSIP_OPTIONS_PROCEEDING - || type==EXOSIP_OPTIONS_ANSWERED - || type==EXOSIP_OPTIONS_REDIRECTED - || type==EXOSIP_OPTIONS_REQUESTFAILURE - || type==EXOSIP_OPTIONS_SERVERFAILURE - || type==EXOSIP_OPTIONS_GLOBALFAILURE - || type==EXOSIP_OPTIONS_NEW) - tr = eXosip_find_last_options(jc, jd); - else if (type==EXOSIP_INFO_NOANSWER - || type==EXOSIP_INFO_PROCEEDING - || type==EXOSIP_INFO_ANSWERED - || type==EXOSIP_INFO_REDIRECTED - || type==EXOSIP_INFO_REQUESTFAILURE - || type==EXOSIP_INFO_SERVERFAILURE - || type==EXOSIP_INFO_GLOBALFAILURE - || type==EXOSIP_INFO_NEW) - tr = eXosip_find_last_info(jc, jd); - else if (type==EXOSIP_CALL_REFERED) - tr = eXosip_find_last_refer(jc, jd); - else if (type==EXOSIP_CALL_REFER_STATUS) - tr = eXosip_find_last_inc_notify_for_refer(jc, jd); - else - tr = eXosip_find_last_invite(jc, jd); - if (tr!=NULL && tr->orig_request!=NULL) - { - osip_message_get_subject(tr->orig_request, 0, &subject); - if (subject!=NULL && subject->hvalue!=NULL && subject->hvalue[0]!='\0') - snprintf(je->subject, 255, "%s", subject->hvalue); - osip_message_header_get_byname(tr->orig_request, "refer-to", 0, - &subject); - if (subject!=NULL && subject->hvalue!=NULL && subject->hvalue[0]!='\0') - snprintf(je->refer_to, 255, "%s", subject->hvalue); - - osip_uri_to_str(tr->orig_request->req_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->req_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - - }else{ - osip_transaction_t *tr; - char *tmp; - tr=eXosip_find_last_invite(jc,NULL); - /* no dialog established but we need to fill remote_contact */ - if (tr!=NULL && tr->last_response!=NULL) - { - osip_contact_t *ctt=NULL; - snprintf(je->reason_phrase, 49, "%s", tr->last_response->reason_phrase); - je->status_code = tr->last_response->status_code; - osip_message_get_contact(tr->last_response,0,&ctt); - if (ctt){ - tmp=NULL; - osip_contact_to_str(ctt,&tmp); - if (tmp){ - strncpy(je->remote_contact,tmp,255); - } - } - } - } - } - - return je; -} - -int -eXosip_event_add_status(eXosip_event_t *je, osip_message_t *response) -{ - if (response!=NULL && response->reason_phrase!=NULL) - { - snprintf(je->reason_phrase, 49, "%s", response->reason_phrase); - je->status_code = response->status_code; - } - return 0; -} - -int -eXosip_event_add_sdp_info(eXosip_event_t *je, osip_message_t *message) -{ - osip_content_type_t *ctt; - osip_mime_version_t *mv; - sdp_message_t *sdp; - osip_body_t *oldbody; - int pos; - int gotpayload = 0; - - - - /* - search for remote_sdp_audio_port & remote_sdp_audio_ip - in the last SIP message - extract the payload to be used for connection either from negotioation context - or from the last SIP message - */ - - - - if (message==NULL) return -1; - - /* get content-type info */ - ctt = osip_message_get_content_type(message); - mv = osip_message_get_mime_version(message); - if (mv==NULL && ctt==NULL) - return 0; /* previous message was not correct or empty */ - if (mv!=NULL) - { - /* look for the SDP body */ - /* ... */ - } - else if (ctt!=NULL) - { - if (ctt->type==NULL || ctt->subtype==NULL) - /* it can be application/sdp or mime... */ - return -1; - if (osip_strcasecmp(ctt->type, "application")!=0 || - osip_strcasecmp(ctt->subtype, "sdp")!=0 ) - { return -1; } - } - - - if (je->jc) - { - int pl = eXosip_retrieve_sdp_negotiation_result(je->jc->c_ctx, je->payload_name, sizeof(je->payload_name)); - if (pl >= 0) - { - je->payload = pl; - gotpayload = 1; - } - } - - - sdp = NULL; - pos = 0; - while (!osip_list_eol(message->bodies, pos)) - { - int i; - oldbody = (osip_body_t *)osip_list_get(message->bodies, pos); - pos++; - sdp_message_init(&sdp); - i = sdp_message_parse(sdp,oldbody->body); - if (i==0) - { - int len = strlen(oldbody->body); - if (len<999) - osip_strncpy(je->sdp_body, oldbody->body, len); - else - osip_strncpy(je->sdp_body, oldbody->body, 999); - - break; - } - sdp_message_free(sdp); - sdp = NULL; - } - - - - if (sdp!=NULL) - { - int j=0; - if (sdp->c_connection !=NULL - && sdp->c_connection->c_addr !=NULL ) - { - snprintf(je->remote_sdp_audio_ip, 49, "%s", - sdp->c_connection->c_addr); - } - - - for (j=0; !osip_list_eol(sdp->m_medias, j); j++) - { - sdp_media_t *med = (sdp_media_t*) osip_list_get(sdp->m_medias, j); - if (med==NULL) - { - snprintf(je->remote_sdp_audio_ip, 49, "Y a probleme!"); - } - - if (med->m_media!=NULL && - 0==osip_strcasecmp(med->m_media, "audio")) - { - sdp_connection_t *conn; - int pos_attr; - char *payload = (char *) osip_list_get (med->m_payloads, 0); - - if (!gotpayload) - je->payload = 0; - - if (!gotpayload && payload!=NULL) - { - je->payload = osip_atoi(payload); - /* copy payload name! */ - for (pos_attr=0; - !osip_list_eol(med->a_attributes, pos_attr); - pos_attr++) - { - sdp_attribute_t *attr; - attr = (sdp_attribute_t *)osip_list_get(med->a_attributes, pos_attr); - if (0==osip_strncasecmp(attr->a_att_field, "rtpmap", 6)) - { - if ((je->payload<10 && - 0==osip_strncasecmp(attr->a_att_value, payload, 1)) - ||(je->payload>9 && je->payload<100 && - 0==osip_strncasecmp(attr->a_att_value, payload, 2)) - ||(je->payload>100 && je->payload<128 && - 0==osip_strncasecmp(attr->a_att_value, payload, 3))) - { - snprintf(je->payload_name, 49, "%s", attr->a_att_value); - } - } - } - } - - - je->remote_sdp_audio_port = osip_atoi(med->m_port); - conn = (sdp_connection_t*) osip_list_get(med->c_connections, 0); - if (conn!=NULL && conn->c_addr!=NULL) - { - snprintf(je->remote_sdp_audio_ip, 49, "%s", - conn->c_addr); - } - sdp_message_free(sdp); - return 0; - } - } - sdp_message_free(sdp); - } - return -1; -} - - -eXosip_event_t * -eXosip_event_init_for_subscribe(int type, - eXosip_subscribe_t *js, - eXosip_dialog_t *jd) -{ - char *tmp; - eXosip_event_t *je; - eXosip_event_init(&je, type); - if (je==NULL) return NULL; - je->js = js; - je->jd = jd; - - je->sid = js->s_id; - if (jd!=NULL) - je->did = jd->d_id; - - je->ss_status = js->s_ss_status; - je->online_status = js->s_online_status; - je->ss_reason = js->s_ss_reason; - - /* je->external_reference = js->external_reference; */ - - if (jd!=NULL&&jd->d_dialog!=NULL) - { - fill_dialog_params(je,jd->d_dialog); - } - - /* fill in usefull info */ - if (type==EXOSIP_SUBSCRIPTION_NEW - || type==EXOSIP_SUBSCRIPTION_NOANSWER - || type==EXOSIP_SUBSCRIPTION_PROCEEDING - || type==EXOSIP_SUBSCRIPTION_ANSWERED - || type==EXOSIP_SUBSCRIPTION_REDIRECTED - || type==EXOSIP_SUBSCRIPTION_REQUESTFAILURE - || type==EXOSIP_SUBSCRIPTION_SERVERFAILURE - || type==EXOSIP_SUBSCRIPTION_GLOBALFAILURE - || type==EXOSIP_SUBSCRIPTION_RELEASED) - { - if (jd!=NULL&&jd->d_dialog!=NULL) - { - osip_transaction_t *tr; - tr = eXosip_find_last_out_subscribe(js, jd); - if (tr!=NULL && tr->orig_request!=NULL) - { - osip_uri_to_str(tr->orig_request->req_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->req_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - if (tr!=NULL && tr->last_response!=NULL) - { - snprintf(je->reason_phrase, 49, "%s", tr->last_response->reason_phrase); - je->status_code = tr->last_response->status_code; - } - } - } - else if (type==EXOSIP_SUBSCRIPTION_NOTIFY) - { - if (jd!=NULL&&jd->d_dialog!=NULL) - { - osip_transaction_t *tr; - tr = eXosip_find_last_inc_notify(js, jd); - if (tr!=NULL && tr->orig_request!=NULL) - { - osip_uri_to_str(tr->orig_request->req_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->req_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - if (tr!=NULL && tr->last_response!=NULL) - { - snprintf(je->reason_phrase, 49, "%s", tr->last_response->reason_phrase); - je->status_code = tr->last_response->status_code; - } - } - } - - return je; -} - -eXosip_event_t * -eXosip_event_init_for_notify(int type, - eXosip_notify_t *jn, - eXosip_dialog_t *jd) -{ - eXosip_event_t *je; - eXosip_event_init(&je, type); - if (je==NULL) return NULL; - je->jn = jn; - je->jd = jd; - - je->nid = jn->n_id; - if (jd!=NULL) - je->did = jd->d_id; - - je->ss_status = jn->n_ss_status; - je->online_status = jn->n_online_status; - je->ss_reason = jn->n_ss_reason; - - /*je->external_reference = jc->external_reference; */ - - /* fill in usefull info */ - if (type==EXOSIP_IN_SUBSCRIPTION_NEW - || type==EXOSIP_IN_SUBSCRIPTION_RELEASED) - { - if (jd!=NULL&&jd->d_dialog!=NULL) - { - osip_transaction_t *tr; - char *tmp; - fill_dialog_params(je,jd->d_dialog); - tr = eXosip_find_last_inc_subscribe(jn, jd); - if (tr!=NULL && tr->orig_request!=NULL) - { - osip_uri_to_str(tr->orig_request->req_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->req_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - if (tr!=NULL && tr->last_response!=NULL) - { - snprintf(je->reason_phrase, 49, "%s", tr->last_response->reason_phrase); - je->status_code = tr->last_response->status_code; - } - } - } - - return je; -} - -eXosip_event_t * -eXosip_event_init_for_reg(int type, - eXosip_reg_t *jr) -{ - eXosip_event_t *je; - eXosip_event_init(&je, type); - if (je==NULL) return NULL; - je->jr = jr; - je->rid = jr->r_id; - snprintf(je->remote_uri, 255, "%s", jr->r_aor); - snprintf(je->req_uri, 255, "%s", jr->r_registrar); - return je; -} - -eXosip_event_t * -eXosip_event_init_for_message(int type, osip_transaction_t *tr, - osip_message_t *sip) -{ - eXosip_event_t *je; - eXosip_event_init(&je, type); - if (je==NULL) return NULL; - - /* fill in usefull info */ - { - char *tmp; - - /* Request URI */ - - osip_uri_to_str(sip->req_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->req_uri, 255, "%s", tmp); - osip_free(tmp); - } - - /* FROM & TO */ - - - if (sip->from != NULL) - { - osip_from_to_str(sip->from, &tmp); - if (tmp!=NULL) - { - snprintf(je->remote_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - if (sip->to != NULL) - { - osip_to_to_str(sip->to, &tmp); - if (tmp!=NULL) - { - snprintf(je->local_uri, 255, "%s", tmp); - osip_free(tmp); - } - } - } - - return je; -} - -int -eXosip_event_init(eXosip_event_t **je, int type) -{ - *je = (eXosip_event_t *) osip_malloc(sizeof(eXosip_event_t)); - if (*je==NULL) return -1; - - memset(*je, 0, sizeof(eXosip_event_t)); - (*je)->type = type; - - if (type==EXOSIP_CALL_NOANSWER) - { - sprintf((*je)->textinfo, "No answer for this Call!"); - } - else if (type==EXOSIP_CALL_PROCEEDING) - { - sprintf((*je)->textinfo, "Call is being processed!"); - } - else if (type==EXOSIP_CALL_RINGING) - { - sprintf((*je)->textinfo, "Remote phone is ringing!"); - } - else if (type==EXOSIP_CALL_ANSWERED) - { - sprintf((*je)->textinfo, "Remote phone has answered!"); - } - else if (type==EXOSIP_CALL_REDIRECTED) - { - sprintf((*je)->textinfo, "Call is redirected!"); - } - else if (type==EXOSIP_CALL_REQUESTFAILURE) - { - sprintf((*je)->textinfo, "4xx received for Call!"); - } - else if (type==EXOSIP_CALL_SERVERFAILURE) - { - sprintf((*je)->textinfo, "5xx received for Call!"); - } - else if (type==EXOSIP_CALL_GLOBALFAILURE) - { - sprintf((*je)->textinfo, "6xx received for Call!"); - } - else if (type==EXOSIP_CALL_NEW) - { - sprintf((*je)->textinfo, "New call received!"); - } - else if (type==EXOSIP_CALL_ACK) - { - sprintf((*je)->textinfo, "ACK received!"); - } - else if (type==EXOSIP_CALL_CANCELLED) - { - sprintf((*je)->textinfo, "Call has been cancelled!"); - } - else if (type==EXOSIP_CALL_TIMEOUT) - { - sprintf((*je)->textinfo, "Timeout. Gived up!"); - } - else if (type==EXOSIP_CALL_HOLD) - { - sprintf((*je)->textinfo, "Call is on Hold!"); - } - else if (type==EXOSIP_CALL_OFFHOLD) - { - sprintf((*je)->textinfo, "Call is off Hold!"); - } - else if (type==EXOSIP_CALL_CLOSED) - { - sprintf((*je)->textinfo, "Bye Received!"); - } - else if (type==EXOSIP_CALL_RELEASED) - { - sprintf((*je)->textinfo, "Call Context is released!"); - } - else if (type==EXOSIP_REGISTRATION_SUCCESS) - { - sprintf((*je)->textinfo, "User is successfully registred!"); - } - else if (type==EXOSIP_REGISTRATION_FAILURE) - { - sprintf((*je)->textinfo, "Registration failed!"); - } - else if (type==EXOSIP_OPTIONS_NEW) - { - sprintf((*je)->textinfo, "New OPTIONS received!"); - } - else if (type==EXOSIP_OPTIONS_NOANSWER) - { - sprintf((*je)->textinfo, "No answer for this OPTIONS!"); - } - else if (type==EXOSIP_OPTIONS_PROCEEDING) - { - sprintf((*je)->textinfo, "OPTIONS is being processed!"); - } - else if (type==EXOSIP_OPTIONS_ANSWERED) - { - sprintf((*je)->textinfo, "2xx received for OPTIONS!"); - } - else if (type==EXOSIP_OPTIONS_REDIRECTED) - { - sprintf((*je)->textinfo, "3xx received for OPTIONS!"); - } - else if (type==EXOSIP_OPTIONS_REQUESTFAILURE) - { - sprintf((*je)->textinfo, "4xx received for OPTIONS!"); - } - else if (type==EXOSIP_OPTIONS_SERVERFAILURE) - { - sprintf((*je)->textinfo, "5xx received for OPTIONS!"); - } - else if (type==EXOSIP_OPTIONS_GLOBALFAILURE) - { - sprintf((*je)->textinfo, "5xx received for OPTIONS!"); - } - else if (type==EXOSIP_INFO_NEW) - { - sprintf((*je)->textinfo, "New INFO received!"); - } - else if (type==EXOSIP_INFO_NOANSWER) - { - sprintf((*je)->textinfo, "No answer for this INFO!"); - } - else if (type==EXOSIP_INFO_PROCEEDING) - { - sprintf((*je)->textinfo, "INFO is being processed!"); - } - else if (type==EXOSIP_INFO_ANSWERED) - { - sprintf((*je)->textinfo, "2xx received for INFO!"); - } - else if (type==EXOSIP_INFO_REDIRECTED) - { - sprintf((*je)->textinfo, "3xx received for INFO!"); - } - else if (type==EXOSIP_INFO_REQUESTFAILURE) - { - sprintf((*je)->textinfo, "4xx received for INFO!"); - } - else if (type==EXOSIP_INFO_SERVERFAILURE) - { - sprintf((*je)->textinfo, "5xx received for INFO!"); - } - else if (type==EXOSIP_INFO_GLOBALFAILURE) - { - sprintf((*je)->textinfo, "6xx received for INFO!"); - } - else if (type==EXOSIP_MESSAGE_NEW) - { - sprintf((*je)->textinfo, "New MESSAGE received!"); - } - else if (type==EXOSIP_MESSAGE_SUCCESS) - { - sprintf((*je)->textinfo, "User has successfully received our MESSAGE!"); - } - else if (type==EXOSIP_MESSAGE_FAILURE) - { - sprintf((*je)->textinfo, "Error received for our MESSAGE!"); - } - else if (type==EXOSIP_SUBSCRIPTION_NEW) - { - sprintf((*je)->textinfo, "New SUBSCRIBE received!"); - } - else if (type==EXOSIP_SUBSCRIPTION_NOANSWER) - { - sprintf((*je)->textinfo, "No answer for this SUBSCRIBE!"); - } - else if (type==EXOSIP_SUBSCRIPTION_PROCEEDING) - { - sprintf((*je)->textinfo, "SUBSCRIBE is being processed!"); - } - else if (type==EXOSIP_SUBSCRIPTION_ANSWERED) - { - sprintf((*je)->textinfo, "2xx received for SUBSCRIBE!"); - } - else if (type==EXOSIP_SUBSCRIPTION_REDIRECTED) - { - sprintf((*je)->textinfo, "3xx received for SUBSCRIBE!"); - } - else if (type==EXOSIP_SUBSCRIPTION_REQUESTFAILURE) - { - sprintf((*je)->textinfo, "4xx received for SUBSCRIBE!"); - } - else if (type==EXOSIP_SUBSCRIPTION_SERVERFAILURE) - { - sprintf((*je)->textinfo, "5xx received for SUBSCRIBE!"); - } - else if (type==EXOSIP_SUBSCRIPTION_GLOBALFAILURE) - { - sprintf((*je)->textinfo, "5xx received for SUBSCRIBE!"); - } - else if (type==EXOSIP_SUBSCRIPTION_NOTIFY) - { - sprintf((*je)->textinfo, "NOTIFY request for subscription!"); - } - else if (type==EXOSIP_SUBSCRIPTION_RELEASED) - { - sprintf((*je)->textinfo, "Subscription has terminate!"); - } - else if (type==EXOSIP_IN_SUBSCRIPTION_NEW) - { - sprintf((*je)->textinfo, "New incoming SUBSCRIBE!"); - } - else if (type==EXOSIP_IN_SUBSCRIPTION_RELEASED) - { - sprintf((*je)->textinfo, "Incoming Subscription has terminate!"); - } - else - { - (*je)->textinfo[0] = '\0'; - } - return 0; -} - -void -eXosip_event_free(eXosip_event_t *je) -{ - if (je==NULL) return; - if (je->i_ctt!=NULL) - osip_content_type_free(je->i_ctt); - if (je->i_bodies!=NULL) - { - int pos; - for (pos=0;!osip_list_eol(je->i_bodies, pos);) - { - osip_body_t *body; - body = (osip_body_t *)osip_list_get(je->i_bodies, pos); - osip_list_remove(je->i_bodies, pos); - osip_body_free(body); - } - } - osip_free(je); -} - -eXosip_call_t * -eXosip_event_get_callinfo(eXosip_event_t *je) -{ - return je->jc; -} - -eXosip_dialog_t * -eXosip_event_get_dialoginfo(eXosip_event_t *je) -{ - return je->jd; -} - -eXosip_reg_t * -eXosip_event_get_reginfo(eXosip_event_t *je) -{ - return je->jr; -} - -eXosip_notify_t * -eXosip_event_get_notifyinfo(eXosip_event_t *je) -{ - return je->jn; -} - -eXosip_subscribe_t * -eXosip_event_get_subscribeinfo(eXosip_event_t *je) -{ - return je->js; -} - -int -eXosip_event_add(eXosip_event_t *je) -{ - int i = osip_fifo_add(eXosip.j_events, (void *) je); - osip_cond_signal((struct osip_cond *)eXosip.j_cond); - __eXosip_wakeup_event(); - return i; -} - -#if 0 -#ifdef CLOCK_REALTIME -/* if CLOCK_REALTIME exist, then clock_gettime should be defined */ - -#define OSIP_CLOCK_REALTIME CLOCK_REALTIME - -void -__eXosip_clock_gettime(clockid_t cid, struct timespec *time) -{ - clock_gettime(cid, time); -} - -#elif defined (WIN32) || defined (_WIN32_WCE) - -#include -#include - -#define OSIP_CLOCK_REALTIME 4002 - -void -__eXosip_clock_gettime(unsigned int clock_id, struct timespec *time) -{ - struct _timeb time_val; - - if (clock_id != OSIP_CLOCK_REALTIME) - return; - - _ftime (&time_val); - time->tv_sec = time_val.time; - time->tv_nsec = time_val.millitm * 1000000; - return; -} -#endif -#endif - -eXosip_event_t * -eXosip_event_wait(int tv_s, int tv_ms) -{ - eXosip_event_t *je = NULL; - -#if 0 /* this does not seems to work. by now */ -#if defined (CLOCK_REALTIME) || defined (WIN32) || defined (_WIN32_WCE) - int i; - - struct timespec deadline; - struct timespec interval; - long tot_ms = (tv_s*1000) + tv_ms; - - static struct osip_mutex *mlock = NULL; - - if (mlock==NULL) mlock = osip_mutex_init(); - - je = (eXosip_event_t *) osip_fifo_tryget(eXosip.j_events); - if(je) return je; - - interval.tv_sec = tot_ms / 1000; - interval.tv_nsec = (tot_ms % 1000) * 1000000L; - - __eXosip_clock_gettime(OSIP_CLOCK_REALTIME, &deadline); - - if ((deadline.tv_nsec += interval.tv_nsec) >= 1000000000L) - { - deadline.tv_nsec -= 1000000000L; - deadline.tv_sec += 1; - } - else - deadline.tv_nsec += interval.tv_nsec; - - deadline.tv_sec += interval.tv_sec; - - i = osip_cond_timedwait ((struct osip_cond *)eXosip.j_cond, - (struct osip_mutex *)mlock, - &deadline); - -#endif -#else - /* basic replacement */ - { - fd_set fdset; - struct timeval tv; - int max, i; - FD_ZERO(&fdset); -#if defined (WIN32) || defined (_WIN32_WCE) - FD_SET((unsigned int)jpipe_get_read_descr(eXosip.j_socketctl_event), &fdset); -#else - FD_SET(jpipe_get_read_descr(eXosip.j_socketctl_event), &fdset); -#endif - max = jpipe_get_read_descr(eXosip.j_socketctl_event); - tv.tv_sec = tv_s; - tv.tv_usec = tv_ms*1000; - - je = (eXosip_event_t *) osip_fifo_tryget(eXosip.j_events); - if (je!=NULL) return je; - - if (tv_s==0 && tv_ms==0) - return NULL; - - i = select(max+1, &fdset, NULL, NULL, &tv); - if (i <= 0) - return 0; - - if (FD_ISSET (jpipe_get_read_descr(eXosip.j_socketctl_event), &fdset)) - { - char buf[500]; - jpipe_read (eXosip.j_socketctl_event, buf, 499); - } - - je = (eXosip_event_t *) osip_fifo_tryget(eXosip.j_events); - if (je!=NULL) return je; - } -#endif - - return je; -} - -eXosip_event_t * -eXosip_event_get() -{ - eXosip_event_t *je; - je = (eXosip_event_t *) osip_fifo_get(eXosip.j_events); - return je; -} diff --git a/linphone/exosip/jfreinds.c b/linphone/exosip/jfreinds.c deleted file mode 100644 index 0f546cef7..000000000 --- a/linphone/exosip/jfreinds.c +++ /dev/null @@ -1,311 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" -#include - -extern eXosip_t eXosip; - -#ifndef EXOSIP_ETC_DIR -#define EXOSIP_ETC_DIR ".eXosip" -#endif - -#ifndef EXOSIP_ADDFRIENDS_SH -#define EXOSIP_ADDFRIENDS_SH "eXosip_addfriend.sh" -#endif - - -static int jfriend_init(jfriend_t **fr, char *ch) -{ - char *next; - int i; - - *fr = (jfriend_t *)osip_malloc(sizeof(jfriend_t)); - if (*fr==NULL) return -1; - - i = jfriend_get_and_set_next_token(&((*fr)->f_nick), ch, &next); - if (i != 0) - goto jf_error1; - osip_clrspace ((*fr)->f_nick); - ch = next; - - i = jfriend_get_and_set_next_token(&((*fr)->f_home), next, &next); - if (i != 0) - goto jf_error2; - osip_clrspace ((*fr)->f_home); - ch = next; - - i = jfriend_get_and_set_next_token(&((*fr)->f_work), ch, &next); - if (i != 0) - goto jf_error3; - osip_clrspace ((*fr)->f_work); - ch = next; - - i = jfriend_get_and_set_next_token(&((*fr)->f_email), ch, &next); - if (i != 0) - goto jf_error4; - osip_clrspace ((*fr)->f_email); - - (*fr)->f_e164 = osip_strdup(next); - osip_clrspace ((*fr)->f_e164); - - return 0; - - jf_error4: - osip_free((*fr)->f_work); - jf_error3: - osip_free((*fr)->f_home); - jf_error2: - osip_free((*fr)->f_nick); - jf_error1: - osip_free(*fr); - *fr = NULL; - return -1; -} - -int -jfriend_get_and_set_next_token (char **dest, char *buf, char **next) -{ - char *end; - char *start; - - *next = NULL; - - /* find first non space and tab element */ - start = buf; - while (((*start == ' ') || (*start == '\t')) && (*start != '\0') - && (*start != '\r') && (*start != '\n') ) - start++; - end = start+1; - while ((*end != '\0') && (*end != '\r') && (*end != '\n') - && (*end != '\t') && (*end != '|')) - end++; - - if ((*end == '\r') || (*end == '\n')) - /* we should continue normally only if this is the separator asked! */ - return -1; - if (end == start) - return -1; /* empty value (or several space!) */ - - *dest = osip_malloc (end - (start) + 1); - osip_strncpy (*dest, start, end - start); - - *next = end + 1; /* return the position right after the separator - */ - return 0; -} - -void __jfriend_remove(char *nickname, char *home) -{ - char *Home; - char command[256]; - char *tmp = command; - int length = 0; - if (nickname!=NULL) - length = strlen(nickname); - - Home = getenv("HOME"); - if (Home==NULL) - return; - length = length + strlen(Home); - osip_clrspace(nickname); - osip_clrspace(home); - - if (home!=NULL) - length = length + strlen(home); - else - return; /* MUST be set */ - length = length + strlen(EXOSIP_ETC_DIR); - - length = length + strlen("/jm_contact"); - if (length>235) /* leave some room for SPACEs and \r\n */ - return ; - - sprintf(tmp , "%s %s/%s/jm_contact", EXOSIP_ADDFRIENDS_SH, - Home, EXOSIP_ETC_DIR); - - tmp = tmp + strlen(tmp); - if (nickname!=NULL) - sprintf(tmp , " %s", nickname); - else - sprintf(tmp , " \"\""); - - tmp = tmp + strlen(tmp); - if (home!=NULL) - sprintf(tmp , " %s", home); - else - sprintf(tmp , " \"\""); - - sprintf(tmp , "delete"); - - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "%s", command)); - system(command); -} - -void jfriend_add(char *nickname, char *home, - char *work, char *email, char *e164) -{ - char *Home; - char command[256]; - char *tmp = command; - int length = 0; - if (nickname!=NULL) - length = strlen(nickname); - - Home = getenv("HOME"); - if (Home==NULL) - return; - length = length + strlen(Home); - - osip_clrspace(nickname); - osip_clrspace(home); - osip_clrspace(work); - osip_clrspace(email); - osip_clrspace(e164); - - if (home!=NULL) - length = length + strlen(home); - else - return; /* MUST be set */ - if (work!=NULL) - length = length + strlen(work); - if (email!=NULL) - length = length + strlen(email); - if (e164!=NULL) - length = length + strlen(e164); - length = length + strlen(EXOSIP_ETC_DIR); - - length = length + strlen("/jm_contact"); - if (length>235) /* leave some room for SPACEs and \r\n */ - return ; - - sprintf(tmp , "%s %s/%s/jm_contact", EXOSIP_ADDFRIENDS_SH, - Home, EXOSIP_ETC_DIR); - - tmp = tmp + strlen(tmp); - if (nickname!=NULL) - sprintf(tmp , " %s", nickname); - else - sprintf(tmp , " \"\""); - - tmp = tmp + strlen(tmp); - if (home!=NULL) - sprintf(tmp , " %s", home); - else - sprintf(tmp , " \"\""); - - tmp = tmp + strlen(tmp); - if (work!=NULL) - sprintf(tmp , " %s", work); - else - sprintf(tmp , " \"\""); - - tmp = tmp + strlen(tmp); - if (email!=NULL) - sprintf(tmp , " %s", email); - else - sprintf(tmp , " \"\""); - - tmp = tmp + strlen(tmp); - if (e164!=NULL) - sprintf(tmp , " %s", e164); - else - sprintf(tmp , " \"\""); - - /* fprintf(stderr, "%s", command); */ - system(command); -} - -void -jfriend_unload() -{ - jfriend_t *fr; - if (eXosip.j_friends==NULL) return; - for (fr=eXosip.j_friends; fr!=NULL; fr=eXosip.j_friends) - { - REMOVE_ELEMENT(eXosip.j_friends,fr); - osip_free(fr->f_nick); - osip_free(fr->f_home); - osip_free(fr->f_work); - osip_free(fr->f_email); - osip_free(fr->f_e164); - osip_free(fr); - } - - osip_free(eXosip.j_friends); - eXosip.j_friends=NULL; - return; -} - -int -jfriend_load() -{ - FILE *file; - char *s; - jfriend_t *fr; - int pos; - char *home; - char filename[255]; - - jfriend_unload(); - home = getenv("HOME"); - sprintf(filename, "%s/%s/%s", home, EXOSIP_ETC_DIR, "jm_contact"); - - file = fopen(filename, "r"); - if (file==NULL) return -1; - s = (char *)osip_malloc(255*sizeof(char)); - pos = 0; - while (NULL!=fgets(s, 254, file)) - { - char *tmp = s; - while (*tmp!='\0' && *tmp!=' ') tmp++; - while (*tmp!='\0' && *tmp==' ') tmp++; - while (*tmp!='\0' && *tmp!=' ') tmp++; - tmp++; /* first usefull characters */ - pos++; - - jfriend_init(&fr, tmp); - if (fr!=NULL) - { ADD_ELEMENT(eXosip.j_friends, fr); } - } - osip_free(s); - fclose(file); - - return 0; /* ok */ -} - -char * -jfriend_get_home(int fid) -{ - jfriend_t *fr; - for (fr = eXosip.j_friends; fr!=NULL ; fr=fr->next) - { - if (fid==0) - return osip_strdup(fr->f_home); - fid--; - } - return NULL; -} diff --git a/linphone/exosip/jidentity.c b/linphone/exosip/jidentity.c deleted file mode 100644 index 96191e65e..000000000 --- a/linphone/exosip/jidentity.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" -#include - -extern eXosip_t eXosip; - -#ifndef EXOSIP_ETC_DIR -#define EXOSIP_ETC_DIR ".eXosip" -#endif - - -#ifndef EXOSIP_ADDIDENTITYS_SH -#define EXOSIP_ADDIDENTITYS_SH "eXosip_addidentity.sh" -#endif - -static int -jidentity_get_and_set_next_token (char **dest, char *buf, char **next) -{ - char *end; - char *start; - - *next = NULL; - - /* find first non space and tab element */ - start = buf; - while (((*start == ' ') || (*start == '\t')) && (*start != '\0') - && (*start != '\r') && (*start != '\n') ) - start++; - end = start+1; - while ((*end != '\0') && (*end != '\r') && (*end != '\n') - && (*end != '\t') && (*end != '|')) - end++; - - if ((*end == '\r') || (*end == '\n')) - /* we should continue normally only if this is the separator asked! */ - return -1; - if (end == start) - return -1; /* empty value (or several space!) */ - - *dest = osip_malloc (end - (start) + 1); - osip_strncpy (*dest, start, end - start); - - *next = end + 1; /* return the position right after the separator - */ - return 0; -} - -static int jidentity_init(jidentity_t **fr, char *ch) -{ - char *next; - int i; - - *fr = (jidentity_t *)osip_malloc(sizeof(jidentity_t)); - if (*fr==NULL) return -1; - - i = jidentity_get_and_set_next_token(&((*fr)->i_identity), ch, &next); - if (i != 0) - goto ji_error1; - osip_clrspace ((*fr)->i_identity); - ch = next; - - i = jidentity_get_and_set_next_token(&((*fr)->i_registrar), next, &next); - if (i != 0) - goto ji_error2; - osip_clrspace ((*fr)->i_registrar); - ch = next; - - i = jidentity_get_and_set_next_token(&((*fr)->i_realm), ch, &next); - if (i != 0) - goto ji_error3; - osip_clrspace ((*fr)->i_realm); - ch = next; - - i = jidentity_get_and_set_next_token(&((*fr)->i_userid), ch, &next); - if (i != 0) - goto ji_error4; - osip_clrspace ((*fr)->i_userid); - - (*fr)->i_pwd = osip_strdup(next); - osip_clrspace ((*fr)->i_pwd); - - if ((*fr)->i_pwd!=NULL && (*fr)->i_pwd[0]!='\0') - { - eXosip_add_authentication_info((*fr)->i_userid, (*fr)->i_userid, - (*fr)->i_pwd, NULL, - (*fr)->i_realm); - } - return 0; - - ji_error4: - osip_free((*fr)->i_realm); - ji_error3: - osip_free((*fr)->i_registrar); - ji_error2: - osip_free((*fr)->i_identity); - ji_error1: - osip_free(*fr); - *fr = NULL; - return -1; -} - -void identitys_add(char *identity, char *registrar, - char *realm, char *userid, char *pwd) -{ - char command[256]; - char *tmp = command; - char *home; - - int length = 0; - if (identity==NULL) - return ; - if (registrar==NULL) - return ; - - if (realm!=NULL && *realm=='\0') - realm = NULL; - if (userid!=NULL && *userid=='\0') - userid = NULL; - if (pwd!=NULL && *pwd=='\0') - pwd = NULL; - - length = strlen(identity) +3; - length = length + strlen(registrar) +3; - - if (realm!=NULL && userid!=NULL && pwd!=NULL) - { - length = length + strlen(realm) +3; - length = length + strlen(userid) +3; - length = length + strlen(pwd) +3; - } - else if (realm==NULL && userid==NULL && pwd==NULL) - {} - else - return ; - - home = getenv("HOME"); - length = length + strlen(home); - length = length + strlen(EXOSIP_ETC_DIR) + 3; - length = length + strlen("/jm_identity") + 1; - - if (length>235) /* leave some room for SPACEs and \r\n */ - return ; - - sprintf(tmp , "%s \"%s/%s/jm_identity\"", EXOSIP_ADDIDENTITYS_SH, - home, EXOSIP_ETC_DIR); - tmp = tmp + strlen(tmp); - sprintf(tmp , " \"%s\"", identity); - tmp = tmp + strlen(tmp); - sprintf(tmp , " \"%s\"", registrar); - tmp = tmp + strlen(tmp); - - if (realm!=NULL && userid!=NULL && pwd!=NULL) - { - sprintf(tmp , " \"%s\"", realm); - tmp = tmp + strlen(tmp); - sprintf(tmp , " \"%s\"", userid); - tmp = tmp + strlen(tmp); - sprintf(tmp , " \"%s\"", pwd); - } - else if (realm==NULL && userid==NULL && pwd==NULL) - { - sprintf(tmp , " \"\""); - tmp = tmp + strlen(tmp); - sprintf(tmp , " \"\""); - tmp = tmp + strlen(tmp); - sprintf(tmp , " \"\""); - } - - system(command); -} - -void -jidentity_unload() -{ - jidentity_t *fr; - if (eXosip.j_identitys==NULL) return; - for (fr=eXosip.j_identitys; fr!=NULL; fr=eXosip.j_identitys) - { - REMOVE_ELEMENT(eXosip.j_identitys,fr); - osip_free(fr->i_identity); - osip_free(fr->i_registrar); - osip_free(fr->i_realm); - osip_free(fr->i_userid); - osip_free(fr->i_pwd); - osip_free(fr); - } - - osip_free(eXosip.j_identitys); - eXosip.j_identitys=NULL; - return; -} - -int -jidentity_load() -{ - FILE *file; - char *s; - jidentity_t *fr; - int pos; - char *home; - char filename[255]; - jidentity_unload(); - - home = getenv("HOME"); - sprintf(filename, "%s/%s/%s", home, EXOSIP_ETC_DIR, "jm_identity"); - - file = fopen(filename, "r"); - if (file==NULL) return -1; - s = (char *)osip_malloc(255*sizeof(char)); - pos = 0; - while (NULL!=fgets(s, 254, file)) - { - char *tmp = s; - while (*tmp!='\0' && *tmp!=' ') tmp++; - while (*tmp!='\0' && *tmp==' ') tmp++; - while (*tmp!='\0' && *tmp!=' ') tmp++; - tmp++; /* first usefull characters */ - pos++; - - jidentity_init(&fr, tmp); - if (fr!=NULL) - { ADD_ELEMENT(eXosip.j_identitys, fr); } - } - osip_free(s); - fclose(file); - - return 0; /* ok */ -} - -char * -jidentity_get_registrar(int fid) -{ - jidentity_t *fr; - for (fr = eXosip.j_identitys; fr!=NULL ; fr=fr->next) - { - if (fid==0) - return osip_strdup(fr->i_registrar); - fid--; - } - return NULL; -} - -char * -jidentity_get_identity(int fid) -{ - jidentity_t *fr; - for (fr = eXosip.j_identitys; fr!=NULL ; fr=fr->next) - { - if (fid==0) - return osip_strdup(fr->i_identity); - fid--; - } - return NULL; -} diff --git a/linphone/exosip/jnotify.c b/linphone/exosip/jnotify.c deleted file mode 100644 index f784ed884..000000000 --- a/linphone/exosip/jnotify.c +++ /dev/null @@ -1,528 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - - -#include "eXosip2.h" -#include - -extern eXosip_t eXosip; - -#if 0 -int eXosip_notify_find(int sid, eXosip_notify_t **jn) -{ - for (*jn=eXosip.j_notifies; *jn!=NULL; *jn=(*jn)->next) - { - if ((*jn)->n_id==sid) - return 0; - } - *jn = NULL; - return -1; -} -#endif - -osip_transaction_t * -eXosip_find_last_inc_subscribe(eXosip_notify_t *jn, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - int pos; - inc_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_inc_trs, pos)) - { - inc_tr = osip_list_get(jd->d_inc_trs, pos); - if (0==strcmp(inc_tr->cseq->method, "SUBSCRIBE")) - break; - else inc_tr = NULL; - pos++; - } - } - else - inc_tr = NULL; - - if (inc_tr==NULL) - return jn->n_inc_tr; /* can be NULL */ - - return inc_tr; -} - - -osip_transaction_t * -eXosip_find_last_out_notify(eXosip_notify_t *jn, eXosip_dialog_t *jd ) -{ - osip_transaction_t *out_tr; - int pos; - out_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (0==strcmp(out_tr->cseq->method, "NOTIFY")) - return out_tr; - pos++; - } - } - - return NULL; -} - -int -eXosip_notify_init(eXosip_notify_t **jn, osip_message_t *inc_subscribe) -{ - osip_contact_t *co; - char *uri; - int i; -#ifdef SM - char *locip; - eXosip_get_localip_from_via(inc_subscribe,&locip); -#else - char locip[50]; - eXosip_guess_ip_for_via(eXosip.ip_family, locip, 49); -#endif - if (inc_subscribe==NULL - ||inc_subscribe->to==NULL - ||inc_subscribe->to->url==NULL) - return -1; - co = (osip_contact_t *) osip_list_get(inc_subscribe->contacts, 0); - if (co==NULL || co->url==NULL) - return -1; - - *jn = (eXosip_notify_t *)osip_malloc(sizeof(eXosip_notify_t)); - if (*jn == NULL) return -1; - memset(*jn, 0, sizeof(eXosip_notify_t)); - - i = osip_uri_to_str(co->url, &uri); - if (i!=0) - { - osip_free(*jn); - *jn=NULL; - return -1; - } - osip_strncpy((*jn)->n_uri, uri, 254); - osip_free(uri); - - if (inc_subscribe->to->url->username!=NULL) - { - /* SM: allocate a string instead of risking a buffer overflow */ - if (eXosip.localport==NULL) - (*jn)->n_contact_info=strdup_printf("sip:%s@%s", - inc_subscribe->to->url->username, - locip); - else - (*jn)->n_contact_info= strdup_printf("sip:%s@%s:%s", - inc_subscribe->to->url->username, - locip, eXosip.localport); - } - else - { - if (eXosip.localport==NULL) - (*jn)->n_contact_info=strdup_printf("sip:%s", locip); - else - (*jn)->n_contact_info=strdup_printf("sip:%s:%s", locip, - eXosip.localport); - } - -#ifdef SM - osip_free(locip); -#endif - return 0; -} - -#if 0 -void -__eXosip_notify_remove_dialog_reference_in_notify(eXosip_notify_t *jn, eXosip_dialog_t *jd) -{ - eXosip_dialog_t *_jd; - jinfo_t *ji; - if (jn==NULL) return; - if (jd==NULL) return; - - for (_jd = jn->n_dialogs; _jd!=NULL; _jd=jn->n_dialogs) - { - if (jd==_jd) - break; - } - if (_jd==NULL) - { - /* dialog not found??? */ - } - - ji = osip_transaction_get_your_instance(jn->n_inc_tr); - if (ji!=NULL && ji->jd==jd) - ji->jd=NULL; - ji = osip_transaction_get_your_instance(jn->n_out_tr); - if (ji!=NULL && ji->jd==jd) - ji->jd=NULL; -} -#endif - -void -eXosip_notify_free(eXosip_notify_t *jn) -{ - /* ... */ - - eXosip_dialog_t *jd; - - for (jd = jn->n_dialogs; jd!=NULL; jd=jn->n_dialogs) - { - REMOVE_ELEMENT(jn->n_dialogs, jd); - eXosip_dialog_free(jd); - } - - __eXosip_delete_jinfo(jn->n_inc_tr); - __eXosip_delete_jinfo(jn->n_out_tr); - if (jn->n_inc_tr!=NULL) - osip_list_add(eXosip.j_transactions, jn->n_inc_tr, 0); - if (jn->n_out_tr!=NULL) - osip_list_add(eXosip.j_transactions, jn->n_out_tr, 0); - if (jn->n_contact_info!=NULL) osip_free(jn->n_contact_info); - osip_free(jn); -} - -int -_eXosip_notify_set_refresh_interval(eXosip_notify_t *jn, - osip_message_t *inc_subscribe) -{ - osip_header_t *exp; - int now; - now = time(NULL); - if (jn==NULL || inc_subscribe==NULL) - return -1; - - osip_message_get_expires(inc_subscribe, 0, &exp); - if (exp==NULL || exp->hvalue==NULL) - jn->n_ss_expires = now + 600; - else - { - jn->n_ss_expires = osip_atoi(exp->hvalue); - if (jn->n_ss_expires!=-1) - jn->n_ss_expires = now + jn->n_ss_expires; - else /* on error, set it to default */ - jn->n_ss_expires = now + 600; - } - - return 0; -} - -int -eXosip_notify_add_allowed_subscriber(char *sip_url) -{ - /* TODO */ - return -1; -} - -int -_eXosip_notify_is_a_known_subscriber(osip_message_t *sip) -{ - /* */ - return -1; -} - - -int -_eXosip_notify_add_body(eXosip_notify_t *jn, osip_message_t *notify) -{ - char buf[1000]; -#ifdef SUPPORT_MSN - int atom_id = 1000; -#endif - if (jn->n_ss_status!=EXOSIP_SUBCRSTATE_ACTIVE - || jn->n_contact_info==NULL || jn->n_contact_info=='\0') /* mandatory! */ - return 0; /* don't need a body? */ - -#ifdef SUPPORT_MSN - - if (jn->n_online_status==EXOSIP_NOTIFY_ONLINE) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -\n\ -

\n\ -\n\ -\n\ -
\n\ -\n\ -", jn->n_contact_info, atom_id, jn->n_contact_info); - - } - else if (jn->n_online_status==EXOSIP_NOTIFY_BUSY) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -\n\ -
\n\ -\n\ -\n\ -
\n\ -
\n\ -
", jn->n_contact_info, atom_id, jn->n_contact_info); - - } - else if (jn->n_online_status==EXOSIP_NOTIFY_BERIGHTBACK) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -\n\ -
\n\ -\n\ -\n\ -
\n\ -
\n\ -
", jn->n_contact_info, atom_id, jn->n_contact_info); - - } - else if (jn->n_online_status==EXOSIP_NOTIFY_AWAY) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -\n\ -
\n\ -\n\ -\n\ -
\n\ -
\n\ -
", jn->n_contact_info, atom_id, jn->n_contact_info); - - } - else if (jn->n_online_status==EXOSIP_NOTIFY_ONTHEPHONE) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -\n\ -
\n\ -\n\ -\n\ -
\n\ -
\n\ -
", jn->n_contact_info, atom_id, jn->n_contact_info); - - } - else if (jn->n_online_status==EXOSIP_NOTIFY_OUTTOLUNCH) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -\n\ -
\n\ -\n\ -\n\ -
\n\ -
\n\ -
", jn->n_contact_info, atom_id, jn->n_contact_info); - - } - else - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -\n\ -
\n\ -\n\ -\n\ -
\n\ -
\n\ -
", jn->n_contact_info, atom_id, jn->n_contact_info); - } - - osip_message_set_body(notify, buf, strlen(buf)); - osip_message_set_content_type(notify, "application/xpidf+xml"); -#else - - if (jn->n_online_status==EXOSIP_NOTIFY_ONLINE) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -open\n\ -\n\ -%s\n\ -online\n\ -\n\ -", - jn->n_contact_info, jn->n_contact_info); - } - else if (jn->n_online_status==EXOSIP_NOTIFY_BUSY) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -open\n\ -\n\ - busy\n\ -\n\ -\n\ -%s\n\ -busy\n\ -\n\ -", - jn->n_contact_info, jn->n_contact_info); - } - else if (jn->n_online_status==EXOSIP_NOTIFY_BERIGHTBACK) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -open\n\ -\n\ - in-transit\n\ -\n\ -\n\ -%s\n\ -be right back\n\ -\n\ -", - jn->n_contact_info, jn->n_contact_info); - } - else if (jn->n_online_status==EXOSIP_NOTIFY_AWAY) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -open\n\ -\n\ - away\n\ -\n\ -\n\ -%s\n\ -away\n\ -\n\ -", - jn->n_contact_info, jn->n_contact_info); - } - else if (jn->n_online_status==EXOSIP_NOTIFY_ONTHEPHONE) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -open\n\ -\n\ - on-the-phone\n\ -\n\ -\n\ -%s\n\ -on the phone\n\ -\n\ -", - jn->n_contact_info, jn->n_contact_info); - } - else if (jn->n_online_status==EXOSIP_NOTIFY_OUTTOLUNCH) - { - sprintf(buf, "\n\ -\n\ -\n\ -\n\ -open\n\ -\n\ - meal\n\ -\n\ -\n\ -%s\n\ -out to lunch\n\ -\n\ -", - jn->n_contact_info, jn->n_contact_info); - } - else - { - /* */ - sprintf(buf, "\n\ -\n%s", - jn->n_contact_info, -"\n\ -\n\ -closed\n\ -\n\ - permanent-absence\n\ -\n\ -\n\ -\n\ -\n\n"); - } - osip_message_set_body(notify, buf, strlen(buf)); - osip_message_set_content_type(notify, "application/pidf+xml"); - -#endif - - return 0; -} - -void -_eXosip_notify_add_expires_in_2XX_for_subscribe(eXosip_notify_t *jn, osip_message_t *answer) -{ - char tmp[20]; - int now; - now = time(NULL); - - if (jn->n_ss_expires-now<0) - { - tmp[0] = '0'; - tmp[1] = '\0'; - } - else - { - sprintf(tmp, "%i", jn->n_ss_expires-now); - } - osip_message_set_expires(answer, tmp); -} diff --git a/linphone/exosip/jpipe.c b/linphone/exosip/jpipe.c deleted file mode 100644 index a91987dc6..000000000 --- a/linphone/exosip/jpipe.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "jpipe.h" - -#ifndef WIN32 - -jpipe_t * jpipe () -{ - jpipe_t *my_pipe = (jpipe_t *) osip_malloc (sizeof (jpipe_t)); - if (my_pipe==NULL) return NULL; - - if (0 != pipe (my_pipe->pipes)) - { - osip_free (my_pipe); - return NULL; - } - return my_pipe; -} - -int jpipe_close (jpipe_t * apipe) -{ - if (apipe == NULL) - return -1; - close (apipe->pipes[0]); - close (apipe->pipes[1]); - osip_free (apipe); - return 0; -} - - -/** - * Write in a pipe. - */ -int -jpipe_write (jpipe_t * apipe, const void *buf, int count) -{ - if (apipe == NULL) - return -1; - return write (apipe->pipes[1], buf, count); -} - -/** - * Read in a pipe. - */ -int jpipe_read (jpipe_t * apipe, void *buf, int count) -{ - if (apipe == NULL) - return -1; - return read (apipe->pipes[0], buf, count); -} - -/** - * Get descriptor of reading pipe. - */ -int jpipe_get_read_descr (jpipe_t * apipe) -{ - if (apipe == NULL) - return -1; - return apipe->pipes[0]; -} - -#else - -jpipe_t * jpipe () -{ - int s = 0; - int timeout = 0; - static int aport = 10500; - struct sockaddr_in raddr; - int j; - - jpipe_t *my_pipe = (jpipe_t *) osip_malloc (sizeof (jpipe_t)); - if (my_pipe==NULL) - return NULL; - - s = (int) socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (0 > s) - { - osip_free (my_pipe); - return NULL; - } - my_pipe->pipes[1] = (int) socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); - if (0 > my_pipe->pipes[1]) - { - closesocket(s); - osip_free (my_pipe); - return NULL; - } - - raddr.sin_addr.s_addr = inet_addr ("127.0.0.1"); - raddr.sin_family = AF_INET; - - j = 50; - while (aport++ && j-- > 0) - { - raddr.sin_port = htons ((short) aport); - if (bind (s, (struct sockaddr *) &raddr, sizeof (raddr)) < 0) - { - OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, - "Failed to bind one local socket %i!\n", - aport)); - } - else - break; - } - - if (j == 0) - { - OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, - "Failed to bind a local socket, aborting!\n")); - closesocket (s); - closesocket (my_pipe->pipes[1]); - osip_free (my_pipe); - } - - j = listen(s,1); - if (j != 0) - { - OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, - "Failed to listen on a local socket, aborting!\n")); - closesocket(s); - closesocket(my_pipe->pipes[1]); - osip_free (my_pipe); - } - - j = setsockopt (my_pipe->pipes[1], - SOL_SOCKET, - SO_RCVTIMEO, (const char*) &timeout, sizeof (timeout)); - if (j != NO_ERROR) - { - /* failed for some reason... */ - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "udp plugin; cannot set O_NONBLOCK to the file desciptor!\n")); - closesocket(s); - closesocket(my_pipe->pipes[1]); - osip_free (my_pipe); - } - - connect (my_pipe->pipes[1], (struct sockaddr *) &raddr, sizeof (raddr)); - - my_pipe->pipes[0] = accept (s, NULL, NULL); - - if (my_pipe->pipes[0]<=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "udp plugin; Failed to call accept!\n")); - closesocket(s); - closesocket(my_pipe->pipes[1]); - osip_free (my_pipe); - } - - return my_pipe; -} - -int jpipe_close (jpipe_t * apipe) -{ - if (apipe == NULL) - return -1; - closesocket (apipe->pipes[0]); - closesocket (apipe->pipes[1]); - osip_free (apipe); - return 0; -} - - -/** - * Write in a pipe. - */ -int -jpipe_write (jpipe_t * apipe, const void *buf, int count) -{ - if (apipe == NULL) - return -1; - return send (apipe->pipes[1], buf, count, 0); -} - -/** - * Read in a pipe. - */ -int jpipe_read (jpipe_t * apipe, void *buf, int count) -{ - if (apipe == NULL) - return -1; - return recv (apipe->pipes[0], buf, count, 0 /* MSG_DONTWAIT */ ); /* BUG?? */ -} - -/** - * Get descriptor of reading pipe. - */ -int jpipe_get_read_descr (jpipe_t * apipe) -{ - if (apipe == NULL) - return -1; - return apipe->pipes[0]; -} - -#endif diff --git a/linphone/exosip/jpipe.h b/linphone/exosip/jpipe.h deleted file mode 100644 index 3870cefd8..000000000 --- a/linphone/exosip/jpipe.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifndef _JPIPE_H_ -#define _JPIPE_H_ - -#include - -#ifndef WIN32 -#ifdef HAVE_UNISTD_H -#include -#endif -#endif - -#ifdef WIN32 -#include -#endif - -/** - * @file jpipe.h - * @brief PPL Pipe Handling Routines - */ - -/** - * @defgroup JPIPE Pipe Handling - * @ingroup PPL - * @{ - */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#ifndef WIN32 - -/** - * Structure for storing a pipe descriptor - * @defvar jpipe_t - */ - typedef struct jpipe_t jpipe_t; - - struct jpipe_t - { - int pipes[2]; - }; - -#else - -/** - * Structure for storing a pipe descriptor - * @defvar ppl_pipe_t - */ - typedef struct jpipe_t jpipe_t; - - struct jpipe_t - { - int pipes[2]; - }; - -#endif - -/** - * Get New pipe pair. - */ - jpipe_t * jpipe (void); - -/** - * Close pipe - */ - int jpipe_close (jpipe_t * apipe); - -/** - * Write in a pipe. - */ - int jpipe_write (jpipe_t * pipe, const void *buf, - int count); - -/** - * Read in a pipe. - */ - int jpipe_read (jpipe_t * pipe, void *buf, - int count); - -/** - * Get descriptor of reading pipe. - */ - int jpipe_get_read_descr (jpipe_t * pipe); - -#ifdef __cplusplus -} -#endif -/** @} */ -#endif diff --git a/linphone/exosip/jpublish.c b/linphone/exosip/jpublish.c deleted file mode 100644 index a309ace8c..000000000 --- a/linphone/exosip/jpublish.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" - -extern eXosip_t eXosip; - -int _eXosip_pub_update(eXosip_pub_t **pub, osip_transaction_t *tr, osip_message_t *answer) -{ - eXosip_pub_t *jpub; - - *pub = NULL; - - for (jpub = eXosip.j_pub; jpub!=NULL; jpub = jpub->next) - { - if (jpub->p_last_tr==NULL) - { /*bug? */ } - else if (tr==jpub->p_last_tr) - { - /* update the sip_etag parameter */ - if (answer==NULL) - { /* bug? */ - } - else if (MSG_IS_STATUS_2XX(answer)) - { - osip_header_t *sip_etag=NULL; - osip_message_header_get_byname(answer, "SIP-ETag", 0, &sip_etag); - if (sip_etag!=NULL && sip_etag->hvalue!=NULL) - snprintf(jpub->p_sip_etag, 64, "%s", sip_etag->hvalue); - } - *pub=jpub; - return 0; - } - } - return -1; -} - -int _eXosip_pub_find_by_aor(eXosip_pub_t **pub, const char *aor) -{ - eXosip_pub_t *jpub; - eXosip_pub_t *ptr; - time_t now; - - *pub = NULL; - - /* delete expired publications */ - now = time(NULL); - ptr = eXosip.j_pub; - for (jpub = ptr; jpub!=NULL; jpub = ptr) - { - ptr = jpub->next; - if (now-jpub->p_expires>60) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_WARNING, NULL, - "eXosip: removing expired publication!")); - REMOVE_ELEMENT(eXosip.j_pub, jpub); - _eXosip_pub_free(jpub); - } - } - - for (jpub = eXosip.j_pub; jpub!=NULL; jpub = jpub->next) - { - if (osip_strcasecmp(aor, jpub->p_aor)==0) - { - *pub=jpub; - return 0; - } - } - return -1; -} - -int _eXosip_pub_init(eXosip_pub_t **pub, const char *aor, const char *exp) -{ - eXosip_pub_t *jpub; - - *pub = NULL; - - jpub = (eXosip_pub_t*) osip_malloc(sizeof(eXosip_pub_t)); - if (jpub==0) - return -1; - memset(jpub, 0, sizeof(eXosip_pub_t)); - snprintf(jpub->p_aor, 256, "%s", aor); - - jpub->p_expires = atoi(exp) + time(NULL); - jpub->p_period = atoi(exp); - - *pub = jpub; - return 0; -} - -void _eXosip_pub_free(eXosip_pub_t *pub) -{ - if (pub->p_last_tr!=NULL) - osip_list_add(eXosip.j_transactions, pub->p_last_tr, 0); - osip_free(pub); -} - diff --git a/linphone/exosip/jreg.c b/linphone/exosip/jreg.c deleted file mode 100644 index fc16c0a1e..000000000 --- a/linphone/exosip/jreg.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" - -extern eXosip_t eXosip; - -int eXosip_reg_init(eXosip_reg_t **jr, char *from, char *proxy, char *contact, char* route) -{ - static int r_id; - - *jr = (eXosip_reg_t*) osip_malloc(sizeof(eXosip_reg_t)); - if (*jr==NULL) return -1; - - if (r_id > 1000000) /* keep it non-negative */ - r_id = 0; - - (*jr)->r_id = ++r_id; - (*jr)->r_reg_period = 3600; /* delay between registration */ - (*jr)->r_aor = osip_strdup(from); /* sip identity */ - (*jr)->r_contact = osip_strdup(contact); /* sip identity */ - (*jr)->r_registrar = osip_strdup(proxy); /* registrar */ - (*jr)->r_route = osip_strdup(route); /* outbound proxy */ -#if 0 - (*jr)->r_realms = NULL; /* list of realms */ -#endif - (*jr)->r_last_tr = NULL; - - (*jr)->next = NULL; - (*jr)->parent = NULL; - return 0; -} - -void eXosip_reg_free(eXosip_reg_t *jreg) -{ - - osip_free(jreg->r_aor); - osip_free(jreg->r_contact); - osip_free(jreg->r_registrar); -#if 0 - osip_free(jreg->r_realms); -#endif - - if (jreg->r_last_tr != NULL) - { - if (jreg->r_last_tr->state==IST_TERMINATED || - jreg->r_last_tr->state==ICT_TERMINATED || - jreg->r_last_tr->state== NICT_TERMINATED || - jreg->r_last_tr->state==NIST_TERMINATED) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "Release a terminated transaction\n")); - __eXosip_delete_jinfo(jreg->r_last_tr); - if (jreg->r_last_tr!=NULL) - osip_list_add(eXosip.j_transactions, jreg->r_last_tr, 0); - } - else - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "Release a non-terminated transaction\n")); - __eXosip_delete_jinfo(jreg->r_last_tr); - if (jreg->r_last_tr!=NULL) - osip_list_add(eXosip.j_transactions, jreg->r_last_tr, 0); - } - } - - osip_free(jreg); -} - -int _eXosip_reg_find(eXosip_reg_t **reg, osip_transaction_t *tr) -{ - eXosip_reg_t *jreg; - *reg = NULL; - if (tr==NULL) return -1; - - for (jreg = eXosip.j_reg; jreg!=NULL; jreg = jreg->next) - { - if (jreg->r_last_tr==tr) - { - *reg = jreg; - return 0; - } - } - return -1; -} diff --git a/linphone/exosip/jrequest.c b/linphone/exosip/jrequest.c deleted file mode 100644 index 854c18782..000000000 --- a/linphone/exosip/jrequest.c +++ /dev/null @@ -1,1158 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" - -#ifndef WIN32 -#include -#include -#include -#include -#ifdef __APPLE_CC__ -#include -#endif -#else -#include -#include -#endif - -extern eXosip_t eXosip; - -/* Private functions */ -static int generating_request_out_of_dialog(osip_message_t **dest, - char *method_name, char *to, - char *transport, char *from, - char *proxy); -static int dialog_fill_route_set(osip_dialog_t *dialog, - osip_message_t *request); - -/* should use cryptographically random identifier is RECOMMENDED.... */ -/* by now this should lead to identical call-id when application are - started at the same time... */ -char * -osip_call_id_new_random() -{ - char *tmp = (char *)osip_malloc(33); - unsigned int number = osip_build_random_number(); - sprintf(tmp,"%u",number); - return tmp; -} - -char * -osip_from_tag_new_random(void) -{ - return osip_call_id_new_random(); -} - -char * -osip_to_tag_new_random(void) -{ - return osip_call_id_new_random(); -} - -unsigned int -via_branch_new_random(void) -{ - return osip_build_random_number(); -} - -/* prepare a minimal request (outside of a dialog) with required headers */ -/* - method_name is the type of request. ("INVITE", "REGISTER"...) - to is the remote target URI - transport is either "TCP" or "UDP" (by now, only UDP is implemented!) -*/ -static int -generating_request_out_of_dialog(osip_message_t **dest, char *method_name, - char *to, char *transport, char *from, - char *proxy) -{ - /* Section 8.1: - A valid request contains at a minimum "To, From, Call-iD, Cseq, - Max-Forwards and Via - */ - int i; - osip_message_t *request; -#ifdef SM - char *locip=NULL; -#else - char locip[50]; -#endif - int doing_register; - char *register_callid_number = NULL; - - i = osip_message_init(&request); - if (i!=0) return -1; - - /* prepare the request-line */ - osip_message_set_method(request, osip_strdup(method_name)); - osip_message_set_version(request, osip_strdup("SIP/2.0")); - osip_message_set_status_code(request, 0); - osip_message_set_reason_phrase(request, NULL); - - doing_register = 0==strcmp("REGISTER", method_name); - - if (doing_register) - { - osip_uri_init(&(request->req_uri)); - i = osip_uri_parse(request->req_uri, proxy); - if (i!=0) - { - goto brood_error_1; - } - osip_message_set_to(request, from); - } - else - { - /* in any cases except REGISTER: */ - i = osip_message_set_to(request, to); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "ERROR: callee address does not seems to be a sipurl: %s\n", to)); - goto brood_error_1; - } - if (proxy!=NULL && proxy[0] != 0) - { /* equal to a pre-existing route set */ - /* if the pre-existing route set contains a "lr" (compliance - with bis-08) then the req_uri should contains the remote target - URI */ - osip_uri_param_t *lr_param; - osip_route_t *o_proxy; -#ifndef __VXWORKS_OS__ - osip_route_init(&o_proxy); -#else - osip_route_init2(&o_proxy); -#endif - i = osip_route_parse(o_proxy, proxy); - if (i!=0) { - osip_route_free(o_proxy); - goto brood_error_1; - } - - osip_uri_uparam_get_byname(o_proxy->url, "lr", &lr_param); - if (lr_param!=NULL) /* to is the remote target URI in this case! */ - { - osip_uri_clone(request->to->url, &(request->req_uri)); - /* "[request] MUST includes a Route header field containing - the route set values in order." */ - osip_list_add(request->routes, o_proxy, 0); - } - else - /* if the first URI of route set does not contain "lr", the req_uri - is set to the first uri of route set */ - { - request->req_uri = o_proxy->url; - o_proxy->url = NULL; - osip_route_free(o_proxy); - /* add the route set */ - /* "The UAC MUST add a route header field containing - the remainder of the route set values in order. - The UAC MUST then place the remote target URI into - the route header field as the last value - */ - osip_message_set_route(request, to); - } - } - else /* No route set (outbound proxy) is used */ - { - /* The UAC must put the remote target URI (to field) in the req_uri */ - i = osip_uri_clone(request->to->url, &(request->req_uri)); - if (i!=0) goto brood_error_1; - } - } - /*guess the local ip since req uri is known */ -#ifdef SM - { - eXosip_get_localip_for(request->req_uri->host,&locip); - } -#else - eXosip_guess_ip_for_via(eXosip.ip_family, locip, 49); -#endif - /* set To and From */ - osip_message_set_from(request, from); - /* add a tag */ - osip_from_set_tag(request->from, osip_from_tag_new_random()); - - /* set the cseq and call_id header */ - { - osip_call_id_t *callid; - osip_cseq_t *cseq; - char *num; - char *cidrand; - - /* call-id is always the same for REGISTRATIONS */ - i = osip_call_id_init(&callid); - if (i!=0) goto brood_error_1; - cidrand = osip_call_id_new_random(); - osip_call_id_set_number(callid, cidrand); - if (doing_register) - register_callid_number = cidrand; - - osip_call_id_set_host(callid, osip_strdup(locip)); - request->call_id = callid; - - i = osip_cseq_init(&cseq); - if (i!=0) goto brood_error_1; - num = osip_strdup(doing_register ? "1" : "20" ); - osip_cseq_set_number(cseq, num); - osip_cseq_set_method(cseq, osip_strdup(method_name)); - request->cseq = cseq; - } - - /* always add the Max-Forward header */ - osip_message_set_max_forwards(request, "70"); /* a UA should start a request with 70 */ - -#define MASQUERADE_VIA -#ifdef MASQUERADE_VIA - /* should be useless with compliant UA */ - if (eXosip.j_firewall_ip[0]!='\0') - { - char *c_address = request->req_uri->host; - - struct addrinfo *addrinfo; - struct __eXosip_sockaddr addr; - i = eXosip_get_addrinfo(&addrinfo, request->req_uri->host, 5060); - if (i==0) - { - memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen); - freeaddrinfo (addrinfo); - c_address = inet_ntoa (((struct sockaddr_in *) &addr)->sin_addr); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "eXosip: here is the resolved destination host=%s\n", c_address)); - } - - if (eXosip_is_public_address(c_address)) - { - char tmp[200]; - snprintf(tmp, 200, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", transport, - eXosip.j_firewall_ip, - eXosip.localport, - via_branch_new_random() ); - osip_message_set_via(request, tmp); - } - else - { - char tmp[200]; - if (eXosip.ip_family==AF_INET6) - snprintf(tmp, 200, "SIP/2.0/%s [%s]:%s;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - else - snprintf(tmp, 200, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - osip_message_set_via(request, tmp); - } - } - else - { - char tmp[200]; - if (eXosip.ip_family==AF_INET6) - snprintf(tmp, 200, "SIP/2.0/%s [%s]:%s;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - else - snprintf(tmp, 200, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - osip_message_set_via(request, tmp); - } - -#else - { - char tmp[200]; - if (eXosip.ip_family==AF_INET6) - spnrintf(tmp, 200, "SIP/2.0/%s [%s]:%s;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - else - spnrintf(tmp, 200, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - - osip_message_set_via(request, tmp); - } -#endif - - /* add specific headers for each kind of request... */ - - if (0==strcmp("INVITE", method_name) || 0==strcmp("SUBSCRIBE", method_name)) - { - char *contact; - osip_from_t *a_from; - int i; - i = osip_from_init(&a_from); - if (i==0) - i = osip_from_parse(a_from, from); - - if (i==0 && a_from!=NULL - && a_from->url!=NULL && a_from->url->username!=NULL ) - { - contact = (char *) osip_malloc(50+strlen(a_from->url->username)); - - if (eXosip.j_firewall_ip[0]!='\0') - { - char *c_address = request->req_uri->host; - - struct addrinfo *addrinfo; - struct __eXosip_sockaddr addr; - i = eXosip_get_addrinfo(&addrinfo, request->req_uri->host, 5060); - if (i==0) - { - memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen); - freeaddrinfo (addrinfo); - c_address = inet_ntoa (((struct sockaddr_in *) &addr)->sin_addr); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "eXosip: here is the resolved destination host=%s\n", c_address)); - } - - if (eXosip_is_public_address(c_address)) - { - if (eXosip.localport==NULL) - sprintf(contact, "", a_from->url->username, - eXosip.j_firewall_ip); - else - sprintf(contact, "", a_from->url->username, - eXosip.j_firewall_ip, - eXosip.localport); - } - else - { - if (eXosip.localport==NULL) - sprintf(contact, "", a_from->url->username, - locip); - else - sprintf(contact, "", a_from->url->username, - locip, - eXosip.localport); - } - } - else - { - if (eXosip.localport==NULL) - sprintf(contact, "", a_from->url->username, - locip); - else - sprintf(contact, "", a_from->url->username, - locip, - eXosip.localport); - } - osip_message_set_contact(request, contact); - osip_free(contact); - } - osip_from_free(a_from); - - /* This is probably useless for other messages */ - osip_message_set_allow(request, "INVITE"); - osip_message_set_allow(request, "ACK"); - osip_message_set_allow(request, "CANCEL"); - osip_message_set_allow(request, "BYE"); - osip_message_set_allow(request, "OPTIONS"); - osip_message_set_allow(request, "REFER"); - osip_message_set_allow(request, "SUBSCRIBE"); - osip_message_set_allow(request, "NOTIFY"); - osip_message_set_allow(request, "MESSAGE"); - } - - if (0==strcmp("SUBSCRIBE", method_name)) - { - osip_message_set_header(request, "Event", "presence"); -#ifdef SUPPORT_MSN - osip_message_set_accept(request, "application/xpidf+xml"); -#else - osip_message_set_accept(request, "application/pidf+xml"); -#endif - } - else if (0==strcmp("REGISTER", method_name)) - { - } - else if (0==strcmp("INFO", method_name)) - { - } - else if (0==strcmp("OPTIONS", method_name)) - { - osip_message_set_accept(request, "application/sdp"); - } - - osip_message_set_user_agent(request, eXosip.user_agent); - /* else if ... */ - *dest = request; -#ifdef SM - osip_free(locip); -#endif - return 0; - - brood_error_1: - osip_message_free(request); - *dest = NULL; -#ifdef SM - if (locip!=NULL) osip_free(locip); -#endif - return -1; -} - -int -generating_register(osip_message_t **reg, char *from, - char *proxy, char *contact, int expires) -{ - osip_from_t *a_from; - osip_via_t *via; - int i; - char * locip; - - i = generating_request_out_of_dialog(reg, "REGISTER", NULL, "UDP", - from, proxy); - if (i!=0) return -1; - - /*get the local ip from the via already established by generating_request_out_of_dialog */ - if (osip_message_get_via((*reg),0,&via)==0){ - locip=via->host; - }else return -1; - - if (contact==NULL) - { - i = osip_from_init(&a_from); - if (i==0) - i = osip_from_parse(a_from, from); - - if (i==0 && a_from!=NULL - && a_from->url!=NULL && a_from->url->username!=NULL ) - { - contact = (char *) osip_malloc(50+strlen(a_from->url->username)); - - if (eXosip.ip_family==AF_INET6) - sprintf(contact, "", a_from->url->username, - locip, - eXosip.localport!=NULL ? eXosip.localport : "5060"); - else - sprintf(contact, "", a_from->url->username, - locip, - eXosip.localport!=NULL ? eXosip.localport : "5060"); - osip_message_set_contact(*reg, contact); - osip_free(contact); - } - osip_from_free(a_from); - } - else - { - osip_message_set_contact(*reg, contact); - } - - { - char exp[10]; /* MUST never be ouside 1 and 3600 */ - snprintf(exp, 9, "%i", expires); - osip_message_set_expires(*reg, exp); - } - - osip_message_set_content_length(*reg, "0"); - - return 0; -} - -/* this method can't be called unless the previous - INVITE transaction is over. */ -int eXosip_build_initial_invite(osip_message_t **invite, char *to, char *from, - char *route, char *subject) -{ - int i; - - if (to!=NULL && *to=='\0') - return -1; - - osip_clrspace(to); - osip_clrspace(subject); - osip_clrspace(from); - osip_clrspace(route); - if (route!=NULL && *route=='\0') - route=NULL; - if (subject!=NULL && *subject=='\0') - subject=NULL; - - i = generating_request_out_of_dialog(invite, "INVITE", to, "UDP", from, - route); - if (i!=0) return -1; - -#if 0 - if (subject==NULL) - osip_message_set_subject(*invite, "New Call"); - else - osip_message_set_subject(*invite, subject); -#else - if (subject!=NULL) - osip_message_set_subject(*invite, subject); -#endif - - /* after this delay, we should send a CANCEL */ - osip_message_set_expires(*invite, "120"); - - /* osip_message_set_organization(*invite, "Jack's Org"); */ - return 0; -} - -/* this method can't be called unless the previous - INVITE transaction is over. */ -int eXosip_build_initial_options(osip_message_t **options, char *to, char *from, - char *route) -{ - int i; - - if (to!=NULL && *to=='\0') - return -1; - - osip_clrspace(to); - osip_clrspace(from); - osip_clrspace(route); - if (route!=NULL && *route=='\0') - route=NULL; - - i = generating_request_out_of_dialog(options, "OPTIONS", to, "UDP", from, - route); - if (i!=0) return -1; - - /* after this delay, we should send a CANCEL */ - osip_message_set_expires(*options, "120"); - - /* osip_message_set_organization(*invite, "Jack's Org"); */ - return 0; -} - -/* this method can't be called unless the previous - INVITE transaction is over. */ -int generating_initial_subscribe(osip_message_t **subscribe, char *to, - char *from, char *route) -{ - int i; - - if (to!=NULL && *to=='\0') - return -1; - - osip_clrspace(to); - osip_clrspace(from); - osip_clrspace(route); - if (route!=NULL && *route=='\0') - route=NULL; - - i = generating_request_out_of_dialog(subscribe, "SUBSCRIBE", to, "UDP", from, - route); - if (i!=0) return -1; - -#ifdef LOW_EXPIRE - osip_message_set_expires(*subscribe, "120"); -#else - osip_message_set_expires(*subscribe, "3600"); -#endif - - /* osip_message_set_organization(*subscribe, "Jack's Org"); */ - return 0; -} - -/* this method can't be called unless the previous - INVITE transaction is over. */ -int generating_message(osip_message_t **message, char *to, char *from, - char *route, char *buff) -{ - int i; - - if (to!=NULL && *to=='\0') - return -1; - - osip_clrspace(to); - /* osip_clrspace(buff); */ - osip_clrspace(from); - osip_clrspace(route); - if (route!=NULL && *route=='\0') - route=NULL; - if (buff!=NULL && *buff=='\0') - return -1; /* at least, the message must be of length >= 1 */ - - i = generating_request_out_of_dialog(message, "MESSAGE", to, "UDP", from, - route); - if (i!=0) return -1; - - osip_message_set_expires(*message, "120"); - osip_message_set_body(*message, buff, strlen(buff)); - osip_message_set_content_type(*message, "text/plain"); - - /* osip_message_set_organization(*message, "Jack's Org"); */ - - - return 0; -} - -/* this method can't be called unless the previous - INVITE transaction is over. */ -int -generating_publish(osip_message_t **message, char *to, char *from, - char *route) -{ - int i; - - if (to!=NULL && *to=='\0') - return -1; - - osip_clrspace(to); - osip_clrspace(from); - osip_clrspace(route); - if (route!=NULL && *route=='\0') - route=NULL; - - i = generating_request_out_of_dialog(message, "PUBLISH", to, "UDP", from, - route); - if (i!=0) return -1; - - /* osip_message_set_organization(*message, "Jack's Org"); */ - - return 0; -} - - -int -generating_options(osip_message_t **options, char *from, char *to, char *proxy) -{ - int i; - i = generating_request_out_of_dialog(options, "OPTIONS", to, "UDP", - from, proxy); - if (i!=0) return -1; - -#if 0 - if (sdp!=NULL) - { - osip_message_set_content_type(*options, "application/sdp"); - osip_message_set_body(*options, sdp); - } -#endif - - return 0; -} - -int -generating_info(osip_message_t **info, char *from, char *to, char *proxy) -{ - int i; - i = generating_request_out_of_dialog(info, "INFO", to, "UDP", - from, proxy); - if (i!=0) return -1; - return 0; -} - - -static int -dialog_fill_route_set(osip_dialog_t *dialog, osip_message_t *request) -{ - /* if the pre-existing route set contains a "lr" (compliance - with bis-08) then the req_uri should contains the remote target - URI */ - int i; - int pos=0; - osip_uri_param_t *lr_param; - osip_route_t *route; - char *last_route; - /* AMD bug: fixed 17/06/2002 */ - - if (dialog->type==CALLER) - { - pos = osip_list_size(dialog->route_set)-1; - route = (osip_route_t*)osip_list_get(dialog->route_set, pos); - } - else - route = (osip_route_t*)osip_list_get(dialog->route_set, 0); - - osip_uri_uparam_get_byname(route->url, "lr", &lr_param); - if (lr_param!=NULL) /* the remote target URI is the req_uri! */ - { - i = osip_uri_clone(dialog->remote_contact_uri->url, - &(request->req_uri)); - if (i!=0) return -1; - /* "[request] MUST includes a Route header field containing - the route set values in order." */ - /* AMD bug: fixed 17/06/2002 */ - pos=0; /* first element is at index 0 */ - while (!osip_list_eol(dialog->route_set, pos)) - { - osip_route_t *route2; - route = osip_list_get(dialog->route_set, pos); - i = osip_route_clone(route, &route2); - if (i!=0) return -1; - if (dialog->type==CALLER) - osip_list_add(request->routes, route2, 0); - else - osip_list_add(request->routes, route2, -1); - pos++; - } - return 0; - } - - /* if the first URI of route set does not contain "lr", the req_uri - is set to the first uri of route set */ - - - i = osip_uri_clone(route->url, &(request->req_uri)); - if (i!=0) return -1; - /* add the route set */ - /* "The UAC MUST add a route header field containing - the remainder of the route set values in order. */ - pos=0; /* yes it is */ - - while (!osip_list_eol(dialog->route_set, pos)) /* not the first one in the list */ - { - osip_route_t *route2; - route = osip_list_get(dialog->route_set, pos); - i = osip_route_clone(route, &route2); - if (i!=0) return -1; - if (dialog->type==CALLER) - { - if (pos!=osip_list_size(dialog->route_set)-1) - osip_list_add(request->routes, route2, 0); - else - osip_route_free(route2); - } - else - { - if (!osip_list_eol(dialog->route_set, pos+1)) - osip_list_add(request->routes, route2, -1); - else - osip_route_free(route2); - } - pos++; - } - - /* The UAC MUST then place the remote target URI into - the route header field as the last value */ - i = osip_uri_to_str(dialog->remote_contact_uri->url, &last_route); - if (i!=0) return -1; - i = osip_message_set_route(request, last_route); - osip_free(last_route); - if (i!=0) { return -1; } - - /* route header and req_uri set */ - return 0; -} - -int -_eXosip_build_request_within_dialog(osip_message_t **dest, char *method_name, - osip_dialog_t *dialog, char *transport) -{ - int i; - osip_message_t *request; -#ifdef SM - char *locip=NULL; -#else - char locip[50]; -#endif - - i = osip_message_init(&request); - if (i!=0) return -1; - - if (dialog->remote_contact_uri==NULL) - { - /* this dialog is probably not established! or the remote UA - is not compliant with the latest RFC - */ - osip_message_free(request); - return -1; - } -#ifdef SM - eXosip_get_localip_for(dialog->remote_contact_uri->url->host,&locip); -#else - eXosip_guess_ip_for_via(eXosip.ip_family, locip, 49); -#endif - /* prepare the request-line */ - request->sip_method = osip_strdup(method_name); - request->sip_version = osip_strdup("SIP/2.0"); - request->status_code = 0; - request->reason_phrase = NULL; - - /* and the request uri???? */ - if (osip_list_eol(dialog->route_set, 0)) - { - /* The UAC must put the remote target URI (to field) in the req_uri */ - i = osip_uri_clone(dialog->remote_contact_uri->url, &(request->req_uri)); - if (i!=0) goto grwd_error_1; - } - else - { - /* fill the request-uri, and the route headers. */ - dialog_fill_route_set(dialog, request); - } - - /* To and From already contains the proper tag! */ - i = osip_to_clone(dialog->remote_uri, &(request->to)); - if (i!=0) goto grwd_error_1; - i = osip_from_clone(dialog->local_uri, &(request->from)); - if (i!=0) goto grwd_error_1; - - /* set the cseq and call_id header */ - osip_message_set_call_id(request, dialog->call_id); - - if (0==strcmp("ACK", method_name)) - { - osip_cseq_t *cseq; - char *tmp; - i = osip_cseq_init(&cseq); - if (i!=0) goto grwd_error_1; - tmp = osip_malloc(20); - sprintf(tmp,"%i", dialog->local_cseq); - osip_cseq_set_number(cseq, tmp); - osip_cseq_set_method(cseq, osip_strdup(method_name)); - request->cseq = cseq; - } - else - { - osip_cseq_t *cseq; - char *tmp; - i = osip_cseq_init(&cseq); - if (i!=0) goto grwd_error_1; - dialog->local_cseq++; /* we should we do that?? */ - tmp = osip_malloc(20); - sprintf(tmp,"%i", dialog->local_cseq); - osip_cseq_set_number(cseq, tmp); - osip_cseq_set_method(cseq, osip_strdup(method_name)); - request->cseq = cseq; - } - - /* always add the Max-Forward header */ - osip_message_set_max_forwards(request, "70"); /* a UA should start a request with 70 */ - - - /* even for ACK for 2xx (ACK within a dialog), the branch ID MUST - be a new ONE! */ -#ifdef MASQUERADE_VIA - /* should be useless with compliant UA */ - if (eXosip.j_firewall_ip[0]!='\0') - { - char *c_address = request->req_uri->host; - - struct addrinfo *addrinfo; - struct __eXosip_sockaddr addr; - i = eXosip_get_addrinfo(&addrinfo, request->req_uri->host, 5060); - if (i==0) - { - memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen); - freeaddrinfo (addrinfo); - c_address = inet_ntoa (((struct sockaddr_in *) &addr)->sin_addr); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "eXosip: here is the resolved destination host=%s\n", c_address)); - } - - if (eXosip_is_public_address(c_address)) - { - char tmp[200]; - sprintf(tmp, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", transport, - eXosip.j_firewall_ip, - eXosip.localport, - via_branch_new_random() ); - osip_message_set_via(request, tmp); - } - else - { - char tmp[200]; - if (eXosip.ip_family==AF_INET6) - snprintf(tmp, 200, "SIP/2.0/%s [%s]:%s;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - else - snprintf(tmp, 200, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - - osip_message_set_via(request, tmp); - } - } - else - { - char tmp[200]; - if (eXosip.ip_family==AF_INET6) - snprintf(tmp, 200, "SIP/2.0/%s [%s]:%s;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - else - snprintf(tmp, 200, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", transport, - locip, - eXosip.localport, - via_branch_new_random() ); - - osip_message_set_via(request, tmp); - } - -#else - { - char tmp[200]; - if (eXosip.ip_family==AF_INET6) - sprintf(tmp, "SIP/2.0/%s [%s]:%s;branch=z9hG4bK%u", transport, - locip, eXosip.localport, - via_branch_new_random()); - else - sprintf(tmp, "SIP/2.0/%s %s:%s;rport;branch=z9hG4bK%u", transport, - locip, eXosip.localport, - via_branch_new_random()); - - osip_message_set_via(request, tmp); - } -#endif - - /* add specific headers for each kind of request... */ - -#if 0 - if (0==strcmp("INVITE", method_name) || 0==strcmp("SUBSCRIBE", method_name)) -#endif - { - char contact[200]; - if (eXosip.j_firewall_ip[0]!='\0') - { - char *c_address = request->req_uri->host; - - struct addrinfo *addrinfo; - struct __eXosip_sockaddr addr; - i = eXosip_get_addrinfo(&addrinfo, request->req_uri->host, 5060); - if (i==0) - { - memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen); - freeaddrinfo (addrinfo); - c_address = inet_ntoa (((struct sockaddr_in *) &addr)->sin_addr); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "eXosip: here is the resolved destination host=%s\n", c_address)); - } - - if (eXosip_is_public_address(c_address)) - { - sprintf(contact, "", dialog->local_uri->url->username, - eXosip.j_firewall_ip, - eXosip.localport); - } - else - { - sprintf(contact, "", dialog->local_uri->url->username, - locip, - eXosip.localport); - } - } - else - { - sprintf(contact, "", dialog->local_uri->url->username, - locip, - eXosip.localport); - } - osip_message_set_contact(request, contact); - /* Here we'll add the supported header if it's needed! */ - /* the require header must be added by the upper layer if needed */ - } - - if (0==strcmp("SUBSCRIBE", method_name)) - { - osip_message_set_header(request, "Event", "presence"); -#ifdef SUPPORT_MSN - osip_message_set_accept(request, "application/xpidf+xml"); -#else - osip_message_set_accept(request, "application/pidf+xml"); -#endif - } - else if (0==strcmp("NOTIFY", method_name)) - { - } - else if (0==strcmp("INFO", method_name)) - { - - } - else if (0==strcmp("OPTIONS", method_name)) - { - osip_message_set_accept(request, "application/sdp"); - } - else if (0==strcmp("ACK", method_name)) - { - /* The ACK MUST contains the same credential than the INVITE!! */ - /* TODO... */ - } - - osip_message_set_user_agent(request, eXosip.user_agent); - /* else if ... */ - *dest = request; - return 0; - - /* grwd_error_2: */ - dialog->local_cseq--; - grwd_error_1: - osip_message_free(request); - *dest = NULL; - return -1; -} - -/* this request is only build within a dialog!! */ -int -generating_bye(osip_message_t **bye, osip_dialog_t *dialog) -{ - int i; - i = _eXosip_build_request_within_dialog(bye, "BYE", dialog, "UDP"); - if (i!=0) return -1; - - return 0; -} - -/* this request is only build within a dialog! (but should not!) */ -int -generating_refer_outside_dialog(osip_message_t **refer, char *refer_to, char *from, char *to, char *proxy) -{ - int i; - i = generating_request_out_of_dialog(refer, "REFER", to, "UDP", - from, proxy); - if (i!=0) return -1; - - osip_message_set_header(*refer, "Refer-to", refer_to); - return 0; -} - -/* this request is only build within a dialog! (but should not!) */ -int -generating_refer(osip_message_t **refer, osip_dialog_t *dialog, char *refer_to) -{ - int i; - i = _eXosip_build_request_within_dialog(refer, "REFER", dialog, "UDP"); - if (i!=0) return -1; - - osip_message_set_header(*refer, "Refer-to", refer_to); - - return 0; -} - -/* this request can be inside or outside a dialog */ -int -generating_options_within_dialog(osip_message_t **options, osip_dialog_t *dialog) -{ - int i; - i = _eXosip_build_request_within_dialog(options, "OPTIONS", dialog, "UDP"); - if (i!=0) return -1; - -#if 0 - if (sdp!=NULL) - { - osip_message_set_content_type(*options, "application/sdp"); - osip_message_set_body(*options, sdp); - } -#endif - - return 0; -} - -int -generating_info_within_dialog(osip_message_t **info, osip_dialog_t *dialog) -{ - int i; - i = _eXosip_build_request_within_dialog(info, "INFO", dialog, "UDP"); - if (i!=0) return -1; - return 0; -} - -/* It is RECOMMENDED to only cancel INVITE request */ -int -generating_cancel(osip_message_t **dest, osip_message_t *request_cancelled) -{ - int i; - osip_message_t *request; - - i = osip_message_init(&request); - if (i!=0) return -1; - - /* prepare the request-line */ - osip_message_set_method(request, osip_strdup("CANCEL")); - osip_message_set_version(request, osip_strdup("SIP/2.0")); - osip_message_set_status_code(request, 0); - osip_message_set_reason_phrase(request, NULL); - - i = osip_uri_clone(request_cancelled->req_uri, &(request->req_uri)); - if (i!=0) goto gc_error_1; - - i = osip_to_clone(request_cancelled->to, &(request->to)); - if (i!=0) goto gc_error_1; - i = osip_from_clone(request_cancelled->from, &(request->from)); - if (i!=0) goto gc_error_1; - - /* set the cseq and call_id header */ - i = osip_call_id_clone(request_cancelled->call_id, &(request->call_id)); - if (i!=0) goto gc_error_1; - i = osip_cseq_clone(request_cancelled->cseq, &(request->cseq)); - if (i!=0) goto gc_error_1; - osip_free(request->cseq->method); - request->cseq->method = osip_strdup("CANCEL"); - - /* copy ONLY the top most Via Field (this method is also used by proxy) */ - { - osip_via_t *via; - osip_via_t *via2; - i = osip_message_get_via(request_cancelled, 0, &via); - if (i!=0) goto gc_error_1; - i = osip_via_clone(via, &via2); - if (i!=0) goto gc_error_1; - osip_list_add(request->vias, via2, -1); - } - - /* add the same route-set than in the previous request */ - { - int pos=0; - osip_route_t *route; - osip_route_t *route2; - while (!osip_list_eol(request_cancelled->routes, pos)) - { - route = (osip_route_t*) osip_list_get(request_cancelled->routes, pos); - i = osip_route_clone(route, &route2); - if (i!=0) goto gc_error_1; - osip_list_add(request->routes, route2, -1); - pos++; - } - } - - osip_message_set_max_forwards(request, "70"); /* a UA should start a request with 70 */ - osip_message_set_user_agent(request, eXosip.user_agent); - - *dest = request; - return 0; - - gc_error_1: - osip_message_free(request); - *dest = NULL; - return -1; -} - - -int -generating_ack_for_2xx(osip_message_t **ack, osip_dialog_t *dialog) -{ - int i; - i = _eXosip_build_request_within_dialog(ack, "ACK", dialog, "UDP"); - if (i!=0) return -1; - - return 0; -} diff --git a/linphone/exosip/jresponse.c b/linphone/exosip/jresponse.c deleted file mode 100644 index 39d83c127..000000000 --- a/linphone/exosip/jresponse.c +++ /dev/null @@ -1,1264 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" -#include - -extern eXosip_t eXosip; - -/* Private functions */ -static char *generating_no_sdp_answer(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_message_t *orig_request, char *local_sdp_port); - -int -eXosip_build_response_default(int jid, int status) -{ - return -1; -} - -int -_eXosip_build_response_default(osip_message_t **dest, osip_dialog_t *dialog, - int status, osip_message_t *request) -{ - osip_generic_param_t *tag; - osip_message_t *response; - int pos; - int i; - - if (request==NULL) return -1; - - i = osip_message_init(&response); - if (i!=0) - return -1; - /* initialise osip_message_t structure */ - /* yet done... */ - - response->sip_version = (char *)osip_malloc(8*sizeof(char)); - sprintf(response->sip_version,"SIP/2.0"); - osip_message_set_status_code(response, status); - - /* handle some internal reason definitions. */ - if (MSG_IS_NOTIFY(request) && status==481) - { - response->reason_phrase = osip_strdup("Subcription Does Not Exist"); - } - else if (MSG_IS_SUBSCRIBE(request) && status==202) - { - response->reason_phrase = osip_strdup("Accepted subscription"); - } - else - { - response->reason_phrase = osip_strdup(osip_message_get_reason(status)); - if (response->reason_phrase==NULL) - { - if (response->status_code == 101) - response->reason_phrase = osip_strdup("Dialog Establishement"); - else - response->reason_phrase = osip_strdup("Unknown code"); - } - response->req_uri = NULL; - response->sip_method = NULL; - } - - i = osip_to_clone(request->to, &(response->to)); - if (i!=0) goto grd_error_1; - - i = osip_to_get_tag(response->to,&tag); - if (i!=0) - { /* we only add a tag if it does not already contains one! */ - if ((dialog!=NULL) && (dialog->local_tag!=NULL)) - /* it should contain the local TAG we created */ - { osip_to_set_tag(response->to, osip_strdup(dialog->local_tag)); } - else - { - if (status!=100) - osip_to_set_tag(response->to, osip_to_tag_new_random()); - } - } - - i = osip_from_clone(request->from, &(response->from)); - if (i!=0) goto grd_error_1; - - pos = 0; - while (!osip_list_eol(request->vias,pos)) - { - osip_via_t *via; - osip_via_t *via2; - via = (osip_via_t *)osip_list_get(request->vias,pos); - i = osip_via_clone(via, &via2); - if (i!=-0) goto grd_error_1; - osip_list_add(response->vias, via2, -1); - pos++; - } - - i = osip_call_id_clone(request->call_id, &(response->call_id)); - if (i!=0) goto grd_error_1; - i = osip_cseq_clone(request->cseq, &(response->cseq)); - if (i!=0) goto grd_error_1; - - if (MSG_IS_SUBSCRIBE(request)) - { - osip_header_t *exp; - osip_message_set_header(response, "Event", "presence"); - i = osip_message_get_expires(request, 0, &exp); - if (exp==NULL) - { - osip_header_t *cp; - i = osip_header_clone(exp, &cp); - if (cp!=NULL) - osip_list_add(response->headers, cp, 0); - } - } - - osip_message_set_allow(response, "INVITE"); - osip_message_set_allow(response, "ACK"); - osip_message_set_allow(response, "OPTIONS"); - osip_message_set_allow(response, "CANCEL"); - osip_message_set_allow(response, "BYE"); - osip_message_set_allow(response, "SUBSCRIBE"); - osip_message_set_allow(response, "NOTIFY"); - osip_message_set_allow(response, "MESSAGE"); - osip_message_set_allow(response, "INFO"); - - *dest = response; - return 0; - - grd_error_1: - osip_message_free(response); - return -1; -} - -int -complete_answer_that_establish_a_dialog(osip_message_t *response, osip_message_t *request) -{ - int i; - int pos=0; - char contact[1000]; -#ifdef SM - char *locip=NULL; -#else - char locip[50]; -#endif - /* 12.1.1: - copy all record-route in response - add a contact with global scope - */ - while (!osip_list_eol(request->record_routes, pos)) - { - osip_record_route_t *rr; - osip_record_route_t *rr2; - rr = osip_list_get(request->record_routes, pos); - i = osip_record_route_clone(rr, &rr2); - if (i!=0) return -1; - osip_list_add(response->record_routes, rr2, -1); - pos++; - } - -#ifdef SM - eXosip_get_localip_from_via(response,&locip); -#else - eXosip_guess_ip_for_via(eXosip.ip_family, locip, 49); -#endif - - if (eXosip.answer_contact[0]) - snprintf(contact,1000, "%s", eXosip.answer_contact); - else if (request->to->url->username==NULL) - snprintf(contact,1000, "", locip, eXosip.localport); - else - snprintf(contact,1000, "", request->to->url->username, - locip, eXosip.localport); - - if (eXosip.j_firewall_ip[0]!='\0') - { - osip_contact_t *con = (osip_contact_t *) osip_list_get (request->contacts, 0); - if (con!=NULL && con->url!=NULL && con->url->host!=NULL) - { - char *c_address = con->url->host; - - struct addrinfo *addrinfo; - struct __eXosip_sockaddr addr; - i = eXosip_get_addrinfo(&addrinfo, con->url->host, 5060); - if (i==0) - { - memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen); - freeaddrinfo (addrinfo); - c_address = inet_ntoa (((struct sockaddr_in *) &addr)->sin_addr); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "eXosip: here is the resolved destination host=%s\n", c_address)); - } - - /* If c_address is a PUBLIC address, the request was - coming from the PUBLIC network. */ - if (eXosip_is_public_address(c_address)) - { - if (request->to->url->username==NULL) - snprintf(contact,1000, "", eXosip.j_firewall_ip, - eXosip.localport); - else - snprintf(contact,1000, "", request->to->url->username, - eXosip.j_firewall_ip, eXosip.localport); - } - } - } - -#ifdef SM - osip_free(locip); -#endif - - osip_message_set_contact(response, contact); - - return 0; -} - -static char * -generating_no_sdp_answer(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_message_t *orig_request, char *local_sdp_port) -{ - sdp_message_t *local_sdp = NULL; - char *local_body = NULL; - char *size; - int i; - - jc->c_ack_sdp = 1; - if(osip_negotiation_sdp_build_offer(eXosip.osip_negotiation, NULL, &local_sdp, local_sdp_port, NULL) != 0) - return NULL; - - if (local_sdp!=NULL) - { - int pos=0; - while (!sdp_message_endof_media (local_sdp, pos)) - { - int k = 0; - char *tmp = sdp_message_m_media_get (local_sdp, pos); - if (0 == strncmp (tmp, "audio", 5)) - { - char *payload = NULL; - do { - payload = sdp_message_m_payload_get (local_sdp, pos, k); - if (payload == NULL) - { - } - else if (0==strcmp("110",payload)) - { - sdp_message_a_attribute_add (local_sdp, - pos, - osip_strdup ("AS"), - osip_strdup ("110 20")); - } - else if (0==strcmp("111",payload)) - { - sdp_message_a_attribute_add (local_sdp, - pos, - osip_strdup ("AS"), - osip_strdup ("111 20")); - } - k++; - } while (payload != NULL); - } - pos++; - } - } - - i = sdp_message_to_str(local_sdp, &local_body); - - if (local_body!=NULL) - { - size= (char *)osip_malloc(7*sizeof(char)); -#ifdef __APPLE_CC__ - sprintf(size,"%li",strlen(local_body)); -#else - sprintf(size,"%i",strlen(local_body)); -#endif - osip_message_set_content_length(orig_request, size); - osip_free(size); - - osip_message_set_body(orig_request, local_body, strlen(local_body)); - osip_message_set_content_type(orig_request, "application/sdp"); - } - else - osip_message_set_content_length(orig_request, "0"); - - osip_negotiation_ctx_set_local_sdp(jc->c_ctx, local_sdp); - - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO3,NULL,"200 OK w/ SDP (RESPONSE TO INVITE w/ NO SDP)=\n%s\n", local_body)); - - return local_body; -} - -char * -generating_sdp_answer(osip_message_t *request, osip_negotiation_ctx_t *context) -{ - sdp_message_t *remote_sdp; - sdp_message_t *local_sdp = NULL; - int i; - char *local_body; - if (context==NULL) - return NULL; - - local_body = NULL; - if (MSG_IS_INVITE(request)||MSG_IS_OPTIONS(request)||MSG_IS_RESPONSE_FOR(request, "INVITE")) - { - osip_body_t *body; - body = (osip_body_t *)osip_list_get(request->bodies,0); - if(body == NULL) - return NULL; - - /* remote_sdp = (sdp_message_t *) osip_malloc(sizeof(sdp_message_t)); */ - i = sdp_message_init(&remote_sdp); - if (i!=0) return NULL; - - /* WE ASSUME IT IS A SDP BODY AND THAT */ - /* IT IS THE ONLY ONE, OF COURSE, THIS IS */ - /* NOT TRUE */ - i = sdp_message_parse(remote_sdp,body->body); - if (i!=0) return NULL; - - i = osip_negotiation_ctx_set_remote_sdp(context, remote_sdp); - - i = osip_negotiation_ctx_execute_negotiation(eXosip.osip_negotiation, context); - if (i==200) - { - local_sdp = osip_negotiation_ctx_get_local_sdp(context); - - if (eXosip.j_firewall_ip[0]!='\0') - { - char *c_address = NULL; - int pos=0; - /* If remote message contains a Public IP, we have to replace the SDP - connection address */ - c_address = sdp_message_c_addr_get(remote_sdp, -1, 0); - while (c_address==NULL) - { - c_address = sdp_message_c_addr_get(remote_sdp, pos, 0); - pos++; - if (pos>10) - break; - } - if (c_address!=NULL) /* found a connection address: check if it is public */ - { - - struct addrinfo *addrinfo; - struct __eXosip_sockaddr addr; - i = eXosip_get_addrinfo(&addrinfo, c_address, 5060); - if (i==0) - { - memcpy (&addr, addrinfo->ai_addr, addrinfo->ai_addrlen); - freeaddrinfo (addrinfo); - c_address = inet_ntoa (((struct sockaddr_in *) &addr)->sin_addr); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO1, NULL, - "eXosip: here is the resolved destination host=%s\n", c_address)); - } - - if (eXosip_is_public_address(c_address)) - { - /* replace the IP with our firewall ip */ - sdp_connection_t *conn; - pos=-1; - conn = sdp_message_connection_get(local_sdp, pos, 0); - while (conn!=NULL) - { - if (conn->c_addr!=NULL ) - { - osip_free(conn->c_addr); - conn->c_addr = osip_strdup(eXosip.j_firewall_ip); - } - pos++; - conn = sdp_message_connection_get(local_sdp, pos, 0); - } - } - } - } - - i = sdp_message_to_str(local_sdp, &local_body); - - remote_sdp = osip_negotiation_ctx_get_remote_sdp(context); - sdp_message_free(remote_sdp); - osip_negotiation_ctx_set_remote_sdp(context, NULL); - - if (i!=0) { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"ERROR: Could not parse local SDP answer %i\n",i)); - return NULL; - } - return local_body; - } - else if (i==415) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"WARNING: Unsupported media %i\n",i)); - } - else - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"ERROR: while building answer to SDP (%i)\n",i)); - } - remote_sdp = osip_negotiation_ctx_get_remote_sdp(context); - sdp_message_free(remote_sdp); - osip_negotiation_ctx_set_remote_sdp(context, NULL); - } - return NULL; -} - -int -eXosip_answer_options_1xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code) -{ - osip_event_t *evt_answer; - osip_transaction_t *tr; - osip_message_t *response; - int i; - - tr = eXosip_find_last_inc_options(jc, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return -1; - } - - if (jd!=NULL) - { - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - } - else - { - i = _eXosip_build_response_default(&response, NULL, code, tr->orig_request); - } - - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"ERROR: Could not create response for OPTIONS\n")); - return -1; - } - - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - return 0; -} - -int -eXosip_answer_options_2xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code) -{ - osip_event_t *evt_answer; - osip_transaction_t *tr; - osip_message_t *response; - sdp_message_t *sdp; - char *body; - char size[10]; - int i; - - tr = eXosip_find_last_inc_options(jc, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return -1; - } - osip_negotiation_sdp_build_offer(eXosip.osip_negotiation, NULL, &sdp, "10400", NULL); - if (sdp==NULL) - { - return -1; - } - if (jd!=NULL) - { - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - } - else - { - i = _eXosip_build_response_default(&response, NULL, code, tr->orig_request); - } - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for options\n")); - sdp_message_free(sdp); /* not used */ - return -1; - } - i = sdp_message_to_str(sdp, &body); - sdp_message_free(sdp); - if (i!=0) { - osip_message_free(response); - return -1; - } - i = osip_message_set_body(response, body, strlen(body)); - if (i!=0) { - osip_message_free(response); - return -1; - } -#ifdef __APPLE_CC__ - snprintf(size, 9,"%li",strlen(body)); -#else - snprintf(size, 9,"%i",strlen(body)); -#endif - i = osip_message_set_content_length(response, size); - if (i!=0) { - osip_free(body); - osip_message_free(response); - return -1; - } - osip_free(body); - i = osip_message_set_content_type(response, "application/sdp"); - if (i!=0) { - osip_message_free(response); - return -1; - } - - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - return 0; -} - -int -eXosip_answer_options_3456xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code) -{ - osip_event_t *evt_answer; - osip_transaction_t *tr; - osip_message_t *response; - int i; - tr = eXosip_find_last_inc_options(jc, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return -1; - } - - if (jd!=NULL) - { - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - } - else - { - i = _eXosip_build_response_default(&response, NULL, code, tr->orig_request); - } - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for options\n")); - return -1; - } - - if (300<=code<=399) - { - /* Should add contact fields */ - /* ... */ - osip_message_set_contact(response, jc->c_redirection); - } - - osip_message_set_content_length(response, "0"); - /* send message to transaction layer */ - - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - - return 0; -} - -int -_eXosip2_answer_invite_1xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code, osip_message_t **answer) -{ - int i; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_invite(jc, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return -1; - } - /* is the transaction already answered? */ - if (tr->state==IST_COMPLETED - || tr->state==IST_CONFIRMED - || tr->state==IST_TERMINATED) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: transaction already answered\n")); - return -1; - } - - if (jd==NULL) - i = _eXosip_build_response_default(answer, NULL, code, tr->orig_request); - else - i = _eXosip_build_response_default(answer, jd->d_dialog, code, tr->orig_request); - - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"ERROR: Could not create response for invite\n")); - return -2; - } - - osip_message_set_content_length(*answer, "0"); - /* send message to transaction layer */ - - if (code>100) - { - i = complete_answer_that_establish_a_dialog(*answer, tr->orig_request); - } - - return 0; -} - -int -_eXosip2_answer_invite_2xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code, osip_message_t **answer) -{ - int i; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_invite(jc, jd); - - if (tr==NULL || tr->orig_request==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer\n")); - return -1; - } - - if (jd!=NULL && jd->d_dialog==NULL) - { /* element previously removed */ - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot answer this closed transaction\n")); - return -1; - } - - /* is the transaction already answered? */ - if (tr->state==IST_COMPLETED - || tr->state==IST_CONFIRMED - || tr->state==IST_TERMINATED) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: transaction already answered\n")); - return -1; - } - - if (jd==NULL) - i = _eXosip_build_response_default(answer, NULL, code, tr->orig_request); - else - i = _eXosip_build_response_default(answer, jd->d_dialog, code, tr->orig_request); - - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for invite\n")); - return -1; - } - - /* request that estabish a dialog: */ - /* 12.1.1 UAS Behavior */ - { - i = complete_answer_that_establish_a_dialog(*answer, tr->orig_request); - if (i!=0) goto g2atii_error_1;; /* ?? */ - } - - return 0; - - g2atii_error_1: - osip_message_free(*answer); - return -1; -} - -int -_eXosip2_answer_invite_3456xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code, osip_message_t **answer) -{ - int i; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_invite(jc, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return -1; - } - /* is the transaction already answered? */ - if (tr->state==IST_COMPLETED - || tr->state==IST_CONFIRMED - || tr->state==IST_TERMINATED) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: transaction already answered\n")); - return -1; - } - - i = _eXosip_build_response_default(answer, jd->d_dialog, code, tr->orig_request); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for invite\n")); - return -1; - } - - if (300<=code<=399) - { - /* Should add contact fields */ - /* ... */ - } - - osip_message_set_content_length(*answer, "0"); - /* send message to transaction layer */ - - return 0; -} - -int -eXosip_answer_invite_1xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code) -{ - osip_event_t *evt_answer; - osip_message_t *response; - int i; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_invite(jc, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return -1; - } - /* is the transaction already answered? */ - if (tr->state==IST_COMPLETED - || tr->state==IST_CONFIRMED - || tr->state==IST_TERMINATED) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: transaction already answered\n")); - return -1; - } - - if (jd==NULL) - i = _eXosip_build_response_default(&response, NULL, code, tr->orig_request); - else - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"ERROR: Could not create response for invite\n")); - return -2; - } - - osip_message_set_content_length(response, "0"); - /* send message to transaction layer */ - - if (code>100) - { - /* request that estabish a dialog: */ - /* 12.1.1 UAS Behavior */ - i = complete_answer_that_establish_a_dialog(response, tr->orig_request); - - if (jd==NULL) - { - i = eXosip_dialog_init_as_uas(&jd, tr->orig_request, response); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog!\n")); - } - ADD_ELEMENT(jc->c_dialogs, jd); - } - } - - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - - return 0; -} - -int -eXosip_answer_invite_2xx_with_body(eXosip_call_t *jc, eXosip_dialog_t *jd, int code,const char*bodytype, const char*body) -{ - osip_event_t *evt_answer; - osip_message_t *response; - int i; - char *size; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_invite(jc, jd); - - if (tr==NULL || tr->orig_request==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer\n")); - return -1; - } - - if (jd!=NULL && jd->d_dialog==NULL) - { /* element previously removed */ - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot answer this closed transaction\n")); - return -1; - } - - /* is the transaction already answered? */ - if (tr->state==IST_COMPLETED - || tr->state==IST_CONFIRMED - || tr->state==IST_TERMINATED) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: transaction already answered\n")); - return -1; - } - - if (jd==NULL) - i = _eXosip_build_response_default(&response, NULL, code, tr->orig_request); - else - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for invite\n")); - code = 500; /* ? which code to use? */ - return -1; - } - - if (code==488) - { - osip_message_set_content_length(response, "0"); - /* TODO: send message to transaction layer */ - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - return 0; - } - - i = osip_message_set_body(response, body, strlen(body)); - if (i!=0) { - goto g2atii_error_1; - } - size = (char *) osip_malloc(6*sizeof(char)); - sprintf(size,"%i",strlen(body)); - i = osip_message_set_content_length(response, size); - osip_free(size); - if (i!=0) goto g2atii_error_1; - i = osip_message_set_content_type(response, bodytype); - if (i!=0) goto g2atii_error_1; - - /* request that estabish a dialog: */ - /* 12.1.1 UAS Behavior */ - { - i = complete_answer_that_establish_a_dialog(response, tr->orig_request); - if (i!=0) goto g2atii_error_1;; /* ?? */ - } - /* THIS RESPONSE MUST BE SENT RELIABILY until the final ACK is received !! */ - /* this response must be stored at the upper layer!!! (it will be destroyed*/ - /* right after being sent! */ - - if (jd==NULL) - { - i = eXosip_dialog_init_as_uas(&jd, tr->orig_request, response); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog!\n")); - return -1; - } - ADD_ELEMENT(jc->c_dialogs, jd); - } - - eXosip_dialog_set_200ok(jd, response); - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - - osip_dialog_set_state(jd->d_dialog, DIALOG_CONFIRMED); - __eXosip_wakeup(); - return 0; - - g2atii_error_1: - osip_message_free(response); - return -1; -} - -int -eXosip_answer_invite_2xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code, char *local_sdp_port) -{ - osip_event_t *evt_answer; - osip_message_t *response; - int i; - char *size; - char *body = NULL; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_invite(jc, jd); - - if (tr==NULL || tr->orig_request==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer\n")); - return -1; - } - - if (jd!=NULL && jd->d_dialog==NULL) - { /* element previously removed */ - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot answer this closed transaction\n")); - return -1; - } - - /* is the transaction already answered? */ - if (tr->state==IST_COMPLETED - || tr->state==IST_CONFIRMED - || tr->state==IST_TERMINATED) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: transaction already answered\n")); - return -1; - } - - /* WE SHOULD LOOK FOR A SDP PACKET!! */ - if(NULL != osip_list_get(tr->orig_request->bodies,0)) - { - body = generating_sdp_answer(tr->orig_request, jc->c_ctx); - if (body==NULL) - code = 488; /* bad sdp */ - } - else - { - if(local_sdp_port==NULL) - code = 488; /* session description in the request is not acceptable. */ - else - /* body is NULL (contains no SDP), generate a response to INVITE w/ no SDP */ - body = generating_no_sdp_answer(jc, jd, tr->orig_request, local_sdp_port); - } - - if (jd==NULL) - i = _eXosip_build_response_default(&response, NULL, code, tr->orig_request); - else - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for invite\n")); - code = 500; /* ? which code to use? */ - osip_free(body); /* not used */ - return -1; - } - - if (code==488) - { - osip_message_set_content_length(response, "0"); - /* TODO: send message to transaction layer */ - osip_free(body); - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - return 0; - } - - i = osip_message_set_body(response, body, strlen(body)); - if (i!=0) { - goto g2atii_error_1; - } - size = (char *) osip_malloc(6*sizeof(char)); -#ifdef __APPLE_CC__ - sprintf(size,"%li",strlen(body)); -#else - sprintf(size,"%i",strlen(body)); -#endif - i = osip_message_set_content_length(response, size); - osip_free(size); - if (i!=0) goto g2atii_error_1; - i = osip_message_set_content_type(response, "application/sdp"); - if (i!=0) goto g2atii_error_1; - - /* request that estabish a dialog: */ - /* 12.1.1 UAS Behavior */ - { - i = complete_answer_that_establish_a_dialog(response, tr->orig_request); - if (i!=0) goto g2atii_error_1;; /* ?? */ - } - - osip_free(body); - /* THIS RESPONSE MUST BE SENT RELIABILY until the final ACK is received !! */ - /* this response must be stored at the upper layer!!! (it will be destroyed*/ - /* right after being sent! */ - - if (jd==NULL) - { - i = eXosip_dialog_init_as_uas(&jd, tr->orig_request, response); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog!\n")); - return -1; - } - ADD_ELEMENT(jc->c_dialogs, jd); - } - - eXosip_dialog_set_200ok(jd, response); - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - - osip_dialog_set_state(jd->d_dialog, DIALOG_CONFIRMED); - __eXosip_wakeup(); - return 0; - - g2atii_error_1: - osip_free(body); - osip_message_free(response); - return -1; -} - -int -eXosip_answer_invite_3456xx(eXosip_call_t *jc, eXosip_dialog_t *jd, int code) -{ - osip_event_t *evt_answer; - osip_message_t *response; - int i; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_invite(jc, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return -1; - } - /* is the transaction already answered? */ - if (tr->state==IST_COMPLETED - || tr->state==IST_CONFIRMED - || tr->state==IST_TERMINATED) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: transaction already answered\n")); - return -1; - } - - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for invite\n")); - return -1; - } - - if (300<=code<=399) - { - /* Should add contact fields */ - /* ... */ - osip_message_set_contact(response, jc->c_redirection); - } - - osip_message_set_content_length(response, "0"); - /* send message to transaction layer */ - - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - return 0; -} - - -void -eXosip_notify_answer_subscribe_1xx(eXosip_notify_t *jn, eXosip_dialog_t *jd, int code) -{ - osip_event_t *evt_answer; - osip_message_t *response; - int i; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_subscribe(jn, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return; - } - - if (jd==NULL) - i = _eXosip_build_response_default(&response, NULL, code, tr->orig_request); - else - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"ERROR: Could not create response for subscribe\n")); - return; - } - - if (code>100) - { - /* request that estabish a dialog: */ - /* 12.1.1 UAS Behavior */ - i = complete_answer_that_establish_a_dialog(response, tr->orig_request); - - if (jd==NULL) - { - i = eXosip_dialog_init_as_uas(&jd, tr->orig_request, response); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog!\n")); - } - ADD_ELEMENT(jn->n_dialogs, jd); - } - } - - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - return ; -} - -void -eXosip_notify_answer_subscribe_2xx(eXosip_notify_t *jn, eXosip_dialog_t *jd, int code) -{ - osip_event_t *evt_answer; - osip_message_t *response; - int i; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_subscribe(jn, jd); - - if (tr==NULL || tr->orig_request==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer\n")); - return; - } - - if (jd!=NULL && jd->d_dialog==NULL) - { /* element previously removed, this is a no hop! */ - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot answer this closed transaction\n")); - return ; - } - - if (jd==NULL) - i = _eXosip_build_response_default(&response, NULL, code, tr->orig_request); - else - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for subscribe\n")); - code = 500; /* ? which code to use? */ - return; - } - - /* request that estabish a dialog: */ - /* 12.1.1 UAS Behavior */ - { - i = complete_answer_that_establish_a_dialog(response, tr->orig_request); - if (i!=0) goto g2atii_error_1;; /* ?? */ - } - - /* THIS RESPONSE MUST BE SENT RELIABILY until the final ACK is received !! */ - /* this response must be stored at the upper layer!!! (it will be destroyed*/ - /* right after being sent! */ - - if (jd==NULL) - { - i = eXosip_dialog_init_as_uas(&jd, tr->orig_request, response); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog!\n")); - return; - } - ADD_ELEMENT(jn->n_dialogs, jd); - } - - eXosip_dialog_set_200ok(jd, response); - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - - osip_dialog_set_state(jd->d_dialog, DIALOG_CONFIRMED); - return ; - - g2atii_error_1: - osip_message_free(response); - return ; -} - -void -eXosip_notify_answer_subscribe_3456xx(eXosip_notify_t *jn, eXosip_dialog_t *jd, int code) -{ - osip_event_t *evt_answer; - osip_message_t *response; - int i; - osip_transaction_t *tr; - tr = eXosip_find_last_inc_subscribe(jn, jd); - if (tr==NULL) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot find transaction to answer")); - return; - } - i = _eXosip_build_response_default(&response, jd->d_dialog, code, tr->orig_request); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for subscribe\n")); - return; - } - - if (300<=code<=399) - { - /* Should add contact fields */ - /* ... */ - } - - evt_answer = osip_new_outgoing_sipmessage(response); - evt_answer->transactionid = tr->transactionid; - - osip_transaction_add_event(tr, evt_answer); - __eXosip_wakeup(); - return ; -} diff --git a/linphone/exosip/jsubscribe.c b/linphone/exosip/jsubscribe.c deleted file mode 100644 index d6b9ad11b..000000000 --- a/linphone/exosip/jsubscribe.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - - -#include "eXosip2.h" -#include - -extern eXosip_t eXosip; - -#if 0 -int eXosip_subscribe_find(int sid, eXosip_subscribe_t **js) -{ - for (*js=eXosip.j_subscribes; *js!=NULL; *js=(*js)->next) - { - if ((*js)->s_id==sid) - return 0; - } - *js = NULL; - return -1; -} -#endif - -osip_transaction_t * -eXosip_find_last_out_subscribe(eXosip_subscribe_t *js, eXosip_dialog_t *jd ) -{ - osip_transaction_t *out_tr; - int pos; - out_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (0==strcmp(out_tr->cseq->method, "SUBSCRIBE")) - break; - else out_tr = NULL; - pos++; - } - } - else - out_tr = NULL; - - if (out_tr==NULL) - return js->s_out_tr; /* can be NULL */ - - return out_tr; -} - -osip_transaction_t * -eXosip_find_last_inc_notify(eXosip_subscribe_t *js, eXosip_dialog_t *jd ) -{ - osip_transaction_t *out_tr; - int pos; - out_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (0==strcmp(out_tr->cseq->method, "NOTIFY")) - return out_tr; - pos++; - } - } - - return NULL; -} - - -#if 0 -void -__eXosip_subscribe_remove_dialog_reference_in_subscribe(eXosip_subscribe_t *js, eXosip_dialog_t *jd) -{ - eXosip_dialog_t *_jd; - jinfo_t *ji; - if (js==NULL) return; - if (jd==NULL) return; - - - for (_jd = js->s_dialogs; _jd!=NULL; _jd=js->s_dialogs) - { - if (jd==_jd) - break; - } - if (_jd==NULL) - { - /* dialog not found??? */ - } - - ji = osip_transaction_get_your_instance(js->s_inc_tr); - if (ji!=NULL && ji->jd==jd) - ji->jd=NULL; - ji = osip_transaction_get_your_instance(js->s_out_tr); - if (ji!=NULL && ji->jd==jd) - ji->jd=NULL; -} -#endif - -int -eXosip_subscribe_init(eXosip_subscribe_t **js, char *uri) -{ - if (uri==NULL) return -1; - *js = (eXosip_subscribe_t *)osip_malloc(sizeof(eXosip_subscribe_t)); - if (*js == NULL) return -1; - memset(*js, 0, sizeof(eXosip_subscribe_t)); - osip_strncpy((*js)->s_uri, uri, strlen(uri)); - return 0; -} - -void -eXosip_subscribe_free(eXosip_subscribe_t *js) -{ - /* ... */ - - eXosip_dialog_t *jd; - - for (jd = js->s_dialogs; jd!=NULL; jd=js->s_dialogs) - { - REMOVE_ELEMENT(js->s_dialogs, jd); - eXosip_dialog_free(jd); - } - - __eXosip_delete_jinfo(js->s_inc_tr); - __eXosip_delete_jinfo(js->s_out_tr); - if (js->s_inc_tr!=NULL) - osip_list_add(eXosip.j_transactions, js->s_inc_tr, 0); - if (js->s_out_tr!=NULL) - osip_list_add(eXosip.j_transactions, js->s_out_tr, 0); - - osip_free(js); -} - -int -_eXosip_subscribe_set_refresh_interval(eXosip_subscribe_t *js, - osip_message_t *out_subscribe) -{ - osip_header_t *exp; - int now = time(NULL); - if (js==NULL || out_subscribe==NULL) - return -1; - - osip_message_get_expires(out_subscribe, 0, &exp); - if (exp==NULL || exp->hvalue==NULL) - js->s_ss_expires = now + 600; - else - { - js->s_ss_expires = osip_atoi(exp->hvalue); - if (js->s_ss_expires!=-1) - js->s_ss_expires = now + js->s_ss_expires; - else /* on error, set it to default */ - js->s_ss_expires = now + 600; - } - - return 0; -} - -int eXosip_subscribe_need_refresh(eXosip_subscribe_t *js, int now) -{ - if (now-js->s_ss_expires>-120) - return 0; - return -1; -} - -int eXosip_subscribe_send_subscribe(eXosip_subscribe_t *js, - eXosip_dialog_t *jd, const char *expires) -{ - osip_transaction_t *transaction; - osip_message_t *subscribe; - osip_event_t *sipevent; - int i; - transaction = eXosip_find_last_out_subscribe(js, jd); - if (transaction!=NULL) - { - if (transaction->state!=NICT_TERMINATED && - transaction->state!=NIST_TERMINATED) - return -1; - } - - i = _eXosip_build_request_within_dialog(&subscribe, "SUBSCRIBE", - jd->d_dialog, "UDP"); - if (i!=0) - return -2; - - osip_message_set_expires(subscribe, expires); - - i = osip_transaction_init(&transaction, - NICT, - eXosip.j_osip, - subscribe); - if (i!=0) - { - /* TODO: release the j_call.. */ - osip_message_free(subscribe); - return -1; - } - - _eXosip_subscribe_set_refresh_interval(js, subscribe); - osip_list_add(jd->d_out_trs, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(subscribe); - sipevent->transactionid = transaction->transactionid; - - osip_transaction_add_event(transaction, sipevent); - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, jd, js, NULL)); - __eXosip_wakeup(); - return 0; -} diff --git a/linphone/exosip/jsubscribers.c b/linphone/exosip/jsubscribers.c deleted file mode 100644 index a4242b43b..000000000 --- a/linphone/exosip/jsubscribers.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" -#include -#include - -extern eXosip_t eXosip; - -#ifndef EXOSIP_ETC_DIR -#define EXOSIP_ETC_DIR ".eXosip" -#endif - -#ifndef EXOSIP_ADDSUBSCRIBERS_SH -#define EXOSIP_ADDSUBSCRIBERS_SH "eXosip_addsubscriber.sh" -#endif - - -static int jsubscriber_init(jsubscriber_t **js, char *ch) -{ - char *next; - int i; - - *js = (jsubscriber_t *)osip_malloc(sizeof(jsubscriber_t)); - if (*js==NULL) return -1; - - i = jfriend_get_and_set_next_token(&((*js)->s_nick), ch, &next); - if (i != 0) - goto js_error1; - osip_clrspace ((*js)->s_nick); - ch = next; - - i = jfriend_get_and_set_next_token(&((*js)->s_uri), ch, &next); - if (i != 0) - goto js_error2; - osip_clrspace ((*js)->s_uri); - ch = next; - - (*js)->s_allow = osip_strdup(next); - osip_clrspace ((*js)->s_allow); - - return 0; - - js_error2: - osip_free((*js)->s_nick); - js_error1: - osip_free(*js); - *js = NULL; - return -1; -} - -void -jsubscriber_unload() -{ - jsubscriber_t *js; - if (eXosip.j_subscribers==NULL) return; - for (js=eXosip.j_subscribers; js!=NULL; js=eXosip.j_subscribers) - { - REMOVE_ELEMENT(eXosip.j_subscribers,js); - osip_free(js->s_nick); - osip_free(js->s_uri); - osip_free(js->s_allow); - osip_free(js); - } - - osip_free(eXosip.j_subscribers); - eXosip.j_subscribers=NULL; - return; -} - -int -jsubscriber_load() -{ - FILE *file; - char *s; - jsubscriber_t *js; - int pos; - char *home; - char filename[255]; - - jsubscriber_unload(); - home = getenv("HOME"); - sprintf(filename, "%s/%s/%s", home, EXOSIP_ETC_DIR, "jm_subscriber"); - - - file = fopen(filename, "r"); - if (file==NULL) return -1; - s = (char *)osip_malloc(255*sizeof(char)); - pos = 0; - while (NULL!=fgets(s, 254, file)) - { - char *tmp = s; - while (*tmp!='\0' && *tmp!=' ') tmp++; - while (*tmp!='\0' && *tmp==' ') tmp++; - while (*tmp!='\0' && *tmp!=' ') tmp++; - tmp++; /* first usefull characters */ - pos++; - - jsubscriber_init(&js, tmp); - if (js!=NULL) - { ADD_ELEMENT(eXosip.j_subscribers, js); } - } - osip_free(s); - fclose(file); - - return 0; /* ok */ -} - -void subscribers_add(char *nickname, char *uri, int black_list) -{ - char *home; - char command[256]; - char *tmp = command; - int length = 0; - if (nickname!=NULL) - length = strlen(nickname); - - if (uri==NULL) - return ; - home = getenv("HOME"); - length = length + strlen(home); - length = length + strlen(uri); - - length = length + 10; /* for black_list info */ - length = length + strlen(EXOSIP_ETC_DIR); - - length = length + strlen("/jm_subscriber"); - if (length>235) /* leave some room for SPACEs and \r\n */ - return ; - - sprintf(tmp , "%s %s/%s/jm_subscriber", EXOSIP_ADDSUBSCRIBERS_SH, home, EXOSIP_ETC_DIR); - - tmp = tmp + strlen(tmp); - if (nickname!=NULL) - sprintf(tmp , " %s", nickname); - else - sprintf(tmp , " \"\""); - - tmp = tmp + strlen(tmp); - sprintf(tmp , " %s", uri); - - tmp = tmp + strlen(tmp); - if (black_list==0) /* allowed */ - sprintf(tmp , " allow"); - else - sprintf(tmp , " reject"); - - system(command); - - jsubscriber_load(); -} - -char * -jsubscriber_get_uri(int fid) -{ - jsubscriber_t *js; - for (js = eXosip.j_subscribers; js!=NULL ; js=js->next) - { - if (fid==0) - return osip_strdup(js->s_uri); - fid--; - } - return NULL; -} diff --git a/linphone/exosip/misc.c b/linphone/exosip/misc.c deleted file mode 100644 index 2be6b1a45..000000000 --- a/linphone/exosip/misc.c +++ /dev/null @@ -1,436 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - - -#include "eXosip2.h" - -extern eXosip_t eXosip; - - -/* some methods to extract transaction information from a eXosip_call_t */ - -int -eXosip_remove_transaction_from_call(osip_transaction_t *tr, eXosip_call_t *jc) -{ - osip_transaction_t *inc_tr; - osip_transaction_t *out_tr; - eXosip_dialog_t *jd; - int pos=0; - - if (jc->c_inc_tr==tr) - { - jc->c_inc_tr = NULL; /* can be NULL */ - return 0; - } - - for (jd=jc->c_dialogs;jd!=NULL;jd=jd->next) - { - pos=0; - while (!osip_list_eol(jd->d_inc_trs, pos)) - { - inc_tr = osip_list_get(jd->d_inc_trs, pos); - if (inc_tr==tr) - { - osip_list_remove(jd->d_inc_trs, pos); - return 0; - } - pos++; - } - } - - if (jc->c_out_tr==tr) - { - jc->c_out_tr = NULL; /* can be NULL */ - return 0; - } - - for (jd=jc->c_dialogs;jd!=NULL;jd=jd->next) - { - pos=0; - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (out_tr==tr) - { - osip_list_remove(jd->d_out_trs, pos); - return 0; - } - pos++; - } - } - - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "eXosip: No information.\n")); - return -1; -} - -osip_transaction_t * -eXosip_find_last_options(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - osip_transaction_t *out_tr; - inc_tr = eXosip_find_last_inc_options(jc, jd); - out_tr = eXosip_find_last_out_options(jc, jd); - if (inc_tr==NULL) - return out_tr; - if (out_tr==NULL) - return inc_tr; - - if (inc_tr->birth_time>out_tr->birth_time) - return inc_tr; - return out_tr; -} - -osip_transaction_t * -eXosip_find_last_inc_options(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - int pos; - inc_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_inc_trs, pos)) - { - inc_tr = osip_list_get(jd->d_inc_trs, pos); - if (0==strcmp(inc_tr->cseq->method, "OPTIONS")) - break; - else inc_tr = NULL; - pos++; - } - } - else - inc_tr = NULL; - - if (inc_tr==NULL) - return jc->c_inc_options_tr; /* can be NULL */ - - return inc_tr; -} - -osip_transaction_t * -eXosip_find_last_out_options(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *out_tr; - int pos; - out_tr = NULL; - pos=0; - if (jd==NULL && jc==NULL) return NULL; - - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (0==strcmp(out_tr->cseq->method, "OPTIONS")) - break; - else out_tr = NULL; - pos++; - } - } - - if (out_tr==NULL) - return jc->c_out_options_tr; /* can be NULL */ - - return out_tr; -} - -osip_transaction_t * -eXosip_find_last_info(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - osip_transaction_t *out_tr; - inc_tr = eXosip_find_last_inc_info(jc, jd); - out_tr = eXosip_find_last_out_info(jc, jd); - if (inc_tr==NULL) - return out_tr; - if (out_tr==NULL) - return inc_tr; - - if (inc_tr->birth_time>out_tr->birth_time) - return inc_tr; - return out_tr; -} - -osip_transaction_t * -eXosip_find_last_inc_info(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - int pos; - inc_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_inc_trs, pos)) - { - inc_tr = osip_list_get(jd->d_inc_trs, pos); - if (0==strcmp(inc_tr->cseq->method, "INFO")) - break; - else inc_tr = NULL; - pos++; - } - } - else - inc_tr = NULL; - - return inc_tr; -} - -osip_transaction_t * -eXosip_find_last_out_info(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *out_tr; - int pos; - out_tr = NULL; - pos=0; - if (jd==NULL && jc==NULL) return NULL; - - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (0==strcmp(out_tr->cseq->method, "INFO")) - break; - else out_tr = NULL; - pos++; - } - } - - return out_tr; -} - -osip_transaction_t * -eXosip_find_last_refer(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - osip_transaction_t *out_tr; - inc_tr = eXosip_find_last_inc_refer(jc, jd); - out_tr = eXosip_find_last_out_refer(jc, jd); - if (inc_tr==NULL) - return out_tr; - if (out_tr==NULL) - return inc_tr; - - if (inc_tr->birth_time>out_tr->birth_time) - return inc_tr; - return out_tr; -} - -osip_transaction_t * -eXosip_find_last_invite(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - osip_transaction_t *out_tr; - inc_tr = eXosip_find_last_inc_invite(jc, jd); - out_tr = eXosip_find_last_out_invite(jc, jd); - if (inc_tr==NULL) - return out_tr; - if (out_tr==NULL) - return inc_tr; - - if (inc_tr->birth_time>out_tr->birth_time) - return inc_tr; - return out_tr; -} - -osip_transaction_t * -eXosip_find_last_inc_invite(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - int pos; - inc_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_inc_trs, pos)) - { - inc_tr = osip_list_get(jd->d_inc_trs, pos); - if (0==strcmp(inc_tr->cseq->method, "INVITE")) - break; - else inc_tr = NULL; - pos++; - } - } - else - inc_tr = NULL; - - if (inc_tr==NULL) - return jc->c_inc_tr; /* can be NULL */ - - return inc_tr; -} - -osip_transaction_t * -eXosip_find_last_out_invite(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *out_tr; - int pos; - out_tr = NULL; - pos=0; - if (jd==NULL && jc==NULL) return NULL; - - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (0==strcmp(out_tr->cseq->method, "INVITE")) - break; - else out_tr = NULL; - pos++; - } - } - - if (out_tr==NULL) - return jc->c_out_tr; /* can be NULL */ - - return out_tr; -} - -osip_transaction_t * -eXosip_find_last_inc_bye(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - int pos; - inc_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_inc_trs, pos)) - { - inc_tr = osip_list_get(jd->d_inc_trs, pos); - if (0==strcmp(inc_tr->cseq->method, "BYE")) - return inc_tr; - pos++; - } - } - - return NULL; -} - -osip_transaction_t * -eXosip_find_last_out_bye(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *out_tr; - int pos; - out_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (0==strcmp(out_tr->cseq->method, "BYE")) - return out_tr; - pos++; - } - } - - return NULL; -} - -osip_transaction_t * -eXosip_find_last_inc_refer(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - int pos; - inc_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_inc_trs, pos)) - { - inc_tr = osip_list_get(jd->d_inc_trs, pos); - if (0==strcmp(inc_tr->cseq->method, "REFER")) - return inc_tr; - pos++; - } - } - - return NULL; -} - -osip_transaction_t * -eXosip_find_last_out_refer(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *out_tr; - int pos; - out_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (0==strcmp(out_tr->cseq->method, "REFER")) - return out_tr; - pos++; - } - } - - return NULL; -} - -osip_transaction_t * -eXosip_find_last_inc_notify_for_refer(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *inc_tr; - int pos; - inc_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_inc_trs, pos)) - { - inc_tr = osip_list_get(jd->d_inc_trs, pos); - if (0==strcmp(inc_tr->cseq->method, "NOTIFY")) - return inc_tr; - pos++; - } - } - - return NULL; -} - -osip_transaction_t * -eXosip_find_last_out_notify_for_refer(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *out_tr; - int pos; - out_tr = NULL; - pos=0; - if (jd!=NULL) - { - while (!osip_list_eol(jd->d_out_trs, pos)) - { - out_tr = osip_list_get(jd->d_out_trs, pos); - if (0==strcmp(out_tr->cseq->method, "NOTIFY")) - return out_tr; - pos++; - } - } - - return NULL; -} diff --git a/linphone/exosip/sdp_offans.c b/linphone/exosip/sdp_offans.c deleted file mode 100644 index 0abef586c..000000000 --- a/linphone/exosip/sdp_offans.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" - -extern eXosip_t eXosip; - -osip_list_t *supported_codec = NULL; - -int eXosip_sdp_accept_audio_codec(osip_negotiation_ctx_t *context, - char *port, char *number_of_port, - int audio_qty, char *payload); -int eXosip_sdp_accept_video_codec(osip_negotiation_ctx_t *context, - char *port, char *number_of_port, - int video_qty, char *payload); -int eXosip_sdp_accept_other_codec(osip_negotiation_ctx_t *context, - char *type, char *port, - char *number_of_port, char *payload); - -char *eXosip_sdp_get_audio_port(osip_negotiation_ctx_t *context, int pos_media); - -int eXosip_sdp_accept_audio_codec(osip_negotiation_ctx_t *context, - char *port, char *number_of_port, - int audio_qty, char *payload) -{ - int pos; - for (pos=0;!osip_list_eol(supported_codec, pos);pos++) - { - char *_payload; - _payload = osip_list_get(supported_codec, pos); - if (0==strcmp(payload,_payload)) - { - /* - We have to look at the rtpmap attributes in context->remote - to check if we support this stuff. - */ - - return 0; - } - } - return -1; -} - -int eXosip_sdp_accept_video_codec(osip_negotiation_ctx_t *context, - char *port, char *number_of_port, - int video_qty, char *payload) -{ - return -1; -} - -int eXosip_sdp_accept_other_codec(osip_negotiation_ctx_t *context, - char *type, char *port, - char *number_of_port, char *payload) -{ - /* ... */ - return -1; -} - -char *eXosip_sdp_get_audio_port(osip_negotiation_ctx_t *context, int pos_media) -{ - eXosip_call_t *jc = (eXosip_call_t*)osip_negotiation_ctx_get_mycontext(context); - if (jc==NULL) - return osip_strdup("10500"); - else if (jc->c_sdp_port[0]=='\0') - return osip_strdup("10500"); - else return osip_strdup(jc->c_sdp_port); -} - -int eXosip_sdp_negotiation_replace(osip_negotiation_t *sn) -{ - if (eXosip.osip_negotiation!=NULL) - osip_negotiation_free(eXosip.osip_negotiation); - eXosip.osip_negotiation = sn; - return 0; -} - -void -eXosip_sdp_negotiation_ctx_set_mycontext(struct eXosip_call_t *jc, void *arg) -{ - osip_negotiation_ctx_set_mycontext(jc->c_ctx, arg); -} - -void eXosip_sdp_negotiation_remove_audio_payloads() -{ - if (supported_codec==NULL) - return; - for (;!osip_list_eol(supported_codec, 0);) - { - char *p; - p = (char *) osip_list_get(supported_codec, 0); - osip_free(p); - osip_list_remove(supported_codec, 0); - } - osip_negotiation_remove_audio_payloads(eXosip.osip_negotiation); -} - -void eXosip_sdp_negotiation_add_codec(char *payload, char *number_of_port, - char *proto, char *c_nettype, - char *c_addrtype, char *c_addr, - char *c_addr_multicast_ttl, - char *c_addr_multicast_int, - char *a_rtpmap) -{ - osip_negotiation_add_support_for_audio_codec(eXosip.osip_negotiation, - payload, - number_of_port, - proto, - c_nettype, - c_addrtype, - c_addr, - c_addr_multicast_ttl, - c_addr_multicast_int, - a_rtpmap); - osip_list_add(supported_codec, osip_strdup(payload), -1); -} - -int eXosip_sdp_negotiation_init(osip_negotiation_t **sn) -{ - int i = osip_negotiation_init(sn); - if (i!=0) { - return -1; - } - if (supported_codec==NULL) - { - supported_codec = (osip_list_t*) osip_malloc(sizeof(osip_list_t)); - osip_list_init(supported_codec); - } - osip_negotiation_set_o_username(*sn, osip_strdup("userX")); - osip_negotiation_set_o_session_id(*sn, osip_strdup("20000001")); - osip_negotiation_set_o_session_version(*sn, osip_strdup("20000001")); - osip_negotiation_set_o_nettype(*sn, osip_strdup("IN")); - osip_negotiation_set_o_addrtype(*sn, osip_strdup("IP4")); - osip_negotiation_set_o_addr(*sn, osip_strdup(eXosip.localip)); - - osip_negotiation_set_c_nettype(*sn, osip_strdup("IN")); - osip_negotiation_set_c_addrtype(*sn, osip_strdup("IP4")); - osip_negotiation_set_c_addr(*sn, osip_strdup(eXosip.localip)); - - /* ALL CODEC MUST SHARE THE SAME "C=" line and proto as the media - will appear on the same "m" line... */ - - osip_negotiation_set_fcn_accept_audio_codec(*sn, &eXosip_sdp_accept_audio_codec); - osip_negotiation_set_fcn_accept_video_codec(*sn, &eXosip_sdp_accept_video_codec); - - osip_negotiation_set_fcn_accept_other_codec(*sn, &eXosip_sdp_accept_other_codec); - osip_negotiation_set_fcn_get_audio_port(*sn, &eXosip_sdp_get_audio_port); - - return 0; -} - -void eXosip_sdp_negotiation_free(osip_negotiation_t *sn) -{ - if (sn==NULL) - return; - osip_list_ofchar_free(supported_codec); - supported_codec = NULL; - osip_negotiation_free(sn); -} - -sdp_message_t * -eXosip_get_local_sdp_info(osip_transaction_t *invite_tr) -{ - osip_content_type_t *ctt; - osip_mime_version_t *mv; - osip_message_t *message; - sdp_message_t *sdp; - osip_body_t *oldbody; - int pos; - - if (invite_tr->ctx_type == IST) - message = invite_tr->last_response; - else if (invite_tr->ctx_type == ICT) - message = invite_tr->orig_request; - else return NULL; /* BUG -> NOT AN INVITE TRANSACTION!! */ - - if (message==NULL) return NULL; - - /* get content-type info */ - ctt = osip_message_get_content_type(message); - mv = osip_message_get_mime_version(message); - if (mv==NULL && ctt==NULL) - return NULL; /* previous message was not correct or empty */ - if (mv!=NULL) - { - /* look for the SDP body */ - /* ... */ - } - else if (ctt!=NULL) - { - if (ctt->type==NULL || ctt->subtype==NULL) - /* it can be application/sdp or mime... */ - return NULL; - if (osip_strcasecmp(ctt->type, "application")!=0 || - osip_strcasecmp(ctt->subtype, "sdp")!=0 ) - { return NULL; } - } - - pos=0; - while (!osip_list_eol(message->bodies, pos)) - { - int i; - oldbody = (osip_body_t *) osip_list_get(message->bodies, pos); - pos++; - sdp_message_init(&sdp); - i = sdp_message_parse(sdp,oldbody->body); - if (i==0) return sdp; - sdp_message_free(sdp); - sdp = NULL; - } - return NULL; -} - -sdp_message_t * -eXosip_get_remote_sdp_info(osip_transaction_t *invite_tr) -{ - osip_content_type_t *ctt; - osip_mime_version_t *mv; - osip_message_t *message; - sdp_message_t *sdp; - osip_body_t *oldbody; - int pos; - - if (invite_tr->ctx_type == IST) - message = invite_tr->orig_request; - else if (invite_tr->ctx_type == ICT) - message = invite_tr->last_response; - else return NULL; /* BUG -> NOT AN INVITE TRANSACTION!! */ - - if (message==NULL) return NULL; - - /* get content-type info */ - ctt = osip_message_get_content_type(message); - mv = osip_message_get_mime_version(message); - if (mv==NULL && ctt==NULL) - return NULL; /* previous message was not correct or empty */ - if (mv!=NULL) - { - /* look for the SDP body */ - /* ... */ - } - else if (ctt!=NULL) - { - if (ctt->type==NULL || ctt->subtype==NULL) - /* it can be application/sdp or mime... */ - return NULL; - if (osip_strcasecmp(ctt->type, "application")!=0 || - osip_strcasecmp(ctt->subtype, "sdp")!=0 ) - { return NULL; } - } - - pos=0; - while (!osip_list_eol(message->bodies, pos)) - { - int i; - oldbody = (osip_body_t *) osip_list_get(message->bodies, pos); - pos++; - sdp_message_init(&sdp); - i = sdp_message_parse(sdp,oldbody->body); - if (i==0) return sdp; - sdp_message_free(sdp); - sdp = NULL; - } - return NULL; -} - -int eXosip_retrieve_sdp_negotiation_result(osip_negotiation_ctx_t *ctx, char *payload_name, int pnsize) -{ - sdp_message_t *local_sdp = 0; - int payload_result = -1; - - if (!ctx) - return payload_result; - - local_sdp = osip_negotiation_ctx_get_local_sdp(ctx); - - if (local_sdp != NULL) - { - sdp_media_t *med = (sdp_media_t*) osip_list_get(local_sdp->m_medias, 0); - char *payload = (char *) osip_list_get (med->m_payloads, 0); - int pos_attr; - - if (payload!=NULL) - { - payload_result = osip_atoi(payload); - - /* copy payload name! */ - for (pos_attr=0; - !osip_list_eol(med->a_attributes, pos_attr); - pos_attr++) - { - sdp_attribute_t *attr; - attr = (sdp_attribute_t *)osip_list_get(med->a_attributes, pos_attr); - if (0==osip_strncasecmp(attr->a_att_field, "rtpmap", 6)) - { - if ((payload_result <10 && - 0==osip_strncasecmp(attr->a_att_value, payload, 1)) - ||(payload_result>9 && payload_result<100 && - 0==osip_strncasecmp(attr->a_att_value, payload, 2)) - ||(payload_result >100 && payload_result<128 && - 0==osip_strncasecmp(attr->a_att_value, payload, 3))) - { - snprintf(payload_name, pnsize, "%s", attr->a_att_value); - return payload_result; - } - } - } - } - } - - return payload_result; - -} diff --git a/linphone/exosip/udp.c b/linphone/exosip/udp.c deleted file mode 100644 index e192c2646..000000000 --- a/linphone/exosip/udp.c +++ /dev/null @@ -1,2635 +0,0 @@ -/* - eXosip - This is the eXtended osip library. - Copyright (C) 2002, 2003 Aymeric MOIZARD - jack@atosc.org - - eXosip is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - eXosip is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#ifdef ENABLE_MPATROL -#include -#endif - -#include "eXosip2.h" -#include -#include - -#ifndef WIN32 -#include -#include -#include -#include -#ifdef __APPLE_CC__ -#include -#endif -#else -#include -#include -#endif - -extern eXosip_t eXosip; - -/* Private functions */ -static void eXosip_send_default_answer(eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt, - int status, - char *reason_phrase, - char *warning, - int line); -static void eXosip_process_info(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt); -static void eXosip_process_options(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt); -static void eXosip_process_bye(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt); -static void eXosip_process_refer(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt); -static void eXosip_process_ack(eXosip_call_t *jc, eXosip_dialog_t *jd, osip_event_t *evt); -static int cancel_match_invite(osip_transaction_t *invite, osip_message_t *cancel); -static void eXosip_process_cancel(osip_transaction_t *transaction, osip_event_t *evt); -static osip_event_t *eXosip_process_reinvite(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt, sdp_message_t *remote_sdp); -static void eXosip_process_invite_on_hold(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt, sdp_message_t *sdp); -static void eXosip_process_invite_off_hold(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt, sdp_message_t *sdp); -static void eXosip_process_new_options(osip_transaction_t *transaction, osip_event_t *evt); -static void eXosip_process_new_invite(osip_transaction_t *transaction, osip_event_t *evt); -static void eXosip_process_invite_within_call(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt); -static int eXosip_event_package_is_supported(osip_transaction_t *transaction, - osip_event_t *evt); -static void eXosip_process_new_subscribe(osip_transaction_t *transaction, - osip_event_t *evt); -static void eXosip_process_subscribe_within_call(eXosip_notify_t *jn, - eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt); -static void eXosip_process_notify_within_dialog(eXosip_subscribe_t *js, - eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt); -static int eXosip_match_notify_for_subscribe(eXosip_subscribe_t *js, osip_message_t *notify); -static void eXosip_process_newrequest(osip_event_t *evt); -static void eXosip_process_response_out_of_transaction(osip_event_t *evt); -static int eXosip_pendingosip_transaction_exist(eXosip_call_t *jc, eXosip_dialog_t *jd); -static int eXosip_release_finished_calls(eXosip_call_t *jc, eXosip_dialog_t *jd); -static int eXosip_release_aborted_calls(eXosip_call_t *jc, eXosip_dialog_t *jd); - - -static void eXosip_send_default_answer(eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt, - int status, - char *reason_phrase, - char *warning, - int line) -{ - osip_event_t *evt_answer; - osip_message_t *answer; - int i; - - /* osip_list_add(eXosip.j_transactions, transaction, 0); */ - osip_transaction_set_your_instance(transaction, NULL); - - /* THIS METHOD DOES NOT ACCEPT STATUS CODE BETWEEN 101 and 299 */ - if (status>100 && status<299 && MSG_IS_INVITE(evt->sip)) - return ; - - if (jd!=NULL) - i = _eXosip_build_response_default(&answer, jd->d_dialog, status, evt->sip); - else - i = _eXosip_build_response_default(&answer, NULL, status, evt->sip); - - if (i!=0 || answer==NULL) - { - return ; - } - - if (reason_phrase!=NULL) - { - char *_reason; - _reason = osip_message_get_reason_phrase(answer); - if (_reason!=NULL) - osip_free(_reason); - _reason = osip_strdup(reason_phrase); - osip_message_set_reason_phrase(answer, _reason); - } - - osip_message_set_content_length(answer, "0"); - - if (status==500) - osip_message_set_retry_after(answer, "10"); - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - osip_transaction_add_event(transaction,evt_answer); - __eXosip_wakeup(); - -} - -static void -__eXosip_report_event(int evt, eXosip_call_t *jc, eXosip_dialog_t *jd, eXosip_event_t *je ) -{ - if (!je) - je = eXosip_event_init_for_call(evt, jc, jd); - - if (eXosip.j_call_callbacks[evt]!=NULL) - eXosip.j_call_callbacks[evt](evt, je); - else if (eXosip.j_runtime_mode==EVENT_MODE) - eXosip_event_add(je); -} - - -static void eXosip_process_options(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt) -{ - osip_event_t *evt_answer; - osip_message_t *answer; - int i; - - osip_transaction_set_your_instance(transaction, - __eXosip_new_jinfo(jc, - NULL /*jd */, - NULL, - NULL)); - i = _eXosip_build_response_default(&answer, jd->d_dialog, 200, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - return ; - } - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - - osip_list_add(jd->d_inc_trs, transaction , 0); - - osip_transaction_add_event(transaction,evt_answer); - __eXosip_wakeup(); -} - -static void eXosip_process_info(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt) -{ - osip_event_t *evt_answer; - osip_message_t *answer; - int i; - - osip_transaction_set_your_instance(transaction, - __eXosip_new_jinfo(jc, - jd, - NULL, - NULL)); - /* for now, send default response of 200ok. eventually, application should - be deciding how to answer INFO messages */ - i = _eXosip_build_response_default(&answer, jd->d_dialog, 200, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - return ; - } - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - - osip_list_add(jd->d_inc_trs, transaction , 0); - - osip_transaction_add_event(transaction,evt_answer); - __eXosip_wakeup(); -} - - -static void eXosip_process_bye(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt) -{ - osip_event_t *evt_answer; - osip_message_t *answer; - int i; - - osip_transaction_set_your_instance(transaction, - __eXosip_new_jinfo(jc, - NULL /*jd */, - NULL, - NULL)); - - i = _eXosip_build_response_default(&answer, jd->d_dialog, 200, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - return ; - } - osip_message_set_content_length(answer, "0"); - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - - osip_list_add(jd->d_inc_trs, transaction , 0); - - /* Release the eXosip_dialog */ - osip_dialog_free(jd->d_dialog); - jd->d_dialog = NULL; - __eXosip_report_event(EXOSIP_CALL_CLOSED, jc, jd, NULL); - - osip_transaction_add_event(transaction,evt_answer); - __eXosip_wakeup(); -} - -static void eXosip_process_refer(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt) -{ - osip_event_t *evt_answer; - osip_message_t *answer; - osip_header_t *referto_head = NULL; - osip_contact_t *referto; - int i; - - /* check if the refer is valid */ - osip_message_header_get_byname(evt->sip, "refer-to", 0, &referto_head); - if (referto_head==NULL || referto_head->hvalue==NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 400, "Missing Refer-To header", "Missing Refer-To header", __LINE__); - return; - } - /* check if refer-to is well-formed */ - osip_contact_init(&referto); - i = osip_contact_parse(referto, referto_head->hvalue); - if (i!=0) - { - osip_contact_free(referto); - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 400, "Non valid Refer-To header", "Non valid Refer-To header", __LINE__); - return; - } - if (0!=osip_strcasecmp(referto->url->scheme, "sip")) - { - osip_contact_free(referto); - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 501, "Scheme Not Implemented", "Scheme Not Implemented", __LINE__); - return; - } - - osip_contact_free(referto); - - /* check policy so we can decline immediatly the refer */ - - osip_transaction_set_your_instance(transaction, - __eXosip_new_jinfo(jc, - jd, - NULL, - NULL)); - - i = _eXosip_build_response_default(&answer, jd->d_dialog, 202, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - return ; - } - - i = complete_answer_that_establish_a_dialog(answer, evt->sip); - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - - osip_list_add(jd->d_inc_trs, transaction , 0); - - osip_transaction_add_event(transaction,evt_answer); - __eXosip_wakeup(); - - _eXosip_transfer_send_notify(jc, jd, EXOSIP_SUBCRSTATE_ACTIVE, "SIP/2.0 100 Trying"); -} - -static void eXosip_process_notify_for_refer(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt) -{ - osip_event_t *evt_answer; - osip_message_t *answer; - int i; - osip_transaction_t *ref; - osip_header_t *event_hdr; - osip_header_t *sub_state; - osip_content_type_t *ctype; - osip_body_t *body = NULL; - - /* get the event type and return "489 Bad Event". */ - osip_message_header_get_byname(evt->sip, "event", 0, &event_hdr); - if (event_hdr==NULL || event_hdr->hvalue==NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 481, "Missing Event header in Notify", "Missing Event header in Notify", __LINE__); - return ; - } - if (0!=osip_strcasecmp(event_hdr->hvalue, "refer")) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 501, "Unsupported Event header", "Unsupported Event header in Notify", __LINE__); - return ; - } - osip_message_header_get_byname(evt->sip, "subscription-state", - 0, - &sub_state); - if (sub_state==NULL||sub_state->hvalue==NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 400, NULL, NULL, __LINE__); - return; - } - - ctype = osip_message_get_content_type(evt->sip); - if (ctype==NULL || ctype->type==NULL || ctype->subtype==NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 400, "Missing Header", "Missing Content-Type Header", __LINE__); - return ; - } - if (0!=osip_strcasecmp(ctype->type, "message") - || 0!=osip_strcasecmp(ctype->subtype, "sipfrag")) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 501, "Unsupported body type", "Unsupported body type", __LINE__); - return ; - } - - osip_message_get_body(evt->sip, 0, &body); - if (body==NULL || body->body==NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 400, "Missing Body", "Missing Body", __LINE__); - return ; - } - - - { - eXosip_event_t *je; - int len; - je = eXosip_event_init_for_call(EXOSIP_CALL_REFER_STATUS, jc, jd); - if (je==NULL) return; - - len = strlen(body->body); - if (len<999) - osip_strncpy(je->sdp_body, body->body, len); - else - osip_strncpy(je->sdp_body, body->body, 999); - - __eXosip_report_event(EXOSIP_CALL_REFER_STATUS, NULL, NULL, je); - } - - /* check if a refer was sent previously! */ - ref = eXosip_find_last_out_refer(jc, jd); - if (ref==NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 481, NULL, "Not associated refer", __LINE__); - return ; - } - - osip_transaction_set_your_instance(transaction, - __eXosip_new_jinfo(jc, - jd, - NULL, - NULL)); - /* for now, send default response of 200ok. eventually, application should - be deciding how to answer INFO messages */ - i = _eXosip_build_response_default(&answer, jd->d_dialog, 200, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - return ; - } - - i = complete_answer_that_establish_a_dialog(answer, evt->sip); - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - - osip_list_add(jd->d_inc_trs, transaction , 0); - - osip_transaction_add_event(transaction,evt_answer); - __eXosip_wakeup(); -} - -static void eXosip_process_ack(eXosip_call_t *jc, eXosip_dialog_t *jd, osip_event_t *evt) -{ - eXosip_event_t *je; - je = eXosip_event_init_for_call(EXOSIP_CALL_ACK, jc, jd); - if (je==NULL) return; - - /* MBW - for SDP in ACK used in alternate SDP offer-response model */ - eXosip_event_add_sdp_info(je, evt->sip); - __eXosip_report_event(EXOSIP_CALL_ACK, NULL, NULL, je); - - osip_event_free(evt); -} - -static int cancel_match_invite(osip_transaction_t *invite, osip_message_t *cancel) -{ - osip_generic_param_t *br; - osip_generic_param_t *br2; - osip_via_t *via; - osip_via_param_get_byname (invite->topvia, "branch", &br); - via = osip_list_get(cancel->vias, 0); - if (via==NULL) return -1; /* request without via??? */ - osip_via_param_get_byname (via, "branch", &br2); - if (br!=NULL && br2==NULL) - return -1; - if (br2!=NULL && br==NULL) - return -1; - if (br2!=NULL && br!=NULL) /* compliant UA :) */ - { - if (br->gvalue!=NULL && br2->gvalue!=NULL && - 0==strcmp(br->gvalue, br2->gvalue)) - return 0; - return -1; - } - /* old backward compatibility mechanism */ - if (0 != osip_call_id_match (invite->callid, cancel->call_id)) - return -1; - if (0 != osip_to_tag_match (invite->to, cancel->to)) - return -1; - if (0 != osip_from_tag_match (invite->from, cancel->from)) - return -1; - if (0 != osip_cseq_match (invite->cseq, cancel->cseq)) - return -1; - if (0 != osip_via_match (invite->topvia, via)) - return -1; - return 0; -} - -static void eXosip_process_cancel(osip_transaction_t *transaction, osip_event_t *evt) -{ - osip_transaction_t *tr; - osip_event_t *evt_answer; - osip_message_t *answer; - int i; - - eXosip_call_t *jc; - eXosip_dialog_t *jd; - - tr = NULL; - jd = NULL; - /* first, look for a Dialog in the map of element */ - for (jc = eXosip.j_calls; jc!= NULL ; jc=jc->next) - { - if (jc->c_inc_tr!=NULL) - { - i = cancel_match_invite(jc->c_inc_tr, evt->sip); - if (i==0) { - tr = jc->c_inc_tr; - break; - } - } - tr=NULL; - for (jd = jc->c_dialogs; jd!= NULL ; jd=jd->next) - { - int pos=0; - while (!osip_list_eol(jd->d_inc_trs, pos)) - { - tr = osip_list_get(jd->d_inc_trs, pos); - i = cancel_match_invite(tr, evt->sip); - if (i==0) - break; - tr = NULL; - pos++; - } - } - if (jd!=NULL) break; /* tr has just been found! */ - } - - if (tr==NULL) /* we didn't found the transaction to cancel */ - { - i = _eXosip_build_response_default(&answer, NULL, 481, evt->sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot cancel transaction.\n")); - osip_list_add(eXosip.j_transactions, tr, 0); - osip_transaction_set_your_instance(tr, NULL); - return ; - } - osip_message_set_content_length(answer, "0"); - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - osip_transaction_add_event(transaction,evt_answer); - - osip_list_add(eXosip.j_transactions, transaction, 0); - osip_transaction_set_your_instance(transaction, NULL); - __eXosip_wakeup(); - return; - } - - if (tr->state==IST_TERMINATED || tr->state==IST_CONFIRMED - || tr->state==IST_COMPLETED) - { - /* I can't find the status code in the rfc? - (I read I must answer 200? wich I found strange) - I probably misunderstood it... and prefer to send 481 - as the transaction has been answered. */ - if (jd==NULL) - i = _eXosip_build_response_default(&answer, NULL, 481, evt->sip); - else - i = _eXosip_build_response_default(&answer, jd->d_dialog, 481, evt->sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot cancel transaction.\n")); - osip_list_add(eXosip.j_transactions, tr, 0); - osip_transaction_set_your_instance(tr, NULL); - return ; - } - osip_message_set_content_length(answer, "0"); - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - osip_transaction_add_event(transaction,evt_answer); - - if (jd!=NULL) - osip_list_add(jd->d_inc_trs, transaction , 0); - else - osip_list_add(eXosip.j_transactions, transaction, 0); - osip_transaction_set_your_instance(transaction, NULL); - __eXosip_wakeup(); - - return ; - } - - { - if (jd==NULL) - i = _eXosip_build_response_default(&answer, NULL, 200, evt->sip); - else - i = _eXosip_build_response_default(&answer, jd->d_dialog, 200, evt->sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot cancel transaction.\n")); - osip_list_add(eXosip.j_transactions, tr, 0); - osip_transaction_set_your_instance(tr, NULL); - return ; - } - osip_message_set_content_length(answer, "0"); - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - osip_transaction_add_event(transaction,evt_answer); - __eXosip_wakeup(); - - if (jd!=NULL) - osip_list_add(jd->d_inc_trs, transaction , 0); - else - osip_list_add(eXosip.j_transactions, transaction, 0); - osip_transaction_set_your_instance(transaction, NULL); - - /* answer transaction to cancel */ - if (jd==NULL) - i = _eXosip_build_response_default(&answer, NULL, 487, - tr->orig_request); - else - i = _eXosip_build_response_default(&answer, jd->d_dialog, 487, - tr->orig_request); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot cancel transaction.\n")); - osip_list_add(eXosip.j_transactions, tr, 0); - osip_transaction_set_your_instance(tr, NULL); - return ; - } - osip_message_set_content_length(answer, "0"); - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = tr->transactionid; - osip_transaction_add_event(tr,evt_answer); - __eXosip_wakeup(); - } -} - -static osip_event_t * -eXosip_process_reinvite(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt, sdp_message_t *remote_sdp) -{ - sdp_message_t *local_sdp; - osip_message_t *answer; - osip_event_t *sipevent; - int i; - - /* We must negociate... */ - local_sdp = NULL; - if (remote_sdp!=NULL) { - sdp_message_t *old_remote_sdp = osip_negotiation_ctx_get_remote_sdp(jc->c_ctx); - if (old_remote_sdp!=NULL) - { - sdp_message_free(old_remote_sdp); - } - osip_negotiation_ctx_set_remote_sdp(jc->c_ctx, remote_sdp); - local_sdp = osip_negotiation_ctx_get_local_sdp(jc->c_ctx); - if (local_sdp!=NULL) - { - sdp_message_free(local_sdp); - osip_negotiation_ctx_set_local_sdp(jc->c_ctx, NULL); - } - local_sdp = NULL; - i = osip_negotiation_ctx_execute_negotiation(eXosip.osip_negotiation, jc->c_ctx); - - if (i!=200) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, i, NULL, NULL, 0); - return NULL; - } - local_sdp = osip_negotiation_ctx_get_local_sdp(jc->c_ctx); - } - -#if 0 - if (remote_sdp==NULL) - { - sdp_message_t *local_sdp; - osip_negotiation_sdp_build_offer(eXosip.osip_negotiation, NULL, &local_sdp, "25563", NULL); - osip_negotiation_ctx_set_local_sdp(jc->c_ctx, local_sdp); - - if (local_sdp==NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, NULL, NULL, __LINE__); - return NULL; - } - } -#endif - - i = _eXosip_build_response_default(&answer, jd->d_dialog, 200, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Internal SIP Error", "Failed to build Answer for INVITE within call", __LINE__); - return NULL; - } - - complete_answer_that_establish_a_dialog(answer, evt->sip); - - if (local_sdp!=NULL) - { - char *local_body; - char *size; - - osip_negotiation_ctx_set_local_sdp(jc->c_ctx, NULL); - i = sdp_message_to_str(local_sdp, &local_body); - sdp_message_free(local_sdp); - if (i!=0) { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Internal SDP Error", "SDP packet is corrupted", __LINE__); - osip_message_free(answer); - return NULL; - } - i = osip_message_set_body(answer, local_body, strlen(local_body)); - if (i!=0) { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Internal SDP Error", "SDP cannot be added in message", __LINE__); - osip_free(local_body); - osip_message_free(answer); - return NULL; - } - size = (char *) osip_malloc(6*sizeof(char)); -#ifdef __APPLE_CC__ - sprintf(size,"%li",strlen(local_body)); -#else - sprintf(size,"%i",strlen(local_body)); -#endif - osip_free(local_body); - osip_message_set_content_length(answer, size); - osip_free(size); - i = osip_message_set_content_type(answer, "application/sdp"); - if (i!=0) { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Internal SIP Error", "Content-Type cannot be added in message", __LINE__); - osip_message_free(answer); - return NULL; - } - - } - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(jc, jd, NULL, NULL)); - sipevent = osip_new_outgoing_sipmessage(answer); - sipevent->transactionid = transaction->transactionid; - - osip_list_add(jd->d_inc_trs, transaction, 0); - return sipevent; -} - - -static void eXosip_process_invite_on_hold(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt, sdp_message_t *sdp) -{ - osip_event_t *sipevent; - sipevent = eXosip_process_reinvite(jc, jd, transaction, evt, sdp); - if (sipevent==NULL) - return; /* ERROR */ - { - eXosip_event_t *je; - je = eXosip_event_init_for_call(EXOSIP_CALL_HOLD, jc, jd); - eXosip_event_add_status(je, sipevent->sip); - eXosip_event_add_sdp_info(je, evt->sip); - __eXosip_report_event(EXOSIP_CALL_HOLD, NULL, NULL, je); - } - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); -} - -static void eXosip_process_invite_off_hold(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt, sdp_message_t *sdp) -{ - osip_event_t *sipevent; - sipevent = eXosip_process_reinvite(jc, jd, transaction, evt, sdp); - if (sipevent==NULL) - return; /* ERROR */ - { - eXosip_event_t *je; - je = eXosip_event_init_for_call(EXOSIP_CALL_OFFHOLD, jc, jd); - eXosip_event_add_status(je, sipevent->sip); - eXosip_event_add_sdp_info(je, evt->sip); - __eXosip_report_event(EXOSIP_CALL_OFFHOLD, NULL, NULL, je); - } - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); -} - -static void eXosip_process_new_options(osip_transaction_t *transaction, osip_event_t *evt) -{ - osip_event_t *evt_answer; - osip_message_t *answer; - int i; - - i = _eXosip_build_response_default(&answer, NULL, 200, evt->sip); - if (i!=0) - { - return ; - } - - osip_list_add(eXosip.j_transactions, transaction, 0); - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - - osip_transaction_add_event(transaction,evt_answer); - __eXosip_wakeup(); -} - -static void eXosip_process_new_invite(osip_transaction_t *transaction, osip_event_t *evt) -{ - osip_event_t *evt_answer; - int i; - eXosip_call_t *jc; - eXosip_dialog_t *jd; - osip_message_t *answer; - - eXosip_call_init(&jc); - /* eXosip_call_set_subect... */ - - ADD_ELEMENT(eXosip.j_calls, jc); - - i = _eXosip_build_response_default(&answer, NULL, 101, evt->sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog.")); - osip_list_add(eXosip.j_transactions, transaction, 0); - osip_transaction_set_your_instance(transaction, NULL); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"ERROR: Could not create response for invite\n")); - return; - } - osip_message_set_content_length(answer, "0"); - i = complete_answer_that_establish_a_dialog(answer, evt->sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot complete answer!\n")); - osip_list_add(eXosip.j_transactions, transaction, 0); - osip_transaction_set_your_instance(transaction, NULL); - osip_message_free(answer); - return ; - } - - i = eXosip_dialog_init_as_uas(&jd, evt->sip, answer); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog!\n")); - osip_list_add(eXosip.j_transactions, transaction, 0); - osip_transaction_set_your_instance(transaction, NULL); - osip_message_free(answer); - return ; - } - ADD_ELEMENT(jc->c_dialogs, jd); - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(jc, jd, NULL, NULL)); - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; -#ifdef AUTO_RING /* default is now to not send a 180 Ringing */ - osip_transaction_add_event(transaction, evt_answer); - __eXosip_wakeup(); -#endif - -#ifdef AUTO_RING /* default is now to not send a 180 Ringing */ - i = _eXosip_build_response_default(&answer, jd->d_dialog, 180, evt->sip); - - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot send ringback.")); - osip_list_add(eXosip.j_transactions, transaction, 0); - osip_transaction_set_your_instance(transaction, NULL); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"ERROR: Could not create response for invite\n")); - return; - } - i = complete_answer_that_establish_a_dialog(answer, evt->sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot complete answer!\n")); - osip_list_add(eXosip.j_transactions, transaction, 0); - osip_transaction_set_your_instance(transaction, NULL); - osip_message_free(answer); - return ; - } - - osip_message_set_content_length(answer, "0"); - /* send message to transaction layer */ - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; -#endif - - eXosip_update(); - jc->c_inc_tr = transaction; - osip_transaction_add_event(transaction, evt_answer); - - /* be sure the invite will be processed - before any API call on this dialog*/ - osip_ist_execute(eXosip.j_osip); - - if (transaction->orig_request!=NULL) - { - eXosip_event_t *je; - je = eXosip_event_init_for_call(EXOSIP_CALL_NEW, jc, jd); - if (je!=NULL) - { - osip_header_t *subject; - char *tmp; - osip_message_get_subject(transaction->orig_request, 0, &subject); - if (subject!=NULL && subject->hvalue!=NULL && subject->hvalue[0]!='\0') - snprintf(je->subject, 255, "%s", subject->hvalue); - osip_uri_to_str(transaction->orig_request->req_uri, &tmp); - if (tmp!=NULL) - { - snprintf(je->req_uri, 255, "%s", tmp); - osip_free(tmp); - } - eXosip_event_add_sdp_info(je, transaction->orig_request); - eXosip_event_add_status(je, answer); - } - __eXosip_report_event(EXOSIP_CALL_NEW, NULL, NULL, je); - } - - __eXosip_wakeup(); - -} - -static void eXosip_process_invite_within_call(eXosip_call_t *jc, eXosip_dialog_t *jd, - osip_transaction_t *transaction, osip_event_t *evt) -{ - sdp_message_t *sdp; - int i; - int pos; - int pos_media; - char *sndrcv; - char *ipaddr; - - /* Is this a "on hold" message? */ - sdp = NULL; - pos = 0; - i = 500; - while (!osip_list_eol(evt->sip->bodies,pos)) - { - osip_body_t *body; - body = (osip_body_t *)osip_list_get(evt->sip->bodies,pos); - pos++; - - i = sdp_message_init(&sdp); - if (i!=0) break; - - /* WE ASSUME IT IS A SDP BODY AND THAT */ - /* IT IS THE ONLY ONE, OF COURSE, THIS IS */ - /* NOT TRUE */ - if (body->body!=NULL) - { - i = sdp_message_parse(sdp,body->body); - if (i==0) { - i = 200; - break; - } - } - sdp_message_free(sdp); - sdp = NULL; - } - - if (pos!=0 && i!=200) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 400, NULL, NULL, __LINE__); - return; - } - - /* TODO: we should verify the content-type */ - if (pos!=0) - { - pos_media=-1; - pos = 0; - ipaddr = NULL; - while (!sdp_message_endof_media(sdp, pos_media)) - { - ipaddr = sdp_message_c_addr_get(sdp, pos_media, pos); - while (ipaddr!=NULL) /* only one is allowed here? */ - { - if (pos==1 && pos_media==-1) - break; - if (0==osip_strcasecmp("0.0.0.0", ipaddr)) - break; - pos++; - ipaddr = sdp_message_c_addr_get(sdp, pos_media, pos); - } - if (pos==1 && pos_media==-1) - ipaddr=NULL; - if (ipaddr!=NULL) - break; - pos = 0; - pos_media++; - } - - if (ipaddr==NULL) - { - sndrcv = NULL; - pos_media=-1; - pos = 0; - while (!sdp_message_endof_media(sdp, pos_media)) - { - sndrcv = sdp_message_a_att_field_get(sdp, pos_media, pos); - while (sndrcv!=NULL) - { - if (0==osip_strcasecmp("inactive", sndrcv) || 0==osip_strcasecmp("sendonly", sndrcv)) - break; - pos++; - sndrcv = sdp_message_a_att_field_get(sdp, pos_media, pos); - } - if (sndrcv!=NULL) - break; - pos = 0; - pos_media++; - } - } - - if (ipaddr!=NULL || (sndrcv!=NULL && (0==osip_strcasecmp("inactive", sndrcv) - || 0==osip_strcasecmp("sendonly", sndrcv)))) - { - /* We received an INVITE to put on hold the other party. */ - eXosip_process_invite_on_hold(jc, jd, transaction, evt, sdp); - return; - } - else - { - /* This is a call modification, probably for taking it of hold */ - eXosip_process_invite_off_hold(jc, jd, transaction, evt, sdp); - return; - } - } - eXosip_process_invite_off_hold(jc, jd, transaction, evt, NULL); - return; -} - -static int eXosip_event_package_is_supported(osip_transaction_t *transaction, - osip_event_t *evt) -{ - osip_header_t *event_hdr; - int code; - - /* get the event type and return "489 Bad Event". */ - osip_message_header_get_byname(evt->sip, "event", 0, &event_hdr); - if (event_hdr==NULL || event_hdr->hvalue==NULL) - { -#ifdef SUPPORT_MSN - /* msn don't show any event header */ - code = 200; /* Bad Request... anyway... */ -#else - code = 400; /* Bad Request */ -#endif - } - else if (0!=osip_strcasecmp(event_hdr->hvalue, "presence")) - code = 489; - else code = 200; - if (code!=200) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(NULL, transaction, evt, code, NULL, NULL, __LINE__); - return 0; - } - return -1; -} - -static void eXosip_process_new_subscribe(osip_transaction_t *transaction, - osip_event_t *evt) -{ - osip_event_t *evt_answer; - eXosip_notify_t *jn; - eXosip_dialog_t *jd; - osip_message_t *answer; - int code; - int i; - - eXosip_notify_init(&jn, evt->sip); - _eXosip_notify_set_refresh_interval(jn, evt->sip); - - i = _eXosip_build_response_default(&answer, NULL, 101, evt->sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog.")); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL,"ERROR: Could not create response for invite\n")); - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_notify_free(jn); - return; - } - i = complete_answer_that_establish_a_dialog(answer, evt->sip); - if (i!=0) - { - osip_message_free(answer); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot complete answer!\n")); - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_notify_free(jn); - return ; - } - - i = eXosip_dialog_init_as_uas(&jd, evt->sip, answer); - if (i!=0) - { - osip_message_free(answer); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot create dialog!\n")); - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_notify_free(jn); - return ; - } - ADD_ELEMENT(jn->n_dialogs, jd); - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, jd, NULL, jn)); - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - osip_transaction_add_event(transaction, evt_answer); - - ADD_ELEMENT(eXosip.j_notifies, jn); - __eXosip_wakeup(); - - /* There should be a list of already accepted freinds for which we - have already accepted the subscription. */ - if (0==_eXosip_notify_is_a_known_subscriber(evt->sip)) - code = 200; - else - code = 202; - - i = _eXosip_build_response_default(&answer, jd->d_dialog, code, evt->sip); - if (i!=0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,"ERROR: Could not create response for subscribe\n")); - osip_list_add(eXosip.j_transactions, transaction, 0); - return; - } - - _eXosip_notify_add_expires_in_2XX_for_subscribe(jn, answer); - - { - - i = complete_answer_that_establish_a_dialog(answer, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - osip_message_free(answer); - return; - } - } - - jn->n_inc_tr = transaction; - - /* eXosip_dialog_set_200ok(jd, answer); */ - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - - osip_transaction_add_event(transaction, evt_answer); - - osip_dialog_set_state(jd->d_dialog, DIALOG_CONFIRMED); - - eXosip_update(); - __eXosip_wakeup(); -} - -static void eXosip_process_subscribe_within_call(eXosip_notify_t *jn, - eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt) -{ - osip_message_t *answer; - osip_event_t *sipevent; - int i; - - _eXosip_notify_set_refresh_interval(jn, evt->sip); - i = _eXosip_build_response_default(&answer, jd->d_dialog, 200, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Internal SIP Error", "Failed to build Answer for SUBSCRIBE", __LINE__); - return ; - } - - _eXosip_notify_add_expires_in_2XX_for_subscribe(jn, answer); - - { - - i = complete_answer_that_establish_a_dialog(answer, evt->sip); - if (i!=0) - { - /* this info is yet known by the remote UA, - so we don't have to exit here */ - } - } - - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, jd, NULL, jn)); - sipevent = osip_new_outgoing_sipmessage(answer); - sipevent->transactionid = transaction->transactionid; - osip_transaction_add_event(transaction, sipevent); - __eXosip_wakeup(); - - /* if subscribe request contains expires="0", close the subscription */ - { - int now = time(NULL); - if (jn->n_ss_expires-now<=0) - { - jn->n_ss_status=EXOSIP_SUBCRSTATE_TERMINATED; - jn->n_ss_reason=TIMEOUT; - } - } - - osip_list_add(jd->d_inc_trs, transaction, 0); - - eXosip_notify_send_notify(jn, jd, jn->n_ss_status, - jn->n_online_status); - return; -} - -static void -eXosip_process_notify_within_dialog(eXosip_subscribe_t *js, - eXosip_dialog_t *jd, - osip_transaction_t *transaction, - osip_event_t *evt) -{ - osip_message_t *answer; - osip_event_t *sipevent; - osip_header_t *sub_state; -#ifdef SUPPORT_MSN - osip_header_t *expires; -#endif - int i; - - if (jd==NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Internal SIP Error", "No dialog for this NOTIFY", __LINE__); - return ; - } - - /* if subscription-state has a reason state set to terminated, - we close the dialog */ -#ifndef SUPPORT_MSN - osip_message_header_get_byname(evt->sip, "subscription-state", - 0, - &sub_state); - if (sub_state==NULL||sub_state->hvalue==NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 400, NULL, NULL, __LINE__); - return; - } -#endif - - i = _eXosip_build_response_default(&answer, jd->d_dialog, 200, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Internal SIP Error", "Failed to build Answer for NOTIFY", __LINE__); - return ; - } - -#ifdef SUPPORT_MSN - osip_message_header_get_byname(evt->sip, "expires", - 0, - &expires); - if (expires!=NULL&&expires->hvalue!=NULL - && 0==osip_strcasecmp(expires->hvalue, "0")) - { - /* delete the dialog! */ - js->s_ss_status = EXOSIP_SUBCRSTATE_TERMINATED; - js->s_online_status = EXOSIP_NOTIFY_UNKNOWN; - { - eXosip_event_t *je; - je = eXosip_event_init_for_subscribe(EXOSIP_SUBSCRIPTION_NOTIFY, js, jd); - if (je!=NULL) - { - eXosip_event_add_status(je, answer); - } - - if (eXosip.j_call_callbacks[EXOSIP_SUBSCRIPTION_NOTIFY]!=NULL) - eXosip.j_call_callbacks[EXOSIP_SUBSCRIPTION_NOTIFY](EXOSIP_SUBSCRIPTION_NOTIFY, je); - else if (eXosip.j_runtime_mode==EVENT_MODE) - eXosip_event_add(je); - } - - sipevent = osip_new_outgoing_sipmessage(answer); - sipevent->transactionid = transaction->transactionid; - osip_transaction_add_event(transaction, sipevent); - - osip_list_add(eXosip.j_transactions, transaction, 0); - - REMOVE_ELEMENT(eXosip.j_subscribes, js); - eXosip_subscribe_free(js); - __eXosip_wakeup(); - - return ; - } - else - { - osip_content_type_t *ctype; - osip_body_t *body = NULL; - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, jd, js, NULL)); - js->s_ss_status = EXOSIP_SUBCRSTATE_ACTIVE; - js->s_online_status = EXOSIP_NOTIFY_UNKNOWN; /* default value */ - - ctype = osip_message_get_content_type(evt->sip); - if (ctype!=NULL && ctype->type!=NULL && ctype->subtype!=NULL) - { - if (0==osip_strcasecmp(ctype->type, "application") - && 0==osip_strcasecmp(ctype->subtype, "xpidf+xml")) - osip_message_get_body(evt->sip, 0, &body); - else - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL, - "Unknown body: %s/%s\n", - ctype->type, ctype->subtype)); - } - } - - if (body!=NULL) - { - /* search for the open string */ - char *tmp = body->body; - while (tmp[0]!='\0') - { - if (tmp[0]=='o' && 0==strncmp(tmp, "online", 6)) - { - js->s_online_status = EXOSIP_NOTIFY_ONLINE; - /* search for the contact entry */ - while (tmp[0]!='\0') - { - if (tmp[0]=='c' && 0==strncmp(tmp, "contact", 7)) - { - /* ... */ - } - tmp++; - } - break; - } - else if (tmp[0]=='b' && 0==strncmp(tmp, "busy", 4)) - { - js->s_online_status = EXOSIP_NOTIFY_BUSY; - break; - } - else if (tmp[0]=='b' && 0==strncmp(tmp, "berightback",11)) - { - js->s_online_status = EXOSIP_NOTIFY_BERIGHTBACK; - break; - } - else if (tmp[0]=='a' && 0==strncmp(tmp, "away", 4)) - { - js->s_online_status = EXOSIP_NOTIFY_AWAY; - break; - } - else if (tmp[0]=='o' && 0==strncmp(tmp, "onthephone", 10)) - { - js->s_online_status = EXOSIP_NOTIFY_ONTHEPHONE; - break; - } - else if (tmp[0]=='o' && 0==strncmp(tmp, "outtolunch", 10)) - { - js->s_online_status = EXOSIP_NOTIFY_OUTTOLUNCH; - break; - } - tmp++; - } - } - } -#else - /* modify the status of user */ - if (0==osip_strncasecmp(sub_state->hvalue, "active", 6)) - { - osip_content_type_t *ctype; - osip_body_t *body = NULL; - js->s_ss_status = EXOSIP_SUBCRSTATE_ACTIVE; - js->s_online_status = EXOSIP_NOTIFY_UNKNOWN; /* default value */ - - /* if there is a body which we understand, analyse it */ - ctype = osip_message_get_content_type(evt->sip); - if (ctype!=NULL && ctype->type!=NULL && ctype->subtype!=NULL) - { - if (0==osip_strcasecmp(ctype->type, "application") - && 0==osip_strcasecmp(ctype->subtype, "pidf+xml")) - osip_message_get_body(evt->sip, 0, &body); - else - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL, - "Unknown body: %s/%s\n", - ctype->type, ctype->subtype)); - } - } - - if (body!=NULL) - { - /* search for the open string */ - char *tmp = body->body; - while (tmp[0]!='\0') - { - if (tmp[0]=='o' && 0==osip_strncasecmp(tmp, "open", 4)) - { - js->s_online_status = EXOSIP_NOTIFY_ONLINE; - /* search for the contact entry */ - while (tmp[0]!='\0') - { - if (tmp[0]=='a' && 0==osip_strncasecmp(tmp, "away", 4)) - js->s_online_status = EXOSIP_NOTIFY_AWAY; - else if (tmp[0]=='m' && 0==osip_strncasecmp(tmp, "meal", 4)) - js->s_online_status = EXOSIP_NOTIFY_OUTTOLUNCH; - else if (tmp[0]=='i' && 0==osip_strncasecmp(tmp, "in-transit", 10)) - js->s_online_status = EXOSIP_NOTIFY_BERIGHTBACK; - else if (tmp[0]=='b' && 0==osip_strncasecmp(tmp, "busy", 4)) - js->s_online_status = EXOSIP_NOTIFY_BUSY; - else if (tmp[0]=='o' && 0==osip_strncasecmp(tmp, "on-the-phone", 12)) - js->s_online_status = EXOSIP_NOTIFY_ONTHEPHONE; - - if (tmp[0]=='/' && 0==osip_strncasecmp(tmp, "/status", 7)) - break; - if (js->s_online_status!=EXOSIP_NOTIFY_ONLINE) - break; - tmp++; - } - - while (tmp[0]!='\0') - { - if (tmp[0]=='c' && 0==osip_strncasecmp(tmp, "contact", 7)) - { - /* ... */ - } - tmp++; - } - break; - } - else if (tmp[0]=='c' && 0==osip_strncasecmp(tmp, "closed", 6)) - { - js->s_online_status = EXOSIP_NOTIFY_CLOSED; - break; - } - tmp++; - } - } - } - else if (0==osip_strncasecmp(sub_state->hvalue, "pending", 7)) - { - js->s_ss_status = EXOSIP_SUBCRSTATE_PENDING; - js->s_online_status = EXOSIP_NOTIFY_PENDING; - } - - if (0==osip_strncasecmp(sub_state->hvalue, "terminated", 10)) - { - /* delete the dialog! */ - js->s_ss_status = EXOSIP_SUBCRSTATE_TERMINATED; - js->s_online_status = EXOSIP_NOTIFY_UNKNOWN; - - { - eXosip_event_t *je; - je = eXosip_event_init_for_subscribe(EXOSIP_SUBSCRIPTION_NOTIFY, js, jd); - if (je!=NULL) - { - eXosip_event_add_status(je, answer); - } - - if (eXosip.j_call_callbacks[EXOSIP_SUBSCRIPTION_NOTIFY]!=NULL) - eXosip.j_call_callbacks[EXOSIP_SUBSCRIPTION_NOTIFY](EXOSIP_SUBSCRIPTION_NOTIFY, je); - else if (eXosip.j_runtime_mode==EVENT_MODE) - eXosip_event_add(je); - } - - sipevent = osip_new_outgoing_sipmessage(answer); - sipevent->transactionid = transaction->transactionid; - osip_transaction_add_event(transaction, sipevent); - - osip_list_add(eXosip.j_transactions, transaction, 0); - - REMOVE_ELEMENT(eXosip.j_subscribes, js); - eXosip_subscribe_free(js); - __eXosip_wakeup(); - return; - } - else - { - osip_transaction_set_your_instance(transaction, __eXosip_new_jinfo(NULL, jd, js, NULL)); - } -#endif - - osip_list_add(jd->d_inc_trs, transaction, 0); - - sipevent = osip_new_outgoing_sipmessage(answer); - sipevent->transactionid = transaction->transactionid; - osip_transaction_add_event(transaction, sipevent); - - { - eXosip_event_t *je; - je = eXosip_event_init_for_subscribe(EXOSIP_SUBSCRIPTION_NOTIFY, js, jd); - if (je!=NULL) - { - eXosip_event_add_status(je, answer); - } - - if (eXosip.j_call_callbacks[EXOSIP_SUBSCRIPTION_NOTIFY]!=NULL) - eXosip.j_call_callbacks[EXOSIP_SUBSCRIPTION_NOTIFY](EXOSIP_SUBSCRIPTION_NOTIFY, je); - else if (eXosip.j_runtime_mode==EVENT_MODE) - eXosip_event_add(je); - } - - __eXosip_wakeup(); - return; -} - -static int -eXosip_match_notify_for_subscribe(eXosip_subscribe_t *js, osip_message_t *notify) -{ - osip_transaction_t *out_sub; - - if (js==NULL) - return -1; - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "Trying to match notify with subscribe\n")); - - out_sub = eXosip_find_last_out_subscribe(js, NULL); - if (out_sub==NULL || out_sub->orig_request==NULL) - return -1; - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "subscribe transaction found\n")); - - /* some checks to avoid crashing on bad requests */ - if (notify == NULL || notify->cseq == NULL - || notify->cseq->method == NULL || notify->to == NULL) - return -1; - - if (0 != osip_call_id_match (out_sub->callid, notify->call_id)) - return -1; - - { - /* The From tag of outgoing request must match - the To tag of incoming notify: - */ - osip_generic_param_t *tag_from; - osip_generic_param_t *tag_to; - - osip_from_param_get_byname (out_sub->from, "tag", &tag_from); - osip_from_param_get_byname (notify->to, "tag", &tag_to); - if (tag_to == NULL || tag_to->gvalue==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL, - "Uncompliant user agent: no tag in from of outgoing request\n")); - return -1; - } - if (tag_from == NULL || tag_to->gvalue==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL, - "Uncompliant user agent: no tag in to of incoming request\n")); - return -1; - } - - if (0 != strcmp (tag_from->gvalue, tag_to->gvalue)) - return -1; - } - - return 0; -} - -static void -eXosip_process_message_outside_of_dialog(osip_transaction_t *transaction, - osip_event_t *evt) -{ - osip_message_t *answer; - osip_event_t *evt_answer; - osip_header_t *expires, *date; - int i; - - /* Check whether the Expire time has been reached */ - - /* the Expires header is present ? */ - if (osip_message_get_expires(evt->sip, 0, &expires) != -1 && expires->hvalue!=NULL) - { - - unsigned long expires_ul; - time_t now_ts, date_ts; - - expires_ul = strtoul(expires->hvalue, (char**)NULL, 10); - now_ts = time(NULL); - - /* - ** A MESSAGE request is said to be expired if its expiration time has - ** passed. The expiration time is determined by examining the Expires - ** header field, if present. MESSAGE requests without an Expires header - ** field do not expire. If the MESSAGE request containing an Expires - ** header field also contains a Date header field, the UAS SHOULD - ** interpret the Expires header field value as delta time from the Date - ** header field value. If the request does not contain a Date header - ** field, the UAS SHOULD interpret the Expires header value as delta - ** time from the time the UAS received the request. - */ - - /* Does the message also contain a Date header ? */ - if (osip_message_get_date(evt->sip, 0, &date) != -1 && date->hvalue != NULL) - { - - /* - 20.17 Date - The Date header field contains the date and time. Unlike HTTP/1.1, - SIP only supports the most recent RFC 1123 [20] format for dates. - As in [H3.3], SIP restricts the time zone in SIP-date to "GMT", while - RFC 1123 allows any time zone. An RFC 1123 date is case-sensitive. - The Date header field reflects the time when the request or - response is first sent. - - The Date header field can be used by simple end systems without a - battery-backed clock to acquire a notion of current time. - However, in its GMT form, it requires clients to know their offset - from GMT. - - Example: - - Date: Sat, 13 Nov 2010 23:29:00 GMT - - 20.19 Expires - - The Expires header field gives the relative time after which the - message (or content) expires. - - The precise meaning of this is method dependent. - - The expiration time in an INVITE does not affect the duration of - the actual session that may result from the invitation. Session - description protocols may offer the ability to express time limits - on the session duration, however. - - The value of this field is an integral number of seconds (in decimal) - between 0 and (2**32)-1, measured from the receipt of the request. - - Example: - - Expires: 5 - - */ - - /* TODO: - date_ts = RECUPERE_TIMESTAMP(date->hvalue); - */ - - date_ts = time(NULL); - - /* Has the message expired ? */ - if (date_ts + expires_ul < now_ts) - { - /* discard old data. */ - return; - } - } - else if (expires_ul != 0) - { - /* No date header, but a not null Expires one: - ** TODO: Compare to the UAS reception time - */ - date_ts = transaction->birth_time; - } - /* The message has not expired */ - } - - /* We must create the event */ - { - eXosip_event_t *je; - je = eXosip_event_init_for_message(EXOSIP_MESSAGE_NEW, transaction, evt->sip); - i = _eXosip_build_response_default(&answer, NULL, SIP_OK, evt->sip); - if (i!=0) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - return ; - } - - if (je!=NULL) - { - int pos = 0; - osip_body_t *oldbody; - - eXosip_event_add_status(je, answer); - - while (!osip_list_eol(evt->sip->bodies, pos)) - { - int len; - oldbody = (osip_body_t *)osip_list_get(evt->sip->bodies, pos); - len = strlen(oldbody->body); - pos++; - - if (len<999) - osip_strncpy(je->sdp_body, oldbody->body, len); - else - osip_strncpy(je->sdp_body, oldbody->body, 999); - } - } - - if (eXosip.j_call_callbacks[EXOSIP_MESSAGE_NEW]!=NULL) - eXosip.j_call_callbacks[EXOSIP_MESSAGE_NEW](EXOSIP_MESSAGE_NEW, je); - else if (eXosip.j_runtime_mode==EVENT_MODE) - eXosip_event_add(je); - } - - /* finally, send the 200 OK response */ - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - - osip_transaction_add_event(transaction, evt_answer); - -#ifdef NEW_TIMER - __eXosip_wakeup(); -#endif - return; -} - - -static void eXosip_process_newrequest (osip_event_t *evt) -{ - osip_transaction_t *transaction; - osip_event_t *evt_answer; - osip_message_t *answer; - int i; - int ctx_type; - eXosip_call_t *jc; - eXosip_subscribe_t *js; - eXosip_notify_t *jn; - eXosip_dialog_t *jd; - - if (MSG_IS_INVITE(evt->sip)) - { - ctx_type = IST; - } - else if (MSG_IS_ACK(evt->sip)) - { /* this should be a ACK for 2xx (but could be a late ACK!) */ - ctx_type = -1; -#if 0 /* ACK must be announced */ - osip_event_free(evt); - return ; -#endif - } - else if (MSG_IS_REQUEST(evt->sip)) - { - ctx_type = NIST; - } - else - { /* We should handle late response and 200 OK before coming here. */ - ctx_type = -1; - osip_event_free(evt); - return ; - } - - transaction=NULL; - if (ctx_type != -1) - { - i = osip_transaction_init(&transaction, - (osip_fsm_type_t)ctx_type, - eXosip.j_osip, - evt->sip); - if (i!=0) - { - osip_event_free(evt); - return ; - } - - evt->transactionid = transaction->transactionid; - osip_transaction_set_your_instance(transaction, NULL); - - i = _eXosip_build_response_default(&answer, NULL, 100, evt->sip); - if (i!=0) - { - __eXosip_delete_jinfo(transaction); - osip_transaction_free(transaction); - osip_event_free(evt); - return ; - } - - osip_message_set_content_length(answer, "0"); - /* send message to transaction layer */ - - evt_answer = osip_new_outgoing_sipmessage(answer); - evt_answer->transactionid = transaction->transactionid; - - /* add the REQUEST & the 100 Trying */ - osip_transaction_add_event(transaction, evt); - osip_transaction_add_event(transaction, evt_answer); - __eXosip_wakeup(); - } - - if (MSG_IS_CANCEL(evt->sip)) - { - /* special handling for CANCEL */ - /* in the new spec, if the CANCEL has a Via branch, then it - is the same as the one in the original INVITE */ - eXosip_process_cancel(transaction, evt); - return ; - } - - jd = NULL; - /* first, look for a Dialog in the map of element */ - for (jc = eXosip.j_calls; jc!= NULL ; jc=jc->next) - { - for (jd = jc->c_dialogs; jd!= NULL ; jd=jd->next) - { - if (jd->d_dialog!=NULL) - { - if (osip_dialog_match_as_uas(jd->d_dialog, evt->sip)==0) - break; - } - } - if (jd!=NULL) break; - } - - - if (jd!=NULL) - { - osip_transaction_t *old_trn; - /* it can be: - 1: a new INVITE offer. - 2: a REFER request from one of the party. - 2: a BYE request from one of the party. - 3: a REQUEST with a wrong CSeq. - 4: a NOT-SUPPORTED method with a wrong CSeq. - */ - - if (!MSG_IS_BYE(evt->sip)) - { - /* reject all requests for a closed dialog */ - old_trn = eXosip_find_last_inc_bye(jc, jd); - if (old_trn == NULL) - old_trn = eXosip_find_last_out_bye(jc, jd); - - if (old_trn!=NULL) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 481, NULL, NULL, __LINE__); - return ; - } - } - - if (MSG_IS_INVITE(evt->sip)) - { - /* the previous transaction MUST be freed */ - old_trn = eXosip_find_last_inc_invite(jc, jd); - - if (old_trn!=NULL && old_trn->state!=IST_TERMINATED) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Retry Later", "An INVITE is not terminated", __LINE__); - return ; - } - - old_trn = eXosip_find_last_out_invite(jc, jd); - if (old_trn!=NULL && old_trn->state!=ICT_TERMINATED) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 491, NULL, NULL, __LINE__); - return ; - } - - osip_dialog_update_osip_cseq_as_uas(jd->d_dialog, evt->sip); - osip_dialog_update_route_set_as_uas(jd->d_dialog, evt->sip); - - eXosip_process_invite_within_call(jc, jd, transaction, evt); - } - else if (MSG_IS_BYE(evt->sip)) - { - old_trn = eXosip_find_last_inc_bye(jc, jd); - - if (old_trn!=NULL) /* && old_trn->state!=NIST_TERMINATED) */ - { /* this situation should NEVER occur?? (we can't receive - two different BYE for one call! */ - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Call Already Terminated", "A pending BYE has already terminate this call", __LINE__); - return; - } - /* osip_transaction_free(old_trn); */ - eXosip_process_bye(jc, jd, transaction, evt); - } - else if (MSG_IS_ACK(evt->sip)) - { - eXosip_process_ack(jc, jd, evt); - } - else if (MSG_IS_REFER(evt->sip)) - { - eXosip_process_refer(jc, jd, transaction, evt); - } - else if (MSG_IS_OPTIONS(evt->sip)) - { - eXosip_process_options(jc, jd, transaction, evt); - } - else if (MSG_IS_INFO(evt->sip)) - { - eXosip_process_info(jc, jd, transaction, evt); - } - else if (MSG_IS_NOTIFY(evt->sip)) - { - eXosip_process_notify_for_refer(jc, jd, transaction, evt); - } - else - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 405, NULL, "Method Not Allowed", __LINE__); - } - return ; - } - - if (MSG_IS_ACK(evt->sip)) - { - /* no transaction has been found for this ACK! */ - osip_event_free(evt); - return; - } - - if (MSG_IS_INFO(evt->sip)) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 481, NULL, NULL, __LINE__); - return; /* fixed */ - } - if (MSG_IS_OPTIONS(evt->sip)) - { - eXosip_process_new_options(transaction, evt); - return; - } - else if (MSG_IS_INVITE(evt->sip)) - { - eXosip_process_new_invite(transaction, evt); - return; - } - else if (MSG_IS_BYE(evt->sip)) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 481, NULL, NULL, __LINE__); - return; - } - - js = NULL; - /* first, look for a Dialog in the map of element */ - for (js = eXosip.j_subscribes; js!= NULL ; js=js->next) - { - for (jd = js->s_dialogs; jd!= NULL ; jd=jd->next) - { - if (jd->d_dialog!=NULL) - { - if (osip_dialog_match_as_uas(jd->d_dialog, evt->sip)==0) - break; - } - } - if (jd!=NULL) break; - } - - if (js!=NULL) - { - /* dialog found */ - osip_transaction_t *old_trn; - /* it can be: - 1: a new INVITE offer. - 2: a REFER request from one of the party. - 2: a BYE request from one of the party. - 3: a REQUEST with a wrong CSeq. - 4: a NOT-SUPPORTED method with a wrong CSeq. - */ - if (MSG_IS_MESSAGE(evt->sip)) - { - /* eXosip_process_imessage_within_subscribe_dialog(transaction, evt); */ - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, SIP_NOT_IMPLEMENTED, - NULL, "MESSAGEs within dialogs are not implemented.", __LINE__); - return; - } - else if (MSG_IS_NOTIFY(evt->sip)) - { - /* the previous transaction MUST be freed */ - old_trn = eXosip_find_last_inc_notify(js, jd); - - /* shouldn't we wait for the COMPLETED state? */ - if (old_trn!=NULL && old_trn->state!=NIST_TERMINATED) - { - /* retry later? */ - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Retry Later", "A pending NOTIFY is not terminated", __LINE__); - return ; - } - - osip_dialog_update_osip_cseq_as_uas(jd->d_dialog, evt->sip); - osip_dialog_update_route_set_as_uas(jd->d_dialog, evt->sip); - - eXosip_process_notify_within_dialog(js, jd, transaction, evt); - } - else - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 501, NULL, "Just Not Implemented", __LINE__); - } - return ; - } - - if (MSG_IS_NOTIFY(evt->sip)) - { - /* I should probably initiate a dialog with info from NOTIFY... - By now, I prefer to discard the message until an answer for - the subscribe is received, then I'll be able to answer - the NOTIFY retransmission. */ - - /* let's try to check if the NOTIFY is related to an existing - subscribe */ - js = NULL; - /* first, look for a Dialog in the map of element */ - for (js = eXosip.j_subscribes; js!= NULL ; js=js->next) - { - if (eXosip_match_notify_for_subscribe(js, evt->sip)==0) - { - i = eXosip_dialog_init_as_uac(&jd, evt->sip); - if (i!=0) - { - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_ERROR, NULL, - "eXosip: cannot establish a dialog\n")); - return; - } - - /* update local cseq from subscribe request */ - if (js->s_out_tr!=NULL && js->s_out_tr->cseq!=NULL - && js->s_out_tr->cseq->number!=NULL) - { - jd->d_dialog->local_cseq = atoi(js->s_out_tr->cseq->number); - OSIP_TRACE (osip_trace - (__FILE__, __LINE__, OSIP_INFO2, NULL, - "eXosip: local cseq has been updated\n")); - } - - ADD_ELEMENT(js->s_dialogs, jd); - eXosip_update(); - - eXosip_process_notify_within_dialog(js, jd, transaction, evt); - return; - } - } - - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(NULL, transaction, evt, 481, NULL, NULL, __LINE__); - return; - } - - jn = NULL; - /* first, look for a Dialog in the map of element */ - for (jn = eXosip.j_notifies; jn!= NULL ; jn=jn->next) - { - for (jd = jn->n_dialogs; jd!= NULL ; jd=jd->next) - { - if (jd->d_dialog!=NULL) - { - if (osip_dialog_match_as_uas(jd->d_dialog, evt->sip)==0) - break; - } - } - if (jd!=NULL) break; - } - - if (jn!=NULL) - { - /* dialog found */ - osip_transaction_t *old_trn; - /* it can be: - 1: a new INVITE offer. - 2: a REFER request from one of the party. - 2: a BYE request from one of the party. - 3: a REQUEST with a wrong CSeq. - 4: a NOT-SUPPORTED method with a wrong CSeq. - */ - if (MSG_IS_MESSAGE(evt->sip)) - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, SIP_NOT_IMPLEMENTED, - NULL, "MESSAGEs within dialogs are not implemented.", __LINE__); - return; - } - else if (MSG_IS_SUBSCRIBE(evt->sip)) - { - /* the previous transaction MUST be freed */ - old_trn = eXosip_find_last_inc_subscribe(jn, jd); - - /* shouldn't we wait for the COMPLETED state? */ - if (old_trn!=NULL && old_trn->state!=NIST_TERMINATED - && old_trn->state!=NIST_COMPLETED) - { - /* retry later? */ - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 500, "Retry Later", "A SUBSCRIBE is not terminated", __LINE__); - return ; - } - - osip_dialog_update_osip_cseq_as_uas(jd->d_dialog, evt->sip); - osip_dialog_update_route_set_as_uas(jd->d_dialog, evt->sip); - - eXosip_process_subscribe_within_call(jn, jd, transaction, evt); - } - else - { - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(jd, transaction, evt, 501, NULL, NULL, __LINE__); - } - return ; - } - - if (MSG_IS_MESSAGE(evt->sip)) - { - eXosip_process_message_outside_of_dialog(transaction , evt); - return; - } - - if (MSG_IS_SUBSCRIBE(evt->sip)) - { - - if (0==eXosip_event_package_is_supported(transaction, evt)) - { - return; - } - eXosip_process_new_subscribe(transaction, evt); - return; - } - - /* default answer */ - osip_list_add(eXosip.j_transactions, transaction, 0); - eXosip_send_default_answer(NULL, transaction, evt, 501, NULL, NULL, __LINE__); -} - -static void eXosip_process_response_out_of_transaction (osip_event_t *evt) -{ - osip_event_free(evt); -} - -static void fix_via(osip_message_t *msg, const struct sockaddr * sa, socklen_t sa_len){ - char host[NI_MAXHOST]; - char serv[NI_MAXSERV]; - int err; - err=getnameinfo(sa, sa_len,host,NI_MAXHOST,serv,NI_MAXSERV, - NI_NUMERICHOST|NI_NUMERICSERV); - if (err!=0){ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL, - "sockaddr_to_char: error in getnameinfo():%s\n",gai_strerror(err) )); - return; - } - osip_message_fix_last_via_header(msg,host,atoi(serv)); -} - -/* if second==-1 && useconds==-1 -> wait for ever - if max_message_nb<=0 -> infinite loop.... */ -int eXosip_read_message ( int max_message_nb, int sec_max, int usec_max ) -{ - fd_set osip_fdset; - struct timeval tv; - char *buf; - - tv.tv_sec = sec_max; - tv.tv_usec = usec_max; - - buf = (char *)osip_malloc(SIP_MESSAGE_MAX_LENGTH*sizeof(char)+1); - while (max_message_nb!=0 && eXosip.j_stop_ua==0) - { - int i; - int max; - int wakeup_socket = jpipe_get_read_descr(eXosip.j_socketctl); - FD_ZERO(&osip_fdset); -#if defined (WIN32) || defined (_WIN32_WCE) - FD_SET((unsigned int)eXosip.j_socket, &osip_fdset); -#else - FD_SET(eXosip.j_socket, &osip_fdset); -#endif - max = eXosip.j_socket; -#if defined (WIN32) || defined (_WIN32_WCE) - FD_SET((unsigned int)wakeup_socket, &osip_fdset); -#else - FD_SET(wakeup_socket, &osip_fdset); -#endif - if (wakeup_socket>eXosip.j_socket) - max = wakeup_socket; - if ((sec_max==-1)||(usec_max==-1)) - i = select(max+1, &osip_fdset, NULL, NULL, NULL); - else - i = select(max+1, &osip_fdset, NULL, NULL, &tv); - - if ((i == -1) && (errno == EINTR || errno == EAGAIN)) - continue; - - if ((i > 0) && FD_ISSET (wakeup_socket, &osip_fdset)) - { - char buf2[500]; - jpipe_read (eXosip.j_socketctl, buf2, 499); - } - - if (0==i || eXosip.j_stop_ua!=0) - { - } - else if (-1==i) - { - osip_free(buf); - return -2; /* error */ - } - else if (FD_ISSET (eXosip.j_socket, &osip_fdset)) - { - struct sockaddr_storage sa; -#ifdef __linux - socklen_t slen; -#else - int slen; -#endif - slen = sizeof(struct sockaddr_storage); - i = recvfrom (eXosip.j_socket, buf, SIP_MESSAGE_MAX_LENGTH, 0, - (struct sockaddr *) &sa, &slen); - if( i > 5 ) /* we expect at least one byte, otherwise there's no doubt that it is not a sip message !*/ - { - /* Message might not end with a "\0" but we know the number of */ - /* char received! */ - osip_transaction_t *transaction = NULL; - osip_event_t *sipevent; - osip_strncpy(buf+i,"\0",1); - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "Received message: \n%s\n", buf)); -#ifdef WIN32 - if (strlen(buf)>412) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "Message suite: \n%s\n", buf+412)); - } -#endif - - sipevent = osip_parse(buf, i); - transaction = NULL; - if (sipevent!=NULL&&sipevent->sip!=NULL) - { - fix_via(sipevent->sip,(struct sockaddr*)&sa,slen); - i = osip_find_transaction_and_add_event(eXosip.j_osip, sipevent); - if (i!=0) - { - /* this event has no transaction, */ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "This is a request\n", buf)); - eXosip_lock(); - if (MSG_IS_REQUEST(sipevent->sip)) - eXosip_process_newrequest(sipevent); - else if (MSG_IS_RESPONSE(sipevent->sip)) - eXosip_process_response_out_of_transaction(sipevent); - eXosip_unlock(); - } - else - { - /* handled by oSIP !*/ - } - } - else - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL, - "Could not parse SIP message\n")); - osip_event_free(sipevent); - } - } - else if (i<0) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_ERROR,NULL, - "Could not read socket\n")); - } - else - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "Dummy SIP message received\n")); - } - } - max_message_nb--; - } - osip_free(buf); - return 0; -} - - -static int eXosip_pendingosip_transaction_exist ( eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - osip_transaction_t *tr; - int now = time(NULL); - - tr = eXosip_find_last_inc_bye(jc, jd); - if (tr!=NULL && tr->state!=NIST_TERMINATED) - { /* Don't want to wait forever on broken transaction!! */ - if (tr->birth_time+180state!=NICT_TERMINATED) - { /* Don't want to wait forever on broken transaction!! */ - if (tr->birth_time+180state!=IST_TERMINATED) - { /* Don't want to wait forever on broken transaction!! */ - if (tr->birth_time+180state!=ICT_TERMINATED) - { /* Don't want to wait forever on broken transaction!! */ - if (tr->birth_time+180state!=IST_TERMINATED) - { /* Don't want to wait forever on broken transaction!! */ - if (tr->birth_time+180state!=NICT_TERMINATED) - { /* Don't want to wait forever on broken transaction!! */ - if (tr->birth_time+180state==NIST_TERMINATED || tr->state==NICT_TERMINATED )) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_finished_calls remove a dialog\n")); - /* Remove existing reference to the dialog from transactions! */ - __eXosip_call_remove_dialog_reference_in_call(jc, jd); - REMOVE_ELEMENT(jc->c_dialogs, jd); - eXosip_dialog_free(jd); - return 0; - } - return -1; -} - - - -static void -__eXosip_release_call(eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - REMOVE_ELEMENT(eXosip.j_calls, jc); - __eXosip_report_event(EXOSIP_CALL_RELEASED, jc, jd, NULL); - eXosip_call_free(jc); - __eXosip_wakeup(); -} - - -static int eXosip_release_aborted_calls ( eXosip_call_t *jc, eXosip_dialog_t *jd ) -{ - int now = time(NULL); - osip_transaction_t *tr; - tr = eXosip_find_last_inc_invite(jc, jd); - if (tr==NULL) - tr = eXosip_find_last_out_invite(jc, jd); - - if (tr==NULL) - { - if (jd!=NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls remove an empty dialog\n")); - __eXosip_call_remove_dialog_reference_in_call(jc, jd); - REMOVE_ELEMENT(jc->c_dialogs, jd); - eXosip_dialog_free(jd); - return 0; - } - return -1; - } - - if (tr!=NULL - && tr->state!=IST_TERMINATED - && tr->state!=ICT_TERMINATED - && tr->birth_time+180c_dialogs, jd); - __eXosip_report_event(EXOSIP_CALL_NOANSWER, jc, jd, NULL); - eXosip_dialog_free(jd); - __eXosip_wakeup(); - return 0; - } - } - - if (tr!=NULL - && (tr->state==IST_TERMINATED - || tr->state==ICT_TERMINATED)) - { - if (tr==jc->c_inc_tr) - { - if (jc->c_inc_tr->last_response==NULL) - { - /* OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls transaction with no answer\n")); */ - } - else if (MSG_IS_STATUS_3XX(jc->c_inc_tr->last_response)) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls answered with a 3xx\n")); - __eXosip_release_call(jc, jd); - return 0; - } - else if (MSG_IS_STATUS_4XX(jc->c_inc_tr->last_response)) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls answered with a 4xx\n")); - __eXosip_release_call(jc, jd); - return 0; - } - else if (MSG_IS_STATUS_5XX(jc->c_inc_tr->last_response)) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls answered with a 5xx\n")); - __eXosip_release_call(jc, jd); - return 0; - } - else if (MSG_IS_STATUS_6XX(jc->c_inc_tr->last_response)) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls answered with a 6xx\n")); - __eXosip_release_call(jc, jd); - return 0; - } - } - else if (tr==jc->c_out_tr) - { - if (jc->c_out_tr->last_response==NULL) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls completed with no answer\n")); - __eXosip_release_call(jc, jd); - return 0; - } - else if (MSG_IS_STATUS_3XX(jc->c_out_tr->last_response)) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls completed answered with 3xx\n")); - __eXosip_release_call(jc, jd); - return 0; - } - else if (MSG_IS_STATUS_4XX(jc->c_out_tr->last_response)) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls completed answered with 4xx\n")); - __eXosip_release_call(jc, jd); - return 0; - } - else if (MSG_IS_STATUS_5XX(jc->c_out_tr->last_response)) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls completed answered with 5xx\n")); - __eXosip_release_call(jc, jd); - return 0; - } - else if (MSG_IS_STATUS_6XX(jc->c_out_tr->last_response)) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO2,NULL, - "eXosip: eXosip_release_aborted_calls completed answered with 6xx\n")); - __eXosip_release_call(jc, jd); - return 0; - } - } - } - - return -1; -} - - -void eXosip_release_terminated_calls ( void ) -{ - eXosip_dialog_t *jd; - eXosip_dialog_t *jdnext; - eXosip_call_t *jc; - eXosip_call_t *jcnext; - int now = time(NULL); - int pos; - - - for (jc = eXosip.j_calls ; jc != NULL; ) - { - jcnext=jc->next; - /* free call terminated with a BYE */ - for (jd = jc->c_dialogs ; jd != NULL; ) - { - jdnext=jd->next; - if (0==eXosip_pendingosip_transaction_exist(jc, jd)) - { } - else if (0==eXosip_release_finished_calls(jc, jd)) - { jd = jc->c_dialogs; } - else if (0==eXosip_release_aborted_calls(jc, jd)) - { jdnext = NULL; } - else - { } - jd=jdnext; - } - jc=jcnext; - } - - for (jc = eXosip.j_calls ; jc != NULL; ) - { - jcnext=jc->next; - if (jc->c_dialogs==NULL) - { - /* release call for options requests */ - if (jc->c_inc_options_tr!=NULL) - { - if (jc->c_inc_options_tr->state==NIST_TERMINATED) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "eXosip: remove an incoming OPTIONS with no final answer\n")); - __eXosip_release_call(jc, NULL); - } - else if (jc->c_inc_options_tr->state!=NIST_TERMINATED - && jc->c_inc_options_tr->birth_time+180c_out_options_tr!=NULL) - { - if (jc->c_out_options_tr->state==NICT_TERMINATED) - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "eXosip: remove an outgoing OPTIONS with no final answer\n")); - __eXosip_release_call(jc, NULL); - } - else if (jc->c_out_options_tr->state!=NIST_TERMINATED - && jc->c_out_options_tr->birth_time+180c_inc_tr!=NULL && jc->c_inc_tr->state!=IST_TERMINATED - && jc->c_inc_tr->birth_time+180c_out_tr!=NULL && jc->c_out_tr->state!=ICT_TERMINATED - && jc->c_out_tr->birth_time+180c_inc_tr!=NULL && jc->c_inc_tr->state!=IST_TERMINATED) - { } - else if (jc->c_out_tr!=NULL && jc->c_out_tr->state!=ICT_TERMINATED) - { } - else /* no active pending transaction */ - { - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "eXosip: remove a call\n")); - __eXosip_release_call(jc, NULL); - } - } - jc = jcnext; - } - - pos = 0; - while (!osip_list_eol(eXosip.j_transactions, pos)) - { - osip_transaction_t *tr = (osip_transaction_t*) osip_list_get(eXosip.j_transactions, pos); - if (tr->state==IST_TERMINATED || tr->state==ICT_TERMINATED - || tr->state== NICT_TERMINATED || tr->state==NIST_TERMINATED) - - { /* free (transaction is already removed from the oSIP stack) */ - OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL, - "Release a terminated transaction\n")); - osip_list_remove(eXosip.j_transactions, pos); - __eXosip_delete_jinfo(tr); - osip_transaction_free(tr); - } - else if (tr->birth_time+180 -#else -# include "proto.h" - extern char * memcpy P((char *, char *, int)); -#endif - -#include "private.h" -#include "gsm.h" -#include "proto.h" - -/* - * 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER - */ - -void Gsm_Coder P8((S,s,LARc,Nc,bc,Mc,xmaxc,xMc), - - struct gsm_state * S, - - word * s, /* [0..159] samples IN */ - -/* - * The RPE-LTD coder works on a frame by frame basis. The length of - * the frame is equal to 160 samples. Some computations are done - * once per frame to produce at the output of the coder the - * LARc[1..8] parameters which are the coded LAR coefficients and - * also to realize the inverse filtering operation for the entire - * frame (160 samples of signal d[0..159]). These parts produce at - * the output of the coder: - */ - - word * LARc, /* [0..7] LAR coefficients OUT */ - -/* - * Procedure 4.2.11 to 4.2.18 are to be executed four times per - * frame. That means once for each sub-segment RPE-LTP analysis of - * 40 samples. These parts produce at the output of the coder: - */ - - word * Nc, /* [0..3] LTP lag OUT */ - word * bc, /* [0..3] coded LTP gain OUT */ - word * Mc, /* [0..3] RPE grid selection OUT */ - word * xmaxc,/* [0..3] Coded maximum amplitude OUT */ - word * xMc /* [13*4] normalized RPE samples OUT */ -) -{ - int k; - word * dp = S->dp0 + 120; /* [ -120...-1 ] */ - word * dpp = dp; /* [ 0...39 ] */ - - static word e[50]; - - word so[160]; - - Gsm_Preprocess (S, s, so); - Gsm_LPC_Analysis (S, so, LARc); - Gsm_Short_Term_Analysis_Filter (S, LARc, so); - - for (k = 0; k <= 3; k++, xMc += 13) { - - Gsm_Long_Term_Predictor ( S, - so+k*40, /* d [0..39] IN */ - dp, /* dp [-120..-1] IN */ - e + 5, /* e [0..39] OUT */ - dpp, /* dpp [0..39] OUT */ - Nc++, - bc++); - - Gsm_RPE_Encoding ( S, - e + 5, /* e ][0..39][ IN/OUT */ - xmaxc++, Mc++, xMc ); - /* - * Gsm_Update_of_reconstructed_short_time_residual_signal - * ( dpp, e + 5, dp ); - */ - - { register int i; - register longword ltmp; - for (i = 0; i <= 39; i++) - dp[ i ] = GSM_ADD( e[5 + i], dpp[i] ); - } - dp += 40; - dpp += 40; - - } - (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160), - 120 * sizeof(*S->dp0) ); -} diff --git a/linphone/gsmlib/config.h b/linphone/gsmlib/config.h deleted file mode 100644 index d5f9a13ac..000000000 --- a/linphone/gsmlib/config.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/*$Header: /sources/linphone/linphone/gsmlib/config.h,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $*/ - -#ifndef CONFIG_H -#define CONFIG_H - -/*efine SIGHANDLER_T int /* signal handlers are void */ -/*efine HAS_SYSV_SIGNAL 1 /* sigs not blocked/reset? */ - -#define HAS_STDLIB_H 1 /* /usr/include/stdlib.h */ -/*efine HAS_LIMITS_H 1 /* /usr/include/limits.h */ -#define HAS_FCNTL_H 1 /* /usr/include/fcntl.h */ -/*efine HAS_ERRNO_DECL 1 /* errno.h declares errno */ - -#define HAS_FSTAT 1 /* fstat syscall */ -#define HAS_FCHMOD 1 /* fchmod syscall */ -#define HAS_CHMOD 1 /* chmod syscall */ -#define HAS_FCHOWN 1 /* fchown syscall */ -#define HAS_CHOWN 1 /* chown syscall */ -/*efine HAS__FSETMODE 1 /* _fsetmode -- set file mode */ - -#define HAS_STRING_H 1 /* /usr/include/string.h */ -/*efine HAS_STRINGS_H 1 /* /usr/include/strings.h */ - -#define HAS_UNISTD_H 1 /* /usr/include/unistd.h */ -#define HAS_UTIME 1 /* POSIX utime(path, times) */ -/*efine HAS_UTIMES 1 /* use utimes() syscall instead */ -#define HAS_UTIME_H 1 /* UTIME header file */ -/*efine HAS_UTIMBUF 1 /* struct utimbuf */ -/*efine HAS_UTIMEUSEC 1 /* microseconds in utimbuf? */ - -#endif /* CONFIG_H */ diff --git a/linphone/gsmlib/debug.c b/linphone/gsmlib/debug.c deleted file mode 100644 index d4b820d23..000000000 --- a/linphone/gsmlib/debug.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/debug.c,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $ */ - -#include "private.h" - -#ifndef NDEBUG - -/* If NDEBUG _is_ defined and no debugging should be performed, - * calls to functions in this module are #defined to nothing - * in private.h. - */ - -#include -#include "proto.h" - -void gsm_debug_words P4( (name, from, to, ptr), - char * name, - int from, - int to, - word * ptr) -{ - int nprinted = 0; - - fprintf( stderr, "%s [%d .. %d]: ", name, from, to ); - while (from <= to) { - fprintf(stderr, "%d ", ptr[ from ] ); - from++; - if (nprinted++ >= 7) { - nprinted = 0; - if (from < to) putc('\n', stderr); - } - } - putc('\n', stderr); -} - -void gsm_debug_longwords P4( (name, from, to, ptr), - char * name, - int from, - int to, - longword * ptr) -{ - int nprinted = 0; - - fprintf( stderr, "%s [%d .. %d]: ", name, from, to ); - while (from <= to) { - - fprintf(stderr, "%d ", ptr[ from ] ); - from++; - if (nprinted++ >= 7) { - nprinted = 0; - if (from < to) putc('\n', stderr); - } - } - putc('\n', stderr); -} - -void gsm_debug_longword P2( (name, value), - char * name, - longword value ) -{ - fprintf(stderr, "%s: %d\n", name, (long)value ); -} - -void gsm_debug_word P2( (name, value), - char * name, - word value ) -{ - fprintf(stderr, "%s: %d\n", name, (long)value); -} - -#endif diff --git a/linphone/gsmlib/decode.c b/linphone/gsmlib/decode.c deleted file mode 100644 index fa4a3068f..000000000 --- a/linphone/gsmlib/decode.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/decode.c,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $ */ - -#include - -#include "private.h" -#include "gsm.h" -#include "proto.h" - -/* - * 4.3 FIXED POINT IMPLEMENTATION OF THE RPE-LTP DECODER - */ - -static void Postprocessing P2((S,s), - struct gsm_state * S, - register word * s) -{ - register int k; - register word msr = S->msr; - register longword ltmp; /* for GSM_ADD */ - register word tmp; - - for (k = 160; k--; s++) { - tmp = GSM_MULT_R( msr, 28180 ); - msr = GSM_ADD(*s, tmp); /* Deemphasis */ - *s = GSM_ADD(msr, msr) & 0xFFF8; /* Truncation & Upscaling */ - } - S->msr = msr; -} - -void Gsm_Decoder P8((S,LARcr, Ncr,bcr,Mcr,xmaxcr,xMcr,s), - struct gsm_state * S, - - word * LARcr, /* [0..7] IN */ - - word * Ncr, /* [0..3] IN */ - word * bcr, /* [0..3] IN */ - word * Mcr, /* [0..3] IN */ - word * xmaxcr, /* [0..3] IN */ - word * xMcr, /* [0..13*4] IN */ - - word * s) /* [0..159] OUT */ -{ - int j, k; - word erp[40], wt[160]; - word * drp = S->dp0 + 120; - - for (j=0; j <= 3; j++, xmaxcr++, bcr++, Ncr++, Mcr++, xMcr += 13) { - - Gsm_RPE_Decoding( S, *xmaxcr, *Mcr, xMcr, erp ); - Gsm_Long_Term_Synthesis_Filtering( S, *Ncr, *bcr, erp, drp ); - - for (k = 0; k <= 39; k++) wt[ j * 40 + k ] = drp[ k ]; - } - - Gsm_Short_Term_Synthesis_Filter( S, LARcr, wt, s ); - Postprocessing(S, s); -} diff --git a/linphone/gsmlib/gsm.h b/linphone/gsmlib/gsm.h deleted file mode 100644 index 78e7f82c1..000000000 --- a/linphone/gsmlib/gsm.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/*$Header: /sources/linphone/linphone/gsmlib/gsm.h,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $*/ - -#ifndef GSM_H -#define GSM_H - -#ifdef __cplusplus -# define NeedFunctionPrototypes 1 -#endif - -#if __STDC__ -# define NeedFunctionPrototypes 1 -#endif - -#ifdef _NO_PROTO -# undef NeedFunctionPrototypes -#endif - -#ifdef NeedFunctionPrototypes -# include /* for FILE * */ -#endif - -#undef GSM_P -#if NeedFunctionPrototypes -# define GSM_P( protos ) protos -#else -# define GSM_P( protos ) ( /* protos */ ) -#endif - -/* - * Interface -vocoders.h" */ - - -typedef struct gsm_state * gsm; -typedef short gsm_signal; /* signed 16 bit */ -typedef unsigned char gsm_byte; -typedef gsm_byte gsm_frame[33]; /* 33 * 8 bits */ - -#define GSM_MAGIC 0xD /* 13 kbit/s RPE-LTP */ - -#define GSM_PATCHLEVEL 10 -#define GSM_MINOR 0 -#define GSM_MAJOR 1 - -#define GSM_OPT_VERBOSE 1 -#define GSM_OPT_FAST 2 -#define GSM_OPT_LTP_CUT 3 -#define GSM_OPT_WAV49 4 -#define GSM_OPT_FRAME_INDEX 5 -#define GSM_OPT_FRAME_CHAIN 6 - -#ifndef __cplusplus - -extern gsm gsm_create GSM_P((void)); -extern void gsm_destroy GSM_P((gsm)); - -extern int gsm_print GSM_P((FILE *, gsm, gsm_byte *)); -extern int gsm_option GSM_P((gsm, int, int *)); - -extern void gsm_encode GSM_P((gsm, gsm_signal *, gsm_byte *)); -extern int gsm_decode GSM_P((gsm, gsm_byte *, gsm_signal *)); - -extern int gsm_explode GSM_P((gsm, gsm_byte *, gsm_signal *)); -extern void gsm_implode GSM_P((gsm, gsm_signal *, gsm_byte *)); -#else -extern "C" -{ -gsm gsm_create GSM_P((void)); -void gsm_destroy GSM_P((gsm)); - -int gsm_print GSM_P((FILE *, gsm, gsm_byte *)); -int gsm_option GSM_P((gsm, int, int *)); - -void gsm_encode GSM_P((gsm, gsm_signal *, gsm_byte *)); -int gsm_decode GSM_P((gsm, gsm_byte *, gsm_signal *)); - -int gsm_explode GSM_P((gsm, gsm_byte *, gsm_signal *)); -void gsm_implode GSM_P((gsm, gsm_signal *, gsm_byte *)); -} - - - - -#endif - - - -#undef GSM_P - -#endif /* GSM_H */ diff --git a/linphone/gsmlib/gsm_create.c b/linphone/gsmlib/gsm_create.c deleted file mode 100644 index b3e6bb13e..000000000 --- a/linphone/gsmlib/gsm_create.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -static char const ident[] = "$Header: /sources/linphone/linphone/gsmlib/gsm_create.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $"; - -#include "config.h" - -#ifdef HAS_STRING_H -#include -#else -# include "proto.h" - extern char * memset P((char *, int, int)); -#endif - -#ifdef HAS_STDLIB_H -# include -#else -# ifdef HAS_MALLOC_H -# include -# else - extern char * malloc(); -# endif -#endif - -#include - -#include "gsm.h" -#include "private.h" -#include "proto.h" - -gsm gsm_create P0() -{ - gsm r; - - r = (gsm)malloc(sizeof(struct gsm_state)); - if (!r) return r; - - memset((char *)r, 0, sizeof(*r)); - r->nrp = 40; - - return r; -} diff --git a/linphone/gsmlib/gsm_decode.c b/linphone/gsmlib/gsm_decode.c deleted file mode 100644 index 928de7d56..000000000 --- a/linphone/gsmlib/gsm_decode.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/gsm_decode.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -#include "private.h" - -#include "gsm.h" -#include "proto.h" - -int gsm_decode P3((s, c, target), gsm s, gsm_byte * c, gsm_signal * target) -{ - word LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13*4]; - -#ifdef WAV49 - if (s->wav_fmt) { - - uword sr = 0; - - s->frame_index = !s->frame_index; - if (s->frame_index) { - - sr = *c++; - LARc[0] = sr & 0x3f; sr >>= 6; - sr |= (uword)*c++ << 2; - LARc[1] = sr & 0x3f; sr >>= 6; - sr |= (uword)*c++ << 4; - LARc[2] = sr & 0x1f; sr >>= 5; - LARc[3] = sr & 0x1f; sr >>= 5; - sr |= (uword)*c++ << 2; - LARc[4] = sr & 0xf; sr >>= 4; - LARc[5] = sr & 0xf; sr >>= 4; - sr |= (uword)*c++ << 2; /* 5 */ - LARc[6] = sr & 0x7; sr >>= 3; - LARc[7] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; - Nc[0] = sr & 0x7f; sr >>= 7; - bc[0] = sr & 0x3; sr >>= 2; - Mc[0] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[0] = sr & 0x3f; sr >>= 6; - xmc[0] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[1] = sr & 0x7; sr >>= 3; - xmc[2] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[3] = sr & 0x7; sr >>= 3; - xmc[4] = sr & 0x7; sr >>= 3; - xmc[5] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; /* 10 */ - xmc[6] = sr & 0x7; sr >>= 3; - xmc[7] = sr & 0x7; sr >>= 3; - xmc[8] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[9] = sr & 0x7; sr >>= 3; - xmc[10] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[11] = sr & 0x7; sr >>= 3; - xmc[12] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; - Nc[1] = sr & 0x7f; sr >>= 7; - bc[1] = sr & 0x3; sr >>= 2; - Mc[1] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[1] = sr & 0x3f; sr >>= 6; - xmc[13] = sr & 0x7; sr >>= 3; - sr = *c++; /* 15 */ - xmc[14] = sr & 0x7; sr >>= 3; - xmc[15] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[16] = sr & 0x7; sr >>= 3; - xmc[17] = sr & 0x7; sr >>= 3; - xmc[18] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[19] = sr & 0x7; sr >>= 3; - xmc[20] = sr & 0x7; sr >>= 3; - xmc[21] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[22] = sr & 0x7; sr >>= 3; - xmc[23] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[24] = sr & 0x7; sr >>= 3; - xmc[25] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; /* 20 */ - Nc[2] = sr & 0x7f; sr >>= 7; - bc[2] = sr & 0x3; sr >>= 2; - Mc[2] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[2] = sr & 0x3f; sr >>= 6; - xmc[26] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[27] = sr & 0x7; sr >>= 3; - xmc[28] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[29] = sr & 0x7; sr >>= 3; - xmc[30] = sr & 0x7; sr >>= 3; - xmc[31] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[32] = sr & 0x7; sr >>= 3; - xmc[33] = sr & 0x7; sr >>= 3; - xmc[34] = sr & 0x7; sr >>= 3; - sr = *c++; /* 25 */ - xmc[35] = sr & 0x7; sr >>= 3; - xmc[36] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[37] = sr & 0x7; sr >>= 3; - xmc[38] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; - Nc[3] = sr & 0x7f; sr >>= 7; - bc[3] = sr & 0x3; sr >>= 2; - Mc[3] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[3] = sr & 0x3f; sr >>= 6; - xmc[39] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[40] = sr & 0x7; sr >>= 3; - xmc[41] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; /* 30 */ - xmc[42] = sr & 0x7; sr >>= 3; - xmc[43] = sr & 0x7; sr >>= 3; - xmc[44] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[45] = sr & 0x7; sr >>= 3; - xmc[46] = sr & 0x7; sr >>= 3; - xmc[47] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[48] = sr & 0x7; sr >>= 3; - xmc[49] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[50] = sr & 0x7; sr >>= 3; - xmc[51] = sr & 0x7; sr >>= 3; - - s->frame_chain = sr & 0xf; - } - else { - sr = s->frame_chain; - sr |= (uword)*c++ << 4; /* 1 */ - LARc[0] = sr & 0x3f; sr >>= 6; - LARc[1] = sr & 0x3f; sr >>= 6; - sr = *c++; - LARc[2] = sr & 0x1f; sr >>= 5; - sr |= (uword)*c++ << 3; - LARc[3] = sr & 0x1f; sr >>= 5; - LARc[4] = sr & 0xf; sr >>= 4; - sr |= (uword)*c++ << 2; - LARc[5] = sr & 0xf; sr >>= 4; - LARc[6] = sr & 0x7; sr >>= 3; - LARc[7] = sr & 0x7; sr >>= 3; - sr = *c++; /* 5 */ - Nc[0] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; - bc[0] = sr & 0x3; sr >>= 2; - Mc[0] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[0] = sr & 0x3f; sr >>= 6; - xmc[0] = sr & 0x7; sr >>= 3; - xmc[1] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[2] = sr & 0x7; sr >>= 3; - xmc[3] = sr & 0x7; sr >>= 3; - xmc[4] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[5] = sr & 0x7; sr >>= 3; - xmc[6] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; /* 10 */ - xmc[7] = sr & 0x7; sr >>= 3; - xmc[8] = sr & 0x7; sr >>= 3; - xmc[9] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[10] = sr & 0x7; sr >>= 3; - xmc[11] = sr & 0x7; sr >>= 3; - xmc[12] = sr & 0x7; sr >>= 3; - sr = *c++; - Nc[1] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; - bc[1] = sr & 0x3; sr >>= 2; - Mc[1] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[1] = sr & 0x3f; sr >>= 6; - xmc[13] = sr & 0x7; sr >>= 3; - xmc[14] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; /* 15 */ - xmc[15] = sr & 0x7; sr >>= 3; - xmc[16] = sr & 0x7; sr >>= 3; - xmc[17] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[18] = sr & 0x7; sr >>= 3; - xmc[19] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[20] = sr & 0x7; sr >>= 3; - xmc[21] = sr & 0x7; sr >>= 3; - xmc[22] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[23] = sr & 0x7; sr >>= 3; - xmc[24] = sr & 0x7; sr >>= 3; - xmc[25] = sr & 0x7; sr >>= 3; - sr = *c++; - Nc[2] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; /* 20 */ - bc[2] = sr & 0x3; sr >>= 2; - Mc[2] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[2] = sr & 0x3f; sr >>= 6; - xmc[26] = sr & 0x7; sr >>= 3; - xmc[27] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[28] = sr & 0x7; sr >>= 3; - xmc[29] = sr & 0x7; sr >>= 3; - xmc[30] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[31] = sr & 0x7; sr >>= 3; - xmc[32] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[33] = sr & 0x7; sr >>= 3; - xmc[34] = sr & 0x7; sr >>= 3; - xmc[35] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; /* 25 */ - xmc[36] = sr & 0x7; sr >>= 3; - xmc[37] = sr & 0x7; sr >>= 3; - xmc[38] = sr & 0x7; sr >>= 3; - sr = *c++; - Nc[3] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; - bc[3] = sr & 0x3; sr >>= 2; - Mc[3] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[3] = sr & 0x3f; sr >>= 6; - xmc[39] = sr & 0x7; sr >>= 3; - xmc[40] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[41] = sr & 0x7; sr >>= 3; - xmc[42] = sr & 0x7; sr >>= 3; - xmc[43] = sr & 0x7; sr >>= 3; - sr = *c++; /* 30 */ - xmc[44] = sr & 0x7; sr >>= 3; - xmc[45] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[46] = sr & 0x7; sr >>= 3; - xmc[47] = sr & 0x7; sr >>= 3; - xmc[48] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[49] = sr & 0x7; sr >>= 3; - xmc[50] = sr & 0x7; sr >>= 3; - xmc[51] = sr & 0x7; sr >>= 3; - } - } - else -#endif - { - /* GSM_MAGIC = (*c >> 4) & 0xF; */ - - if (((*c >> 4) & 0x0F) != GSM_MAGIC) return -1; - - LARc[0] = (*c++ & 0xF) << 2; /* 1 */ - LARc[0] |= (*c >> 6) & 0x3; - LARc[1] = *c++ & 0x3F; - LARc[2] = (*c >> 3) & 0x1F; - LARc[3] = (*c++ & 0x7) << 2; - LARc[3] |= (*c >> 6) & 0x3; - LARc[4] = (*c >> 2) & 0xF; - LARc[5] = (*c++ & 0x3) << 2; - LARc[5] |= (*c >> 6) & 0x3; - LARc[6] = (*c >> 3) & 0x7; - LARc[7] = *c++ & 0x7; - Nc[0] = (*c >> 1) & 0x7F; - bc[0] = (*c++ & 0x1) << 1; - bc[0] |= (*c >> 7) & 0x1; - Mc[0] = (*c >> 5) & 0x3; - xmaxc[0] = (*c++ & 0x1F) << 1; - xmaxc[0] |= (*c >> 7) & 0x1; - xmc[0] = (*c >> 4) & 0x7; - xmc[1] = (*c >> 1) & 0x7; - xmc[2] = (*c++ & 0x1) << 2; - xmc[2] |= (*c >> 6) & 0x3; - xmc[3] = (*c >> 3) & 0x7; - xmc[4] = *c++ & 0x7; - xmc[5] = (*c >> 5) & 0x7; - xmc[6] = (*c >> 2) & 0x7; - xmc[7] = (*c++ & 0x3) << 1; /* 10 */ - xmc[7] |= (*c >> 7) & 0x1; - xmc[8] = (*c >> 4) & 0x7; - xmc[9] = (*c >> 1) & 0x7; - xmc[10] = (*c++ & 0x1) << 2; - xmc[10] |= (*c >> 6) & 0x3; - xmc[11] = (*c >> 3) & 0x7; - xmc[12] = *c++ & 0x7; - Nc[1] = (*c >> 1) & 0x7F; - bc[1] = (*c++ & 0x1) << 1; - bc[1] |= (*c >> 7) & 0x1; - Mc[1] = (*c >> 5) & 0x3; - xmaxc[1] = (*c++ & 0x1F) << 1; - xmaxc[1] |= (*c >> 7) & 0x1; - xmc[13] = (*c >> 4) & 0x7; - xmc[14] = (*c >> 1) & 0x7; - xmc[15] = (*c++ & 0x1) << 2; - xmc[15] |= (*c >> 6) & 0x3; - xmc[16] = (*c >> 3) & 0x7; - xmc[17] = *c++ & 0x7; - xmc[18] = (*c >> 5) & 0x7; - xmc[19] = (*c >> 2) & 0x7; - xmc[20] = (*c++ & 0x3) << 1; - xmc[20] |= (*c >> 7) & 0x1; - xmc[21] = (*c >> 4) & 0x7; - xmc[22] = (*c >> 1) & 0x7; - xmc[23] = (*c++ & 0x1) << 2; - xmc[23] |= (*c >> 6) & 0x3; - xmc[24] = (*c >> 3) & 0x7; - xmc[25] = *c++ & 0x7; - Nc[2] = (*c >> 1) & 0x7F; - bc[2] = (*c++ & 0x1) << 1; /* 20 */ - bc[2] |= (*c >> 7) & 0x1; - Mc[2] = (*c >> 5) & 0x3; - xmaxc[2] = (*c++ & 0x1F) << 1; - xmaxc[2] |= (*c >> 7) & 0x1; - xmc[26] = (*c >> 4) & 0x7; - xmc[27] = (*c >> 1) & 0x7; - xmc[28] = (*c++ & 0x1) << 2; - xmc[28] |= (*c >> 6) & 0x3; - xmc[29] = (*c >> 3) & 0x7; - xmc[30] = *c++ & 0x7; - xmc[31] = (*c >> 5) & 0x7; - xmc[32] = (*c >> 2) & 0x7; - xmc[33] = (*c++ & 0x3) << 1; - xmc[33] |= (*c >> 7) & 0x1; - xmc[34] = (*c >> 4) & 0x7; - xmc[35] = (*c >> 1) & 0x7; - xmc[36] = (*c++ & 0x1) << 2; - xmc[36] |= (*c >> 6) & 0x3; - xmc[37] = (*c >> 3) & 0x7; - xmc[38] = *c++ & 0x7; - Nc[3] = (*c >> 1) & 0x7F; - bc[3] = (*c++ & 0x1) << 1; - bc[3] |= (*c >> 7) & 0x1; - Mc[3] = (*c >> 5) & 0x3; - xmaxc[3] = (*c++ & 0x1F) << 1; - xmaxc[3] |= (*c >> 7) & 0x1; - xmc[39] = (*c >> 4) & 0x7; - xmc[40] = (*c >> 1) & 0x7; - xmc[41] = (*c++ & 0x1) << 2; - xmc[41] |= (*c >> 6) & 0x3; - xmc[42] = (*c >> 3) & 0x7; - xmc[43] = *c++ & 0x7; /* 30 */ - xmc[44] = (*c >> 5) & 0x7; - xmc[45] = (*c >> 2) & 0x7; - xmc[46] = (*c++ & 0x3) << 1; - xmc[46] |= (*c >> 7) & 0x1; - xmc[47] = (*c >> 4) & 0x7; - xmc[48] = (*c >> 1) & 0x7; - xmc[49] = (*c++ & 0x1) << 2; - xmc[49] |= (*c >> 6) & 0x3; - xmc[50] = (*c >> 3) & 0x7; - xmc[51] = *c & 0x7; /* 33 */ - } - - Gsm_Decoder(s, LARc, Nc, bc, Mc, xmaxc, xmc, target); - - return 0; -} diff --git a/linphone/gsmlib/gsm_destroy.c b/linphone/gsmlib/gsm_destroy.c deleted file mode 100644 index e8bc33e63..000000000 --- a/linphone/gsmlib/gsm_destroy.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/gsm_destroy.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -#include "gsm.h" -#include "config.h" -#include "proto.h" - -#ifdef HAS_STDLIB_H -# include -#else -# ifdef HAS_MALLOC_H -# include -# else - extern void free(); -# endif -#endif - -void gsm_destroy P1((S), gsm S) -{ - if (S) free((char *)S); -} diff --git a/linphone/gsmlib/gsm_encode.c b/linphone/gsmlib/gsm_encode.c deleted file mode 100644 index 0c55ee0aa..000000000 --- a/linphone/gsmlib/gsm_encode.c +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/gsm_encode.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -#include "private.h" -#include "gsm.h" -#include "proto.h" - -void gsm_encode P3((s, source, c), gsm s, gsm_signal * source, gsm_byte * c) -{ - word LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13*4]; - - Gsm_Coder(s, source, LARc, Nc, bc, Mc, xmaxc, xmc); - - - /* variable size - - GSM_MAGIC 4 - - LARc[0] 6 - LARc[1] 6 - LARc[2] 5 - LARc[3] 5 - LARc[4] 4 - LARc[5] 4 - LARc[6] 3 - LARc[7] 3 - - Nc[0] 7 - bc[0] 2 - Mc[0] 2 - xmaxc[0] 6 - xmc[0] 3 - xmc[1] 3 - xmc[2] 3 - xmc[3] 3 - xmc[4] 3 - xmc[5] 3 - xmc[6] 3 - xmc[7] 3 - xmc[8] 3 - xmc[9] 3 - xmc[10] 3 - xmc[11] 3 - xmc[12] 3 - - Nc[1] 7 - bc[1] 2 - Mc[1] 2 - xmaxc[1] 6 - xmc[13] 3 - xmc[14] 3 - xmc[15] 3 - xmc[16] 3 - xmc[17] 3 - xmc[18] 3 - xmc[19] 3 - xmc[20] 3 - xmc[21] 3 - xmc[22] 3 - xmc[23] 3 - xmc[24] 3 - xmc[25] 3 - - Nc[2] 7 - bc[2] 2 - Mc[2] 2 - xmaxc[2] 6 - xmc[26] 3 - xmc[27] 3 - xmc[28] 3 - xmc[29] 3 - xmc[30] 3 - xmc[31] 3 - xmc[32] 3 - xmc[33] 3 - xmc[34] 3 - xmc[35] 3 - xmc[36] 3 - xmc[37] 3 - xmc[38] 3 - - Nc[3] 7 - bc[3] 2 - Mc[3] 2 - xmaxc[3] 6 - xmc[39] 3 - xmc[40] 3 - xmc[41] 3 - xmc[42] 3 - xmc[43] 3 - xmc[44] 3 - xmc[45] 3 - xmc[46] 3 - xmc[47] 3 - xmc[48] 3 - xmc[49] 3 - xmc[50] 3 - xmc[51] 3 - */ - -#ifdef WAV49 - - if (s->wav_fmt) { - s->frame_index = !s->frame_index; - if (s->frame_index) { - - uword sr; - - sr = 0; - sr = sr >> 6 | LARc[0] << 10; - sr = sr >> 6 | LARc[1] << 10; - *c++ = sr >> 4; - sr = sr >> 5 | LARc[2] << 11; - *c++ = sr >> 7; - sr = sr >> 5 | LARc[3] << 11; - sr = sr >> 4 | LARc[4] << 12; - *c++ = sr >> 6; - sr = sr >> 4 | LARc[5] << 12; - sr = sr >> 3 | LARc[6] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | LARc[7] << 13; - sr = sr >> 7 | Nc[0] << 9; - *c++ = sr >> 5; - sr = sr >> 2 | bc[0] << 14; - sr = sr >> 2 | Mc[0] << 14; - sr = sr >> 6 | xmaxc[0] << 10; - *c++ = sr >> 3; - sr = sr >> 3 | xmc[0] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[1] << 13; - sr = sr >> 3 | xmc[2] << 13; - sr = sr >> 3 | xmc[3] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[4] << 13; - sr = sr >> 3 | xmc[5] << 13; - sr = sr >> 3 | xmc[6] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[7] << 13; - sr = sr >> 3 | xmc[8] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[9] << 13; - sr = sr >> 3 | xmc[10] << 13; - sr = sr >> 3 | xmc[11] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[12] << 13; - sr = sr >> 7 | Nc[1] << 9; - *c++ = sr >> 5; - sr = sr >> 2 | bc[1] << 14; - sr = sr >> 2 | Mc[1] << 14; - sr = sr >> 6 | xmaxc[1] << 10; - *c++ = sr >> 3; - sr = sr >> 3 | xmc[13] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[14] << 13; - sr = sr >> 3 | xmc[15] << 13; - sr = sr >> 3 | xmc[16] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[17] << 13; - sr = sr >> 3 | xmc[18] << 13; - sr = sr >> 3 | xmc[19] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[20] << 13; - sr = sr >> 3 | xmc[21] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[22] << 13; - sr = sr >> 3 | xmc[23] << 13; - sr = sr >> 3 | xmc[24] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[25] << 13; - sr = sr >> 7 | Nc[2] << 9; - *c++ = sr >> 5; - sr = sr >> 2 | bc[2] << 14; - sr = sr >> 2 | Mc[2] << 14; - sr = sr >> 6 | xmaxc[2] << 10; - *c++ = sr >> 3; - sr = sr >> 3 | xmc[26] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[27] << 13; - sr = sr >> 3 | xmc[28] << 13; - sr = sr >> 3 | xmc[29] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[30] << 13; - sr = sr >> 3 | xmc[31] << 13; - sr = sr >> 3 | xmc[32] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[33] << 13; - sr = sr >> 3 | xmc[34] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[35] << 13; - sr = sr >> 3 | xmc[36] << 13; - sr = sr >> 3 | xmc[37] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[38] << 13; - sr = sr >> 7 | Nc[3] << 9; - *c++ = sr >> 5; - sr = sr >> 2 | bc[3] << 14; - sr = sr >> 2 | Mc[3] << 14; - sr = sr >> 6 | xmaxc[3] << 10; - *c++ = sr >> 3; - sr = sr >> 3 | xmc[39] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[40] << 13; - sr = sr >> 3 | xmc[41] << 13; - sr = sr >> 3 | xmc[42] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[43] << 13; - sr = sr >> 3 | xmc[44] << 13; - sr = sr >> 3 | xmc[45] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[46] << 13; - sr = sr >> 3 | xmc[47] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[48] << 13; - sr = sr >> 3 | xmc[49] << 13; - sr = sr >> 3 | xmc[50] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[51] << 13; - sr = sr >> 4; - *c = sr >> 8; - s->frame_chain = *c; - } - else { - uword sr; - - sr = 0; - sr = sr >> 4 | s->frame_chain << 12; - sr = sr >> 6 | LARc[0] << 10; - *c++ = sr >> 6; - sr = sr >> 6 | LARc[1] << 10; - *c++ = sr >> 8; - sr = sr >> 5 | LARc[2] << 11; - sr = sr >> 5 | LARc[3] << 11; - *c++ = sr >> 6; - sr = sr >> 4 | LARc[4] << 12; - sr = sr >> 4 | LARc[5] << 12; - *c++ = sr >> 6; - sr = sr >> 3 | LARc[6] << 13; - sr = sr >> 3 | LARc[7] << 13; - *c++ = sr >> 8; - sr = sr >> 7 | Nc[0] << 9; - sr = sr >> 2 | bc[0] << 14; - *c++ = sr >> 7; - sr = sr >> 2 | Mc[0] << 14; - sr = sr >> 6 | xmaxc[0] << 10; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[0] << 13; - sr = sr >> 3 | xmc[1] << 13; - sr = sr >> 3 | xmc[2] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[3] << 13; - sr = sr >> 3 | xmc[4] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[5] << 13; - sr = sr >> 3 | xmc[6] << 13; - sr = sr >> 3 | xmc[7] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[8] << 13; - sr = sr >> 3 | xmc[9] << 13; - sr = sr >> 3 | xmc[10] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[11] << 13; - sr = sr >> 3 | xmc[12] << 13; - *c++ = sr >> 8; - sr = sr >> 7 | Nc[1] << 9; - sr = sr >> 2 | bc[1] << 14; - *c++ = sr >> 7; - sr = sr >> 2 | Mc[1] << 14; - sr = sr >> 6 | xmaxc[1] << 10; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[13] << 13; - sr = sr >> 3 | xmc[14] << 13; - sr = sr >> 3 | xmc[15] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[16] << 13; - sr = sr >> 3 | xmc[17] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[18] << 13; - sr = sr >> 3 | xmc[19] << 13; - sr = sr >> 3 | xmc[20] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[21] << 13; - sr = sr >> 3 | xmc[22] << 13; - sr = sr >> 3 | xmc[23] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[24] << 13; - sr = sr >> 3 | xmc[25] << 13; - *c++ = sr >> 8; - sr = sr >> 7 | Nc[2] << 9; - sr = sr >> 2 | bc[2] << 14; - *c++ = sr >> 7; - sr = sr >> 2 | Mc[2] << 14; - sr = sr >> 6 | xmaxc[2] << 10; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[26] << 13; - sr = sr >> 3 | xmc[27] << 13; - sr = sr >> 3 | xmc[28] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[29] << 13; - sr = sr >> 3 | xmc[30] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[31] << 13; - sr = sr >> 3 | xmc[32] << 13; - sr = sr >> 3 | xmc[33] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[34] << 13; - sr = sr >> 3 | xmc[35] << 13; - sr = sr >> 3 | xmc[36] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[37] << 13; - sr = sr >> 3 | xmc[38] << 13; - *c++ = sr >> 8; - sr = sr >> 7 | Nc[3] << 9; - sr = sr >> 2 | bc[3] << 14; - *c++ = sr >> 7; - sr = sr >> 2 | Mc[3] << 14; - sr = sr >> 6 | xmaxc[3] << 10; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[39] << 13; - sr = sr >> 3 | xmc[40] << 13; - sr = sr >> 3 | xmc[41] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[42] << 13; - sr = sr >> 3 | xmc[43] << 13; - *c++ = sr >> 8; - sr = sr >> 3 | xmc[44] << 13; - sr = sr >> 3 | xmc[45] << 13; - sr = sr >> 3 | xmc[46] << 13; - *c++ = sr >> 7; - sr = sr >> 3 | xmc[47] << 13; - sr = sr >> 3 | xmc[48] << 13; - sr = sr >> 3 | xmc[49] << 13; - *c++ = sr >> 6; - sr = sr >> 3 | xmc[50] << 13; - sr = sr >> 3 | xmc[51] << 13; - *c++ = sr >> 8; - } - } - - else - -#endif /* WAV49 */ - { - - *c++ = ((GSM_MAGIC & 0xF) << 4) /* 1 */ - | ((LARc[0] >> 2) & 0xF); - *c++ = ((LARc[0] & 0x3) << 6) - | (LARc[1] & 0x3F); - *c++ = ((LARc[2] & 0x1F) << 3) - | ((LARc[3] >> 2) & 0x7); - *c++ = ((LARc[3] & 0x3) << 6) - | ((LARc[4] & 0xF) << 2) - | ((LARc[5] >> 2) & 0x3); - *c++ = ((LARc[5] & 0x3) << 6) - | ((LARc[6] & 0x7) << 3) - | (LARc[7] & 0x7); - *c++ = ((Nc[0] & 0x7F) << 1) - | ((bc[0] >> 1) & 0x1); - *c++ = ((bc[0] & 0x1) << 7) - | ((Mc[0] & 0x3) << 5) - | ((xmaxc[0] >> 1) & 0x1F); - *c++ = ((xmaxc[0] & 0x1) << 7) - | ((xmc[0] & 0x7) << 4) - | ((xmc[1] & 0x7) << 1) - | ((xmc[2] >> 2) & 0x1); - *c++ = ((xmc[2] & 0x3) << 6) - | ((xmc[3] & 0x7) << 3) - | (xmc[4] & 0x7); - *c++ = ((xmc[5] & 0x7) << 5) /* 10 */ - | ((xmc[6] & 0x7) << 2) - | ((xmc[7] >> 1) & 0x3); - *c++ = ((xmc[7] & 0x1) << 7) - | ((xmc[8] & 0x7) << 4) - | ((xmc[9] & 0x7) << 1) - | ((xmc[10] >> 2) & 0x1); - *c++ = ((xmc[10] & 0x3) << 6) - | ((xmc[11] & 0x7) << 3) - | (xmc[12] & 0x7); - *c++ = ((Nc[1] & 0x7F) << 1) - | ((bc[1] >> 1) & 0x1); - *c++ = ((bc[1] & 0x1) << 7) - | ((Mc[1] & 0x3) << 5) - | ((xmaxc[1] >> 1) & 0x1F); - *c++ = ((xmaxc[1] & 0x1) << 7) - | ((xmc[13] & 0x7) << 4) - | ((xmc[14] & 0x7) << 1) - | ((xmc[15] >> 2) & 0x1); - *c++ = ((xmc[15] & 0x3) << 6) - | ((xmc[16] & 0x7) << 3) - | (xmc[17] & 0x7); - *c++ = ((xmc[18] & 0x7) << 5) - | ((xmc[19] & 0x7) << 2) - | ((xmc[20] >> 1) & 0x3); - *c++ = ((xmc[20] & 0x1) << 7) - | ((xmc[21] & 0x7) << 4) - | ((xmc[22] & 0x7) << 1) - | ((xmc[23] >> 2) & 0x1); - *c++ = ((xmc[23] & 0x3) << 6) - | ((xmc[24] & 0x7) << 3) - | (xmc[25] & 0x7); - *c++ = ((Nc[2] & 0x7F) << 1) /* 20 */ - | ((bc[2] >> 1) & 0x1); - *c++ = ((bc[2] & 0x1) << 7) - | ((Mc[2] & 0x3) << 5) - | ((xmaxc[2] >> 1) & 0x1F); - *c++ = ((xmaxc[2] & 0x1) << 7) - | ((xmc[26] & 0x7) << 4) - | ((xmc[27] & 0x7) << 1) - | ((xmc[28] >> 2) & 0x1); - *c++ = ((xmc[28] & 0x3) << 6) - | ((xmc[29] & 0x7) << 3) - | (xmc[30] & 0x7); - *c++ = ((xmc[31] & 0x7) << 5) - | ((xmc[32] & 0x7) << 2) - | ((xmc[33] >> 1) & 0x3); - *c++ = ((xmc[33] & 0x1) << 7) - | ((xmc[34] & 0x7) << 4) - | ((xmc[35] & 0x7) << 1) - | ((xmc[36] >> 2) & 0x1); - *c++ = ((xmc[36] & 0x3) << 6) - | ((xmc[37] & 0x7) << 3) - | (xmc[38] & 0x7); - *c++ = ((Nc[3] & 0x7F) << 1) - | ((bc[3] >> 1) & 0x1); - *c++ = ((bc[3] & 0x1) << 7) - | ((Mc[3] & 0x3) << 5) - | ((xmaxc[3] >> 1) & 0x1F); - *c++ = ((xmaxc[3] & 0x1) << 7) - | ((xmc[39] & 0x7) << 4) - | ((xmc[40] & 0x7) << 1) - | ((xmc[41] >> 2) & 0x1); - *c++ = ((xmc[41] & 0x3) << 6) /* 30 */ - | ((xmc[42] & 0x7) << 3) - | (xmc[43] & 0x7); - *c++ = ((xmc[44] & 0x7) << 5) - | ((xmc[45] & 0x7) << 2) - | ((xmc[46] >> 1) & 0x3); - *c++ = ((xmc[46] & 0x1) << 7) - | ((xmc[47] & 0x7) << 4) - | ((xmc[48] & 0x7) << 1) - | ((xmc[49] >> 2) & 0x1); - *c++ = ((xmc[49] & 0x3) << 6) - | ((xmc[50] & 0x7) << 3) - | (xmc[51] & 0x7); - - } -} diff --git a/linphone/gsmlib/gsm_explode.c b/linphone/gsmlib/gsm_explode.c deleted file mode 100644 index b7c98ed5a..000000000 --- a/linphone/gsmlib/gsm_explode.c +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/gsm_explode.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -#include "private.h" -#include "gsm.h" -#include "proto.h" - -int gsm_explode P3((s, c, target), gsm s, gsm_byte * c, gsm_signal * target) -{ -# define LARc target -# define Nc *((gsm_signal (*) [17])(target + 8)) -# define bc *((gsm_signal (*) [17])(target + 9)) -# define Mc *((gsm_signal (*) [17])(target + 10)) -# define xmaxc *((gsm_signal (*) [17])(target + 11)) - - -#ifdef WAV49 - if (s->wav_fmt) { - - uword sr = 0; - - if (s->frame_index == 1) { - - sr = *c++; - LARc[0] = sr & 0x3f; sr >>= 6; - sr |= (uword)*c++ << 2; - LARc[1] = sr & 0x3f; sr >>= 6; - sr |= (uword)*c++ << 4; - LARc[2] = sr & 0x1f; sr >>= 5; - LARc[3] = sr & 0x1f; sr >>= 5; - sr |= (uword)*c++ << 2; - LARc[4] = sr & 0xf; sr >>= 4; - LARc[5] = sr & 0xf; sr >>= 4; - sr |= (uword)*c++ << 2; /* 5 */ - LARc[6] = sr & 0x7; sr >>= 3; - LARc[7] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; - Nc[0] = sr & 0x7f; sr >>= 7; - bc[0] = sr & 0x3; sr >>= 2; - Mc[0] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[0] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (target + 12) - xmc[0] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[1] = sr & 0x7; sr >>= 3; - xmc[2] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[3] = sr & 0x7; sr >>= 3; - xmc[4] = sr & 0x7; sr >>= 3; - xmc[5] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; /* 10 */ - xmc[6] = sr & 0x7; sr >>= 3; - xmc[7] = sr & 0x7; sr >>= 3; - xmc[8] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[9] = sr & 0x7; sr >>= 3; - xmc[10] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[11] = sr & 0x7; sr >>= 3; - xmc[12] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; - Nc[1] = sr & 0x7f; sr >>= 7; - bc[1] = sr & 0x3; sr >>= 2; - Mc[1] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[1] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (target + 29 - 13) - - xmc[13] = sr & 0x7; sr >>= 3; - sr = *c++; /* 15 */ - xmc[14] = sr & 0x7; sr >>= 3; - xmc[15] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[16] = sr & 0x7; sr >>= 3; - xmc[17] = sr & 0x7; sr >>= 3; - xmc[18] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[19] = sr & 0x7; sr >>= 3; - xmc[20] = sr & 0x7; sr >>= 3; - xmc[21] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[22] = sr & 0x7; sr >>= 3; - xmc[23] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[24] = sr & 0x7; sr >>= 3; - xmc[25] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; /* 20 */ - Nc[2] = sr & 0x7f; sr >>= 7; - bc[2] = sr & 0x3; sr >>= 2; - Mc[2] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[2] = sr & 0x3f; sr >>= 6; - -#undef xmc -#define xmc (target + 46 - 26) - - xmc[26] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[27] = sr & 0x7; sr >>= 3; - xmc[28] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[29] = sr & 0x7; sr >>= 3; - xmc[30] = sr & 0x7; sr >>= 3; - xmc[31] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[32] = sr & 0x7; sr >>= 3; - xmc[33] = sr & 0x7; sr >>= 3; - xmc[34] = sr & 0x7; sr >>= 3; - sr = *c++; /* 25 */ - xmc[35] = sr & 0x7; sr >>= 3; - xmc[36] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[37] = sr & 0x7; sr >>= 3; - xmc[38] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; - Nc[3] = sr & 0x7f; sr >>= 7; - bc[3] = sr & 0x3; sr >>= 2; - Mc[3] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[3] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (target + 63 - 39) - - xmc[39] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[40] = sr & 0x7; sr >>= 3; - xmc[41] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; /* 30 */ - xmc[42] = sr & 0x7; sr >>= 3; - xmc[43] = sr & 0x7; sr >>= 3; - xmc[44] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[45] = sr & 0x7; sr >>= 3; - xmc[46] = sr & 0x7; sr >>= 3; - xmc[47] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[48] = sr & 0x7; sr >>= 3; - xmc[49] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[50] = sr & 0x7; sr >>= 3; - xmc[51] = sr & 0x7; sr >>= 3; - - s->frame_chain = sr & 0xf; - } - else { - sr = s->frame_chain; - sr |= (uword)*c++ << 4; /* 1 */ - LARc[0] = sr & 0x3f; sr >>= 6; - LARc[1] = sr & 0x3f; sr >>= 6; - sr = *c++; - LARc[2] = sr & 0x1f; sr >>= 5; - sr |= (uword)*c++ << 3; - LARc[3] = sr & 0x1f; sr >>= 5; - LARc[4] = sr & 0xf; sr >>= 4; - sr |= (uword)*c++ << 2; - LARc[5] = sr & 0xf; sr >>= 4; - LARc[6] = sr & 0x7; sr >>= 3; - LARc[7] = sr & 0x7; sr >>= 3; - sr = *c++; /* 5 */ - Nc[0] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; - bc[0] = sr & 0x3; sr >>= 2; - Mc[0] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[0] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (target + 12) - xmc[0] = sr & 0x7; sr >>= 3; - xmc[1] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[2] = sr & 0x7; sr >>= 3; - xmc[3] = sr & 0x7; sr >>= 3; - xmc[4] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[5] = sr & 0x7; sr >>= 3; - xmc[6] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; /* 10 */ - xmc[7] = sr & 0x7; sr >>= 3; - xmc[8] = sr & 0x7; sr >>= 3; - xmc[9] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[10] = sr & 0x7; sr >>= 3; - xmc[11] = sr & 0x7; sr >>= 3; - xmc[12] = sr & 0x7; sr >>= 3; - sr = *c++; - Nc[1] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; - bc[1] = sr & 0x3; sr >>= 2; - Mc[1] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[1] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (target + 29 - 13) - - xmc[13] = sr & 0x7; sr >>= 3; - xmc[14] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; /* 15 */ - xmc[15] = sr & 0x7; sr >>= 3; - xmc[16] = sr & 0x7; sr >>= 3; - xmc[17] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[18] = sr & 0x7; sr >>= 3; - xmc[19] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[20] = sr & 0x7; sr >>= 3; - xmc[21] = sr & 0x7; sr >>= 3; - xmc[22] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[23] = sr & 0x7; sr >>= 3; - xmc[24] = sr & 0x7; sr >>= 3; - xmc[25] = sr & 0x7; sr >>= 3; - sr = *c++; - Nc[2] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; /* 20 */ - bc[2] = sr & 0x3; sr >>= 2; - Mc[2] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[2] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (target + 46 - 26) - xmc[26] = sr & 0x7; sr >>= 3; - xmc[27] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[28] = sr & 0x7; sr >>= 3; - xmc[29] = sr & 0x7; sr >>= 3; - xmc[30] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[31] = sr & 0x7; sr >>= 3; - xmc[32] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[33] = sr & 0x7; sr >>= 3; - xmc[34] = sr & 0x7; sr >>= 3; - xmc[35] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; /* 25 */ - xmc[36] = sr & 0x7; sr >>= 3; - xmc[37] = sr & 0x7; sr >>= 3; - xmc[38] = sr & 0x7; sr >>= 3; - sr = *c++; - Nc[3] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; - bc[3] = sr & 0x3; sr >>= 2; - Mc[3] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[3] = sr & 0x3f; sr >>= 6; - -#undef xmc -#define xmc (target + 63 - 39) - - xmc[39] = sr & 0x7; sr >>= 3; - xmc[40] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[41] = sr & 0x7; sr >>= 3; - xmc[42] = sr & 0x7; sr >>= 3; - xmc[43] = sr & 0x7; sr >>= 3; - sr = *c++; /* 30 */ - xmc[44] = sr & 0x7; sr >>= 3; - xmc[45] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[46] = sr & 0x7; sr >>= 3; - xmc[47] = sr & 0x7; sr >>= 3; - xmc[48] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[49] = sr & 0x7; sr >>= 3; - xmc[50] = sr & 0x7; sr >>= 3; - xmc[51] = sr & 0x7; sr >>= 3; - } - } - else -#endif - { - /* GSM_MAGIC = (*c >> 4) & 0xF; */ - - if (((*c >> 4) & 0x0F) != GSM_MAGIC) return -1; - - LARc[0] = (*c++ & 0xF) << 2; /* 1 */ - LARc[0] |= (*c >> 6) & 0x3; - LARc[1] = *c++ & 0x3F; - LARc[2] = (*c >> 3) & 0x1F; - LARc[3] = (*c++ & 0x7) << 2; - LARc[3] |= (*c >> 6) & 0x3; - LARc[4] = (*c >> 2) & 0xF; - LARc[5] = (*c++ & 0x3) << 2; - LARc[5] |= (*c >> 6) & 0x3; - LARc[6] = (*c >> 3) & 0x7; - LARc[7] = *c++ & 0x7; - - Nc[0] = (*c >> 1) & 0x7F; - - bc[0] = (*c++ & 0x1) << 1; - bc[0] |= (*c >> 7) & 0x1; - - Mc[0] = (*c >> 5) & 0x3; - - xmaxc[0] = (*c++ & 0x1F) << 1; - xmaxc[0] |= (*c >> 7) & 0x1; - -#undef xmc -#define xmc (target + 12) - - xmc[0] = (*c >> 4) & 0x7; - xmc[1] = (*c >> 1) & 0x7; - xmc[2] = (*c++ & 0x1) << 2; - xmc[2] |= (*c >> 6) & 0x3; - xmc[3] = (*c >> 3) & 0x7; - xmc[4] = *c++ & 0x7; - xmc[5] = (*c >> 5) & 0x7; - xmc[6] = (*c >> 2) & 0x7; - xmc[7] = (*c++ & 0x3) << 1; /* 10 */ - xmc[7] |= (*c >> 7) & 0x1; - xmc[8] = (*c >> 4) & 0x7; - xmc[9] = (*c >> 1) & 0x7; - xmc[10] = (*c++ & 0x1) << 2; - xmc[10] |= (*c >> 6) & 0x3; - xmc[11] = (*c >> 3) & 0x7; - xmc[12] = *c++ & 0x7; - - Nc[1] = (*c >> 1) & 0x7F; - - bc[1] = (*c++ & 0x1) << 1; - bc[1] |= (*c >> 7) & 0x1; - - Mc[1] = (*c >> 5) & 0x3; - - xmaxc[1] = (*c++ & 0x1F) << 1; - xmaxc[1] |= (*c >> 7) & 0x1; - -#undef xmc -#define xmc (target + 29 - 13) - - xmc[13] = (*c >> 4) & 0x7; - xmc[14] = (*c >> 1) & 0x7; - xmc[15] = (*c++ & 0x1) << 2; - xmc[15] |= (*c >> 6) & 0x3; - xmc[16] = (*c >> 3) & 0x7; - xmc[17] = *c++ & 0x7; - xmc[18] = (*c >> 5) & 0x7; - xmc[19] = (*c >> 2) & 0x7; - xmc[20] = (*c++ & 0x3) << 1; - xmc[20] |= (*c >> 7) & 0x1; - xmc[21] = (*c >> 4) & 0x7; - xmc[22] = (*c >> 1) & 0x7; - xmc[23] = (*c++ & 0x1) << 2; - xmc[23] |= (*c >> 6) & 0x3; - xmc[24] = (*c >> 3) & 0x7; - xmc[25] = *c++ & 0x7; - - Nc[2] = (*c >> 1) & 0x7F; - - bc[2] = (*c++ & 0x1) << 1; /* 20 */ - bc[2] |= (*c >> 7) & 0x1; - - Mc[2] = (*c >> 5) & 0x3; - - xmaxc[2] = (*c++ & 0x1F) << 1; - xmaxc[2] |= (*c >> 7) & 0x1; - -#undef xmc -#define xmc (target + 46 - 26) - - xmc[26] = (*c >> 4) & 0x7; - xmc[27] = (*c >> 1) & 0x7; - xmc[28] = (*c++ & 0x1) << 2; - xmc[28] |= (*c >> 6) & 0x3; - xmc[29] = (*c >> 3) & 0x7; - xmc[30] = *c++ & 0x7; - xmc[31] = (*c >> 5) & 0x7; - xmc[32] = (*c >> 2) & 0x7; - xmc[33] = (*c++ & 0x3) << 1; - xmc[33] |= (*c >> 7) & 0x1; - xmc[34] = (*c >> 4) & 0x7; - xmc[35] = (*c >> 1) & 0x7; - xmc[36] = (*c++ & 0x1) << 2; - xmc[36] |= (*c >> 6) & 0x3; - xmc[37] = (*c >> 3) & 0x7; - xmc[38] = *c++ & 0x7; - - Nc[3] = (*c >> 1) & 0x7F; - - bc[3] = (*c++ & 0x1) << 1; - bc[3] |= (*c >> 7) & 0x1; - - Mc[3] = (*c >> 5) & 0x3; - - xmaxc[3] = (*c++ & 0x1F) << 1; - xmaxc[3] |= (*c >> 7) & 0x1; - -#undef xmc -#define xmc (target + 63 - 39) - - xmc[39] = (*c >> 4) & 0x7; - xmc[40] = (*c >> 1) & 0x7; - xmc[41] = (*c++ & 0x1) << 2; - xmc[41] |= (*c >> 6) & 0x3; - xmc[42] = (*c >> 3) & 0x7; - xmc[43] = *c++ & 0x7; /* 30 */ - xmc[44] = (*c >> 5) & 0x7; - xmc[45] = (*c >> 2) & 0x7; - xmc[46] = (*c++ & 0x3) << 1; - xmc[46] |= (*c >> 7) & 0x1; - xmc[47] = (*c >> 4) & 0x7; - xmc[48] = (*c >> 1) & 0x7; - xmc[49] = (*c++ & 0x1) << 2; - xmc[49] |= (*c >> 6) & 0x3; - xmc[50] = (*c >> 3) & 0x7; - xmc[51] = *c & 0x7; /* 33 */ - } - - return 0; -} diff --git a/linphone/gsmlib/gsm_implode.c b/linphone/gsmlib/gsm_implode.c deleted file mode 100644 index e2c9d1c72..000000000 --- a/linphone/gsmlib/gsm_implode.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/gsm_implode.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -#include "private.h" - -#include "gsm.h" -#include "proto.h" - -void gsm_implode P3((s, source, c), gsm s, gsm_signal * source, gsm_byte * c) -{ - /* variable size index - - GSM_MAGIC 4 - - - LARc[0] 6 0 - LARc[1] 6 1 - LARc[2] 5 2 - LARc[3] 5 3 - LARc[4] 4 4 - LARc[5] 4 5 - LARc[6] 3 6 - LARc[7] 3 7 - - Nc[0] 7 8 - bc[0] 2 9 - Mc[0] 2 10 - xmaxc[0] 6 11 - xmc[0] 3 12 - xmc[1] 3 13 - xmc[2] 3 14 - xmc[3] 3 15 - xmc[4] 3 16 - xmc[5] 3 17 - xmc[6] 3 18 - xmc[7] 3 19 - xmc[8] 3 20 - xmc[9] 3 21 - xmc[10] 3 22 - xmc[11] 3 23 - xmc[12] 3 24 - - Nc[1] 7 25 - bc[1] 2 26 - Mc[1] 2 27 - xmaxc[1] 6 28 - xmc[13] 3 29 - xmc[14] 3 30 - xmc[15] 3 31 - xmc[16] 3 32 - xmc[17] 3 33 - xmc[18] 3 34 - xmc[19] 3 35 - xmc[20] 3 36 - xmc[21] 3 37 - xmc[22] 3 38 - xmc[23] 3 39 - xmc[24] 3 40 - xmc[25] 3 41 - - Nc[2] 7 42 - bc[2] 2 43 - Mc[2] 2 44 - xmaxc[2] 6 45 - xmc[26] 3 46 - xmc[27] 3 47 - xmc[28] 3 48 - xmc[29] 3 49 - xmc[30] 3 50 - xmc[31] 3 51 - xmc[32] 3 52 - xmc[33] 3 53 - xmc[34] 3 54 - xmc[35] 3 55 - xmc[36] 3 56 - xmc[37] 3 57 - xmc[38] 3 58 - - Nc[3] 7 59 - bc[3] 2 60 - Mc[3] 2 61 - xmaxc[3] 6 62 - xmc[39] 3 63 - xmc[40] 3 64 - xmc[41] 3 65 - xmc[42] 3 66 - xmc[43] 3 67 - xmc[44] 3 68 - xmc[45] 3 69 - xmc[46] 3 70 - xmc[47] 3 71 - xmc[48] 3 72 - xmc[49] 3 73 - xmc[50] 3 74 - xmc[51] 3 75 - */ - - /* There are 76 parameters per frame. The first eight are - * unique. The remaining 68 are four identical subframes of - * 17 parameters each. gsm_implode converts from a representation - * of these parameters as values in one array of signed words - * to the "packed" version of a GSM frame. - */ - -# define LARc source -# define Nc *((gsm_signal (*) [17])(source + 8)) -# define bc *((gsm_signal (*) [17])(source + 9)) -# define Mc *((gsm_signal (*) [17])(source + 10)) -# define xmaxc *((gsm_signal (*) [17])(source + 11)) - -#ifdef WAV49 - if (s->wav_fmt) { - - uword sr = 0; - if (s->frame_index == 0) { - - sr = *c++; - LARc[0] = sr & 0x3f; sr >>= 6; - sr |= (uword)*c++ << 2; - LARc[1] = sr & 0x3f; sr >>= 6; - sr |= (uword)*c++ << 4; - LARc[2] = sr & 0x1f; sr >>= 5; - LARc[3] = sr & 0x1f; sr >>= 5; - sr |= (uword)*c++ << 2; - LARc[4] = sr & 0xf; sr >>= 4; - LARc[5] = sr & 0xf; sr >>= 4; - sr |= (uword)*c++ << 2; /* 5 */ - LARc[6] = sr & 0x7; sr >>= 3; - LARc[7] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; - Nc[0] = sr & 0x7f; sr >>= 7; - bc[0] = sr & 0x3; sr >>= 2; - Mc[0] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[0] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (source + 12) - xmc[0] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[1] = sr & 0x7; sr >>= 3; - xmc[2] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[3] = sr & 0x7; sr >>= 3; - xmc[4] = sr & 0x7; sr >>= 3; - xmc[5] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; /* 10 */ - xmc[6] = sr & 0x7; sr >>= 3; - xmc[7] = sr & 0x7; sr >>= 3; - xmc[8] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[9] = sr & 0x7; sr >>= 3; - xmc[10] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[11] = sr & 0x7; sr >>= 3; - xmc[12] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; - Nc[1] = sr & 0x7f; sr >>= 7; - bc[1] = sr & 0x3; sr >>= 2; - Mc[1] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[1] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (source + 29 - 13) - xmc[13] = sr & 0x7; sr >>= 3; - sr = *c++; /* 15 */ - xmc[14] = sr & 0x7; sr >>= 3; - xmc[15] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[16] = sr & 0x7; sr >>= 3; - xmc[17] = sr & 0x7; sr >>= 3; - xmc[18] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[19] = sr & 0x7; sr >>= 3; - xmc[20] = sr & 0x7; sr >>= 3; - xmc[21] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[22] = sr & 0x7; sr >>= 3; - xmc[23] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[24] = sr & 0x7; sr >>= 3; - xmc[25] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; /* 20 */ - Nc[2] = sr & 0x7f; sr >>= 7; - bc[2] = sr & 0x3; sr >>= 2; - Mc[2] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[2] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (source + 46 - 26) - xmc[26] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[27] = sr & 0x7; sr >>= 3; - xmc[28] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[29] = sr & 0x7; sr >>= 3; - xmc[30] = sr & 0x7; sr >>= 3; - xmc[31] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[32] = sr & 0x7; sr >>= 3; - xmc[33] = sr & 0x7; sr >>= 3; - xmc[34] = sr & 0x7; sr >>= 3; - sr = *c++; /* 25 */ - xmc[35] = sr & 0x7; sr >>= 3; - xmc[36] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[37] = sr & 0x7; sr >>= 3; - xmc[38] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 4; - Nc[3] = sr & 0x7f; sr >>= 7; - bc[3] = sr & 0x3; sr >>= 2; - Mc[3] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 1; - xmaxc[3] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (source + 63 - 39) - - xmc[39] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[40] = sr & 0x7; sr >>= 3; - xmc[41] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; /* 30 */ - xmc[42] = sr & 0x7; sr >>= 3; - xmc[43] = sr & 0x7; sr >>= 3; - xmc[44] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[45] = sr & 0x7; sr >>= 3; - xmc[46] = sr & 0x7; sr >>= 3; - xmc[47] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[48] = sr & 0x7; sr >>= 3; - xmc[49] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[50] = sr & 0x7; sr >>= 3; - xmc[51] = sr & 0x7; sr >>= 3; - - s->frame_chain = sr & 0xf; - } - else { - sr = s->frame_chain; - sr |= (uword)*c++ << 4; /* 1 */ - LARc[0] = sr & 0x3f; sr >>= 6; - LARc[1] = sr & 0x3f; sr >>= 6; - sr = *c++; - LARc[2] = sr & 0x1f; sr >>= 5; - sr |= (uword)*c++ << 3; - LARc[3] = sr & 0x1f; sr >>= 5; - LARc[4] = sr & 0xf; sr >>= 4; - sr |= (uword)*c++ << 2; - LARc[5] = sr & 0xf; sr >>= 4; - LARc[6] = sr & 0x7; sr >>= 3; - LARc[7] = sr & 0x7; sr >>= 3; - sr = *c++; /* 5 */ - Nc[0] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; - bc[0] = sr & 0x3; sr >>= 2; - Mc[0] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[0] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (source + 12) - xmc[0] = sr & 0x7; sr >>= 3; - xmc[1] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[2] = sr & 0x7; sr >>= 3; - xmc[3] = sr & 0x7; sr >>= 3; - xmc[4] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[5] = sr & 0x7; sr >>= 3; - xmc[6] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; /* 10 */ - xmc[7] = sr & 0x7; sr >>= 3; - xmc[8] = sr & 0x7; sr >>= 3; - xmc[9] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[10] = sr & 0x7; sr >>= 3; - xmc[11] = sr & 0x7; sr >>= 3; - xmc[12] = sr & 0x7; sr >>= 3; - sr = *c++; - Nc[1] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; - bc[1] = sr & 0x3; sr >>= 2; - Mc[1] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[1] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (source + 29 - 13) - xmc[13] = sr & 0x7; sr >>= 3; - xmc[14] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; /* 15 */ - xmc[15] = sr & 0x7; sr >>= 3; - xmc[16] = sr & 0x7; sr >>= 3; - xmc[17] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[18] = sr & 0x7; sr >>= 3; - xmc[19] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[20] = sr & 0x7; sr >>= 3; - xmc[21] = sr & 0x7; sr >>= 3; - xmc[22] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[23] = sr & 0x7; sr >>= 3; - xmc[24] = sr & 0x7; sr >>= 3; - xmc[25] = sr & 0x7; sr >>= 3; - sr = *c++; - Nc[2] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; /* 20 */ - bc[2] = sr & 0x3; sr >>= 2; - Mc[2] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[2] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (source + 46 - 26) - xmc[26] = sr & 0x7; sr >>= 3; - xmc[27] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[28] = sr & 0x7; sr >>= 3; - xmc[29] = sr & 0x7; sr >>= 3; - xmc[30] = sr & 0x7; sr >>= 3; - sr = *c++; - xmc[31] = sr & 0x7; sr >>= 3; - xmc[32] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[33] = sr & 0x7; sr >>= 3; - xmc[34] = sr & 0x7; sr >>= 3; - xmc[35] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; /* 25 */ - xmc[36] = sr & 0x7; sr >>= 3; - xmc[37] = sr & 0x7; sr >>= 3; - xmc[38] = sr & 0x7; sr >>= 3; - sr = *c++; - Nc[3] = sr & 0x7f; sr >>= 7; - sr |= (uword)*c++ << 1; - bc[3] = sr & 0x3; sr >>= 2; - Mc[3] = sr & 0x3; sr >>= 2; - sr |= (uword)*c++ << 5; - xmaxc[3] = sr & 0x3f; sr >>= 6; -#undef xmc -#define xmc (source + 63 - 39) - - xmc[39] = sr & 0x7; sr >>= 3; - xmc[40] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[41] = sr & 0x7; sr >>= 3; - xmc[42] = sr & 0x7; sr >>= 3; - xmc[43] = sr & 0x7; sr >>= 3; - sr = *c++; /* 30 */ - xmc[44] = sr & 0x7; sr >>= 3; - xmc[45] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 2; - xmc[46] = sr & 0x7; sr >>= 3; - xmc[47] = sr & 0x7; sr >>= 3; - xmc[48] = sr & 0x7; sr >>= 3; - sr |= (uword)*c++ << 1; - xmc[49] = sr & 0x7; sr >>= 3; - xmc[50] = sr & 0x7; sr >>= 3; - xmc[51] = sr & 0x7; sr >>= 3; - } - } - else -#endif - { - - *c++ = ((GSM_MAGIC & 0xF) << 4) /* 1 */ - | ((LARc[0] >> 2) & 0xF); - *c++ = ((LARc[0] & 0x3) << 6) - | (LARc[1] & 0x3F); - *c++ = ((LARc[2] & 0x1F) << 3) - | ((LARc[3] >> 2) & 0x7); - *c++ = ((LARc[3] & 0x3) << 6) - | ((LARc[4] & 0xF) << 2) - | ((LARc[5] >> 2) & 0x3); - *c++ = ((LARc[5] & 0x3) << 6) - | ((LARc[6] & 0x7) << 3) - | (LARc[7] & 0x7); - - - *c++ = ((Nc[0] & 0x7F) << 1) - - - | ((bc[0] >> 1) & 0x1); - *c++ = ((bc[0] & 0x1) << 7) - - - | ((Mc[0] & 0x3) << 5) - - | ((xmaxc[0] >> 1) & 0x1F); - *c++ = ((xmaxc[0] & 0x1) << 7) - -#undef xmc -#define xmc (source + 12) - - | ((xmc[0] & 0x7) << 4) - | ((xmc[1] & 0x7) << 1) - | ((xmc[2] >> 2) & 0x1); - *c++ = ((xmc[2] & 0x3) << 6) - | ((xmc[3] & 0x7) << 3) - | (xmc[4] & 0x7); - *c++ = ((xmc[5] & 0x7) << 5) /* 10 */ - | ((xmc[6] & 0x7) << 2) - | ((xmc[7] >> 1) & 0x3); - *c++ = ((xmc[7] & 0x1) << 7) - | ((xmc[8] & 0x7) << 4) - | ((xmc[9] & 0x7) << 1) - | ((xmc[10] >> 2) & 0x1); - *c++ = ((xmc[10] & 0x3) << 6) - | ((xmc[11] & 0x7) << 3) - | (xmc[12] & 0x7); - - - *c++ = ((Nc[1] & 0x7F) << 1) - - - | ((bc[1] >> 1) & 0x1); - *c++ = ((bc[1] & 0x1) << 7) - - - | ((Mc[1] & 0x3) << 5) - - - | ((xmaxc[1] >> 1) & 0x1F); - *c++ = ((xmaxc[1] & 0x1) << 7) - -#undef xmc -#define xmc (source + 29 - 13) - - | ((xmc[13] & 0x7) << 4) - | ((xmc[14] & 0x7) << 1) - | ((xmc[15] >> 2) & 0x1); - *c++ = ((xmc[15] & 0x3) << 6) - | ((xmc[16] & 0x7) << 3) - | (xmc[17] & 0x7); - *c++ = ((xmc[18] & 0x7) << 5) - | ((xmc[19] & 0x7) << 2) - | ((xmc[20] >> 1) & 0x3); - *c++ = ((xmc[20] & 0x1) << 7) - | ((xmc[21] & 0x7) << 4) - | ((xmc[22] & 0x7) << 1) - | ((xmc[23] >> 2) & 0x1); - *c++ = ((xmc[23] & 0x3) << 6) - | ((xmc[24] & 0x7) << 3) - | (xmc[25] & 0x7); - - - *c++ = ((Nc[2] & 0x7F) << 1) /* 20 */ - - - | ((bc[2] >> 1) & 0x1); - *c++ = ((bc[2] & 0x1) << 7) - - - | ((Mc[2] & 0x3) << 5) - - - | ((xmaxc[2] >> 1) & 0x1F); - *c++ = ((xmaxc[2] & 0x1) << 7) - -#undef xmc -#define xmc (source + 46 - 26) - - | ((xmc[26] & 0x7) << 4) - | ((xmc[27] & 0x7) << 1) - | ((xmc[28] >> 2) & 0x1); - *c++ = ((xmc[28] & 0x3) << 6) - | ((xmc[29] & 0x7) << 3) - | (xmc[30] & 0x7); - *c++ = ((xmc[31] & 0x7) << 5) - | ((xmc[32] & 0x7) << 2) - | ((xmc[33] >> 1) & 0x3); - *c++ = ((xmc[33] & 0x1) << 7) - | ((xmc[34] & 0x7) << 4) - | ((xmc[35] & 0x7) << 1) - | ((xmc[36] >> 2) & 0x1); - *c++ = ((xmc[36] & 0x3) << 6) - | ((xmc[37] & 0x7) << 3) - | (xmc[38] & 0x7); - - - *c++ = ((Nc[3] & 0x7F) << 1) - - - | ((bc[3] >> 1) & 0x1); - *c++ = ((bc[3] & 0x1) << 7) - - - | ((Mc[3] & 0x3) << 5) - - - | ((xmaxc[3] >> 1) & 0x1F); - *c++ = ((xmaxc[3] & 0x1) << 7) - -#undef xmc -#define xmc (source + 63 - 39) - - | ((xmc[39] & 0x7) << 4) - | ((xmc[40] & 0x7) << 1) - | ((xmc[41] >> 2) & 0x1); - *c++ = ((xmc[41] & 0x3) << 6) /* 30 */ - | ((xmc[42] & 0x7) << 3) - | (xmc[43] & 0x7); - *c++ = ((xmc[44] & 0x7) << 5) - | ((xmc[45] & 0x7) << 2) - | ((xmc[46] >> 1) & 0x3); - *c++ = ((xmc[46] & 0x1) << 7) - | ((xmc[47] & 0x7) << 4) - | ((xmc[48] & 0x7) << 1) - | ((xmc[49] >> 2) & 0x1); - *c++ = ((xmc[49] & 0x3) << 6) - | ((xmc[50] & 0x7) << 3) - | (xmc[51] & 0x7); - } -} diff --git a/linphone/gsmlib/gsm_option.c b/linphone/gsmlib/gsm_option.c deleted file mode 100644 index 17a174a32..000000000 --- a/linphone/gsmlib/gsm_option.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/gsm_option.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -#include "private.h" - -#include "gsm.h" -#include "proto.h" - -int gsm_option P3((r, opt, val), gsm r, int opt, int * val) -{ - int result = -1; - - switch (opt) { - case GSM_OPT_LTP_CUT: -#ifdef LTP_CUT - result = r->ltp_cut; - if (val) r->ltp_cut = *val; -#endif - break; - - case GSM_OPT_VERBOSE: -#ifndef NDEBUG - result = r->verbose; - if (val) r->verbose = *val; -#endif - break; - - case GSM_OPT_FAST: - -#if defined(FAST) && defined(USE_FLOAT_MUL) - result = r->fast; - if (val) r->fast = !!*val; -#endif - break; - - case GSM_OPT_FRAME_CHAIN: - -#ifdef WAV49 - result = r->frame_chain; - if (val) r->frame_chain = *val; -#endif - break; - - case GSM_OPT_FRAME_INDEX: - -#ifdef WAV49 - result = r->frame_index; - if (val) r->frame_index = *val; -#endif - break; - - case GSM_OPT_WAV49: - -#ifdef WAV49 - result = r->wav_fmt; - if (val) r->wav_fmt = !!*val; -#endif - break; - - default: - break; - } - return result; -} diff --git a/linphone/gsmlib/gsm_print.c b/linphone/gsmlib/gsm_print.c deleted file mode 100644 index bdd467911..000000000 --- a/linphone/gsmlib/gsm_print.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/gsm_print.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -#include - -#include "private.h" - -#include "gsm.h" -#include "proto.h" - -int gsm_print P3((f, s, c), FILE * f, gsm s, gsm_byte * c) -{ - word LARc[8], Nc[4], Mc[4], bc[4], xmaxc[4], xmc[13*4]; - - /* GSM_MAGIC = (*c >> 4) & 0xF; */ - - if (((*c >> 4) & 0x0F) != GSM_MAGIC) return -1; - - LARc[0] = (*c++ & 0xF) << 2; /* 1 */ - LARc[0] |= (*c >> 6) & 0x3; - LARc[1] = *c++ & 0x3F; - LARc[2] = (*c >> 3) & 0x1F; - LARc[3] = (*c++ & 0x7) << 2; - LARc[3] |= (*c >> 6) & 0x3; - LARc[4] = (*c >> 2) & 0xF; - LARc[5] = (*c++ & 0x3) << 2; - LARc[5] |= (*c >> 6) & 0x3; - LARc[6] = (*c >> 3) & 0x7; - LARc[7] = *c++ & 0x7; - - - Nc[0] = (*c >> 1) & 0x7F; - bc[0] = (*c++ & 0x1) << 1; - bc[0] |= (*c >> 7) & 0x1; - Mc[0] = (*c >> 5) & 0x3; - xmaxc[0] = (*c++ & 0x1F) << 1; - xmaxc[0] |= (*c >> 7) & 0x1; - xmc[0] = (*c >> 4) & 0x7; - xmc[1] = (*c >> 1) & 0x7; - xmc[2] = (*c++ & 0x1) << 2; - xmc[2] |= (*c >> 6) & 0x3; - xmc[3] = (*c >> 3) & 0x7; - xmc[4] = *c++ & 0x7; - xmc[5] = (*c >> 5) & 0x7; - xmc[6] = (*c >> 2) & 0x7; - xmc[7] = (*c++ & 0x3) << 1; /* 10 */ - xmc[7] |= (*c >> 7) & 0x1; - xmc[8] = (*c >> 4) & 0x7; - xmc[9] = (*c >> 1) & 0x7; - xmc[10] = (*c++ & 0x1) << 2; - xmc[10] |= (*c >> 6) & 0x3; - xmc[11] = (*c >> 3) & 0x7; - xmc[12] = *c++ & 0x7; - - Nc[1] = (*c >> 1) & 0x7F; - bc[1] = (*c++ & 0x1) << 1; - bc[1] |= (*c >> 7) & 0x1; - Mc[1] = (*c >> 5) & 0x3; - xmaxc[1] = (*c++ & 0x1F) << 1; - xmaxc[1] |= (*c >> 7) & 0x1; - xmc[13] = (*c >> 4) & 0x7; - xmc[14] = (*c >> 1) & 0x7; - xmc[15] = (*c++ & 0x1) << 2; - xmc[15] |= (*c >> 6) & 0x3; - xmc[16] = (*c >> 3) & 0x7; - xmc[17] = *c++ & 0x7; - xmc[18] = (*c >> 5) & 0x7; - xmc[19] = (*c >> 2) & 0x7; - xmc[20] = (*c++ & 0x3) << 1; - xmc[20] |= (*c >> 7) & 0x1; - xmc[21] = (*c >> 4) & 0x7; - xmc[22] = (*c >> 1) & 0x7; - xmc[23] = (*c++ & 0x1) << 2; - xmc[23] |= (*c >> 6) & 0x3; - xmc[24] = (*c >> 3) & 0x7; - xmc[25] = *c++ & 0x7; - - - Nc[2] = (*c >> 1) & 0x7F; - bc[2] = (*c++ & 0x1) << 1; /* 20 */ - bc[2] |= (*c >> 7) & 0x1; - Mc[2] = (*c >> 5) & 0x3; - xmaxc[2] = (*c++ & 0x1F) << 1; - xmaxc[2] |= (*c >> 7) & 0x1; - xmc[26] = (*c >> 4) & 0x7; - xmc[27] = (*c >> 1) & 0x7; - xmc[28] = (*c++ & 0x1) << 2; - xmc[28] |= (*c >> 6) & 0x3; - xmc[29] = (*c >> 3) & 0x7; - xmc[30] = *c++ & 0x7; - xmc[31] = (*c >> 5) & 0x7; - xmc[32] = (*c >> 2) & 0x7; - xmc[33] = (*c++ & 0x3) << 1; - xmc[33] |= (*c >> 7) & 0x1; - xmc[34] = (*c >> 4) & 0x7; - xmc[35] = (*c >> 1) & 0x7; - xmc[36] = (*c++ & 0x1) << 2; - xmc[36] |= (*c >> 6) & 0x3; - xmc[37] = (*c >> 3) & 0x7; - xmc[38] = *c++ & 0x7; - - Nc[3] = (*c >> 1) & 0x7F; - bc[3] = (*c++ & 0x1) << 1; - bc[3] |= (*c >> 7) & 0x1; - Mc[3] = (*c >> 5) & 0x3; - xmaxc[3] = (*c++ & 0x1F) << 1; - xmaxc[3] |= (*c >> 7) & 0x1; - - xmc[39] = (*c >> 4) & 0x7; - xmc[40] = (*c >> 1) & 0x7; - xmc[41] = (*c++ & 0x1) << 2; - xmc[41] |= (*c >> 6) & 0x3; - xmc[42] = (*c >> 3) & 0x7; - xmc[43] = *c++ & 0x7; /* 30 */ - xmc[44] = (*c >> 5) & 0x7; - xmc[45] = (*c >> 2) & 0x7; - xmc[46] = (*c++ & 0x3) << 1; - xmc[46] |= (*c >> 7) & 0x1; - xmc[47] = (*c >> 4) & 0x7; - xmc[48] = (*c >> 1) & 0x7; - xmc[49] = (*c++ & 0x1) << 2; - xmc[49] |= (*c >> 6) & 0x3; - xmc[50] = (*c >> 3) & 0x7; - xmc[51] = *c & 0x7; /* 33 */ - - fprintf(f, - "LARc:\t%2.2d %2.2d %2.2d %2.2d %2.2d %2.2d %2.2d %2.2d\n", - LARc[0],LARc[1],LARc[2],LARc[3],LARc[4],LARc[5],LARc[6],LARc[7]); - - fprintf(f, "#1: Nc %4.4d bc %d Mc %d xmaxc %d\n", - Nc[0], bc[0], Mc[0], xmaxc[0]); - fprintf(f, -"\t%.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d\n", - xmc[0],xmc[1],xmc[2],xmc[3],xmc[4],xmc[5],xmc[6], - xmc[7],xmc[8],xmc[9],xmc[10],xmc[11],xmc[12] ); - - fprintf(f, "#2: Nc %4.4d bc %d Mc %d xmaxc %d\n", - Nc[1], bc[1], Mc[1], xmaxc[1]); - fprintf(f, -"\t%.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d\n", - xmc[13+0],xmc[13+1],xmc[13+2],xmc[13+3],xmc[13+4],xmc[13+5], - xmc[13+6], xmc[13+7],xmc[13+8],xmc[13+9],xmc[13+10],xmc[13+11], - xmc[13+12] ); - - fprintf(f, "#3: Nc %4.4d bc %d Mc %d xmaxc %d\n", - Nc[2], bc[2], Mc[2], xmaxc[2]); - fprintf(f, -"\t%.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d\n", - xmc[26+0],xmc[26+1],xmc[26+2],xmc[26+3],xmc[26+4],xmc[26+5], - xmc[26+6], xmc[26+7],xmc[26+8],xmc[26+9],xmc[26+10],xmc[26+11], - xmc[26+12] ); - - fprintf(f, "#4: Nc %4.4d bc %d Mc %d xmaxc %d\n", - Nc[3], bc[3], Mc[3], xmaxc[3]); - fprintf(f, -"\t%.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d %.2d\n", - xmc[39+0],xmc[39+1],xmc[39+2],xmc[39+3],xmc[39+4],xmc[39+5], - xmc[39+6], xmc[39+7],xmc[39+8],xmc[39+9],xmc[39+10],xmc[39+11], - xmc[39+12] ); - - return 0; -} diff --git a/linphone/gsmlib/gsm_wrapper.c b/linphone/gsmlib/gsm_wrapper.c deleted file mode 100644 index 1179080e3..000000000 --- a/linphone/gsmlib/gsm_wrapper.c +++ /dev/null @@ -1,67 +0,0 @@ -#include "gsm_wrapper.h" -#include - -/* the following code has been added by Simon MORLAT to make GSM interface compatible with linphone*/ - -/* the public codec_info structure*/ - -struct codec_info gsm_codec_info= -{ - "GSM", - 160*2, /* size of the uncompressed frame*/ - 33, /* size of compressed frame*/ - 13000, /* bit rate*/ - {{ - 8000 - }}, /* audio sampling freq*/ - GSMcodec_new, /* codec constructor*/ - 3, /* payload type*/ - "gsm/8000/1", - CODEC_AUDIO, /* type*/ - 0, /*usable, set later*/ - 1 /*usable for user, default value*/ -}; - - -Codec *GSMcodec_new() -{ - GSMCodec *obj; - - obj=(GSMCodec*)malloc(sizeof(GSMCodec));/* we should make a few check to see if this codec is a GSM...*/ - - obj->baseclass._getinfo=&wgsm_getinfo; - obj->baseclass._encode=&wgsm_encode; - obj->baseclass._decode=&wgsm_decode; - obj->baseclass._destroy=&wgsm_destroy; - obj->gsm_enc=gsm_create(); - obj->gsm_dec=gsm_create(); - return((Codec*)obj); -} - - -void wgsm_getinfo(Codec *codec,struct codec_info *info) -{ - if (info==NULL) return; - memcpy(info,&gsm_codec_info,sizeof(codec_info_t)); -} - -void wgsm_encode(Codec *codec,char *frame, char *data) -{ - GSMCodec *obj=(GSMCodec*)codec; /* we should make a few check to see if this codec is a GSM...*/ - gsm_encode(obj->gsm_enc,(gsm_signal*)frame,data); -} - -void wgsm_decode(Codec *codec,char *data, char *frame) -{ - GSMCodec *obj=(GSMCodec*)codec; /* we should make a few check to see if this codec is a GSM...*/ - gsm_decode(obj->gsm_dec,data,(gsm_signal*)frame); -} - -void wgsm_destroy(Codec *codec) -{ - GSMCodec *obj=(GSMCodec*)codec; /* we should make a few check to see if this codec is a GSM...*/ - gsm_destroy(obj->gsm_enc); - gsm_destroy(obj->gsm_dec); - free(obj); -} - diff --git a/linphone/gsmlib/gsm_wrapper.h b/linphone/gsmlib/gsm_wrapper.h deleted file mode 100644 index 8fc9d4f09..000000000 --- a/linphone/gsmlib/gsm_wrapper.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef GSM_WRAPPER -#define GSM_WRAPPER - -#include "../console/codec.h" -#include "gsm.h" - -/* the following code has been added by Simon MORLAT to make lpc10 interface compatible with linphone*/ - -/*Class definition*/ -typedef struct _GSMCodec -{ - Codec baseclass; /* Codec must be the first element of the structure in order to have the object mechanism to work*/ - gsm gsm_enc,gsm_dec; -} GSMCodec; - -/* this the constructor for derivate class GSMCodec*/ -Codec * GSMcodec_new(); - -extern struct codec_info gsm_codec_info; - -/* these are the overrides for the base class 's functions*/ -void wgsm_getinfo(Codec *codec, struct codec_info *info); -void wgsm_encode(Codec *codec, char *frame, char *data); -void wgsm_decode(Codec *codec, char *data, char *frame); -void wgsm_destroy(Codec *codec); - - -#endif diff --git a/linphone/gsmlib/gsmadd.c b/linphone/gsmlib/gsmadd.c deleted file mode 100644 index ddf1516f0..000000000 --- a/linphone/gsmlib/gsmadd.c +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/gsmadd.c,v 1.1 2005/03/09 17:26:29 smorlat Exp $ */ - -/* - * See private.h for the more commonly used macro versions. - */ - -#include -#include - -#include "private.h" -#include "gsm.h" -#include "proto.h" - -#define saturate(x) \ - ((x) < MIN_WORD ? MIN_WORD : (x) > MAX_WORD ? MAX_WORD: (x)) - -word gsm_add P2((a,b), word a, word b) -{ - longword sum = (longword)a + (longword)b; - return saturate(sum); -} - -word gsm_sub P2((a,b), word a, word b) -{ - longword diff = (longword)a - (longword)b; - return saturate(diff); -} - -word gsm_mult P2((a,b), word a, word b) -{ - if (a == MIN_WORD && b == MIN_WORD) return MAX_WORD; - else return SASR( (longword)a * (longword)b, 15 ); -} - -word gsm_mult_r P2((a,b), word a, word b) -{ - if (b == MIN_WORD && a == MIN_WORD) return MAX_WORD; - else { - longword prod = (longword)a * (longword)b + 16384; - prod >>= 15; - return prod & 0xFFFF; - } -} - -word gsm_abs P1((a), word a) -{ - return a < 0 ? (a == MIN_WORD ? MAX_WORD : -a) : a; -} - -longword gsm_L_mult P2((a,b),word a, word b) -{ - assert( a != MIN_WORD || b != MIN_WORD ); - return ((longword)a * (longword)b) << 1; -} - -longword gsm_L_add P2((a,b), longword a, longword b) -{ - if (a < 0) { - if (b >= 0) return a + b; - else { - ulongword A = (ulongword)-(a + 1) + (ulongword)-(b + 1); - return A >= MAX_LONGWORD ? MIN_LONGWORD :-(longword)A-2; - } - } - else if (b <= 0) return a + b; - else { - ulongword A = (ulongword)a + (ulongword)b; - return A > MAX_LONGWORD ? MAX_LONGWORD : A; - } -} - -longword gsm_L_sub P2((a,b), longword a, longword b) -{ - if (a >= 0) { - if (b >= 0) return a - b; - else { - /* a>=0, b<0 */ - - ulongword A = (ulongword)a + -(b + 1); - return A >= MAX_LONGWORD ? MAX_LONGWORD : (A + 1); - } - } - else if (b <= 0) return a - b; - else { - /* a<0, b>0 */ - - ulongword A = (ulongword)-(a + 1) + b; - return A >= MAX_LONGWORD ? MIN_LONGWORD : -(longword)A - 1; - } -} - -static unsigned char const bitoff[ 256 ] = { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -word gsm_norm P1((a), longword a ) -/* - * the number of left shifts needed to normalize the 32 bit - * variable L_var1 for positive values on the interval - * - * with minimum of - * minimum of 1073741824 (01000000000000000000000000000000) and - * maximum of 2147483647 (01111111111111111111111111111111) - * - * - * and for negative values on the interval with - * minimum of -2147483648 (-10000000000000000000000000000000) and - * maximum of -1073741824 ( -1000000000000000000000000000000). - * - * in order to normalize the result, the following - * operation must be done: L_norm_var1 = L_var1 << norm( L_var1 ); - * - * (That's 'ffs', only from the left, not the right..) - */ -{ - assert(a != 0); - - if (a < 0) { - if (a <= -1073741824) return 0; - a = ~a; - } - - return a & 0xffff0000 - ? ( a & 0xff000000 - ? -1 + bitoff[ 0xFF & (a >> 24) ] - : 7 + bitoff[ 0xFF & (a >> 16) ] ) - : ( a & 0xff00 - ? 15 + bitoff[ 0xFF & (a >> 8) ] - : 23 + bitoff[ 0xFF & a ] ); -} - -longword gsm_L_asl P2((a,n), longword a, int n) -{ - if (n >= 32) return 0; - if (n <= -32) return -(a < 0); - if (n < 0) return gsm_L_asr(a, -n); - return a << n; -} - -word gsm_asl P2((a,n), word a, int n) -{ - if (n >= 16) return 0; - if (n <= -16) return -(a < 0); - if (n < 0) return gsm_asr(a, -n); - return a << n; -} - -longword gsm_L_asr P2((a,n), longword a, int n) -{ - if (n >= 32) return -(a < 0); - if (n <= -32) return 0; - if (n < 0) return a << -n; - -# ifdef SASR - return a >> n; -# else - if (a >= 0) return a >> n; - else return -(longword)( -(ulongword)a >> n ); -# endif -} - -word gsm_asr P2((a,n), word a, int n) -{ - if (n >= 16) return -(a < 0); - if (n <= -16) return 0; - if (n < 0) return a << -n; - -# ifdef SASR - return a >> n; -# else - if (a >= 0) return a >> n; - else return -(word)( -(uword)a >> n ); -# endif -} - -/* - * (From p. 46, end of section 4.2.5) - * - * NOTE: The following lines gives [sic] one correct implementation - * of the div(num, denum) arithmetic operation. Compute div - * which is the integer division of num by denum: with denum - * >= num > 0 - */ - -word gsm_div P2((num,denum), word num, word denum) -{ - longword L_num = num; - longword L_denum = denum; - word div = 0; - int k = 15; - - /* The parameter num sometimes becomes zero. - * Although this is explicitly guarded against in 4.2.5, - * we assume that the result should then be zero as well. - */ - - /* assert(num != 0); */ - - assert(num >= 0 && denum >= num); - if (num == 0) - return 0; - - while (k--) { - div <<= 1; - L_num <<= 1; - - if (L_num >= L_denum) { - L_num -= L_denum; - div++; - } - } - - return div; -} diff --git a/linphone/gsmlib/long_term.c b/linphone/gsmlib/long_term.c deleted file mode 100644 index c5365920c..000000000 --- a/linphone/gsmlib/long_term.c +++ /dev/null @@ -1,949 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/long_term.c,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $ */ - -#include -#include - -#include "private.h" - -#include "gsm.h" -#include "proto.h" - -/* - * 4.2.11 .. 4.2.12 LONG TERM PREDICTOR (LTP) SECTION - */ - - -/* - * This module computes the LTP gain (bc) and the LTP lag (Nc) - * for the long term analysis filter. This is done by calculating a - * maximum of the cross-correlation function between the current - * sub-segment short term residual signal d[0..39] (output of - * the short term analysis filter; for simplification the index - * of this array begins at 0 and ends at 39 for each sub-segment of the - * RPE-LTP analysis) and the previous reconstructed short term - * residual signal dp[ -120 .. -1 ]. A dynamic scaling must be - * performed to avoid overflow. - */ - - /* The next procedure exists in six versions. First two integer - * version (if USE_FLOAT_MUL is not defined); then four floating - * point versions, twice with proper scaling (USE_FLOAT_MUL defined), - * once without (USE_FLOAT_MUL and FAST defined, and fast run-time - * option used). Every pair has first a Cut version (see the -C - * option to toast or the LTP_CUT option to gsm_option()), then the - * uncut one. (For a detailed explanation of why this is altogether - * a bad idea, see Henry Spencer and Geoff Collyer, ``#ifdef Considered - * Harmful''.) - */ - -#ifndef USE_FLOAT_MUL - -#ifdef LTP_CUT - -static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), - - struct gsm_state * st, - - register word * d, /* [0..39] IN */ - register word * dp, /* [-120..-1] IN */ - word * bc_out, /* OUT */ - word * Nc_out /* OUT */ -) -{ - register int k, lambda; - word Nc, bc; - word wt[40]; - - longword L_result; - longword L_max, L_power; - word R, S, dmax, scal, best_k; - word ltp_cut; - - register word temp, wt_k; - - /* Search of the optimum scaling of d[0..39]. - */ - dmax = 0; - for (k = 0; k <= 39; k++) { - temp = d[k]; - temp = GSM_ABS( temp ); - if (temp > dmax) { - dmax = temp; - best_k = k; - } - } - temp = 0; - if (dmax == 0) scal = 0; - else { - assert(dmax > 0); - temp = gsm_norm( (longword)dmax << 16 ); - } - if (temp > 6) scal = 0; - else scal = 6 - temp; - assert(scal >= 0); - - /* Search for the maximum cross-correlation and coding of the LTP lag - */ - L_max = 0; - Nc = 40; /* index for the maximum cross-correlation */ - wt_k = SASR(d[best_k], scal); - - for (lambda = 40; lambda <= 120; lambda++) { - L_result = (longword)wt_k * dp[best_k - lambda]; - if (L_result > L_max) { - Nc = lambda; - L_max = L_result; - } - } - *Nc_out = Nc; - L_max <<= 1; - - /* Rescaling of L_max - */ - assert(scal <= 100 && scal >= -100); - L_max = L_max >> (6 - scal); /* sub(6, scal) */ - - assert( Nc <= 120 && Nc >= 40); - - /* Compute the power of the reconstructed short term residual - * signal dp[..] - */ - L_power = 0; - for (k = 0; k <= 39; k++) { - - register longword L_temp; - - L_temp = SASR( dp[k - Nc], 3 ); - L_power += L_temp * L_temp; - } - L_power <<= 1; /* from L_MULT */ - - /* Normalization of L_max and L_power - */ - - if (L_max <= 0) { - *bc_out = 0; - return; - } - if (L_max >= L_power) { - *bc_out = 3; - return; - } - - temp = gsm_norm( L_power ); - - R = SASR( L_max << temp, 16 ); - S = SASR( L_power << temp, 16 ); - - /* Coding of the LTP gain - */ - - /* Table 4.3a must be used to obtain the level DLB[i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break; - *bc_out = bc; -} - -#endif /* LTP_CUT */ - -static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), - register word * d, /* [0..39] IN */ - register word * dp, /* [-120..-1] IN */ - word * bc_out, /* OUT */ - word * Nc_out /* OUT */ -) -{ - register int k, lambda; - word Nc, bc; - word wt[40]; - - longword L_max, L_power; - word R, S, dmax, scal; - register word temp; - - /* Search of the optimum scaling of d[0..39]. - */ - dmax = 0; - - for (k = 0; k <= 39; k++) { - temp = d[k]; - temp = GSM_ABS( temp ); - if (temp > dmax) dmax = temp; - } - - temp = 0; - if (dmax == 0) scal = 0; - else { - assert(dmax > 0); - temp = gsm_norm( (longword)dmax << 16 ); - } - - if (temp > 6) scal = 0; - else scal = 6 - temp; - - assert(scal >= 0); - - /* Initialization of a working array wt - */ - - for (k = 0; k <= 39; k++) wt[k] = SASR( d[k], scal ); - - /* Search for the maximum cross-correlation and coding of the LTP lag - */ - L_max = 0; - Nc = 40; /* index for the maximum cross-correlation */ - - for (lambda = 40; lambda <= 120; lambda++) { - -# undef STEP -# define STEP(k) (longword)wt[k] * dp[k - lambda] - - register longword L_result; - - L_result = STEP(0) ; L_result += STEP(1) ; - L_result += STEP(2) ; L_result += STEP(3) ; - L_result += STEP(4) ; L_result += STEP(5) ; - L_result += STEP(6) ; L_result += STEP(7) ; - L_result += STEP(8) ; L_result += STEP(9) ; - L_result += STEP(10) ; L_result += STEP(11) ; - L_result += STEP(12) ; L_result += STEP(13) ; - L_result += STEP(14) ; L_result += STEP(15) ; - L_result += STEP(16) ; L_result += STEP(17) ; - L_result += STEP(18) ; L_result += STEP(19) ; - L_result += STEP(20) ; L_result += STEP(21) ; - L_result += STEP(22) ; L_result += STEP(23) ; - L_result += STEP(24) ; L_result += STEP(25) ; - L_result += STEP(26) ; L_result += STEP(27) ; - L_result += STEP(28) ; L_result += STEP(29) ; - L_result += STEP(30) ; L_result += STEP(31) ; - L_result += STEP(32) ; L_result += STEP(33) ; - L_result += STEP(34) ; L_result += STEP(35) ; - L_result += STEP(36) ; L_result += STEP(37) ; - L_result += STEP(38) ; L_result += STEP(39) ; - - if (L_result > L_max) { - - Nc = lambda; - L_max = L_result; - } - } - - *Nc_out = Nc; - - L_max <<= 1; - - /* Rescaling of L_max - */ - assert(scal <= 100 && scal >= -100); - L_max = L_max >> (6 - scal); /* sub(6, scal) */ - - assert( Nc <= 120 && Nc >= 40); - - /* Compute the power of the reconstructed short term residual - * signal dp[..] - */ - L_power = 0; - for (k = 0; k <= 39; k++) { - - register longword L_temp; - - L_temp = SASR( dp[k - Nc], 3 ); - L_power += L_temp * L_temp; - } - L_power <<= 1; /* from L_MULT */ - - /* Normalization of L_max and L_power - */ - - if (L_max <= 0) { - *bc_out = 0; - return; - } - if (L_max >= L_power) { - *bc_out = 3; - return; - } - - temp = gsm_norm( L_power ); - - R = SASR( L_max << temp, 16 ); - S = SASR( L_power << temp, 16 ); - - /* Coding of the LTP gain - */ - - /* Table 4.3a must be used to obtain the level DLB[i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break; - *bc_out = bc; -} - -#else /* USE_FLOAT_MUL */ - -#ifdef LTP_CUT - -static void Cut_Calculation_of_the_LTP_parameters P5((st, d,dp,bc_out,Nc_out), - struct gsm_state * st, /* IN */ - register word * d, /* [0..39] IN */ - register word * dp, /* [-120..-1] IN */ - word * bc_out, /* OUT */ - word * Nc_out /* OUT */ -) -{ - register int k, lambda; - word Nc, bc; - word ltp_cut; - - float wt_float[40]; - float dp_float_base[120], * dp_float = dp_float_base + 120; - - longword L_max, L_power; - word R, S, dmax, scal; - register word temp; - - /* Search of the optimum scaling of d[0..39]. - */ - dmax = 0; - - for (k = 0; k <= 39; k++) { - temp = d[k]; - temp = GSM_ABS( temp ); - if (temp > dmax) dmax = temp; - } - - temp = 0; - if (dmax == 0) scal = 0; - else { - assert(dmax > 0); - temp = gsm_norm( (longword)dmax << 16 ); - } - - if (temp > 6) scal = 0; - else scal = 6 - temp; - - assert(scal >= 0); - ltp_cut = (longword)SASR(dmax, scal) * st->ltp_cut / 100; - - - /* Initialization of a working array wt - */ - - for (k = 0; k < 40; k++) { - register word w = SASR( d[k], scal ); - if (w < 0 ? w > -ltp_cut : w < ltp_cut) { - wt_float[k] = 0.0; - } - else { - wt_float[k] = w; - } - } - for (k = -120; k < 0; k++) dp_float[k] = dp[k]; - - /* Search for the maximum cross-correlation and coding of the LTP lag - */ - L_max = 0; - Nc = 40; /* index for the maximum cross-correlation */ - - for (lambda = 40; lambda <= 120; lambda += 9) { - - /* Calculate L_result for l = lambda .. lambda + 9. - */ - register float *lp = dp_float - lambda; - - register float W; - register float a = lp[-8], b = lp[-7], c = lp[-6], - d = lp[-5], e = lp[-4], f = lp[-3], - g = lp[-2], h = lp[-1]; - register float E; - register float S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0, - S5 = 0, S6 = 0, S7 = 0, S8 = 0; - -# undef STEP -# define STEP(K, a, b, c, d, e, f, g, h) \ - if ((W = wt_float[K]) != 0.0) { \ - E = W * a; S8 += E; \ - E = W * b; S7 += E; \ - E = W * c; S6 += E; \ - E = W * d; S5 += E; \ - E = W * e; S4 += E; \ - E = W * f; S3 += E; \ - E = W * g; S2 += E; \ - E = W * h; S1 += E; \ - a = lp[K]; \ - E = W * a; S0 += E; } else (a = lp[K]) - -# define STEP_A(K) STEP(K, a, b, c, d, e, f, g, h) -# define STEP_B(K) STEP(K, b, c, d, e, f, g, h, a) -# define STEP_C(K) STEP(K, c, d, e, f, g, h, a, b) -# define STEP_D(K) STEP(K, d, e, f, g, h, a, b, c) -# define STEP_E(K) STEP(K, e, f, g, h, a, b, c, d) -# define STEP_F(K) STEP(K, f, g, h, a, b, c, d, e) -# define STEP_G(K) STEP(K, g, h, a, b, c, d, e, f) -# define STEP_H(K) STEP(K, h, a, b, c, d, e, f, g) - - STEP_A( 0); STEP_B( 1); STEP_C( 2); STEP_D( 3); - STEP_E( 4); STEP_F( 5); STEP_G( 6); STEP_H( 7); - - STEP_A( 8); STEP_B( 9); STEP_C(10); STEP_D(11); - STEP_E(12); STEP_F(13); STEP_G(14); STEP_H(15); - - STEP_A(16); STEP_B(17); STEP_C(18); STEP_D(19); - STEP_E(20); STEP_F(21); STEP_G(22); STEP_H(23); - - STEP_A(24); STEP_B(25); STEP_C(26); STEP_D(27); - STEP_E(28); STEP_F(29); STEP_G(30); STEP_H(31); - - STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35); - STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39); - - if (S0 > L_max) { L_max = S0; Nc = lambda; } - if (S1 > L_max) { L_max = S1; Nc = lambda + 1; } - if (S2 > L_max) { L_max = S2; Nc = lambda + 2; } - if (S3 > L_max) { L_max = S3; Nc = lambda + 3; } - if (S4 > L_max) { L_max = S4; Nc = lambda + 4; } - if (S5 > L_max) { L_max = S5; Nc = lambda + 5; } - if (S6 > L_max) { L_max = S6; Nc = lambda + 6; } - if (S7 > L_max) { L_max = S7; Nc = lambda + 7; } - if (S8 > L_max) { L_max = S8; Nc = lambda + 8; } - - } - *Nc_out = Nc; - - L_max <<= 1; - - /* Rescaling of L_max - */ - assert(scal <= 100 && scal >= -100); - L_max = L_max >> (6 - scal); /* sub(6, scal) */ - - assert( Nc <= 120 && Nc >= 40); - - /* Compute the power of the reconstructed short term residual - * signal dp[..] - */ - L_power = 0; - for (k = 0; k <= 39; k++) { - - register longword L_temp; - - L_temp = SASR( dp[k - Nc], 3 ); - L_power += L_temp * L_temp; - } - L_power <<= 1; /* from L_MULT */ - - /* Normalization of L_max and L_power - */ - - if (L_max <= 0) { - *bc_out = 0; - return; - } - if (L_max >= L_power) { - *bc_out = 3; - return; - } - - temp = gsm_norm( L_power ); - - R = SASR( L_max << temp, 16 ); - S = SASR( L_power << temp, 16 ); - - /* Coding of the LTP gain - */ - - /* Table 4.3a must be used to obtain the level DLB[i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break; - *bc_out = bc; -} - -#endif /* LTP_CUT */ - -static void Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), - register word * d, /* [0..39] IN */ - register word * dp, /* [-120..-1] IN */ - word * bc_out, /* OUT */ - word * Nc_out /* OUT */ -) -{ - register int k, lambda; - word Nc, bc; - - float wt_float[40]; - float dp_float_base[120], * dp_float = dp_float_base + 120; - - longword L_max, L_power; - word R, S, dmax, scal; - register word temp; - - /* Search of the optimum scaling of d[0..39]. - */ - dmax = 0; - - for (k = 0; k <= 39; k++) { - temp = d[k]; - temp = GSM_ABS( temp ); - if (temp > dmax) dmax = temp; - } - - temp = 0; - if (dmax == 0) scal = 0; - else { - assert(dmax > 0); - temp = gsm_norm( (longword)dmax << 16 ); - } - - if (temp > 6) scal = 0; - else scal = 6 - temp; - - assert(scal >= 0); - - /* Initialization of a working array wt - */ - - for (k = 0; k < 40; k++) wt_float[k] = SASR( d[k], scal ); - for (k = -120; k < 0; k++) dp_float[k] = dp[k]; - - /* Search for the maximum cross-correlation and coding of the LTP lag - */ - L_max = 0; - Nc = 40; /* index for the maximum cross-correlation */ - - for (lambda = 40; lambda <= 120; lambda += 9) { - - /* Calculate L_result for l = lambda .. lambda + 9. - */ - register float *lp = dp_float - lambda; - - register float W; - register float a = lp[-8], b = lp[-7], c = lp[-6], - d = lp[-5], e = lp[-4], f = lp[-3], - g = lp[-2], h = lp[-1]; - register float E; - register float S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0, - S5 = 0, S6 = 0, S7 = 0, S8 = 0; - -# undef STEP -# define STEP(K, a, b, c, d, e, f, g, h) \ - W = wt_float[K]; \ - E = W * a; S8 += E; \ - E = W * b; S7 += E; \ - E = W * c; S6 += E; \ - E = W * d; S5 += E; \ - E = W * e; S4 += E; \ - E = W * f; S3 += E; \ - E = W * g; S2 += E; \ - E = W * h; S1 += E; \ - a = lp[K]; \ - E = W * a; S0 += E - -# define STEP_A(K) STEP(K, a, b, c, d, e, f, g, h) -# define STEP_B(K) STEP(K, b, c, d, e, f, g, h, a) -# define STEP_C(K) STEP(K, c, d, e, f, g, h, a, b) -# define STEP_D(K) STEP(K, d, e, f, g, h, a, b, c) -# define STEP_E(K) STEP(K, e, f, g, h, a, b, c, d) -# define STEP_F(K) STEP(K, f, g, h, a, b, c, d, e) -# define STEP_G(K) STEP(K, g, h, a, b, c, d, e, f) -# define STEP_H(K) STEP(K, h, a, b, c, d, e, f, g) - - STEP_A( 0); STEP_B( 1); STEP_C( 2); STEP_D( 3); - STEP_E( 4); STEP_F( 5); STEP_G( 6); STEP_H( 7); - - STEP_A( 8); STEP_B( 9); STEP_C(10); STEP_D(11); - STEP_E(12); STEP_F(13); STEP_G(14); STEP_H(15); - - STEP_A(16); STEP_B(17); STEP_C(18); STEP_D(19); - STEP_E(20); STEP_F(21); STEP_G(22); STEP_H(23); - - STEP_A(24); STEP_B(25); STEP_C(26); STEP_D(27); - STEP_E(28); STEP_F(29); STEP_G(30); STEP_H(31); - - STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35); - STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39); - - if (S0 > L_max) { L_max = S0; Nc = lambda; } - if (S1 > L_max) { L_max = S1; Nc = lambda + 1; } - if (S2 > L_max) { L_max = S2; Nc = lambda + 2; } - if (S3 > L_max) { L_max = S3; Nc = lambda + 3; } - if (S4 > L_max) { L_max = S4; Nc = lambda + 4; } - if (S5 > L_max) { L_max = S5; Nc = lambda + 5; } - if (S6 > L_max) { L_max = S6; Nc = lambda + 6; } - if (S7 > L_max) { L_max = S7; Nc = lambda + 7; } - if (S8 > L_max) { L_max = S8; Nc = lambda + 8; } - } - *Nc_out = Nc; - - L_max <<= 1; - - /* Rescaling of L_max - */ - assert(scal <= 100 && scal >= -100); - L_max = L_max >> (6 - scal); /* sub(6, scal) */ - - assert( Nc <= 120 && Nc >= 40); - - /* Compute the power of the reconstructed short term residual - * signal dp[..] - */ - L_power = 0; - for (k = 0; k <= 39; k++) { - - register longword L_temp; - - L_temp = SASR( dp[k - Nc], 3 ); - L_power += L_temp * L_temp; - } - L_power <<= 1; /* from L_MULT */ - - /* Normalization of L_max and L_power - */ - - if (L_max <= 0) { - *bc_out = 0; - return; - } - if (L_max >= L_power) { - *bc_out = 3; - return; - } - - temp = gsm_norm( L_power ); - - R = SASR( L_max << temp, 16 ); - S = SASR( L_power << temp, 16 ); - - /* Coding of the LTP gain - */ - - /* Table 4.3a must be used to obtain the level DLB[i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - for (bc = 0; bc <= 2; bc++) if (R <= gsm_mult(S, gsm_DLB[bc])) break; - *bc_out = bc; -} - -#ifdef FAST -#ifdef LTP_CUT - -static void Cut_Fast_Calculation_of_the_LTP_parameters P5((st, - d,dp,bc_out,Nc_out), - struct gsm_state * st, /* IN */ - register word * d, /* [0..39] IN */ - register word * dp, /* [-120..-1] IN */ - word * bc_out, /* OUT */ - word * Nc_out /* OUT */ -) -{ - register int k, lambda; - register float wt_float; - word Nc, bc; - word wt_max, best_k, ltp_cut; - - float dp_float_base[120], * dp_float = dp_float_base + 120; - - register float L_result, L_max, L_power; - - wt_max = 0; - - for (k = 0; k < 40; ++k) { - if ( d[k] > wt_max) wt_max = d[best_k = k]; - else if (-d[k] > wt_max) wt_max = -d[best_k = k]; - } - - assert(wt_max >= 0); - wt_float = (float)wt_max; - - for (k = -120; k < 0; ++k) dp_float[k] = (float)dp[k]; - - /* Search for the maximum cross-correlation and coding of the LTP lag - */ - L_max = 0; - Nc = 40; /* index for the maximum cross-correlation */ - - for (lambda = 40; lambda <= 120; lambda++) { - L_result = wt_float * dp_float[best_k - lambda]; - if (L_result > L_max) { - Nc = lambda; - L_max = L_result; - } - } - - *Nc_out = Nc; - if (L_max <= 0.) { - *bc_out = 0; - return; - } - - /* Compute the power of the reconstructed short term residual - * signal dp[..] - */ - dp_float -= Nc; - L_power = 0; - for (k = 0; k < 40; ++k) { - register float f = dp_float[k]; - L_power += f * f; - } - - if (L_max >= L_power) { - *bc_out = 3; - return; - } - - /* Coding of the LTP gain - * Table 4.3a must be used to obtain the level DLB[i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - lambda = L_max / L_power * 32768.; - for (bc = 0; bc <= 2; ++bc) if (lambda <= gsm_DLB[bc]) break; - *bc_out = bc; -} - -#endif /* LTP_CUT */ - -static void Fast_Calculation_of_the_LTP_parameters P4((d,dp,bc_out,Nc_out), - register word * d, /* [0..39] IN */ - register word * dp, /* [-120..-1] IN */ - word * bc_out, /* OUT */ - word * Nc_out /* OUT */ -) -{ - register int k, lambda; - word Nc, bc; - - float wt_float[40]; - float dp_float_base[120], * dp_float = dp_float_base + 120; - - register float L_max, L_power; - - for (k = 0; k < 40; ++k) wt_float[k] = (float)d[k]; - for (k = -120; k < 0; ++k) dp_float[k] = (float)dp[k]; - - /* Search for the maximum cross-correlation and coding of the LTP lag - */ - L_max = 0; - Nc = 40; /* index for the maximum cross-correlation */ - - for (lambda = 40; lambda <= 120; lambda += 9) { - - /* Calculate L_result for l = lambda .. lambda + 9. - */ - register float *lp = dp_float - lambda; - - register float W; - register float a = lp[-8], b = lp[-7], c = lp[-6], - d = lp[-5], e = lp[-4], f = lp[-3], - g = lp[-2], h = lp[-1]; - register float E; - register float S0 = 0, S1 = 0, S2 = 0, S3 = 0, S4 = 0, - S5 = 0, S6 = 0, S7 = 0, S8 = 0; - -# undef STEP -# define STEP(K, a, b, c, d, e, f, g, h) \ - W = wt_float[K]; \ - E = W * a; S8 += E; \ - E = W * b; S7 += E; \ - E = W * c; S6 += E; \ - E = W * d; S5 += E; \ - E = W * e; S4 += E; \ - E = W * f; S3 += E; \ - E = W * g; S2 += E; \ - E = W * h; S1 += E; \ - a = lp[K]; \ - E = W * a; S0 += E - -# define STEP_A(K) STEP(K, a, b, c, d, e, f, g, h) -# define STEP_B(K) STEP(K, b, c, d, e, f, g, h, a) -# define STEP_C(K) STEP(K, c, d, e, f, g, h, a, b) -# define STEP_D(K) STEP(K, d, e, f, g, h, a, b, c) -# define STEP_E(K) STEP(K, e, f, g, h, a, b, c, d) -# define STEP_F(K) STEP(K, f, g, h, a, b, c, d, e) -# define STEP_G(K) STEP(K, g, h, a, b, c, d, e, f) -# define STEP_H(K) STEP(K, h, a, b, c, d, e, f, g) - - STEP_A( 0); STEP_B( 1); STEP_C( 2); STEP_D( 3); - STEP_E( 4); STEP_F( 5); STEP_G( 6); STEP_H( 7); - - STEP_A( 8); STEP_B( 9); STEP_C(10); STEP_D(11); - STEP_E(12); STEP_F(13); STEP_G(14); STEP_H(15); - - STEP_A(16); STEP_B(17); STEP_C(18); STEP_D(19); - STEP_E(20); STEP_F(21); STEP_G(22); STEP_H(23); - - STEP_A(24); STEP_B(25); STEP_C(26); STEP_D(27); - STEP_E(28); STEP_F(29); STEP_G(30); STEP_H(31); - - STEP_A(32); STEP_B(33); STEP_C(34); STEP_D(35); - STEP_E(36); STEP_F(37); STEP_G(38); STEP_H(39); - - if (S0 > L_max) { L_max = S0; Nc = lambda; } - if (S1 > L_max) { L_max = S1; Nc = lambda + 1; } - if (S2 > L_max) { L_max = S2; Nc = lambda + 2; } - if (S3 > L_max) { L_max = S3; Nc = lambda + 3; } - if (S4 > L_max) { L_max = S4; Nc = lambda + 4; } - if (S5 > L_max) { L_max = S5; Nc = lambda + 5; } - if (S6 > L_max) { L_max = S6; Nc = lambda + 6; } - if (S7 > L_max) { L_max = S7; Nc = lambda + 7; } - if (S8 > L_max) { L_max = S8; Nc = lambda + 8; } - } - *Nc_out = Nc; - - if (L_max <= 0.) { - *bc_out = 0; - return; - } - - /* Compute the power of the reconstructed short term residual - * signal dp[..] - */ - dp_float -= Nc; - L_power = 0; - for (k = 0; k < 40; ++k) { - register float f = dp_float[k]; - L_power += f * f; - } - - if (L_max >= L_power) { - *bc_out = 3; - return; - } - - /* Coding of the LTP gain - * Table 4.3a must be used to obtain the level DLB[i] for the - * quantization of the LTP gain b to get the coded version bc. - */ - lambda = L_max / L_power * 32768.; - for (bc = 0; bc <= 2; ++bc) if (lambda <= gsm_DLB[bc]) break; - *bc_out = bc; -} - -#endif /* FAST */ -#endif /* USE_FLOAT_MUL */ - - -/* 4.2.12 */ - -static void Long_term_analysis_filtering P6((bc,Nc,dp,d,dpp,e), - word bc, /* IN */ - word Nc, /* IN */ - register word * dp, /* previous d [-120..-1] IN */ - register word * d, /* d [0..39] IN */ - register word * dpp, /* estimate [0..39] OUT */ - register word * e /* long term res. signal [0..39] OUT */ -) -/* - * In this part, we have to decode the bc parameter to compute - * the samples of the estimate dpp[0..39]. The decoding of bc needs the - * use of table 4.3b. The long term residual signal e[0..39] - * is then calculated to be fed to the RPE encoding section. - */ -{ - register int k; - register longword ltmp; - -# undef STEP -# define STEP(BP) \ - for (k = 0; k <= 39; k++) { \ - dpp[k] = GSM_MULT_R( BP, dp[k - Nc]); \ - e[k] = GSM_SUB( d[k], dpp[k] ); \ - } - - switch (bc) { - case 0: STEP( 3277 ); break; - case 1: STEP( 11469 ); break; - case 2: STEP( 21299 ); break; - case 3: STEP( 32767 ); break; - } -} - -void Gsm_Long_Term_Predictor P7((S,d,dp,e,dpp,Nc,bc), /* 4x for 160 samples */ - - struct gsm_state * S, - - word * d, /* [0..39] residual signal IN */ - word * dp, /* [-120..-1] d' IN */ - - word * e, /* [0..39] OUT */ - word * dpp, /* [0..39] OUT */ - word * Nc, /* correlation lag OUT */ - word * bc /* gain factor OUT */ -) -{ - assert( d ); assert( dp ); assert( e ); - assert( dpp); assert( Nc ); assert( bc ); - -#if defined(FAST) && defined(USE_FLOAT_MUL) - if (S->fast) -#if defined (LTP_CUT) - if (S->ltp_cut) - Cut_Fast_Calculation_of_the_LTP_parameters(S, - d, dp, bc, Nc); - else -#endif /* LTP_CUT */ - Fast_Calculation_of_the_LTP_parameters(d, dp, bc, Nc ); - else -#endif /* FAST & USE_FLOAT_MUL */ -#ifdef LTP_CUT - if (S->ltp_cut) - Cut_Calculation_of_the_LTP_parameters(S, d, dp, bc, Nc); - else -#endif - Calculation_of_the_LTP_parameters(d, dp, bc, Nc); - - Long_term_analysis_filtering( *bc, *Nc, dp, d, dpp, e ); -} - -/* 4.3.2 */ -void Gsm_Long_Term_Synthesis_Filtering P5((S,Ncr,bcr,erp,drp), - struct gsm_state * S, - - word Ncr, - word bcr, - register word * erp, /* [0..39] IN */ - register word * drp /* [-120..-1] IN, [-120..40] OUT */ -) -/* - * This procedure uses the bcr and Ncr parameter to realize the - * long term synthesis filtering. The decoding of bcr needs - * table 4.3b. - */ -{ - register longword ltmp; /* for ADD */ - register int k; - word brp, drpp, Nr; - - /* Check the limits of Nr. - */ - Nr = Ncr < 40 || Ncr > 120 ? S->nrp : Ncr; - S->nrp = Nr; - assert(Nr >= 40 && Nr <= 120); - - /* Decoding of the LTP gain bcr - */ - brp = gsm_QLB[ bcr ]; - - /* Computation of the reconstructed short term residual - * signal drp[0..39] - */ - assert(brp != MIN_WORD); - - for (k = 0; k <= 39; k++) { - drpp = GSM_MULT_R( brp, drp[ k - Nr ] ); - drp[k] = GSM_ADD( erp[k], drpp ); - } - - /* - * Update of the reconstructed short term residual signal - * drp[ -1..-120 ] - */ - - for (k = 0; k <= 119; k++) drp[ -120 + k ] = drp[ -80 + k ]; -} diff --git a/linphone/gsmlib/lpc.c b/linphone/gsmlib/lpc.c deleted file mode 100644 index 5fa53ac12..000000000 --- a/linphone/gsmlib/lpc.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/lpc.c,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $ */ - -#include -#include - -#include "private.h" - -#include "gsm.h" -#include "proto.h" - -#undef P - -/* - * 4.2.4 .. 4.2.7 LPC ANALYSIS SECTION - */ - -/* 4.2.4 */ - - -static void Autocorrelation P2((s, L_ACF), - word * s, /* [0..159] IN/OUT */ - longword * L_ACF) /* [0..8] OUT */ -/* - * The goal is to compute the array L_ACF[k]. The signal s[i] must - * be scaled in order to avoid an overflow situation. - */ -{ - register int k, i; - - word temp, smax, scalauto; - -#ifdef USE_FLOAT_MUL - float float_s[160]; -#endif - - /* Dynamic scaling of the array s[0..159] - */ - - /* Search for the maximum. - */ - smax = 0; - for (k = 0; k <= 159; k++) { - temp = GSM_ABS( s[k] ); - if (temp > smax) smax = temp; - } - - /* Computation of the scaling factor. - */ - if (smax == 0) scalauto = 0; - else { - assert(smax > 0); - scalauto = 4 - gsm_norm( (longword)smax << 16 );/* sub(4,..) */ - } - - /* Scaling of the array s[0...159] - */ - - if (scalauto > 0) { - -# ifdef USE_FLOAT_MUL -# define SCALE(n) \ - case n: for (k = 0; k <= 159; k++) \ - float_s[k] = (float) \ - (s[k] = GSM_MULT_R(s[k], 16384 >> (n-1)));\ - break; -# else -# define SCALE(n) \ - case n: for (k = 0; k <= 159; k++) \ - s[k] = GSM_MULT_R( s[k], 16384 >> (n-1) );\ - break; -# endif /* USE_FLOAT_MUL */ - - switch (scalauto) { - SCALE(1) - SCALE(2) - SCALE(3) - SCALE(4) - } -# undef SCALE - } -# ifdef USE_FLOAT_MUL - else for (k = 0; k <= 159; k++) float_s[k] = (float) s[k]; -# endif - - /* Compute the L_ACF[..]. - */ - { -# ifdef USE_FLOAT_MUL - register float * sp = float_s; - register float sl = *sp; - -# define STEP(k) L_ACF[k] += (longword)(sl * sp[ -(k) ]); -# else - word * sp = s; - word sl = *sp; - -# define STEP(k) L_ACF[k] += ((longword)sl * sp[ -(k) ]); -# endif - -# define NEXTI sl = *++sp - - - for (k = 9; k--; L_ACF[k] = 0) ; - - STEP (0); - NEXTI; - STEP(0); STEP(1); - NEXTI; - STEP(0); STEP(1); STEP(2); - NEXTI; - STEP(0); STEP(1); STEP(2); STEP(3); - NEXTI; - STEP(0); STEP(1); STEP(2); STEP(3); STEP(4); - NEXTI; - STEP(0); STEP(1); STEP(2); STEP(3); STEP(4); STEP(5); - NEXTI; - STEP(0); STEP(1); STEP(2); STEP(3); STEP(4); STEP(5); STEP(6); - NEXTI; - STEP(0); STEP(1); STEP(2); STEP(3); STEP(4); STEP(5); STEP(6); STEP(7); - - for (i = 8; i <= 159; i++) { - - NEXTI; - - STEP(0); - STEP(1); STEP(2); STEP(3); STEP(4); - STEP(5); STEP(6); STEP(7); STEP(8); - } - - for (k = 9; k--; L_ACF[k] <<= 1) ; - - } - /* Rescaling of the array s[0..159] - */ - if (scalauto > 0) { - assert(scalauto <= 4); - for (k = 160; k--; *s++ <<= scalauto) ; - } -} - -#if defined(USE_FLOAT_MUL) && defined(FAST) - -static void Fast_Autocorrelation P2((s, L_ACF), - word * s, /* [0..159] IN/OUT */ - longword * L_ACF) /* [0..8] OUT */ -{ - register int k, i; - float f_L_ACF[9]; - float scale; - - float s_f[160]; - register float *sf = s_f; - - for (i = 0; i < 160; ++i) sf[i] = s[i]; - for (k = 0; k <= 8; k++) { - register float L_temp2 = 0; - register float *sfl = sf - k; - for (i = k; i < 160; ++i) L_temp2 += sf[i] * sfl[i]; - f_L_ACF[k] = L_temp2; - } - scale = MAX_LONGWORD / f_L_ACF[0]; - - for (k = 0; k <= 8; k++) { - L_ACF[k] = f_L_ACF[k] * scale; - } -} -#endif /* defined (USE_FLOAT_MUL) && defined (FAST) */ - -/* 4.2.5 */ - -static void Reflection_coefficients P2( (L_ACF, r), - longword * L_ACF, /* 0...8 IN */ - register word * r /* 0...7 OUT */ -) -{ - register int i, m, n; - register word temp; - register longword ltmp; - word ACF[9]; /* 0..8 */ - word P[ 9]; /* 0..8 */ - word K[ 9]; /* 2..8 */ - - /* Schur recursion with 16 bits arithmetic. - */ - - if (L_ACF[0] == 0) { - for (i = 8; i--; *r++ = 0) ; - return; - } - - assert( L_ACF[0] != 0 ); - temp = gsm_norm( L_ACF[0] ); - - assert(temp >= 0 && temp < 32); - - /* ? overflow ? */ - for (i = 0; i <= 8; i++) ACF[i] = SASR( L_ACF[i] << temp, 16 ); - - /* Initialize array P[..] and K[..] for the recursion. - */ - - for (i = 1; i <= 7; i++) K[ i ] = ACF[ i ]; - for (i = 0; i <= 8; i++) P[ i ] = ACF[ i ]; - - /* Compute reflection coefficients - */ - for (n = 1; n <= 8; n++, r++) { - - temp = P[1]; - temp = GSM_ABS(temp); - if (P[0] < temp) { - for (i = n; i <= 8; i++) *r++ = 0; - return; - } - - *r = gsm_div( temp, P[0] ); - - assert(*r >= 0); - if (P[1] > 0) *r = -*r; /* r[n] = sub(0, r[n]) */ - assert (*r != MIN_WORD); - if (n == 8) return; - - /* Schur recursion - */ - temp = GSM_MULT_R( P[1], *r ); - P[0] = GSM_ADD( P[0], temp ); - - for (m = 1; m <= 8 - n; m++) { - temp = GSM_MULT_R( K[ m ], *r ); - P[m] = GSM_ADD( P[ m+1 ], temp ); - - temp = GSM_MULT_R( P[ m+1 ], *r ); - K[m] = GSM_ADD( K[ m ], temp ); - } - } -} - -/* 4.2.6 */ - -static void Transformation_to_Log_Area_Ratios P1((r), - register word * r /* 0..7 IN/OUT */ -) -/* - * The following scaling for r[..] and LAR[..] has been used: - * - * r[..] = integer( real_r[..]*32768. ); -1 <= real_r < 1. - * LAR[..] = integer( real_LAR[..] * 16384 ); - * with -1.625 <= real_LAR <= 1.625 - */ -{ - register word temp; - register int i; - - - /* Computation of the LAR[0..7] from the r[0..7] - */ - for (i = 1; i <= 8; i++, r++) { - - temp = *r; - temp = GSM_ABS(temp); - assert(temp >= 0); - - if (temp < 22118) { - temp >>= 1; - } else if (temp < 31130) { - assert( temp >= 11059 ); - temp -= 11059; - } else { - assert( temp >= 26112 ); - temp -= 26112; - temp <<= 2; - } - - *r = *r < 0 ? -temp : temp; - assert( *r != MIN_WORD ); - } -} - -/* 4.2.7 */ - -static void Quantization_and_coding P1((LAR), - register word * LAR /* [0..7] IN/OUT */ -) -{ - register word temp; - longword ltmp; - - - /* This procedure needs four tables; the following equations - * give the optimum scaling for the constants: - * - * A[0..7] = integer( real_A[0..7] * 1024 ) - * B[0..7] = integer( real_B[0..7] * 512 ) - * MAC[0..7] = maximum of the LARc[0..7] - * MIC[0..7] = minimum of the LARc[0..7] - */ - -# undef STEP -# define STEP( A, B, MAC, MIC ) \ - temp = GSM_MULT( A, *LAR ); \ - temp = GSM_ADD( temp, B ); \ - temp = GSM_ADD( temp, 256 ); \ - temp = SASR( temp, 9 ); \ - *LAR = temp>MAC ? MAC - MIC : (tempfast) Fast_Autocorrelation (s, L_ACF ); - else -#endif - Autocorrelation (s, L_ACF ); - Reflection_coefficients (L_ACF, LARc ); - Transformation_to_Log_Area_Ratios (LARc); - Quantization_and_coding (LARc); -} diff --git a/linphone/gsmlib/preprocess.c b/linphone/gsmlib/preprocess.c deleted file mode 100644 index 82ee9099e..000000000 --- a/linphone/gsmlib/preprocess.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/preprocess.c,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $ */ - -#include -#include - -#include "private.h" - -#include "gsm.h" -#include "proto.h" - -/* 4.2.0 .. 4.2.3 PREPROCESSING SECTION - * - * After A-law to linear conversion (or directly from the - * Ato D converter) the following scaling is assumed for - * input to the RPE-LTP algorithm: - * - * in: 0.1.....................12 - * S.v.v.v.v.v.v.v.v.v.v.v.v.*.*.* - * - * Where S is the sign bit, v a valid bit, and * a "don't care" bit. - * The original signal is called sop[..] - * - * out: 0.1................... 12 - * S.S.v.v.v.v.v.v.v.v.v.v.v.v.0.0 - */ - - -void Gsm_Preprocess P3((S, s, so), - struct gsm_state * S, - word * s, - word * so ) /* [0..159] IN/OUT */ -{ - - word z1 = S->z1; - longword L_z2 = S->L_z2; - word mp = S->mp; - - word s1; - longword L_s2; - - longword L_temp; - - word msp, lsp; - word SO; - - longword ltmp; /* for ADD */ - ulongword utmp; /* for L_ADD */ - - register int k = 160; - - while (k--) { - - /* 4.2.1 Downscaling of the input signal - */ - SO = SASR( *s, 3 ) << 2; - s++; - - assert (SO >= -0x4000); /* downscaled by */ - assert (SO <= 0x3FFC); /* previous routine. */ - - - /* 4.2.2 Offset compensation - * - * This part implements a high-pass filter and requires extended - * arithmetic precision for the recursive part of this filter. - * The input of this procedure is the array so[0...159] and the - * output the array sof[ 0...159 ]. - */ - /* Compute the non-recursive part - */ - - s1 = SO - z1; /* s1 = gsm_sub( *so, z1 ); */ - z1 = SO; - - assert(s1 != MIN_WORD); - - /* Compute the recursive part - */ - L_s2 = s1; - L_s2 <<= 15; - - /* Execution of a 31 bv 16 bits multiplication - */ - - msp = SASR( L_z2, 15 ); - lsp = L_z2-((longword)msp<<15); /* gsm_L_sub(L_z2,(msp<<15)); */ - - L_s2 += GSM_MULT_R( lsp, 32735 ); - L_temp = (longword)msp * 32735; /* GSM_L_MULT(msp,32735) >> 1;*/ - L_z2 = GSM_L_ADD( L_temp, L_s2 ); - - /* Compute sof[k] with rounding - */ - L_temp = GSM_L_ADD( L_z2, 16384 ); - - /* 4.2.3 Preemphasis - */ - - msp = GSM_MULT_R( mp, -28180 ); - mp = SASR( L_temp, 15 ); - *so++ = GSM_ADD( mp, msp ); - } - - S->z1 = z1; - S->L_z2 = L_z2; - S->mp = mp; -} diff --git a/linphone/gsmlib/private.h b/linphone/gsmlib/private.h deleted file mode 100644 index d78fd6b97..000000000 --- a/linphone/gsmlib/private.h +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/*$Header: /sources/linphone/linphone/gsmlib/private.h,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $*/ - -#ifndef PRIVATE_H -#define PRIVATE_H - -typedef short word; /* 16 bit signed int */ -typedef long longword; /* 32 bit signed int */ - -typedef unsigned short uword; /* unsigned word */ -typedef unsigned long ulongword; /* unsigned longword */ - -struct gsm_state { - - word dp0[ 280 ]; - - word z1; /* preprocessing.c, Offset_com. */ - longword L_z2; /* Offset_com. */ - int mp; /* Preemphasis */ - - word u[8]; /* short_term_aly_filter.c */ - word LARpp[2][8]; /* */ - word j; /* */ - - word ltp_cut; /* long_term.c, LTP crosscorr. */ - word nrp; /* 40 */ /* long_term.c, synthesis */ - word v[9]; /* short_term.c, synthesis */ - word msr; /* decoder.c, Postprocessing */ - - char verbose; /* only used if !NDEBUG */ - char fast; /* only used if FAST */ - - char wav_fmt; /* only used if WAV49 defined */ - unsigned char frame_index; /* odd/even chaining */ - unsigned char frame_chain; /* half-byte to carry forward */ -}; - - -#define MIN_WORD (-32767 - 1) -#define MAX_WORD 32767 - -#define MIN_LONGWORD (-2147483647 - 1) -#define MAX_LONGWORD 2147483647 - -#ifdef SASR /* flag: >> is a signed arithmetic shift right */ -#undef SASR -#define SASR(x, by) ((x) >> (by)) -#else -#define SASR(x, by) ((x) >= 0 ? (x) >> (by) : (~(-((x) + 1) >> (by)))) -#endif /* SASR */ - -#include "proto.h" - -/* - * Prototypes from add.c - */ -extern word gsm_mult P((word a, word b)); -extern longword gsm_L_mult P((word a, word b)); -extern word gsm_mult_r P((word a, word b)); - -extern word gsm_div P((word num, word denum)); - -extern word gsm_add P(( word a, word b )); -extern longword gsm_L_add P(( longword a, longword b )); - -extern word gsm_sub P((word a, word b)); -extern longword gsm_L_sub P((longword a, longword b)); - -extern word gsm_abs P((word a)); - -extern word gsm_norm P(( longword a )); - -extern longword gsm_L_asl P((longword a, int n)); -extern word gsm_asl P((word a, int n)); - -extern longword gsm_L_asr P((longword a, int n)); -extern word gsm_asr P((word a, int n)); - -/* - * Inlined functions from add.h - */ - -/* - * #define GSM_MULT_R(a, b) (* word a, word b, !(a == b == MIN_WORD) *) \ - * (0x0FFFF & SASR(((longword)(a) * (longword)(b) + 16384), 15)) - */ -#define GSM_MULT_R(a, b) /* word a, word b, !(a == b == MIN_WORD) */ \ - (SASR( ((longword)(a) * (longword)(b) + 16384), 15 )) - -# define GSM_MULT(a,b) /* word a, word b, !(a == b == MIN_WORD) */ \ - (SASR( ((longword)(a) * (longword)(b)), 15 )) - -# define GSM_L_MULT(a, b) /* word a, word b */ \ - (((longword)(a) * (longword)(b)) << 1) - -# define GSM_L_ADD(a, b) \ - ( (a) < 0 ? ( (b) >= 0 ? (a) + (b) \ - : (utmp = (ulongword)-((a) + 1) + (ulongword)-((b) + 1)) \ - >= MAX_LONGWORD ? MIN_LONGWORD : -(longword)utmp-2 ) \ - : ((b) <= 0 ? (a) + (b) \ - : (utmp = (ulongword)(a) + (ulongword)(b)) >= MAX_LONGWORD \ - ? MAX_LONGWORD : utmp)) - -/* - * # define GSM_ADD(a, b) \ - * ((ltmp = (longword)(a) + (longword)(b)) >= MAX_WORD \ - * ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp) - */ -/* Nonportable, but faster: */ - -#define GSM_ADD(a, b) \ - ((ulongword)((ltmp = (longword)(a) + (longword)(b)) - MIN_WORD) > \ - MAX_WORD - MIN_WORD ? (ltmp > 0 ? MAX_WORD : MIN_WORD) : ltmp) - -# define GSM_SUB(a, b) \ - ((ltmp = (longword)(a) - (longword)(b)) >= MAX_WORD \ - ? MAX_WORD : ltmp <= MIN_WORD ? MIN_WORD : ltmp) - -# define GSM_ABS(a) ((a) < 0 ? ((a) == MIN_WORD ? MAX_WORD : -(a)) : (a)) - -/* Use these if necessary: - -# define GSM_MULT_R(a, b) gsm_mult_r(a, b) -# define GSM_MULT(a, b) gsm_mult(a, b) -# define GSM_L_MULT(a, b) gsm_L_mult(a, b) - -# define GSM_L_ADD(a, b) gsm_L_add(a, b) -# define GSM_ADD(a, b) gsm_add(a, b) -# define GSM_SUB(a, b) gsm_sub(a, b) - -# define GSM_ABS(a) gsm_abs(a) - -*/ - -/* - * More prototypes from implementations.. - */ -extern void Gsm_Coder P(( - struct gsm_state * S, - word * s, /* [0..159] samples IN */ - word * LARc, /* [0..7] LAR coefficients OUT */ - word * Nc, /* [0..3] LTP lag OUT */ - word * bc, /* [0..3] coded LTP gain OUT */ - word * Mc, /* [0..3] RPE grid selection OUT */ - word * xmaxc,/* [0..3] Coded maximum amplitude OUT */ - word * xMc /* [13*4] normalized RPE samples OUT */)); - -extern void Gsm_Long_Term_Predictor P(( /* 4x for 160 samples */ - struct gsm_state * S, - word * d, /* [0..39] residual signal IN */ - word * dp, /* [-120..-1] d' IN */ - word * e, /* [0..40] OUT */ - word * dpp, /* [0..40] OUT */ - word * Nc, /* correlation lag OUT */ - word * bc /* gain factor OUT */)); - -extern void Gsm_LPC_Analysis P(( - struct gsm_state * S, - word * s, /* 0..159 signals IN/OUT */ - word * LARc)); /* 0..7 LARc's OUT */ - -extern void Gsm_Preprocess P(( - struct gsm_state * S, - word * s, word * so)); - -extern void Gsm_Encoding P(( - struct gsm_state * S, - word * e, - word * ep, - word * xmaxc, - word * Mc, - word * xMc)); - -extern void Gsm_Short_Term_Analysis_Filter P(( - struct gsm_state * S, - word * LARc, /* coded log area ratio [0..7] IN */ - word * d /* st res. signal [0..159] IN/OUT */)); - -extern void Gsm_Decoder P(( - struct gsm_state * S, - word * LARcr, /* [0..7] IN */ - word * Ncr, /* [0..3] IN */ - word * bcr, /* [0..3] IN */ - word * Mcr, /* [0..3] IN */ - word * xmaxcr, /* [0..3] IN */ - word * xMcr, /* [0..13*4] IN */ - word * s)); /* [0..159] OUT */ - -extern void Gsm_Decoding P(( - struct gsm_state * S, - word xmaxcr, - word Mcr, - word * xMcr, /* [0..12] IN */ - word * erp)); /* [0..39] OUT */ - -extern void Gsm_Long_Term_Synthesis_Filtering P(( - struct gsm_state* S, - word Ncr, - word bcr, - word * erp, /* [0..39] IN */ - word * drp)); /* [-120..-1] IN, [0..40] OUT */ - -void Gsm_RPE_Decoding P(( - struct gsm_state *S, - word xmaxcr, - word Mcr, - word * xMcr, /* [0..12], 3 bits IN */ - word * erp)); /* [0..39] OUT */ - -void Gsm_RPE_Encoding P(( - struct gsm_state * S, - word * e, /* -5..-1][0..39][40..44 IN/OUT */ - word * xmaxc, /* OUT */ - word * Mc, /* OUT */ - word * xMc)); /* [0..12] OUT */ - -extern void Gsm_Short_Term_Synthesis_Filter P(( - struct gsm_state * S, - word * LARcr, /* log area ratios [0..7] IN */ - word * drp, /* received d [0...39] IN */ - word * s)); /* signal s [0..159] OUT */ - -extern void Gsm_Update_of_reconstructed_short_time_residual_signal P(( - word * dpp, /* [0...39] IN */ - word * ep, /* [0...39] IN */ - word * dp)); /* [-120...-1] IN/OUT */ - -/* - * Tables from table.c - */ -#ifndef GSM_TABLE_C - -extern word gsm_A[8], gsm_B[8], gsm_MIC[8], gsm_MAC[8]; -extern word gsm_INVA[8]; -extern word gsm_DLB[4], gsm_QLB[4]; -extern word gsm_H[11]; -extern word gsm_NRFAC[8]; -extern word gsm_FAC[8]; - -#endif /* GSM_TABLE_C */ - -/* - * Debugging - */ -#ifdef NDEBUG - -# define gsm_debug_words(a, b, c, d) /* nil */ -# define gsm_debug_longwords(a, b, c, d) /* nil */ -# define gsm_debug_word(a, b) /* nil */ -# define gsm_debug_longword(a, b) /* nil */ - -#else /* !NDEBUG => DEBUG */ - - extern void gsm_debug_words P((char * name, int, int, word *)); - extern void gsm_debug_longwords P((char * name, int, int, longword *)); - extern void gsm_debug_longword P((char * name, longword)); - extern void gsm_debug_word P((char * name, word)); - -#endif /* !NDEBUG */ - -#include "unproto.h" - -#endif /* PRIVATE_H */ diff --git a/linphone/gsmlib/proto.h b/linphone/gsmlib/proto.h deleted file mode 100644 index 3cedd367e..000000000 --- a/linphone/gsmlib/proto.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/*$Header: /sources/linphone/linphone/gsmlib/proto.h,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $*/ - -#ifndef PROTO_H -#define PROTO_H - -#if __cplusplus -# define NeedFunctionPrototypes 1 -#endif - -#if __STDC__ -# define NeedFunctionPrototypes 1 -#endif - -#ifdef _NO_PROTO -# undef NeedFunctionPrototypes -#endif - -#undef P /* gnu stdio.h actually defines this... */ -#undef P0 -#undef P1 -#undef P2 -#undef P3 -#undef P4 -#undef P5 -#undef P6 -#undef P7 -#undef P8 - -#if NeedFunctionPrototypes - -# define P( protos ) protos - -# define P0() (void) -# define P1(x, a) (a) -# define P2(x, a, b) (a, b) -# define P3(x, a, b, c) (a, b, c) -# define P4(x, a, b, c, d) (a, b, c, d) -# define P5(x, a, b, c, d, e) (a, b, c, d, e) -# define P6(x, a, b, c, d, e, f) (a, b, c, d, e, f) -# define P7(x, a, b, c, d, e, f, g) (a, b, c, d, e, f, g) -# define P8(x, a, b, c, d, e, f, g, h) (a, b, c, d, e, f, g, h) - -#else /* !NeedFunctionPrototypes */ - -# define P( protos ) ( /* protos */ ) - -# define P0() () -# define P1(x, a) x a; -# define P2(x, a, b) x a; b; -# define P3(x, a, b, c) x a; b; c; -# define P4(x, a, b, c, d) x a; b; c; d; -# define P5(x, a, b, c, d, e) x a; b; c; d; e; -# define P6(x, a, b, c, d, e, f) x a; b; c; d; e; f; -# define P7(x, a, b, c, d, e, f, g) x a; b; c; d; e; f; g; -# define P8(x, a, b, c, d, e, f, g, h) x a; b; c; d; e; f; g; h; - -#endif /* !NeedFunctionPrototypes */ - -#endif /* PROTO_H */ diff --git a/linphone/gsmlib/rpe.c b/linphone/gsmlib/rpe.c deleted file mode 100644 index 15a359c76..000000000 --- a/linphone/gsmlib/rpe.c +++ /dev/null @@ -1,488 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/rpe.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -#include -#include - -#include "private.h" - -#include "gsm.h" -#include "proto.h" - -/* 4.2.13 .. 4.2.17 RPE ENCODING SECTION - */ - -/* 4.2.13 */ - -static void Weighting_filter P2((e, x), - register word * e, /* signal [-5..0.39.44] IN */ - word * x /* signal [0..39] OUT */ -) -/* - * The coefficients of the weighting filter are stored in a table - * (see table 4.4). The following scaling is used: - * - * H[0..10] = integer( real_H[ 0..10] * 8192 ); - */ -{ - /* word wt[ 50 ]; */ - - register longword L_result; - register int k /* , i */ ; - - /* Initialization of a temporary working array wt[0...49] - */ - - /* for (k = 0; k <= 4; k++) wt[k] = 0; - * for (k = 5; k <= 44; k++) wt[k] = *e++; - * for (k = 45; k <= 49; k++) wt[k] = 0; - * - * (e[-5..-1] and e[40..44] are allocated by the caller, - * are initially zero and are not written anywhere.) - */ - e -= 5; - - /* Compute the signal x[0..39] - */ - for (k = 0; k <= 39; k++) { - - L_result = 8192 >> 1; - - /* for (i = 0; i <= 10; i++) { - * L_temp = GSM_L_MULT( wt[k+i], gsm_H[i] ); - * L_result = GSM_L_ADD( L_result, L_temp ); - * } - */ - -#undef STEP -#define STEP( i, H ) (e[ k + i ] * (longword)H) - - /* Every one of these multiplications is done twice -- - * but I don't see an elegant way to optimize this. - * Do you? - */ - -#ifdef STUPID_COMPILER - L_result += STEP( 0, -134 ) ; - L_result += STEP( 1, -374 ) ; - /* + STEP( 2, 0 ) */ - L_result += STEP( 3, 2054 ) ; - L_result += STEP( 4, 5741 ) ; - L_result += STEP( 5, 8192 ) ; - L_result += STEP( 6, 5741 ) ; - L_result += STEP( 7, 2054 ) ; - /* + STEP( 8, 0 ) */ - L_result += STEP( 9, -374 ) ; - L_result += STEP( 10, -134 ) ; -#else - L_result += - STEP( 0, -134 ) - + STEP( 1, -374 ) - /* + STEP( 2, 0 ) */ - + STEP( 3, 2054 ) - + STEP( 4, 5741 ) - + STEP( 5, 8192 ) - + STEP( 6, 5741 ) - + STEP( 7, 2054 ) - /* + STEP( 8, 0 ) */ - + STEP( 9, -374 ) - + STEP(10, -134 ) - ; -#endif - - /* L_result = GSM_L_ADD( L_result, L_result ); (* scaling(x2) *) - * L_result = GSM_L_ADD( L_result, L_result ); (* scaling(x4) *) - * - * x[k] = SASR( L_result, 16 ); - */ - - /* 2 adds vs. >>16 => 14, minus one shift to compensate for - * those we lost when replacing L_MULT by '*'. - */ - - L_result = SASR( L_result, 13 ); - x[k] = ( L_result < MIN_WORD ? MIN_WORD - : (L_result > MAX_WORD ? MAX_WORD : L_result )); - } -} - -/* 4.2.14 */ - -static void RPE_grid_selection P3((x,xM,Mc_out), - word * x, /* [0..39] IN */ - word * xM, /* [0..12] OUT */ - word * Mc_out /* OUT */ -) -/* - * The signal x[0..39] is used to select the RPE grid which is - * represented by Mc. - */ -{ - /* register word temp1; */ - register int /* m, */ i; - register longword L_result, L_temp; - longword EM; /* xxx should be L_EM? */ - word Mc; - - longword L_common_0_3; - - EM = 0; - Mc = 0; - - /* for (m = 0; m <= 3; m++) { - * L_result = 0; - * - * - * for (i = 0; i <= 12; i++) { - * - * temp1 = SASR( x[m + 3*i], 2 ); - * - * assert(temp1 != MIN_WORD); - * - * L_temp = GSM_L_MULT( temp1, temp1 ); - * L_result = GSM_L_ADD( L_temp, L_result ); - * } - * - * if (L_result > EM) { - * Mc = m; - * EM = L_result; - * } - * } - */ - -#undef STEP -#define STEP( m, i ) L_temp = SASR( x[m + 3 * i], 2 ); \ - L_result += L_temp * L_temp; - - /* common part of 0 and 3 */ - - L_result = 0; - STEP( 0, 1 ); STEP( 0, 2 ); STEP( 0, 3 ); STEP( 0, 4 ); - STEP( 0, 5 ); STEP( 0, 6 ); STEP( 0, 7 ); STEP( 0, 8 ); - STEP( 0, 9 ); STEP( 0, 10); STEP( 0, 11); STEP( 0, 12); - L_common_0_3 = L_result; - - /* i = 0 */ - - STEP( 0, 0 ); - L_result <<= 1; /* implicit in L_MULT */ - EM = L_result; - - /* i = 1 */ - - L_result = 0; - STEP( 1, 0 ); - STEP( 1, 1 ); STEP( 1, 2 ); STEP( 1, 3 ); STEP( 1, 4 ); - STEP( 1, 5 ); STEP( 1, 6 ); STEP( 1, 7 ); STEP( 1, 8 ); - STEP( 1, 9 ); STEP( 1, 10); STEP( 1, 11); STEP( 1, 12); - L_result <<= 1; - if (L_result > EM) { - Mc = 1; - EM = L_result; - } - - /* i = 2 */ - - L_result = 0; - STEP( 2, 0 ); - STEP( 2, 1 ); STEP( 2, 2 ); STEP( 2, 3 ); STEP( 2, 4 ); - STEP( 2, 5 ); STEP( 2, 6 ); STEP( 2, 7 ); STEP( 2, 8 ); - STEP( 2, 9 ); STEP( 2, 10); STEP( 2, 11); STEP( 2, 12); - L_result <<= 1; - if (L_result > EM) { - Mc = 2; - EM = L_result; - } - - /* i = 3 */ - - L_result = L_common_0_3; - STEP( 3, 12 ); - L_result <<= 1; - if (L_result > EM) { - Mc = 3; - EM = L_result; - } - - /**/ - - /* Down-sampling by a factor 3 to get the selected xM[0..12] - * RPE sequence. - */ - for (i = 0; i <= 12; i ++) xM[i] = x[Mc + 3*i]; - *Mc_out = Mc; -} - -/* 4.12.15 */ - -static void APCM_quantization_xmaxc_to_exp_mant P3((xmaxc,exp_out,mant_out), - word xmaxc, /* IN */ - word * exp_out, /* OUT */ - word * mant_out ) /* OUT */ -{ - word exp, mant; - - /* Compute exponent and mantissa of the decoded version of xmaxc - */ - - exp = 0; - if (xmaxc > 15) exp = SASR(xmaxc, 3) - 1; - mant = xmaxc - (exp << 3); - - if (mant == 0) { - exp = -4; - mant = 7; - } - else { - while (mant <= 7) { - mant = mant << 1 | 1; - exp--; - } - mant -= 8; - } - - assert( exp >= -4 && exp <= 6 ); - assert( mant >= 0 && mant <= 7 ); - - *exp_out = exp; - *mant_out = mant; -} - -static void APCM_quantization P5((xM,xMc,mant_out,exp_out,xmaxc_out), - word * xM, /* [0..12] IN */ - - word * xMc, /* [0..12] OUT */ - word * mant_out, /* OUT */ - word * exp_out, /* OUT */ - word * xmaxc_out /* OUT */ -) -{ - int i, itest; - - word xmax, xmaxc, temp, temp1, temp2; - word exp, mant; - - - /* Find the maximum absolute value xmax of xM[0..12]. - */ - - xmax = 0; - for (i = 0; i <= 12; i++) { - temp = xM[i]; - temp = GSM_ABS(temp); - if (temp > xmax) xmax = temp; - } - - /* Qantizing and coding of xmax to get xmaxc. - */ - - exp = 0; - temp = SASR( xmax, 9 ); - itest = 0; - - for (i = 0; i <= 5; i++) { - - itest |= (temp <= 0); - temp = SASR( temp, 1 ); - - assert(exp <= 5); - if (itest == 0) exp++; /* exp = add (exp, 1) */ - } - - assert(exp <= 6 && exp >= 0); - temp = exp + 5; - - assert(temp <= 11 && temp >= 0); - xmaxc = gsm_add( SASR(xmax, temp), exp << 3 ); - - /* Quantizing and coding of the xM[0..12] RPE sequence - * to get the xMc[0..12] - */ - - APCM_quantization_xmaxc_to_exp_mant( xmaxc, &exp, &mant ); - - /* This computation uses the fact that the decoded version of xmaxc - * can be calculated by using the exponent and the mantissa part of - * xmaxc (logarithmic table). - * So, this method avoids any division and uses only a scaling - * of the RPE samples by a function of the exponent. A direct - * multiplication by the inverse of the mantissa (NRFAC[0..7] - * found in table 4.5) gives the 3 bit coded version xMc[0..12] - * of the RPE samples. - */ - - - /* Direct computation of xMc[0..12] using table 4.5 - */ - - assert( exp <= 4096 && exp >= -4096); - assert( mant >= 0 && mant <= 7 ); - - temp1 = 6 - exp; /* normalization by the exponent */ - temp2 = gsm_NRFAC[ mant ]; /* inverse mantissa */ - - for (i = 0; i <= 12; i++) { - - assert(temp1 >= 0 && temp1 < 16); - - temp = xM[i] << temp1; - temp = GSM_MULT( temp, temp2 ); - temp = SASR(temp, 12); - xMc[i] = temp + 4; /* see note below */ - } - - /* NOTE: This equation is used to make all the xMc[i] positive. - */ - - *mant_out = mant; - *exp_out = exp; - *xmaxc_out = xmaxc; -} - -/* 4.2.16 */ - -static void APCM_inverse_quantization P4((xMc,mant,exp,xMp), - register word * xMc, /* [0..12] IN */ - word mant, - word exp, - register word * xMp) /* [0..12] OUT */ -/* - * This part is for decoding the RPE sequence of coded xMc[0..12] - * samples to obtain the xMp[0..12] array. Table 4.6 is used to get - * the mantissa of xmaxc (FAC[0..7]). - */ -{ - int i; - word temp, temp1, temp2, temp3; - longword ltmp; - - assert( mant >= 0 && mant <= 7 ); - - temp1 = gsm_FAC[ mant ]; /* see 4.2-15 for mant */ - temp2 = gsm_sub( 6, exp ); /* see 4.2-15 for exp */ - temp3 = gsm_asl( 1, gsm_sub( temp2, 1 )); - - for (i = 13; i--;) { - - assert( *xMc <= 7 && *xMc >= 0 ); /* 3 bit unsigned */ - - /* temp = gsm_sub( *xMc++ << 1, 7 ); */ - temp = (*xMc++ << 1) - 7; /* restore sign */ - assert( temp <= 7 && temp >= -7 ); /* 4 bit signed */ - - temp <<= 12; /* 16 bit signed */ - temp = GSM_MULT_R( temp1, temp ); - temp = GSM_ADD( temp, temp3 ); - *xMp++ = gsm_asr( temp, temp2 ); - } -} - -/* 4.2.17 */ - -static void RPE_grid_positioning P3((Mc,xMp,ep), - word Mc, /* grid position IN */ - register word * xMp, /* [0..12] IN */ - register word * ep /* [0..39] OUT */ -) -/* - * This procedure computes the reconstructed long term residual signal - * ep[0..39] for the LTP analysis filter. The inputs are the Mc - * which is the grid position selection and the xMp[0..12] decoded - * RPE samples which are upsampled by a factor of 3 by inserting zero - * values. - */ -{ - int i = 13; - - assert(0 <= Mc && Mc <= 3); - - switch (Mc) { - case 3: *ep++ = 0; - case 2: do { - *ep++ = 0; - case 1: *ep++ = 0; - case 0: *ep++ = *xMp++; - } while (--i); - } - while (++Mc < 4) *ep++ = 0; - - /* - - int i, k; - for (k = 0; k <= 39; k++) ep[k] = 0; - for (i = 0; i <= 12; i++) { - ep[ Mc + (3*i) ] = xMp[i]; - } - */ -} - -/* 4.2.18 */ - -/* This procedure adds the reconstructed long term residual signal - * ep[0..39] to the estimated signal dpp[0..39] from the long term - * analysis filter to compute the reconstructed short term residual - * signal dp[-40..-1]; also the reconstructed short term residual - * array dp[-120..-41] is updated. - */ - -#if 0 /* Has been inlined in code.c */ -void Gsm_Update_of_reconstructed_short_time_residual_signal P3((dpp, ep, dp), - word * dpp, /* [0...39] IN */ - word * ep, /* [0...39] IN */ - word * dp) /* [-120...-1] IN/OUT */ -{ - int k; - - for (k = 0; k <= 79; k++) - dp[ -120 + k ] = dp[ -80 + k ]; - - for (k = 0; k <= 39; k++) - dp[ -40 + k ] = gsm_add( ep[k], dpp[k] ); -} -#endif /* Has been inlined in code.c */ - -void Gsm_RPE_Encoding P5((S,e,xmaxc,Mc,xMc), - - struct gsm_state * S, - - word * e, /* -5..-1][0..39][40..44 IN/OUT */ - word * xmaxc, /* OUT */ - word * Mc, /* OUT */ - word * xMc) /* [0..12] OUT */ -{ - word x[40]; - word xM[13], xMp[13]; - word mant, exp; - - Weighting_filter(e, x); - RPE_grid_selection(x, xM, Mc); - - APCM_quantization( xM, xMc, &mant, &exp, xmaxc); - APCM_inverse_quantization( xMc, mant, exp, xMp); - - RPE_grid_positioning( *Mc, xMp, e ); - -} - -void Gsm_RPE_Decoding P5((S, xmaxcr, Mcr, xMcr, erp), - struct gsm_state * S, - - word xmaxcr, - word Mcr, - word * xMcr, /* [0..12], 3 bits IN */ - word * erp /* [0..39] OUT */ -) -{ - word exp, mant; - word xMp[ 13 ]; - - APCM_quantization_xmaxc_to_exp_mant( xmaxcr, &exp, &mant ); - APCM_inverse_quantization( xMcr, mant, exp, xMp ); - RPE_grid_positioning( Mcr, xMp, erp ); - -} diff --git a/linphone/gsmlib/short_term.c b/linphone/gsmlib/short_term.c deleted file mode 100644 index 951261edc..000000000 --- a/linphone/gsmlib/short_term.c +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/short_term.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -#include -#include - -#include "private.h" - -#include "gsm.h" -#include "proto.h" - -/* - * SHORT TERM ANALYSIS FILTERING SECTION - */ - -/* 4.2.8 */ - -static void Decoding_of_the_coded_Log_Area_Ratios P2((LARc,LARpp), - word * LARc, /* coded log area ratio [0..7] IN */ - word * LARpp) /* out: decoded .. */ -{ - register word temp1 /* , temp2 */; - register long ltmp; /* for GSM_ADD */ - - /* This procedure requires for efficient implementation - * two tables. - * - * INVA[1..8] = integer( (32768 * 8) / real_A[1..8]) - * MIC[1..8] = minimum value of the LARc[1..8] - */ - - /* Compute the LARpp[1..8] - */ - - /* for (i = 1; i <= 8; i++, B++, MIC++, INVA++, LARc++, LARpp++) { - * - * temp1 = GSM_ADD( *LARc, *MIC ) << 10; - * temp2 = *B << 1; - * temp1 = GSM_SUB( temp1, temp2 ); - * - * assert(*INVA != MIN_WORD); - * - * temp1 = GSM_MULT_R( *INVA, temp1 ); - * *LARpp = GSM_ADD( temp1, temp1 ); - * } - */ - -#undef STEP -#define STEP( B, MIC, INVA ) \ - temp1 = GSM_ADD( *LARc++, MIC ) << 10; \ - temp1 = GSM_SUB( temp1, B << 1 ); \ - temp1 = GSM_MULT_R( INVA, temp1 ); \ - *LARpp++ = GSM_ADD( temp1, temp1 ); - - STEP( 0, -32, 13107 ); - STEP( 0, -32, 13107 ); - STEP( 2048, -16, 13107 ); - STEP( -2560, -16, 13107 ); - - STEP( 94, -8, 19223 ); - STEP( -1792, -8, 17476 ); - STEP( -341, -4, 31454 ); - STEP( -1144, -4, 29708 ); - - /* NOTE: the addition of *MIC is used to restore - * the sign of *LARc. - */ -} - -/* 4.2.9 */ -/* Computation of the quantized reflection coefficients - */ - -/* 4.2.9.1 Interpolation of the LARpp[1..8] to get the LARp[1..8] - */ - -/* - * Within each frame of 160 analyzed speech samples the short term - * analysis and synthesis filters operate with four different sets of - * coefficients, derived from the previous set of decoded LARs(LARpp(j-1)) - * and the actual set of decoded LARs (LARpp(j)) - * - * (Initial value: LARpp(j-1)[1..8] = 0.) - */ - -static void Coefficients_0_12 P3((LARpp_j_1, LARpp_j, LARp), - register word * LARpp_j_1, - register word * LARpp_j, - register word * LARp) -{ - register int i; - register longword ltmp; - - for (i = 1; i <= 8; i++, LARp++, LARpp_j_1++, LARpp_j++) { - *LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 )); - *LARp = GSM_ADD( *LARp, SASR( *LARpp_j_1, 1)); - } -} - -static void Coefficients_13_26 P3((LARpp_j_1, LARpp_j, LARp), - register word * LARpp_j_1, - register word * LARpp_j, - register word * LARp) -{ - register int i; - register longword ltmp; - for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) { - *LARp = GSM_ADD( SASR( *LARpp_j_1, 1), SASR( *LARpp_j, 1 )); - } -} - -static void Coefficients_27_39 P3((LARpp_j_1, LARpp_j, LARp), - register word * LARpp_j_1, - register word * LARpp_j, - register word * LARp) -{ - register int i; - register longword ltmp; - - for (i = 1; i <= 8; i++, LARpp_j_1++, LARpp_j++, LARp++) { - *LARp = GSM_ADD( SASR( *LARpp_j_1, 2 ), SASR( *LARpp_j, 2 )); - *LARp = GSM_ADD( *LARp, SASR( *LARpp_j, 1 )); - } -} - - -static void Coefficients_40_159 P2((LARpp_j, LARp), - register word * LARpp_j, - register word * LARp) -{ - register int i; - - for (i = 1; i <= 8; i++, LARp++, LARpp_j++) - *LARp = *LARpp_j; -} - -/* 4.2.9.2 */ - -static void LARp_to_rp P1((LARp), - register word * LARp) /* [0..7] IN/OUT */ -/* - * The input of this procedure is the interpolated LARp[0..7] array. - * The reflection coefficients, rp[i], are used in the analysis - * filter and in the synthesis filter. - */ -{ - register int i; - register word temp; - register longword ltmp; - - for (i = 1; i <= 8; i++, LARp++) { - - /* temp = GSM_ABS( *LARp ); - * - * if (temp < 11059) temp <<= 1; - * else if (temp < 20070) temp += 11059; - * else temp = GSM_ADD( temp >> 2, 26112 ); - * - * *LARp = *LARp < 0 ? -temp : temp; - */ - - if (*LARp < 0) { - temp = *LARp == MIN_WORD ? MAX_WORD : -(*LARp); - *LARp = - ((temp < 11059) ? temp << 1 - : ((temp < 20070) ? temp + 11059 - : GSM_ADD( temp >> 2, 26112 ))); - } else { - temp = *LARp; - *LARp = (temp < 11059) ? temp << 1 - : ((temp < 20070) ? temp + 11059 - : GSM_ADD( temp >> 2, 26112 )); - } - } -} - - -/* 4.2.10 */ -static void Short_term_analysis_filtering P4((S,rp,k_n,s), - struct gsm_state * S, - register word * rp, /* [0..7] IN */ - register int k_n, /* k_end - k_start */ - register word * s /* [0..n-1] IN/OUT */ -) -/* - * This procedure computes the short term residual signal d[..] to be fed - * to the RPE-LTP loop from the s[..] signal and from the local rp[..] - * array (quantized reflection coefficients). As the call of this - * procedure can be done in many ways (see the interpolation of the LAR - * coefficient), it is assumed that the computation begins with index - * k_start (for arrays d[..] and s[..]) and stops with index k_end - * (k_start and k_end are defined in 4.2.9.1). This procedure also - * needs to keep the array u[0..7] in memory for each call. - */ -{ - register word * u = S->u; - register int i; - register word di, zzz, ui, sav, rpi; - register longword ltmp; - - for (; k_n--; s++) { - - di = sav = *s; - - for (i = 0; i < 8; i++) { /* YYY */ - - ui = u[i]; - rpi = rp[i]; - u[i] = sav; - - zzz = GSM_MULT_R(rpi, di); - sav = GSM_ADD( ui, zzz); - - zzz = GSM_MULT_R(rpi, ui); - di = GSM_ADD( di, zzz ); - } - - *s = di; - } -} - -#if defined(USE_FLOAT_MUL) && defined(FAST) - -static void Fast_Short_term_analysis_filtering P4((S,rp,k_n,s), - struct gsm_state * S, - register word * rp, /* [0..7] IN */ - register int k_n, /* k_end - k_start */ - register word * s /* [0..n-1] IN/OUT */ -) -{ - register word * u = S->u; - register int i; - - float uf[8], - rpf[8]; - - register float scalef = 3.0517578125e-5; - register float sav, di, temp; - - for (i = 0; i < 8; ++i) { - uf[i] = u[i]; - rpf[i] = rp[i] * scalef; - } - for (; k_n--; s++) { - sav = di = *s; - for (i = 0; i < 8; ++i) { - register float rpfi = rpf[i]; - register float ufi = uf[i]; - - uf[i] = sav; - temp = rpfi * di + ufi; - di += rpfi * ufi; - sav = temp; - } - *s = di; - } - for (i = 0; i < 8; ++i) u[i] = uf[i]; -} -#endif /* ! (defined (USE_FLOAT_MUL) && defined (FAST)) */ - -static void Short_term_synthesis_filtering P5((S,rrp,k,wt,sr), - struct gsm_state * S, - register word * rrp, /* [0..7] IN */ - register int k, /* k_end - k_start */ - register word * wt, /* [0..k-1] IN */ - register word * sr /* [0..k-1] OUT */ -) -{ - register word * v = S->v; - register int i; - register word sri, tmp1, tmp2; - register longword ltmp; /* for GSM_ADD & GSM_SUB */ - - while (k--) { - sri = *wt++; - for (i = 8; i--;) { - - /* sri = GSM_SUB( sri, gsm_mult_r( rrp[i], v[i] ) ); - */ - tmp1 = rrp[i]; - tmp2 = v[i]; - tmp2 = ( tmp1 == MIN_WORD && tmp2 == MIN_WORD - ? MAX_WORD - : 0x0FFFF & (( (longword)tmp1 * (longword)tmp2 - + 16384) >> 15)) ; - - sri = GSM_SUB( sri, tmp2 ); - - /* v[i+1] = GSM_ADD( v[i], gsm_mult_r( rrp[i], sri ) ); - */ - tmp1 = ( tmp1 == MIN_WORD && sri == MIN_WORD - ? MAX_WORD - : 0x0FFFF & (( (longword)tmp1 * (longword)sri - + 16384) >> 15)) ; - - v[i+1] = GSM_ADD( v[i], tmp1); - } - *sr++ = v[0] = sri; - } -} - - -#if defined(FAST) && defined(USE_FLOAT_MUL) - -static void Fast_Short_term_synthesis_filtering P5((S,rrp,k,wt,sr), - struct gsm_state * S, - register word * rrp, /* [0..7] IN */ - register int k, /* k_end - k_start */ - register word * wt, /* [0..k-1] IN */ - register word * sr /* [0..k-1] OUT */ -) -{ - register word * v = S->v; - register int i; - - float va[9], rrpa[8]; - register float scalef = 3.0517578125e-5, temp; - - for (i = 0; i < 8; ++i) { - va[i] = v[i]; - rrpa[i] = (float)rrp[i] * scalef; - } - while (k--) { - register float sri = *wt++; - for (i = 8; i--;) { - sri -= rrpa[i] * va[i]; - if (sri < -32768.) sri = -32768.; - else if (sri > 32767.) sri = 32767.; - - temp = va[i] + rrpa[i] * sri; - if (temp < -32768.) temp = -32768.; - else if (temp > 32767.) temp = 32767.; - va[i+1] = temp; - } - *sr++ = va[0] = sri; - } - for (i = 0; i < 9; ++i) v[i] = va[i]; -} - -#endif /* defined(FAST) && defined(USE_FLOAT_MUL) */ - -void Gsm_Short_Term_Analysis_Filter P3((S,LARc,s), - - struct gsm_state * S, - - word * LARc, /* coded log area ratio [0..7] IN */ - word * s /* signal [0..159] IN/OUT */ -) -{ - word * LARpp_j = S->LARpp[ S->j ]; - word * LARpp_j_1 = S->LARpp[ S->j ^= 1 ]; - - word LARp[8]; - -#undef FILTER -#if defined(FAST) && defined(USE_FLOAT_MUL) -# define FILTER (* (S->fast \ - ? Fast_Short_term_analysis_filtering \ - : Short_term_analysis_filtering )) - -#else -# define FILTER Short_term_analysis_filtering -#endif - - Decoding_of_the_coded_Log_Area_Ratios( LARc, LARpp_j ); - - Coefficients_0_12( LARpp_j_1, LARpp_j, LARp ); - LARp_to_rp( LARp ); - FILTER( S, LARp, 13, s); - - Coefficients_13_26( LARpp_j_1, LARpp_j, LARp); - LARp_to_rp( LARp ); - FILTER( S, LARp, 14, s + 13); - - Coefficients_27_39( LARpp_j_1, LARpp_j, LARp); - LARp_to_rp( LARp ); - FILTER( S, LARp, 13, s + 27); - - Coefficients_40_159( LARpp_j, LARp); - LARp_to_rp( LARp ); - FILTER( S, LARp, 120, s + 40); -} - -void Gsm_Short_Term_Synthesis_Filter P4((S, LARcr, wt, s), - struct gsm_state * S, - - word * LARcr, /* received log area ratios [0..7] IN */ - word * wt, /* received d [0..159] IN */ - - word * s /* signal s [0..159] OUT */ -) -{ - word * LARpp_j = S->LARpp[ S->j ]; - word * LARpp_j_1 = S->LARpp[ S->j ^=1 ]; - - word LARp[8]; - -#undef FILTER -#if defined(FAST) && defined(USE_FLOAT_MUL) - -# define FILTER (* (S->fast \ - ? Fast_Short_term_synthesis_filtering \ - : Short_term_synthesis_filtering )) -#else -# define FILTER Short_term_synthesis_filtering -#endif - - Decoding_of_the_coded_Log_Area_Ratios( LARcr, LARpp_j ); - - Coefficients_0_12( LARpp_j_1, LARpp_j, LARp ); - LARp_to_rp( LARp ); - FILTER( S, LARp, 13, wt, s ); - - Coefficients_13_26( LARpp_j_1, LARpp_j, LARp); - LARp_to_rp( LARp ); - FILTER( S, LARp, 14, wt + 13, s + 13 ); - - Coefficients_27_39( LARpp_j_1, LARpp_j, LARp); - LARp_to_rp( LARp ); - FILTER( S, LARp, 13, wt + 27, s + 27 ); - - Coefficients_40_159( LARpp_j, LARp ); - LARp_to_rp( LARp ); - FILTER(S, LARp, 120, wt + 40, s + 40); -} diff --git a/linphone/gsmlib/table.c b/linphone/gsmlib/table.c deleted file mode 100644 index 46a090978..000000000 --- a/linphone/gsmlib/table.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/table.c,v 1.1.1.1 2001/11/19 19:50:12 smorlat Exp $ */ - -/* Most of these tables are inlined at their point of use. - */ - -/* 4.4 TABLES USED IN THE FIXED POINT IMPLEMENTATION OF THE RPE-LTP - * CODER AND DECODER - * - * (Most of them inlined, so watch out.) - */ - -#define GSM_TABLE_C -#include "private.h" -#include "gsm.h" - -/* Table 4.1 Quantization of the Log.-Area Ratios - */ -/* i 1 2 3 4 5 6 7 8 */ -word gsm_A[8] = {20480, 20480, 20480, 20480, 13964, 15360, 8534, 9036}; -word gsm_B[8] = { 0, 0, 2048, -2560, 94, -1792, -341, -1144}; -word gsm_MIC[8] = { -32, -32, -16, -16, -8, -8, -4, -4 }; -word gsm_MAC[8] = { 31, 31, 15, 15, 7, 7, 3, 3 }; - - -/* Table 4.2 Tabulation of 1/A[1..8] - */ -word gsm_INVA[8]={ 13107, 13107, 13107, 13107, 19223, 17476, 31454, 29708 }; - - -/* Table 4.3a Decision level of the LTP gain quantizer - */ -/* bc 0 1 2 3 */ -word gsm_DLB[4] = { 6554, 16384, 26214, 32767 }; - - -/* Table 4.3b Quantization levels of the LTP gain quantizer - */ -/* bc 0 1 2 3 */ -word gsm_QLB[4] = { 3277, 11469, 21299, 32767 }; - - -/* Table 4.4 Coefficients of the weighting filter - */ -/* i 0 1 2 3 4 5 6 7 8 9 10 */ -word gsm_H[11] = {-134, -374, 0, 2054, 5741, 8192, 5741, 2054, 0, -374, -134 }; - - -/* Table 4.5 Normalized inverse mantissa used to compute xM/xmax - */ -/* i 0 1 2 3 4 5 6 7 */ -word gsm_NRFAC[8] = { 29128, 26215, 23832, 21846, 20165, 18725, 17476, 16384 }; - - -/* Table 4.6 Normalized direct mantissa used to compute xM/xmax - */ -/* i 0 1 2 3 4 5 6 7 */ -word gsm_FAC[8] = { 18431, 20479, 22527, 24575, 26623, 28671, 30719, 32767 }; diff --git a/linphone/gsmlib/toast.h b/linphone/gsmlib/toast.h deleted file mode 100644 index 4c33a35d2..000000000 --- a/linphone/gsmlib/toast.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/* $Header: /sources/linphone/linphone/gsmlib/toast.h,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $ */ - -#ifndef TOAST_H -#define TOAST_H /* Guard against multiple includes */ - -#include "config.h" - -#include -#include - -#include -#include -#include - -#include -#ifndef HAS_ERRNO_DECL - extern int errno; -#endif - -#ifdef HAS_LIMITS_H -#include -#endif - -#ifdef HAS_FCNTL_H -# include -#endif - -#ifdef HAS_UTIME -# ifdef HAS_UTIME_H -# include -# endif -#endif - -#include "gsm.h" - -#ifndef S_ISREG -#define S_ISREG(x) ((x) & S_IFREG) -#endif /* S_ISREG */ - - -# define READ "rb" -# define WRITE "wb" -#ifdef O_BINARY -# define O_WRITE_EXCL O_WRONLY|O_CREAT|O_EXCL|O_BINARY -#else -# define O_WRITE_EXCL O_WRONLY|O_CREAT|O_EXCL -#endif - -#ifndef SIGHANDLER_T -#define SIGHANDLER_T void /* what does a signal handler return? */ -#endif - - -#ifdef HAS_STRING_H -#include -#else -# ifdef HAS_STRINGS_H -# include -# else -# include "proto.h" - - extern int strlen P((char *)); - extern char * strcpy P((char *, char *)); - extern char * strcat P((char *, char *)); - extern char * strrchr P((char *, int)); - -# include "unproto.h" -# endif -#endif - - -#ifdef HAS_STDLIB_H -#include -#else -# include "proto.h" -# ifdef HAS_MALLOC_H -# include -# else - extern char * malloc P((unsigned)); -# endif - extern int exit P((int)); -# include "unproto.h" -#endif - - -#ifdef HAS_UNISTD_H -# include -#endif - -/* - * This suffix is tacked onto/removed from filenames - * similar to the way freeze and compress do it. - */ -#define SUFFIX_TOASTED ".gsm" - -#include "proto.h" - -extern int audio_init_input P((void)), audio_init_output P((void)); -extern int ulaw_input P((gsm_signal*)), ulaw_output P((gsm_signal *)); -extern int alaw_input P((gsm_signal*)), alaw_output P((gsm_signal *)); -extern int linear_input P((gsm_signal*)), linear_output P((gsm_signal *)); - -#endif /* TOAST_H */ diff --git a/linphone/gsmlib/unproto.h b/linphone/gsmlib/unproto.h deleted file mode 100644 index 6ef49e36f..000000000 --- a/linphone/gsmlib/unproto.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische - * Universitaet Berlin. See the accompanying file "COPYRIGHT" for - * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - */ - -/*$Header: /sources/linphone/linphone/gsmlib/unproto.h,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $*/ - -#ifdef PROTO_H /* sic */ -#undef PROTO_H - -#undef P -#undef P0 -#undef P1 -#undef P2 -#undef P3 -#undef P4 -#undef P5 -#undef P6 -#undef P7 -#undef P8 - -#endif /* PROTO_H */ diff --git a/linphone/gtk/.gitignore b/linphone/gtk/.gitignore deleted file mode 100644 index ce7656e3e..000000000 --- a/linphone/gtk/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -linphone diff --git a/linphone/gtk/GNOME_LinphoneApplet.server.in.in b/linphone/gtk/GNOME_LinphoneApplet.server.in.in deleted file mode 100644 index 79920977f..000000000 --- a/linphone/gtk/GNOME_LinphoneApplet.server.in.in +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/linphone/gtk/GNOME_LinphoneApplet.xml b/linphone/gtk/GNOME_LinphoneApplet.xml deleted file mode 100644 index 9a5350fd2..000000000 --- a/linphone/gtk/GNOME_LinphoneApplet.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/linphone/gtk/Makefile.am b/linphone/gtk/Makefile.am deleted file mode 100644 index 506bcf4e0..000000000 --- a/linphone/gtk/Makefile.am +++ /dev/null @@ -1,77 +0,0 @@ -## Process this file with automake to produce Makefile.in - -linphone_common_sources=\ - linphone.c linphone.h \ - gui_utils.c gui_utils.h \ - support.c support.h \ - interface.c interface.h \ - callbacks.c callbacks.h \ - presence.c presence.h \ - propertybox.c propertybox.h \ - addressbook.c addressbook.h \ - friends.c friends.h - - -INCLUDES = \ - -I$(top_srcdir)\ - -I$(top_srcdir)/intl \ - -I$(top_srcdir)/coreapi \ - -I$(top_srcdir)/mediastreamer2/include - -if BUILD_GTK - -bin_PROGRAMS = linphone - -linphone_SOURCES = \ - main.c \ - $(linphone_common_sources) - -linphone_LDADD = $(LIBGTK_LIBS) $(INTLLIBS) \ - $(ORTP_LIBS) \ - $(top_builddir)/mediastreamer2/src/libmediastreamer.la \ - $(top_builddir)/coreapi/liblinphone.la - -endif - -AM_CFLAGS=$(STRICT_OPTIONS) $(LIBGTK_CFLAGS) $(IPV6_CFLAGS) \ - $(ORTP_CFLAGS) $(OSIP_CFLAGS) - -@INTLTOOL_SERVER_RULE@ - -if BUILD_GNOME_APPLET - -gnome_appletdir=$(libexecdir) - -gnome_applet_PROGRAMS = linphone_applet - -linphone_applet_SOURCES = \ - $(linphone_common_sources)\ - applet.c - -linphone_applet_CFLAGS=$(AM_CFLAGS) $(GNOME_APPLETS_CFLAGS) -DLINPHONE_APPLET - -linphone_applet_LDADD = \ - $(GNOME_APPLETS_LIBS) \ - $(top_builddir)/coreapi/liblinphone.la \ - $(OSIP_LIBS) - - -serverdir = $(libdir)/bonobo/servers -server_in_files = GNOME_LinphoneApplet.server.in -server_DATA = $(server_in_files:.server.in=.server) - -$(server_in_files): $(server_in_files:.server.in=.server.in.in) - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ - - -uidir = $(datadir)/gnome-2.0/ui -ui_DATA = GNOME_LinphoneApplet.xml - -endif - -EXTRA_DIST = \ - GNOME_LinphoneApplet.server.in.in \ - applet.c \ - $(ui_DATA) - -DISTCLEANFILES=GNOME_LinphoneApplet.server.in GNOME_LinphoneApplet.server diff --git a/linphone/gtk/addressbook.c b/linphone/gtk/addressbook.c deleted file mode 100644 index edefde3d0..000000000 --- a/linphone/gtk/addressbook.c +++ /dev/null @@ -1,306 +0,0 @@ -/*************************************************************************** - addressbook.c - - ------------------- - begin : Wed Jan 30 2002 - copyright : (C) 2002 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - - -#include "linphone.h" - -#define get_address_book() (&uiobj->addressbook) -#define get_main_window() (&uiobj->main_window) -#define get_core() (uiobj->core) -#define get_uiobj() (uiobj) - -void fill_address_book(GtkWidget *address_list); - -void ab_destroyed(){ - get_uiobj()->ab=NULL; -} - -void show_address_book(){ - if (get_uiobj()->ab!=NULL){ - gtk_widget_show(get_uiobj()->ab); - }else{ - get_uiobj()->ab=create_and_fill_address_book(); - g_signal_connect(G_OBJECT(get_uiobj()->ab),"destroy",G_CALLBACK(ab_destroyed),NULL); - gtk_widget_show(get_uiobj()->ab); - } -} - -#define GLADE_HOOKUP_OBJECT(component,widget,name) \ - g_object_set_data_full (G_OBJECT (component), name, \ - gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) - -void contact_draw(GtkWidget *w, LinphoneProxyConfig *cfg){ - GtkWidget *table=lookup_widget(w,"table10"); - GtkWidget *combo; - combo=proxy_combo_box_new(cfg); - gtk_widget_show(combo); - gtk_table_attach(GTK_TABLE(table),combo,1,2,2,3, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - GLADE_HOOKUP_OBJECT(w,combo,"proxy"); - combo=gtk_combo_box_new_text(); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo),_("Wait")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo),_("Deny")); - gtk_combo_box_append_text(GTK_COMBO_BOX(combo),_("Accept")); - gtk_widget_show(combo); - gtk_table_attach(GTK_TABLE(table),combo,1,2,3,4, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - GLADE_HOOKUP_OBJECT(w,combo,"pol"); -} - -GtkWidget * contact_new(LinphoneFriend *lf, GtkWidget *ab){ - GtkWidget *w=create_contact_box(); - contact_draw(w,NULL); - gtk_widget_show(w); - g_object_set_data(G_OBJECT(w),"friend_ref",(gpointer)lf); - g_object_set_data(G_OBJECT(w),"address_book",(gpointer)ab); - g_object_set_data(G_OBJECT(w),"add",GINT_TO_POINTER(TRUE)); - gtk_combo_box_set_active(GTK_COMBO_BOX(lookup_widget(w,"pol")),lf->pol); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(w,"send_subscribe")),lf->subscribe); - return w; -} - -GtkWidget * contact_edit(LinphoneFriend *lf, GtkWidget *ab){ - GtkWidget *w=create_contact_box(); - gchar *tmpstr; - contact_draw(w,lf->proxy); - - g_object_set_data(G_OBJECT(w),"friend_ref",(gpointer)lf); - linphone_friend_edit(lf); - tmpstr=linphone_friend_get_name(lf); - if (tmpstr!=NULL) { - gtk_entry_set_text(GTK_ENTRY(lookup_widget(w,"name")),tmpstr); - g_free(tmpstr); - } - tmpstr=linphone_friend_get_addr(lf); - gtk_entry_set_text(GTK_ENTRY(lookup_widget(w,"sipaddr")),tmpstr); - g_free(tmpstr); - - gtk_combo_box_set_active(GTK_COMBO_BOX(lookup_widget(w,"pol")),lf->pol); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(w,"send_subscribe")),lf->subscribe); - - gtk_widget_show(w); - if (ab!=NULL) g_object_set_data(G_OBJECT(w),"address_book",(gpointer)ab); - return w; -} - -GtkWidget * subscriber_edit(LinphoneFriend *lf){ - GtkWidget *w=contact_edit(lf,NULL); - g_object_set_data(G_OBJECT(w),"add",GINT_TO_POINTER(TRUE)); - return w; -} - -gint contact_ok(GtkWidget *dialog){ - gchar *name,*sipaddr; - gchar *url; - gboolean add=FALSE; - GtkWidget *ab; - LinphoneFriend *lf; - int err; - lf=(LinphoneFriend*)g_object_get_data(G_OBJECT(dialog),"friend_ref"); - add=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(dialog),"add")); - name=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(dialog,"name")),0,-1); - sipaddr=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(dialog,"sipaddr")),0,-1); - url=g_strdup_printf("%s <%s>",name,sipaddr); - /* workaround a bug in osip ? */ - /* something doesn't like addresses like "machin <>" */ - if (strchr(sipaddr,'<')==NULL){ - err=linphone_friend_set_sip_addr(lf,url); - }else err=-1; - if (err<0){ - linphone_gnome_ui_display_something(get_uiobj(),GTK_MESSAGE_WARNING,_("Bad sip address: a sip address looks like sip:user@domain")); - linphone_friend_destroy(lf); - g_free(name); - g_free(sipaddr); - g_free(url); - return -1; - } - g_free(name); - g_free(sipaddr); - g_free(url); - linphone_friend_set_proxy(lf,proxy_combo_box_get_selected(lookup_widget(dialog,"proxy"))); - linphone_friend_set_inc_subscribe_policy(lf,gtk_combo_box_get_active(GTK_COMBO_BOX(lookup_widget(dialog,"pol")))); - linphone_friend_send_subscribe(lf,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog,"send_subscribe")))); - if (add){ - linphone_core_add_friend(get_core(),lf); - } - else linphone_friend_done(lf); - /* ask the address book to redraw itself */ - ab=g_object_get_data(G_OBJECT(dialog),"address_book"); - if (ab!=NULL) fill_address_book(lookup_widget(ab,"address_list")); - return 0; -} - -enum{ - SIP_ADDRESS_COLUMN, - FRIEND_REFERENCE, - AB_NCOLUMNS -}; - -void choose_address_and_close(GtkWidget *ab){ - GtkTreeSelection *select; - GtkWidget *addressentry=get_main_window()->addressentry; - GtkTreeIter iter; - GtkTreeModel *model; - gchar *address=NULL; - GtkWidget *address_list=lookup_widget(ab,"address_list"); - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (address_list)); - if (select==NULL) return; - if (gtk_tree_selection_get_selected (select, &model, &iter)) - { - gtk_tree_model_get (model, &iter,SIP_ADDRESS_COLUMN , &address, -1); - } - if (address!=NULL){ - gtk_entry_set_text (GTK_ENTRY(addressentry),address); - g_free(address); - } - gtk_widget_destroy(ab); -} -void -address_book_close (GtkWidget *object, - gpointer user_data) -{ - gtk_widget_destroy(gtk_widget_get_toplevel(object)); -} - -void address_selection_changed_cb(GtkTreeSelection *selection, gpointer data) -{ - -} -gboolean address_button_press(GtkWidget *widget,GdkEventButton *event,gpointer user_data) -{ - GtkWidget *ab=(GtkWidget*)user_data; - if (event->type==GDK_2BUTTON_PRESS){ - choose_address_and_close(ab); - return TRUE; - } - return FALSE; -} - -void fill_address_book(GtkWidget *address_list){ - GtkListStore *store; - GtkTreeIter iter; - GtkTreeModel *model; - const MSList *elem; - gchar *tmpstr; - /* fill the store */ - elem=linphone_core_get_friend_list(get_core()); - model=gtk_tree_view_get_model(GTK_TREE_VIEW(address_list)); - store=GTK_LIST_STORE(model); - gtk_list_store_clear(store); - for(;elem!=NULL;elem=ms_list_next(elem)){ - LinphoneFriend *lf=(LinphoneFriend*)elem->data; - tmpstr=linphone_friend_get_url(lf); - gtk_list_store_append(store,&iter); - gtk_list_store_set(store,&iter,SIP_ADDRESS_COLUMN,tmpstr,FRIEND_REFERENCE,(gpointer)lf,-1); - ms_free(tmpstr); - } -} - -GtkWidget *create_and_fill_address_book(){ - GtkListStore *store; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkTreeSelection *select; - GtkWidget *address_list; - GtkWidget *ret=create_address_book(); - - address_list=lookup_widget(ret,"address_list"); - store = gtk_list_store_new (AB_NCOLUMNS, G_TYPE_STRING,G_TYPE_POINTER); - gtk_tree_view_set_model(GTK_TREE_VIEW(address_list),GTK_TREE_MODEL(store)); - g_object_unref(G_OBJECT(store)); - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Contact list"), - renderer, - "text", SIP_ADDRESS_COLUMN, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (address_list), column); - - /* Setup the selection handler */ - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (address_list)); - gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); - g_signal_connect (G_OBJECT (select), "changed", - G_CALLBACK (address_selection_changed_cb), - NULL); - - /* setup handler for double click */ - g_signal_connect(G_OBJECT(address_list),"button-press-event",G_CALLBACK(address_button_press),(gpointer)ret); - - fill_address_book(address_list); - return ret; -} - -void -on_modify_address_clicked (GtkButton *button, - gpointer user_data) -{ - GtkTreeSelection *select; - GtkTreeIter iter; - GtkTreeModel *model; - GtkWidget *address_list=lookup_widget(gtk_widget_get_toplevel(GTK_WIDGET(button)),"address_list"); - - /* change the address in the view */ - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (address_list)); - if (gtk_tree_selection_get_selected (select, &model, &iter)) - { - LinphoneFriend *lf=NULL; - gtk_tree_model_get(model,&iter,FRIEND_REFERENCE,&lf,-1); - contact_edit(lf,gtk_widget_get_toplevel(GTK_WIDGET(button))); - } -} - -void on_add_address_clicked(GtkButton *button,gpointer user_data) -{ - LinphoneFriend *lf=linphone_friend_new(); - contact_new(lf,gtk_widget_get_toplevel(GTK_WIDGET(button))); -} - -void on_remove_address_clicked(GtkButton *button,gpointer user_data) -{ - GtkTreeSelection *select; - GtkTreeIter iter; - GtkTreeModel *model; - GtkWidget *address_list=lookup_widget(gtk_widget_get_toplevel(GTK_WIDGET(button)),"address_list"); - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (address_list)); - if (gtk_tree_selection_get_selected (select, &model, &iter)) - { - LinphoneFriend *lf=NULL; - gtk_tree_model_get(model,&iter,FRIEND_REFERENCE,&lf,-1); - linphone_core_remove_friend(get_core(),lf); - gtk_list_store_remove(GTK_LIST_STORE(model), &iter); - } -} - -void on_select_address_clicked(GtkButton *button,gpointer user_data) -{ - choose_address_and_close(gtk_widget_get_toplevel(GTK_WIDGET(button))); -} - - -void -on_contact_box_response (GtkDialog *dialog, - gint response_id, - gpointer user_data) -{ - switch (response_id){ - case GTK_RESPONSE_OK: - contact_ok(GTK_WIDGET(dialog)); - break; - default: - break; - } - gtk_widget_destroy(GTK_WIDGET(dialog)); -} diff --git a/linphone/gtk/addressbook.h b/linphone/gtk/addressbook.h deleted file mode 100644 index f5f5431e3..000000000 --- a/linphone/gtk/addressbook.h +++ /dev/null @@ -1,28 +0,0 @@ -/*************************************************************************** - addressbook.h - - ------------------- - begin : Wed Jan 30 2002 - copyright : (C) 2002 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - - -#ifndef ADDRESSBOOK_H -#define ADDRESSBOOK_H - -GtkWidget *create_and_fill_address_book(); -void show_address_book(); -GtkWidget * contact_new(LinphoneFriend *lf, GtkWidget *ab); -GtkWidget * contact_edit(LinphoneFriend *lf, GtkWidget *ab); -GtkWidget * subscriber_edit(LinphoneFriend *lf); - -#endif diff --git a/linphone/gtk/applet.c b/linphone/gtk/applet.c deleted file mode 100644 index 68149e652..000000000 --- a/linphone/gtk/applet.c +++ /dev/null @@ -1,185 +0,0 @@ -/*************************************************************************** - applet.c - Applet code for linphone's gnome - interface - ------------------- - begin : Sat Dec 14 2002 - copyright : (C) 2001 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include "linphone.h" - -#define get_uiobj() (uiobj) - -LinphoneCore core; -LinphoneGnomeUI ui; -static int show=0; -static gulong signal_ref; -static GtkWidget *applet_button=NULL; -static GdkPixbuf *original_icon=NULL; -static GtkWidget *icon=NULL; - -void draw_icon(GtkWidget *button, int size) -{ - GdkPixbuf *resized; - if (original_icon==NULL){ - original_icon=gdk_pixbuf_new_from_file(PACKAGE_DATA_DIR "/pixmaps/linphone/linphone2.xpm", - NULL); - g_return_if_fail( original_icon!=NULL); - } - if (icon!=NULL){ - gtk_container_remove(GTK_CONTAINER(button),icon); - gtk_widget_destroy(icon); - } - resized=gdk_pixbuf_scale_simple(original_icon,size,size,GDK_INTERP_BILINEAR); - g_return_if_fail(resized!=NULL); - icon=gtk_image_new_from_pixbuf(resized); - g_return_if_fail(icon!=NULL); - gdk_pixbuf_unref(resized); - gtk_container_add(GTK_CONTAINER(button),icon); - gtk_widget_show(icon); -} - -void linphone_applet_about_cb(gpointer p) -{ - GtkWidget *about2; - about2 = create_about2 (); - gtk_widget_show (about2); -} - - - -static void applet_change_pixel_size(GtkWidget *applet, int size) -{ - g_return_if_fail(applet_button!=NULL); - draw_icon(applet_button,size); -} - -static void applet_destroy_cb(GtkWidget *widget, gpointer data) -{ - if (get_uiobj()->main_window.window!=NULL){ - gtk_widget_destroy(get_uiobj()->main_window.window); - } - linphone_gnome_uninit(get_uiobj()); -} - -static gboolean -gui_destroy_cb (GtkWidget *widget, gpointer data) -{ - linphone_gnome_ui_uninit(get_uiobj()); - show=0; - return FALSE; -} - -static gboolean button_press_cb(GtkWidget *applet, GdkEventButton* event, gpointer data) -{ - if (event->button!=1) return FALSE; - if (show){ - g_signal_handlers_disconnect_by_func(G_OBJECT(get_uiobj()->main_window.window), - G_CALLBACK(gui_destroy_cb),NULL); - linphone_gnome_ui_hide(get_uiobj()); - - show=0; - }else { - linphone_gnome_ui_show(get_uiobj()); - signal_ref=g_signal_connect(G_OBJECT(get_uiobj()->main_window.window), - "destroy", - G_CALLBACK(gui_destroy_cb),NULL); - show=1; - } - return FALSE; -} - -const BonoboUIVerb linphone_applet_menu_verbs [] = { - BONOBO_UI_UNSAFE_VERB ("About", linphone_applet_about_cb), - BONOBO_UI_VERB_END -}; - -static gboolean -linphone_applet_fill (PanelApplet *applet) -{ - gint size=panel_applet_get_size(applet); - - applet_button=gtk_frame_new(NULL); - gtk_container_add(GTK_CONTAINER(applet),applet_button); - gtk_widget_show(applet_button); - - draw_icon(applet_button,size); - - g_signal_connect(G_OBJECT(applet),"button-press-event",G_CALLBACK(button_press_cb),NULL); - - - g_signal_connect(G_OBJECT(applet),"change_size", - G_CALLBACK(applet_change_pixel_size), - NULL); - - - g_signal_connect (G_OBJECT (applet), "destroy", - G_CALLBACK (applet_destroy_cb), NULL); - - //sizehint = panel_applet_get_size (PANEL_APPLET (applet)); - panel_applet_setup_menu_from_file (applet, - NULL, - "GNOME_LinphoneApplet.xml", - NULL, - linphone_applet_menu_verbs, - NULL); - - /* tracing for osip */ - TRACE_INITIALIZE(5,stdout); - - linphone_gnome_init(&ui,&core); - gtk_widget_show_all (GTK_WIDGET (applet)); - - return TRUE; -} - - -static gboolean -linphone_applet_factory (PanelApplet *applet, - const gchar *iid, - gpointer data) -{ - static int instances=0; - GtkWidget *dialog; - if (!strcmp (iid, "OAFIID:GNOME_LinphoneApplet")){ - if (instances>0){ - dialog = gtk_message_dialog_new (GTK_WINDOW(applet), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_CLOSE, - (const gchar*) _("Cannot run multiples instances of the linphone applet.")); - /* Destroy the dialog when the user responds to it (e.g. clicks a button) */ - g_signal_connect_swapped (G_OBJECT (dialog), "response", - G_CALLBACK (gtk_widget_destroy), - G_OBJECT (dialog)); - gtk_widget_show(GTK_WIDGET(dialog)); - return FALSE; - } - return linphone_applet_fill (applet); - } - return FALSE; -} - -#define GNOMELOCALEDIR PACKAGE_LOCALE_DIR - -PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_LinphoneApplet_Factory", - PANEL_TYPE_APPLET, - "linphone_applet", - "0", - linphone_applet_factory, - NULL) diff --git a/linphone/gtk/callbacks.c b/linphone/gtk/callbacks.c deleted file mode 100644 index 78f293db6..000000000 --- a/linphone/gtk/callbacks.c +++ /dev/null @@ -1,707 +0,0 @@ -/* -linphone -Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr) - -callbacks.c -- gtk callbacks, and osipua callbacks. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "linphone.h" -#include - -#define get_core() (uiobj->core) -#define get_main_window() (&uiobj->main_window) -#define get_uiobj() (uiobj) - -void -on_about1_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - GtkWidget *about2; - about2 = create_about2 (); - gtk_widget_show (about2); -} - - -gint -on_prop1_close (GtkDialog *gnomedialog, - gpointer user_data) -{ -#ifdef NOTYET - LinphoneMainWindow *obj=get_main_window(); - gnome_appbar_clear_stack( GNOME_APPBAR(obj->status_bar)); -#endif - - return(FALSE); -} - -void -on_parametres1_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - LinphoneGnomeUI *ui=get_uiobj(); - linphone_property_box_init(&ui->propbox); -} - - - -void -on_user_manual1_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ -#ifdef NOTYET - gnome_help_display("index.xml",NULL,NULL); -#endif -} - - -gboolean -on_play_vol_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - int vol; - vol=(gtk_range_get_adjustment(GTK_RANGE(widget)))->value; - linphone_core_set_play_level(get_core(),vol); - return FALSE; -} - - -gboolean -on_rec_vol_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - int vol; - vol=(gtk_range_get_adjustment(GTK_RANGE(widget)))->value; - linphone_core_set_rec_level(get_core(),vol); - return FALSE; -} - - -gboolean -on_ring_vol_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - int vol; - vol=(gtk_range_get_adjustment(GTK_RANGE(widget)))->value; - linphone_core_set_ring_level(get_core(),vol); - return FALSE; -} - - -void -on_prop1_help (GtkDialog *gnomepropertybox, - gint arg1, - gpointer user_data) -{ -#ifdef NOTYET - gnome_help_display("index.html",NULL,NULL); -#endif -} - - - - -void -on_fermer1_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - linphone_gnome_ui_hide(get_uiobj()); -} - - - -#if 0 -/*this is when the panel size changes*/ -void applet_change_pixel_size(GtkWidget *w, int size, gpointer data) -{ - GtkWidget *pixmap,*button; - - pixmap=gtk_object_get_data(GTK_OBJECT(applet),"applet_pixmap"); - button=(GtkWidget*)gtk_object_get_data(GTK_OBJECT(applet),"applet_button"); - if (button==NULL) - { - printf("Cannot find applet button\n"); - return; - } - if (pixmap!=NULL) gtk_widget_destroy(pixmap); - pixmap = gnome_pixmap_new_from_xpm_d_at_size(linphone2_xpm, - size-4, size-4); - gtk_object_set_data(GTK_OBJECT(applet),"applet_pixmap",pixmap); - gtk_widget_show(pixmap); - gtk_container_add(GTK_CONTAINER(button), pixmap); -} -#endif - -void -on_adresse_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - show_address_book(); -} - -void on_address_book_show(GtkWidget *widget,gpointer user_data) -{ - -} - - - -void -on_showmore_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - gint state; - GtkWidget *optioncontrols=get_main_window()->optioncontrols; - state=gtk_toggle_button_get_active(togglebutton); - if (state) gtk_widget_show(optioncontrols); - else { - gtk_widget_hide(optioncontrols); - } -} - - -void -on_useRPC_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ -#ifdef VINCENT_MAURY_RSVP - LinphoneCore *lc=get_core(); - gboolean state; - state=gtk_toggle_button_get_active(togglebutton); - /* change RPC settings according to state */ - if (state) - { - if (linphone_core_set_rpc_mode(lc,1)!=0) /* set rpc on */ - { - printf("RPC error. unable to set rpc on !\n"); - printf("Check to see if RPC server is running\n"); - gtk_toggle_button_set_active(togglebutton,FALSE); - /*linphone_core_set_rpc_mode(lc,0);*/ - } - } - else - { - if (linphone_core_set_rpc_mode(lc,0)!=0) /* set rpc off */ - printf("RPC error. That's impossible !!\n"); - } -#endif -} - -void -on_useRSVP_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ -#ifdef VINCENT_MAURY_RSVP - LinphoneCore *lc=get_core(); - LinphoneGnomeUI *ui=get_uiobj(); - gboolean state; - state=gtk_toggle_button_get_active(togglebutton); - /* change the QoS settings function of the state */ - if (state) - { - linphone_core_set_rsvp_mode(lc,1); /* set RSVP on */ - gtk_widget_show(lookup_widget(ui->propbox.prop,"useRPC")); /* show RPC checkbox */ - } - else - { - linphone_core_set_rsvp_mode(lc,0); /* set RSVP off */ - /* uncheck RPC if necessary and hide RPC checkbox */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( - lookup_widget(ui->propbox.prop,"useRPC")),FALSE); - gtk_widget_hide(lookup_widget(ui->propbox.prop,"useRPC")); - } -#endif -} - -#ifdef VINCENT_MAURY_RSVP -/* callback called when you click the yes/no dialog box - * send yes or no to the core_change_qos which knows the question - * and will be able to ajust qos */ -void dialog_click (GtkDialog *dialog,gint arg1,gpointer user_data) -{ - LinphoneCore *lc=get_core(); - if (lc->call==NULL) - return; - - if (arg1==GTK_RESPONSE_YES) - { - printf("YES\n"); - linphone_core_change_qos(lc, 1); /* 1 = yes */ - } - else - { - printf("NO\n"); - linphone_core_change_qos(lc, 0); /* 0 = no */ - } - gtk_widget_destroy((GtkWidget*)dialog); -} -#endif - - -void -on_alt_href_clicked (GtkButton *button, - gpointer user_data) -{ -#ifdef NOTYET - gchar *url; - GtkWidget *label; - osip_from_t * from; - LinphoneGnomeUI *ui=get_uiobj(); - label=GTK_BIN(button)->child; - gtk_label_get(GTK_LABEL(label),&url); - osip_from_init(&from); - if ( osip_from_parse(from,url) <0){ - /* do something here */ - }else - { /* it was a sip url, so display it in the entry*/ - gtk_entry_set_text(GTK_ENTRY(gnome_entry_gtk_entry(GNOME_ENTRY(ui->main_window.addressentry))),url); - } - osip_from_free(from); -#endif -} - -void -on_alt_href_realize (GtkWidget *widget, - gpointer user_data) -{ - GdkCursor *cursor = gdk_cursor_new(GDK_HAND2); - gdk_window_set_cursor(widget->window, cursor); - gdk_cursor_destroy(cursor); -} - - -void -on_dtmf_3_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"3"); -} - - -void -on_dmtf_2_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"2"); -} - - -void -on_dtmf_1_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"1"); -} - - -void -on_dtmf_4_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"4"); -} - - -void -on_dtmf_5_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"5"); -} - - -void -on_dtmf_6_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"6"); -} - - -void -on_dtmf_7_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"7"); -} - - -void -on_dtmf_8_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"8"); - -} - - -void -on_dtmf_9_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"9"); - -} - - -void -on_dtmf_star_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"*"); - -} - - -void -on_dtmf_0_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"0"); - -} - - -void -on_dtmf_pound_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *dtmf_entry=get_main_window()->dtmfentry; - gtk_entry_append_text(GTK_ENTRY(dtmf_entry),"#"); - -} - - -void -on_dtmf_entry_changed (GtkEditable *editable, - gpointer user_data) -{ - gchar *dtmfs; - gint len; - /* get the last entry in the text box and plays it */ - dtmfs=gtk_editable_get_chars(editable,0,-1); - g_return_if_fail(dtmfs!=NULL); - len=strlen(dtmfs); - if (len>0){ - g_message("Sending dtmf %c",dtmfs[len-1]); - linphone_core_send_dtmf(get_uiobj()->core,dtmfs[len-1]); - } - g_free(dtmfs); -} - - -void -on_exit1_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ -#ifdef LINPHONE_APPLET -#else - gtk_widget_destroy(get_uiobj()->main_window.window); -#endif -} - - -void on_app1_destroy(GtkWidget *app1, gpointer user_data) -{ -#ifdef LINPHONE_APPLET -#else - gtk_main_quit(); -#endif -} - -void -on_display_ab_clicked (GtkButton *button, - gpointer user_data) -{ - show_address_book(); -} - - -void -on_inc_subscr_dialog_response (GtkDialog *dialog, - gint response_id, - gpointer user_data) -{ - LinphoneFriend *lf=(LinphoneFriend*)g_object_get_data(G_OBJECT(dialog),"friend_ref"); - switch(response_id){ - case GTK_RESPONSE_ACCEPT: - subscriber_edit(lf); - break; - case GTK_RESPONSE_REJECT: - linphone_core_reject_subscriber(get_core(),lf); - break; - } - gtk_widget_destroy(GTK_WIDGET(dialog)); -} - -void authentication_dialog_ok(GtkWidget *w) -{ - gchar *realm,*username,*userid,*passwd; - LinphoneAuthInfo *info; - realm=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(w,"realm")),0,-1); - username=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(w,"username")),0,-1); - userid=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(w,"userid")),0,-1); - passwd=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(w,"passwd")),0,-1); - info=linphone_auth_info_new(username,userid,passwd,NULL,realm); - linphone_core_add_auth_info(get_core(),info); - g_free(username); - g_free(userid); - g_free(passwd); - g_free(realm); -} - -void -on_authentication_dialog_response (GtkDialog *dialog, - gint response_id, - gpointer user_data) -{ - switch(response_id){ - case GTK_RESPONSE_OK: - authentication_dialog_ok(GTK_WIDGET(dialog)); - gtk_widget_destroy(GTK_WIDGET(dialog)); - break; - case GTK_RESPONSE_CANCEL: - gtk_widget_destroy(GTK_WIDGET(dialog)); - } -} - -void -on_clear_auth_info_clicked (GtkButton *button, - gpointer user_data) -{ - linphone_core_clear_all_auth_info(get_core()); -} - - -void -on_call_history_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - linphone_gnome_show_call_logs_window(get_uiobj()); -} - - -void -on_call_logs_response (GtkDialog *dialog, - gint response_id, - gpointer user_data) -{ - gtk_widget_destroy(GTK_WIDGET(dialog)); -} - - -void -on_call_logs_destroy (GtkObject *object, - gpointer user_data) -{ - get_uiobj()->logs=NULL; -} - - -static void completion_add_text(GtkEntry *entry, const char *text){ - GtkTreeIter iter; - GtkTreeModel *model=gtk_entry_completion_get_model(gtk_entry_get_completion(entry)); - - if (gtk_tree_model_get_iter_first(model,&iter)){ - do { - gchar *uri=NULL; - gtk_tree_model_get(model,&iter,0,&uri,-1); - if (uri!=NULL){ - if (strcmp(uri,text)==0) { - /*remove text */ - gtk_list_store_remove(GTK_LIST_STORE(model),&iter); - g_free(uri); - break; - } - g_free(uri); - } - }while (gtk_tree_model_iter_next(model,&iter)); - } - /* and prepend it on top of the list */ - gtk_list_store_prepend(GTK_LIST_STORE(model),&iter); - gtk_list_store_set(GTK_LIST_STORE(model),&iter,0,text,-1); -} - - -void -on_callbutton_clicked (GtkButton *button, - gpointer user_data) -{ - LinphoneGnomeUI *ui=get_uiobj(); - LinphoneCore *lc=get_core(); - GtkEntry *entry=GTK_ENTRY(ui->main_window.addressentry); - - if (lc->call==NULL){ - const gchar *sipurl=NULL; - int err; - /* we have no dialog in progress */ - /* get the url to call */ - sipurl=gtk_entry_get_text(entry); - err=linphone_core_invite(lc,sipurl); - if (err==0) completion_add_text(entry,sipurl); - }else { - linphone_core_accept_call(lc,NULL); - gdk_window_set_keep_above (ui->main_window.window->window, 0); - } -} - -void -on_hangup_clicked (GtkButton *button, - gpointer user_data) -{ - LinphoneGnomeUI *ui=get_uiobj(); - LinphoneCore *lc=get_core(); - gdk_window_set_keep_above (ui->main_window.window->window, 0); - if (lc->call!=NULL){ - gtk_window_set_title(GTK_WINDOW(ui->main_window.window),"linphone"); - linphone_core_terminate_call(lc,NULL); - } -} - -GtkWidget *chatroom_new(const gchar *url, LinphoneChatRoom *cr){ - GtkWidget *gcr=NULL; - if (cr==NULL) - cr=linphone_core_create_chat_room(get_core(),url); - if (cr!=NULL){ - gchar *tmp; - gcr=create_chatroom(); - g_object_set_data(G_OBJECT(gcr),"chatroom",(gpointer)cr); - linphone_chat_room_set_user_data(cr,(gpointer)gcr); - tmp=g_strdup_printf(_("Chat with %s"),url); - gtk_window_set_title(GTK_WINDOW(gcr),tmp); - g_free(tmp); - } - return gcr; -} - -void chatroom_append(GtkWidget *gcr, const gchar *from, const gchar *message){ - GtkTextBuffer *tb; - gchar *str; - GtkTextIter enditer; - GtkTextView *tv=GTK_TEXT_VIEW(lookup_widget(gcr,"chattext")); - tb=gtk_text_view_get_buffer(tv); - g_return_if_fail(tb!=NULL); - gtk_text_buffer_get_end_iter(tb,&enditer); - str=g_strdup_printf("[%s]\t:%s\n",from,message); - gtk_text_buffer_insert(tb,&enditer,str,strlen(str)); - g_free(str); -} - -void chatroom_close(GtkWidget *gcr){ - LinphoneChatRoom *cr; - cr=(LinphoneChatRoom*)g_object_get_data(G_OBJECT(gcr),"chatroom"); - linphone_chat_room_destroy(cr); -} - - -void -on_chat_clicked (GtkButton *button, - gpointer user_data) -{ - gchar *sipurl; - - sipurl=gtk_editable_get_chars(GTK_EDITABLE(get_main_window()->addressentry),0,-1); - GtkWidget *gcr=chatroom_new(sipurl,NULL); - if (gcr!=NULL) gtk_widget_show(gcr); - g_free(sipurl); -} - - -void -on_chatbox_clicked (GtkButton *button, - gpointer user_data) -{ - gtk_widget_destroy(gtk_widget_get_toplevel(GTK_WIDGET(button))); -} - - - -void -on_chatentry_activate (GtkEntry *entry, - gpointer user_data) -{ - LinphoneChatRoom *cr; - gchar *text; - text=gtk_editable_get_chars(GTK_EDITABLE(entry),0,-1); - if (strlen(text)>0){ - GtkWidget *gcr=gtk_widget_get_toplevel(GTK_WIDGET(entry)); - cr=(LinphoneChatRoom*)g_object_get_data(G_OBJECT(gcr),"chatroom"); - linphone_chat_room_send_message(cr,text); - chatroom_append(gcr,linphone_core_get_primary_contact(get_core()),text); - gtk_editable_delete_text(GTK_EDITABLE(entry),0,-1); - } -} - -void -on_chatroom_destroy (GtkObject *object, - gpointer user_data) -{ - chatroom_close(GTK_WIDGET(object)); -} - - - -void -on_addressentry_activate (GtkEntry *entry, - gpointer user_data) -{ - on_callbutton_clicked(NULL,NULL); -} - -void -on_addressentry_destroy (GtkObject *object, - gpointer user_data) -{ - linphone_gnome_save_uri_history(get_uiobj()); -} - -void -on_video_enabled_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - bool_t enabled=gtk_toggle_button_get_active(togglebutton); - linphone_core_enable_video(get_core(),enabled,enabled); -} - - -void -on_echocancelation_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - linphone_core_enable_echo_cancelation(get_core(), - gtk_toggle_button_get_active(togglebutton)); -} - - - - diff --git a/linphone/gtk/callbacks.h b/linphone/gtk/callbacks.h deleted file mode 100644 index 505539c47..000000000 --- a/linphone/gtk/callbacks.h +++ /dev/null @@ -1,545 +0,0 @@ -#include - - -void -on_app1_destroy (GtkObject *object, - gpointer user_data); - -void -on_adresse_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_parametres1_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_fermer1_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_exit1_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_about1_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_user_manual1_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_greenbutton_clicked (GtkButton *button, - gpointer user_data); - -void -on_redbutton_clicked (GtkButton *button, - gpointer user_data); - -void -on_showmore_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -gboolean -on_play_vol_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); - -gboolean -on_rec_vol_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); - -gboolean -on_ring_vol_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); - -void -on_reachable (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_busy (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_minutesaway_changed (GtkEditable *editable, - gpointer user_data); - -void -on_away (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_do_not_disturb (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_moved_tmply (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_alt_serv (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_contact_field_changed (GtkEditable *editable, - gpointer user_data); - -void -on_presence_validate_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_entry_changed (GtkEditable *editable, - gpointer user_data); - -void -on_dtmf_3_clicked (GtkButton *button, - gpointer user_data); - -void -on_dmtf_2_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_1_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_4_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_5_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_6_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_7_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_8_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_9_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_star_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_0_clicked (GtkButton *button, - gpointer user_data); - -void -on_dtmf_pound_clicked (GtkButton *button, - gpointer user_data); - -void -on_propertybox1_apply (GtkDialog *propertybox, - gint page_num, - gpointer user_data); - -void -on_property_box_response (GtkDialog *dialog, - gint response_id, - gpointer user_data); - -gboolean -on_prop1_close (GtkDialog *gnomedialog, - gpointer user_data); - -void -on_prop1_help (GtkDialog *propertybox, - gint page_num, - gpointer user_data); - -gboolean -on_hscale1_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); - -void -on_audioport_changed (GtkEditable *editable, - gpointer user_data); - -void -on_sipport_changed (GtkEditable *editable, - gpointer user_data); - -void -on_user_name_changed (GtkEditable *editable, - gpointer user_data); - -void -on_domain_name_changed (GtkEditable *editable, - gpointer user_data); - -void -on_registrar_checked_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_rsvp_checked_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - - -void -on_redirect_button_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_proxy_button_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_obproxy_button_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_registrar_addr_changed (GtkEditable *editable, - gpointer user_data); - -void -on_reg_passwd_changed (GtkEditable *editable, - gpointer user_data); - -void -on_address_of_record_changed (GtkEditable *editable, - gpointer user_data); - -void -on_aucodec_up_clicked (GtkButton *button, - gpointer user_data); - -void -on_aucodec_down_clicked (GtkButton *button, - gpointer user_data); - -void -on_aucodec_enable_clicked (GtkButton *button, - gpointer user_data); - -void -on_aucodec_disable_clicked (GtkButton *button, - gpointer user_data); - -void -on_sounddriver_changed (GtkEditable *editable, - gpointer user_data); - -void -on_source_changed (GtkEditable *editable, - gpointer user_data); - -void -on_autokill_button1_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_address_book_show (GtkWidget *widget, - gpointer user_data); - -void -on_add_address_clicked (GtkButton *button, - gpointer user_data); - -void -on_remove_address_clicked (GtkButton *button, - gpointer user_data); - -void -on_select_address_clicked (GtkButton *button, - gpointer user_data); - -void -on_modify_address_clicked (GtkButton *button, - gpointer user_data); - -void -on_alt_href_clicked (GtkButton *button, - gpointer user_data); - -void -on_alt_href_realize (GtkWidget *widget, - gpointer user_data); - - -void -on_exit1_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -address_book_close (GtkButton *button, - gpointer user_data); - -void -on_card_changed (GtkEditable *editable, - gpointer user_data); - -void -on_audio_jittcomp_value_changed (GtkRange *range, - gpointer user_data); - -void -on_enable_nat_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_nat_address_changed (GtkEditable *editable, - gpointer user_data); - -void -on_display_ab_clicked (GtkButton *button, - gpointer user_data); - -void -on_ringfileentry_changed (GtkEditable *editable, - gpointer user_data); - -void -on_ringpreview_clicked (GtkButton *button, - gpointer user_data); - -gboolean -on_property_box_closed (GtkDialog *gnomedialog, - gpointer user_data); - -void -on_address_book_close (GtkObject *object, - gpointer user_data); - -#ifndef VERSION -# define VERSION LINPHONE_VERSION -#endif - -void -on_addfriend_clicked (GtkButton *button, - gpointer user_data); - -void -on_removefriend_clicked (GtkButton *button, - gpointer user_data); - -void -on_add_adbk_clicked (GtkButton *button, - gpointer user_data); - -void -on_addfriend_dialog_response (GtkDialog *dialog, - gint response_id, - gpointer user_data); - -void -on_friendlist_row_activated (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer user_data); -void -on_useRSVP_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_useRPC_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -#ifdef VINCENT_MAURY_RSVP -void -dialog_click (GtkDialog *dialog, - gint arg1, - gpointer user_data); -#endif - -void -on_proxy_config_box_response (GtkDialog *dialog, - gint response_id, - gpointer user_data); - -void -on_removeproxy_button_clicked (GtkButton *button, - gpointer user_data); - -void -on_addproxy_button_clicked (GtkButton *button, - gpointer user_data); - -void -on_editproxy_button_clicked (GtkButton *button, - gpointer user_data); - - -void -on_contact_box_response (GtkDialog *dialog, - gint response_id, - gpointer user_data); - -void -on_inc_subscr_dialog_response (GtkDialog *dialog, - gint response_id, - gpointer user_data); - -void -on_ob_proxy_changed (GtkComboBox *combobox, - gpointer user_data); - -void -on_authentication_dialog_response (GtkDialog *dialog, - gint response_id, - gpointer user_data); - -void -on_clear_auth_info_clicked (GtkButton *button, - gpointer user_data); - -void -on_use_sipinfo_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_guess_hostname_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_call_history_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_call_logs_response (GtkDialog *dialog, - gint response_id, - gpointer user_data); - -void -on_call_logs_destroy (GtkObject *object, - gpointer user_data); - -void -on_enable_ipv6_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_play_card_changed (GtkComboBox *combobox, - gpointer user_data); - -void -on_capt_card_changed (GtkComboBox *combobox, - gpointer user_data); - -void -on_ring_card_changed (GtkComboBox *combobox, - gpointer user_data); - -void -on_callbutton_clicked (GtkButton *button, - gpointer user_data); - -void -on_chatbox_clicked (GtkButton *button, - gpointer user_data); - -void -on_chatentry_activate (GtkEntry *entry, - gpointer user_data); - -void -on_hangup_clicked (GtkButton *button, - gpointer user_data); - -void -on_chat_clicked (GtkButton *button, - gpointer user_data); - -void -on_chatroom_destroy (GtkObject *object, - gpointer user_data); - -void -on_ring_card_changed (GtkComboBox *combobox, - gpointer user_data); - -void -on_addressentry_editing_done (GtkCellEditable *celleditable, - gpointer user_data); - -void -on_addressentry_destroy (GtkObject *object, - gpointer user_data); - -gboolean -on_addressentry_key_pressed (GtkWidget *widget, - GdkEventKey *event, - gpointer user_data); - -void -on_addressentry_changed (GtkComboBox *combobox, - gpointer user_data); - -void -on_addressentry_activate (GtkEntry *entry, - gpointer user_data); - -void -on_addressentry_destroy (GtkObject *object, - gpointer user_data); - -void -on_download_bw_value_changed (GtkSpinButton *spinbutton, - gpointer user_data); - -void -on_download_bw_editing_done (GtkCellEditable *celleditable, - gpointer user_data); - -void -on_download_bw_changed (GtkEditable *editable, - gpointer user_data); - -gboolean -on_upload_bw_output (GtkSpinButton *spinbutton, - gpointer user_data); - -void -on_upload_bw_change_value (GtkSpinButton *spinbutton, - GtkScrollType scroll, - gpointer user_data); - -void -on_upload_bw_value_changed (GtkSpinButton *spinbutton, - gpointer user_data); - -gboolean -on_upload_bw_leave_notify_event (GtkWidget *widget, - GdkEventCrossing *event, - gpointer user_data); - -void -on_video_enabled_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_echocancelation_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_no_nat_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_use_stun_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_static_nat_toggled (GtkToggleButton *togglebutton, - gpointer user_data); - -void -on_stun_server_changed (GtkEditable *editable, - gpointer user_data); diff --git a/linphone/gtk/friends.c b/linphone/gtk/friends.c deleted file mode 100644 index d4da7828e..000000000 --- a/linphone/gtk/friends.c +++ /dev/null @@ -1,127 +0,0 @@ -/*************************************************************************** - friends.c - display of friend's list - - ------------------- - begin : Mon Dec 17 2001 - copyright : (C) 2001 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include "linphone.h" - - -#define get_friend_list() (&uiobj->main_window.friendlist) -#define get_core() (uiobj->core) -#define get_main_window() (&uiobj->main_window) - -enum{ - FRIEND_PRESENCE_IMG, - FRIEND_SIP_ADDRESS, - FRIEND_PRESENCE_STATUS, - FRIEND_ID, - FRIEND_LIST_NCOL -}; - -void friend_list_set_friend_status(FriendList *fl, LinphoneFriend * fid, const gchar *url, const gchar *status, const gchar *img){ - GtkTreeIter iter; - LinphoneFriend *tmp=0; - gboolean found=FALSE; - GtkTreeModel *model=gtk_tree_view_get_model(GTK_TREE_VIEW(fl->friendlist)); - if (gtk_tree_model_get_iter_first(model,&iter)) { - do{ - gtk_tree_model_get(model,&iter,FRIEND_ID,&tmp,-1); - //printf("tmp=%i, fid=%i",tmp,fid); - if (fid==tmp) { - GdkPixbuf *pixbuf; - gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_PRESENCE_STATUS,status,-1); - pixbuf = create_pixbuf(img); - if (pixbuf) - { - gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_PRESENCE_IMG, pixbuf,-1); - } - found=TRUE; - } - }while(gtk_tree_model_iter_next(model,&iter)); - } - if (found==FALSE){ - //printf("Adding new notifier\n"); - GdkPixbuf *pixbuf; - gtk_list_store_append(GTK_LIST_STORE(model),&iter); - gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_SIP_ADDRESS, url, FRIEND_PRESENCE_STATUS,status,FRIEND_ID,fid,-1); - pixbuf = create_pixbuf(img); - if (pixbuf) gtk_list_store_set(GTK_LIST_STORE(model),&iter,FRIEND_PRESENCE_IMG, pixbuf,-1); - } -} - - -void -on_friendlist_row_activated (GtkTreeView *treeview, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer user_data) -{ - GtkTreeSelection *select; - GtkTreeIter iter; - GtkTreeModel *model; - gchar* friend; - select = gtk_tree_view_get_selection (treeview); - if (gtk_tree_selection_get_selected (select, &model, &iter)) - { - gtk_tree_model_get (model, &iter,FRIEND_SIP_ADDRESS , &friend, -1); - gtk_entry_set_text(GTK_ENTRY(get_main_window()->addressentry),friend); - g_free(friend); - } -} - -void friend_list_init(FriendList *fl,LinphoneCore *lc,GtkWidget *mainwidget) -{ - GtkListStore *store; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkTreeSelection *select; - - - store = gtk_list_store_new (FRIEND_LIST_NCOL, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); - fl->lc=lc; - fl->friendlist=lookup_widget(mainwidget,"friendlist"); - /* need to add friends to the store here ...*/ - - gtk_tree_view_set_model(GTK_TREE_VIEW(fl->friendlist),GTK_TREE_MODEL(store)); - g_object_unref(G_OBJECT(store)); - - renderer = gtk_cell_renderer_pixbuf_new(); - column = gtk_tree_view_column_new_with_attributes (NULL, - renderer, - "pixbuf", FRIEND_PRESENCE_IMG, - NULL); - gtk_tree_view_column_set_min_width (column, 29); - gtk_tree_view_append_column (GTK_TREE_VIEW (fl->friendlist), column); - - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Name"), - renderer, - "text", FRIEND_SIP_ADDRESS, - NULL); - g_object_set (G_OBJECT(column), "resizable", TRUE, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (fl->friendlist), column); - - column = gtk_tree_view_column_new_with_attributes (_("Presence status"), - renderer, - "text", FRIEND_PRESENCE_STATUS, - NULL); - g_object_set (G_OBJECT(column), "resizable", TRUE, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (fl->friendlist), column); - - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (fl->friendlist)); - gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); - -} diff --git a/linphone/gtk/friends.h b/linphone/gtk/friends.h deleted file mode 100644 index 02bf65cb0..000000000 --- a/linphone/gtk/friends.h +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - friends.h - display of friend's list - - ------------------- - begin : Mon Dec 17 2001 - copyright : (C) 2001 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#include - -struct _FriendList { - LinphoneCore *lc; - GtkWidget *friendlist; -}; - -typedef struct _FriendList FriendList; - -void friend_list_init(FriendList *fl,LinphoneCore *lc,GtkWidget *mainwidget); -void friend_list_set_friend_status(FriendList *fl, LinphoneFriend * fid, const gchar *url, const gchar *status, const gchar *img); diff --git a/linphone/gtk/gui_utils.c b/linphone/gtk/gui_utils.c deleted file mode 100644 index f58390bc2..000000000 --- a/linphone/gtk/gui_utils.c +++ /dev/null @@ -1,102 +0,0 @@ -/* -applet.c - some utils functions that cannot be set in interface.c. - -Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#include "linphone.h" - - -/* creates the applet button* -GtkWidget *create_applet() -{ - GtkWidget *frame; - GtkWidget *button; - GtkWidget *vbox; - GtkWidget *applet; - - applet = applet_widget_new("linphone_applet"); - - frame = gtk_frame_new(NULL); - gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); - gtk_widget_show(frame); - - vbox = gtk_vbox_new(FALSE, FALSE); - gtk_container_add(GTK_CONTAINER(frame), vbox); - gtk_widget_show(vbox); - - button = gtk_button_new(); - gtk_widget_ref(button); - GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_DEFAULT); - GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); - gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, TRUE, 0); - - - gtk_widget_show(button); - applet_widget_add (APPLET_WIDGET (applet), frame); - gtk_object_set_data_full(GTK_OBJECT(applet),"applet_button",button,(GtkDestroyNotify)gtk_widget_unref); - gtk_signal_connect(GTK_OBJECT(button), "button_press_event", - GTK_SIGNAL_FUNC(on_applet_clicked), NULL); - gtk_signal_connect(GTK_OBJECT(applet), "change_pixel_size", - GTK_SIGNAL_FUNC(applet_change_pixel_size), NULL); - applet_widget_set_tooltip( APPLET_WIDGET (applet),_("linphone")); - gtk_widget_show(applet); - return(applet); -}; - -*/ -/* this just sets level adjustements for startup*/ -void set_levels(LinphoneGnomeUI *ui,gint reclev, gint playlev, gint ringlev) -{ - GtkWidget *range; - GtkWidget *window=ui->main_window.window; - return; - if (window) - { - range=lookup_widget(window,"rec_vol"); - gtk_adjustment_set_value (gtk_range_get_adjustment(GTK_RANGE(range)),(gfloat)reclev); - range=lookup_widget(window,"play_vol"); - gtk_adjustment_set_value (gtk_range_get_adjustment(GTK_RANGE(range)),(gfloat)playlev); - range=lookup_widget(window,"ring_vol"); - gtk_adjustment_set_value (gtk_range_get_adjustment(GTK_RANGE(range)),(gfloat)ringlev); - } -} - - -void alt_ressource_display(LinphoneGnomeUI *ui,const gchar *url) -{ - GtkWidget *href; - GtkWidget *altdisplay; - GtkLabel *label; - gchar *pattern; - - altdisplay=create_altressource(); - g_object_set_data(G_OBJECT(altdisplay),"ui",(gpointer)ui); - href=lookup_widget(altdisplay,"alt_href"); - label=GTK_LABEL(GTK_BIN(href)->child); - gtk_label_set_text(label,url); - /* pattern used to set underline for string */ - pattern = g_strnfill(strlen(url), '_'); - gtk_label_set_pattern(label,pattern); - g_free(pattern); - gtk_widget_show(altdisplay); -} - - - - diff --git a/linphone/gtk/gui_utils.h b/linphone/gtk/gui_utils.h deleted file mode 100644 index 426de9c3d..000000000 --- a/linphone/gtk/gui_utils.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -applet.h - ome utils functions that cannot be set in interface.c. - -Copyright (C) 2000 Simon MORLAT (simon.morlat@free.fr) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef GUI_UTILS_H -#define GUI_UTILS_H - -#include "linphone.h" - -/* set audio levels on the main window*/ -void set_levels(LinphoneGnomeUI *ui,gint reclev, gint playlev, gint ringlev); - -/* display an alternate url (used in 380 response) */ -void alt_ressource_display(LinphoneGnomeUI *ui, const gchar *url); - -#endif - diff --git a/linphone/gtk/interface.c b/linphone/gtk/interface.c deleted file mode 100644 index ced4cbeb6..000000000 --- a/linphone/gtk/interface.c +++ /dev/null @@ -1,3045 +0,0 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include - -#include -#include - -#include "callbacks.h" -#include "interface.h" -#include "support.h" - -#define GLADE_HOOKUP_OBJECT(component,widget,name) \ - g_object_set_data_full (G_OBJECT (component), name, \ - gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) - -#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ - g_object_set_data (G_OBJECT (component), name, widget) - -GtkWidget* -create_app1 (void) -{ - GtkWidget *app1; - GdkPixbuf *app1_icon_pixbuf; - GtkWidget *dock1; - GtkWidget *menubar1; - GtkWidget *connexion1; - GtkWidget *connexion1_menu; - GtkWidget *addresse1; - GtkWidget *image39; - GtkWidget *parametres1; - GtkWidget *call_history; - GtkWidget *image40; - GtkWidget *separator1; - GtkWidget *exit1; - GtkWidget *image41; - GtkWidget *help1; - GtkWidget *help1_menu; - GtkWidget *about1; - GtkWidget *user_manual1; - GtkWidget *frame6; - GtkWidget *vbox4; - GtkWidget *vbox24; - GtkWidget *hbox15; - GtkWidget *frame7; - GtkWidget *addressentry; - GtkWidget *label1; - GtkWidget *display_ab; - GtkWidget *alignment22; - GtkWidget *hbox36; - GtkWidget *image33; - GtkWidget *label108; - GtkWidget *proxy_hbox; - GtkWidget *proxytouse_label; - GtkWidget *hbox2; - GtkWidget *callbutton; - GtkWidget *button14; - GtkWidget *button18; - GtkWidget *showmore; - GtkWidget *alignment5; - GtkWidget *hbox17; - GtkWidget *image12; - GtkWidget *label60; - GtkWidget *optioncontrols; - GtkWidget *vbox31; - GtkWidget *frame8; - GtkWidget *vbox5; - GtkWidget *label30; - GtkWidget *play_vol; - GtkWidget *label31; - GtkWidget *rec_vol; - GtkWidget *label110; - GtkWidget *ring_vol; - GtkWidget *label113; - GtkWidget *frame27; - GtkWidget *alignment23; - GtkWidget *vbox32; - GtkWidget *video_enabled; - GtkWidget *label114; - GtkWidget *label33; - GtkWidget *vbox6; - GtkWidget *presence_frame; - GtkWidget *presence_vbox; - GtkWidget *presence_reachable; - GSList *presence_reachable_group = NULL; - GtkWidget *hbox4; - GtkWidget *radiobutton2; - GtkWidget *minutesaway; - GtkWidget *label35; - GtkWidget *radiobutton3; - GtkWidget *radiobutton4; - GtkWidget *radiobutton5; - GtkWidget *radiobutton6; - GtkWidget *hbox5; - GtkWidget *label36; - GtkWidget *contact_field; - GtkWidget *label34; - GtkWidget *frame19; - GtkWidget *vbox18; - GtkWidget *dtmf_entry; - GtkWidget *table5; - GtkWidget *dtmf_3; - GtkWidget *dmtf_2; - GtkWidget *dtmf_1; - GtkWidget *dtmf_4; - GtkWidget *dtmf_5; - GtkWidget *dtmf_6; - GtkWidget *dtmf_7; - GtkWidget *dtmf_8; - GtkWidget *dtmf_9; - GtkWidget *dtmf_star; - GtkWidget *dtmf_0; - GtkWidget *dtmf_pound; - GtkWidget *label38; - GtkWidget *vbox22; - GtkWidget *scrolledwindow3; - GtkWidget *friendlist; - GtkWidget *label65; - GtkWidget *appbarframe1; - GtkWidget *appbar1; - GtkAccelGroup *accel_group; - GtkTooltips *tooltips; - - tooltips = gtk_tooltips_new (); - - accel_group = gtk_accel_group_new (); - - app1 = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (app1), _("linphone")); - gtk_window_set_resizable (GTK_WINDOW (app1), FALSE); - app1_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (app1_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (app1), app1_icon_pixbuf); - gdk_pixbuf_unref (app1_icon_pixbuf); - } - - dock1 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (dock1); - gtk_container_add (GTK_CONTAINER (app1), dock1); - - menubar1 = gtk_menu_bar_new (); - gtk_widget_show (menubar1); - gtk_box_pack_start (GTK_BOX (dock1), menubar1, TRUE, TRUE, 0); - - connexion1 = gtk_menu_item_new_with_mnemonic (_("Go")); - gtk_widget_show (connexion1); - gtk_container_add (GTK_CONTAINER (menubar1), connexion1); - - connexion1_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (connexion1), connexion1_menu); - - addresse1 = gtk_image_menu_item_new_with_mnemonic (_("Address book")); - gtk_widget_show (addresse1); - gtk_container_add (GTK_CONTAINER (connexion1_menu), addresse1); - - image39 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU); - gtk_widget_show (image39); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (addresse1), image39); - - parametres1 = gtk_image_menu_item_new_from_stock ("gtk-preferences", accel_group); - gtk_widget_show (parametres1); - gtk_container_add (GTK_CONTAINER (connexion1_menu), parametres1); - - call_history = gtk_image_menu_item_new_with_mnemonic (_("Call history")); - gtk_widget_show (call_history); - gtk_container_add (GTK_CONTAINER (connexion1_menu), call_history); - gtk_tooltips_set_tip (tooltips, call_history, _("Shows calls"), NULL); - - image40 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU); - gtk_widget_show (image40); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (call_history), image40); - - separator1 = gtk_separator_menu_item_new (); - gtk_widget_show (separator1); - gtk_container_add (GTK_CONTAINER (connexion1_menu), separator1); - gtk_widget_set_sensitive (separator1, FALSE); - - exit1 = gtk_image_menu_item_new_with_mnemonic (_("Exit")); - gtk_widget_show (exit1); - gtk_container_add (GTK_CONTAINER (connexion1_menu), exit1); - - image41 = gtk_image_new_from_stock ("gtk-quit", GTK_ICON_SIZE_MENU); - gtk_widget_show (image41); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (exit1), image41); - - help1 = gtk_menu_item_new_with_mnemonic (_("Help")); - gtk_widget_show (help1); - gtk_container_add (GTK_CONTAINER (menubar1), help1); - - help1_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (help1), help1_menu); - - about1 = gtk_image_menu_item_new_from_stock ("gtk-about", accel_group); - gtk_widget_show (about1); - gtk_container_add (GTK_CONTAINER (help1_menu), about1); - - user_manual1 = gtk_image_menu_item_new_from_stock ("gtk-help", accel_group); - gtk_widget_show (user_manual1); - gtk_container_add (GTK_CONTAINER (help1_menu), user_manual1); - - frame6 = gtk_frame_new (NULL); - gtk_widget_show (frame6); - gtk_box_pack_start (GTK_BOX (dock1), frame6, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame6), 9); - - vbox4 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox4); - gtk_container_add (GTK_CONTAINER (frame6), vbox4); - - vbox24 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox24); - gtk_box_pack_start (GTK_BOX (vbox4), vbox24, TRUE, TRUE, 0); - - hbox15 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox15); - gtk_box_pack_start (GTK_BOX (vbox24), hbox15, TRUE, TRUE, 0); - - frame7 = gtk_frame_new (NULL); - gtk_widget_show (frame7); - gtk_box_pack_start (GTK_BOX (hbox15), frame7, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame7), 5); - - addressentry = gtk_entry_new (); - gtk_widget_show (addressentry); - gtk_container_add (GTK_CONTAINER (frame7), addressentry); - gtk_tooltips_set_tip (tooltips, addressentry, _("Enter sip address or phone number here"), NULL); - gtk_entry_set_text (GTK_ENTRY (addressentry), _("sip:")); - - label1 = gtk_label_new (_("Sip address:")); - gtk_widget_show (label1); - gtk_frame_set_label_widget (GTK_FRAME (frame7), label1); - - display_ab = gtk_button_new (); - gtk_widget_show (display_ab); - gtk_box_pack_start (GTK_BOX (hbox15), display_ab, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (display_ab), 15); - gtk_tooltips_set_tip (tooltips, display_ab, _("Shows the address book"), NULL); - - alignment22 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment22); - gtk_container_add (GTK_CONTAINER (display_ab), alignment22); - - hbox36 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox36); - gtk_container_add (GTK_CONTAINER (alignment22), hbox36); - - image33 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image33); - gtk_box_pack_start (GTK_BOX (hbox36), image33, FALSE, FALSE, 0); - - label108 = gtk_label_new_with_mnemonic (_("...")); - gtk_widget_show (label108); - gtk_box_pack_start (GTK_BOX (hbox36), label108, FALSE, FALSE, 0); - - proxy_hbox = gtk_hbox_new (FALSE, 0); - gtk_widget_show (proxy_hbox); - gtk_box_pack_start (GTK_BOX (vbox24), proxy_hbox, TRUE, TRUE, 0); - - proxytouse_label = gtk_label_new (_("Proxy to use:")); - gtk_widget_show (proxytouse_label); - gtk_box_pack_start (GTK_BOX (proxy_hbox), proxytouse_label, TRUE, TRUE, 0); - gtk_label_set_justify (GTK_LABEL (proxytouse_label), GTK_JUSTIFY_CENTER); - - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox2); - gtk_box_pack_start (GTK_BOX (vbox4), hbox2, TRUE, TRUE, 0); - - callbutton = gtk_button_new_with_mnemonic (_("Call or\nanswer")); - gtk_widget_show (callbutton); - gtk_box_pack_start (GTK_BOX (hbox2), callbutton, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (callbutton), 8); - - button14 = gtk_button_new_with_mnemonic (_("Hangup\nor refuse")); - gtk_widget_show (button14); - gtk_box_pack_start (GTK_BOX (hbox2), button14, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button14), 8); - - button18 = gtk_button_new_with_mnemonic (_("Or chat !")); - gtk_widget_show (button18); - gtk_box_pack_start (GTK_BOX (vbox4), button18, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button18), 8); - - showmore = gtk_check_button_new (); - gtk_widget_show (showmore); - gtk_box_pack_start (GTK_BOX (vbox4), showmore, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (showmore), TRUE); - - alignment5 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment5); - gtk_container_add (GTK_CONTAINER (showmore), alignment5); - - hbox17 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox17); - gtk_container_add (GTK_CONTAINER (alignment5), hbox17); - - image12 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image12); - gtk_box_pack_start (GTK_BOX (hbox17), image12, FALSE, FALSE, 0); - - label60 = gtk_label_new_with_mnemonic (_("Show more...")); - gtk_widget_show (label60); - gtk_box_pack_start (GTK_BOX (hbox17), label60, FALSE, FALSE, 0); - - optioncontrols = gtk_notebook_new (); - gtk_widget_show (optioncontrols); - gtk_box_pack_start (GTK_BOX (vbox4), optioncontrols, TRUE, TRUE, 0); - - vbox31 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox31); - gtk_container_add (GTK_CONTAINER (optioncontrols), vbox31); - - frame8 = gtk_frame_new (NULL); - gtk_widget_show (frame8); - gtk_box_pack_start (GTK_BOX (vbox31), frame8, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame8), 11); - - vbox5 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox5); - gtk_container_add (GTK_CONTAINER (frame8), vbox5); - gtk_container_set_border_width (GTK_CONTAINER (vbox5), 2); - - label30 = gtk_label_new (_("Playback level:")); - gtk_widget_show (label30); - gtk_box_pack_start (GTK_BOX (vbox5), label30, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label30), 7.45058e-09, 0.5); - - play_vol = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (75, 0, 100, 0, 0, 0))); - gtk_widget_show (play_vol); - gtk_box_pack_start (GTK_BOX (vbox5), play_vol, TRUE, TRUE, 0); - gtk_scale_set_value_pos (GTK_SCALE (play_vol), GTK_POS_RIGHT); - gtk_scale_set_digits (GTK_SCALE (play_vol), 0); - - label31 = gtk_label_new (_("Recording level:")); - gtk_widget_show (label31); - gtk_box_pack_start (GTK_BOX (vbox5), label31, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label31), 7.45058e-09, 0.5); - - rec_vol = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (75, 0, 100, 0, 0, 0))); - gtk_widget_show (rec_vol); - gtk_box_pack_start (GTK_BOX (vbox5), rec_vol, TRUE, TRUE, 0); - gtk_scale_set_value_pos (GTK_SCALE (rec_vol), GTK_POS_RIGHT); - gtk_scale_set_digits (GTK_SCALE (rec_vol), 0); - - label110 = gtk_label_new (_("Ring level:")); - gtk_widget_show (label110); - gtk_box_pack_start (GTK_BOX (vbox5), label110, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label110), 7.45058e-09, 0.5); - - ring_vol = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (75, 0, 100, 0, 0, 0))); - gtk_widget_show (ring_vol); - gtk_box_pack_start (GTK_BOX (vbox5), ring_vol, TRUE, TRUE, 0); - gtk_scale_set_value_pos (GTK_SCALE (ring_vol), GTK_POS_RIGHT); - gtk_scale_set_digits (GTK_SCALE (ring_vol), 0); - - label113 = gtk_label_new (_("Sound")); - gtk_widget_show (label113); - gtk_frame_set_label_widget (GTK_FRAME (frame8), label113); - - frame27 = gtk_frame_new (NULL); - gtk_widget_show (frame27); - gtk_box_pack_start (GTK_BOX (vbox31), frame27, FALSE, FALSE, 0); - - alignment23 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_widget_show (alignment23); - gtk_container_add (GTK_CONTAINER (frame27), alignment23); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment23), 0, 0, 12, 0); - - vbox32 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox32); - gtk_container_add (GTK_CONTAINER (alignment23), vbox32); - - video_enabled = gtk_check_button_new_with_mnemonic (_("Enable video")); - gtk_widget_show (video_enabled); - gtk_box_pack_start (GTK_BOX (vbox32), video_enabled, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (video_enabled), TRUE); - - label114 = gtk_label_new (_("Video")); - gtk_widget_show (label114); - gtk_frame_set_label_widget (GTK_FRAME (frame27), label114); - gtk_label_set_use_markup (GTK_LABEL (label114), TRUE); - - label33 = gtk_label_new (_("Controls")); - gtk_widget_show (label33); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (optioncontrols), gtk_notebook_get_nth_page (GTK_NOTEBOOK (optioncontrols), 0), label33); - gtk_label_set_justify (GTK_LABEL (label33), GTK_JUSTIFY_CENTER); - - vbox6 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox6); - gtk_container_add (GTK_CONTAINER (optioncontrols), vbox6); - - presence_frame = gtk_frame_new (NULL); - gtk_widget_show (presence_frame); - gtk_box_pack_start (GTK_BOX (vbox6), presence_frame, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (presence_frame), 11); - - presence_vbox = gtk_vbox_new (FALSE, 0); - gtk_widget_show (presence_vbox); - gtk_container_add (GTK_CONTAINER (presence_frame), presence_vbox); - - presence_reachable = gtk_radio_button_new_with_mnemonic (NULL, _("Reachable")); - gtk_widget_show (presence_reachable); - gtk_box_pack_start (GTK_BOX (presence_vbox), presence_reachable, FALSE, FALSE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (presence_reachable), presence_reachable_group); - presence_reachable_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (presence_reachable)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (presence_reachable), TRUE); - - hbox4 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox4); - gtk_box_pack_start (GTK_BOX (presence_vbox), hbox4, FALSE, TRUE, 0); - - radiobutton2 = gtk_radio_button_new_with_mnemonic (NULL, _("Busy, I'll be back in ")); - gtk_widget_show (radiobutton2); - gtk_box_pack_start (GTK_BOX (hbox4), radiobutton2, TRUE, TRUE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton2), presence_reachable_group); - presence_reachable_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton2)); - - minutesaway = gtk_entry_new (); - gtk_widget_show (minutesaway); - gtk_box_pack_start (GTK_BOX (hbox4), minutesaway, FALSE, FALSE, 0); - gtk_tooltips_set_tip (tooltips, minutesaway, _("The other party will be informed that you'll be back in X minutes"), NULL); - gtk_entry_set_text (GTK_ENTRY (minutesaway), _("5")); - - label35 = gtk_label_new (_("mn")); - gtk_widget_show (label35); - gtk_box_pack_start (GTK_BOX (hbox4), label35, TRUE, TRUE, 0); - gtk_label_set_justify (GTK_LABEL (label35), GTK_JUSTIFY_CENTER); - - radiobutton3 = gtk_radio_button_new_with_mnemonic (NULL, _("Away")); - gtk_widget_show (radiobutton3); - gtk_box_pack_start (GTK_BOX (presence_vbox), radiobutton3, FALSE, FALSE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton3), presence_reachable_group); - presence_reachable_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton3)); - - radiobutton4 = gtk_radio_button_new_with_mnemonic (NULL, _("Do not disturb")); - gtk_widget_show (radiobutton4); - gtk_box_pack_start (GTK_BOX (presence_vbox), radiobutton4, FALSE, FALSE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton4), presence_reachable_group); - presence_reachable_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton4)); - - radiobutton5 = gtk_radio_button_new_with_mnemonic (NULL, _("Moved temporarily")); - gtk_widget_show (radiobutton5); - gtk_box_pack_start (GTK_BOX (presence_vbox), radiobutton5, FALSE, FALSE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton5), presence_reachable_group); - presence_reachable_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton5)); - - radiobutton6 = gtk_radio_button_new_with_mnemonic (NULL, _("Alternative service")); - gtk_widget_show (radiobutton6); - gtk_box_pack_start (GTK_BOX (presence_vbox), radiobutton6, FALSE, FALSE, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton6), presence_reachable_group); - presence_reachable_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton6)); - - hbox5 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox5); - gtk_box_pack_start (GTK_BOX (presence_vbox), hbox5, FALSE, TRUE, 0); - - label36 = gtk_label_new (_("URL:")); - gtk_widget_show (label36); - gtk_box_pack_start (GTK_BOX (hbox5), label36, TRUE, TRUE, 0); - gtk_label_set_justify (GTK_LABEL (label36), GTK_JUSTIFY_CENTER); - - contact_field = gtk_entry_new (); - gtk_widget_show (contact_field); - gtk_box_pack_start (GTK_BOX (hbox5), contact_field, FALSE, FALSE, 0); - - label34 = gtk_label_new (_("Presence")); - gtk_widget_show (label34); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (optioncontrols), gtk_notebook_get_nth_page (GTK_NOTEBOOK (optioncontrols), 1), label34); - gtk_label_set_justify (GTK_LABEL (label34), GTK_JUSTIFY_CENTER); - - frame19 = gtk_frame_new (NULL); - gtk_widget_show (frame19); - gtk_container_add (GTK_CONTAINER (optioncontrols), frame19); - gtk_container_set_border_width (GTK_CONTAINER (frame19), 15); - - vbox18 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox18); - gtk_container_add (GTK_CONTAINER (frame19), vbox18); - - dtmf_entry = gtk_entry_new (); - gtk_widget_show (dtmf_entry); - gtk_box_pack_start (GTK_BOX (vbox18), dtmf_entry, FALSE, FALSE, 0); - gtk_tooltips_set_tip (tooltips, dtmf_entry, _("Press digits to send DTMFs."), NULL); - - table5 = gtk_table_new (4, 3, TRUE); - gtk_widget_show (table5); - gtk_box_pack_start (GTK_BOX (vbox18), table5, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (table5), 14); - gtk_table_set_row_spacings (GTK_TABLE (table5), 10); - gtk_table_set_col_spacings (GTK_TABLE (table5), 10); - - dtmf_3 = gtk_button_new_with_mnemonic (_(" 3\ndef")); - gtk_widget_show (dtmf_3); - gtk_table_attach (GTK_TABLE (table5), dtmf_3, 2, 3, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dmtf_2 = gtk_button_new_with_mnemonic (_(" 2\nabc")); - gtk_widget_show (dmtf_2); - gtk_table_attach (GTK_TABLE (table5), dmtf_2, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_1 = gtk_button_new_with_mnemonic (_("1")); - gtk_widget_show (dtmf_1); - gtk_table_attach (GTK_TABLE (table5), dtmf_1, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_4 = gtk_button_new_with_mnemonic (_(" 4\nghi")); - gtk_widget_show (dtmf_4); - gtk_table_attach (GTK_TABLE (table5), dtmf_4, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_5 = gtk_button_new_with_mnemonic (_(" 5\njkl")); - gtk_widget_show (dtmf_5); - gtk_table_attach (GTK_TABLE (table5), dtmf_5, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_6 = gtk_button_new_with_mnemonic (_(" 6\nmno")); - gtk_widget_show (dtmf_6); - gtk_table_attach (GTK_TABLE (table5), dtmf_6, 2, 3, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_7 = gtk_button_new_with_mnemonic (_(" 7\npqrs")); - gtk_widget_show (dtmf_7); - gtk_table_attach (GTK_TABLE (table5), dtmf_7, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_8 = gtk_button_new_with_mnemonic (_(" 8\ntuv")); - gtk_widget_show (dtmf_8); - gtk_table_attach (GTK_TABLE (table5), dtmf_8, 1, 2, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_9 = gtk_button_new_with_mnemonic (_(" 9\nwxyz")); - gtk_widget_show (dtmf_9); - gtk_table_attach (GTK_TABLE (table5), dtmf_9, 2, 3, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_star = gtk_button_new_with_mnemonic (_("*")); - gtk_widget_show (dtmf_star); - gtk_table_attach (GTK_TABLE (table5), dtmf_star, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_0 = gtk_button_new_with_mnemonic (_("0")); - gtk_widget_show (dtmf_0); - gtk_table_attach (GTK_TABLE (table5), dtmf_0, 1, 2, 3, 4, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - dtmf_pound = gtk_button_new_with_mnemonic (_("#")); - gtk_widget_show (dtmf_pound); - gtk_table_attach (GTK_TABLE (table5), dtmf_pound, 2, 3, 3, 4, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - - label38 = gtk_label_new (_("DTMF")); - gtk_widget_show (label38); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (optioncontrols), gtk_notebook_get_nth_page (GTK_NOTEBOOK (optioncontrols), 2), label38); - gtk_label_set_justify (GTK_LABEL (label38), GTK_JUSTIFY_CENTER); - - vbox22 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox22); - gtk_container_add (GTK_CONTAINER (optioncontrols), vbox22); - - scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow3); - gtk_box_pack_start (GTK_BOX (vbox22), scrolledwindow3, TRUE, TRUE, 0); - - friendlist = gtk_tree_view_new (); - gtk_widget_show (friendlist); - gtk_container_add (GTK_CONTAINER (scrolledwindow3), friendlist); - - label65 = gtk_label_new (_("My online friends")); - gtk_widget_show (label65); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (optioncontrols), gtk_notebook_get_nth_page (GTK_NOTEBOOK (optioncontrols), 3), label65); - - appbarframe1 = gtk_frame_new (NULL); - gtk_widget_show (appbarframe1); - gtk_box_pack_start (GTK_BOX (dock1), appbarframe1, TRUE, TRUE, 0); - - appbar1 = gtk_statusbar_new (); - gtk_widget_show (appbar1); - gtk_container_add (GTK_CONTAINER (appbarframe1), appbar1); - - g_signal_connect ((gpointer) app1, "destroy", - G_CALLBACK (on_app1_destroy), - NULL); - g_signal_connect ((gpointer) addresse1, "activate", - G_CALLBACK (on_adresse_activate), - NULL); - g_signal_connect ((gpointer) parametres1, "activate", - G_CALLBACK (on_parametres1_activate), - NULL); - g_signal_connect ((gpointer) call_history, "activate", - G_CALLBACK (on_call_history_activate), - NULL); - g_signal_connect ((gpointer) exit1, "activate", - G_CALLBACK (on_exit1_activate), - NULL); - g_signal_connect ((gpointer) about1, "activate", - G_CALLBACK (on_about1_activate), - NULL); - g_signal_connect ((gpointer) user_manual1, "activate", - G_CALLBACK (on_user_manual1_activate), - NULL); - g_signal_connect ((gpointer) addressentry, "activate", - G_CALLBACK (on_addressentry_activate), - NULL); - g_signal_connect ((gpointer) addressentry, "destroy", - G_CALLBACK (on_addressentry_destroy), - NULL); - g_signal_connect ((gpointer) display_ab, "clicked", - G_CALLBACK (on_display_ab_clicked), - NULL); - g_signal_connect ((gpointer) callbutton, "clicked", - G_CALLBACK (on_callbutton_clicked), - NULL); - g_signal_connect ((gpointer) button14, "clicked", - G_CALLBACK (on_hangup_clicked), - NULL); - g_signal_connect ((gpointer) button18, "clicked", - G_CALLBACK (on_chat_clicked), - NULL); - g_signal_connect ((gpointer) showmore, "toggled", - G_CALLBACK (on_showmore_toggled), - NULL); - g_signal_connect ((gpointer) play_vol, "button_release_event", - G_CALLBACK (on_play_vol_button_release_event), - NULL); - g_signal_connect ((gpointer) rec_vol, "button_release_event", - G_CALLBACK (on_rec_vol_button_release_event), - NULL); - g_signal_connect ((gpointer) ring_vol, "button_release_event", - G_CALLBACK (on_rec_vol_button_release_event), - NULL); - g_signal_connect ((gpointer) video_enabled, "toggled", - G_CALLBACK (on_video_enabled_toggled), - NULL); - g_signal_connect ((gpointer) presence_reachable, "toggled", - G_CALLBACK (on_reachable), - NULL); - g_signal_connect ((gpointer) radiobutton2, "toggled", - G_CALLBACK (on_busy), - NULL); - g_signal_connect ((gpointer) minutesaway, "changed", - G_CALLBACK (on_minutesaway_changed), - NULL); - g_signal_connect ((gpointer) radiobutton3, "toggled", - G_CALLBACK (on_away), - NULL); - g_signal_connect ((gpointer) radiobutton4, "toggled", - G_CALLBACK (on_do_not_disturb), - NULL); - g_signal_connect ((gpointer) radiobutton5, "toggled", - G_CALLBACK (on_moved_tmply), - NULL); - g_signal_connect ((gpointer) radiobutton6, "toggled", - G_CALLBACK (on_alt_serv), - NULL); - g_signal_connect ((gpointer) contact_field, "changed", - G_CALLBACK (on_contact_field_changed), - NULL); - g_signal_connect ((gpointer) dtmf_entry, "changed", - G_CALLBACK (on_dtmf_entry_changed), - NULL); - g_signal_connect ((gpointer) dtmf_3, "clicked", - G_CALLBACK (on_dtmf_3_clicked), - NULL); - g_signal_connect ((gpointer) dmtf_2, "clicked", - G_CALLBACK (on_dmtf_2_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_1, "clicked", - G_CALLBACK (on_dtmf_1_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_4, "clicked", - G_CALLBACK (on_dtmf_4_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_5, "clicked", - G_CALLBACK (on_dtmf_5_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_6, "clicked", - G_CALLBACK (on_dtmf_6_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_7, "clicked", - G_CALLBACK (on_dtmf_7_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_8, "clicked", - G_CALLBACK (on_dtmf_8_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_9, "clicked", - G_CALLBACK (on_dtmf_9_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_star, "clicked", - G_CALLBACK (on_dtmf_star_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_0, "clicked", - G_CALLBACK (on_dtmf_0_clicked), - NULL); - g_signal_connect ((gpointer) dtmf_pound, "clicked", - G_CALLBACK (on_dtmf_pound_clicked), - NULL); - g_signal_connect ((gpointer) friendlist, "row_activated", - G_CALLBACK (on_friendlist_row_activated), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (app1, app1, "app1"); - GLADE_HOOKUP_OBJECT (app1, dock1, "dock1"); - GLADE_HOOKUP_OBJECT (app1, menubar1, "menubar1"); - GLADE_HOOKUP_OBJECT (app1, connexion1, "connexion1"); - GLADE_HOOKUP_OBJECT (app1, connexion1_menu, "connexion1_menu"); - GLADE_HOOKUP_OBJECT (app1, addresse1, "addresse1"); - GLADE_HOOKUP_OBJECT (app1, image39, "image39"); - GLADE_HOOKUP_OBJECT (app1, parametres1, "parametres1"); - GLADE_HOOKUP_OBJECT (app1, call_history, "call_history"); - GLADE_HOOKUP_OBJECT (app1, image40, "image40"); - GLADE_HOOKUP_OBJECT (app1, separator1, "separator1"); - GLADE_HOOKUP_OBJECT (app1, exit1, "exit1"); - GLADE_HOOKUP_OBJECT (app1, image41, "image41"); - GLADE_HOOKUP_OBJECT (app1, help1, "help1"); - GLADE_HOOKUP_OBJECT (app1, help1_menu, "help1_menu"); - GLADE_HOOKUP_OBJECT (app1, about1, "about1"); - GLADE_HOOKUP_OBJECT (app1, user_manual1, "user_manual1"); - GLADE_HOOKUP_OBJECT (app1, frame6, "frame6"); - GLADE_HOOKUP_OBJECT (app1, vbox4, "vbox4"); - GLADE_HOOKUP_OBJECT (app1, vbox24, "vbox24"); - GLADE_HOOKUP_OBJECT (app1, hbox15, "hbox15"); - GLADE_HOOKUP_OBJECT (app1, frame7, "frame7"); - GLADE_HOOKUP_OBJECT (app1, addressentry, "addressentry"); - GLADE_HOOKUP_OBJECT (app1, label1, "label1"); - GLADE_HOOKUP_OBJECT (app1, display_ab, "display_ab"); - GLADE_HOOKUP_OBJECT (app1, alignment22, "alignment22"); - GLADE_HOOKUP_OBJECT (app1, hbox36, "hbox36"); - GLADE_HOOKUP_OBJECT (app1, image33, "image33"); - GLADE_HOOKUP_OBJECT (app1, label108, "label108"); - GLADE_HOOKUP_OBJECT (app1, proxy_hbox, "proxy_hbox"); - GLADE_HOOKUP_OBJECT (app1, proxytouse_label, "proxytouse_label"); - GLADE_HOOKUP_OBJECT (app1, hbox2, "hbox2"); - GLADE_HOOKUP_OBJECT (app1, callbutton, "callbutton"); - GLADE_HOOKUP_OBJECT (app1, button14, "button14"); - GLADE_HOOKUP_OBJECT (app1, button18, "button18"); - GLADE_HOOKUP_OBJECT (app1, showmore, "showmore"); - GLADE_HOOKUP_OBJECT (app1, alignment5, "alignment5"); - GLADE_HOOKUP_OBJECT (app1, hbox17, "hbox17"); - GLADE_HOOKUP_OBJECT (app1, image12, "image12"); - GLADE_HOOKUP_OBJECT (app1, label60, "label60"); - GLADE_HOOKUP_OBJECT (app1, optioncontrols, "optioncontrols"); - GLADE_HOOKUP_OBJECT (app1, vbox31, "vbox31"); - GLADE_HOOKUP_OBJECT (app1, frame8, "frame8"); - GLADE_HOOKUP_OBJECT (app1, vbox5, "vbox5"); - GLADE_HOOKUP_OBJECT (app1, label30, "label30"); - GLADE_HOOKUP_OBJECT (app1, play_vol, "play_vol"); - GLADE_HOOKUP_OBJECT (app1, label31, "label31"); - GLADE_HOOKUP_OBJECT (app1, rec_vol, "rec_vol"); - GLADE_HOOKUP_OBJECT (app1, label110, "label110"); - GLADE_HOOKUP_OBJECT (app1, ring_vol, "ring_vol"); - GLADE_HOOKUP_OBJECT (app1, label113, "label113"); - GLADE_HOOKUP_OBJECT (app1, frame27, "frame27"); - GLADE_HOOKUP_OBJECT (app1, alignment23, "alignment23"); - GLADE_HOOKUP_OBJECT (app1, vbox32, "vbox32"); - GLADE_HOOKUP_OBJECT (app1, video_enabled, "video_enabled"); - GLADE_HOOKUP_OBJECT (app1, label114, "label114"); - GLADE_HOOKUP_OBJECT (app1, label33, "label33"); - GLADE_HOOKUP_OBJECT (app1, vbox6, "vbox6"); - GLADE_HOOKUP_OBJECT (app1, presence_frame, "presence_frame"); - GLADE_HOOKUP_OBJECT (app1, presence_vbox, "presence_vbox"); - GLADE_HOOKUP_OBJECT (app1, presence_reachable, "presence_reachable"); - GLADE_HOOKUP_OBJECT (app1, hbox4, "hbox4"); - GLADE_HOOKUP_OBJECT (app1, radiobutton2, "radiobutton2"); - GLADE_HOOKUP_OBJECT (app1, minutesaway, "minutesaway"); - GLADE_HOOKUP_OBJECT (app1, label35, "label35"); - GLADE_HOOKUP_OBJECT (app1, radiobutton3, "radiobutton3"); - GLADE_HOOKUP_OBJECT (app1, radiobutton4, "radiobutton4"); - GLADE_HOOKUP_OBJECT (app1, radiobutton5, "radiobutton5"); - GLADE_HOOKUP_OBJECT (app1, radiobutton6, "radiobutton6"); - GLADE_HOOKUP_OBJECT (app1, hbox5, "hbox5"); - GLADE_HOOKUP_OBJECT (app1, label36, "label36"); - GLADE_HOOKUP_OBJECT (app1, contact_field, "contact_field"); - GLADE_HOOKUP_OBJECT (app1, label34, "label34"); - GLADE_HOOKUP_OBJECT (app1, frame19, "frame19"); - GLADE_HOOKUP_OBJECT (app1, vbox18, "vbox18"); - GLADE_HOOKUP_OBJECT (app1, dtmf_entry, "dtmf_entry"); - GLADE_HOOKUP_OBJECT (app1, table5, "table5"); - GLADE_HOOKUP_OBJECT (app1, dtmf_3, "dtmf_3"); - GLADE_HOOKUP_OBJECT (app1, dmtf_2, "dmtf_2"); - GLADE_HOOKUP_OBJECT (app1, dtmf_1, "dtmf_1"); - GLADE_HOOKUP_OBJECT (app1, dtmf_4, "dtmf_4"); - GLADE_HOOKUP_OBJECT (app1, dtmf_5, "dtmf_5"); - GLADE_HOOKUP_OBJECT (app1, dtmf_6, "dtmf_6"); - GLADE_HOOKUP_OBJECT (app1, dtmf_7, "dtmf_7"); - GLADE_HOOKUP_OBJECT (app1, dtmf_8, "dtmf_8"); - GLADE_HOOKUP_OBJECT (app1, dtmf_9, "dtmf_9"); - GLADE_HOOKUP_OBJECT (app1, dtmf_star, "dtmf_star"); - GLADE_HOOKUP_OBJECT (app1, dtmf_0, "dtmf_0"); - GLADE_HOOKUP_OBJECT (app1, dtmf_pound, "dtmf_pound"); - GLADE_HOOKUP_OBJECT (app1, label38, "label38"); - GLADE_HOOKUP_OBJECT (app1, vbox22, "vbox22"); - GLADE_HOOKUP_OBJECT (app1, scrolledwindow3, "scrolledwindow3"); - GLADE_HOOKUP_OBJECT (app1, friendlist, "friendlist"); - GLADE_HOOKUP_OBJECT (app1, label65, "label65"); - GLADE_HOOKUP_OBJECT (app1, appbarframe1, "appbarframe1"); - GLADE_HOOKUP_OBJECT (app1, appbar1, "appbar1"); - GLADE_HOOKUP_OBJECT_NO_REF (app1, tooltips, "tooltips"); - - gtk_window_add_accel_group (GTK_WINDOW (app1), accel_group); - - return app1; -} - -GtkWidget* -create_about2 (void) -{ - GtkWidget *about2; - const gchar *authors[] = { - "Simon MORLAT", - "Aymeric Moizard", - "Sharath K Udupa", - NULL - }; - const gchar *documenters[] = { - "Simon MORLAT", - "Philippe Beau", - NULL - }; - gchar *translators = "it: Alberto Zanoni\nde: Jean Jacques Sarton\nfr: Simon Morlat\nde: Jean-Jacques Sarton, Ursula Herles-Hartz\nes: Jesus Benitez, Nelson Benitez\nja: Yamaguchi Yoshiya\nnl: Hendrik-Jan Heins\npl: Robert Nasiadek <darkone@darkone.pl>\npt_BR: Rafael Caesar Lenzi \nsv: Daniel Nylander "; - GdkPixbuf *about2_logo_pixbuf; - - about2 = gtk_about_dialog_new (); - gtk_container_set_border_width (GTK_CONTAINER (about2), 5); - gtk_window_set_destroy_with_parent (GTK_WINDOW (about2), TRUE); - gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about2), VERSION); - gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (about2), _("Linphone")); - gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (about2), _("C: 2001\nMade in Old Europe")); - gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (about2), _("Linphone is a web-phone.\nIt is compatible with SIP and RTP protocols.")); - gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (about2), " This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"); - gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (about2), "http://www.linphone.org"); - gtk_about_dialog_set_website_label (GTK_ABOUT_DIALOG (about2), _("http://www.linphone.org")); - gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (about2), authors); - gtk_about_dialog_set_documenters (GTK_ABOUT_DIALOG (about2), documenters); - gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (about2), translators); - about2_logo_pixbuf = create_pixbuf ("linphone.png"); - gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (about2), about2_logo_pixbuf); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (about2, about2, "about2"); - - return about2; -} - -GtkWidget* -create_prop1 (void) -{ - GtkWidget *prop1; - GdkPixbuf *prop1_icon_pixbuf; - GtkWidget *prop1box; - GtkWidget *prop1notebook; - GtkWidget *vbox9; - GtkWidget *frame26; - GtkWidget *alignment21; - GtkWidget *vbox29; - GtkWidget *enable_ipv6; - GtkWidget *label105; - GtkWidget *frame21; - GtkWidget *vbox21; - GtkWidget *label56; - GtkWidget *table13; - GtkWidget *no_nat; - GSList *no_nat_group = NULL; - GtkWidget *use_stun; - GtkWidget *static_nat; - GtkWidget *nat_address; - GtkWidget *stun_server; - GtkWidget *label55; - GtkWidget *frame20; - GtkWidget *table6; - GtkWidget *audio_jittcomp; - GtkObject *audioport_adj; - GtkWidget *audioport; - GtkWidget *label52; - GtkWidget *label53; - GtkWidget *label54; - GtkWidget *frame25; - GtkWidget *alignment20; - GtkWidget *vbox28; - GtkWidget *use_sipinfo; - GtkWidget *label103; - GtkWidget *network; - GtkWidget *vbox12; - GtkWidget *vbox20; - GtkWidget *frame17; - GtkWidget *vbox16; - GtkWidget *table4; - GtkWidget *label10; - GtkWidget *combo3; - GList *combo3_items = NULL; - GtkWidget *rec_source; - GtkWidget *label106; - GtkWidget *play_card; - GtkWidget *capt_card; - GtkWidget *label11; - GtkWidget *ringsnddev_label; - GtkWidget *label63; - GtkWidget *ring_card; - GtkWidget *echocancelation; - GtkWidget *label115; - GtkWidget *hbox20; - GtkWidget *ringfileentry; - GtkWidget *ringpreview; - GtkWidget *alignment24; - GtkWidget *hbox37; - GtkWidget *image42; - GtkWidget *label118; - GtkWidget *label48; - GtkWidget *sound; - GtkWidget *vbox7; - GtkWidget *frame10; - GtkWidget *hbox6; - GtkWidget *label13; - GtkObject *sip_port_adj; - GtkWidget *sip_port; - GtkWidget *label43; - GtkWidget *frame11; - GtkWidget *vbox27; - GtkWidget *hbox7; - GtkWidget *label26; - GtkWidget *label27; - GtkWidget *user_name; - GtkWidget *label28; - GtkWidget *domain_name; - GtkWidget *guess_hostname; - GtkWidget *label44; - GtkWidget *frame1; - GtkWidget *vbox23; - GtkWidget *scrolledwindow4; - GtkWidget *proxy_list; - GtkWidget *hbuttonbox6; - GtkWidget *addproxy_button; - GtkWidget *alignment12; - GtkWidget *hbox25; - GtkWidget *image19; - GtkWidget *label77; - GtkWidget *editproxy_button; - GtkWidget *alignment13; - GtkWidget *hbox26; - GtkWidget *image20; - GtkWidget *label78; - GtkWidget *removeproxy_button; - GtkWidget *alignment14; - GtkWidget *hbox27; - GtkWidget *image21; - GtkWidget *label79; - GtkWidget *label45; - GtkWidget *frame24; - GtkWidget *alignment18; - GtkWidget *clear_auth_info; - GtkWidget *alignment19; - GtkWidget *hbox34; - GtkWidget *image27; - GtkWidget *label102; - GtkWidget *label101; - GtkWidget *sip_pref; - GtkWidget *vbox13; - GtkWidget *frame16; - GtkWidget *hbox9; - GtkWidget *vbox14; - GtkWidget *label9; - GtkWidget *codec_notebook; - GtkWidget *scrolledwindow2; - GtkWidget *au_codec_list; - GtkWidget *label116; - GtkWidget *scrolledwindow7; - GtkWidget *vid_codec_list; - GtkWidget *label117; - GtkWidget *hbuttonbox4; - GtkWidget *aucodec_up; - GtkWidget *aucodec_down; - GtkWidget *aucodec_enable; - GtkWidget *alignment1; - GtkWidget *hbox11; - GtkWidget *image4; - GtkWidget *label50; - GtkWidget *aucodec_disable; - GtkWidget *alignment2; - GtkWidget *hbox12; - GtkWidget *image5; - GtkWidget *label51; - GtkWidget *table12; - GtkWidget *label112; - GtkWidget *label111; - GtkObject *download_bw_adj; - GtkWidget *download_bw; - GtkObject *upload_bw_adj; - GtkWidget *upload_bw; - GtkWidget *vbox17; - GtkWidget *label22; - GtkWidget *frame18; - GtkWidget *codec_info; - GtkWidget *label47; - GtkWidget *label46; - GtkWidget *codecs_pref; - GtkWidget *hbuttonbox7; - GtkWidget *prop_help_button; - GtkWidget *prop_apply_button; - GtkWidget *prop_close_button; - GtkWidget *prop_ok_button; - GtkTooltips *tooltips; - - tooltips = gtk_tooltips_new (); - - prop1 = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (prop1), _("Parameters")); - gtk_window_set_resizable (GTK_WINDOW (prop1), FALSE); - prop1_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (prop1_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (prop1), prop1_icon_pixbuf); - gdk_pixbuf_unref (prop1_icon_pixbuf); - } - - prop1box = GTK_DIALOG (prop1)->vbox; - - prop1notebook = gtk_notebook_new (); - gtk_widget_show (prop1notebook); - gtk_box_pack_start (GTK_BOX (prop1box), prop1notebook, TRUE, TRUE, 0); - - vbox9 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox9); - gtk_container_add (GTK_CONTAINER (prop1notebook), vbox9); - - frame26 = gtk_frame_new (NULL); - gtk_widget_show (frame26); - gtk_box_pack_start (GTK_BOX (vbox9), frame26, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame26), 6); - - alignment21 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_widget_show (alignment21); - gtk_container_add (GTK_CONTAINER (frame26), alignment21); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment21), 0, 0, 12, 0); - - vbox29 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox29); - gtk_container_add (GTK_CONTAINER (alignment21), vbox29); - - enable_ipv6 = gtk_check_button_new_with_mnemonic (_("Use IPv6 network (if available)")); - gtk_widget_show (enable_ipv6); - gtk_box_pack_start (GTK_BOX (vbox29), enable_ipv6, FALSE, FALSE, 0); - gtk_tooltips_set_tip (tooltips, enable_ipv6, _("Toggle this if you are on an ipv6 network and you wish linphone to use it."), NULL); - - label105 = gtk_label_new (_("Global")); - gtk_widget_show (label105); - gtk_frame_set_label_widget (GTK_FRAME (frame26), label105); - gtk_label_set_use_markup (GTK_LABEL (label105), TRUE); - - frame21 = gtk_frame_new (NULL); - gtk_widget_show (frame21); - gtk_box_pack_start (GTK_BOX (vbox9), frame21, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame21), 5); - - vbox21 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox21); - gtk_container_add (GTK_CONTAINER (frame21), vbox21); - gtk_container_set_border_width (GTK_CONTAINER (vbox21), 6); - - label56 = gtk_label_new (_("These options is only for users in a private network, behind a gateway. If you are not in this situation, then leave this empty.")); - gtk_widget_show (label56); - gtk_box_pack_start (GTK_BOX (vbox21), label56, TRUE, TRUE, 0); - gtk_label_set_line_wrap (GTK_LABEL (label56), TRUE); - gtk_misc_set_padding (GTK_MISC (label56), 0, 12); - - table13 = gtk_table_new (3, 2, FALSE); - gtk_widget_show (table13); - gtk_box_pack_start (GTK_BOX (vbox21), table13, FALSE, FALSE, 0); - - no_nat = gtk_radio_button_new_with_mnemonic (NULL, _("No firewall")); - gtk_widget_show (no_nat); - gtk_table_attach (GTK_TABLE (table13), no_nat, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (no_nat), no_nat_group); - no_nat_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (no_nat)); - - use_stun = gtk_radio_button_new_with_mnemonic (NULL, _("Use this STUN server to guess firewall address :")); - gtk_widget_show (use_stun); - gtk_table_attach (GTK_TABLE (table13), use_stun, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (use_stun), no_nat_group); - no_nat_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (use_stun)); - - static_nat = gtk_radio_button_new_with_mnemonic (NULL, _("Specify firewall address manually:")); - gtk_widget_show (static_nat); - gtk_table_attach (GTK_TABLE (table13), static_nat, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_radio_button_set_group (GTK_RADIO_BUTTON (static_nat), no_nat_group); - no_nat_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (static_nat)); - - nat_address = gtk_entry_new (); - gtk_widget_show (nat_address); - gtk_table_attach (GTK_TABLE (table13), nat_address, 1, 2, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - stun_server = gtk_entry_new (); - gtk_widget_show (stun_server); - gtk_table_attach (GTK_TABLE (table13), stun_server, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - label55 = gtk_label_new (_("NAT traversal options (experimental)")); - gtk_widget_show (label55); - gtk_frame_set_label_widget (GTK_FRAME (frame21), label55); - - frame20 = gtk_frame_new (NULL); - gtk_widget_show (frame20); - gtk_box_pack_start (GTK_BOX (vbox9), frame20, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame20), 5); - - table6 = gtk_table_new (2, 2, FALSE); - gtk_widget_show (table6); - gtk_container_add (GTK_CONTAINER (frame20), table6); - - audio_jittcomp = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (150, 60, 512, 10, 0, 0))); - gtk_widget_show (audio_jittcomp); - gtk_table_attach (GTK_TABLE (table6), audio_jittcomp, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND), 20, 0); - gtk_scale_set_value_pos (GTK_SCALE (audio_jittcomp), GTK_POS_RIGHT); - gtk_scale_set_digits (GTK_SCALE (audio_jittcomp), 0); - - audioport_adj = gtk_adjustment_new (7000, 5000, 65535, 1, 10, 10); - audioport = gtk_spin_button_new (GTK_ADJUSTMENT (audioport_adj), 4, 0); - gtk_widget_show (audioport); - gtk_table_attach (GTK_TABLE (table6), audioport, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND), 20, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (audioport), TRUE); - - label52 = gtk_label_new (_("Number of buffered miliseconds (jitter compensation):")); - gtk_widget_show (label52); - gtk_table_attach (GTK_TABLE (table6), label52, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (label52), GTK_JUSTIFY_CENTER); - gtk_label_set_line_wrap (GTK_LABEL (label52), TRUE); - - label53 = gtk_label_new (_("RTP port used for audio:")); - gtk_widget_show (label53); - gtk_table_attach (GTK_TABLE (table6), label53, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - gtk_label_set_justify (GTK_LABEL (label53), GTK_JUSTIFY_CENTER); - - label54 = gtk_label_new (_("RTP properties")); - gtk_widget_show (label54); - gtk_frame_set_label_widget (GTK_FRAME (frame20), label54); - - frame25 = gtk_frame_new (NULL); - gtk_widget_show (frame25); - gtk_box_pack_start (GTK_BOX (vbox9), frame25, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame25), 5); - - alignment20 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_widget_show (alignment20); - gtk_container_add (GTK_CONTAINER (frame25), alignment20); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment20), 0, 0, 12, 0); - - vbox28 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox28); - gtk_container_add (GTK_CONTAINER (alignment20), vbox28); - - use_sipinfo = gtk_check_button_new_with_mnemonic (_("Use SIP INFO message instead of RTP rfc2833 for DTMF transmitting")); - gtk_widget_show (use_sipinfo); - gtk_box_pack_start (GTK_BOX (vbox28), use_sipinfo, FALSE, FALSE, 0); - gtk_tooltips_set_tip (tooltips, use_sipinfo, _("RTP-RFC2833 is the recommended way."), NULL); - - label103 = gtk_label_new (_("Other")); - gtk_widget_show (label103); - gtk_frame_set_label_widget (GTK_FRAME (frame25), label103); - gtk_label_set_use_markup (GTK_LABEL (label103), TRUE); - - network = gtk_label_new (_("Network")); - gtk_widget_show (network); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (prop1notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (prop1notebook), 0), network); - gtk_label_set_justify (GTK_LABEL (network), GTK_JUSTIFY_CENTER); - - vbox12 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox12); - gtk_container_add (GTK_CONTAINER (prop1notebook), vbox12); - - vbox20 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox20); - gtk_box_pack_start (GTK_BOX (vbox12), vbox20, FALSE, TRUE, 0); - - frame17 = gtk_frame_new (NULL); - gtk_widget_show (frame17); - gtk_box_pack_start (GTK_BOX (vbox20), frame17, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame17), 10); - - vbox16 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox16); - gtk_container_add (GTK_CONTAINER (frame17), vbox16); - - table4 = gtk_table_new (6, 2, FALSE); - gtk_widget_show (table4); - gtk_box_pack_start (GTK_BOX (vbox16), table4, TRUE, TRUE, 0); - - label10 = gtk_label_new (_("Playback sound device:")); - gtk_widget_show (label10); - gtk_table_attach (GTK_TABLE (table4), label10, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_EXPAND), - (GtkAttachOptions) (GTK_EXPAND), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label10), 0, 0.5); - - combo3 = gtk_combo_new (); - g_object_set_data (G_OBJECT (GTK_COMBO (combo3)->popwin), - "GladeParentKey", combo3); - gtk_widget_show (combo3); - gtk_table_attach (GTK_TABLE (table4), combo3, 1, 2, 2, 3, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_combo_set_value_in_list (GTK_COMBO (combo3), TRUE, FALSE); - combo3_items = g_list_append (combo3_items, (gpointer) _("micro")); - combo3_items = g_list_append (combo3_items, (gpointer) _("line")); - combo3_items = g_list_append (combo3_items, (gpointer) ""); - gtk_combo_set_popdown_strings (GTK_COMBO (combo3), combo3_items); - g_list_free (combo3_items); - - rec_source = GTK_COMBO (combo3)->entry; - gtk_widget_show (rec_source); - gtk_editable_set_editable (GTK_EDITABLE (rec_source), FALSE); - - label106 = gtk_label_new (_("Capture sound device:")); - gtk_widget_show (label106); - gtk_table_attach (GTK_TABLE (table4), label106, 0, 1, 1, 2, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (label106), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (label106), 0, 0.5); - - play_card = gtk_combo_box_new_text (); - gtk_widget_show (play_card); - gtk_table_attach (GTK_TABLE (table4), play_card, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - - capt_card = gtk_combo_box_new_text (); - gtk_widget_show (capt_card); - gtk_table_attach (GTK_TABLE (table4), capt_card, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - - label11 = gtk_label_new (_("Recording source:")); - gtk_widget_show (label11); - gtk_table_attach (GTK_TABLE (table4), label11, 0, 1, 2, 3, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label11), 0, 0.5); - - ringsnddev_label = gtk_label_new (_("Ring sound device")); - gtk_widget_show (ringsnddev_label); - gtk_table_attach (GTK_TABLE (table4), ringsnddev_label, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_EXPAND), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (ringsnddev_label), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (ringsnddev_label), 0, 0.5); - - label63 = gtk_label_new (_("Ring sound:")); - gtk_widget_show (label63); - gtk_table_attach (GTK_TABLE (table4), label63, 0, 1, 4, 5, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (label63), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (label63), 0, 0.5); - - ring_card = gtk_combo_box_new_text (); - gtk_widget_show (ring_card); - gtk_table_attach (GTK_TABLE (table4), ring_card, 1, 2, 3, 4, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - - echocancelation = gtk_check_button_new_with_mnemonic (""); - gtk_widget_show (echocancelation); - gtk_table_attach (GTK_TABLE (table4), echocancelation, 1, 2, 5, 6, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - label115 = gtk_label_new (_("Enable echo-canceler (cancels the echo heard by the remote party)")); - gtk_widget_show (label115); - gtk_table_attach (GTK_TABLE (table4), label115, 0, 1, 5, 6, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); - gtk_label_set_justify (GTK_LABEL (label115), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (label115), 0, 0.5); - - hbox20 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox20); - gtk_table_attach (GTK_TABLE (table4), hbox20, 1, 2, 4, 5, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (GTK_FILL), 0, 0); - - ringfileentry = gtk_file_chooser_button_new (_("Choose file"), GTK_FILE_CHOOSER_ACTION_OPEN); - gtk_widget_show (ringfileentry); - gtk_box_pack_start (GTK_BOX (hbox20), ringfileentry, TRUE, TRUE, 0); - - ringpreview = gtk_button_new (); - gtk_widget_show (ringpreview); - gtk_box_pack_start (GTK_BOX (hbox20), ringpreview, FALSE, FALSE, 10); - - alignment24 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment24); - gtk_container_add (GTK_CONTAINER (ringpreview), alignment24); - - hbox37 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox37); - gtk_container_add (GTK_CONTAINER (alignment24), hbox37); - - image42 = gtk_image_new_from_stock ("gtk-dialog-info", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image42); - gtk_box_pack_start (GTK_BOX (hbox37), image42, FALSE, FALSE, 0); - - label118 = gtk_label_new_with_mnemonic (_("Listen")); - gtk_widget_show (label118); - gtk_box_pack_start (GTK_BOX (hbox37), label118, FALSE, FALSE, 0); - - label48 = gtk_label_new (_("Sound properties")); - gtk_widget_show (label48); - gtk_frame_set_label_widget (GTK_FRAME (frame17), label48); - - sound = gtk_label_new (_("Sound device")); - gtk_widget_show (sound); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (prop1notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (prop1notebook), 1), sound); - gtk_label_set_justify (GTK_LABEL (sound), GTK_JUSTIFY_CENTER); - - vbox7 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox7); - gtk_container_add (GTK_CONTAINER (prop1notebook), vbox7); - - frame10 = gtk_frame_new (NULL); - gtk_widget_show (frame10); - gtk_box_pack_start (GTK_BOX (vbox7), frame10, FALSE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame10), 10); - - hbox6 = gtk_hbox_new (FALSE, 67); - gtk_widget_show (hbox6); - gtk_container_add (GTK_CONTAINER (frame10), hbox6); - - label13 = gtk_label_new (_("Run sip user agent on port:")); - gtk_widget_show (label13); - gtk_box_pack_start (GTK_BOX (hbox6), label13, TRUE, TRUE, 0); - gtk_label_set_justify (GTK_LABEL (label13), GTK_JUSTIFY_CENTER); - - sip_port_adj = gtk_adjustment_new (5060, 5000, 65535, 1, 10, 10); - sip_port = gtk_spin_button_new (GTK_ADJUSTMENT (sip_port_adj), 4, 0); - gtk_widget_show (sip_port); - gtk_box_pack_start (GTK_BOX (hbox6), sip_port, TRUE, TRUE, 32); - gtk_tooltips_set_tip (tooltips, sip_port, _("It is strongly recommended to use port 5060."), NULL); - - label43 = gtk_label_new (_("SIP port")); - gtk_widget_show (label43); - gtk_frame_set_label_widget (GTK_FRAME (frame10), label43); - - frame11 = gtk_frame_new (NULL); - gtk_widget_show (frame11); - gtk_box_pack_start (GTK_BOX (vbox7), frame11, FALSE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame11), 10); - - vbox27 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox27); - gtk_container_add (GTK_CONTAINER (frame11), vbox27); - - hbox7 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox7); - gtk_box_pack_start (GTK_BOX (vbox27), hbox7, TRUE, TRUE, 0); - - label26 = gtk_label_new (_("Your sip address:")); - gtk_widget_show (label26); - gtk_box_pack_start (GTK_BOX (hbox7), label26, TRUE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label26), GTK_JUSTIFY_CENTER); - - label27 = gtk_label_new (_("sip:")); - gtk_widget_show (label27); - gtk_box_pack_start (GTK_BOX (hbox7), label27, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label27), GTK_JUSTIFY_RIGHT); - - user_name = gtk_entry_new (); - gtk_widget_show (user_name); - gtk_box_pack_start (GTK_BOX (hbox7), user_name, FALSE, FALSE, 0); - - label28 = gtk_label_new (_("@")); - gtk_widget_show (label28); - gtk_box_pack_start (GTK_BOX (hbox7), label28, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label28), GTK_JUSTIFY_CENTER); - - domain_name = gtk_entry_new (); - gtk_widget_show (domain_name); - gtk_box_pack_start (GTK_BOX (hbox7), domain_name, FALSE, TRUE, 0); - - guess_hostname = gtk_check_button_new_with_mnemonic (_("Automatically guess a valid hostname")); - gtk_widget_show (guess_hostname); - gtk_box_pack_start (GTK_BOX (vbox27), guess_hostname, TRUE, TRUE, 0); - - label44 = gtk_label_new (_("Identity")); - gtk_widget_show (label44); - gtk_frame_set_label_widget (GTK_FRAME (frame11), label44); - - frame1 = gtk_frame_new (NULL); - gtk_widget_show (frame1); - gtk_box_pack_start (GTK_BOX (vbox7), frame1, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame1), 10); - - vbox23 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox23); - gtk_container_add (GTK_CONTAINER (frame1), vbox23); - - scrolledwindow4 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow4); - gtk_box_pack_start (GTK_BOX (vbox23), scrolledwindow4, TRUE, TRUE, 0); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow4), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow4), GTK_SHADOW_ETCHED_OUT); - - proxy_list = gtk_tree_view_new (); - gtk_widget_show (proxy_list); - gtk_container_add (GTK_CONTAINER (scrolledwindow4), proxy_list); - gtk_widget_set_size_request (proxy_list, -1, 100); - - hbuttonbox6 = gtk_hbutton_box_new (); - gtk_widget_show (hbuttonbox6); - gtk_box_pack_start (GTK_BOX (vbox23), hbuttonbox6, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox6), 5); - gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox6), GTK_BUTTONBOX_SPREAD); - - addproxy_button = gtk_button_new (); - gtk_widget_show (addproxy_button); - gtk_container_add (GTK_CONTAINER (hbuttonbox6), addproxy_button); - GTK_WIDGET_SET_FLAGS (addproxy_button, GTK_CAN_DEFAULT); - - alignment12 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment12); - gtk_container_add (GTK_CONTAINER (addproxy_button), alignment12); - - hbox25 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox25); - gtk_container_add (GTK_CONTAINER (alignment12), hbox25); - - image19 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image19); - gtk_box_pack_start (GTK_BOX (hbox25), image19, FALSE, FALSE, 0); - - label77 = gtk_label_new_with_mnemonic (_("Add proxy/registrar")); - gtk_widget_show (label77); - gtk_box_pack_start (GTK_BOX (hbox25), label77, FALSE, FALSE, 0); - - editproxy_button = gtk_button_new (); - gtk_widget_show (editproxy_button); - gtk_container_add (GTK_CONTAINER (hbuttonbox6), editproxy_button); - GTK_WIDGET_SET_FLAGS (editproxy_button, GTK_CAN_DEFAULT); - - alignment13 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment13); - gtk_container_add (GTK_CONTAINER (editproxy_button), alignment13); - - hbox26 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox26); - gtk_container_add (GTK_CONTAINER (alignment13), hbox26); - - image20 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image20); - gtk_box_pack_start (GTK_BOX (hbox26), image20, FALSE, FALSE, 0); - - label78 = gtk_label_new_with_mnemonic (_("Edit")); - gtk_widget_show (label78); - gtk_box_pack_start (GTK_BOX (hbox26), label78, FALSE, FALSE, 0); - - removeproxy_button = gtk_button_new (); - gtk_widget_show (removeproxy_button); - gtk_container_add (GTK_CONTAINER (hbuttonbox6), removeproxy_button); - GTK_WIDGET_SET_FLAGS (removeproxy_button, GTK_CAN_DEFAULT); - - alignment14 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment14); - gtk_container_add (GTK_CONTAINER (removeproxy_button), alignment14); - - hbox27 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox27); - gtk_container_add (GTK_CONTAINER (alignment14), hbox27); - - image21 = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image21); - gtk_box_pack_start (GTK_BOX (hbox27), image21, FALSE, FALSE, 0); - - label79 = gtk_label_new_with_mnemonic (_("Remove")); - gtk_widget_show (label79); - gtk_box_pack_start (GTK_BOX (hbox27), label79, FALSE, FALSE, 0); - - label45 = gtk_label_new (_("Remote services")); - gtk_widget_show (label45); - gtk_frame_set_label_widget (GTK_FRAME (frame1), label45); - - frame24 = gtk_frame_new (NULL); - gtk_widget_show (frame24); - gtk_box_pack_start (GTK_BOX (vbox7), frame24, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame24), 10); - - alignment18 = gtk_alignment_new (0.5, 0.5, 1, 1); - gtk_widget_show (alignment18); - gtk_container_add (GTK_CONTAINER (frame24), alignment18); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment18), 0, 0, 12, 0); - - clear_auth_info = gtk_button_new (); - gtk_widget_show (clear_auth_info); - gtk_container_add (GTK_CONTAINER (alignment18), clear_auth_info); - - alignment19 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment19); - gtk_container_add (GTK_CONTAINER (clear_auth_info), alignment19); - - hbox34 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox34); - gtk_container_add (GTK_CONTAINER (alignment19), hbox34); - - image27 = gtk_image_new_from_stock ("gtk-delete", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image27); - gtk_box_pack_start (GTK_BOX (hbox34), image27, FALSE, FALSE, 0); - - label102 = gtk_label_new_with_mnemonic (_("Clear all stored authentication information (username,password...)")); - gtk_widget_show (label102); - gtk_box_pack_start (GTK_BOX (hbox34), label102, FALSE, FALSE, 0); - - label101 = gtk_label_new (_("Authentication information")); - gtk_widget_show (label101); - gtk_frame_set_label_widget (GTK_FRAME (frame24), label101); - - sip_pref = gtk_label_new (_("SIP")); - gtk_widget_show (sip_pref); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (prop1notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (prop1notebook), 2), sip_pref); - gtk_label_set_justify (GTK_LABEL (sip_pref), GTK_JUSTIFY_CENTER); - - vbox13 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox13); - gtk_container_add (GTK_CONTAINER (prop1notebook), vbox13); - - frame16 = gtk_frame_new (NULL); - gtk_widget_show (frame16); - gtk_box_pack_start (GTK_BOX (vbox13), frame16, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame16), 10); - - hbox9 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox9); - gtk_container_add (GTK_CONTAINER (frame16), hbox9); - - vbox14 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox14); - gtk_box_pack_start (GTK_BOX (hbox9), vbox14, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox14), 9); - - label9 = gtk_label_new (_("List of audio codecs, in order of preference:")); - gtk_widget_show (label9); - gtk_box_pack_start (GTK_BOX (vbox14), label9, FALSE, FALSE, 4); - gtk_misc_set_alignment (GTK_MISC (label9), 0, 0.5); - - codec_notebook = gtk_notebook_new (); - gtk_widget_show (codec_notebook); - gtk_box_pack_start (GTK_BOX (vbox14), codec_notebook, TRUE, TRUE, 0); - - scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow2); - gtk_container_add (GTK_CONTAINER (codec_notebook), scrolledwindow2); - GTK_WIDGET_UNSET_FLAGS (scrolledwindow2, GTK_CAN_FOCUS); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_SHADOW_ETCHED_IN); - - au_codec_list = gtk_tree_view_new (); - gtk_widget_show (au_codec_list); - gtk_container_add (GTK_CONTAINER (scrolledwindow2), au_codec_list); - gtk_tree_view_set_reorderable (GTK_TREE_VIEW (au_codec_list), TRUE); - - label116 = gtk_label_new (_("Audio codecs")); - gtk_widget_show (label116); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (codec_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (codec_notebook), 0), label116); - - scrolledwindow7 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow7); - gtk_container_add (GTK_CONTAINER (codec_notebook), scrolledwindow7); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow7), GTK_SHADOW_IN); - - vid_codec_list = gtk_tree_view_new (); - gtk_widget_show (vid_codec_list); - gtk_container_add (GTK_CONTAINER (scrolledwindow7), vid_codec_list); - - label117 = gtk_label_new (_("Video Codecs")); - gtk_widget_show (label117); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (codec_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (codec_notebook), 1), label117); - - hbuttonbox4 = gtk_hbutton_box_new (); - gtk_widget_show (hbuttonbox4); - gtk_box_pack_start (GTK_BOX (vbox14), hbuttonbox4, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox4), 10); - - aucodec_up = gtk_button_new_from_stock ("gtk-go-up"); - gtk_widget_show (aucodec_up); - gtk_container_add (GTK_CONTAINER (hbuttonbox4), aucodec_up); - GTK_WIDGET_SET_FLAGS (aucodec_up, GTK_CAN_DEFAULT); - - aucodec_down = gtk_button_new_from_stock ("gtk-go-down"); - gtk_widget_show (aucodec_down); - gtk_container_add (GTK_CONTAINER (hbuttonbox4), aucodec_down); - GTK_WIDGET_SET_FLAGS (aucodec_down, GTK_CAN_DEFAULT); - - aucodec_enable = gtk_button_new (); - gtk_widget_show (aucodec_enable); - gtk_container_add (GTK_CONTAINER (hbuttonbox4), aucodec_enable); - GTK_WIDGET_SET_FLAGS (aucodec_enable, GTK_CAN_DEFAULT); - - alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment1); - gtk_container_add (GTK_CONTAINER (aucodec_enable), alignment1); - - hbox11 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox11); - gtk_container_add (GTK_CONTAINER (alignment1), hbox11); - - image4 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image4); - gtk_box_pack_start (GTK_BOX (hbox11), image4, FALSE, FALSE, 0); - - label50 = gtk_label_new_with_mnemonic (_("Enable")); - gtk_widget_show (label50); - gtk_box_pack_start (GTK_BOX (hbox11), label50, FALSE, FALSE, 0); - - aucodec_disable = gtk_button_new (); - gtk_widget_show (aucodec_disable); - gtk_container_add (GTK_CONTAINER (hbuttonbox4), aucodec_disable); - GTK_WIDGET_SET_FLAGS (aucodec_disable, GTK_CAN_DEFAULT); - - alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment2); - gtk_container_add (GTK_CONTAINER (aucodec_disable), alignment2); - - hbox12 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox12); - gtk_container_add (GTK_CONTAINER (alignment2), hbox12); - - image5 = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image5); - gtk_box_pack_start (GTK_BOX (hbox12), image5, FALSE, FALSE, 0); - - label51 = gtk_label_new_with_mnemonic (_("Disable")); - gtk_widget_show (label51); - gtk_box_pack_start (GTK_BOX (hbox12), label51, FALSE, FALSE, 0); - - table12 = gtk_table_new (2, 2, TRUE); - gtk_widget_show (table12); - gtk_box_pack_start (GTK_BOX (vbox14), table12, FALSE, TRUE, 0); - - label112 = gtk_label_new (_("Upload bandwidth (kbit/sec):")); - gtk_widget_show (label112); - gtk_table_attach (GTK_TABLE (table12), label112, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (label112), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (label112), 0, 0.5); - - label111 = gtk_label_new (_("Download bandwidth (kbit/sec):")); - gtk_widget_show (label111); - gtk_table_attach (GTK_TABLE (table12), label111, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (label111), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (label111), 0, 0.5); - - download_bw_adj = gtk_adjustment_new (0, 0, 100000, 10, 100, 10); - download_bw = gtk_spin_button_new (GTK_ADJUSTMENT (download_bw_adj), 1, 0); - gtk_widget_show (download_bw); - gtk_table_attach (GTK_TABLE (table12), download_bw, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (download_bw), GTK_UPDATE_IF_VALID); - - upload_bw_adj = gtk_adjustment_new (0, 0, 100000, 10, 100, 10); - upload_bw = gtk_spin_button_new (GTK_ADJUSTMENT (upload_bw_adj), 1, 0); - gtk_widget_show (upload_bw); - gtk_table_attach (GTK_TABLE (table12), upload_bw, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - vbox17 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox17); - gtk_box_pack_start (GTK_BOX (hbox9), vbox17, TRUE, FALSE, 0); - - label22 = gtk_label_new (_("Note: Codecs in red are not usable regarding to your connection type to the internet.")); - gtk_widget_show (label22); - gtk_box_pack_start (GTK_BOX (vbox17), label22, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label22), GTK_JUSTIFY_CENTER); - gtk_label_set_line_wrap (GTK_LABEL (label22), TRUE); - gtk_misc_set_padding (GTK_MISC (label22), 15, 0); - - frame18 = gtk_frame_new (NULL); - gtk_widget_show (frame18); - gtk_box_pack_start (GTK_BOX (vbox17), frame18, TRUE, TRUE, 5); - gtk_container_set_border_width (GTK_CONTAINER (frame18), 8); - - codec_info = gtk_label_new (_("No information availlable")); - gtk_widget_show (codec_info); - gtk_container_add (GTK_CONTAINER (frame18), codec_info); - gtk_label_set_justify (GTK_LABEL (codec_info), GTK_JUSTIFY_CENTER); - gtk_label_set_line_wrap (GTK_LABEL (codec_info), TRUE); - gtk_misc_set_padding (GTK_MISC (codec_info), 10, 10); - - label47 = gtk_label_new (_("Codec information")); - gtk_widget_show (label47); - gtk_frame_set_label_widget (GTK_FRAME (frame18), label47); - - label46 = gtk_label_new (_("Audio and video codecs")); - gtk_widget_show (label46); - gtk_frame_set_label_widget (GTK_FRAME (frame16), label46); - gtk_misc_set_alignment (GTK_MISC (label46), 0.53, 0.5); - - codecs_pref = gtk_label_new (_("Codecs")); - gtk_widget_show (codecs_pref); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (prop1notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (prop1notebook), 3), codecs_pref); - gtk_label_set_justify (GTK_LABEL (codecs_pref), GTK_JUSTIFY_CENTER); - - hbuttonbox7 = GTK_DIALOG (prop1)->action_area; - gtk_widget_show (hbuttonbox7); - gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox7), GTK_BUTTONBOX_END); - - prop_help_button = gtk_button_new_from_stock ("gtk-help"); - gtk_widget_show (prop_help_button); - gtk_dialog_add_action_widget (GTK_DIALOG (prop1), prop_help_button, GTK_RESPONSE_HELP); - GTK_WIDGET_SET_FLAGS (prop_help_button, GTK_CAN_DEFAULT); - - prop_apply_button = gtk_button_new_from_stock ("gtk-apply"); - gtk_widget_show (prop_apply_button); - gtk_dialog_add_action_widget (GTK_DIALOG (prop1), prop_apply_button, GTK_RESPONSE_APPLY); - GTK_WIDGET_SET_FLAGS (prop_apply_button, GTK_CAN_DEFAULT); - - prop_close_button = gtk_button_new_from_stock ("gtk-close"); - gtk_widget_show (prop_close_button); - gtk_dialog_add_action_widget (GTK_DIALOG (prop1), prop_close_button, GTK_RESPONSE_CLOSE); - GTK_WIDGET_SET_FLAGS (prop_close_button, GTK_CAN_DEFAULT); - - prop_ok_button = gtk_button_new_from_stock ("gtk-ok"); - gtk_widget_show (prop_ok_button); - gtk_dialog_add_action_widget (GTK_DIALOG (prop1), prop_ok_button, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (prop_ok_button, GTK_CAN_DEFAULT); - - g_signal_connect ((gpointer) prop1, "close", - G_CALLBACK (on_prop1_close), - NULL); - g_signal_connect ((gpointer) prop1, "close", - G_CALLBACK (on_property_box_closed), - NULL); - g_signal_connect ((gpointer) prop1, "response", - G_CALLBACK (on_property_box_response), - NULL); - g_signal_connect ((gpointer) enable_ipv6, "toggled", - G_CALLBACK (on_enable_ipv6_toggled), - NULL); - g_signal_connect ((gpointer) no_nat, "toggled", - G_CALLBACK (on_no_nat_toggled), - NULL); - g_signal_connect ((gpointer) use_stun, "toggled", - G_CALLBACK (on_use_stun_toggled), - NULL); - g_signal_connect ((gpointer) static_nat, "toggled", - G_CALLBACK (on_static_nat_toggled), - NULL); - g_signal_connect ((gpointer) nat_address, "changed", - G_CALLBACK (on_nat_address_changed), - NULL); - g_signal_connect ((gpointer) stun_server, "changed", - G_CALLBACK (on_stun_server_changed), - NULL); - g_signal_connect ((gpointer) audio_jittcomp, "value_changed", - G_CALLBACK (on_audio_jittcomp_value_changed), - NULL); - g_signal_connect ((gpointer) audioport, "changed", - G_CALLBACK (on_audioport_changed), - NULL); - g_signal_connect ((gpointer) use_sipinfo, "toggled", - G_CALLBACK (on_use_sipinfo_toggled), - NULL); - g_signal_connect ((gpointer) rec_source, "changed", - G_CALLBACK (on_source_changed), - NULL); - g_signal_connect ((gpointer) play_card, "changed", - G_CALLBACK (on_play_card_changed), - NULL); - g_signal_connect ((gpointer) capt_card, "changed", - G_CALLBACK (on_capt_card_changed), - NULL); - g_signal_connect ((gpointer) ring_card, "changed", - G_CALLBACK (on_ring_card_changed), - NULL); - g_signal_connect ((gpointer) echocancelation, "toggled", - G_CALLBACK (on_echocancelation_toggled), - NULL); - g_signal_connect ((gpointer) ringpreview, "clicked", - G_CALLBACK (on_ringpreview_clicked), - NULL); - g_signal_connect ((gpointer) sip_port, "changed", - G_CALLBACK (on_sipport_changed), - NULL); - g_signal_connect ((gpointer) user_name, "changed", - G_CALLBACK (on_user_name_changed), - NULL); - g_signal_connect ((gpointer) domain_name, "changed", - G_CALLBACK (on_domain_name_changed), - NULL); - g_signal_connect ((gpointer) guess_hostname, "toggled", - G_CALLBACK (on_guess_hostname_toggled), - NULL); - g_signal_connect ((gpointer) addproxy_button, "clicked", - G_CALLBACK (on_addproxy_button_clicked), - NULL); - g_signal_connect ((gpointer) editproxy_button, "clicked", - G_CALLBACK (on_editproxy_button_clicked), - NULL); - g_signal_connect ((gpointer) removeproxy_button, "clicked", - G_CALLBACK (on_removeproxy_button_clicked), - NULL); - g_signal_connect ((gpointer) clear_auth_info, "clicked", - G_CALLBACK (on_clear_auth_info_clicked), - NULL); - g_signal_connect ((gpointer) aucodec_up, "clicked", - G_CALLBACK (on_aucodec_up_clicked), - NULL); - g_signal_connect ((gpointer) aucodec_down, "clicked", - G_CALLBACK (on_aucodec_down_clicked), - NULL); - g_signal_connect ((gpointer) aucodec_enable, "clicked", - G_CALLBACK (on_aucodec_enable_clicked), - NULL); - g_signal_connect ((gpointer) aucodec_disable, "clicked", - G_CALLBACK (on_aucodec_disable_clicked), - NULL); - g_signal_connect ((gpointer) download_bw, "value_changed", - G_CALLBACK (on_download_bw_value_changed), - NULL); - g_signal_connect ((gpointer) upload_bw, "value_changed", - G_CALLBACK (on_upload_bw_value_changed), - NULL); - g_signal_connect ((gpointer) prop_help_button, "clicked", - G_CALLBACK (on_prop1_help), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (prop1, prop1, "prop1"); - GLADE_HOOKUP_OBJECT_NO_REF (prop1, prop1box, "prop1box"); - GLADE_HOOKUP_OBJECT (prop1, prop1notebook, "prop1notebook"); - GLADE_HOOKUP_OBJECT (prop1, vbox9, "vbox9"); - GLADE_HOOKUP_OBJECT (prop1, frame26, "frame26"); - GLADE_HOOKUP_OBJECT (prop1, alignment21, "alignment21"); - GLADE_HOOKUP_OBJECT (prop1, vbox29, "vbox29"); - GLADE_HOOKUP_OBJECT (prop1, enable_ipv6, "enable_ipv6"); - GLADE_HOOKUP_OBJECT (prop1, label105, "label105"); - GLADE_HOOKUP_OBJECT (prop1, frame21, "frame21"); - GLADE_HOOKUP_OBJECT (prop1, vbox21, "vbox21"); - GLADE_HOOKUP_OBJECT (prop1, label56, "label56"); - GLADE_HOOKUP_OBJECT (prop1, table13, "table13"); - GLADE_HOOKUP_OBJECT (prop1, no_nat, "no_nat"); - GLADE_HOOKUP_OBJECT (prop1, use_stun, "use_stun"); - GLADE_HOOKUP_OBJECT (prop1, static_nat, "static_nat"); - GLADE_HOOKUP_OBJECT (prop1, nat_address, "nat_address"); - GLADE_HOOKUP_OBJECT (prop1, stun_server, "stun_server"); - GLADE_HOOKUP_OBJECT (prop1, label55, "label55"); - GLADE_HOOKUP_OBJECT (prop1, frame20, "frame20"); - GLADE_HOOKUP_OBJECT (prop1, table6, "table6"); - GLADE_HOOKUP_OBJECT (prop1, audio_jittcomp, "audio_jittcomp"); - GLADE_HOOKUP_OBJECT (prop1, audioport, "audioport"); - GLADE_HOOKUP_OBJECT (prop1, label52, "label52"); - GLADE_HOOKUP_OBJECT (prop1, label53, "label53"); - GLADE_HOOKUP_OBJECT (prop1, label54, "label54"); - GLADE_HOOKUP_OBJECT (prop1, frame25, "frame25"); - GLADE_HOOKUP_OBJECT (prop1, alignment20, "alignment20"); - GLADE_HOOKUP_OBJECT (prop1, vbox28, "vbox28"); - GLADE_HOOKUP_OBJECT (prop1, use_sipinfo, "use_sipinfo"); - GLADE_HOOKUP_OBJECT (prop1, label103, "label103"); - GLADE_HOOKUP_OBJECT (prop1, network, "network"); - GLADE_HOOKUP_OBJECT (prop1, vbox12, "vbox12"); - GLADE_HOOKUP_OBJECT (prop1, vbox20, "vbox20"); - GLADE_HOOKUP_OBJECT (prop1, frame17, "frame17"); - GLADE_HOOKUP_OBJECT (prop1, vbox16, "vbox16"); - GLADE_HOOKUP_OBJECT (prop1, table4, "table4"); - GLADE_HOOKUP_OBJECT (prop1, label10, "label10"); - GLADE_HOOKUP_OBJECT (prop1, combo3, "combo3"); - GLADE_HOOKUP_OBJECT (prop1, rec_source, "rec_source"); - GLADE_HOOKUP_OBJECT (prop1, label106, "label106"); - GLADE_HOOKUP_OBJECT (prop1, play_card, "play_card"); - GLADE_HOOKUP_OBJECT (prop1, capt_card, "capt_card"); - GLADE_HOOKUP_OBJECT (prop1, label11, "label11"); - GLADE_HOOKUP_OBJECT (prop1, ringsnddev_label, "ringsnddev_label"); - GLADE_HOOKUP_OBJECT (prop1, label63, "label63"); - GLADE_HOOKUP_OBJECT (prop1, ring_card, "ring_card"); - GLADE_HOOKUP_OBJECT (prop1, echocancelation, "echocancelation"); - GLADE_HOOKUP_OBJECT (prop1, label115, "label115"); - GLADE_HOOKUP_OBJECT (prop1, hbox20, "hbox20"); - GLADE_HOOKUP_OBJECT (prop1, ringfileentry, "ringfileentry"); - GLADE_HOOKUP_OBJECT (prop1, ringpreview, "ringpreview"); - GLADE_HOOKUP_OBJECT (prop1, alignment24, "alignment24"); - GLADE_HOOKUP_OBJECT (prop1, hbox37, "hbox37"); - GLADE_HOOKUP_OBJECT (prop1, image42, "image42"); - GLADE_HOOKUP_OBJECT (prop1, label118, "label118"); - GLADE_HOOKUP_OBJECT (prop1, label48, "label48"); - GLADE_HOOKUP_OBJECT (prop1, sound, "sound"); - GLADE_HOOKUP_OBJECT (prop1, vbox7, "vbox7"); - GLADE_HOOKUP_OBJECT (prop1, frame10, "frame10"); - GLADE_HOOKUP_OBJECT (prop1, hbox6, "hbox6"); - GLADE_HOOKUP_OBJECT (prop1, label13, "label13"); - GLADE_HOOKUP_OBJECT (prop1, sip_port, "sip_port"); - GLADE_HOOKUP_OBJECT (prop1, label43, "label43"); - GLADE_HOOKUP_OBJECT (prop1, frame11, "frame11"); - GLADE_HOOKUP_OBJECT (prop1, vbox27, "vbox27"); - GLADE_HOOKUP_OBJECT (prop1, hbox7, "hbox7"); - GLADE_HOOKUP_OBJECT (prop1, label26, "label26"); - GLADE_HOOKUP_OBJECT (prop1, label27, "label27"); - GLADE_HOOKUP_OBJECT (prop1, user_name, "user_name"); - GLADE_HOOKUP_OBJECT (prop1, label28, "label28"); - GLADE_HOOKUP_OBJECT (prop1, domain_name, "domain_name"); - GLADE_HOOKUP_OBJECT (prop1, guess_hostname, "guess_hostname"); - GLADE_HOOKUP_OBJECT (prop1, label44, "label44"); - GLADE_HOOKUP_OBJECT (prop1, frame1, "frame1"); - GLADE_HOOKUP_OBJECT (prop1, vbox23, "vbox23"); - GLADE_HOOKUP_OBJECT (prop1, scrolledwindow4, "scrolledwindow4"); - GLADE_HOOKUP_OBJECT (prop1, proxy_list, "proxy_list"); - GLADE_HOOKUP_OBJECT (prop1, hbuttonbox6, "hbuttonbox6"); - GLADE_HOOKUP_OBJECT (prop1, addproxy_button, "addproxy_button"); - GLADE_HOOKUP_OBJECT (prop1, alignment12, "alignment12"); - GLADE_HOOKUP_OBJECT (prop1, hbox25, "hbox25"); - GLADE_HOOKUP_OBJECT (prop1, image19, "image19"); - GLADE_HOOKUP_OBJECT (prop1, label77, "label77"); - GLADE_HOOKUP_OBJECT (prop1, editproxy_button, "editproxy_button"); - GLADE_HOOKUP_OBJECT (prop1, alignment13, "alignment13"); - GLADE_HOOKUP_OBJECT (prop1, hbox26, "hbox26"); - GLADE_HOOKUP_OBJECT (prop1, image20, "image20"); - GLADE_HOOKUP_OBJECT (prop1, label78, "label78"); - GLADE_HOOKUP_OBJECT (prop1, removeproxy_button, "removeproxy_button"); - GLADE_HOOKUP_OBJECT (prop1, alignment14, "alignment14"); - GLADE_HOOKUP_OBJECT (prop1, hbox27, "hbox27"); - GLADE_HOOKUP_OBJECT (prop1, image21, "image21"); - GLADE_HOOKUP_OBJECT (prop1, label79, "label79"); - GLADE_HOOKUP_OBJECT (prop1, label45, "label45"); - GLADE_HOOKUP_OBJECT (prop1, frame24, "frame24"); - GLADE_HOOKUP_OBJECT (prop1, alignment18, "alignment18"); - GLADE_HOOKUP_OBJECT (prop1, clear_auth_info, "clear_auth_info"); - GLADE_HOOKUP_OBJECT (prop1, alignment19, "alignment19"); - GLADE_HOOKUP_OBJECT (prop1, hbox34, "hbox34"); - GLADE_HOOKUP_OBJECT (prop1, image27, "image27"); - GLADE_HOOKUP_OBJECT (prop1, label102, "label102"); - GLADE_HOOKUP_OBJECT (prop1, label101, "label101"); - GLADE_HOOKUP_OBJECT (prop1, sip_pref, "sip_pref"); - GLADE_HOOKUP_OBJECT (prop1, vbox13, "vbox13"); - GLADE_HOOKUP_OBJECT (prop1, frame16, "frame16"); - GLADE_HOOKUP_OBJECT (prop1, hbox9, "hbox9"); - GLADE_HOOKUP_OBJECT (prop1, vbox14, "vbox14"); - GLADE_HOOKUP_OBJECT (prop1, label9, "label9"); - GLADE_HOOKUP_OBJECT (prop1, codec_notebook, "codec_notebook"); - GLADE_HOOKUP_OBJECT (prop1, scrolledwindow2, "scrolledwindow2"); - GLADE_HOOKUP_OBJECT (prop1, au_codec_list, "au_codec_list"); - GLADE_HOOKUP_OBJECT (prop1, label116, "label116"); - GLADE_HOOKUP_OBJECT (prop1, scrolledwindow7, "scrolledwindow7"); - GLADE_HOOKUP_OBJECT (prop1, vid_codec_list, "vid_codec_list"); - GLADE_HOOKUP_OBJECT (prop1, label117, "label117"); - GLADE_HOOKUP_OBJECT (prop1, hbuttonbox4, "hbuttonbox4"); - GLADE_HOOKUP_OBJECT (prop1, aucodec_up, "aucodec_up"); - GLADE_HOOKUP_OBJECT (prop1, aucodec_down, "aucodec_down"); - GLADE_HOOKUP_OBJECT (prop1, aucodec_enable, "aucodec_enable"); - GLADE_HOOKUP_OBJECT (prop1, alignment1, "alignment1"); - GLADE_HOOKUP_OBJECT (prop1, hbox11, "hbox11"); - GLADE_HOOKUP_OBJECT (prop1, image4, "image4"); - GLADE_HOOKUP_OBJECT (prop1, label50, "label50"); - GLADE_HOOKUP_OBJECT (prop1, aucodec_disable, "aucodec_disable"); - GLADE_HOOKUP_OBJECT (prop1, alignment2, "alignment2"); - GLADE_HOOKUP_OBJECT (prop1, hbox12, "hbox12"); - GLADE_HOOKUP_OBJECT (prop1, image5, "image5"); - GLADE_HOOKUP_OBJECT (prop1, label51, "label51"); - GLADE_HOOKUP_OBJECT (prop1, table12, "table12"); - GLADE_HOOKUP_OBJECT (prop1, label112, "label112"); - GLADE_HOOKUP_OBJECT (prop1, label111, "label111"); - GLADE_HOOKUP_OBJECT (prop1, download_bw, "download_bw"); - GLADE_HOOKUP_OBJECT (prop1, upload_bw, "upload_bw"); - GLADE_HOOKUP_OBJECT (prop1, vbox17, "vbox17"); - GLADE_HOOKUP_OBJECT (prop1, label22, "label22"); - GLADE_HOOKUP_OBJECT (prop1, frame18, "frame18"); - GLADE_HOOKUP_OBJECT (prop1, codec_info, "codec_info"); - GLADE_HOOKUP_OBJECT (prop1, label47, "label47"); - GLADE_HOOKUP_OBJECT (prop1, label46, "label46"); - GLADE_HOOKUP_OBJECT (prop1, codecs_pref, "codecs_pref"); - GLADE_HOOKUP_OBJECT_NO_REF (prop1, hbuttonbox7, "hbuttonbox7"); - GLADE_HOOKUP_OBJECT (prop1, prop_help_button, "prop_help_button"); - GLADE_HOOKUP_OBJECT (prop1, prop_apply_button, "prop_apply_button"); - GLADE_HOOKUP_OBJECT (prop1, prop_close_button, "prop_close_button"); - GLADE_HOOKUP_OBJECT (prop1, prop_ok_button, "prop_ok_button"); - GLADE_HOOKUP_OBJECT_NO_REF (prop1, tooltips, "tooltips"); - - return prop1; -} - -GtkWidget* -create_address_book (void) -{ - GtkWidget *address_book; - GdkPixbuf *address_book_icon_pixbuf; - GtkWidget *dialog_vbox7; - GtkWidget *vbox1; - GtkWidget *scrolledwindow1; - GtkWidget *viewport1; - GtkWidget *address_list; - GtkWidget *dialog_action_area7; - GtkWidget *hbuttonbox1; - GtkWidget *add_address; - GtkWidget *remove_address; - GtkWidget *modify_address; - GtkWidget *alignment15; - GtkWidget *hbox29; - GtkWidget *image22; - GtkWidget *label93; - GtkWidget *close_addbook; - GtkWidget *select_address; - GtkWidget *alignment7; - GtkWidget *hbox19; - GtkWidget *image14; - GtkWidget *label62; - - address_book = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (address_book), _("Address Book")); - gtk_window_set_default_size (GTK_WINDOW (address_book), -1, 305); - address_book_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (address_book_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (address_book), address_book_icon_pixbuf); - gdk_pixbuf_unref (address_book_icon_pixbuf); - } - - dialog_vbox7 = GTK_DIALOG (address_book)->vbox; - gtk_widget_show (dialog_vbox7); - - vbox1 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox1); - gtk_box_pack_start (GTK_BOX (dialog_vbox7), vbox1, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox1), 12); - - scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow1); - gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0); - GTK_WIDGET_UNSET_FLAGS (scrolledwindow1, GTK_CAN_FOCUS); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN); - - viewport1 = gtk_viewport_new (NULL, NULL); - gtk_widget_show (viewport1); - gtk_container_add (GTK_CONTAINER (scrolledwindow1), viewport1); - - address_list = gtk_tree_view_new (); - gtk_widget_show (address_list); - gtk_container_add (GTK_CONTAINER (viewport1), address_list); - - dialog_action_area7 = GTK_DIALOG (address_book)->action_area; - gtk_widget_show (dialog_action_area7); - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area7), GTK_BUTTONBOX_SPREAD); - - hbuttonbox1 = gtk_hbutton_box_new (); - gtk_widget_show (hbuttonbox1); - gtk_container_add (GTK_CONTAINER (dialog_action_area7), hbuttonbox1); - gtk_box_set_spacing (GTK_BOX (hbuttonbox1), 11); - - add_address = gtk_button_new_from_stock ("gtk-add"); - gtk_widget_show (add_address); - gtk_container_add (GTK_CONTAINER (hbuttonbox1), add_address); - GTK_WIDGET_SET_FLAGS (add_address, GTK_CAN_DEFAULT); - gtk_button_set_relief (GTK_BUTTON (add_address), GTK_RELIEF_HALF); - - remove_address = gtk_button_new_from_stock ("gtk-delete"); - gtk_widget_show (remove_address); - gtk_container_add (GTK_CONTAINER (hbuttonbox1), remove_address); - GTK_WIDGET_SET_FLAGS (remove_address, GTK_CAN_DEFAULT); - gtk_button_set_relief (GTK_BUTTON (remove_address), GTK_RELIEF_HALF); - - modify_address = gtk_button_new (); - gtk_widget_show (modify_address); - gtk_container_add (GTK_CONTAINER (hbuttonbox1), modify_address); - GTK_WIDGET_SET_FLAGS (modify_address, GTK_CAN_DEFAULT); - - alignment15 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment15); - gtk_container_add (GTK_CONTAINER (modify_address), alignment15); - - hbox29 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox29); - gtk_container_add (GTK_CONTAINER (alignment15), hbox29); - - image22 = gtk_image_new_from_stock ("gtk-justify-center", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image22); - gtk_box_pack_start (GTK_BOX (hbox29), image22, FALSE, FALSE, 0); - - label93 = gtk_label_new_with_mnemonic (_("Edit")); - gtk_widget_show (label93); - gtk_box_pack_start (GTK_BOX (hbox29), label93, FALSE, FALSE, 0); - - close_addbook = gtk_button_new_from_stock ("gtk-close"); - gtk_widget_show (close_addbook); - gtk_container_add (GTK_CONTAINER (hbuttonbox1), close_addbook); - GTK_WIDGET_SET_FLAGS (close_addbook, GTK_CAN_DEFAULT); - - select_address = gtk_button_new (); - gtk_widget_show (select_address); - gtk_container_add (GTK_CONTAINER (hbuttonbox1), select_address); - GTK_WIDGET_SET_FLAGS (select_address, GTK_CAN_DEFAULT); - - alignment7 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment7); - gtk_container_add (GTK_CONTAINER (select_address), alignment7); - - hbox19 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox19); - gtk_container_add (GTK_CONTAINER (alignment7), hbox19); - - image14 = gtk_image_new_from_stock ("gtk-quit", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image14); - gtk_box_pack_start (GTK_BOX (hbox19), image14, FALSE, FALSE, 0); - - label62 = gtk_label_new_with_mnemonic (_("Select")); - gtk_widget_show (label62); - gtk_box_pack_start (GTK_BOX (hbox19), label62, FALSE, FALSE, 0); - - g_signal_connect ((gpointer) add_address, "clicked", - G_CALLBACK (on_add_address_clicked), - NULL); - g_signal_connect ((gpointer) remove_address, "clicked", - G_CALLBACK (on_remove_address_clicked), - NULL); - g_signal_connect ((gpointer) modify_address, "clicked", - G_CALLBACK (on_modify_address_clicked), - NULL); - g_signal_connect ((gpointer) close_addbook, "clicked", - G_CALLBACK (address_book_close), - NULL); - g_signal_connect ((gpointer) select_address, "clicked", - G_CALLBACK (on_select_address_clicked), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (address_book, address_book, "address_book"); - GLADE_HOOKUP_OBJECT_NO_REF (address_book, dialog_vbox7, "dialog_vbox7"); - GLADE_HOOKUP_OBJECT (address_book, vbox1, "vbox1"); - GLADE_HOOKUP_OBJECT (address_book, scrolledwindow1, "scrolledwindow1"); - GLADE_HOOKUP_OBJECT (address_book, viewport1, "viewport1"); - GLADE_HOOKUP_OBJECT (address_book, address_list, "address_list"); - GLADE_HOOKUP_OBJECT_NO_REF (address_book, dialog_action_area7, "dialog_action_area7"); - GLADE_HOOKUP_OBJECT (address_book, hbuttonbox1, "hbuttonbox1"); - GLADE_HOOKUP_OBJECT (address_book, add_address, "add_address"); - GLADE_HOOKUP_OBJECT (address_book, remove_address, "remove_address"); - GLADE_HOOKUP_OBJECT (address_book, modify_address, "modify_address"); - GLADE_HOOKUP_OBJECT (address_book, alignment15, "alignment15"); - GLADE_HOOKUP_OBJECT (address_book, hbox29, "hbox29"); - GLADE_HOOKUP_OBJECT (address_book, image22, "image22"); - GLADE_HOOKUP_OBJECT (address_book, label93, "label93"); - GLADE_HOOKUP_OBJECT (address_book, close_addbook, "close_addbook"); - GLADE_HOOKUP_OBJECT (address_book, select_address, "select_address"); - GLADE_HOOKUP_OBJECT (address_book, alignment7, "alignment7"); - GLADE_HOOKUP_OBJECT (address_book, hbox19, "hbox19"); - GLADE_HOOKUP_OBJECT (address_book, image14, "image14"); - GLADE_HOOKUP_OBJECT (address_book, label62, "label62"); - - return address_book; -} - -GtkWidget* -create_altressource (void) -{ - GtkWidget *altressource; - GdkPixbuf *altressource_icon_pixbuf; - GtkWidget *dialog_vbox10; - GtkWidget *vbox19; - GtkWidget *label49; - GtkWidget *alt_href; - GtkWidget *dialog_action_area10; - GtkWidget *closebutton1; - - altressource = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (altressource), _("Information")); - gtk_window_set_resizable (GTK_WINDOW (altressource), FALSE); - gtk_window_set_destroy_with_parent (GTK_WINDOW (altressource), TRUE); - altressource_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (altressource_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (altressource), altressource_icon_pixbuf); - gdk_pixbuf_unref (altressource_icon_pixbuf); - } - gtk_window_set_type_hint (GTK_WINDOW (altressource), GDK_WINDOW_TYPE_HINT_DIALOG); - - dialog_vbox10 = GTK_DIALOG (altressource)->vbox; - gtk_widget_show (dialog_vbox10); - - vbox19 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox19); - gtk_box_pack_start (GTK_BOX (dialog_vbox10), vbox19, TRUE, TRUE, 0); - - label49 = gtk_label_new (_("User is not reachable at the moment but he invites you to contact him using the following alternate ressource:")); - gtk_widget_show (label49); - gtk_box_pack_start (GTK_BOX (vbox19), label49, TRUE, TRUE, 10); - gtk_label_set_justify (GTK_LABEL (label49), GTK_JUSTIFY_CENTER); - gtk_label_set_line_wrap (GTK_LABEL (label49), TRUE); - gtk_misc_set_padding (GTK_MISC (label49), 25, 5); - - alt_href = gtk_button_new_with_mnemonic (_("None.")); - gtk_widget_show (alt_href); - gtk_box_pack_start (GTK_BOX (vbox19), alt_href, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (alt_href), 12); - gtk_button_set_relief (GTK_BUTTON (alt_href), GTK_RELIEF_NONE); - - dialog_action_area10 = GTK_DIALOG (altressource)->action_area; - gtk_widget_show (dialog_action_area10); - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area10), GTK_BUTTONBOX_END); - - closebutton1 = gtk_button_new_from_stock ("gtk-close"); - gtk_widget_show (closebutton1); - gtk_dialog_add_action_widget (GTK_DIALOG (altressource), closebutton1, GTK_RESPONSE_CLOSE); - GTK_WIDGET_SET_FLAGS (closebutton1, GTK_CAN_DEFAULT); - - g_signal_connect_swapped ((gpointer) alt_href, "clicked", - G_CALLBACK (on_alt_href_clicked), - GTK_OBJECT (altressource)); - g_signal_connect ((gpointer) alt_href, "realize", - G_CALLBACK (on_alt_href_realize), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (altressource, altressource, "altressource"); - GLADE_HOOKUP_OBJECT_NO_REF (altressource, dialog_vbox10, "dialog_vbox10"); - GLADE_HOOKUP_OBJECT (altressource, vbox19, "vbox19"); - GLADE_HOOKUP_OBJECT (altressource, label49, "label49"); - GLADE_HOOKUP_OBJECT (altressource, alt_href, "alt_href"); - GLADE_HOOKUP_OBJECT_NO_REF (altressource, dialog_action_area10, "dialog_action_area10"); - GLADE_HOOKUP_OBJECT (altressource, closebutton1, "closebutton1"); - - return altressource; -} - -GtkWidget* -create_proxy_config_box (void) -{ - GtkWidget *proxy_config_box; - GdkPixbuf *proxy_config_box_icon_pixbuf; - GtkWidget *dialog_vbox12; - GtkWidget *frame22; - GtkWidget *table8; - GtkWidget *reg_sendregister; - GtkWidget *label82; - GtkWidget *reg_route; - GtkWidget *reg_proxy; - GtkWidget *label83; - GtkWidget *label84; - GtkWidget *reg_identity; - GtkWidget *label85; - GtkObject *reg_expires_adj; - GtkWidget *reg_expires; - GtkWidget *label81; - GtkWidget *label104; - GtkWidget *publish; - GtkWidget *label86; - GtkWidget *dialog_action_area12; - GtkWidget *helpbutton1; - GtkWidget *okbutton2; - - proxy_config_box = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (proxy_config_box), _("Proxy/Registrar configuration box")); - gtk_window_set_modal (GTK_WINDOW (proxy_config_box), TRUE); - gtk_window_set_destroy_with_parent (GTK_WINDOW (proxy_config_box), TRUE); - proxy_config_box_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (proxy_config_box_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (proxy_config_box), proxy_config_box_icon_pixbuf); - gdk_pixbuf_unref (proxy_config_box_icon_pixbuf); - } - gtk_window_set_type_hint (GTK_WINDOW (proxy_config_box), GDK_WINDOW_TYPE_HINT_DIALOG); - - dialog_vbox12 = GTK_DIALOG (proxy_config_box)->vbox; - gtk_widget_show (dialog_vbox12); - - frame22 = gtk_frame_new (NULL); - gtk_widget_show (frame22); - gtk_box_pack_start (GTK_BOX (dialog_vbox12), frame22, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame22), 8); - - table8 = gtk_table_new (7, 2, FALSE); - gtk_widget_show (table8); - gtk_container_add (GTK_CONTAINER (frame22), table8); - - reg_sendregister = gtk_check_button_new_with_mnemonic (""); - gtk_widget_show (reg_sendregister); - gtk_table_attach (GTK_TABLE (table8), reg_sendregister, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (reg_sendregister), TRUE); - - label82 = gtk_label_new (_("Route (optional):")); - gtk_widget_show (label82); - gtk_table_attach (GTK_TABLE (table8), label82, 0, 1, 5, 6, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label82), 0, 0.5); - - reg_route = gtk_entry_new (); - gtk_widget_show (reg_route); - gtk_table_attach (GTK_TABLE (table8), reg_route, 1, 2, 5, 6, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_entry_set_max_length (GTK_ENTRY (reg_route), 256); - - reg_proxy = gtk_entry_new (); - gtk_widget_show (reg_proxy); - gtk_table_attach (GTK_TABLE (table8), reg_proxy, 1, 2, 4, 5, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_entry_set_max_length (GTK_ENTRY (reg_proxy), 250); - gtk_entry_set_text (GTK_ENTRY (reg_proxy), _("sip:")); - - label83 = gtk_label_new (_("SIP Proxy:")); - gtk_widget_show (label83); - gtk_table_attach (GTK_TABLE (table8), label83, 0, 1, 4, 5, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label83), 0, 0.5); - - label84 = gtk_label_new (_("SIP Identity:")); - gtk_widget_show (label84); - gtk_table_attach (GTK_TABLE (table8), label84, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label84), 0, 0.5); - - reg_identity = gtk_entry_new (); - gtk_widget_show (reg_identity); - gtk_table_attach (GTK_TABLE (table8), reg_identity, 1, 2, 3, 4, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_entry_set_max_length (GTK_ENTRY (reg_identity), 256); - gtk_entry_set_text (GTK_ENTRY (reg_identity), _("sip:")); - - label85 = gtk_label_new (_("Registration Period:")); - gtk_widget_show (label85); - gtk_table_attach (GTK_TABLE (table8), label85, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label85), 0, 0.5); - - reg_expires_adj = gtk_adjustment_new (900, 120, 72000, 1, 10, 10); - reg_expires = gtk_spin_button_new (GTK_ADJUSTMENT (reg_expires_adj), 1, 0); - gtk_widget_show (reg_expires); - gtk_table_attach (GTK_TABLE (table8), reg_expires, 1, 2, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (reg_expires), TRUE); - - label81 = gtk_label_new (_("Send registration:")); - gtk_widget_show (label81); - gtk_table_attach (GTK_TABLE (table8), label81, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label81), 0, 0.5); - - label104 = gtk_label_new (_("Publish presence information:")); - gtk_widget_show (label104); - gtk_table_attach (GTK_TABLE (table8), label104, 0, 1, 6, 7, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label104), 0, 0.5); - - publish = gtk_check_button_new_with_mnemonic (""); - gtk_widget_show (publish); - gtk_table_attach (GTK_TABLE (table8), publish, 1, 2, 6, 7, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - label86 = gtk_label_new (_("Proxy/Registrar configuration box")); - gtk_widget_show (label86); - gtk_frame_set_label_widget (GTK_FRAME (frame22), label86); - - dialog_action_area12 = GTK_DIALOG (proxy_config_box)->action_area; - gtk_widget_show (dialog_action_area12); - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area12), GTK_BUTTONBOX_END); - - helpbutton1 = gtk_button_new_from_stock ("gtk-help"); - gtk_widget_show (helpbutton1); - gtk_dialog_add_action_widget (GTK_DIALOG (proxy_config_box), helpbutton1, GTK_RESPONSE_HELP); - GTK_WIDGET_SET_FLAGS (helpbutton1, GTK_CAN_DEFAULT); - - okbutton2 = gtk_button_new_from_stock ("gtk-ok"); - gtk_widget_show (okbutton2); - gtk_dialog_add_action_widget (GTK_DIALOG (proxy_config_box), okbutton2, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton2, GTK_CAN_DEFAULT); - - g_signal_connect ((gpointer) proxy_config_box, "response", - G_CALLBACK (on_proxy_config_box_response), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (proxy_config_box, proxy_config_box, "proxy_config_box"); - GLADE_HOOKUP_OBJECT_NO_REF (proxy_config_box, dialog_vbox12, "dialog_vbox12"); - GLADE_HOOKUP_OBJECT (proxy_config_box, frame22, "frame22"); - GLADE_HOOKUP_OBJECT (proxy_config_box, table8, "table8"); - GLADE_HOOKUP_OBJECT (proxy_config_box, reg_sendregister, "reg_sendregister"); - GLADE_HOOKUP_OBJECT (proxy_config_box, label82, "label82"); - GLADE_HOOKUP_OBJECT (proxy_config_box, reg_route, "reg_route"); - GLADE_HOOKUP_OBJECT (proxy_config_box, reg_proxy, "reg_proxy"); - GLADE_HOOKUP_OBJECT (proxy_config_box, label83, "label83"); - GLADE_HOOKUP_OBJECT (proxy_config_box, label84, "label84"); - GLADE_HOOKUP_OBJECT (proxy_config_box, reg_identity, "reg_identity"); - GLADE_HOOKUP_OBJECT (proxy_config_box, label85, "label85"); - GLADE_HOOKUP_OBJECT (proxy_config_box, reg_expires, "reg_expires"); - GLADE_HOOKUP_OBJECT (proxy_config_box, label81, "label81"); - GLADE_HOOKUP_OBJECT (proxy_config_box, label104, "label104"); - GLADE_HOOKUP_OBJECT (proxy_config_box, publish, "publish"); - GLADE_HOOKUP_OBJECT (proxy_config_box, label86, "label86"); - GLADE_HOOKUP_OBJECT_NO_REF (proxy_config_box, dialog_action_area12, "dialog_action_area12"); - GLADE_HOOKUP_OBJECT (proxy_config_box, helpbutton1, "helpbutton1"); - GLADE_HOOKUP_OBJECT (proxy_config_box, okbutton2, "okbutton2"); - - gtk_widget_grab_focus (proxy_config_box); - return proxy_config_box; -} - -GtkWidget* -create_contact_box (void) -{ - GtkWidget *contact_box; - GdkPixbuf *contact_box_icon_pixbuf; - GtkWidget *dialog_vbox13; - GtkWidget *frame23; - GtkWidget *vbox25; - GtkWidget *table10; - GtkWidget *sipaddr; - GtkWidget *name; - GtkWidget *label89; - GtkWidget *label90; - GtkWidget *label91; - GtkWidget *label92; - GtkWidget *send_subscribe; - GtkWidget *label88; - GtkWidget *dialog_action_area13; - GtkWidget *helpbutton2; - GtkWidget *cancelbutton2; - GtkWidget *okbutton3; - - contact_box = gtk_dialog_new (); - GTK_WIDGET_SET_FLAGS (contact_box, GTK_CAN_FOCUS); - gtk_window_set_title (GTK_WINDOW (contact_box), _("Edit contact information")); - gtk_window_set_destroy_with_parent (GTK_WINDOW (contact_box), TRUE); - contact_box_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (contact_box_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (contact_box), contact_box_icon_pixbuf); - gdk_pixbuf_unref (contact_box_icon_pixbuf); - } - gtk_window_set_type_hint (GTK_WINDOW (contact_box), GDK_WINDOW_TYPE_HINT_DIALOG); - - dialog_vbox13 = GTK_DIALOG (contact_box)->vbox; - gtk_widget_show (dialog_vbox13); - - frame23 = gtk_frame_new (NULL); - gtk_widget_show (frame23); - gtk_box_pack_start (GTK_BOX (dialog_vbox13), frame23, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (frame23), 6); - - vbox25 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox25); - gtk_container_add (GTK_CONTAINER (frame23), vbox25); - - table10 = gtk_table_new (4, 2, TRUE); - gtk_widget_show (table10); - gtk_box_pack_start (GTK_BOX (vbox25), table10, TRUE, TRUE, 0); - - sipaddr = gtk_entry_new (); - gtk_widget_show (sipaddr); - gtk_table_attach (GTK_TABLE (table10), sipaddr, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_entry_set_text (GTK_ENTRY (sipaddr), _("sip:")); - - name = gtk_entry_new (); - gtk_widget_show (name); - gtk_table_attach (GTK_TABLE (table10), name, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - label89 = gtk_label_new (_("Name:")); - gtk_widget_show (label89); - gtk_table_attach (GTK_TABLE (table10), label89, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label89), 0, 0.5); - - label90 = gtk_label_new (_("Sip address:")); - gtk_widget_show (label90); - gtk_table_attach (GTK_TABLE (table10), label90, 0, 1, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label90), 0, 0.5); - - label91 = gtk_label_new (_("Proxy to use:")); - gtk_widget_show (label91); - gtk_table_attach (GTK_TABLE (table10), label91, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label91), 0, 0.5); - - label92 = gtk_label_new (_("Subscribe policy:")); - gtk_widget_show (label92); - gtk_table_attach (GTK_TABLE (table10), label92, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_misc_set_alignment (GTK_MISC (label92), 0, 0.5); - - send_subscribe = gtk_check_button_new_with_mnemonic (_("Send subscription (see person's online status)")); - gtk_widget_show (send_subscribe); - gtk_box_pack_start (GTK_BOX (vbox25), send_subscribe, TRUE, TRUE, 0); - - label88 = gtk_label_new (_("Contact information")); - gtk_widget_show (label88); - gtk_frame_set_label_widget (GTK_FRAME (frame23), label88); - - dialog_action_area13 = GTK_DIALOG (contact_box)->action_area; - gtk_widget_show (dialog_action_area13); - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area13), GTK_BUTTONBOX_END); - - helpbutton2 = gtk_button_new_from_stock ("gtk-help"); - gtk_widget_show (helpbutton2); - gtk_dialog_add_action_widget (GTK_DIALOG (contact_box), helpbutton2, GTK_RESPONSE_HELP); - GTK_WIDGET_SET_FLAGS (helpbutton2, GTK_CAN_DEFAULT); - - cancelbutton2 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_widget_show (cancelbutton2); - gtk_dialog_add_action_widget (GTK_DIALOG (contact_box), cancelbutton2, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton2, GTK_CAN_DEFAULT); - - okbutton3 = gtk_button_new_from_stock ("gtk-ok"); - gtk_widget_show (okbutton3); - gtk_dialog_add_action_widget (GTK_DIALOG (contact_box), okbutton3, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton3, GTK_CAN_DEFAULT); - - g_signal_connect ((gpointer) contact_box, "response", - G_CALLBACK (on_contact_box_response), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (contact_box, contact_box, "contact_box"); - GLADE_HOOKUP_OBJECT_NO_REF (contact_box, dialog_vbox13, "dialog_vbox13"); - GLADE_HOOKUP_OBJECT (contact_box, frame23, "frame23"); - GLADE_HOOKUP_OBJECT (contact_box, vbox25, "vbox25"); - GLADE_HOOKUP_OBJECT (contact_box, table10, "table10"); - GLADE_HOOKUP_OBJECT (contact_box, sipaddr, "sipaddr"); - GLADE_HOOKUP_OBJECT (contact_box, name, "name"); - GLADE_HOOKUP_OBJECT (contact_box, label89, "label89"); - GLADE_HOOKUP_OBJECT (contact_box, label90, "label90"); - GLADE_HOOKUP_OBJECT (contact_box, label91, "label91"); - GLADE_HOOKUP_OBJECT (contact_box, label92, "label92"); - GLADE_HOOKUP_OBJECT (contact_box, send_subscribe, "send_subscribe"); - GLADE_HOOKUP_OBJECT (contact_box, label88, "label88"); - GLADE_HOOKUP_OBJECT_NO_REF (contact_box, dialog_action_area13, "dialog_action_area13"); - GLADE_HOOKUP_OBJECT (contact_box, helpbutton2, "helpbutton2"); - GLADE_HOOKUP_OBJECT (contact_box, cancelbutton2, "cancelbutton2"); - GLADE_HOOKUP_OBJECT (contact_box, okbutton3, "okbutton3"); - - return contact_box; -} - -GtkWidget* -create_inc_subscr_dialog (void) -{ - GtkWidget *inc_subscr_dialog; - GdkPixbuf *inc_subscr_dialog_icon_pixbuf; - GtkWidget *dialog_vbox14; - GtkWidget *hbox32; - GtkWidget *image25; - GtkWidget *subscr_label; - GtkWidget *dialog_action_area14; - GtkWidget *button15; - GtkWidget *alignment17; - GtkWidget *hbox31; - GtkWidget *image24; - GtkWidget *label95; - GtkWidget *button16; - GtkWidget *alignment16; - GtkWidget *hbox30; - GtkWidget *image23; - GtkWidget *label94; - - inc_subscr_dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (inc_subscr_dialog), _("New incoming subscription")); - inc_subscr_dialog_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (inc_subscr_dialog_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (inc_subscr_dialog), inc_subscr_dialog_icon_pixbuf); - gdk_pixbuf_unref (inc_subscr_dialog_icon_pixbuf); - } - gtk_window_set_type_hint (GTK_WINDOW (inc_subscr_dialog), GDK_WINDOW_TYPE_HINT_DIALOG); - - dialog_vbox14 = GTK_DIALOG (inc_subscr_dialog)->vbox; - gtk_widget_show (dialog_vbox14); - - hbox32 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox32); - gtk_box_pack_start (GTK_BOX (dialog_vbox14), hbox32, TRUE, TRUE, 0); - - image25 = gtk_image_new_from_stock ("gtk-dialog-warning", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image25); - gtk_box_pack_start (GTK_BOX (hbox32), image25, FALSE, TRUE, 0); - - subscr_label = gtk_label_new (_("You have received a new subscription...")); - gtk_widget_show (subscr_label); - gtk_box_pack_start (GTK_BOX (hbox32), subscr_label, TRUE, TRUE, 0); - gtk_label_set_line_wrap (GTK_LABEL (subscr_label), TRUE); - gtk_misc_set_padding (GTK_MISC (subscr_label), 14, 9); - - dialog_action_area14 = GTK_DIALOG (inc_subscr_dialog)->action_area; - gtk_widget_show (dialog_action_area14); - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area14), GTK_BUTTONBOX_SPREAD); - - button15 = gtk_button_new (); - gtk_widget_show (button15); - gtk_dialog_add_action_widget (GTK_DIALOG (inc_subscr_dialog), button15, GTK_RESPONSE_REJECT); - GTK_WIDGET_SET_FLAGS (button15, GTK_CAN_DEFAULT); - - alignment17 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment17); - gtk_container_add (GTK_CONTAINER (button15), alignment17); - - hbox31 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox31); - gtk_container_add (GTK_CONTAINER (alignment17), hbox31); - - image24 = gtk_image_new_from_stock ("gtk-stop", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image24); - gtk_box_pack_start (GTK_BOX (hbox31), image24, FALSE, FALSE, 0); - - label95 = gtk_label_new_with_mnemonic (_("Refuse")); - gtk_widget_show (label95); - gtk_box_pack_start (GTK_BOX (hbox31), label95, FALSE, FALSE, 0); - - button16 = gtk_button_new (); - gtk_widget_show (button16); - gtk_dialog_add_action_widget (GTK_DIALOG (inc_subscr_dialog), button16, GTK_RESPONSE_ACCEPT); - GTK_WIDGET_SET_FLAGS (button16, GTK_CAN_DEFAULT); - - alignment16 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment16); - gtk_container_add (GTK_CONTAINER (button16), alignment16); - - hbox30 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox30); - gtk_container_add (GTK_CONTAINER (alignment16), hbox30); - - image23 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image23); - gtk_box_pack_start (GTK_BOX (hbox30), image23, FALSE, FALSE, 0); - - label94 = gtk_label_new_with_mnemonic (_("Accept")); - gtk_widget_show (label94); - gtk_box_pack_start (GTK_BOX (hbox30), label94, FALSE, FALSE, 0); - - g_signal_connect ((gpointer) inc_subscr_dialog, "response", - G_CALLBACK (on_inc_subscr_dialog_response), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (inc_subscr_dialog, inc_subscr_dialog, "inc_subscr_dialog"); - GLADE_HOOKUP_OBJECT_NO_REF (inc_subscr_dialog, dialog_vbox14, "dialog_vbox14"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, hbox32, "hbox32"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, image25, "image25"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, subscr_label, "subscr_label"); - GLADE_HOOKUP_OBJECT_NO_REF (inc_subscr_dialog, dialog_action_area14, "dialog_action_area14"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, button15, "button15"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, alignment17, "alignment17"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, hbox31, "hbox31"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, image24, "image24"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, label95, "label95"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, button16, "button16"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, alignment16, "alignment16"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, hbox30, "hbox30"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, image23, "image23"); - GLADE_HOOKUP_OBJECT (inc_subscr_dialog, label94, "label94"); - - return inc_subscr_dialog; -} - -GtkWidget* -create_authentication_dialog (void) -{ - GtkWidget *authentication_dialog; - GdkPixbuf *authentication_dialog_icon_pixbuf; - GtkWidget *dialog_vbox15; - GtkWidget *vbox26; - GtkWidget *hbox33; - GtkWidget *image26; - GtkWidget *question; - GtkWidget *table11; - GtkWidget *realm; - GtkWidget *username; - GtkWidget *passwd; - GtkWidget *userid; - GtkWidget *label100; - GtkWidget *label99; - GtkWidget *label98; - GtkWidget *label97; - GtkWidget *dialog_action_area15; - GtkWidget *cancelbutton3; - GtkWidget *okbutton4; - - authentication_dialog = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (authentication_dialog), _("Authentication requested")); - gtk_window_set_destroy_with_parent (GTK_WINDOW (authentication_dialog), TRUE); - authentication_dialog_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (authentication_dialog_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (authentication_dialog), authentication_dialog_icon_pixbuf); - gdk_pixbuf_unref (authentication_dialog_icon_pixbuf); - } - gtk_window_set_type_hint (GTK_WINDOW (authentication_dialog), GDK_WINDOW_TYPE_HINT_DIALOG); - - dialog_vbox15 = GTK_DIALOG (authentication_dialog)->vbox; - gtk_widget_show (dialog_vbox15); - - vbox26 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox26); - gtk_box_pack_start (GTK_BOX (dialog_vbox15), vbox26, TRUE, TRUE, 0); - - hbox33 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox33); - gtk_box_pack_start (GTK_BOX (vbox26), hbox33, FALSE, FALSE, 0); - - image26 = gtk_image_new_from_stock ("gtk-dialog-question", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image26); - gtk_box_pack_start (GTK_BOX (hbox33), image26, TRUE, TRUE, 0); - gtk_misc_set_padding (GTK_MISC (image26), 16, 0); - - question = gtk_label_new (_("Authentication required for realm")); - gtk_widget_show (question); - gtk_box_pack_start (GTK_BOX (hbox33), question, TRUE, TRUE, 0); - gtk_label_set_justify (GTK_LABEL (question), GTK_JUSTIFY_CENTER); - gtk_misc_set_padding (GTK_MISC (question), 29, 14); - - table11 = gtk_table_new (5, 2, FALSE); - gtk_widget_show (table11); - gtk_box_pack_start (GTK_BOX (vbox26), table11, TRUE, TRUE, 0); - - realm = gtk_entry_new (); - gtk_widget_show (realm); - gtk_table_attach (GTK_TABLE (table11), realm, 1, 2, 0, 1, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_editable_set_editable (GTK_EDITABLE (realm), FALSE); - - username = gtk_entry_new (); - gtk_widget_show (username); - gtk_table_attach (GTK_TABLE (table11), username, 1, 2, 1, 2, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - passwd = gtk_entry_new (); - gtk_widget_show (passwd); - gtk_table_attach (GTK_TABLE (table11), passwd, 1, 2, 2, 3, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - gtk_entry_set_visibility (GTK_ENTRY (passwd), FALSE); - - userid = gtk_entry_new (); - gtk_widget_show (userid); - gtk_table_attach (GTK_TABLE (table11), userid, 1, 2, 3, 4, - (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), - (GtkAttachOptions) (0), 0, 0); - - label100 = gtk_label_new (_("userid:")); - gtk_widget_show (label100); - gtk_table_attach (GTK_TABLE (table11), label100, 0, 1, 3, 4, - (GtkAttachOptions) (GTK_EXPAND | GTK_SHRINK), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (label100), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (label100), 0, 0.5); - - label99 = gtk_label_new (_("password:")); - gtk_widget_show (label99); - gtk_table_attach (GTK_TABLE (table11), label99, 0, 1, 2, 3, - (GtkAttachOptions) (GTK_EXPAND), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (label99), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (label99), 0, 0.5); - - label98 = gtk_label_new (_("username:")); - gtk_widget_show (label98); - gtk_table_attach (GTK_TABLE (table11), label98, 0, 1, 1, 2, - (GtkAttachOptions) (0), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (label98), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (label98), 0, 0.5); - - label97 = gtk_label_new (_("realm:")); - gtk_widget_show (label97); - gtk_table_attach (GTK_TABLE (table11), label97, 0, 1, 0, 1, - (GtkAttachOptions) (GTK_EXPAND), - (GtkAttachOptions) (0), 0, 0); - gtk_label_set_justify (GTK_LABEL (label97), GTK_JUSTIFY_CENTER); - gtk_misc_set_alignment (GTK_MISC (label97), 0, 0.5); - - dialog_action_area15 = GTK_DIALOG (authentication_dialog)->action_area; - gtk_widget_show (dialog_action_area15); - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area15), GTK_BUTTONBOX_END); - - cancelbutton3 = gtk_button_new_from_stock ("gtk-cancel"); - gtk_widget_show (cancelbutton3); - gtk_dialog_add_action_widget (GTK_DIALOG (authentication_dialog), cancelbutton3, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (cancelbutton3, GTK_CAN_DEFAULT); - - okbutton4 = gtk_button_new_from_stock ("gtk-ok"); - gtk_widget_show (okbutton4); - gtk_dialog_add_action_widget (GTK_DIALOG (authentication_dialog), okbutton4, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (okbutton4, GTK_CAN_DEFAULT); - - g_signal_connect ((gpointer) authentication_dialog, "response", - G_CALLBACK (on_authentication_dialog_response), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (authentication_dialog, authentication_dialog, "authentication_dialog"); - GLADE_HOOKUP_OBJECT_NO_REF (authentication_dialog, dialog_vbox15, "dialog_vbox15"); - GLADE_HOOKUP_OBJECT (authentication_dialog, vbox26, "vbox26"); - GLADE_HOOKUP_OBJECT (authentication_dialog, hbox33, "hbox33"); - GLADE_HOOKUP_OBJECT (authentication_dialog, image26, "image26"); - GLADE_HOOKUP_OBJECT (authentication_dialog, question, "question"); - GLADE_HOOKUP_OBJECT (authentication_dialog, table11, "table11"); - GLADE_HOOKUP_OBJECT (authentication_dialog, realm, "realm"); - GLADE_HOOKUP_OBJECT (authentication_dialog, username, "username"); - GLADE_HOOKUP_OBJECT (authentication_dialog, passwd, "passwd"); - GLADE_HOOKUP_OBJECT (authentication_dialog, userid, "userid"); - GLADE_HOOKUP_OBJECT (authentication_dialog, label100, "label100"); - GLADE_HOOKUP_OBJECT (authentication_dialog, label99, "label99"); - GLADE_HOOKUP_OBJECT (authentication_dialog, label98, "label98"); - GLADE_HOOKUP_OBJECT (authentication_dialog, label97, "label97"); - GLADE_HOOKUP_OBJECT_NO_REF (authentication_dialog, dialog_action_area15, "dialog_action_area15"); - GLADE_HOOKUP_OBJECT (authentication_dialog, cancelbutton3, "cancelbutton3"); - GLADE_HOOKUP_OBJECT (authentication_dialog, okbutton4, "okbutton4"); - - return authentication_dialog; -} - -GtkWidget* -create_call_logs (void) -{ - GtkWidget *call_logs; - GdkPixbuf *call_logs_icon_pixbuf; - GtkWidget *dialog_vbox16; - GtkWidget *scrolledwindow5; - GtkWidget *logview; - GtkWidget *dialog_action_area16; - GtkWidget *closebutton2; - - call_logs = gtk_dialog_new (); - gtk_window_set_title (GTK_WINDOW (call_logs), _("Linphone - Call history")); - gtk_window_set_default_size (GTK_WINDOW (call_logs), 240, 240); - gtk_window_set_destroy_with_parent (GTK_WINDOW (call_logs), TRUE); - call_logs_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (call_logs_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (call_logs), call_logs_icon_pixbuf); - gdk_pixbuf_unref (call_logs_icon_pixbuf); - } - gtk_window_set_type_hint (GTK_WINDOW (call_logs), GDK_WINDOW_TYPE_HINT_DIALOG); - - dialog_vbox16 = GTK_DIALOG (call_logs)->vbox; - gtk_widget_show (dialog_vbox16); - - scrolledwindow5 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow5); - gtk_box_pack_start (GTK_BOX (dialog_vbox16), scrolledwindow5, TRUE, TRUE, 0); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow5), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow5), GTK_SHADOW_IN); - - logview = gtk_text_view_new (); - gtk_widget_show (logview); - gtk_container_add (GTK_CONTAINER (scrolledwindow5), logview); - gtk_text_view_set_editable (GTK_TEXT_VIEW (logview), FALSE); - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (logview), FALSE); - - dialog_action_area16 = GTK_DIALOG (call_logs)->action_area; - gtk_widget_show (dialog_action_area16); - gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area16), GTK_BUTTONBOX_END); - - closebutton2 = gtk_button_new_from_stock ("gtk-close"); - gtk_widget_show (closebutton2); - gtk_dialog_add_action_widget (GTK_DIALOG (call_logs), closebutton2, GTK_RESPONSE_CLOSE); - GTK_WIDGET_SET_FLAGS (closebutton2, GTK_CAN_DEFAULT); - - g_signal_connect ((gpointer) call_logs, "response", - G_CALLBACK (on_call_logs_response), - NULL); - g_signal_connect ((gpointer) call_logs, "destroy", - G_CALLBACK (on_call_logs_destroy), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (call_logs, call_logs, "call_logs"); - GLADE_HOOKUP_OBJECT_NO_REF (call_logs, dialog_vbox16, "dialog_vbox16"); - GLADE_HOOKUP_OBJECT (call_logs, scrolledwindow5, "scrolledwindow5"); - GLADE_HOOKUP_OBJECT (call_logs, logview, "logview"); - GLADE_HOOKUP_OBJECT_NO_REF (call_logs, dialog_action_area16, "dialog_action_area16"); - GLADE_HOOKUP_OBJECT (call_logs, closebutton2, "closebutton2"); - - return call_logs; -} - -GtkWidget* -create_chatroom (void) -{ - GtkWidget *chatroom; - GdkPixbuf *chatroom_icon_pixbuf; - GtkWidget *vbox30; - GtkWidget *scrolledwindow6; - GtkWidget *chattext; - GtkWidget *hbox35; - GtkWidget *label107; - GtkWidget *chatentry; - GtkWidget *button17; - - chatroom = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (chatroom), _("Chat Room")); - gtk_window_set_default_size (GTK_WINDOW (chatroom), 400, 400); - gtk_window_set_destroy_with_parent (GTK_WINDOW (chatroom), TRUE); - chatroom_icon_pixbuf = create_pixbuf ("linphone2.xpm"); - if (chatroom_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (chatroom), chatroom_icon_pixbuf); - gdk_pixbuf_unref (chatroom_icon_pixbuf); - } - - vbox30 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox30); - gtk_container_add (GTK_CONTAINER (chatroom), vbox30); - - scrolledwindow6 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow6); - gtk_box_pack_start (GTK_BOX (vbox30), scrolledwindow6, TRUE, TRUE, 0); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow6), GTK_SHADOW_IN); - - chattext = gtk_text_view_new (); - gtk_widget_show (chattext); - gtk_container_add (GTK_CONTAINER (scrolledwindow6), chattext); - gtk_text_view_set_editable (GTK_TEXT_VIEW (chattext), FALSE); - - hbox35 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox35); - gtk_box_pack_start (GTK_BOX (vbox30), hbox35, FALSE, TRUE, 0); - - label107 = gtk_label_new (_("Text:")); - gtk_widget_show (label107); - gtk_box_pack_start (GTK_BOX (hbox35), label107, FALSE, FALSE, 0); - - chatentry = gtk_entry_new (); - gtk_widget_show (chatentry); - gtk_box_pack_start (GTK_BOX (hbox35), chatentry, TRUE, TRUE, 0); - - button17 = gtk_button_new_from_stock ("gtk-close"); - gtk_widget_show (button17); - gtk_box_pack_start (GTK_BOX (vbox30), button17, FALSE, FALSE, 0); - - g_signal_connect ((gpointer) chatroom, "destroy", - G_CALLBACK (on_chatroom_destroy), - NULL); - g_signal_connect ((gpointer) chatentry, "activate", - G_CALLBACK (on_chatentry_activate), - NULL); - g_signal_connect ((gpointer) button17, "clicked", - G_CALLBACK (on_chatbox_clicked), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (chatroom, chatroom, "chatroom"); - GLADE_HOOKUP_OBJECT (chatroom, vbox30, "vbox30"); - GLADE_HOOKUP_OBJECT (chatroom, scrolledwindow6, "scrolledwindow6"); - GLADE_HOOKUP_OBJECT (chatroom, chattext, "chattext"); - GLADE_HOOKUP_OBJECT (chatroom, hbox35, "hbox35"); - GLADE_HOOKUP_OBJECT (chatroom, label107, "label107"); - GLADE_HOOKUP_OBJECT (chatroom, chatentry, "chatentry"); - GLADE_HOOKUP_OBJECT (chatroom, button17, "button17"); - - gtk_widget_grab_focus (chatentry); - return chatroom; -} - -GtkWidget* -create_aboutdialog1 (void) -{ - GtkWidget *aboutdialog1; - const gchar *authors[] = { - "Simon MORLAT", - "Aymeric Moizard", - "Sharath K Udupa", - NULL - }; - const gchar *documenters[] = { - "Simon MORLAT", - "Philippe Beau", - NULL - }; - gchar *translators = "it: Alberto Zanoni\nde: Jean Jacques Sarton\nfr: Simon Morlat\nes: Jesus Benitez\nja: Yamaguchi Yoshiya\npl: obert Nasiadek \npt_BR: Rafael Caesar Lenzi \nsv: Daniel Nylander "; - GdkPixbuf *aboutdialog1_logo_pixbuf; - - aboutdialog1 = gtk_about_dialog_new (); - gtk_container_set_border_width (GTK_CONTAINER (aboutdialog1), 5); - gtk_window_set_destroy_with_parent (GTK_WINDOW (aboutdialog1), TRUE); - gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (aboutdialog1), VERSION); - gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (aboutdialog1), _("Linphone")); - gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (aboutdialog1), _("C: 2001\nMade in Old Europe")); - gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (aboutdialog1), _("Linphone is a web-phone.\nIt is compatible with SIP and RTP protocols.")); - gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (aboutdialog1), " This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation; either version 2 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"); - gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (aboutdialog1), "http://www.linphone.org"); - gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (aboutdialog1), authors); - gtk_about_dialog_set_documenters (GTK_ABOUT_DIALOG (aboutdialog1), documenters); - gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (aboutdialog1), translators); - aboutdialog1_logo_pixbuf = create_pixbuf ("linphone.png"); - gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG (aboutdialog1), aboutdialog1_logo_pixbuf); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (aboutdialog1, aboutdialog1, "aboutdialog1"); - - return aboutdialog1; -} - diff --git a/linphone/gtk/interface.h b/linphone/gtk/interface.h deleted file mode 100644 index 4556c2706..000000000 --- a/linphone/gtk/interface.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - */ - -GtkWidget* create_app1 (void); -GtkWidget* create_about2 (void); -GtkWidget* create_prop1 (void); -GtkWidget* create_address_book (void); -GtkWidget* create_altressource (void); -GtkWidget* create_proxy_config_box (void); -GtkWidget* create_contact_box (void); -GtkWidget* create_inc_subscr_dialog (void); -GtkWidget* create_authentication_dialog (void); -GtkWidget* create_call_logs (void); -GtkWidget* create_chatroom (void); -GtkWidget* create_aboutdialog1 (void); diff --git a/linphone/gtk/linphone.c b/linphone/gtk/linphone.c deleted file mode 100644 index 29c212526..000000000 --- a/linphone/gtk/linphone.c +++ /dev/null @@ -1,482 +0,0 @@ -/*************************************************************************** - linphone.c - Main code for linphone's gnome - interface - ------------------- - begin : Mon Dec 17 2001 - copyright : (C) 2001 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -/* -linphone, gtk-glade interface. -Copyright (C) 2008 Simon MORLAT (simon.morlat@linphone.org) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "linphone.h" -#include "support.h" -#include "interface.h" -#include "callbacks.h" -#include "gui_utils.h" -#include "lpconfig.h" - -#include - - -LinphoneGnomeUI *uiobj=NULL; -#define get_uiobj() (uiobj) -#define get_core() (uiobj->core) -#define get_friend_list() (&uiobj->main_window.friendlist) - -void linphone_gnome_ui_init(LinphoneGnomeUI *ui,LinphoneCore *core) -{ - memset(ui,0,sizeof(LinphoneGnomeUI)); - ui->core=core; - uiobj=ui; - ui->main_window.shown_once=FALSE; -} - -static void restore_uri_history(GtkEntry *uribar, LpConfig *cfg){ - char key[20]; - int i; - GtkEntryCompletion *gep=gtk_entry_completion_new(); - GtkListStore *model=gtk_list_store_new(1,G_TYPE_STRING); - for (i=0;;i++){ - const char *uri; - snprintf(key,sizeof(key),"uri%i",i); - uri=lp_config_get_string(cfg,"GtkUi",key,NULL); - if (uri!=NULL) { - GtkTreeIter iter; - gtk_list_store_append(model,&iter); - gtk_list_store_set(model,&iter,0,uri,-1); - if (i==0) gtk_entry_set_text(uribar,uri); - } - else break; - } - gtk_entry_completion_set_model(gep,GTK_TREE_MODEL(model)); - gtk_entry_completion_set_text_column(gep,0); - gtk_entry_set_completion(uribar,gep); -} - -void linphone_gnome_save_uri_history(LinphoneGnomeUI *ui){ - char key[20]; - int i=0; - char *uri=NULL; - GtkTreeIter iter; - GtkEntry *uribar=GTK_ENTRY(ui->main_window.addressentry); - GtkTreeModel *model=gtk_entry_completion_get_model(gtk_entry_get_completion(uribar)); - LpConfig *cfg=linphone_core_get_config(ui->core); - if (!gtk_tree_model_get_iter_first(model,&iter)) return; - do { - gtk_tree_model_get(model,&iter,0,&uri,-1); - if (uri) { - snprintf(key,sizeof(key),"uri%i",i); - lp_config_set_string(cfg,"GtkUi",key,uri); - g_free(uri); - }else break; - i++; - if (i>5) break; - }while(gtk_tree_model_iter_next(model,&iter)); -} - -void main_window_create(LinphoneGnomeUI *obj) -{ - GtkWidget *child; - GtkWidget *window; - window=create_app1 (); -#ifdef NOTYET - gnome_window_icon_set_from_default(GTK_WINDOW(window)); -#endif - obj->main_window.status_bar=lookup_widget(window,"appbar1"); - obj->main_window.addressentry=lookup_widget(window,"addressentry"); - obj->main_window.optioncontrols=lookup_widget(window,"optioncontrols"); - obj->main_window.dtmfentry=lookup_widget(window,"dtmf_entry"); - obj->main_window.callbutton=lookup_widget(window,"callbutton"); - child=lookup_widget(window,"showmore"); - /* hide the optionnal controls at startup */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(child),0); -#ifndef VIDEO_ENABLED - gtk_widget_hide(lookup_widget(child,"video_enabled")); -#else - gtk_toggle_button_set_active( - GTK_TOGGLE_BUTTON(lookup_widget(child,"video_enabled")), - linphone_core_video_enabled(obj->core)); -#endif - presence_box_init(&obj->main_window.presencebox,window,obj->core); - friend_list_init(&obj->main_window.friendlist,obj->core,window); - g_object_set_data(G_OBJECT(window),"ui",(gpointer)obj); - obj->main_window.window=window; -} - -void linphone_gnome_ui_show(LinphoneGnomeUI *ui) -{ - if (ui->main_window.window==NULL){ - main_window_create(ui); - - } - gtk_widget_show(ui->main_window.window); - ui->main_window.shown_once=TRUE; -} - -void linphone_gnome_ui_hide(LinphoneGnomeUI *ui) -{ - if (ui->main_window.window==NULL) return; - gtk_widget_hide(ui->main_window.window); -} - - -void linphone_gnome_ui_uninit(LinphoneGnomeUI *ui) -{ - ui->main_window.window=NULL; -} - -void linphone_gnome_ui_display_something(LinphoneGnomeUI *ui,GtkMessageType type,const gchar *message) -{ - GtkWidget *dialog; - - linphone_gnome_ui_show(ui); - if (type==GTK_MESSAGE_QUESTION) - { -#ifdef VINCENT_MAURY_RSVP - /* draw a question box. link to dialog_click callback */ - dialog = gtk_message_dialog_new ( - GTK_WINDOW(ui->main_window.window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - (const gchar*)message); - /* connect the click event to the callback */ - g_signal_connect_swapped (G_OBJECT (dialog), "response", - G_CALLBACK (dialog_click), - G_OBJECT (dialog)); - /* actually show the box */ - gtk_widget_show(dialog); -#endif - } - else - { - dialog = gtk_message_dialog_new (GTK_WINDOW(ui->main_window.window), - GTK_DIALOG_DESTROY_WITH_PARENT, - type, - GTK_BUTTONS_CLOSE, - (const gchar*)message); - /* Destroy the dialog when the user responds to it (e.g. clicks a button) */ - g_signal_connect_swapped (G_OBJECT (dialog), "response", - G_CALLBACK (gtk_widget_destroy), - G_OBJECT (dialog)); - gtk_widget_show(dialog); - } -} - -/* these are the LinphoneCore virtual functions */ -void linphone_gnome_display_message(LinphoneCore *lc, const char *message) -{ - LinphoneGnomeUI *ui=(LinphoneGnomeUI*)lc->data; - linphone_gnome_ui_display_something(ui,GTK_MESSAGE_INFO,message); -} - -#ifdef VINCENT_MAURY_RSVP -/* Question box with yes/no answer. */ -void linphone_gnome_display_yes_no(LinphoneCore *lc,const char *message) -{ - LinphoneGnomeUI *ui=(LinphoneGnomeUI*)lc->data; - if (strcmp(message,"With QoS")==0) - /* the caller asks for QoS, this function is called because, by default, - * you don't use QoS ! */ - linphone_gnome_ui_display_something(ui,GTK_MESSAGE_QUESTION, - _("The caller asks for resource reservation. Do you agree ?")); - else - linphone_gnome_ui_display_something(ui,GTK_MESSAGE_QUESTION, - _("The caller doesn't use resource reservation. \ - Do you wish to continue anyway ?")); -} -#endif - -void linphone_gnome_display_warning(LinphoneCore *lc, const char *warning) -{ - LinphoneGnomeUI *ui=(LinphoneGnomeUI*)lc->data; - linphone_gnome_ui_display_something(ui,GTK_MESSAGE_WARNING,warning); -} - -void linphone_gnome_display_status(LinphoneCore *lc, const char *status) -{ - LinphoneGnomeUI *ui=(LinphoneGnomeUI*)lc->data; - if (ui->main_window.window==NULL) return; - if (!ui->main_window.shown_once) return; /* avoid a gnome bug*/ - gtk_statusbar_push(GTK_STATUSBAR(ui->main_window.status_bar), - gtk_statusbar_get_context_id(GTK_STATUSBAR(ui->main_window.status_bar),"") - ,status); -} - -void linphone_gnome_inv_recv(LinphoneCore *lc,const char *from) -{ - LinphoneGnomeUI *ui=(LinphoneGnomeUI*)lc->data; - gchar *title; - if (ui->main_window.window==NULL) return; - gtk_entry_set_text(GTK_ENTRY(ui->main_window.addressentry),from); - title=g_strdup_printf(_("linphone - receiving call from %s"),from); - gtk_window_set_title(GTK_WINDOW(ui->main_window.window),title); - gdk_window_set_keep_above (ui->main_window.window->window, 1); - g_free(title); -} - -void linphone_gnome_show(LinphoneCore *lc) -{ - LinphoneGnomeUI *ui=(LinphoneGnomeUI*)lc->data; - linphone_gnome_ui_show(ui); -} - -void linphone_gnome_display_url(LinphoneCore *lc, const char *message, const char *url) -{ - LinphoneGnomeUI *ui=(LinphoneGnomeUI*)lc->data; - alt_ressource_display(ui,url); -} - - - -void linphone_gnome_notify_received(LinphoneCore *lc,LinphoneFriend *fid, const char *from, const char *status, const char *img){ - FriendList *fl=get_friend_list(); - friend_list_set_friend_status(fl,fid,from,status, img); -} - -void linphone_gnome_new_unknown_subscriber(LinphoneCore *lc, LinphoneFriend *lf, const char *url){ - GtkWidget *d=create_inc_subscr_dialog(); - gchar *text=g_strdup_printf(_("You have received a subscription from %s." - "This means that this person wishes to be notified of your presence information (online, busy, away...).\n" - "Do you agree ?"),url); - gtk_label_set_text(GTK_LABEL(lookup_widget(d,"subscr_label")),text); - g_object_set_data(G_OBJECT(d),"friend_ref",(gpointer)lf); - gtk_widget_show(d); -} - -static gboolean destroy_auth(GtkWidget *w){ - gtk_widget_destroy(w); - return FALSE; -} - -void linphone_gnome_prompt_authentication(LinphoneCore *lc, const gchar *realm, const gchar *username){ - GtkWidget *w=create_authentication_dialog(); - gchar *question=g_strdup_printf(_("Authentication required for realm %s"),realm); - gtk_label_set_text(GTK_LABEL(lookup_widget(w,"question")),question); - g_free(question); - gtk_entry_set_text(GTK_ENTRY(lookup_widget(w,"realm")),realm); - gtk_entry_set_text(GTK_ENTRY(lookup_widget(w,"username")),username); - gtk_widget_show(w); - //automatically destroys the window after 30 seconds to avoid multiple windows to be popped up after some hours. - g_timeout_add(30000,(GtkFunction)destroy_auth,w); -} - -void linphone_gnome_bye_recv(LinphoneCore *lc, const char *from){ - LinphoneGnomeUI *ui=(LinphoneGnomeUI*)lc->data; - gtk_window_set_title(GTK_WINDOW(ui->main_window.window),"linphone"); -} - -void stub(){ -} - -void linphone_gnome_call_log_updated(LinphoneCore *lc, LinphoneCallLog *newcl){ - LinphoneGnomeUI *ui=(LinphoneGnomeUI *)linphone_core_get_user_data(lc); - linphone_gnome_update_call_logs(ui); -} - -void linphone_gnome_text_received(LinphoneCore *lc,LinphoneChatRoom *cr, const char *from, const char *msg){ - GtkWidget *gcr=(GtkWidget*)linphone_chat_room_get_user_data(cr); - if (gcr==NULL){ - gcr=chatroom_new(from,cr); - } - gtk_widget_show(gcr); - chatroom_append(gcr,from,msg); -} - -LinphoneCoreVTable linphone_gnome_vtable= -{ - show: linphone_gnome_show, - inv_recv: linphone_gnome_inv_recv, - bye_recv : linphone_gnome_bye_recv, - notify_recv: linphone_gnome_notify_received, - new_unknown_subscriber: linphone_gnome_new_unknown_subscriber, - auth_info_requested: linphone_gnome_prompt_authentication, - display_status : linphone_gnome_display_status, - display_message : linphone_gnome_display_message, - display_warning : linphone_gnome_display_warning, -#ifdef VINCENT_MAURY_RSVP - display_yes_no : linphone_gnome_display_yes_no, -#endif - display_url : linphone_gnome_display_url, - display_question : stub, - call_log_updated : linphone_gnome_call_log_updated, - text_received: linphone_gnome_text_received -}; - -gboolean linphone_gnome_iterate(LinphoneCore *lc) -{ - linphone_core_iterate(lc); - return TRUE; -} - -void proxy_changed(GtkWidget *combo){ - LinphoneProxyConfig *pcfg=proxy_combo_box_get_selected(combo); - linphone_core_set_default_proxy(get_core(),pcfg); -} - -void linphone_refresh_proxy_combo_box(GtkWidget *window){ - LinphoneCore *lc=get_core(); - GtkWidget *combo; - const MSList *elem=linphone_core_get_proxy_config_list(lc); - LinphoneProxyConfig *cfg=NULL; - GtkWidget *hbox=lookup_widget(window,"proxy_hbox"); - - linphone_core_get_default_proxy(lc,&cfg); - - if (elem==NULL){ - gtk_widget_hide(hbox); - return; - } - combo=(GtkWidget*)g_object_get_data(G_OBJECT(hbox),"proxy"); - if (combo!=NULL){ - gtk_widget_destroy(combo); - } - combo=proxy_combo_box_new(cfg); - g_object_set_data(G_OBJECT(hbox),"proxy",(gpointer)combo); - g_signal_connect(G_OBJECT(combo),"changed",G_CALLBACK(proxy_changed),NULL); - gtk_box_pack_start_defaults(GTK_BOX(hbox),combo); - gtk_widget_show(combo); - gtk_widget_show(hbox); - -} - -void linphone_gnome_init(LinphoneGnomeUI *ui,LinphoneCore *lc) -{ - gchar *configfile_name = - g_strdup_printf ("%s/.gnome2/linphone", getenv ("HOME")); - linphone_gnome_ui_init(ui,lc); - linphone_gnome_ui_show(ui); - linphone_core_init(lc,&linphone_gnome_vtable,configfile_name,(gpointer)ui); - g_free(configfile_name); - set_levels(ui,linphone_core_get_rec_level(lc),linphone_core_get_play_level(lc),linphone_core_get_ring_level(lc)); - /* get history of uri bar */ - restore_uri_history(GTK_ENTRY(ui->main_window.addressentry), linphone_core_get_config(lc)); - linphone_refresh_proxy_combo_box(ui->main_window.window); - ui->timeout_id=gtk_timeout_add(20,(GtkFunction)linphone_gnome_iterate,(gpointer)lc); -} - -void linphone_gnome_uninit(LinphoneGnomeUI *ui) -{ - LinphoneCore *lc=ui->core; - linphone_gnome_ui_uninit(ui); - linphone_core_uninit(lc); - gtk_timeout_remove (ui->timeout_id); -} - -GtkWidget *proxy_combo_box_new(LinphoneProxyConfig *selected){ - GtkWidget *combo; - const MSList *elem; - GtkListStore *store=gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_POINTER); - GtkTreeIter iter; - GtkTreeIter prxiter; - GtkCellRenderer *renderer; - gboolean proxy_found=FALSE; - /* fill the store */ - elem=linphone_core_get_proxy_config_list(get_core()); - gtk_list_store_append(store,&iter); - gtk_list_store_set(store,&iter,0,_("None"),1,(gpointer)NULL,-1); - for(;elem!=NULL;elem=ms_list_next(elem)){ - LinphoneProxyConfig *proxy=(LinphoneProxyConfig*)elem->data; - gtk_list_store_append(store,&iter); - gtk_list_store_set(store,&iter,0,proxy->reg_proxy,1,(gpointer)proxy,-1); - if (selected==proxy) { - prxiter=iter; - proxy_found=TRUE; - } - } - combo=gtk_combo_box_new_with_model(GTK_TREE_MODEL(store)); - g_object_unref(G_OBJECT(store)); - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, - "text", 0, - NULL); - if (proxy_found){ - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo),&prxiter); - }else{ - /*else select "None" */ - gtk_combo_box_set_active(GTK_COMBO_BOX(combo),0); - } - return combo; -} - -LinphoneProxyConfig *proxy_combo_box_get_selected(GtkWidget *combo){ - LinphoneProxyConfig *pcfg=NULL; - GtkTreeIter iter; - if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo),&iter)){ - GtkTreeModel *model=gtk_combo_box_get_model(GTK_COMBO_BOX(combo)); - gtk_tree_model_get(model,&iter,1,(gpointer)&pcfg,-1); - } - return pcfg; -} - -void linphone_gnome_update_call_logs(LinphoneGnomeUI *ui){ - LinphoneCore *lc=ui->core; - GtkTextView *tv; - GtkTextBuffer *tb; - GtkTextIter begin,end; - GtkTextTag *tag; - MSList *elem; - if (ui->logs==NULL) return; - tv=GTK_TEXT_VIEW(lookup_widget(ui->logs,"logview")); - tb=gtk_text_view_get_buffer(tv); - - gtk_text_buffer_get_bounds(tb,&begin,&end); - gtk_text_buffer_delete(tb,&begin,&end); - gtk_text_buffer_get_end_iter(tb,&end); - for (elem=linphone_core_get_call_logs(lc);elem!=NULL;elem=ms_list_next(elem)){ - LinphoneCallLog *cl=(LinphoneCallLog*)elem->data; - gchar *str=linphone_call_log_to_str(cl); - tag=NULL; - if (cl->status==LinphoneCallMissed){ - tag=gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(tb),"redforeground"); - if (tag==NULL) tag = gtk_text_buffer_create_tag (tb, "redforeground", - "foreground", "red", NULL); - } - gtk_text_buffer_insert_with_tags(tb,&end,str,-1,tag,NULL); - gtk_text_buffer_insert(tb,&end,"\n",-1); - - ms_free(str); - } -} - -void linphone_gnome_show_call_logs_window(LinphoneGnomeUI *ui){ - if (ui->logs==NULL) { - ui->logs=create_call_logs(); - } - linphone_gnome_update_call_logs(ui); - gtk_widget_show(ui->logs); -} diff --git a/linphone/gtk/linphone.h b/linphone/gtk/linphone.h deleted file mode 100644 index 983815529..000000000 --- a/linphone/gtk/linphone.h +++ /dev/null @@ -1,68 +0,0 @@ - - -#ifndef LINPHONE_H -#define LINPHONE_H - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#define _(String) gettext (String) - -#include -#include "lpconfig.h" - -#include "support.h" -#include "propertybox.h" -#include "presence.h" -#include "addressbook.h" -#include "friends.h" - -typedef struct _LinphoneMainWindow -{ - GtkWidget *window; - GtkWidget *status_bar; - GtkWidget *addressentry; - GtkWidget *optioncontrols; - GtkWidget *dtmfentry; - GtkWidget *callbutton; - PresenceBox presencebox; - FriendList friendlist; - gboolean shown_once; -}LinphoneMainWindow; - -typedef struct _LinphoneGnomeUI -{ - LinphoneMainWindow main_window; - LinphonePropertyBox propbox; - GtkWidget *ab; /*the address book */ - GtkWidget *logs; /* the call logs window */ - LinphoneCore *core; - guint timeout_id; -}LinphoneGnomeUI; - - -void linphone_gnome_ui_init(LinphoneGnomeUI *ui,LinphoneCore *core); -void linphone_gnome_ui_show(LinphoneGnomeUI *ui); -void linphone_gnome_ui_hide(LinphoneGnomeUI *ui); -void linphone_gnome_ui_uninit(LinphoneGnomeUI *ui); - -void linphone_gnome_init(LinphoneGnomeUI *ui,LinphoneCore *lc); -void linphone_gnome_uninit(LinphoneGnomeUI *ui); - -extern LinphoneGnomeUI *uiobj; - -GtkWidget *proxy_combo_box_new(LinphoneProxyConfig *selected); -void linphone_refresh_proxy_combo_box(GtkWidget *window); -LinphoneProxyConfig *proxy_combo_box_get_selected(GtkWidget *combo); -void linphone_gnome_show_call_logs_window(LinphoneGnomeUI *ui); -void linphone_gnome_update_call_logs(LinphoneGnomeUI *ui); -void linphone_gnome_ui_display_something(LinphoneGnomeUI *ui,GtkMessageType type,const gchar *message); -void linphone_gnome_save_uri_history(LinphoneGnomeUI *ui); - -GtkWidget *chatroom_new(const gchar *url, LinphoneChatRoom *cr); -void chatroom_append(GtkWidget *gcr, const gchar *from, const gchar *message); -void chatroom_close(GtkWidget *gcr); - -#endif diff --git a/linphone/gtk/main.c b/linphone/gtk/main.c deleted file mode 100644 index 646d5540f..000000000 --- a/linphone/gtk/main.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Initial main.c file generated by Glade. Edit as required. - * Glade will not overwrite this file. - */ - - -#include "linphone.h" - -/* -#include "../osipua/src/dbgalloc.h" - -GMemVTable dbgtable={ - smalloc, - srealloc, - sfree, - scalloc, - smalloc, - srealloc -}; -*/ -LinphoneCore core; -LinphoneGnomeUI ui; -static gboolean verbose=0; -GOptionEntry linphone_options[2]={ - { - .long_name="verbose", - .short_name= '\0', - .arg=G_OPTION_ARG_NONE, - .arg_data= (gpointer)&verbose, - .description="log to stdout some debug information while running." - } -}; - -int -main (int argc, char *argv[]) -{ - void *p; - - g_thread_init(NULL); - //g_log_set_fatal_mask("GLib",G_LOG_LEVEL_WARNING); - //g_mem_set_vtable(glib_mem_profiler_table); - //g_mem_set_vtable(&dbgtable); -#ifdef ENABLE_NLS - p=bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); - if (p==NULL) perror("bindtextdomain failed"); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); -#else - printf("NLS disabled.\n"); -#endif - -#ifdef NOWOBSOLETE_NOTYET - gnome_program_init ("linphone", LINPHONE_VERSION, LIBGNOMEUI_MODULE, - argc, argv, - GNOME_PARAM_APP_DATADIR, PACKAGE_DATA_DIR, - GNOME_PARAM_POPT_TABLE,&linphone_options,NULL); -#endif - if (!gtk_init_with_args(&argc,&argv,_("A free SIP video-phone"), - linphone_options,NULL,NULL)) - return -1; - add_pixmap_directory(PACKAGE_DATA_DIR "/pixmaps/linphone"); - add_pixmap_directory("pixmaps"); - - if (verbose) linphone_core_enable_logs(stdout); - else linphone_core_disable_logs(); - linphone_gnome_init(&ui,&core); - linphone_gnome_ui_show(&ui); - gtk_main (); - gdk_threads_leave(); /* it appears that the gdk lock is hold while exiting from gtk_main() */ - linphone_gnome_uninit(&ui); - //g_mem_profile(); - exit(0); - return 0; -} diff --git a/linphone/gtk/presence.c b/linphone/gtk/presence.c deleted file mode 100644 index 18042b2c8..000000000 --- a/linphone/gtk/presence.c +++ /dev/null @@ -1,150 +0,0 @@ -/*************************************************************************** - presence.c - code for the presence box - ------------------- - begin : Mon Dec 17 2001 - copyright : (C) 2001 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#include "linphone.h" -#include "callbacks.h" -#include "support.h" - - -void presence_box_init(PresenceBox *p, GtkWidget *main_window,LinphoneCore *lc) -{ - GtkWidget *r; - p->lc=lc; - p->contact_field=lookup_widget(main_window,"contact_field"); - p->minutesaway=lookup_widget(main_window,"minutesaway"); - r=lookup_widget(main_window,"presence_reachable"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(r),TRUE); - r=lookup_widget(main_window,"presence_frame"); -} - -void presence_box_changed(PresenceBox *p) -{ - presence_box_apply(p); -} - -#define get_presence_box() (&(uiobj)->main_window.presencebox) - - -void -on_reachable (GtkToggleButton *togglebutton,gpointer user_data) -{ - PresenceBox *p=get_presence_box(); - if (!gtk_toggle_button_get_active(togglebutton)) return; - //gtk_widget_set_sensitive(p->contact_field,FALSE); - p->toggled_button=PRESENCE_MODE_REACHABLE; - //gtk_widget_set_sensitive(p->minutesaway,FALSE); - //gtk_widget_set_sensitive(p->contact_field,FALSE); - presence_box_changed(p); -} - - -void -on_busy (GtkToggleButton *togglebutton,gpointer user_data) -{ - PresenceBox *p=get_presence_box(); - if (!gtk_toggle_button_get_active(togglebutton)) return; - //gtk_widget_set_sensitive(p->contact_field,FALSE); - p->toggled_button=PRESENCE_MODE_BUSY; - //gtk_widget_set_sensitive(p->minutesaway,TRUE); - presence_box_changed(p); -} - - -void -on_minutesaway_changed (GtkEditable *editable,gpointer user_data) -{ - PresenceBox *p=get_presence_box(); - presence_box_changed(p); -} - - -void -on_away (GtkToggleButton *togglebutton,gpointer user_data) -{ - PresenceBox *p=get_presence_box(); - if (!gtk_toggle_button_get_active(togglebutton)) return; - //gtk_widget_set_sensitive(p->contact_field,FALSE); - //gtk_widget_set_sensitive(p->minutesaway,TRUE); - p->toggled_button=PRESENCE_MODE_AWAY; - presence_box_changed(p); -} - - -void -on_do_not_disturb (GtkToggleButton *togglebutton,gpointer user_data) -{ - PresenceBox *p=get_presence_box(); - if (!gtk_toggle_button_get_active(togglebutton)) return; - //gtk_widget_set_sensitive(p->contact_field,FALSE); - //gtk_widget_set_sensitive(p->minutesaway,FALSE); - p->toggled_button=PRESENCE_MODE_NOT_DISTURB; - presence_box_changed(p); -} - - -void -on_moved_tmply (GtkToggleButton *togglebutton,gpointer user_data) -{ - PresenceBox *p=get_presence_box(); - if (!gtk_toggle_button_get_active(togglebutton)) return; - //gtk_widget_set_sensitive(p->contact_field,TRUE); - //gtk_widget_set_sensitive(p->minutesaway,FALSE); - p->toggled_button=PRESENCE_MODE_MOVED; - presence_box_changed(p); -} - - -void -on_alt_serv (GtkToggleButton *togglebutton,gpointer user_data) -{ - PresenceBox *p=get_presence_box(); - if (!gtk_toggle_button_get_active(togglebutton)) return; - //gtk_widget_set_sensitive(p->contact_field,TRUE); - //gtk_widget_set_sensitive(p->minutesaway,FALSE); - p->toggled_button=PRESENCE_MODE_ALT_SERVICE; - presence_box_changed(p); -} - - -void -on_contact_field_changed (GtkEditable *entry,gpointer user_data) -{ - PresenceBox *p=get_presence_box(); - presence_box_changed(p); -} - -void presence_box_apply(PresenceBox *p) -{ - gchar *tmp,*contact=NULL; - int minutes_away=-1; - g_message("presence_box_apply"); - /* retrieve the minutes away */ - tmp = gtk_editable_get_chars (GTK_EDITABLE(p->minutesaway),0,-1); - if (tmp!=NULL && strlen(tmp)>0) - { - minutes_away = atoi(tmp); - g_free(tmp); - } - /* retrieve the alternate contact url */ - tmp = gtk_editable_get_chars (GTK_EDITABLE(p->contact_field),0,-1); - if (tmp!=NULL && strlen(tmp)>0) - { - contact=tmp; - } - /* set presence mode */ - linphone_core_set_presence_info(p->lc,minutes_away,contact,p->toggled_button); - if (tmp!=NULL) g_free(tmp); -} diff --git a/linphone/gtk/presence.h b/linphone/gtk/presence.h deleted file mode 100644 index cbe8701c7..000000000 --- a/linphone/gtk/presence.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************** - presence.h - code for the presence box - ------------------- - begin : Mon Dec 17 2001 - copyright : (C) 2001 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef PRESENCE_H -#define PRESENCE_H - -enum { PRESENCE_MODE_REACHABLE=LINPHONE_STATUS_ONLINE, - PRESENCE_MODE_BUSY=LINPHONE_STATUS_BUSY, - PRESENCE_MODE_AWAY=LINPHONE_STATUS_AWAY, - PRESENCE_MODE_NOT_DISTURB=LINPHONE_STATUS_NOT_DISTURB, - PRESENCE_MODE_MOVED=LINPHONE_STATUS_MOVED, - PRESENCE_MODE_ALT_SERVICE=LINPHONE_STATUS_ALT_SERVICE - }; - - -typedef struct _PresenceBox -{ - LinphoneCore *lc; - GtkWidget *minutesaway; - GtkWidget *contact_field; - gint toggled_button; /* indicate which button is toggled*/ -} PresenceBox; - - -void presence_box_init(PresenceBox *p, GtkWidget *main_window,LinphoneCore *lc); -void presence_box_changed(PresenceBox *p); -void presence_box_apply(PresenceBox *p); - -#endif diff --git a/linphone/gtk/propertybox.c b/linphone/gtk/propertybox.c deleted file mode 100644 index 3a4b472ed..000000000 --- a/linphone/gtk/propertybox.c +++ /dev/null @@ -1,1107 +0,0 @@ -/*************************************************************************** - propertybox.c - description - ------------------- - begin : Wed Jan 30 2002 - copyright : (C) 2002 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - - -#include "linphone.h" - -enum{ -#ifdef INET6 - IFACE_INDEX, -#endif - IFACE_NAME, - IFACE_ADDR, - IFACE_NCOLUMNS -}; - -enum { - CODEC_NAME, - CODEC_RATE, - CODEC_BITRATE, - CODEC_STATUS, - CODEC_PRIVDATA, - CODEC_COLOR, - CODEC_NCOLUMNS -}; - -#define get_core() (uiobj->core) -#define get_property_box() (&uiobj->propbox) -#ifdef NOTYET -#define property_box_changed() gnome_property_box_changed(GNOME_PROPERTY_BOX ( (&uiobj->propbox)->prop)) -#else -#define property_box_changed() -#endif -#define get_main_window() (&uiobj->main_window) - -#if !GTK_CHECK_VERSION(2,6,0) -static gchar * _lp_combo_box_get_active_text (GtkComboBox *combobox) -{ - GtkTreeIter iter; - GtkTreeModel *model; - gchar *text = NULL; - model = gtk_combo_box_get_model (combobox); - if (gtk_combo_box_get_active_iter (combobox, &iter) && model) - gtk_tree_model_get (model, &iter, 0, &text, -1); - return text; -} -#endif /* GTK+ < 2.6.0 */ - -void net_section_init(NetSection *sec, GtkWidget *prop) -{ - sec->au_port=lookup_widget(prop,"audioport"); - sec->audio_jittcomp=lookup_widget(prop,"audio_jittcomp"); -#ifdef LINPHONE_DEPRECATED - sec->interfaces=lookup_widget(prop, "interfaces"); -#endif - sec->nat_address=lookup_widget(prop,"nat_address"); - sec->use_sipinfo=lookup_widget(prop,"use_sipinfo"); - sec->enable_ipv6=lookup_widget(prop,"enable_ipv6"); -} - -void codec_list_update(GtkTreeView *listview); - - -void net_selection_changed_cb(GtkTreeSelection *select, gpointer userdata) -{ - property_box_changed(); -} - -void net_section_fill(NetSection *sec,LinphoneCore *lc) -{ - gfloat value; - const gchar *nat_address,*stun_server; - - value=(gfloat)linphone_core_get_audio_jittcomp(lc); - /* put the current value of jitt_comp*/ - gtk_adjustment_set_value (gtk_range_get_adjustment(GTK_RANGE(sec->audio_jittcomp)),value); - /* display current rtp port */ - gtk_spin_button_set_value(GTK_SPIN_BUTTON(sec->au_port), - (gfloat)linphone_core_get_audio_port(lc)); - - - /* nat setup */ - nat_address=linphone_core_get_nat_address(lc); - - if (linphone_core_get_firewall_policy(lc)==LINPHONE_POLICY_USE_NAT_ADDRESS) - gtk_toggle_button_set_active( - GTK_TOGGLE_BUTTON(lookup_widget(get_property_box()->prop,"static_nat")) - ,TRUE); - - if (nat_address!=NULL) { - gtk_entry_set_text(GTK_ENTRY(sec->nat_address),nat_address); - } - stun_server=linphone_core_get_stun_server(lc); - if (stun_server!=NULL) - gtk_entry_set_text( - GTK_ENTRY(lookup_widget(get_property_box()->prop,"stun_server")), - stun_server); - if (linphone_core_get_firewall_policy(lc)==LINPHONE_POLICY_USE_STUN) - gtk_toggle_button_set_active( - GTK_TOGGLE_BUTTON(lookup_widget(get_property_box()->prop,"use_stun")),TRUE); - - - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sec->use_sipinfo), - linphone_core_get_use_info_for_dtmf(lc)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sec->enable_ipv6), - linphone_core_ipv6_enabled(lc)); -} - -void -on_enable_nat_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - property_box_changed(); - -} - - - -void -on_nat_address_changed (GtkEditable *editable, - gpointer user_data) -{ - property_box_changed(); -} - -void -on_enable_ipv6_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - property_box_changed(); -} - - -void net_section_apply(NetSection *sec,LinphoneCore *lc) -{ - gboolean use_nat,use_stun; - gchar *name; - - use_nat=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( - lookup_widget(get_property_box()->prop,"static_nat"))); - name=gtk_editable_get_chars(GTK_EDITABLE(sec->nat_address),0,-1); - linphone_core_set_nat_address(lc,name); - g_free(name); - - use_stun=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( - lookup_widget(get_property_box()->prop,"use_stun") )); - name=gtk_editable_get_chars(GTK_EDITABLE( - lookup_widget(get_property_box()->prop,"stun_server") ),0,-1); - linphone_core_set_stun_server(lc,name); - g_free(name); - if (use_stun) linphone_core_set_firewall_policy(lc, - LINPHONE_POLICY_USE_STUN); - else if (use_nat) linphone_core_set_firewall_policy(lc, - LINPHONE_POLICY_USE_NAT_ADDRESS); - else linphone_core_set_firewall_policy(lc, - LINPHONE_POLICY_NO_FIREWALL); - - { - /* get the value of jitt_comp*/ - GtkAdjustment *adj= gtk_range_get_adjustment(GTK_RANGE(sec->audio_jittcomp)); - linphone_core_set_audio_jittcomp(lc,(gint)adj->value); - /* get rtp port */ - adj=gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(sec->au_port)); - linphone_core_set_audio_port(lc,(gint)adj->value); - } - linphone_core_enable_ipv6(lc,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sec->enable_ipv6))); -} - - -enum{ - PROXY_CONFIG_IDENTITY, - PROXY_CONFIG_REF, - PROXY_CONFIG_NCOL -}; - -void sip_section_init(SipSection *sec,GtkWidget *prop) -{ - - GtkListStore *store; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkTreeSelection *select; - sec->port=lookup_widget(prop,"sip_port"); - sec->username=lookup_widget(prop, "user_name"); - sec->hostname=lookup_widget(prop,"domain_name"); - sec->proxy_list=lookup_widget(prop,"proxy_list"); - sec->guess_hostname=lookup_widget(prop,"guess_hostname"); - /* create the proxy list */ - store = gtk_list_store_new (PROXY_CONFIG_NCOL, G_TYPE_STRING, G_TYPE_POINTER); - - gtk_tree_view_set_model(GTK_TREE_VIEW(sec->proxy_list),GTK_TREE_MODEL(store)); - g_object_unref(G_OBJECT(store)); - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Account"), - renderer, - "text", PROXY_CONFIG_IDENTITY, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (sec->proxy_list), column); - - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (sec->proxy_list)); - gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); -} - - -void proxy_list_fill(GtkTreeModel *model, LinphoneCore *lc){ - const MSList *elem; - GtkTreeIter iter; - /* fill the proxy list */ - gtk_list_store_clear(GTK_LIST_STORE(model)); - elem=linphone_core_get_proxy_config_list(lc); - for(;elem!=NULL;elem=ms_list_next(elem)){ - LinphoneProxyConfig *pcfg=(LinphoneProxyConfig*)elem->data; - gtk_list_store_append(GTK_LIST_STORE(model),&iter); - gtk_list_store_set(GTK_LIST_STORE(model),&iter,PROXY_CONFIG_IDENTITY,pcfg->reg_identity, - PROXY_CONFIG_REF,pcfg,-1); - } -} - -void sip_section_fill(SipSection *sec, LinphoneCore *lc) -{ - osip_from_t *contact; - GtkTreeModel *model=gtk_tree_view_get_model(GTK_TREE_VIEW(sec->proxy_list)); - - /* set sip port */ - gtk_spin_button_set_value(GTK_SPIN_BUTTON(sec->port), - (gfloat)linphone_core_get_sip_port(lc)); - contact=linphone_core_get_primary_contact_parsed(lc); - g_return_if_fail(contact!=NULL); - /* set sip username */ - gtk_entry_set_text(GTK_ENTRY(sec->username),contact->url->username); - /* set domain name */ - gtk_entry_set_text(GTK_ENTRY(sec->hostname),contact->url->host); - osip_from_free(contact); - proxy_list_fill(model,lc); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sec->guess_hostname), - linphone_core_get_guess_hostname(lc)); -} - -void sip_section_apply(SipSection *sec, LinphoneCore *lc) -{ - GtkAdjustment *adj; - gchar *tmp; - gchar *username,*hostname; - /* get sip port*/ - adj=gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(sec->port)); - - username=gtk_editable_get_chars(GTK_EDITABLE(sec->username),0,-1); - if (username!=NULL && strlen(username)!=0) - { - hostname=gtk_editable_get_chars(GTK_EDITABLE(sec->hostname),0,-1); - if (hostname!=NULL && strlen(hostname)!=0) - { - tmp=g_strdup_printf("sip:%s@%s",username,hostname); - linphone_core_set_primary_contact(lc,tmp); - linphone_core_set_sip_port(lc,(int)gtk_adjustment_get_value(adj)); - g_free(hostname); - g_free(tmp); - } - g_free(username); - } -} - - -void -on_addproxy_button_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *w=create_proxy_config_box(); - gtk_widget_show(w); -} - - -void -on_editproxy_button_clicked (GtkButton *button, - gpointer user_data) -{ - GtkWidget *w; - GtkTreeSelection *select; - GtkTreeIter iter; - GtkTreeModel *model; - LinphoneProxyConfig * cfg; - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (get_property_box()->sip.proxy_list)); - if (gtk_tree_selection_get_selected (select, &model, &iter)) - { - gtk_tree_model_get (model, &iter,PROXY_CONFIG_REF , &cfg, -1); - gtk_list_store_remove(GTK_LIST_STORE(model), &iter); - linphone_proxy_config_edit(cfg); - }else return; - w=create_proxy_config_box(); - gtk_widget_show(w); - if (cfg->reg_proxy!=NULL) gtk_entry_set_text(GTK_ENTRY(lookup_widget(w,"reg_proxy")),cfg->reg_proxy); - if (cfg->reg_route!=NULL) gtk_entry_set_text(GTK_ENTRY(lookup_widget(w,"reg_route")),cfg->reg_route); - if (cfg->reg_identity!=NULL) gtk_entry_set_text(GTK_ENTRY(lookup_widget(w,"reg_identity")),cfg->reg_identity); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(w,"reg_sendregister")),cfg->reg_sendregister); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(w,"publish")),cfg->publish); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(w,"reg_expires")),cfg->expires); - g_object_set_data(G_OBJECT(w),"edited_config",(gpointer)cfg); -} - - -void -on_removeproxy_button_clicked (GtkButton *button, - gpointer user_data) -{ - GtkTreeSelection *select; - GtkTreeIter iter; - GtkTreeModel *model; - LinphoneProxyConfig * cfg; - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (get_property_box()->sip.proxy_list)); - if (gtk_tree_selection_get_selected (select, &model, &iter)) - { - gtk_tree_model_get (model, &iter,PROXY_CONFIG_REF , &cfg, -1); - gtk_list_store_remove(GTK_LIST_STORE(model), &iter); - linphone_core_remove_proxy_config(get_core(),cfg); - linphone_refresh_proxy_combo_box(get_main_window()->window); - } -} - -void get_proxy_config_box_data(GtkWidget *dialog) -{ - gchar *tmp; - gboolean editing=FALSE; - LinphoneProxyConfig *cfg; - tmp=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(dialog,"reg_proxy")),0,-1); - cfg=(LinphoneProxyConfig*)g_object_get_data(G_OBJECT(dialog),"edited_config"); - if (cfg==NULL){ - cfg=linphone_proxy_config_new(); - linphone_proxy_config_set_server_addr(cfg,tmp); - g_free(tmp); - if (cfg==NULL) { - /* set an error message here */ - return; - } - }else{ - linphone_proxy_config_set_server_addr(cfg,tmp); - g_free(tmp); - editing=TRUE; - } - tmp=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(dialog,"reg_route")),0,-1); - linphone_proxy_config_set_route(cfg,tmp); - g_free(tmp); - tmp=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(dialog,"reg_identity")),0,-1); - linphone_proxy_config_set_identity(cfg,tmp); - g_free(tmp); - tmp=gtk_editable_get_chars(GTK_EDITABLE(lookup_widget(dialog,"reg_expires")),0,-1); - { - int exp; - if (tmp!=NULL) - { - exp = atoi(tmp); - if (exp<=0) - exp = 200; /* minimum */ - if (exp>7200) - exp = 7200; /* maximum */ - linphone_proxy_config_expires(cfg,exp); - } - } - g_free(tmp); - linphone_proxy_config_enableregister(cfg,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog,"reg_sendregister")))); - linphone_proxy_config_enable_publish(cfg,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(dialog,"publish")))); - if (editing) linphone_proxy_config_done(cfg); - else linphone_core_add_proxy_config(get_core(),cfg); - /* set the last entered/changed proxy as the default one */ - linphone_core_set_default_proxy(get_core(),cfg); - proxy_list_fill(gtk_tree_view_get_model(GTK_TREE_VIEW(get_property_box()->sip.proxy_list)),get_core()); - linphone_refresh_proxy_combo_box(get_main_window()->window); -} - -void -on_proxy_config_box_response (GtkDialog *dialog, - gint response_id, - gpointer user_data) -{ - switch(response_id){ - case GTK_RESPONSE_OK: - get_proxy_config_box_data(GTK_WIDGET(dialog)); - gtk_widget_destroy(GTK_WIDGET(dialog)); - - break; - } -} - - -void codec_section_init(CodecSection *sec, GtkWidget *prop) -{ - sec->au_codec_list=lookup_widget(prop,"au_codec_list"); - sec->vi_codec_list=lookup_widget(prop,"vid_codec_list"); - sec->codec_info=lookup_widget(prop,"codec_info"); -} - -void codec_selection_changed_cb(GtkTreeSelection *selection, gpointer data) -{ - GtkTreeIter iter; - GtkTreeModel *model; - struct _PayloadType *pt=NULL; - LinphonePropertyBox *prop=get_property_box(); - - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - gtk_tree_model_get (model, &iter, CODEC_PRIVDATA, &pt, -1); - g_return_if_fail(pt!=NULL); - /* display the codec information */ - gtk_label_set_text(GTK_LABEL(prop->codec.codec_info),payload_type_get_description(pt)); - } -} - -void codec_list_build(GtkTreeView *listview,const MSList *codeclist) -{ - const MSList *elem; - GtkListStore *store = gtk_list_store_new (CODEC_NCOLUMNS, G_TYPE_STRING, - G_TYPE_INT, - G_TYPE_FLOAT, - G_TYPE_STRING, - G_TYPE_POINTER, - G_TYPE_STRING); - GtkTreeIter iter; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkTreeSelection *select=gtk_tree_view_get_selection (listview); - for(elem=codeclist; elem!=NULL; elem=elem->next){ - gchar *status; - gint rate; - gfloat bitrate; - gchar *color; - struct _PayloadType *pt=(struct _PayloadType *)elem->data; - if (payload_type_enabled(pt)) status=_("Enabled"); - else status=_("Disabled"); - if (linphone_core_check_payload_type_usability(get_core(),pt)) color="blue"; - else color="red"; - /* get an iterator */ - gtk_list_store_append(store,&iter); - bitrate=payload_type_get_bitrate(pt)/1000.0; - rate=payload_type_get_rate(pt); - gtk_list_store_set(store,&iter, CODEC_NAME,payload_type_get_mime(pt), - CODEC_RATE,rate, - CODEC_BITRATE,bitrate, - CODEC_STATUS,status, - CODEC_PRIVDATA,(gpointer)pt, - CODEC_COLOR,(gpointer)color, - -1); - } - gtk_tree_view_set_model(listview,GTK_TREE_MODEL(store)); - g_object_unref(G_OBJECT(store)); - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Name"), - renderer, - "text", CODEC_NAME, - "foreground",CODEC_COLOR, - NULL); - gtk_tree_view_append_column (listview, column); - column = gtk_tree_view_column_new_with_attributes (_("Rate (Hz)"), - renderer, - "text", CODEC_RATE, - "foreground",CODEC_COLOR, - NULL); - gtk_tree_view_append_column (listview, column); - column = gtk_tree_view_column_new_with_attributes (_("Status"), - renderer, - "text", CODEC_STATUS, - "foreground",CODEC_COLOR, - NULL); - gtk_tree_view_append_column (listview, column); - column = gtk_tree_view_column_new_with_attributes (_("Min bitrate (kbit/s)"), - renderer, - "text", CODEC_BITRATE, - "foreground",CODEC_COLOR, - NULL); - gtk_tree_view_append_column (listview, column); - - /* Setup the selection handler */ - select = gtk_tree_view_get_selection (listview); - gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); - //gtk_tree_view_columns_autosize(GTK_TREE_VIEW (sec->interfaces)); - g_signal_connect (G_OBJECT (select), "changed", - G_CALLBACK (codec_selection_changed_cb), - NULL); -} - -void codec_section_fill(CodecSection *sec, LinphoneCore *lc, GtkWidget *propbox) -{ - /* display prefered codecs*/ - int value; - const MSList *audio_codecs=linphone_core_get_audio_codecs(lc); - const MSList *video_codecs=linphone_core_get_video_codecs(lc); - codec_list_build(GTK_TREE_VIEW(sec->au_codec_list),audio_codecs); - codec_list_build(GTK_TREE_VIEW(lookup_widget(propbox,"vid_codec_list")),video_codecs); - value=linphone_core_get_download_bandwidth(lc); - if (value!=0) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(propbox,"download_bw")),value); - else - gtk_entry_set_text(GTK_ENTRY(lookup_widget(propbox,"download_bw")),_("Unlimited")); - value=linphone_core_get_upload_bandwidth(lc); - if (value!=0) - gtk_spin_button_set_value(GTK_SPIN_BUTTON(lookup_widget(propbox,"upload_bw")),value); - else - gtk_entry_set_text(GTK_ENTRY(lookup_widget(propbox,"upload_bw")),_("Unlimited")); -} - -void codec_section_apply(CodecSection *sec, LinphoneCore *lc) -{ - GtkTreeIter iter; - struct _PayloadType *pt; - MSList *codeclist=NULL; - gchar *status; - GtkTreeModel *model=gtk_tree_view_get_model(GTK_TREE_VIEW(sec->au_codec_list)); - /* retrieve the codec list */ - g_return_if_fail(gtk_tree_model_get_iter_first(model,&iter)); - do{ - gtk_tree_model_get (model, &iter, CODEC_STATUS,&status,CODEC_PRIVDATA, &pt,-1); - g_return_if_fail(pt!=NULL); - if (strcmp(status,_("Enabled"))==0) payload_type_set_enable(pt,1); - else payload_type_set_enable(pt,0); - codeclist=ms_list_append(codeclist,pt); - }while (gtk_tree_model_iter_next(model,&iter)); - linphone_core_set_audio_codecs(lc,codeclist); - model=gtk_tree_view_get_model(GTK_TREE_VIEW(sec->vi_codec_list)); - /* retrieve the codec list */ - codeclist=NULL; - g_return_if_fail(gtk_tree_model_get_iter_first(model,&iter)); - do{ - gtk_tree_model_get (model, &iter, CODEC_STATUS,&status,CODEC_PRIVDATA, &pt,-1); - g_return_if_fail(pt!=NULL); - if (strcmp(status,_("Enabled"))==0) payload_type_set_enable(pt,1); - else payload_type_set_enable(pt,0); - codeclist=ms_list_append(codeclist,pt); - }while (gtk_tree_model_iter_next(model,&iter)); - linphone_core_set_video_codecs(lc,codeclist); -} - -void sound_section_init(SoundSection *sec, GtkWidget *prop) -{ - sec->source_entry=lookup_widget(prop,"rec_source"); - sec->ringfileentry=lookup_widget(prop,"ringfileentry"); -} - - -void -on_play_card_changed (GtkComboBox *combobox, - gpointer user_data) -{ -#if GTK_CHECK_VERSION(2,6,0) - char *dev=gtk_combo_box_get_active_text(combobox); -#else /* GTK < 2.6.0 */ - char *dev=_lp_combo_box_get_active_text(combobox); -#endif /* GTK < 2.6.0 */ - linphone_core_set_playback_device(get_core(),dev); - property_box_changed(); - g_free(dev); -} - - -void -on_capt_card_changed (GtkComboBox *combobox, - gpointer user_data) -{ -#if GTK_CHECK_VERSION(2,6,0) - char * dev=gtk_combo_box_get_active_text(combobox); -#else /* GTK < 2.6.0 */ - char * dev=_lp_combo_box_get_active_text(combobox); -#endif /* GTK < 2.6.0 */ - linphone_core_set_capture_device(get_core(),dev); - property_box_changed(); - g_free(dev); -} - -void -on_ring_card_changed (GtkComboBox *combobox, - gpointer user_data) -{ -#if GTK_CHECK_VERSION(2,6,0) - char * dev=gtk_combo_box_get_active_text(combobox); -#else /* GTK < 2.6.0 */ - char * dev=_lp_combo_box_get_active_text(combobox); -#endif /* GTK < 2.6.0 */ - if(dev != NULL) - { - linphone_core_set_ringer_device(get_core(),dev); - property_box_changed(); - g_free(dev); - } -} - -static int get_dev_index(const char **devnames, const char *dev){ - int i; - for (i=0;devnames[i]!=NULL;i++){ - if (strcmp(devnames[i],dev)==0) - return i; - } - g_warning("could not find %s in device list.",dev); - return 0; -} - -void sound_section_fill(SoundSection *sec, LinphoneCore *lc) -{ - GtkComboBox *play_card=GTK_COMBO_BOX(lookup_widget(get_property_box()->prop,"play_card")); - GtkComboBox *capt_card=GTK_COMBO_BOX(lookup_widget(get_property_box()->prop,"capt_card")); - GtkComboBox *ring_card=GTK_COMBO_BOX(lookup_widget(get_property_box()->prop,"ring_card")); - int i; - const char **devnames=linphone_core_get_sound_devices(lc); - /* select used sound drivers*/ - - for (i=0;devnames[i]!=NULL;i++){ - const char *carddesc=devnames[i]; - gtk_combo_box_append_text(play_card,carddesc); - gtk_combo_box_append_text(capt_card,carddesc); - gtk_combo_box_append_text(ring_card,carddesc); - } - /*select used cards */ - gtk_combo_box_set_active(play_card,get_dev_index(devnames,linphone_core_get_playback_device(lc))); - gtk_combo_box_set_active(capt_card,get_dev_index(devnames,linphone_core_get_capture_device(lc))); - gtk_combo_box_set_active(ring_card,get_dev_index(devnames,linphone_core_get_ringer_device(lc))); - /* select audio source*/ - switch(linphone_core_get_sound_source(lc)) - { - case 'm': - gtk_entry_set_text (GTK_ENTRY (sec->source_entry), _("micro")); - break; - case 'l': - gtk_entry_set_text (GTK_ENTRY (sec->source_entry), _("line")); - break; - default: - g_warning("Invalid source !"); - } - { - const gchar *ringfile=linphone_core_get_ring(lc); - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(sec->ringfileentry),ringfile); - - } - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(lookup_widget(get_property_box()->prop,"echocancelation")),linphone_core_echo_cancelation_enabled(lc)); -} - - - - -void sound_section_apply(SoundSection *sec, LinphoneCore *lc) -{ - gchar *tmp; - - /* get audio source*/ - tmp=gtk_editable_get_chars(GTK_EDITABLE(sec->source_entry),0,-1); - if (strcmp(tmp,_("micro"))==0) linphone_core_set_sound_source(lc,'m'); - else if (strcmp(tmp,_("line"))==0) linphone_core_set_sound_source(lc,'l'); - g_free(tmp); - - /* get ring path */ - tmp=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(sec->ringfileentry)); - if(tmp != NULL) - { - linphone_core_set_ring(lc,tmp); - g_free(tmp); - } -} - -void ring_finished(LinphoneCore *lc,gpointer user_data) -{ - GtkWidget *button=(GtkWidget*)user_data; - LinphonePropertyBox *prop=get_property_box(); - if (prop->prop==NULL) return; /* the box has been closed before the end of the preview */ - gtk_widget_set_sensitive(button,1); -} - -void -on_ringpreview_clicked (GtkButton *button, - gpointer user_data) -{ - int err; - gchar *tmp; - LinphonePropertyBox *prop=get_property_box(); - LinphoneCore *lc=get_core(); - /* get ring path */ - tmp=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(prop->sound.ringfileentry)); - err=linphone_core_preview_ring(lc,tmp,ring_finished,(gpointer)button); - if (err==0) gtk_widget_set_sensitive(GTK_WIDGET(button),0); - g_free(tmp); -} - - -void linphone_property_box_fill(LinphonePropertyBox * box, LinphoneCore *lp) -{ - net_section_fill(&box->net,lp); - sip_section_fill(&box->sip,lp); - codec_section_fill(&box->codec,lp,box->prop); - sound_section_fill(&box->sound,lp); - /* set uchanged state to the prop1 box, because gtk_entry_set_text() causes signal "changed" - to be sent */ -#ifdef NOTYET - gnome_property_box_set_state(GNOME_PROPERTY_BOX(box->prop),0); -#else - fprintf(stderr, "not yet implemented\n"); -#endif -} - -void linphone_property_box_init(LinphonePropertyBox *box) -{ - GtkWidget *prop=create_prop1(); - box->prop=prop; - net_section_init(&box->net,prop); - sip_section_init(&box->sip,prop); - codec_section_init(&box->codec,prop); - sound_section_init(&box->sound,prop); - gtk_widget_show(prop); - linphone_property_box_fill(box,get_core()); -} - - - - -void linphone_property_box_apply (gint pagenum) -{ - LinphonePropertyBox *prop=get_property_box(); - LinphoneCore *lc=get_core(); - switch(pagenum) - { - case 0: - net_section_apply(&prop->net,lc); - break; - case 1: - sound_section_apply(&prop->sound,lc); - break; - case 2: - sip_section_apply(&prop->sip,lc); - break; - case 3: - codec_section_apply(&prop->codec,lc); - break; - } -} - - -void -on_audioport_changed (GtkEditable *editable, - gpointer user_data) -{ -#ifdef NOTYET - LinphonePropertyBox *prop=get_property_box(); - gnome_property_box_changed(GNOME_PROPERTY_BOX(prop->prop)); - return; -#endif -} - - -void -on_sipport_changed (GtkEditable *editable, - gpointer user_data) -{ -#ifdef NOTYET - LinphonePropertyBox *prop=get_property_box(); - gnome_property_box_changed(GNOME_PROPERTY_BOX(prop->prop)); - return; -#endif -} - - -void -on_source_changed (GtkEditable *editable, - gpointer user_data) -{ -#ifdef NOTYET - LinphonePropertyBox *prop=get_property_box(); - gnome_property_box_changed(GNOME_PROPERTY_BOX(prop->prop)); -#endif -} - -enum { - CODEC_ACTION_UP, - CODEC_ACTION_DOWN -}; - - -void codec_row_move(GtkTreeView *listview, int action) -{ - GtkTreeIter iter; - GtkTreeIter previter,nextiter,newiter; - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreePath *treepath; - struct _PayloadType *codec=NULL; - gchar *name=NULL; - gint rate; - gfloat bitrate; - gchar *status=NULL; - gchar *color=NULL; - - selection=gtk_tree_view_get_selection(listview); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - gtk_tree_model_get (model, &iter, CODEC_NAME,&name, - CODEC_RATE,&rate, - CODEC_BITRATE,&bitrate, - CODEC_STATUS,&status, - CODEC_PRIVDATA, &codec, - CODEC_COLOR,&color, - -1); - g_return_if_fail(codec!=NULL); - switch(action){ - case CODEC_ACTION_UP: - /* get an iterator on the prev codec */ - treepath=gtk_tree_model_get_path(model,&iter); - if (!gtk_tree_path_prev(treepath)){ - /* codec is the first, no match. */ - return; - } - gtk_tree_model_get_iter(model,&previter,treepath); - gtk_list_store_insert_before(GTK_LIST_STORE(model),&newiter,&previter); - break; - case CODEC_ACTION_DOWN: - /* get an iterator on the next codec */ - nextiter=iter; - if (!gtk_tree_model_iter_next(model,&nextiter)){ - /* codec is the last, no match. */ - return; - } - gtk_list_store_insert_after(GTK_LIST_STORE(model),&newiter,&nextiter); - - break; - } - gtk_list_store_set(GTK_LIST_STORE(model),&newiter, - CODEC_NAME,name, - CODEC_RATE,rate, - CODEC_BITRATE,bitrate, - CODEC_STATUS,status, - CODEC_PRIVDATA, codec, - CODEC_COLOR,color, - -1); - /* remove the selected line */ - gtk_list_store_remove(GTK_LIST_STORE(model),&iter); - gtk_tree_selection_select_iter(selection,&newiter); - g_free(name); - g_free(status); - g_free(color); - } -} - -static void codec_move(int action){ - GtkTreeView *listview; - int page=gtk_notebook_get_current_page(GTK_NOTEBOOK( - lookup_widget(get_property_box()->prop,"codec_notebook"))); - if (page==0) - listview=GTK_TREE_VIEW(get_property_box()->codec.au_codec_list); - else - listview=GTK_TREE_VIEW(lookup_widget(get_property_box()->prop,"vid_codec_list")); - codec_row_move(listview,action); - property_box_changed(); -} - -void -on_aucodec_up_clicked (GtkButton *button, - gpointer user_data) -{ - codec_move(CODEC_ACTION_UP); -} - - -void -on_aucodec_down_clicked (GtkButton *button, - gpointer user_data) -{ - codec_move(CODEC_ACTION_DOWN); -} - -void codec_set_status(GtkTreeView *listview,gboolean status) -{ - GtkTreeModel *model; - GtkTreeSelection *selection; - GtkTreeIter iter; - gchar *statusstring; - selection=gtk_tree_view_get_selection(listview); - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - if (status) statusstring=_("Enabled"); - else statusstring=_("Disabled"); - gtk_list_store_set(GTK_LIST_STORE(model),&iter,CODEC_STATUS,statusstring,-1); - } -} - -void codec_list_update(GtkTreeView *listview) -{ - GtkTreeModel *model; - GtkTreeIter iter; - PayloadType *pt; - gchar *color; - gfloat bitrate; - model=gtk_tree_view_get_model(listview); - - g_return_if_fail(gtk_tree_model_get_iter_first(model,&iter)); - do{ - gtk_tree_model_get (model, &iter, CODEC_PRIVDATA, &pt,-1); - if (linphone_core_check_payload_type_usability(get_core(),pt)){ - color="blue"; - }else color="red"; - bitrate=payload_type_get_bitrate(pt)/1000.0; - gtk_list_store_set(GTK_LIST_STORE(model),&iter,CODEC_COLOR,color,CODEC_BITRATE,bitrate,-1); - }while (gtk_tree_model_iter_next(model,&iter)); -} - -static void codec_enable(gboolean val){ - GtkTreeView *listview; - int page=gtk_notebook_get_current_page(GTK_NOTEBOOK( - lookup_widget(get_property_box()->prop,"codec_notebook"))); - if (page==0) - listview=GTK_TREE_VIEW(get_property_box()->codec.au_codec_list); - else - listview=GTK_TREE_VIEW(lookup_widget(get_property_box()->prop,"vid_codec_list")); - codec_set_status(listview,val); - property_box_changed(); -} - -void -on_aucodec_enable_clicked (GtkButton *button, - gpointer user_data) -{ - codec_enable(TRUE); -} - - -void -on_aucodec_disable_clicked (GtkButton *button, - gpointer user_data) -{ - codec_enable(FALSE); -} - - -void -on_user_name_changed (GtkEditable *editable, - gpointer user_data) -{ - property_box_changed(); -} - - -void -on_domain_name_changed (GtkEditable *editable, - gpointer user_data) -{ - property_box_changed(); -} - - - -void -on_reg_passwd_changed (GtkEditable *editable, - gpointer user_data) -{ - property_box_changed(); -} - - -void -on_obproxy_button_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - property_box_changed(); -} - -void -on_address_of_record_changed (GtkEditable *editable, - gpointer user_data) -{ - property_box_changed(); -} - - -void -on_audio_jittcomp_value_changed (GtkRange *range, - gpointer user_data) -{ - property_box_changed(); -} - -void -on_ringfileentry_changed (GtkEditable *editable, - gpointer user_data) -{ - property_box_changed(); -} - -void linphone_property_box_uninit(LinphonePropertyBox *box) -{ - memset(box,0, sizeof(LinphonePropertyBox)); -} - -void -on_property_box_response (GtkDialog *dialog, - gint response_id, - gpointer user_data) -{ - int i; - switch(response_id) - { - case GTK_RESPONSE_OK: - for(i = 0; i < 4; i++) - { - linphone_property_box_apply(i); - } - gtk_widget_destroy(GTK_WIDGET(dialog)); - break; - case GTK_RESPONSE_APPLY: - { - GtkNotebook *notebook = GTK_NOTEBOOK(lookup_widget(get_property_box()->prop,"prop1notebook")); - i = gtk_notebook_get_current_page(notebook); - linphone_property_box_apply(i); - } - break; - case GTK_RESPONSE_CLOSE: - case GTK_RESPONSE_CANCEL: - gtk_widget_destroy(GTK_WIDGET(dialog)); - break; - } -} - -gboolean -on_property_box_closed (GtkDialog *gnomedialog, - gpointer user_data) -{ - linphone_property_box_uninit(get_property_box()); - return FALSE; -} - -void -on_use_sipinfo_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - linphone_core_set_use_info_for_dtmf(get_core(),gtk_toggle_button_get_active(togglebutton)); -} - - -void -on_guess_hostname_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - GtkWidget *hostname; - osip_from_t *from; - gboolean val=gtk_toggle_button_get_active(togglebutton); - linphone_core_set_guess_hostname(get_core(),val); - hostname=get_property_box()->sip.hostname; - from=linphone_core_get_primary_contact_parsed(get_core()); - gtk_entry_set_text(GTK_ENTRY(hostname),from->url->host); - gtk_widget_set_sensitive(hostname,!val); - osip_from_free(from); -} - -void -on_download_bw_value_changed (GtkSpinButton *spinbutton, - gpointer user_data) -{ - gdouble val=gtk_spin_button_get_value(spinbutton); - if (val==0) gtk_entry_set_text(GTK_ENTRY(spinbutton),_("Unlimited")); - linphone_core_set_download_bandwidth(get_core(),(int)val); - codec_list_update(GTK_TREE_VIEW(lookup_widget(gtk_widget_get_toplevel(GTK_WIDGET(spinbutton)),"au_codec_list"))); - codec_list_update(GTK_TREE_VIEW(lookup_widget(gtk_widget_get_toplevel(GTK_WIDGET(spinbutton)),"vid_codec_list"))); -} - -void -on_upload_bw_value_changed (GtkSpinButton *spinbutton, - gpointer user_data) -{ - gdouble val=gtk_spin_button_get_value(spinbutton); - if (val==0) gtk_entry_set_text(GTK_ENTRY(spinbutton),_("Unlimited")); - linphone_core_set_upload_bandwidth(get_core(),(int)val); - codec_list_update(GTK_TREE_VIEW(lookup_widget(gtk_widget_get_toplevel(GTK_WIDGET(spinbutton)),"au_codec_list"))); - codec_list_update(GTK_TREE_VIEW(lookup_widget(gtk_widget_get_toplevel(GTK_WIDGET(spinbutton)),"vid_codec_list"))); -} - -void -on_no_nat_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - property_box_changed(); -} - - -void -on_use_stun_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - property_box_changed(); -} - - -void -on_static_nat_toggled (GtkToggleButton *togglebutton, - gpointer user_data) -{ - property_box_changed(); -} - -void -on_stun_server_changed (GtkEditable *editable, - gpointer user_data) -{ - property_box_changed(); -} - diff --git a/linphone/gtk/propertybox.h b/linphone/gtk/propertybox.h deleted file mode 100644 index 5126a7d2d..000000000 --- a/linphone/gtk/propertybox.h +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** - propertybox.h - description - ------------------- - begin : Wed Jan 30 2002 - copyright : (C) 2002 by Simon Morlat - email : simon.morlat@linphone.org - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "interface.h" - -struct _NetSection -{ - GtkWidget *interfaces; - gint if_sel; - GtkWidget *au_port; - GtkWidget *audio_jittcomp; - GtkWidget *enable_nat; - GtkWidget *nat_label; - GtkWidget *nat_address; - GtkWidget *use_sipinfo; - GtkWidget *enable_ipv6; -}; -typedef struct _NetSection NetSection; - -void net_section_init(NetSection *sec, GtkWidget *prop); -void net_section_apply(NetSection *sec, LinphoneCore *lp); - -struct _SipSection -{ - GtkWidget *port; - GtkWidget *username; - GtkWidget *hostname; - GtkWidget *proxy_list; - GtkWidget *guess_hostname; -}; - -typedef struct _SipSection SipSection; - -void sip_section_enable_registrar(SipSection *sec, LinphoneCore *lp, gboolean state); -void sip_section_fill(SipSection *sec, LinphoneCore *lp); - -void sip_section_init(SipSection *sec, GtkWidget *prop); -void sip_section_apply(SipSection *sec, LinphoneCore *lp); - -struct _CodecSection -{ - GtkWidget *au_codec_list; - GtkWidget *vi_codec_list; - GtkWidget *codec_info; -}; - -typedef struct _CodecSection CodecSection; - -void codec_section_init(CodecSection *sec, GtkWidget *prop); -void codec_section_apply(CodecSection *sec, LinphoneCore *lc); - -struct _SoundSection -{ - GtkWidget *source_entry; - GtkWidget *autokill_button; - GtkWidget *ringfileentry; - GtkWidget *ringpreview; -}; -typedef struct _SoundSection SoundSection; - -void sound_section_init(SoundSection *sec,GtkWidget *prop); -void sound_section_apply(SoundSection *sec, LinphoneCore *lc); - -struct _LinphonePropertyBox -{ - GtkWidget *prop; - NetSection net; - SipSection sip; - CodecSection codec; - SoundSection sound; -}; - -typedef struct _LinphonePropertyBox LinphonePropertyBox; - -void linphone_property_box_init(LinphonePropertyBox *box); -//void linphone_property_box_apply(LinphonePropertyBox * box, LinphoneCore *lc, int page); -void linphone_property_box_apply(int page); -void linphone_property_box_uninit(LinphonePropertyBox *box); diff --git a/linphone/gtk/support.c b/linphone/gtk/support.c deleted file mode 100644 index 00aff2982..000000000 --- a/linphone/gtk/support.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include - -#include - -#include "support.h" - -GtkWidget* -lookup_widget (GtkWidget *widget, - const gchar *widget_name) -{ - GtkWidget *parent, *found_widget; - - for (;;) - { - if (GTK_IS_MENU (widget)) - parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); - else - parent = widget->parent; - if (!parent) - parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); - if (parent == NULL) - break; - widget = parent; - } - - found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), - widget_name); - if (!found_widget) - g_warning ("Widget not found: %s", widget_name); - return found_widget; -} - -static GList *pixmaps_directories = NULL; - -/* Use this function to set the directory containing installed pixmaps. */ -void -add_pixmap_directory (const gchar *directory) -{ - pixmaps_directories = g_list_prepend (pixmaps_directories, - g_strdup (directory)); -} - -/* This is an internally used function to find pixmap files. */ -static gchar* -find_pixmap_file (const gchar *filename) -{ - GList *elem; - - /* We step through each of the pixmaps directory to find it. */ - elem = pixmaps_directories; - while (elem) - { - gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, - G_DIR_SEPARATOR_S, filename); - if (g_file_test (pathname, G_FILE_TEST_EXISTS)) - return pathname; - g_free (pathname); - elem = elem->next; - } - return NULL; -} - -/* This is an internally used function to create pixmaps. */ -GtkWidget* -create_pixmap (GtkWidget *widget, - const gchar *filename) -{ - gchar *pathname = NULL; - GtkWidget *pixmap; - - if (!filename || !filename[0]) - return gtk_image_new (); - - pathname = find_pixmap_file (filename); - - if (!pathname) - { - g_warning (_("Couldn't find pixmap file: %s"), filename); - return gtk_image_new (); - } - - pixmap = gtk_image_new_from_file (pathname); - g_free (pathname); - return pixmap; -} - -/* This is an internally used function to create pixmaps. */ -GdkPixbuf* -create_pixbuf (const gchar *filename) -{ - gchar *pathname = NULL; - GdkPixbuf *pixbuf; - GError *error = NULL; - - if (!filename || !filename[0]) - return NULL; - - pathname = find_pixmap_file (filename); - - if (!pathname) - { - g_warning (_("Couldn't find pixmap file: %s"), filename); - return NULL; - } - - pixbuf = gdk_pixbuf_new_from_file (pathname, &error); - if (!pixbuf) - { - fprintf (stderr, "Failed to load pixbuf file: %s: %s\n", - pathname, error->message); - g_error_free (error); - } - g_free (pathname); - return pixbuf; -} - -/* This is used to set ATK action descriptions. */ -void -glade_set_atk_action_description (AtkAction *action, - const gchar *action_name, - const gchar *description) -{ - gint n_actions, i; - - n_actions = atk_action_get_n_actions (action); - for (i = 0; i < n_actions; i++) - { - if (!strcmp (atk_action_get_name (action, i), action_name)) - atk_action_set_description (action, i, description); - } -} - diff --git a/linphone/gtk/support.h b/linphone/gtk/support.h deleted file mode 100644 index a32649e53..000000000 --- a/linphone/gtk/support.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -/* - * Standard gettext macros. - */ -#ifdef ENABLE_NLS -# include -# undef _ -# define _(String) dgettext (PACKAGE, String) -# define Q_(String) g_strip_context ((String), gettext (String)) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#else -# define textdomain(String) (String) -# define gettext(String) (String) -# define dgettext(Domain,Message) (Message) -# define dcgettext(Domain,Message,Type) (Message) -# define bindtextdomain(Domain,Directory) (Domain) -# define _(String) (String) -# define Q_(String) g_strip_context ((String), (String)) -# define N_(String) (String) -#endif - - -/* - * Public Functions. - */ - -/* - * This function returns a widget in a component created by Glade. - * Call it with the toplevel widget in the component (i.e. a window/dialog), - * or alternatively any widget in the component, and the name of the widget - * you want returned. - */ -GtkWidget* lookup_widget (GtkWidget *widget, - const gchar *widget_name); - - -/* Use this function to set the directory containing installed pixmaps. */ -void add_pixmap_directory (const gchar *directory); - - -/* - * Private Functions. - */ - -/* This is used to create the pixmaps used in the interface. */ -GtkWidget* create_pixmap (GtkWidget *widget, - const gchar *filename); - -/* This is used to create the pixbufs used in the interface. */ -GdkPixbuf* create_pixbuf (const gchar *filename); - -/* This is used to set ATK action descriptions. */ -void glade_set_atk_action_description (AtkAction *action, - const gchar *action_name, - const gchar *description); - diff --git a/linphone/ipkg/.gitignore b/linphone/ipkg/.gitignore deleted file mode 100644 index bf7b0e90e..000000000 --- a/linphone/ipkg/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -Makefile.in -linphone.control diff --git a/linphone/ipkg/Makefile.am b/linphone/ipkg/Makefile.am deleted file mode 100644 index b5d762405..000000000 --- a/linphone/ipkg/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST=ipaq-config.site linphone.control glib.control libosip.control linphone.control.in diff --git a/linphone/ipkg/glib.control b/linphone/ipkg/glib.control deleted file mode 100644 index 2af6a91f4..000000000 --- a/linphone/ipkg/glib.control +++ /dev/null @@ -1,8 +0,0 @@ -Package: libglib2.2 -Section: libs -Priority: optional -Version: 2.2.2 -Architecture: arm -Maintainer: Simon Morlat -Depends: libc6 -Description: a usefull set of C routines in a portable library. diff --git a/linphone/ipkg/ipaq-config.site b/linphone/ipkg/ipaq-config.site deleted file mode 100644 index 8a320dce5..000000000 --- a/linphone/ipkg/ipaq-config.site +++ /dev/null @@ -1,89 +0,0 @@ -# config.site for configure -# iPAQ Familiar Linux TARGET - -# this config file is only suitable for the 3.2 release of the arm toolchain. - -# run with -# CONFIG_SITE=/wherever/you/store/it/ipaq-config.site ./configure -# or -# export CONFIG_SITE=/wherever/you/store/it/ipaq-config.site -# if this is going to be a whole compilation orgy - -# Modified from the one provided by Bradley D. LaRonde -# Edited by Andrej Cedilnik -# Used some of solutions by Tilman Vogel -# Ported for iPAQ Familiar by Oliver Kurth - -HOSTCC=gcc - -# Names of the cross-compilers -CC=arm-linux-gcc -CXX=arm-linux-g++ - -# The cross compiler specific options -CFLAGS="-O2 -fno-exceptions" -CXXFLAGS="-O2 -fno-exceptions" -CPPFLAGS="-O2 -fno-exceptions" -LDFLAGS="" - -# Some other programs -AR=arm-linux-ar -RANLIB=arm-linux-ranlib -NM=arm-linux-nm -ac_cv_path_NM=arm-linux-nm -ac_cv_func_setpgrp_void=yes -host=arm-linux -#prefix=/usr/mipsel-linux -x_includes=/skiff/local/arm-linux/include/X11 -x_libraries=/skiff/local/arm-linux/lib/X11 - -# These are for GNU shellutils -jm_cv_have_proc_uptime=yes -jm_cv_func_working_gnu_strftime=yes - -# Some options for ease of compiling python -# (these are left over from the agenda. Not checked for iPAQ) -ac_cv_sizeof_int=4 -ac_cv_sizeof_char=1 -ac_cv_sizeof_short=2 -ac_cv_sizeof_float=4 -ac_cv_sizeof_double=8 -ac_cv_sizeof_pthread_t=4 -ac_cv_sizeof_long=4 -ac_cv_sizeof_void_p=4 -ac_cv_sizeof_long_long=8 -ac_cv_sizeof_off_t=4 -ac_cv_sizeof_fpos_t=4 -ac_cv_sizeof_time_t=4 - -# Some other stuff nobody knows why -#bad_forward=no -#LDSHARED='mipsel-linux-gcc -msoft-float -shared' -#ac_cv_malloc_zero=nonnull - -# squeak wants this -# can't do misaligned access to doubles -ac_cv_double_align=no -# dunno what order doubles are in -ac_cv_double_order=no - -ac_cv_header_wchar_h=no - -# added by oku, for compiling glib: -glib_cv_has__inline=yes -glib_cv_has__inline__=yes -glib_cv_hasinline=yes -glib_cv_sane_realloc=yes -glib_cv_va_copy=no -glib_cv___va_copy=yes -glib_cv_va_val_copy=yes -glib_cv_rtldglobal_broken=no -glib_cv_uscore=yes -ac_cv_func_getpwuid_r=yes -glib_cv_sizeof_gmutex=24 - -#added by Simon Morlat, for compiling glib-2.2.x - -glib_cv_stack_grows=no -ac_cv_func_posix_getpwuid_r=yes -glib_cv_use_pid_surrogate=yes diff --git a/linphone/ipkg/libosip.control b/linphone/ipkg/libosip.control deleted file mode 100644 index 2da070de4..000000000 --- a/linphone/ipkg/libosip.control +++ /dev/null @@ -1,8 +0,0 @@ -Package: libosip -Section: libs -Priority: optional -Version: 0.9.7-1 -Architecture: arm -Maintainer: Simon Morlat -Depends: libc6 -Description: a SIP (RFC3261) C library. diff --git a/linphone/ipkg/linphone.control.in b/linphone/ipkg/linphone.control.in deleted file mode 100644 index 4edc99577..000000000 --- a/linphone/ipkg/linphone.control.in +++ /dev/null @@ -1,8 +0,0 @@ -Package: linphone -Section: net -Priority: optional -Version: @VERSION@-1 -Architecture: arm -Maintainer: Simon Morlat -Depends: libc6, libosip -Description: a SIP (RFC3261) internet phone. diff --git a/linphone/lpc10-1.5/.gitignore b/linphone/lpc10-1.5/.gitignore deleted file mode 100644 index fe404a3f7..000000000 --- a/linphone/lpc10-1.5/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -*.lo -.deps -.libs -Makefile -Makefile.in -liblpc10.la diff --git a/linphone/lpc10-1.5/FAQ b/linphone/lpc10-1.5/FAQ deleted file mode 100644 index 559c251b9..000000000 --- a/linphone/lpc10-1.5/FAQ +++ /dev/null @@ -1,102 +0,0 @@ - Information on 2400 bps LPC and 4800 bps CELP speech coders - for Frequently Asked Questions lists (audio-formats, comp.compression) - -The U.S. DoD's Federal-Standard-1016 based 4800 bps code excited linear -prediction voice coder version 3.2 (CELP 3.2) Fortran and C simulation -source codes are available for worldwide distribution (on DOS -diskettes, but configured to compile on Sun SPARC stations) from NTIS -and DTIC. Example input and processed speech files are included. A -Technical Information Bulletin (TIB), "Details to Assist in -Implementation of Federal Standard 1016 CELP," and the official -standard, "Federal Standard 1016, Telecommunications: Analog to -Digital Conversion of Radio Voice by 4,800 bit/second Code Excited -Linear Prediction (CELP)," are also available. - -This is available through the National Technical Information Service: - -NTIS -U.S. Department of Commerce -5285 Port Royal Road -Springfield, VA 22161 -USA -(703) 487-4650 - -The "AD" ordering number for the CELP software is AD M000 118 -(US$ 90.00) and for the TIB it's AD A256 629 (US$ 17.50). The LPC-10 -standard, described below, is FIPS Pub 137 (US$ 12.50). There is a -$3.00 shipping charge on all U.S. orders. The telephone number for -their automated system is 703-487-4650, or 703-487-4600 if you'd prefer -to talk with a real person. - -(U.S. DoD personnel and contractors can receive the package from the -Defense Technical Information Center: DTIC, Building 5, Cameron -Station, Alexandria, VA 22304-6145. Their telephone number is -703-274-7633.) - -The following articles describe the Federal-Standard-1016 4.8-kbps CELP -coder (it's unnecessary to read more than one): - -Campbell, Joseph P. Jr., Thomas E. Tremain and Vanoy C. Welch, -"The Federal Standard 1016 4800 bps CELP Voice Coder," Digital Signal -Processing, Academic Press, 1991, Vol. 1, No. 3, p. 145-155. - -Campbell, Joseph P. Jr., Thomas E. Tremain and Vanoy C. Welch, -"The DoD 4.8 kbps Standard (Proposed Federal Standard 1016)," -in Advances in Speech Coding, ed. Atal, Cuperman and Gersho, -Kluwer Academic Publishers, 1991, Chapter 12, p. 121-133. - -Campbell, Joseph P. Jr., Thomas E. Tremain and Vanoy C. Welch, "The -Proposed Federal Standard 1016 4800 bps Voice Coder: CELP," Speech -Technology Magazine, April/May 1990, p. 58-64. - - -The U.S. DoD's Federal-Standard-1015/NATO-STANAG-4198 based 2400 bps -linear prediction coder (LPC-10) was republished as a Federal -Information Processing Standards Publication 137 (FIPS Pub 137). -It is described in: - -Thomas E. Tremain, "The Government Standard Linear Predictive Coding -Algorithm: LPC-10," Speech Technology Magazine, April 1982, p. 40-49. - -There is also a section about FS-1015 in the book: -Panos E. Papamichalis, Practical Approaches to Speech Coding, -Prentice-Hall, 1987. - -The voicing classifier used in the enhanced LPC-10 (LPC-10e) is described in: -Campbell, Joseph P., Jr. and T. E. Tremain, "Voiced/Unvoiced Classification -of Speech with Applications to the U.S. Government LPC-10E Algorithm," -Proceedings of the IEEE International Conference on Acoustics, Speech, and -Signal Processing, 1986, p. 473-6. - -Copies of the official standard -"Federal Standard 1016, Telecommunications: Analog to Digital Conversion -of Radio Voice by 4,800 bit/second Code Excited Linear Prediction (CELP)" -are available for US$ 5.00 each from: - -GSA Federal Supply Service Bureau -Specification Section, Suite 8100 -470 E. L'Enfant Place, S.W. -Washington, DC 20407 -(202)755-0325 - -Realtime DSP code for FS-1015 and FS-1016 is sold by: - -John DellaMorte -DSP Software Engineering -165 Middlesex Tpk, Suite 206 -Bedford, MA 01730 -USA -1-617-275-3733 -1-617-275-4323 (fax) -dspse.bedford@channel1.com - -DSP Software Engineering's FS-1016 code can run on a DSP Research's Tiger 30 -(a PC board with a TMS320C3x and analog interface suited to development work). - -DSP Research -1095 E. Duane Ave. -Sunnyvale, CA 94086 -USA -(408)773-1042 -(408)736-3451 (fax) - diff --git a/linphone/lpc10-1.5/Makefile.am b/linphone/lpc10-1.5/Makefile.am deleted file mode 100644 index 289649bab..000000000 --- a/linphone/lpc10-1.5/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -EXTRA_DIST=README README-1.0 FAQ README.new - -noinst_LTLIBRARIES=liblpc10.la - - -liblpc10_la_SOURCES=f2clib.c lpc10.h f2c.h\ - analys.c \ - bsynz.c \ - chanwr.c \ - dcbias.c \ - decode.c \ - deemp.c \ - difmag.c \ - dyptrk.c \ - encode.c \ - energy.c \ - ham84.c \ - hp100.c \ - invert.c \ - irc2pc.c \ - ivfilt.c \ - lpcdec.c \ - lpcenc.c \ - lpcini.c \ - lpfilt.c \ - median.c \ - mload.c \ - onset.c \ - pitsyn.c \ - placea.c \ - placev.c \ - preemp.c \ - prepro.c \ - random.c \ - rcchk.c \ - synths.c \ - tbdm.c \ - voicin.c \ - vparms.c - -liblpc10_la_LIBADD=-lm - -#noinst_PROGRAMS=bitio - -#bitio_SOURCES=bitio.c lpc10_wrapper.h - -#bitio_LDADD=liblpc10.la - -AM_CFLAGS=-w diff --git a/linphone/lpc10-1.5/README b/linphone/lpc10-1.5/README deleted file mode 100644 index b31e79315..000000000 --- a/linphone/lpc10-1.5/README +++ /dev/null @@ -1,81 +0,0 @@ - U.S. Department of Defense - LPC-10 2400 bps Voice Coder - Release 1.5 - October 1997 - -(Note that this release 1.5 is not from any "official" source. It is -from Andy Fingerhut. Contact information below.) - -This package is available from: - -http://www.arl.wustl.edu/~jaf/lpc/lpc10-1.5.tar.gz - - -New in release 1.5: - -Just some minor fixes to sample applications "nuke" and "unnuke" that -caused them not to work correctly on compilers with 16 bit int's. -This was only a bug in the sample application code, not in the LPC-10 -library itself. - -NEW IN RELEASE 1.4! - -You can now compress (or decompress) multiple audio streams -"simultaneously", by alternating the compression (or decompression) of -frames for each audio stream. Only the C version supports this -feature, but who really cared whether the Fortran version supported -this or not, eh? - - -Contents: - README - This file - README-1.0 - The original README file from Release 1.0 - FAQ - Frequently Asked Questions items for LPC and CELP - lpc55 - modified Fortran code for LPC-10 Version 55 - README - summary of modifications made - README.f2c - hints on installing f2c on some machines, - and notes on the f2c invocation options used - README.jaf - hints on using the LPC-10 coder from a C application - RCS - Revision Control System directory containing - master files for all sources, showing the steps - of changes that I made to the original 1.0 sources. - lpc55-C - Hand-modified C version of code, most of - which was created by running f2c on the - Fortran code in directory lpc55 above. I'm - fairly certain that the C code from the 1.0 - release was out of date with respect to the - Fortran code, so it was not included in this - distribution. - data - Sample speech files, containing: - dam9.spd - Sample input speech file - dam9-out.spd - Speech processed by modified Fortran code. - This is identical to dam9_lpc55.spd from - release 1.0, except for 180 0 samples at the - beginning, and many samples here and there - that are off by 1, probably due to different - rounding of reals. - abtool_1.2 - Sun GUI tool for playing listening comparisons - between speech files (this is a beta version) - misc - bin - Several useful shell scripts for audio on Sun machines - README - Description of audio file formats - fortran-locals - Some files I made when determining whether local - variables in Fortran subroutines and functions - were like C "static" local variables or not. - gcc-2.6.0-bug - A program that demonstrates a bug in GCC 2.6.0 - on the Solaris 2.4 machine siesta.cs.wustl.edu. - I don't know how widespread this problem is, - but it does have an unpleasant side effect if - GCC 2.6.0 is used to compile f2c. - -See also the file README-1.0 for some other useful details. - - -Andy Fingerhut -Applied Research Laboratory <-- this line is optional if -Washington University, Campus Box 1045/Bryan 509 you have limited space -One Brookings Drive -Saint Louis, MO 63130-4899 - -jaf@arl.wustl.edu -http://www.arl.wustl.edu/~jaf/ diff --git a/linphone/lpc10-1.5/README-1.0 b/linphone/lpc10-1.5/README-1.0 deleted file mode 100644 index 7fb7871dc..000000000 --- a/linphone/lpc10-1.5/README-1.0 +++ /dev/null @@ -1,47 +0,0 @@ - U.S. Department of Defense - LPC-10 2400 bps Voice Coder - Release 1.0 - October 1993 - - -Contents: - README - This file - FAQ - Frequently Asked Questions items for LPC and CELP - lpc55 - Fortran code for LPC-10 Version 55 - lpc55-C - C code for LPC-10 - data - Sample speech files, containing: - dam9.spd - Sample input speech file - dam9_lpc55.spd - Speech processed by LPC-10 - abtool_1.2 - Sun GUI tool for playing listening comparisons - between speech files (this is a beta version) - - The distribution file has been compressed with the GNU compression -program gzip version 1.2.3, available from archives such as ftp.uu.net and -wuarchive.wustl.edu. To unpack it, use the commands: - - gunzip lpc-1.0.tar (uncompress the archive file) - tar xvf lpc-1.0.tar (extract the contents of the archive) - -(For distribution on pcfs floppy disks (IBM PC format), the file names may - not appear exactly as shown above.) - - Documentation on using the above programs is included in README files -in each directory. Documentation describing the internal operation of -LPC-10 is currently available only in hardcopy format. We will include -more extensive documentation with future releases of this package. - - All development of LPC-10 has been done in Fortran, so the Fortran -code has been written for flexible and easy use in a research environment. -The C version was translated from the Fortran to assist in porting LPC -to Digital Signal Processors (DSPs), and does not have the debugging -features or I/O flexiblility of the Fortran version. Both versions -have been tested on a Sun SPARCstation-10 running Solaris 2.2 and -SunOS 4.1.2. - - The speech files are in 16 bit linear format, sampled at 8000 Hz. There -are no headers on these files, so some manipulation may be required to -play them on your system. The following alias will play speech files on -the Sun speakerbox: - - alias play 'audioconvert -i pcm16,mono,raw,r=8k -f sun \!* | audioplay' - play dam9.spd diff --git a/linphone/lpc10-1.5/README.new b/linphone/lpc10-1.5/README.new deleted file mode 100644 index 30abe4c97..000000000 --- a/linphone/lpc10-1.5/README.new +++ /dev/null @@ -1,89 +0,0 @@ -Tue Aug 20 16:19:51 CDT 1996 -Andy Fingerhut (jaf@arl.wustl.edu) - -In release 1.4, there are quite a few hand modifications to the C code -that was automatically created from the Fortran code with f2c. They -are all summarized in change log comments at the beginning of the -changed files. All of the original files from f2c were checked in to -RCS before modification, so it is possible to see exactly what changes -were made, for the extremely curious. That precaution was also for my -benefit, in case I ever recompile the Fortran sources, and want to -make similar changes to that new C source code. - -Below is the README file for this directory included with the 1.3 -release of the LPC-10 package. A few parts of it are a little out of -date, but it is correct for the most part. - - -Sun Jul 7 15:30:31 CDT 1996 -Andy Fingerhut (jaf@arl.wustl.edu) - -To create the LPC-10 library, copy the appropriate makefile to the -proper name for easy use, e.g., for Unix, copy makefile.unx to the -file "Makefile". The file makefile.dos has been used with some -version of the 'nmake' utility that comes with the Microsoft C -compiler (the same one used for Nautilus v1.5a, which I believe -specifies Microsoft C version 7.0 or later). - -Then edit the file lpc10.h in the directory above. It should already -be set up to work properly on any Unix compiler for which "int" is 32 -bits and "short" is 16 bits, and under the Microsoft C compiler -configured so that "long" is 32 bits and "int" is 16 bits. There must -be a typedef for the two types INT32 and INT16 in that file. You -should choose types that compile to those sizes using your compiler, -because there are places in the LPC-10 code that expect INT16's to -have exactly 16 bits (at least, I *think* they must be no larger), and -INT32's to have exactly 32 bits. - - -A few notes on how these files were created -------------------------------------------- - -(This section is mostly for my benefit, so I can remember what I did. -You don't need to read it if you just want to use this package. It -might be useful to read it if you change the Fortran sources and want -to recreate a usable library of C sources. -- Andy) - -These C sources were created automatically from the Fortran sources -using f2c, for the most part. Listed below are the extra -modifications that were made after this automatic conversion. Many of -them were made so that it was not necessary to install f2c in order to -use this LPC-10 coder. - -1. - -Put all of those files that were necessary for only the coder, rather -than an application that uses the coder, into this subdirectory called -lpc10. - -2. - -Copied f2c.h from the f2c distribution into this subdirectory. Some -modifications were made to the "typedef" statements in this file, to -explicitly indicate the sizes (in bits) that different integer types -should be. The types INT32 and INT16 must be defined in a file called -lpc10.h in the directory above. Created the file f2clib.c, containing -only the functions pow_ii(), r_sign(), and i_nint() from the f2c -library. - -3. - -The f2c output originally had a file called contrl_com.c, that defined -a small structure containing a few variables that were used in many -different functions of the LPC10 code. Every file containing -functions that used it defined it as "extern", while contrl_com.c -actually allocated storage for the structure. Bill Dorsey, one of the -lead developers of Nautilus, said that the Microsoft C compiler had -problems either compiling this file, or linking it with all of the -other compiled files, so he just eliminated that file and removed the -"extern" keyword from the one of the files that declared it that way. -The file chosen (arbitrarily) was analys.c. - -4. - -Copied the makefiles for Unix and Microsoft C from the Nautilus v1.5a -distribution into the lpc10 directory. Modified them to take out -references to Nautilus. These makefiles don't create an executable, -but a library of compiled functions called liblpc10.a (Unix) or -LPC10.LIB (DOS). This library can be used when linking an executable -that calls the functions lpcini_(), lpcenc_(), and lpcdec_(). diff --git a/linphone/lpc10-1.5/analys.c b/linphone/lpc10-1.5/analys.c deleted file mode 100644 index 6e8ece4ab..000000000 --- a/linphone/lpc10-1.5/analys.c +++ /dev/null @@ -1,617 +0,0 @@ -/* - -$Log: analys.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:13 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:16:01 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:29:08 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int analys_(real *speech, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_encoder_state *st); -/* comlen contrl_ 12 */ -/*:ref: preemp_ 14 5 6 6 4 6 6 */ -/*:ref: onset_ 14 7 6 4 4 4 4 4 4 */ -/*:ref: placev_ 14 11 4 4 4 4 4 4 4 4 4 4 4 */ -/*:ref: lpfilt_ 14 4 6 6 4 4 */ -/*:ref: ivfilt_ 14 5 6 6 4 4 6 */ -/*:ref: tbdm_ 14 8 6 4 4 4 6 4 4 4 */ -/*:ref: voicin_ 14 12 4 6 6 4 4 6 6 4 6 4 4 4 */ -/*:ref: dyptrk_ 14 6 6 4 4 4 4 4 */ -/*:ref: placea_ 14 9 4 4 4 4 4 4 4 4 4 */ -/*:ref: dcbias_ 14 3 4 6 6 */ -/*:ref: energy_ 14 3 4 6 6 */ -/*:ref: mload_ 14 6 4 4 4 6 6 6 */ -/*:ref: invert_ 14 4 4 6 6 6 */ -/*:ref: rcchk_ 14 3 4 6 6 */ -/*:ref: initonset_ 14 0 */ -/*:ref: initvoicin_ 14 0 */ -/*:ref: initdyptrk_ 14 0 */ -/* Rerunning f2c -P may change prototypes or declarations. */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Common Block Declarations */ - -extern struct { - integer order, lframe; - logical corrp; -} contrl_; - -#define contrl_1 contrl_ - -/* Table of constant values */ - -static integer c__10 = 10; -static integer c__181 = 181; -static integer c__720 = 720; -static integer c__3 = 3; -static integer c__90 = 90; -static integer c__156 = 156; -static integer c__307 = 307; -static integer c__462 = 462; -static integer c__312 = 312; -static integer c__60 = 60; -static integer c__1 = 1; - -/* ****************************************************************** */ - -/* ANALYS Version 55 */ - -/* $Log: analys.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:13 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:16:01 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:29:08 jaf - * Initial revision - * */ -/* Revision 1.9 1996/05/23 19:41:07 jaf */ -/* Commented out some unnecessary lines that were reading uninitialized */ -/* values. */ - -/* Revision 1.8 1996/03/27 23:57:55 jaf */ -/* Added some comments about which indices of the local buffers INBUF, */ -/* LPBUF, etc., get read or modified by some of the subroutine calls. I */ -/* just did this while trying to figure out the discrepancy between the */ -/* embedded code compiled with all local variables implicitly saved, and */ -/* without. */ - -/* I added some debugging write statements in hopes of finding a problem. */ -/* None of them ever printed anything while running with the long input */ -/* speech file dam9.spd provided in the distribution. */ - -/* Revision 1.7 1996/03/27 18:06:20 jaf */ -/* Commented out access to MAXOSP, which is just a debugging variable */ -/* that was defined in the COMMON block CONTRL in contrl.fh. */ - -/* Revision 1.6 1996/03/26 19:31:33 jaf */ -/* Commented out trace statements. */ - -/* Revision 1.5 1996/03/21 15:19:35 jaf */ -/* Added comments for ENTRY PITDEC. */ - -/* Revision 1.4 1996/03/19 20:54:27 jaf */ -/* Added a line to INITANALYS. See comments there. */ - -/* Revision 1.3 1996/03/19 20:52:49 jaf */ -/* Rearranged the order of the local variables quite a bit, to separate */ -/* them into groups of "constants", "locals that don't need to be saved */ -/* from one call to the next", and "local that do need to be saved from */ -/* one call to the next". */ - -/* Several locals in the last set should have been given initial values, */ -/* but weren't. I gave them all initial values of 0. */ - -/* Added a separate ENTRY INITANALYS that initializes all local state */ -/* that should be, and also calls the corresponding entries of the */ -/* subroutines called by ANALYS that also have local state. */ - -/* There used to be DATA statements in ANALYS. I got rid of most of */ -/* them, and added a local logical variable FIRST that calls the entry */ -/* INITANALYS on the first call to ANALYS. This is just so that one need */ -/* not remember to call INITANALYS first in order for the state to be */ -/* initialized. */ - -/* Revision 1.2 1996/03/11 23:29:32 jaf */ -/* Added several comments with my own personal questions about the */ -/* Fortran 77 meaning of the parameters passed to the subroutine PREEMP. */ - -/* Revision 1.1 1996/02/07 14:42:29 jaf */ -/* Initial revision */ - - -/* ****************************************************************** */ - -/* SUBROUTINE ANALYS */ - -/* Input: */ -/* SPEECH */ -/* Indices 1 through LFRAME read. */ -/* Output: */ -/* VOICE */ -/* Indices 1 through 2 written. */ -/* PITCH */ -/* Written in subroutine DYPTRK, and then perhaps read and written */ -/* some more. */ -/* RMS */ -/* Written. */ -/* RC */ -/* Indices 1 through ORDER written (ORDER defined in contrl.fh). */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this filter, or */ -/* reinitialize its state for any other reason, call the ENTRY */ -/* INITANALYS. */ - - -/* ENTRY PITDEC */ - -/* Input: */ -/* PITCH - Encoded pitch index */ -/* Output: */ -/* PTAU - Decoded pitch period */ - -/* This entry has no local state. It accesses a "constant" array */ -/* declared in ANALYS. */ - -/* Subroutine */ int analys_(real *speech, integer *voice, integer - *pitch, real *rms, real *rc, struct lpc10_encoder_state *st) -{ - /* Initialized data */ - - static integer tau[60] = { 20,21,22,23,24,25,26,27,28,29,30,31,32,33,34, - 35,36,37,38,39,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72, - 74,76,78,80,84,88,92,96,100,104,108,112,116,120,124,128,132,136, - 140,144,148,152,156 }; - static integer buflim[4] = { 181,720,25,720 }; - static real precoef = .9375f; - - /* System generated locals */ - integer i__1; - - /* Local variables */ - real amdf[60]; - integer half; - real abuf[156]; - real *bias; - extern /* Subroutine */ int tbdm_(real *, integer *, integer *, integer *, - real *, integer *, integer *, integer *); - integer *awin; - integer midx, ewin[6] /* was [2][3] */; - real ivrc[2], temp; - real *zpre; - integer *vwin; - integer i__, j, lanal; - extern /* Subroutine */ int rcchk_(integer *, real *, real *), mload_( - integer *, integer *, integer *, real *, real *, real *); - real *inbuf, *pebuf; - real *lpbuf, *ivbuf; - real *rcbuf; - integer *osbuf; - extern /* Subroutine */ int onset_(real *, integer *, integer *, integer * - , integer *, integer *, integer *, struct lpc10_encoder_state *); - integer *osptr; - extern /* Subroutine */ placea_(integer *, integer * - , integer *, integer *, integer *, integer *, integer *, integer * - , integer *), dcbias_(integer *, real *, real *), placev_(integer - *, integer *, integer *, integer *, integer *, integer *, integer - *, integer *, integer *, integer *, integer *); - integer ipitch; - integer *obound; - extern /* Subroutine */ int preemp_(real *, real *, integer *, real *, - real *), voicin_(integer *, real *, real *, integer *, integer *, - real *, real *, integer *, real *, integer *, integer *, integer *, - struct lpc10_encoder_state *); - integer *voibuf; - integer mintau; - real *rmsbuf; - extern /* Subroutine */ int lpfilt_(real *, real *, integer *, integer *), - ivfilt_(real *, real *, integer *, integer *, real *), energy_( - integer *, real *, real *), invert_(integer *, real *, real *, - real *); - integer minptr, maxptr; - extern /* Subroutine */ int dyptrk_(real *, integer *, integer *, integer - *, integer *, integer *, struct lpc10_encoder_state *); - real phi[100] /* was [10][10] */, psi[10]; - -/* $Log: analys.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:13 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:16:01 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:29:08 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Arguments to ANALYS */ -/* $Log: analys.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:13 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:16:01 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:29:08 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:05:55 jaf */ -/* Commented out the common block variables that are not needed by the */ -/* embedded version. */ - -/* Revision 1.2 1996/03/26 19:34:50 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:44:09 jaf */ -/* Initial revision */ - -/* LPC Processing control variables: */ - -/* *** Read-only: initialized in setup */ - -/* Files for Speech, Parameter, and Bitstream Input & Output, */ -/* and message and debug outputs. */ - -/* Here are the only files which use these variables: */ - -/* lpcsim.f setup.f trans.f error.f vqsetup.f */ - -/* Many files which use fdebug are not listed, since it is only used in */ -/* those other files conditionally, to print trace statements. */ -/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* LPC order, Frame size, Quantization rate, Bits per frame, */ -/* Error correction */ -/* Subroutine SETUP is the only place where order is assigned a value, */ -/* and that value is 10. It could increase efficiency 1% or so to */ -/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as -*/ -/* a variable in a COMMON block, since it is used in many places in the */ -/* core of the coding and decoding routines. Actually, I take that back. -*/ -/* At least when compiling with f2c, the upper bound of DO loops is */ -/* stored in a local variable before the DO loop begins, and then that is -*/ -/* compared against on each iteration. */ -/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ -/* Similarly for quant, which is given a value of 2400 in SETUP. quant */ -/* is used in only a few places, and never in the core coding and */ -/* decoding routines, so it could be eliminated entirely. */ -/* nbits is similar to quant, and is given a value of 54 in SETUP. */ -/* corrp is given a value of .TRUE. in SETUP, and is only used in the */ -/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ -/* coder significantly whether it is .TRUE. or .FALSE., or whether it is -*/ -/* a constant or a variable, since it is only examined once per frame. */ -/* Leaving it as a variable that is set to .TRUE. seems like a good */ -/* idea, since it does enable some error-correction capability for */ -/* unvoiced frames, with no change in the coding rate, and no noticeable -*/ -/* quality difference in the decoded speech. */ -/* integer quant, nbits */ -/* *** Read/write: variables for debugging, not needed for LPC algorithm -*/ - -/* Current frame, Unstable frames, Output clip count, Max onset buffer, -*/ -/* Debug listing detail level, Line count on listing page */ - -/* nframe is not needed for an embedded LPC10 at all. */ -/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ -/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ -/* an application, I would recommend removing the call to ERROR in RCCHK, -*/ -/* and remove ERROR and nunsfm completely. */ -/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in -*/ -/* sread.f. When LPC10 is embedded into an application, one might want */ -/* to cause it to be incremented in a routine that takes the output of */ -/* SYNTHS and sends it to an audio device. It could be optionally */ -/* displayed, for those that might want to know what it is. */ -/* maxosp is never initialized to 0 in SETUP, although it probably should -*/ -/* be, and it is updated in subroutine ANALYS. I doubt that its value */ -/* would be of much interest to an application in which LPC10 is */ -/* embedded. */ -/* listl and lincnt are not needed for an embedded LPC10 at all. */ -/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* common /contrl/ quant, nbits */ -/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* Arguments to entry PITDEC (below) */ -/* Parameters/constants */ -/* Constants */ -/* NF = Number of frames */ -/* AF = Frame in which analysis is done */ -/* OSLEN = Length of the onset buffer */ -/* LTAU = Number of pitch lags */ -/* SBUFL, SBUFH = Start and end index of speech buffers */ -/* LBUFL, LBUFH = Start and end index of LPF speech buffer */ -/* MINWIN, MAXWIN = Min and Max length of voicing (and analysis) windows -*/ -/* PWLEN, PWINH, PWINL = Length, upper and lower limits of pitch window - */ -/* DVWINL, DVWINH = Default lower and upper limits of voicing window */ -/* The tables TAU and BUFLIM, and the variable PRECOEF, are not */ -/* Fortran PARAMETER's, but they are initialized with DATA */ -/* statements, and never modified. Thus, they need not have SAVE */ -/* statements for them to keep their values from one invocation to -*/ -/* the next. */ -/* Local variables that need not be saved */ -/* Local state */ -/* Data Buffers */ -/* INBUF Raw speech (with DC bias removed each frame) */ -/* PEBUF Preemphasized speech */ -/* LPBUF Low pass speech buffer */ -/* IVBUF Inverse filtered speech */ -/* OSBUF Indexes of onsets in speech buffers */ -/* VWIN Voicing window indices */ -/* AWIN Analysis window indices */ -/* EWIN Energy window indices */ -/* VOIBUF Voicing decisions on windows in VWIN */ -/* RMSBUF RMS energy */ -/* RCBUF Reflection Coefficients */ - -/* Pitch is handled separately from the above parameters. */ -/* The following variables deal with pitch: */ -/* MIDX Encoded initial pitch estimate for analysis frame */ -/* IPITCH Initial pitch computed for frame AF (decoded from MIDX) */ -/* PITCH The encoded pitch value (index into TAU) for the present */ -/* frame (delayed and smoothed by Dyptrack) */ - /* Parameter adjustments */ - if (speech) { - --speech; - } - if (voice) { - --voice; - } - if (rc) { - --rc; - } - - /* Function Body */ - -/* Calculations are done on future frame due to requirements */ -/* of the pitch tracker. Delay RMS and RC's 2 frames to give */ -/* current frame parameters on return. */ -/* Update all buffers */ - - inbuf = &(st->inbuf[0]); - pebuf = &(st->pebuf[0]); - lpbuf = &(st->lpbuf[0]); - ivbuf = &(st->ivbuf[0]); - bias = &(st->bias); - osbuf = &(st->osbuf[0]); - osptr = &(st->osptr); - obound = &(st->obound[0]); - vwin = &(st->vwin[0]); - awin = &(st->awin[0]); - voibuf = &(st->voibuf[0]); - rmsbuf = &(st->rmsbuf[0]); - rcbuf = &(st->rcbuf[0]); - zpre = &(st->zpre); - - i__1 = 720 - contrl_1.lframe; - for (i__ = 181; i__ <= i__1; ++i__) { - inbuf[i__ - 181] = inbuf[contrl_1.lframe + i__ - 181]; - pebuf[i__ - 181] = pebuf[contrl_1.lframe + i__ - 181]; - } - i__1 = 540 - contrl_1.lframe; - for (i__ = 229; i__ <= i__1; ++i__) { - ivbuf[i__ - 229] = ivbuf[contrl_1.lframe + i__ - 229]; - } - i__1 = 720 - contrl_1.lframe; - for (i__ = 25; i__ <= i__1; ++i__) { - lpbuf[i__ - 25] = lpbuf[contrl_1.lframe + i__ - 25]; - } - j = 1; - i__1 = (*osptr) - 1; - for (i__ = 1; i__ <= i__1; ++i__) { - if (osbuf[i__ - 1] > contrl_1.lframe) { - osbuf[j - 1] = osbuf[i__ - 1] - contrl_1.lframe; - ++j; - } - } - *osptr = j; - voibuf[0] = voibuf[2]; - voibuf[1] = voibuf[3]; - for (i__ = 1; i__ <= 2; ++i__) { - vwin[(i__ << 1) - 2] = vwin[(i__ + 1 << 1) - 2] - contrl_1.lframe; - vwin[(i__ << 1) - 1] = vwin[(i__ + 1 << 1) - 1] - contrl_1.lframe; - awin[(i__ << 1) - 2] = awin[(i__ + 1 << 1) - 2] - contrl_1.lframe; - awin[(i__ << 1) - 1] = awin[(i__ + 1 << 1) - 1] - contrl_1.lframe; -/* EWIN(*,J) is unused for J .NE. AF, so the following shift is -*/ -/* unnecessary. It also causes error messages when the C versio -n */ -/* of the code created from this by f2c is run with Purify. It -*/ -/* correctly complains that uninitialized memory is being read. -*/ -/* EWIN(1,I) = EWIN(1,I+1) - LFRAME */ -/* EWIN(2,I) = EWIN(2,I+1) - LFRAME */ - obound[i__ - 1] = obound[i__]; - voibuf[i__ * 2] = voibuf[(i__ + 1) * 2]; - voibuf[(i__ << 1) + 1] = voibuf[(i__ + 1 << 1) + 1]; - rmsbuf[i__ - 1] = rmsbuf[i__]; - i__1 = contrl_1.order; - for (j = 1; j <= i__1; ++j) { - rcbuf[j + i__ * 10 - 11] = rcbuf[j + (i__ + 1) * 10 - 11]; - } - } -/* Copy input speech, scale to sign+12 bit integers */ -/* Remove long term DC bias. */ -/* If the average value in the frame was over 1/4096 (after current -*/ -/* BIAS correction), then subtract that much more from samples in */ -/* next frame. If the average value in the frame was under */ -/* -1/4096, add 1/4096 more to samples in next frame. In all other -*/ -/* cases, keep BIAS the same. */ - temp = 0.f; - i__1 = contrl_1.lframe; - for (i__ = 1; i__ <= i__1; ++i__) { - inbuf[720 - contrl_1.lframe + i__ - 181] = speech[i__] * 4096.f - - (*bias); - temp += inbuf[720 - contrl_1.lframe + i__ - 181]; - } - if (temp > (real) contrl_1.lframe) { - *bias += 1; - } - if (temp < (real) (-contrl_1.lframe)) { - *bias += -1; - } -/* Place Voicing Window */ - i__ = 721 - contrl_1.lframe; - preemp_(&inbuf[i__ - 181], &pebuf[i__ - 181], &contrl_1.lframe, &precoef, - zpre); - onset_(pebuf, osbuf, osptr, &c__10, &c__181, &c__720, &contrl_1.lframe, st); - -/* MAXOSP is just a debugging variable. */ - -/* MAXOSP = MAX( MAXOSP, OSPTR ) */ - - placev_(osbuf, osptr, &c__10, &obound[2], vwin, &c__3, &contrl_1.lframe, - &c__90, &c__156, &c__307, &c__462); -/* The Pitch Extraction algorithm estimates the pitch for a frame -*/ -/* of speech by locating the minimum of the average magnitude difference - */ -/* function (AMDF). The AMDF operates on low-pass, inverse filtered */ -/* speech. (The low-pass filter is an 800 Hz, 19 tap, equiripple, FIR -*/ -/* filter and the inverse filter is a 2nd-order LPC filter.) The pitch -*/ -/* estimate is later refined by dynamic programming (DYPTRK). However, -*/ -/* since some of DYPTRK's parameters are a function of the voicing */ -/* decisions, a voicing decision must precede the final pitch estimation. -*/ -/* See subroutines LPFILT, IVFILT, and TBDM. */ -/* LPFILT reads indices LBUFH-LFRAME-29 = 511 through LBUFH = 720 */ -/* of INBUF, and writes indices LBUFH+1-LFRAME = 541 through LBUFH -*/ -/* = 720 of LPBUF. */ - lpfilt_(&inbuf[228], &lpbuf[384], &c__312, &contrl_1.lframe); -/* IVFILT reads indices (PWINH-LFRAME-7) = 353 through PWINH = 540 -*/ -/* of LPBUF, and writes indices (PWINH-LFRAME+1) = 361 through */ -/* PWINH = 540 of IVBUF. */ - ivfilt_(&lpbuf[204], ivbuf, &c__312, &contrl_1.lframe, ivrc); -/* TBDM reads indices PWINL = 229 through */ -/* (PWINL-1)+MAXWIN+(TAU(LTAU)-TAU(1))/2 = 452 of IVBUF, and writes -*/ -/* indices 1 through LTAU = 60 of AMDF. */ - tbdm_(ivbuf, &c__156, tau, &c__60, amdf, &minptr, &maxptr, &mintau); -/* Voicing decisions are made for each half frame of input speech. -*/ -/* An initial voicing classification is made for each half of the */ -/* analysis frame, and the voicing decisions for the present frame */ -/* are finalized. See subroutine VOICIN. */ -/* The voicing detector (VOICIN) classifies the input signal as */ -/* unvoiced (including silence) or voiced using the AMDF windowed */ -/* maximum-to-minimum ratio, the zero crossing rate, energy measures, */ -/* reflection coefficients, and prediction gains. */ -/* The pitch and voicing rules apply smoothing and isolated */ -/* corrections to the pitch and voicing estimates and, in the process, -*/ -/* introduce two frames of delay into the corrected pitch estimates and -*/ -/* voicing decisions. */ - for (half = 1; half <= 2; ++half) { - voicin_(&vwin[4], inbuf, lpbuf, buflim, &half, &amdf[minptr - 1], & - amdf[maxptr - 1], &mintau, ivrc, obound, voibuf, &c__3, st); - } -/* Find the minimum cost pitch decision over several frames */ -/* given the current voicing decision and the AMDF array */ - dyptrk_(amdf, &c__60, &minptr, &voibuf[7], pitch, &midx, st); - ipitch = tau[midx - 1]; -/* Place spectrum analysis and energy windows */ - placea_(&ipitch, voibuf, &obound[2], &c__3, vwin, awin, ewin, & - contrl_1.lframe, &c__156); -/* Remove short term DC bias over the analysis window, Put result in ABUF -*/ - lanal = awin[5] + 1 - awin[4]; - dcbias_(&lanal, &pebuf[awin[4] - 181], abuf); -/* ABUF(1:LANAL) is now defined. It is equal to */ -/* PEBUF(AWIN(1,AF):AWIN(2,AF)) corrected for short term DC bias. */ -/* Compute RMS over integer number of pitch periods within the */ -/* analysis window. */ -/* Note that in a hardware implementation this computation may be */ -/* simplified by using diagonal elements of PHI computed by MLOAD. */ - i__1 = ewin[5] - ewin[4] + 1; - energy_(&i__1, &abuf[ewin[4] - awin[4]], &rmsbuf[2]); -/* Matrix load and invert, check RC's for stability */ - mload_(&contrl_1.order, &c__1, &lanal, abuf, phi, psi); - invert_(&contrl_1.order, phi, psi, &rcbuf[20]); - rcchk_(&contrl_1.order, &rcbuf[10], &rcbuf[20]); -/* Set return parameters */ - voice[1] = voibuf[2]; - voice[2] = voibuf[3]; - *rms = rmsbuf[0]; - i__1 = contrl_1.order; - for (i__ = 1; i__ <= i__1; ++i__) { - rc[i__] = rcbuf[i__ - 1]; - } - return 0; -} /* analys_ */ diff --git a/linphone/lpc10-1.5/bitio.c b/linphone/lpc10-1.5/bitio.c deleted file mode 100644 index 86c38f0c9..000000000 --- a/linphone/lpc10-1.5/bitio.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "lpc10_wrapper.c" -#include - - - -int main() -{ - FILE *input; - int i; - unsigned char buffer[10]; - INT32 bits[54]; - - input=fopen("/tmp/dam9.bits","r"); - if (input==NULL) printf("error opening file\n"); - fread(buffer,7,1,input); - read_bits(buffer,bits,54); - for (i=0;i<54;i++) printf("%i ",bits[i]); - fclose(input); - return(0); -} \ No newline at end of file diff --git a/linphone/lpc10-1.5/bsynz.c b/linphone/lpc10-1.5/bsynz.c deleted file mode 100644 index 4cec9d14e..000000000 --- a/linphone/lpc10-1.5/bsynz.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - -$Log: bsynz.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:18:55 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:58 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int bsynz_(real *coef, integer *ip, integer *iv, real *sout, real *rms, real *ratio, real *g2pass, struct lpc10_decoder_state *st); -/* comlen contrl_ 12 */ -/*:ref: random_ 4 0 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Common Block Declarations */ - -extern struct { - integer order, lframe; - logical corrp; -} contrl_; - -#define contrl_1 contrl_ - -/* ***************************************************************** */ - -/* BSYNZ Version 54 */ - -/* $Log: bsynz.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:18:55 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:58 jaf - * Initial revision - * */ -/* Revision 1.4 1996/03/27 18:11:22 jaf */ -/* Changed the range of NOISE printed out in the debugging statements, */ -/* even though they are commented out. I didn't discover this until I */ -/* tried comparing two different versions of the LPC-10 coder, each with */ -/* full tracing enabled. */ - -/* Revision 1.3 1996/03/26 19:33:23 jaf */ -/* Commented out trace statements. */ - -/* Revision 1.2 1996/03/20 17:12:54 jaf */ -/* Added comments about which indices of array arguments are read or */ -/* written. */ - -/* Rearranged local variable declarations to indicate which need to be */ -/* saved from one invocation to the next. Added entry INITBSYNZ to */ -/* reinitialize the local state variables, if desired. */ - -/* Revision 1.1 1996/02/07 14:43:15 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* Synthesize One Pitch Epoch */ - -/* Input: */ -/* COEF - Predictor coefficients */ -/* Indices 1 through ORDER read. */ -/* IP - Pitch period (number of samples to synthesize) */ -/* IV - Voicing for the current epoch */ -/* RMS - Energy for the current epoch */ -/* RATIO - Energy slope for plosives */ -/* G2PASS- Sharpening factor for 2 pass synthesis */ -/* Output: */ -/* SOUT - Synthesized speech */ -/* Indices 1 through IP written. */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this filter, or */ -/* reinitialize its state for any other reason, call the ENTRY */ -/* INITBSYNZ. */ - -/* Subroutine */ int bsynz_(real *coef, integer *ip, integer *iv, - real *sout, real *rms, real *ratio, real *g2pass, - struct lpc10_decoder_state *st) -{ - /* Initialized data */ - - integer *ipo; - real *rmso; - static integer kexc[25] = { 8,-16,26,-48,86,-162,294,-502,718,-728,184, - 672,-610,-672,184,728,718,502,294,162,86,48,26,16,8 }; - real *exc; - real *exc2; - real *lpi1; - real *lpi2; - real *lpi3; - real *hpi1; - real *hpi2; - real *hpi3; - - /* System generated locals */ - integer i__1, i__2; - real r__1, r__2; - - /* Builtin functions */ - double sqrt(doublereal); - - /* Local variables */ - real gain, xssq; - integer i__, j, k; - real noise[166], pulse; - integer px; - real sscale; - extern integer random_(struct lpc10_decoder_state *); - real xy, sum, ssq; - real lpi0, hpi0; - -/* $Log: bsynz.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:18:55 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:58 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Arguments */ -/* $Log: bsynz.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:18:55 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:58 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:05:55 jaf */ -/* Commented out the common block variables that are not needed by the */ -/* embedded version. */ - -/* Revision 1.2 1996/03/26 19:34:50 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:44:09 jaf */ -/* Initial revision */ - -/* LPC Processing control variables: */ - -/* *** Read-only: initialized in setup */ - -/* Files for Speech, Parameter, and Bitstream Input & Output, */ -/* and message and debug outputs. */ - -/* Here are the only files which use these variables: */ - -/* lpcsim.f setup.f trans.f error.f vqsetup.f */ - -/* Many files which use fdebug are not listed, since it is only used in */ -/* those other files conditionally, to print trace statements. */ -/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* LPC order, Frame size, Quantization rate, Bits per frame, */ -/* Error correction */ -/* Subroutine SETUP is the only place where order is assigned a value, */ -/* and that value is 10. It could increase efficiency 1% or so to */ -/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as -*/ -/* a variable in a COMMON block, since it is used in many places in the */ -/* core of the coding and decoding routines. Actually, I take that back. -*/ -/* At least when compiling with f2c, the upper bound of DO loops is */ -/* stored in a local variable before the DO loop begins, and then that is -*/ -/* compared against on each iteration. */ -/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ -/* Similarly for quant, which is given a value of 2400 in SETUP. quant */ -/* is used in only a few places, and never in the core coding and */ -/* decoding routines, so it could be eliminated entirely. */ -/* nbits is similar to quant, and is given a value of 54 in SETUP. */ -/* corrp is given a value of .TRUE. in SETUP, and is only used in the */ -/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ -/* coder significantly whether it is .TRUE. or .FALSE., or whether it is -*/ -/* a constant or a variable, since it is only examined once per frame. */ -/* Leaving it as a variable that is set to .TRUE. seems like a good */ -/* idea, since it does enable some error-correction capability for */ -/* unvoiced frames, with no change in the coding rate, and no noticeable -*/ -/* quality difference in the decoded speech. */ -/* integer quant, nbits */ -/* *** Read/write: variables for debugging, not needed for LPC algorithm -*/ - -/* Current frame, Unstable frames, Output clip count, Max onset buffer, -*/ -/* Debug listing detail level, Line count on listing page */ - -/* nframe is not needed for an embedded LPC10 at all. */ -/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ -/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ -/* an application, I would recommend removing the call to ERROR in RCCHK, -*/ -/* and remove ERROR and nunsfm completely. */ -/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in -*/ -/* sread.f. When LPC10 is embedded into an application, one might want */ -/* to cause it to be incremented in a routine that takes the output of */ -/* SYNTHS and sends it to an audio device. It could be optionally */ -/* displayed, for those that might want to know what it is. */ -/* maxosp is never initialized to 0 in SETUP, although it probably should -*/ -/* be, and it is updated in subroutine ANALYS. I doubt that its value */ -/* would be of much interest to an application in which LPC10 is */ -/* embedded. */ -/* listl and lincnt are not needed for an embedded LPC10 at all. */ -/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* common /contrl/ quant, nbits */ -/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* Function return value definitions */ -/* Parameters/constants */ -/* KEXC is not a Fortran PARAMETER, but it is an array initialized -*/ -/* with a DATA statement that is never modified. */ -/* Local variables that need not be saved */ -/* NOISE is declared with range (1:MAXPIT+MAXORD), but only indices -*/ -/* ORDER+1 through ORDER+IP are ever used, and I think that IP */ -/* .LE. MAXPIT. Why not declare it to be in the range (1:MAXPIT) */ -/* and use that range? */ -/* Local state */ -/* I believe that only indices 1 through ORDER of EXC need to be */ -/* saved from one invocation to the next, but we may as well save */ -/* the whole array. */ -/* None of these local variables were given initial values in the */ -/* original code. I'm guessing that 0 is a reasonable initial */ -/* value for all of them. */ - /* Parameter adjustments */ - if (coef) { - --coef; - } - if (sout) { - --sout; - } - - /* Function Body */ - ipo = &(st->ipo); - exc = &(st->exc[0]); - exc2 = &(st->exc2[0]); - lpi1 = &(st->lpi1); - lpi2 = &(st->lpi2); - lpi3 = &(st->lpi3); - hpi1 = &(st->hpi1); - hpi2 = &(st->hpi2); - hpi3 = &(st->hpi3); - rmso = &(st->rmso_bsynz); - -/* MAXPIT+MAXORD=166 */ -/* Calculate history scale factor XY and scale filter state */ -/* Computing MIN */ - r__1 = *rmso / (*rms + 1e-6f); - xy = min(r__1,8.f); - *rmso = *rms; - i__1 = contrl_1.order; - for (i__ = 1; i__ <= i__1; ++i__) { - exc2[i__ - 1] = exc2[*ipo + i__ - 1] * xy; - } - *ipo = *ip; - if (*iv == 0) { -/* Generate white noise for unvoiced */ - i__1 = *ip; - for (i__ = 1; i__ <= i__1; ++i__) { - exc[contrl_1.order + i__ - 1] = (real) (random_(st) / 64); - } -/* Impulse doublet excitation for plosives */ -/* (RANDOM()+32768) is in the range 0 to 2**16-1. Therefore the - */ -/* following expression should be evaluated using integers with -at */ -/* least 32 bits (16 isn't enough), and PX should be in the rang -e */ -/* ORDER+1+0 through ORDER+1+(IP-2) .EQ. ORDER+IP-1. */ - px = (random_(st) + 32768) * (*ip - 1) / 65536 + contrl_1.order + 1; - r__1 = *ratio / 4 * 1.f; - pulse = r__1 * 342; - if (pulse > 2e3f) { - pulse = 2e3f; - } - exc[px - 1] += pulse; - exc[px] -= pulse; -/* Load voiced excitation */ - } else { - sscale = sqrt((real) (*ip)) / 6.928f; - i__1 = *ip; - for (i__ = 1; i__ <= i__1; ++i__) { - exc[contrl_1.order + i__ - 1] = 0.f; - if (i__ <= 25) { - exc[contrl_1.order + i__ - 1] = sscale * kexc[i__ - 1]; - } - lpi0 = exc[contrl_1.order + i__ - 1]; - r__2 = exc[contrl_1.order + i__ - 1] * .125f + *lpi1 * .75f; - r__1 = r__2 + *lpi2 * .125f; - exc[contrl_1.order + i__ - 1] = r__1 + *lpi3 * 0.f; - *lpi3 = *lpi2; - *lpi2 = *lpi1; - *lpi1 = lpi0; - } - i__1 = *ip; - for (i__ = 1; i__ <= i__1; ++i__) { - noise[contrl_1.order + i__ - 1] = random_(st) * 1.f / 64; - hpi0 = noise[contrl_1.order + i__ - 1]; - r__2 = noise[contrl_1.order + i__ - 1] * -.125f + *hpi1 * .25f; - r__1 = r__2 + *hpi2 * -.125f; - noise[contrl_1.order + i__ - 1] = r__1 + *hpi3 * 0.f; - *hpi3 = *hpi2; - *hpi2 = *hpi1; - *hpi1 = hpi0; - } - i__1 = *ip; - for (i__ = 1; i__ <= i__1; ++i__) { - exc[contrl_1.order + i__ - 1] += noise[contrl_1.order + i__ - 1]; - } - } -/* Synthesis filters: */ -/* Modify the excitation with all-zero filter 1 + G*SUM */ - xssq = 0.f; - i__1 = *ip; - for (i__ = 1; i__ <= i__1; ++i__) { - k = contrl_1.order + i__; - sum = 0.f; - i__2 = contrl_1.order; - for (j = 1; j <= i__2; ++j) { - sum += coef[j] * exc[k - j - 1]; - } - sum *= *g2pass; - exc2[k - 1] = sum + exc[k - 1]; - } -/* Synthesize using the all pole filter 1 / (1 - SUM) */ - i__1 = *ip; - for (i__ = 1; i__ <= i__1; ++i__) { - k = contrl_1.order + i__; - sum = 0.f; - i__2 = contrl_1.order; - for (j = 1; j <= i__2; ++j) { - sum += coef[j] * exc2[k - j - 1]; - } - exc2[k - 1] = sum + exc2[k - 1]; - xssq += exc2[k - 1] * exc2[k - 1]; - } -/* Save filter history for next epoch */ - i__1 = contrl_1.order; - for (i__ = 1; i__ <= i__1; ++i__) { - exc[i__ - 1] = exc[*ip + i__ - 1]; - exc2[i__ - 1] = exc2[*ip + i__ - 1]; - } -/* Apply gain to match RMS */ - r__1 = *rms * *rms; - ssq = r__1 * *ip; - gain = sqrt(ssq / xssq); - i__1 = *ip; - for (i__ = 1; i__ <= i__1; ++i__) { - sout[i__] = gain * exc2[contrl_1.order + i__ - 1]; - } - return 0; -} /* bsynz_ */ diff --git a/linphone/lpc10-1.5/chanwr.c b/linphone/lpc10-1.5/chanwr.c deleted file mode 100644 index 7a2712ec3..000000000 --- a/linphone/lpc10-1.5/chanwr.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - -$Log: chanwr.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:20:24 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Revision 1.1 1996/08/19 22:40:31 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int chanwr_(integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits, struct lpc10_encoder_state *st); -extern int chanrd_(integer *order, integer *ipitv, integer *irms, integer *irc, integer *ibits); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* *********************************************************************** */ - -/* CHANL Version 49 */ - -/* $Log: chanwr.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:20:24 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Revision 1.1 1996/08/19 22:40:31 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/21 15:14:57 jaf */ -/* Added comments about which indices of argument arrays are read or */ -/* written, and about the one bit of local state in CHANWR. CHANRD */ -/* has no local state. */ - -/* Revision 1.2 1996/03/13 18:55:10 jaf */ -/* Comments added explaining which of the local variables of this */ -/* subroutine need to be saved from one invocation to the next, and which */ -/* do not. */ - -/* Revision 1.1 1996/02/07 14:43:31 jaf */ -/* Initial revision */ - - -/* *********************************************************************** */ - -/* CHANWR: */ -/* Place quantized parameters into bitstream */ - -/* Input: */ -/* ORDER - Number of reflection coefficients (not really variable) */ -/* IPITV - Quantized pitch/voicing parameter */ -/* IRMS - Quantized energy parameter */ -/* IRC - Quantized reflection coefficients */ -/* Indices 1 through ORDER read. */ -/* Output: */ -/* IBITS - Serial bitstream */ -/* Indices 1 through 54 written. */ -/* Bit 54, the SYNC bit, alternates from one call to the next. */ - -/* Subroutine CHANWR maintains one bit of local state from one call to */ -/* the next, in the variable ISYNC. I believe that this one bit is only */ -/* intended to allow a receiver to resynchronize its interpretation of */ -/* the bit stream, by looking for which of the 54 bits alternates every */ -/* frame time. This is just a simple framing mechanism that is not */ -/* useful when other, higher overhead framing mechanisms are used to */ -/* transmit the coded frames. */ - -/* I'm not going to make an entry to reinitialize this bit, since it */ -/* doesn't help a receiver much to know whether the first sync bit is a 0 */ -/* or a 1. It needs to examine several frames in sequence to have */ -/* reasonably good assurance that its framing is correct. */ - - -/* CHANRD: */ -/* Reconstruct parameters from bitstream */ - -/* Input: */ -/* ORDER - Number of reflection coefficients (not really variable) */ -/* IBITS - Serial bitstream */ -/* Indices 1 through 53 read (SYNC bit is ignored). */ -/* Output: */ -/* IPITV - Quantized pitch/voicing parameter */ -/* IRMS - Quantized energy parameter */ -/* IRC - Quantized reflection coefficients */ -/* Indices 1 through ORDER written */ - -/* Entry CHANRD has no local state. */ - - - -/* IBITS is 54 bits of LPC data ordered as follows: */ -/* R1-0, R2-0, R3-0, P-0, A-0, */ -/* R1-1, R2-1, R3-1, P-1, A-1, */ -/* R1-2, R4-0, R3-2, A-2, P-2, R4-1, */ -/* R1-3, R2-2, R3-3, R4-2, A-3, */ -/* R1-4, R2-3, R3-4, R4-3, A-4, */ -/* P-3, R2-4, R7-0, R8-0, P-4, R4-4, */ -/* R5-0, R6-0, R7-1,R10-0, R8-1, */ -/* R5-1, R6-1, R7-2, R9-0, P-5, */ -/* R5-2, R6-2,R10-1, R8-2, P-6, R9-1, */ -/* R5-3, R6-3, R7-3, R9-2, R8-3, SYNC */ -/* Subroutine */ int chanwr_0_(int n__, integer *order, integer *ipitv, - integer *irms, integer *irc, integer *ibits, - struct lpc10_encoder_state *st) -{ - /* Initialized data */ - - integer *isync; - static integer bit[10] = { 2,4,8,8,8,8,16,16,16,16 }; - static integer iblist[53] = { 13,12,11,1,2,13,12,11,1,2,13,10,11,2,1,10, - 13,12,11,10,2,13,12,11,10,2,1,12,7,6,1,10,9,8,7,4,6,9,8,7,5,1,9,8, - 4,6,1,5,9,8,7,5,6 }; - - /* System generated locals */ - integer i__1; - - /* Local variables */ - integer itab[13], i__; - -/* Arguments */ -/* Parameters/constants */ -/* These arrays are not Fortran PARAMETER's, but they are defined */ -/* by DATA statements below, and their contents are never altered. -*/ -/* Local variables that need not be saved */ -/* Local state */ -/* ISYNC is only used by CHANWR, not by ENTRY CHANRD. */ - - /* Parameter adjustments */ - --irc; - --ibits; - - /* Function Body */ - switch(n__) { - case 1: goto L_chanrd; - } - - isync = &(st->isync); - -/* *********************************************************************** - */ -/* Place quantized parameters into bitstream */ -/* *********************************************************************** - */ -/* Place parameters into ITAB */ - itab[0] = *ipitv; - itab[1] = *irms; - itab[2] = 0; - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - itab[i__ + 2] = irc[*order + 1 - i__] & 32767; - } -/* Put 54 bits into IBITS array */ - for (i__ = 1; i__ <= 53; ++i__) { - ibits[i__] = itab[iblist[i__ - 1] - 1] & 1; - itab[iblist[i__ - 1] - 1] /= 2; - } - ibits[54] = *isync & 1; - *isync = 1 - *isync; - return 0; -/* *********************************************************************** - */ -/* Reconstruct parameters from bitstream */ -/* *********************************************************************** - */ - -L_chanrd: -/* Reconstruct ITAB */ - for (i__ = 1; i__ <= 13; ++i__) { - itab[i__ - 1] = 0; - } - for (i__ = 1; i__ <= 53; ++i__) { - itab[iblist[54 - i__ - 1] - 1] = (itab[iblist[54 - i__ - 1] - 1] << 1) - + ibits[54 - i__]; - } -/* Sign extend RC's */ - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - if ((itab[i__ + 2] & bit[i__ - 1]) != 0) { - itab[i__ + 2] -= bit[i__ - 1] << 1; - } - } -/* Restore variables */ - *ipitv = itab[0]; - *irms = itab[1]; - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - irc[i__] = itab[*order + 4 - i__ - 1]; - } - return 0; -} /* chanwr_ */ - -/* Subroutine */ int chanwr_(integer *order, integer *ipitv, integer *irms, - integer *irc, integer *ibits, struct lpc10_encoder_state *st) -{ - return chanwr_0_(0, order, ipitv, irms, irc, ibits, st); - } - -/* Subroutine */ int chanrd_(integer *order, integer *ipitv, integer *irms, - integer *irc, integer *ibits) -{ - return chanwr_0_(1, order, ipitv, irms, irc, ibits, 0); - } diff --git a/linphone/lpc10-1.5/dcbias.c b/linphone/lpc10-1.5/dcbias.c deleted file mode 100644 index 60d41e9ae..000000000 --- a/linphone/lpc10-1.5/dcbias.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - -$Log: dcbias.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:40:23 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int dcbias_(integer *len, real *speech, real *sigout); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ********************************************************************* */ - -/* DCBIAS Version 50 */ - -/* $Log: dcbias.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:40:23 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/18 21:19:22 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 16:44:53 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:44:21 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* Calculate and remove DC bias from buffer. */ - -/* Input: */ -/* LEN - Length of speech buffers */ -/* SPEECH - Input speech buffer */ -/* Indices 1 through LEN read. */ -/* Output: */ -/* SIGOUT - Output speech buffer */ -/* Indices 1 through LEN written */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int dcbias_(integer *len, real *speech, real *sigout) -{ - /* System generated locals */ - integer i__1; - - /* Local variables */ - real bias; - integer i__; - -/* Arguments */ -/* Local variables that need not be saved */ - /* Parameter adjustments */ - --sigout; - --speech; - - /* Function Body */ - bias = 0.f; - i__1 = *len; - for (i__ = 1; i__ <= i__1; ++i__) { - bias += speech[i__]; - } - bias /= *len; - i__1 = *len; - for (i__ = 1; i__ <= i__1; ++i__) { - sigout[i__] = speech[i__] - bias; - } - return 0; -} /* dcbias_ */ - diff --git a/linphone/lpc10-1.5/decode.c b/linphone/lpc10-1.5/decode.c deleted file mode 100644 index 8e2abb325..000000000 --- a/linphone/lpc10-1.5/decode.c +++ /dev/null @@ -1,589 +0,0 @@ -/* - -$Log: decode.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:22:39 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:38 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int decode_(integer *ipitv, integer *irms, integer *irc, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_decoder_state *st); -/* comlen contrl_ 12 */ -/*:ref: ham84_ 14 3 4 4 4 */ -/*:ref: median_ 4 3 4 4 4 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Common Block Declarations */ - -extern struct { - integer order, lframe; - logical corrp; -} contrl_; - -#define contrl_1 contrl_ - -/* Table of constant values */ - -static integer c__2 = 2; - -/* ***************************************************************** */ - -/* DECODE Version 54 */ - -/* $Log: decode.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:22:39 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:38 jaf - * Initial revision - * */ -/* Revision 1.5 1996/05/23 20:06:03 jaf */ -/* Assigned PITCH a "default" value on the first call, since otherwise it */ -/* would be left uninitialized. */ - -/* Revision 1.4 1996/03/26 19:35:18 jaf */ -/* Commented out trace statements. */ - -/* Revision 1.3 1996/03/21 21:10:50 jaf */ -/* Added entry INITDECODE to reinitialize the local state of subroutine */ -/* DECODE. */ - -/* Revision 1.2 1996/03/21 21:04:50 jaf */ -/* Determined which local variables should be saved from one invocation */ -/* to the next, and guessed initial values for some that should have been */ -/* saved, but weren't given initial values. Many of the arrays are */ -/* "constants", and many local variables are only used if the "global" */ -/* variable CORRP is .TRUE. */ - -/* Added comments explaining which indices of array arguments are read or */ -/* written. */ - -/* Revision 1.1 1996/02/12 03:21:10 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* This subroutine provides error correction and decoding */ -/* for all LPC parameters */ - -/* Input: */ -/* IPITV - Index value of pitch */ -/* IRMS - Coded Energy */ -/* CORRP - Error correction: */ -/* If FALSE, parameters are decoded directly with no delay. If TRUE, */ -/* most important parameter bits are protected by Hamming code and */ -/* median smoothed. This requires an additional frame of delay. */ -/* Input/Output: */ -/* IRC - Coded Reflection Coefficients */ -/* Indices 1 through ORDER always read, then written. */ -/* Output: */ -/* VOICE - Half frame voicing decisions */ -/* Indices 1 through 2 written. */ -/* PITCH - Decoded pitch */ -/* RMS - Energy */ -/* RC - Reflection coefficients */ -/* Indices 1 through ORDER written. */ - -/* NOTE: Zero RC's should be done more directly, but this would affect */ -/* coded parameter printout. */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this filter, or */ -/* reinitialize its state for any other reason, call the ENTRY */ -/* INITDECODE. */ - -/* Subroutine */ int decode_(integer *ipitv, integer *irms, - integer *irc, integer *voice, integer *pitch, real *rms, real *rc, - struct lpc10_decoder_state *st) -{ - /* Initialized data */ - - logical *first; - static integer ethrs = 2048; - static integer ethrs1 = 128; - static integer ethrs2 = 1024; - static integer ethrs3 = 2048; - static integer ivtab[32] = { 24960,24960,24960,24960,25480,25480,25483, - 25480,16640,1560,1560,1560,16640,1816,1563,1560,24960,24960,24859, - 24856,26001,25881,25915,25913,1560,1560,7800,3640,1561,1561,3643, - 3641 }; - static real corth[32] /* was [4][8] */ = { 32767.f,10.f,5.f,0.f, - 32767.f,8.f,4.f,0.f,32.f,6.4f,3.2f,0.f,32.f,6.4f,3.2f,0.f,32.f, - 11.2f,6.4f,0.f,32.f,11.2f,6.4f,0.f,16.f,5.6f,3.2f,0.f,16.f,5.6f, - 3.2f,0.f }; - static integer detau[128] = { 0,0,0,3,0,3,3,31,0,3,3,21,3,3,29,30,0,3,3, - 20,3,25,27,26,3,23,58,22,3,24,28,3,0,3,3,3,3,39,33,32,3,37,35,36, - 3,38,34,3,3,42,46,44,50,40,48,3,54,3,56,3,52,3,3,1,0,3,3,108,3,78, - 100,104,3,84,92,88,156,80,96,3,3,74,70,72,66,76,68,3,62,3,60,3,64, - 3,3,1,3,116,132,112,148,152,3,3,140,3,136,3,144,3,3,1,124,120,128, - 3,3,3,3,1,3,3,3,1,3,1,1,1 }; - static integer rmst[64] = { 1024,936,856,784,718,656,600,550,502,460,420, - 384,352,328,294,270,246,226,206,188,172,158,144,132,120,110,102, - 92,84,78,70,64,60,54,50,46,42,38,34,32,30,26,24,22,20,18,17,16,15, - 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 }; - static integer detab7[32] = { 4,11,18,25,32,39,46,53,60,66,72,77,82,87,92, - 96,101,104,108,111,114,115,117,119,121,122,123,124,125,126,127, - 127 }; - static real descl[8] = { .6953f,.625f,.5781f,.5469f,.5312f,.5391f,.4688f, - .3828f }; - integer *ivp2h; - static integer deadd[8] = { 1152,-2816,-1536,-3584,-1280,-2432,768,-1920 } - ; - static integer qb[8] = { 511,511,1023,1023,1023,1023,2047,4095 }; - static integer nbit[10] = { 8,8,5,5,4,4,4,4,3,2 }; - static integer zrc[10] = { 0,0,0,0,0,3,0,2,0,0 }; - static integer bit[5] = { 2,4,8,16,32 }; - integer *iovoic; - integer *iavgp; - integer *iptold; - integer *erate; - integer *drc; - integer *dpit; - integer *drms; - - /* System generated locals */ - integer i__1, i__2; - - /* Builtin functions */ - integer pow_ii(integer *, integer *); - - /* Local variables */ - extern /* Subroutine */ int ham84_(integer *, integer *, integer *); - integer ipit, iout, i__, icorf, index, ivoic, ixcor, i1, i2, i4; - extern integer median_(integer *, integer *, integer *); - integer ishift, errcnt, lsb; - -/* $Log: decode.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:22:39 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:38 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Arguments */ -/* $Log: decode.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:22:39 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:38 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:05:55 jaf */ -/* Commented out the common block variables that are not needed by the */ -/* embedded version. */ - -/* Revision 1.2 1996/03/26 19:34:50 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:44:09 jaf */ -/* Initial revision */ - -/* LPC Processing control variables: */ - -/* *** Read-only: initialized in setup */ - -/* Files for Speech, Parameter, and Bitstream Input & Output, */ -/* and message and debug outputs. */ - -/* Here are the only files which use these variables: */ - -/* lpcsim.f setup.f trans.f error.f vqsetup.f */ - -/* Many files which use fdebug are not listed, since it is only used in */ -/* those other files conditionally, to print trace statements. */ -/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* LPC order, Frame size, Quantization rate, Bits per frame, */ -/* Error correction */ -/* Subroutine SETUP is the only place where order is assigned a value, */ -/* and that value is 10. It could increase efficiency 1% or so to */ -/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as -*/ -/* a variable in a COMMON block, since it is used in many places in the */ -/* core of the coding and decoding routines. Actually, I take that back. -*/ -/* At least when compiling with f2c, the upper bound of DO loops is */ -/* stored in a local variable before the DO loop begins, and then that is -*/ -/* compared against on each iteration. */ -/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ -/* Similarly for quant, which is given a value of 2400 in SETUP. quant */ -/* is used in only a few places, and never in the core coding and */ -/* decoding routines, so it could be eliminated entirely. */ -/* nbits is similar to quant, and is given a value of 54 in SETUP. */ -/* corrp is given a value of .TRUE. in SETUP, and is only used in the */ -/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ -/* coder significantly whether it is .TRUE. or .FALSE., or whether it is -*/ -/* a constant or a variable, since it is only examined once per frame. */ -/* Leaving it as a variable that is set to .TRUE. seems like a good */ -/* idea, since it does enable some error-correction capability for */ -/* unvoiced frames, with no change in the coding rate, and no noticeable -*/ -/* quality difference in the decoded speech. */ -/* integer quant, nbits */ -/* *** Read/write: variables for debugging, not needed for LPC algorithm -*/ - -/* Current frame, Unstable frames, Output clip count, Max onset buffer, -*/ -/* Debug listing detail level, Line count on listing page */ - -/* nframe is not needed for an embedded LPC10 at all. */ -/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ -/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ -/* an application, I would recommend removing the call to ERROR in RCCHK, -*/ -/* and remove ERROR and nunsfm completely. */ -/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in -*/ -/* sread.f. When LPC10 is embedded into an application, one might want */ -/* to cause it to be incremented in a routine that takes the output of */ -/* SYNTHS and sends it to an audio device. It could be optionally */ -/* displayed, for those that might want to know what it is. */ -/* maxosp is never initialized to 0 in SETUP, although it probably should -*/ -/* be, and it is updated in subroutine ANALYS. I doubt that its value */ -/* would be of much interest to an application in which LPC10 is */ -/* embedded. */ -/* listl and lincnt are not needed for an embedded LPC10 at all. */ -/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* common /contrl/ quant, nbits */ -/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* Function return value definitions */ - -/* Parameters/constants */ - -/* The variables below that are not Fortran PARAMETER's are */ -/* initialized with DATA statements, and then never modified. */ -/* The following are used regardless of CORRP's value. */ - -/* DETAU, NBIT, QB, DEADD, DETAB7, RMST, DESCL */ - -/* The following are used only if CORRP is .TRUE. */ - -/* ETHRS, ETHRS1, ETHRS2, ETHRS3, IVTAB, BIT, CORTH, ZRC */ - -/* Local variables that need not be saved */ - -/* The following are used regardless of CORRP's value */ -/* The following are used only if CORRP is .TRUE. */ - -/* Local state */ - -/* The following are used regardless of CORRP's value */ -/* The following are used only if CORRP is .TRUE. */ -/* I am guessing the initial values for IVP2H, IOVOIC, DRC, DPIT, */ -/* and DRMS. They should be checked to see if they are reasonable. -*/ -/* I'm also guessing for ERATE, but I think 0 is the right initial -*/ -/* value. */ - /* Parameter adjustments */ - if (irc) { - --irc; - } - if (voice) { - --voice; - } - if (rc) { - --rc; - } - - /* Function Body */ - - iptold = &(st->iptold); - first = &(st->first); - ivp2h = &(st->ivp2h); - iovoic = &(st->iovoic); - iavgp = &(st->iavgp); - erate = &(st->erate); - drc = &(st->drc[0]); - dpit = &(st->dpit[0]); - drms = &(st->drms[0]); - -/* DATA statements for "constants" defined above. */ -/* IF (LISTL.GE.3) WRITE(FDEBUG,800) IPITV,IRMS,(IRC(J),J=1,ORDER) */ -/* 800 FORMAT(1X,' <>',T32,6X,I6,I5,T50,10I8) */ -/* If no error correction, do pitch and voicing then jump to decode */ - i4 = detau[*ipitv]; - if (! contrl_1.corrp) { - voice[1] = 1; - voice[2] = 1; - if (*ipitv <= 1) { - voice[1] = 0; - } - if (*ipitv == 0 || *ipitv == 2) { - voice[2] = 0; - } - *pitch = i4; - if (*pitch <= 4) { - *pitch = *iptold; - } - if (voice[1] == 1 && voice[2] == 1) { - *iptold = *pitch; - } - if (voice[1] != voice[2]) { - *pitch = *iptold; - } - goto L900; - } -/* Do error correction pitch and voicing */ - if (i4 > 4) { - dpit[0] = i4; - ivoic = 2; - *iavgp = (*iavgp * 15 + i4 + 8) / 16; - } else { - ivoic = i4; - dpit[0] = *iavgp; - } - drms[0] = *irms; - i__1 = contrl_1.order; - for (i__ = 1; i__ <= i__1; ++i__) { - drc[i__ * 3 - 3] = irc[i__]; - } -/* Determine index to IVTAB from V/UV decision */ -/* If error rate is high then use alternate table */ - index = (*ivp2h << 4) + (*iovoic << 2) + ivoic + 1; - i1 = ivtab[index - 1]; - ipit = i1 & 3; - icorf = i1 / 8; - if (*erate < ethrs) { - icorf /= 64; - } -/* Determine error rate: 4=high 1=low */ - ixcor = 4; - if (*erate < ethrs3) { - ixcor = 3; - } - if (*erate < ethrs2) { - ixcor = 2; - } - if (*erate < ethrs1) { - ixcor = 1; - } -/* Voice/unvoice decision determined from bits 0 and 1 of IVTAB */ - voice[1] = icorf / 2 & 1; - voice[2] = icorf & 1; -/* Skip decoding on first frame because present data not yet available */ - if (*first) { - *first = FALSE_; -/* Assign PITCH a "default" value on the first call, since */ -/* otherwise it would be left uninitialized. The two lines -*/ -/* below were copied from above, since it seemed like a */ -/* reasonable thing to do for the first call. */ - *pitch = i4; - if (*pitch <= 4) { - *pitch = *iptold; - } - goto L500; - } -/* If bit 4 of ICORF is set then correct RMS and RC(1) - RC(4). */ -/* Determine error rate and correct errors using a Hamming 8,4 code */ -/* during transition or unvoiced frame. If IOUT is negative, */ -/* more than 1 error occurred, use previous frame's parameters. */ - if ((icorf & bit[3]) != 0) { - errcnt = 0; - lsb = drms[1] & 1; - index = (drc[22] << 4) + drms[1] / 2; - ham84_(&index, &iout, &errcnt); - drms[1] = drms[2]; - if (iout >= 0) { - drms[1] = (iout << 1) + lsb; - } - for (i__ = 1; i__ <= 4; ++i__) { - if (i__ == 1) { - i1 = ((drc[25] & 7) << 1) + (drc[28] & 1); - } else { - i1 = drc[(9 - i__) * 3 - 2] & 15; - } - i2 = drc[(5 - i__) * 3 - 2] & 31; - lsb = i2 & 1; - index = (i1 << 4) + i2 / 2; - ham84_(&index, &iout, &errcnt); - if (iout >= 0) { - iout = (iout << 1) + lsb; - if ((iout & 16) == 16) { - iout += -32; - } - } else { - iout = drc[(5 - i__) * 3 - 1]; - } - drc[(5 - i__) * 3 - 2] = iout; - } -/* Determine error rate */ - *erate = *erate * .96875f + errcnt * 102; - } -/* Get unsmoothed RMS, RC's, and PITCH */ - *irms = drms[1]; - i__1 = contrl_1.order; - for (i__ = 1; i__ <= i__1; ++i__) { - irc[i__] = drc[i__ * 3 - 2]; - } - if (ipit == 1) { - dpit[1] = dpit[2]; - } - if (ipit == 3) { - dpit[1] = dpit[0]; - } - *pitch = dpit[1]; -/* If bit 2 of ICORF is set then smooth RMS and RC's, */ - if ((icorf & bit[1]) != 0) { - if ((i__1 = drms[1] - drms[0], (real) abs(i__1)) >= corth[ixcor + 3] - && (i__2 = drms[1] - drms[2], (real) abs(i__2)) >= corth[ - ixcor + 3]) { - *irms = median_(&drms[2], &drms[1], drms); - } - for (i__ = 1; i__ <= 6; ++i__) { - if ((i__1 = drc[i__ * 3 - 2] - drc[i__ * 3 - 3], (real) abs(i__1)) - >= corth[ixcor + (i__ + 2 << 2) - 5] && (i__2 = drc[i__ * - 3 - 2] - drc[i__ * 3 - 1], (real) abs(i__2)) >= corth[ - ixcor + (i__ + 2 << 2) - 5]) { - irc[i__] = median_(&drc[i__ * 3 - 1], &drc[i__ * 3 - 2], &drc[ - i__ * 3 - 3]); - } - } - } -/* If bit 3 of ICORF is set then smooth pitch */ - if ((icorf & bit[2]) != 0) { - if ((i__1 = dpit[1] - dpit[0], (real) abs(i__1)) >= corth[ixcor - 1] - && (i__2 = dpit[1] - dpit[2], (real) abs(i__2)) >= corth[ - ixcor - 1]) { - *pitch = median_(&dpit[2], &dpit[1], dpit); - } - } -/* If bit 5 of ICORF is set then RC(5) - RC(10) are loaded with */ -/* values so that after quantization bias is removed in decode */ -/* the values will be zero. */ -L500: - if ((icorf & bit[4]) != 0) { - i__1 = contrl_1.order; - for (i__ = 5; i__ <= i__1; ++i__) { - irc[i__] = zrc[i__ - 1]; - } - } -/* House keeping - one frame delay */ - *iovoic = ivoic; - *ivp2h = voice[2]; - dpit[2] = dpit[1]; - dpit[1] = dpit[0]; - drms[2] = drms[1]; - drms[1] = drms[0]; - i__1 = contrl_1.order; - for (i__ = 1; i__ <= i__1; ++i__) { - drc[i__ * 3 - 1] = drc[i__ * 3 - 2]; - drc[i__ * 3 - 2] = drc[i__ * 3 - 3]; - } -L900: -/* IF (LISTL.GE.3)WRITE(FDEBUG,801)VOICE,PITCH,IRMS,(IRC(J),J=1,ORDER) */ -/* 801 FORMAT(1X,'<>',T32,2I3,I6,I5,T50,10I8) */ -/* Decode RMS */ - *irms = rmst[(31 - *irms) * 2]; -/* Decode RC(1) and RC(2) from log-area-ratios */ -/* Protect from illegal coded value (-16) caused by bit errors */ - for (i__ = 1; i__ <= 2; ++i__) { - i2 = irc[i__]; - i1 = 0; - if (i2 < 0) { - i1 = 1; - i2 = -i2; - if (i2 > 15) { - i2 = 0; - } - } - i2 = detab7[i2 * 2]; - if (i1 == 1) { - i2 = -i2; - } - ishift = 15 - nbit[i__ - 1]; - irc[i__] = i2 * pow_ii(&c__2, &ishift); - } -/* Decode RC(3)-RC(10) to sign plus 14 bits */ - i__1 = contrl_1.order; - for (i__ = 3; i__ <= i__1; ++i__) { - i2 = irc[i__]; - ishift = 15 - nbit[i__ - 1]; - i2 *= pow_ii(&c__2, &ishift); - i2 += qb[i__ - 3]; - irc[i__] = i2 * descl[i__ - 3] + deadd[i__ - 3]; - } -/* IF (LISTL.GE.3) WRITE(FDEBUG,811) IRMS, (IRC(I),I=1,ORDER) */ -/* 811 FORMAT(1X,'<>',T45,I4,1X,10I8) */ -/* Scale RMS and RC's to reals */ - *rms = (real) (*irms); - i__1 = contrl_1.order; - for (i__ = 1; i__ <= i__1; ++i__) { - rc[i__] = irc[i__] / 16384.f; - } - return 0; -} /* decode_ */ diff --git a/linphone/lpc10-1.5/deemp.c b/linphone/lpc10-1.5/deemp.c deleted file mode 100644 index 6f5f0f3a9..000000000 --- a/linphone/lpc10-1.5/deemp.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - -$Log: deemp.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:23:46 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:34 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int deemp_(real *x, integer *n, struct lpc10_decoder_state *st); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ***************************************************************** */ - -/* DEEMP Version 48 */ - -/* $Log: deemp.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:23:46 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:32:34 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/20 15:54:37 jaf */ -/* Added comments about which indices of array arguments are read or */ -/* written. */ - -/* Added entry INITDEEMP to reinitialize the local state variables, if */ -/* desired. */ - -/* Revision 1.2 1996/03/14 22:11:13 jaf */ -/* Comments added explaining which of the local variables of this */ -/* subroutine need to be saved from one invocation to the next, and which */ -/* do not. */ - -/* Revision 1.1 1996/02/07 14:44:53 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* De-Emphasize output speech with 1 / ( 1 - .75z**-1 ) */ -/* cascaded with 200 Hz high pass filter */ -/* ( 1 - 1.9998z**-1 + z**-2 ) / ( 1 - 1.75z**-1 + .78z**-2 ) */ - -/* WARNING! The coefficients above may be out of date with the code */ -/* below. Either that, or some kind of transformation was performed */ -/* on the coefficients above to create the code below. */ - -/* Input: */ -/* N - Number of samples */ -/* Input/Output: */ -/* X - Speech */ -/* Indices 1 through N are read before being written. */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this filter, or */ -/* reinitialize its state for any other reason, call the ENTRY */ -/* INITDEEMP. */ - -/* Subroutine */ int deemp_(real *x, integer *n, struct lpc10_decoder_state *st) -{ - /* Initialized data */ - - real *dei1; - real *dei2; - real *deo1; - real *deo2; - real *deo3; - - /* System generated locals */ - integer i__1; - real r__1; - - /* Local variables */ - integer k; - real dei0; - -/* Arguments */ -/* Local variables that need not be saved */ -/* Local state */ -/* All of the locals saved below were not given explicit initial */ -/* values in the original code. I think 0 is a safe choice. */ - /* Parameter adjustments */ - if (x) { - --x; - } - - /* Function Body */ - - dei1 = &(st->dei1); - dei2 = &(st->dei2); - deo1 = &(st->deo1); - deo2 = &(st->deo2); - deo3 = &(st->deo3); - - i__1 = *n; - for (k = 1; k <= i__1; ++k) { - dei0 = x[k]; - r__1 = x[k] - *dei1 * 1.9998f + *dei2; - x[k] = r__1 + *deo1 * 2.5f - *deo2 * 2.0925f + *deo3 * .585f; - *dei2 = *dei1; - *dei1 = dei0; - *deo3 = *deo2; - *deo2 = *deo1; - *deo1 = x[k]; - } - return 0; -} /* deemp_ */ diff --git a/linphone/lpc10-1.5/difmag.c b/linphone/lpc10-1.5/difmag.c deleted file mode 100644 index 7a3589872..000000000 --- a/linphone/lpc10-1.5/difmag.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - -$Log: difmag.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:32:31 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int difmag_(real *speech, integer *lpita, integer *tau, integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer *maxptr); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ********************************************************************** */ - -/* DIFMAG Version 49 */ - -/* $Log: difmag.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:14 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:32:31 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/15 23:09:39 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 14:41:31 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:45:04 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* Compute Average Magnitude Difference Function */ - -/* Inputs: */ -/* SPEECH - Low pass filtered speech */ -/* Indices MIN_N1 through MAX_N1+LPITA-1 are read, where */ -/* MIN_N1 = (MAXLAG - MAX_TAU)/2+1 MAX_TAU = max of TAU(I) for I=1,LTAU -*/ -/* MAX_N1 = (MAXLAG - MIN_TAU)/2+1 MIN_TAU = min of TAU(I) for I=1,LTAU -*/ -/* LPITA - Length of speech buffer */ -/* TAU - Table of lags */ -/* Indices 1 through LTAU read. */ -/* LTAU - Number of lag values to compute */ -/* MAXLAG - Maximum possible lag value */ -/* Outputs: */ -/* (All of these outputs are also read, but only after being written.) */ -/* AMDF - Average Magnitude Difference for each lag in TAU */ -/* Indices 1 through LTAU written */ -/* MINPTR - Index of minimum AMDF value */ -/* MAXPTR - Index of maximum AMDF value */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int difmag_(real *speech, integer *lpita, integer *tau, - integer *ltau, integer *maxlag, real *amdf, integer *minptr, integer * - maxptr) -{ - /* System generated locals */ - integer i__1, i__2; - real r__1; - - /* Local variables */ - integer i__, j, n1, n2; - real sum; - -/* Arguments */ -/* Local variables that need not be saved */ -/* Local state */ -/* None */ - /* Parameter adjustments */ - --amdf; - --tau; - --speech; - - /* Function Body */ - *minptr = 1; - *maxptr = 1; - i__1 = *ltau; - for (i__ = 1; i__ <= i__1; ++i__) { - n1 = (*maxlag - tau[i__]) / 2 + 1; - n2 = n1 + *lpita - 1; - sum = 0.f; - i__2 = n2; - for (j = n1; j <= i__2; j += 4) { - sum += (r__1 = speech[j] - speech[j + tau[i__]], abs(r__1)); - } - amdf[i__] = sum; - if (amdf[i__] < amdf[*minptr]) { - *minptr = i__; - } - if (amdf[i__] > amdf[*maxptr]) { - *maxptr = i__; - } - } - return 0; -} /* difmag_ */ - diff --git a/linphone/lpc10-1.5/dyptrk.c b/linphone/lpc10-1.5/dyptrk.c deleted file mode 100644 index 168d2c3a6..000000000 --- a/linphone/lpc10-1.5/dyptrk.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - -$Log: dyptrk.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:25:29 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:32:26 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int dyptrk_(real *amdf, integer *ltau, integer *minptr, integer *voice, integer *pitch, integer *midx, struct lpc10_encoder_state *st); -/* comlen contrl_ 12 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Common Block Declarations */ - -extern struct { - integer order, lframe; - logical corrp; -} contrl_; - -#define contrl_1 contrl_ - -/* ********************************************************************* */ - -/* DYPTRK Version 52 */ - -/* $Log: dyptrk.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:25:29 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:32:26 jaf - * Initial revision - * */ -/* Revision 1.5 1996/03/26 19:35:35 jaf */ -/* Commented out trace statements. */ - -/* Revision 1.4 1996/03/19 18:03:22 jaf */ -/* Replaced the initialization "DATA P/60*DEPTH*0/" with "DATA P/120*0/", */ -/* because apparently Fortran (or at least f2c) can't handle expressions */ -/* like that. */ - -/* Revision 1.3 1996/03/19 17:38:32 jaf */ -/* Added comments about the local variables that should be saved from one */ -/* invocation to the next. None of them were given initial values in the */ -/* original code, but from my testing, it appears that initializing them */ -/* all to 0 works. */ - -/* Added entry INITDYPTRK to reinitialize these local variables. */ - -/* Revision 1.2 1996/03/13 16:32:17 jaf */ -/* Comments added explaining which of the local variables of this */ -/* subroutine need to be saved from one invocation to the next, and which */ -/* do not. */ - -/* WARNING! Some of them that should are never given initial values in */ -/* this code. Hopefully, Fortran 77 defines initial values for them, but */ -/* even so, giving them explicit initial values is preferable. */ - -/* Revision 1.1 1996/02/07 14:45:14 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* Dynamic Pitch Tracker */ - -/* Input: */ -/* AMDF - Average Magnitude Difference Function array */ -/* Indices 1 through LTAU read, and MINPTR */ -/* LTAU - Number of lags in AMDF */ -/* MINPTR - Location of minimum AMDF value */ -/* VOICE - Voicing decision */ -/* Output: */ -/* PITCH - Smoothed pitch value, 2 frames delayed */ -/* MIDX - Initial estimate of current frame pitch */ -/* Compile time constant: */ -/* DEPTH - Number of frames to trace back */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this filter, or */ -/* reinitialize its state for any other reason, call the ENTRY */ -/* INITDYPTRK. */ - -/* Subroutine */ int dyptrk_(real *amdf, integer *ltau, integer * - minptr, integer *voice, integer *pitch, integer *midx, - struct lpc10_encoder_state *st) -{ - /* Initialized data */ - - real *s; - integer *p; - integer *ipoint; - real *alphax; - - /* System generated locals */ - integer i__1; - - /* Local variables */ - integer pbar; - real sbar; - integer path[2], iptr, i__, j; - real alpha, minsc, maxsc; - -/* Arguments */ -/* $Log: dyptrk.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:25:29 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:32:26 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:05:55 jaf */ -/* Commented out the common block variables that are not needed by the */ -/* embedded version. */ - -/* Revision 1.2 1996/03/26 19:34:50 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:44:09 jaf */ -/* Initial revision */ - -/* LPC Processing control variables: */ - -/* *** Read-only: initialized in setup */ - -/* Files for Speech, Parameter, and Bitstream Input & Output, */ -/* and message and debug outputs. */ - -/* Here are the only files which use these variables: */ - -/* lpcsim.f setup.f trans.f error.f vqsetup.f */ - -/* Many files which use fdebug are not listed, since it is only used in */ -/* those other files conditionally, to print trace statements. */ -/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* LPC order, Frame size, Quantization rate, Bits per frame, */ -/* Error correction */ -/* Subroutine SETUP is the only place where order is assigned a value, */ -/* and that value is 10. It could increase efficiency 1% or so to */ -/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as -*/ -/* a variable in a COMMON block, since it is used in many places in the */ -/* core of the coding and decoding routines. Actually, I take that back. -*/ -/* At least when compiling with f2c, the upper bound of DO loops is */ -/* stored in a local variable before the DO loop begins, and then that is -*/ -/* compared against on each iteration. */ -/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ -/* Similarly for quant, which is given a value of 2400 in SETUP. quant */ -/* is used in only a few places, and never in the core coding and */ -/* decoding routines, so it could be eliminated entirely. */ -/* nbits is similar to quant, and is given a value of 54 in SETUP. */ -/* corrp is given a value of .TRUE. in SETUP, and is only used in the */ -/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ -/* coder significantly whether it is .TRUE. or .FALSE., or whether it is -*/ -/* a constant or a variable, since it is only examined once per frame. */ -/* Leaving it as a variable that is set to .TRUE. seems like a good */ -/* idea, since it does enable some error-correction capability for */ -/* unvoiced frames, with no change in the coding rate, and no noticeable -*/ -/* quality difference in the decoded speech. */ -/* integer quant, nbits */ -/* *** Read/write: variables for debugging, not needed for LPC algorithm -*/ - -/* Current frame, Unstable frames, Output clip count, Max onset buffer, -*/ -/* Debug listing detail level, Line count on listing page */ - -/* nframe is not needed for an embedded LPC10 at all. */ -/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ -/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ -/* an application, I would recommend removing the call to ERROR in RCCHK, -*/ -/* and remove ERROR and nunsfm completely. */ -/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in -*/ -/* sread.f. When LPC10 is embedded into an application, one might want */ -/* to cause it to be incremented in a routine that takes the output of */ -/* SYNTHS and sends it to an audio device. It could be optionally */ -/* displayed, for those that might want to know what it is. */ -/* maxosp is never initialized to 0 in SETUP, although it probably should -*/ -/* be, and it is updated in subroutine ANALYS. I doubt that its value */ -/* would be of much interest to an application in which LPC10 is */ -/* embedded. */ -/* listl and lincnt are not needed for an embedded LPC10 at all. */ -/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* common /contrl/ quant, nbits */ -/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* Parameters/constants */ -/* Local variables that need not be saved */ -/* Note that PATH is only used for debugging purposes, and can be */ -/* removed. */ -/* Local state */ -/* It would be a bit more "general" to define S(LTAU), if Fortran */ -/* allows the argument of a function to be used as the dimension of -*/ -/* a local array variable. */ -/* IPOINT is always in the range 0 to DEPTH-1. */ -/* WARNING! */ - -/* In the original version of this subroutine, IPOINT, ALPHAX, */ -/* every element of S, and potentially any element of P with the */ -/* second index value .NE. IPTR were read without being given */ -/* initial values (all indices of P with second index equal to */ -/* IPTR are all written before being read in this subroutine). */ - -/* From examining the code carefully, it appears that all of these -*/ -/* should be saved from one invocation to the next. */ - -/* I've run lpcsim with the "-l 6" option to see all of the */ -/* debugging information that is printed out by this subroutine */ -/* below, and it appears that S, P, IPOINT, and ALPHAX are all */ -/* initialized to 0 (these initial values would likely be different -*/ -/* on different platforms, compilers, etc.). Given that the output -*/ -/* of the coder sounds reasonable, I'm going to initialize these */ -/* variables to 0 explicitly. */ - - s = &(st->s[0]); - p = &(st->p[0]); - ipoint = &(st->ipoint); - alphax = &(st->alphax); - - - /* Parameter adjustments */ - if (amdf) { - --amdf; - } - - /* Function Body */ - -/* Calculate the confidence factor ALPHA, used as a threshold slope in -*/ -/* SEESAW. If unvoiced, set high slope so that every point in P array -*/ -/* is marked as a potential pitch frequency. A scaled up version (ALPHAX -)*/ -/* is used to maintain arithmetic precision. */ - if (*voice == 1) { - *alphax = *alphax * .75f + amdf[*minptr] / 2.f; - } else { - *alphax *= .984375f; - } - alpha = *alphax / 16; - if (*voice == 0 && *alphax < 128.f) { - alpha = 8.f; - } -/* SEESAW: Construct a pitch pointer array and intermediate winner functio -n*/ -/* Left to right pass: */ - iptr = *ipoint + 1; - p[iptr * 60 - 60] = 1; - i__ = 1; - pbar = 1; - sbar = s[0]; - i__1 = *ltau; - for (i__ = 1; i__ <= i__1; ++i__) { - sbar += alpha; - if (sbar < s[i__ - 1]) { - s[i__ - 1] = sbar; - p[i__ + iptr * 60 - 61] = pbar; - } else { - sbar = s[i__ - 1]; - p[i__ + iptr * 60 - 61] = i__; - pbar = i__; - } - } -/* Right to left pass: */ - i__ = pbar - 1; - sbar = s[i__]; - while(i__ >= 1) { - sbar += alpha; - if (sbar < s[i__ - 1]) { - s[i__ - 1] = sbar; - p[i__ + iptr * 60 - 61] = pbar; - } else { - pbar = p[i__ + iptr * 60 - 61]; - i__ = pbar; - sbar = s[i__ - 1]; - } - --i__; - } -/* Update S using AMDF */ -/* Find maximum, minimum, and location of minimum */ - s[0] += amdf[1] / 2; - minsc = s[0]; - maxsc = minsc; - *midx = 1; - i__1 = *ltau; - for (i__ = 2; i__ <= i__1; ++i__) { - s[i__ - 1] += amdf[i__] / 2; - if (s[i__ - 1] > maxsc) { - maxsc = s[i__ - 1]; - } - if (s[i__ - 1] < minsc) { - *midx = i__; - minsc = s[i__ - 1]; - } - } -/* Subtract MINSC from S to prevent overflow */ - i__1 = *ltau; - for (i__ = 1; i__ <= i__1; ++i__) { - s[i__ - 1] -= minsc; - } - maxsc -= minsc; -/* Use higher octave pitch if significant null there */ - j = 0; - for (i__ = 20; i__ <= 40; i__ += 10) { - if (*midx > i__) { - if (s[*midx - i__ - 1] < maxsc / 4) { - j = i__; - } - } - } - *midx -= j; -/* TRACE: look back two frames to find minimum cost pitch estimate */ - j = *ipoint; - *pitch = *midx; - for (i__ = 1; i__ <= 2; ++i__) { - j = j % 2 + 1; - *pitch = p[*pitch + j * 60 - 61]; - path[i__ - 1] = *pitch; - } - -/* The following statement subtracts one from IPOINT, mod DEPTH. I -*/ -/* think the author chose to add DEPTH-1, instead of subtracting 1, -*/ -/* because then it will work even if MOD doesn't work as desired on -*/ -/* negative arguments. */ - - *ipoint = (*ipoint + 1) % 2; - return 0; -} /* dyptrk_ */ diff --git a/linphone/lpc10-1.5/encode.c b/linphone/lpc10-1.5/encode.c deleted file mode 100644 index 4c0f9d330..000000000 --- a/linphone/lpc10-1.5/encode.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - -$Log: encode.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:32:21 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int encode_(integer *voice, integer *pitch, real *rms, real *rc, integer *ipitch, integer *irms, integer *irc); -/* comlen contrl_ 12 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Common Block Declarations */ - -extern struct { - integer order, lframe; - logical corrp; -} contrl_; - -#define contrl_1 contrl_ - -/* Table of constant values */ - -static integer c__2 = 2; - -/* ***************************************************************** */ - -/* ENCODE Version 54 */ - -/* $Log: encode.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:32:21 jaf - * Initial revision - * */ -/* Revision 1.5 1996/03/26 19:35:50 jaf */ -/* Commented out trace statements. */ - -/* Revision 1.4 1996/03/21 00:26:29 jaf */ -/* Added the comment that this subroutine has no local state. */ - -/* In the last check-in, I forgot to mention that I had added comments */ -/* explaining which indices of array arguments are read or written. */ - -/* Revision 1.3 1996/03/21 00:22:39 jaf */ -/* Added comments explaining that all local arrays are effectively */ -/* constants. */ - -/* Revision 1.2 1996/03/13 18:48:33 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:45:29 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* Quantize LPC parameters for transmission */ - -/* INPUTS: */ -/* VOICE - Half frame voicing decisions */ -/* Indices 1 through 2 read. */ -/* PITCH - Pitch */ -/* RMS - Energy */ -/* RC - Reflection coefficients */ -/* Indices 1 through ORDER read. */ -/* CORRP - Error Correction: TRUE = yes, FALSE = none */ -/* (this is defined in file control.fh) */ -/* OUTPUTS: */ -/* IPITCH - Coded pitch and voicing */ -/* IRMS - Quantized energy */ -/* IRC - Quantized reflection coefficients */ -/* Indices 1 through MAX(ORDER,2) written. */ -/* If CORRP is .TRUE., then indices 1 through 10 written */ -/* for unvoiced frames. */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int encode_(integer *voice, integer *pitch, real *rms, real * - rc, integer *ipitch, integer *irms, integer *irc) -{ - /* Initialized data */ - - static integer enctab[16] = { 0,7,11,12,13,10,6,1,14,9,5,2,3,4,8,15 }; - static integer entau[60] = { 19,11,27,25,29,21,23,22,30,14,15,7,39,38,46, - 42,43,41,45,37,53,49,51,50,54,52,60,56,58,26,90,88,92,84,86,82,83, - 81,85,69,77,73,75,74,78,70,71,67,99,97,113,112,114,98,106,104,108, - 100,101,76 }; - static integer enadd[8] = { 1920,-768,2432,1280,3584,1536,2816,-1152 }; - static real enscl[8] = { .0204f,.0167f,.0145f,.0147f,.0143f,.0135f,.0125f, - .0112f }; - static integer enbits[8] = { 6,5,4,4,4,4,3,3 }; - static integer entab6[64] = { 0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3, - 3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,9,9, - 9,10,10,11,11,12,13,14,15 }; - static integer rmst[64] = { 1024,936,856,784,718,656,600,550,502,460,420, - 384,352,328,294,270,246,226,206,188,172,158,144,132,120,110,102, - 92,84,78,70,64,60,54,50,46,42,38,34,32,30,26,24,22,20,18,17,16,15, - 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 }; - - /* System generated locals */ - integer i__1, i__2; - - /* Builtin functions */ - integer pow_ii(integer *, integer *); - - /* Local variables */ - integer idel, nbit, i__, j, i2, i3, mrk; - -/* $Log: encode.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:32:21 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Arguments */ -/* $Log: encode.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:32:21 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:05:55 jaf */ -/* Commented out the common block variables that are not needed by the */ -/* embedded version. */ - -/* Revision 1.2 1996/03/26 19:34:50 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:44:09 jaf */ -/* Initial revision */ - -/* LPC Processing control variables: */ - -/* *** Read-only: initialized in setup */ - -/* Files for Speech, Parameter, and Bitstream Input & Output, */ -/* and message and debug outputs. */ - -/* Here are the only files which use these variables: */ - -/* lpcsim.f setup.f trans.f error.f vqsetup.f */ - -/* Many files which use fdebug are not listed, since it is only used in */ -/* those other files conditionally, to print trace statements. */ -/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* LPC order, Frame size, Quantization rate, Bits per frame, */ -/* Error correction */ -/* Subroutine SETUP is the only place where order is assigned a value, */ -/* and that value is 10. It could increase efficiency 1% or so to */ -/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as -*/ -/* a variable in a COMMON block, since it is used in many places in the */ -/* core of the coding and decoding routines. Actually, I take that back. -*/ -/* At least when compiling with f2c, the upper bound of DO loops is */ -/* stored in a local variable before the DO loop begins, and then that is -*/ -/* compared against on each iteration. */ -/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ -/* Similarly for quant, which is given a value of 2400 in SETUP. quant */ -/* is used in only a few places, and never in the core coding and */ -/* decoding routines, so it could be eliminated entirely. */ -/* nbits is similar to quant, and is given a value of 54 in SETUP. */ -/* corrp is given a value of .TRUE. in SETUP, and is only used in the */ -/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ -/* coder significantly whether it is .TRUE. or .FALSE., or whether it is -*/ -/* a constant or a variable, since it is only examined once per frame. */ -/* Leaving it as a variable that is set to .TRUE. seems like a good */ -/* idea, since it does enable some error-correction capability for */ -/* unvoiced frames, with no change in the coding rate, and no noticeable -*/ -/* quality difference in the decoded speech. */ -/* integer quant, nbits */ -/* *** Read/write: variables for debugging, not needed for LPC algorithm -*/ - -/* Current frame, Unstable frames, Output clip count, Max onset buffer, -*/ -/* Debug listing detail level, Line count on listing page */ - -/* nframe is not needed for an embedded LPC10 at all. */ -/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ -/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ -/* an application, I would recommend removing the call to ERROR in RCCHK, -*/ -/* and remove ERROR and nunsfm completely. */ -/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in -*/ -/* sread.f. When LPC10 is embedded into an application, one might want */ -/* to cause it to be incremented in a routine that takes the output of */ -/* SYNTHS and sends it to an audio device. It could be optionally */ -/* displayed, for those that might want to know what it is. */ -/* maxosp is never initialized to 0 in SETUP, although it probably should -*/ -/* be, and it is updated in subroutine ANALYS. I doubt that its value */ -/* would be of much interest to an application in which LPC10 is */ -/* embedded. */ -/* listl and lincnt are not needed for an embedded LPC10 at all. */ -/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* common /contrl/ quant, nbits */ -/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* Parameters/constants */ -/* These arrays are not Fortran PARAMETER's, but they are defined */ -/* by DATA statements below, and their contents are never altered. -*/ -/* Local variables that need not be saved */ - /* Parameter adjustments */ - --irc; - --rc; - --voice; - - /* Function Body */ -/* Scale RMS and RC's to integers */ - *irms = *rms; - i__1 = contrl_1.order; - for (i__ = 1; i__ <= i__1; ++i__) { - irc[i__] = rc[i__] * 32768.f; - } -/* IF(LISTL.GE.3)WRITE(FDEBUG,800)VOICE,PITCH,IRMS,(IRC(I),I=1,ORDER) */ -/* 800 FORMAT(1X,/,' <>',T32,2I3,I6,I5,T50,10I8) */ -/* Encode pitch and voicing */ - if (voice[1] != 0 && voice[2] != 0) { - *ipitch = entau[*pitch - 1]; - } else { - if (contrl_1.corrp) { - *ipitch = 0; - if (voice[1] != voice[2]) { - *ipitch = 127; - } - } else { - *ipitch = (voice[1] << 1) + voice[2]; - } - } -/* Encode RMS by binary table search */ - j = 32; - idel = 16; - *irms = min(*irms,1023); - while(idel > 0) { - if (*irms > rmst[j - 1]) { - j -= idel; - } - if (*irms < rmst[j - 1]) { - j += idel; - } - idel /= 2; - } - if (*irms > rmst[j - 1]) { - --j; - } - *irms = 31 - j / 2; -/* Encode RC(1) and (2) as log-area-ratios */ - for (i__ = 1; i__ <= 2; ++i__) { - i2 = irc[i__]; - mrk = 0; - if (i2 < 0) { - i2 = -i2; - mrk = 1; - } - i2 /= 512; - i2 = min(i2,63); - i2 = entab6[i2]; - if (mrk != 0) { - i2 = -i2; - } - irc[i__] = i2; - } -/* Encode RC(3) - (10) linearly, remove bias then scale */ - i__1 = contrl_1.order; - for (i__ = 3; i__ <= i__1; ++i__) { - i2 = irc[i__] / 2; - i2 = (i2 + enadd[contrl_1.order + 1 - i__ - 1]) * enscl[ - contrl_1.order + 1 - i__ - 1]; -/* Computing MIN */ - i__2 = max(i2,-127); - i2 = min(i__2,127); - nbit = enbits[contrl_1.order + 1 - i__ - 1]; - i3 = 0; - if (i2 < 0) { - i3 = -1; - } - i2 /= pow_ii(&c__2, &nbit); - if (i3 == -1) { - --i2; - } - irc[i__] = i2; - } -/* Protect the most significant bits of the most */ -/* important parameters during non-voiced frames. */ -/* RC(1) - RC(4) are protected using 20 parity bits */ -/* replacing RC(5) - RC(10). */ - if (contrl_1.corrp) { - if (*ipitch == 0 || *ipitch == 127) { - irc[5] = enctab[(irc[1] & 30) / 2]; - irc[6] = enctab[(irc[2] & 30) / 2]; - irc[7] = enctab[(irc[3] & 30) / 2]; - irc[8] = enctab[(*irms & 30) / 2]; - irc[9] = enctab[(irc[4] & 30) / 2] / 2; - irc[10] = enctab[(irc[4] & 30) / 2] & 1; - } - } -/* IF(LISTL.GE.3)WRITE(FDEBUG,801)VOICE,IPITCH,IRMS,(IRC(J),J=1,ORDER) */ -/* 801 FORMAT(1X,'<>',T32,2I3,I6,I5,T50,10I8) */ - return 0; -} /* encode_ */ - diff --git a/linphone/lpc10-1.5/energy.c b/linphone/lpc10-1.5/energy.c deleted file mode 100644 index 995cbac47..000000000 --- a/linphone/lpc10-1.5/energy.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - -$Log: energy.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:32:17 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int energy_(integer *len, real *speech, real *rms); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ********************************************************************* */ - -/* ENERGY Version 50 */ - -/* $Log: energy.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:32:17 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/18 21:17:41 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 16:46:02 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:45:40 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* Compute RMS energy. */ - -/* Input: */ -/* LEN - Length of speech buffer */ -/* SPEECH - Speech buffer */ -/* Indices 1 through LEN read. */ -/* Output: */ -/* RMS - Root Mean Square energy */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int energy_(integer *len, real *speech, real *rms) -{ - /* System generated locals */ - integer i__1; - - /* Builtin functions */ - double sqrt(doublereal); - - /* Local variables */ - integer i__; - -/* Arguments */ -/* Local variables that need not be saved */ - /* Parameter adjustments */ - --speech; - - /* Function Body */ - *rms = 0.f; - i__1 = *len; - for (i__ = 1; i__ <= i__1; ++i__) { - *rms += speech[i__] * speech[i__]; - } - *rms = sqrt(*rms / *len); - return 0; -} /* energy_ */ - diff --git a/linphone/lpc10-1.5/f2c.h b/linphone/lpc10-1.5/f2c.h deleted file mode 100644 index 5193e277a..000000000 --- a/linphone/lpc10-1.5/f2c.h +++ /dev/null @@ -1,260 +0,0 @@ -/* - -$Log: f2c.h,v $ -Revision 1.2 2005/11/30 20:07:31 smorlat -ready for 1.2.0 ? - -Revision 1.1.1.1 2001/11/19 19:50:13 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:26:28 jaf - * Any typedef defining a type that was used in lpc10_encoder_state or - * lpc10_decoder_state struct's was commented out here and added to - * lpc10.h. - * - * Revision 1.1 1996/08/19 22:32:13 jaf - * Initial revision - * - -*/ - -/* - * f2c.h - * - * SCCS ID: @(#)f2c.h 1.2 96/05/19 - */ - -/* f2c.h -- Standard Fortran to C header file */ - -/** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." - - - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ - -#ifndef F2C_INCLUDE -#define F2C_INCLUDE - -#include "lpc10.h" - -/*typedef long int integer;*/ -/*typedef INT32 integer;*/ -/*typedef short int shortint;*/ -/*typedef INT16 shortint;*/ -/*typedef float real;*/ -/* doublereal only used for function arguments to sqrt, exp, etc. */ -typedef double doublereal; -/* 32 bits seems wasteful, but there really aren't that many logical - * variables around, and making them 32 bits could avoid word - * alignment problems, perhaps. */ -/*typedef long int logical;*/ -/*typedef INT32 logical;*/ -/* The following types are not used in the translated C code for the - * LPC-10 coder, but they might be needed by the definitions down - * below, so they don't cause compilation errors. */ -typedef char *address; -typedef struct { real r, i; } complex; -typedef struct { doublereal r, i; } doublecomplex; -typedef short int shortlogical; -typedef char logical1; -typedef char integer1; -/* typedef long long longint; */ /* system-dependent */ - -#define TRUE_ (1) -#define FALSE_ (0) - -/* Extern is for use with -E */ -#ifndef Extern -#define Extern extern -#endif - -/* I/O stuff */ - -#ifdef f2c_i2 -/* for -i2 */ -typedef short flag; -typedef short ftnlen; -typedef short ftnint; -#else -typedef long int flag; -typedef long int ftnlen; -typedef long int ftnint; -#endif - -/*external read, write*/ -typedef struct -{ flag cierr; - ftnint ciunit; - flag ciend; - char *cifmt; - ftnint cirec; -} cilist; - -/*internal read, write*/ -typedef struct -{ flag icierr; - char *iciunit; - flag iciend; - char *icifmt; - ftnint icirlen; - ftnint icirnum; -} icilist; - -/*open*/ -typedef struct -{ flag oerr; - ftnint ounit; - char *ofnm; - ftnlen ofnmlen; - char *osta; - char *oacc; - char *ofm; - ftnint orl; - char *oblnk; -} olist; - -/*close*/ -typedef struct -{ flag cerr; - ftnint cunit; - char *csta; -} cllist; - -/*rewind, backspace, endfile*/ -typedef struct -{ flag aerr; - ftnint aunit; -} alist; - -/* inquire */ -typedef struct -{ flag inerr; - ftnint inunit; - char *infile; - ftnlen infilen; - ftnint *inex; /*parameters in standard's order*/ - ftnint *inopen; - ftnint *innum; - ftnint *innamed; - char *inname; - ftnlen innamlen; - char *inacc; - ftnlen inacclen; - char *inseq; - ftnlen inseqlen; - char *indir; - ftnlen indirlen; - char *infmt; - ftnlen infmtlen; - char *inform; - ftnint informlen; - char *inunf; - ftnlen inunflen; - ftnint *inrecl; - ftnint *innrec; - char *inblank; - ftnlen inblanklen; -} inlist; - -#define VOID void - -union Multitype { /* for multiple entry points */ - integer1 g; - shortint h; - integer i; - /* longint j; */ - real r; - doublereal d; - complex c; - doublecomplex z; - }; - -typedef union Multitype Multitype; - -/*typedef long int Long;*/ /* No longer used; formerly in Namelist */ - -struct Vardesc { /* for Namelist */ - char *name; - char *addr; - ftnlen *dims; - int type; - }; -typedef struct Vardesc Vardesc; - -struct Namelist { - char *name; - Vardesc **vars; - int nvars; - }; -typedef struct Namelist Namelist; - -/* to avoid a conflict on netbsd 3.0 */ -#ifdef abs -#undef abs -#endif - -#define abs(x) ((x) >= 0 ? (x) : -(x)) -#define dabs(x) (doublereal)abs(x) -#define min(a,b) ((a) <= (b) ? (a) : (b)) -#define max(a,b) ((a) >= (b) ? (a) : (b)) -#define dmin(a,b) (doublereal)min(a,b) -#define dmax(a,b) (doublereal)max(a,b) - -/* procedure parameter types for -A and -C++ */ - -#define F2C_proc_par_types 1 -#ifdef __cplusplus -typedef int /* Unknown procedure type */ (*U_fp)(...); -typedef shortint (*J_fp)(...); -typedef integer (*I_fp)(...); -typedef real (*R_fp)(...); -typedef doublereal (*D_fp)(...), (*E_fp)(...); -typedef /* Complex */ VOID (*C_fp)(...); -typedef /* Double Complex */ VOID (*Z_fp)(...); -typedef logical (*L_fp)(...); -typedef shortlogical (*K_fp)(...); -typedef /* Character */ VOID (*H_fp)(...); -typedef /* Subroutine */ int (*S_fp)(...); -#else -typedef int /* Unknown procedure type */ (*U_fp)(); -typedef shortint (*J_fp)(); -typedef integer (*I_fp)(); -typedef real (*R_fp)(); -typedef doublereal (*D_fp)(), (*E_fp)(); -typedef /* Complex */ VOID (*C_fp)(); -typedef /* Double Complex */ VOID (*Z_fp)(); -typedef logical (*L_fp)(); -typedef shortlogical (*K_fp)(); -typedef /* Character */ VOID (*H_fp)(); -typedef /* Subroutine */ int (*S_fp)(); -#endif -/* E_fp is for real functions when -R is not specified */ -typedef VOID C_f; /* complex function */ -typedef VOID H_f; /* character function */ -typedef VOID Z_f; /* double complex function */ -typedef doublereal E_f; /* real function with -R not specified */ - -/* undef any lower-case symbols that your C compiler predefines, e.g.: */ - -#ifndef Skip_f2c_Undefs -#undef cray -#undef gcos -#undef mc68010 -#undef mc68020 -#undef mips -#undef pdp11 -#undef sgi -#undef sparc -#undef sun -#undef sun2 -#undef sun3 -#undef sun4 -#undef u370 -#undef u3b -#undef u3b2 -#undef u3b5 -#undef unix -#undef vax -#endif -#endif diff --git a/linphone/lpc10-1.5/f2clib.c b/linphone/lpc10-1.5/f2clib.c deleted file mode 100644 index 6bd8cdfb3..000000000 --- a/linphone/lpc10-1.5/f2clib.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - -$Log: f2clib.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:13 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:32:10 jaf - * Initial revision - * - -*/ - -/* - * f2clib.c - * - * SCCS ID: @(#)f2clib.c 1.2 96/05/19 - */ - -#include "f2c.h" - -#ifdef KR_headers -integer pow_ii(ap, bp) integer *ap, *bp; -#else -integer pow_ii(integer *ap, integer *bp) -#endif -{ - integer pow, x, n; - unsigned long u; - - x = *ap; - n = *bp; - - if (n <= 0) { - if (n == 0 || x == 1) - return 1; - if (x != -1) - return x == 0 ? 1/x : 0; - n = -n; - } - u = n; - for(pow = 1; ; ) - { - if(u & 01) - pow *= x; - if(u >>= 1) - x *= x; - else - break; - } - return(pow); - } - - - -#ifdef KR_headers -double r_sign(a,b) real *a, *b; -#else -double r_sign(real *a, real *b) -#endif -{ -double x; -x = (*a >= 0 ? *a : - *a); -return( *b >= 0 ? x : -x); -} - - - -#ifdef KR_headers -double floor(); -integer i_nint(x) real *x; -#else -#undef abs -#include "math.h" -integer i_nint(real *x) -#endif -{ -return( (*x)>=0 ? - floor(*x + .5) : -floor(.5 - *x) ); -} diff --git a/linphone/lpc10-1.5/ham84.c b/linphone/lpc10-1.5/ham84.c deleted file mode 100644 index 0b2ab86d5..000000000 --- a/linphone/lpc10-1.5/ham84.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - -$Log: ham84.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:32:07 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int ham84_(integer *input, integer *output, integer *errcnt); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ***************************************************************** */ - -/* HAM84 Version 45G */ - -/* $Log: ham84.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:32:07 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/21 15:26:00 jaf */ -/* Put comment header in standard form. */ - -/* Revision 1.2 1996/03/13 22:00:13 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:47:04 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* Hamming 8,4 Decoder - can correct 1 out of seven bits */ -/* and can detect up to two errors. */ - -/* Input: */ -/* INPUT - Seven bit data word, 4 bits parameter and */ -/* 4 bits parity information */ -/* Input/Output: */ -/* ERRCNT - Sums errors detected by Hamming code */ -/* Output: */ -/* OUTPUT - 4 corrected parameter bits */ - -/* This subroutine is entered with an eight bit word in INPUT. The 8th */ -/* bit is parity and is stripped off. The remaining 7 bits address the */ -/* hamming 8,4 table and the output OUTPUT from the table gives the 4 */ -/* bits of corrected data. If bit 4 is set, no error was detected. */ -/* ERRCNT is the number of errors counted. */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int ham84_(integer *input, integer *output, integer *errcnt) -{ - /* Initialized data */ - - static integer dactab[128] = { 16,0,0,3,0,5,14,7,0,9,14,11,14,13,30,14,0, - 9,2,7,4,7,7,23,9,25,10,9,12,9,14,7,0,5,2,11,5,21,6,5,8,11,11,27, - 12,5,14,11,2,1,18,2,12,5,2,7,12,9,2,11,28,12,12,15,0,3,3,19,4,13, - 6,3,8,13,10,3,13,29,14,13,4,1,10,3,20,4,4,7,10,9,26,10,4,13,10,15, - 8,1,6,3,6,5,22,6,24,8,8,11,8,13,6,15,1,17,2,1,4,1,6,15,8,1,10,15, - 12,15,15,31 }; - - integer i__, j, parity; - -/* Arguments */ -/* Parameters/constants */ -/* Local variables that need not be saved */ -/* Determine parity of input word */ - parity = *input & 255; - parity ^= parity / 16; - parity ^= parity / 4; - parity ^= parity / 2; - parity &= 1; - i__ = dactab[*input & 127]; - *output = i__ & 15; - j = i__ & 16; - if (j != 0) { -/* No errors detected in seven bits */ - if (parity != 0) { - ++(*errcnt); - } - } else { -/* One or two errors detected */ - ++(*errcnt); - if (parity == 0) { -/* Two errors detected */ - ++(*errcnt); - *output = -1; - } - } - return 0; -} /* ham84_ */ - diff --git a/linphone/lpc10-1.5/hp100.c b/linphone/lpc10-1.5/hp100.c deleted file mode 100644 index 51ce4665c..000000000 --- a/linphone/lpc10-1.5/hp100.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - -$Log: hp100.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:28:05 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:32:04 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int hp100_(real *speech, integer *start, integer *end, - struct lpc10_encoder_state *st); -extern int inithp100_(void); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ********************************************************************* */ - -/* HP100 Version 55 */ - -/* $Log: hp100.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:28:05 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:32:04 jaf - * Initial revision - * */ -/* Revision 1.6 1996/03/15 16:45:25 jaf */ -/* Rearranged a few comments. */ - -/* Revision 1.5 1996/03/14 23:20:54 jaf */ -/* Added comments about when INITHP100 should be used. */ - -/* Revision 1.4 1996/03/14 23:08:08 jaf */ -/* Added an entry named INITHP100 that initializes the local state of */ -/* subroutine HP100. */ - -/* Revision 1.3 1996/03/14 22:09:20 jaf */ -/* Comments added explaining which of the local variables of this */ -/* subroutine need to be saved from one invocation to the next, and which */ -/* do not. */ - -/* Revision 1.2 1996/02/12 15:05:54 jaf */ -/* Added lots of comments explaining why I changed one line, which was a */ -/* declaration with initializations. */ - -/* Revision 1.1 1996/02/07 14:47:12 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* 100 Hz High Pass Filter */ - -/* Jan 92 - corrected typo (1.937148 to 1.935715), */ -/* rounded coefficients to 7 places, */ -/* corrected and merged gain (.97466**4), */ -/* merged numerator into first two sections. */ - -/* Input: */ -/* start, end - Range of samples to filter */ -/* Input/Output: */ -/* speech(end) - Speech data. */ -/* Indices start through end are read and modified. */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this filter, or */ -/* reinitialize its state for any other reason, call the ENTRY */ -/* INITHP100. */ -/* Subroutine */ int hp100_(real *speech, integer *start, integer *end, - struct lpc10_encoder_state *st) -{ - /* Temporary local copies of variables in lpc10_encoder_state. - I've only created these because it might cause the loop below - to execute a bit faster to access local variables, rather than - variables in the lpc10_encoder_state structure. It is just a - guess that it will be faster. */ - - real z11; - real z21; - real z12; - real z22; - - /* System generated locals */ - integer i__1; - - /* Local variables */ - integer i__; - real si, err; - -/* Arguments */ -/* Local variables that need not be saved */ -/* Local state */ - /* Parameter adjustments */ - if (speech) { - --speech; - } - - /* Function Body */ - - z11 = st->z11; - z21 = st->z21; - z12 = st->z12; - z22 = st->z22; - - i__1 = *end; - for (i__ = *start; i__ <= i__1; ++i__) { - si = speech[i__]; - err = si + z11 * 1.859076f - z21 * .8648249f; - si = err - z11 * 2.f + z21; - z21 = z11; - z11 = err; - err = si + z12 * 1.935715f - z22 * .9417004f; - si = err - z12 * 2.f + z22; - z22 = z12; - z12 = err; - speech[i__] = si * .902428f; - } - - st->z11 = z11; - st->z21 = z21; - st->z12 = z12; - st->z22 = z22; - - return 0; -} /* hp100_ */ diff --git a/linphone/lpc10-1.5/invert.c b/linphone/lpc10-1.5/invert.c deleted file mode 100644 index 19cbb71ab..000000000 --- a/linphone/lpc10-1.5/invert.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - -$Log: invert.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:32:00 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int invert_(integer *order, real *phi, real *psi, real *rc); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* **************************************************************** */ - -/* INVERT Version 45G */ - -/* $Log: invert.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:32:00 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/18 20:52:47 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 16:51:32 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Eliminated a comment from the original, describing a local array X */ -/* that appeared nowhere in the code. */ - -/* Revision 1.1 1996/02/07 14:47:20 jaf */ -/* Initial revision */ - - -/* **************************************************************** */ - -/* Invert a covariance matrix using Choleski decomposition method. */ - -/* Input: */ -/* ORDER - Analysis order */ -/* PHI(ORDER,ORDER) - Covariance matrix */ -/* Indices (I,J) read, where ORDER .GE. I .GE. J .GE. 1.*/ -/* All other indices untouched. */ -/* PSI(ORDER) - Column vector to be predicted */ -/* Indices 1 through ORDER read. */ -/* Output: */ -/* RC(ORDER) - Pseudo reflection coefficients */ -/* Indices 1 through ORDER written, and then possibly read. -*/ -/* Internal: */ -/* V(ORDER,ORDER) - Temporary matrix */ -/* Same indices written as read from PHI. */ -/* Many indices may be read and written again after */ -/* initially being copied from PHI, but all indices */ -/* are written before being read. */ - -/* NOTE: Temporary matrix V is not needed and may be replaced */ -/* by PHI if the original PHI values do not need to be preserved. */ - -/* Subroutine */ int invert_(integer *order, real *phi, real *psi, real *rc) -{ - /* System generated locals */ - integer phi_dim1, phi_offset, i__1, i__2, i__3; - real r__1, r__2; - - /* Local variables */ - real save; - integer i__, j, k; - real v[100] /* was [10][10] */; - -/* Arguments */ -/* $Log: invert.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:32:00 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Parameters/constants */ -/* Local variables that need not be saved */ -/* Decompose PHI into V * D * V' where V is a triangular matrix whose */ -/* main diagonal elements are all 1, V' is the transpose of V, and */ -/* D is a vector. Here D(n) is stored in location V(n,n). */ - /* Parameter adjustments */ - --rc; - --psi; - phi_dim1 = *order; - phi_offset = phi_dim1 + 1; - phi -= phi_offset; - - /* Function Body */ - i__1 = *order; - for (j = 1; j <= i__1; ++j) { - i__2 = *order; - for (i__ = j; i__ <= i__2; ++i__) { - v[i__ + j * 10 - 11] = phi[i__ + j * phi_dim1]; - } - i__2 = j - 1; - for (k = 1; k <= i__2; ++k) { - save = v[j + k * 10 - 11] * v[k + k * 10 - 11]; - i__3 = *order; - for (i__ = j; i__ <= i__3; ++i__) { - v[i__ + j * 10 - 11] -= v[i__ + k * 10 - 11] * save; - } - } -/* Compute intermediate results, which are similar to RC's */ - if ((r__1 = v[j + j * 10 - 11], abs(r__1)) < 1e-10f) { - goto L100; - } - rc[j] = psi[j]; - i__2 = j - 1; - for (k = 1; k <= i__2; ++k) { - rc[j] -= rc[k] * v[j + k * 10 - 11]; - } - v[j + j * 10 - 11] = 1.f / v[j + j * 10 - 11]; - rc[j] *= v[j + j * 10 - 11]; -/* Computing MAX */ -/* Computing MIN */ - r__2 = rc[j]; - r__1 = min(r__2,.999f); - rc[j] = max(r__1,-.999f); - } - return 0; -/* Zero out higher order RC's if algorithm terminated early */ -L100: - i__1 = *order; - for (i__ = j; i__ <= i__1; ++i__) { - rc[i__] = 0.f; - } -/* Back substitute for PC's (if needed) */ -/* 110 DO J = ORDER,1,-1 */ -/* PC(J) = RC(J) */ -/* DO I = 1,J-1 */ -/* PC(J) = PC(J) - PC(I)*V(J,I) */ -/* END DO */ -/* END DO */ - return 0; -} /* invert_ */ - diff --git a/linphone/lpc10-1.5/irc2pc.c b/linphone/lpc10-1.5/irc2pc.c deleted file mode 100644 index df563735e..000000000 --- a/linphone/lpc10-1.5/irc2pc.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - -$Log: irc2pc.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:31:56 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int irc2pc_(real *rc, real *pc, integer *order, real *gprime, real *g2pass); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ***************************************************************** */ - -/* IRC2PC Version 48 */ - -/* $Log: irc2pc.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:31:56 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/20 15:47:19 jaf */ -/* Added comments about which indices of array arguments are read or */ -/* written. */ - -/* Revision 1.2 1996/03/14 16:59:04 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:47:27 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* Convert Reflection Coefficients to Predictor Coeficients */ - -/* Inputs: */ -/* RC - Reflection coefficients */ -/* Indices 1 through ORDER read. */ -/* ORDER - Number of RC's */ -/* GPRIME - Excitation modification gain */ -/* Outputs: */ -/* PC - Predictor coefficients */ -/* Indices 1 through ORDER written. */ -/* Indices 1 through ORDER-1 are read after being written. */ -/* G2PASS - Excitation modification sharpening factor */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int irc2pc_(real *rc, real *pc, integer *order, real *gprime, - real *g2pass) -{ - /* System generated locals */ - integer i__1, i__2; - - /* Builtin functions */ - double sqrt(doublereal); - - /* Local variables */ - real temp[10]; - integer i__, j; - -/* Arguments */ -/* $Log: irc2pc.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:31:56 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Local variables that need not be saved */ - /* Parameter adjustments */ - --pc; - --rc; - - /* Function Body */ - *g2pass = 1.f; - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - *g2pass *= 1.f - rc[i__] * rc[i__]; - } - *g2pass = *gprime * sqrt(*g2pass); - pc[1] = rc[1]; - i__1 = *order; - for (i__ = 2; i__ <= i__1; ++i__) { - i__2 = i__ - 1; - for (j = 1; j <= i__2; ++j) { - temp[j - 1] = pc[j] - rc[i__] * pc[i__ - j]; - } - i__2 = i__ - 1; - for (j = 1; j <= i__2; ++j) { - pc[j] = temp[j - 1]; - } - pc[i__] = rc[i__]; - } - return 0; -} /* irc2pc_ */ - diff --git a/linphone/lpc10-1.5/ivfilt.c b/linphone/lpc10-1.5/ivfilt.c deleted file mode 100644 index 18e229b7d..000000000 --- a/linphone/lpc10-1.5/ivfilt.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - -$Log: ivfilt.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:31:53 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer *nsamp, real *ivrc); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ********************************************************************* */ - -/* IVFILT Version 48 */ - -/* $Log: ivfilt.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:31:53 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/15 21:36:29 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 00:01:00 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:47:34 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* 2nd order inverse filter, speech is decimated 4:1 */ - -/* Input: */ -/* LEN - Length of speech buffers */ -/* NSAMP - Number of samples to filter */ -/* LPBUF - Low pass filtered speech buffer */ -/* Indices LEN-NSAMP-7 through LEN read. */ -/* Output: */ -/* IVBUF - Inverse filtered speech buffer */ -/* Indices LEN-NSAMP+1 through LEN written. */ -/* IVRC - Inverse filter reflection coefficients (for voicing) */ -/* Indices 1 and 2 both written (also read, but only after writing). -*/ - -/* This subroutine has no local state. */ - -/* Subroutine */ int ivfilt_(real *lpbuf, real *ivbuf, integer *len, integer * - nsamp, real *ivrc) -{ - /* System generated locals */ - integer i__1; - - /* Local variables */ - integer i__, j, k; - real r__[3], pc1, pc2; - -/* Arguments */ -/* Local variables that need not be saved */ -/* Local state */ -/* None */ -/* Calculate Autocorrelations */ - /* Parameter adjustments */ - --ivbuf; - --lpbuf; - --ivrc; - - /* Function Body */ - for (i__ = 1; i__ <= 3; ++i__) { - r__[i__ - 1] = 0.f; - k = i__ - 1 << 2; - i__1 = *len; - for (j = (i__ << 2) + *len - *nsamp; j <= i__1; j += 2) { - r__[i__ - 1] += lpbuf[j] * lpbuf[j - k]; - } - } -/* Calculate predictor coefficients */ - pc1 = 0.f; - pc2 = 0.f; - ivrc[1] = 0.f; - ivrc[2] = 0.f; - if (r__[0] > 1e-10f) { - ivrc[1] = r__[1] / r__[0]; - ivrc[2] = (r__[2] - ivrc[1] * r__[1]) / (r__[0] - ivrc[1] * r__[1]); - pc1 = ivrc[1] - ivrc[1] * ivrc[2]; - pc2 = ivrc[2]; - } -/* Inverse filter LPBUF into IVBUF */ - i__1 = *len; - for (i__ = *len + 1 - *nsamp; i__ <= i__1; ++i__) { - ivbuf[i__] = lpbuf[i__] - pc1 * lpbuf[i__ - 4] - pc2 * lpbuf[i__ - 8]; - } - return 0; -} /* ivfilt_ */ - diff --git a/linphone/lpc10-1.5/lpc10.h b/linphone/lpc10-1.5/lpc10.h deleted file mode 100644 index 4ece9f07f..000000000 --- a/linphone/lpc10-1.5/lpc10.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - -$Log: lpc10.h,v $ -Revision 1.1.1.1 2001/11/19 19:50:13 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:47:31 jaf - * Initial revision - * - -*/ - -#ifndef __LPC10_H__ -#define __LPC10_H__ - -#define LPC10_SAMPLES_PER_FRAME 180 -#define LPC10_BITS_IN_COMPRESSED_FRAME 54 - - -/* - - The "#if defined"'s in this file are by no means intended to be - complete. They are what Nautilus uses, which has been successfully - compiled under DOS with the Microsoft C compiler, and under a few - versions of Unix with the GNU C compiler. - - */ - - -typedef short INT16; -typedef int INT32; - - -#if defined(__MSDOS__) || defined(MSDOS) -typedef int INT16; -typedef long INT32; -#endif - - - -/* The initial values for every member of this structure is 0, except - where noted in comments. */ - -/* These two lines are copied from f2c.h. There should be a more - elegant way of doing this than having the same declarations in two - files. */ - -typedef float real; -typedef INT32 integer; -typedef INT32 logical; -typedef INT16 shortint; - -struct lpc10_encoder_state { - /* State used only by function hp100 */ - real z11; - real z21; - real z12; - real z22; - - /* State used by function analys */ - real inbuf[540], pebuf[540]; - real lpbuf[696], ivbuf[312]; - real bias; - integer osbuf[10]; /* no initial value necessary */ - integer osptr; /* initial value 1 */ - integer obound[3]; - integer vwin[6] /* was [2][3] */; /* initial value vwin[4] = 307; vwin[5] = 462; */ - integer awin[6] /* was [2][3] */; /* initial value awin[4] = 307; awin[5] = 462; */ - integer voibuf[8] /* was [2][4] */; - real rmsbuf[3]; - real rcbuf[30] /* was [10][3] */; - real zpre; - - - /* State used by function onset */ - real n; - real d__; /* initial value 1.f */ - real fpc; /* no initial value necessary */ - real l2buf[16]; - real l2sum1; - integer l2ptr1; /* initial value 1 */ - integer l2ptr2; /* initial value 9 */ - integer lasti; /* no initial value necessary */ - logical hyst; /* initial value FALSE_ */ - - /* State used by function voicin */ - real dither; /* initial value 20.f */ - real snr; - real maxmin; - real voice[6] /* was [2][3] */; /* initial value is probably unnecessary */ - integer lbve, lbue, fbve, fbue; - integer ofbue, sfbue; - integer olbue, slbue; - /* Initial values: - lbve = 3000; - fbve = 3000; - fbue = 187; - ofbue = 187; - sfbue = 187; - lbue = 93; - olbue = 93; - slbue = 93; - snr = (real) (fbve / fbue << 6); - */ - - /* State used by function dyptrk */ - real s[60]; - integer p[120] /* was [60][2] */; - integer ipoint; - real alphax; - - /* State used by function chanwr */ - integer isync; - -}; - - -struct lpc10_decoder_state { - - /* State used by function decode */ - integer iptold; /* initial value 60 */ - logical first; /* initial value TRUE_ */ - integer ivp2h; - integer iovoic; - integer iavgp; /* initial value 60 */ - integer erate; - integer drc[30] /* was [3][10] */; - integer dpit[3]; - integer drms[3]; - - /* State used by function synths */ - real buf[360]; - integer buflen; /* initial value 180 */ - - /* State used by function pitsyn */ - integer ivoico; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ - integer ipito; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ - real rmso; /* initial value 1.f */ - real rco[10]; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ - integer jsamp; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ - logical first_pitsyn; /* initial value TRUE_ */ - - /* State used by function bsynz */ - integer ipo; - real exc[166]; - real exc2[166]; - real lpi1; - real lpi2; - real lpi3; - real hpi1; - real hpi2; - real hpi3; - real rmso_bsynz; - - /* State used by function random */ - integer j; /* initial value 2 */ - integer k; /* initial value 5 */ - shortint y[5]; /* initial value { -21161,-8478,30892,-10216,16950 } */ - - /* State used by function deemp */ - real dei1; - real dei2; - real deo1; - real deo2; - real deo3; - -}; - - - -/* - - Calling sequence: - - Call create_lpc10_encoder_state(), which returns a pointer to an - already initialized lpc10_encoder_state structure. - - lpc10_encode reads indices 0 through (LPC10_SAMPLES_PER_FRAME-1) of - array speech[], and writes indices 0 through - (LPC10_BITS_IN_COMPRESSED_FRAME-1) of array bits[], and both reads - and writes the lpc10_encoder_state structure contents. The - lpc10_encoder_state structure should *not* be initialized for every - frame of encoded speech. Once at the beginning of execution, done - automatically for you by create_lpc10_encoder_state(), is enough. - - init_lpc10_encoder_state() reinitializes the lpc10_encoder_state - structure. This might be useful if you are finished processing one - sound sample, and want to reuse the same lpc10_encoder_state - structure to process another sound sample. There might be other - uses as well. - - Note that the comments in the lpc10/lpcenc.c file imply that indices - 1 through 180 of array speech[] are read. These comments were - written for the Fortran version of the code, before it was - automatically converted to C by the conversion program f2c. f2c - seems to use the convention that the pointers to arrays passed as - function arguments point to the first index used in the Fortran - code, whatever index that might be (usually 1), and then it modifies - the pointer inside of the function, like so: - - if (speech) { - --speech; - } - - So that the code can access the first value at index 1 and the last - at index 180. This makes the translated C code "closer" to the - original Fortran code. - - The calling sequence for the decoder is similar to the encoder. The - only significant difference is that the array bits[] is read - (indices 0 through (LPC10_BITS_IN_COMPRESSED_FRAME-1)), and the - array speech[] is written (indices 0 through - (LPC10_SAMPLES_PER_FRAME-1)). - - */ - -struct lpc10_encoder_state * create_lpc10_encoder_state (); -void init_lpc10_encoder_state (struct lpc10_encoder_state *st); -int lpc10_encode (real *speech, INT32 *bits, struct lpc10_encoder_state *st); - -struct lpc10_decoder_state * create_lpc10_decoder_state (); -void init_lpc10_decoder_state (struct lpc10_decoder_state *st); -int lpc10_decode (INT32 *bits, real *speech, struct lpc10_decoder_state *st); - -#endif /* __LPC10_H__ */ diff --git a/linphone/lpc10-1.5/lpc10_wrapper.c b/linphone/lpc10-1.5/lpc10_wrapper.c deleted file mode 100644 index 333b81f89..000000000 --- a/linphone/lpc10-1.5/lpc10_wrapper.c +++ /dev/null @@ -1,229 +0,0 @@ -#include -#include -#include -#include "lpc10_wrapper.h" -#include - -/* the public codec_info_t*/ - -struct codec_info LPC10codec_info= -{ - "LPC10-1.5", - LPC10_SAMPLES_PER_FRAME*2, /* size in bytes of the uncompressed frame*/ - ((LPC10_BITS_IN_COMPRESSED_FRAME/8) + 1), /* 7 bytes */ /* size in bytes of compressed frame*/ - 2400, /* bit rate*/ - {{ - 8000 - }}, /* audio sampling freq*/ - LPC10codec_new, /* codec constructor*/ - 115, /* payload type */ - "lpc10-15/8000/1", /*description */ - CODEC_AUDIO, /* type*/ - 0, /*usable, set later*/ - 1 /*usable for user, default value*/ -}; - -/* The return value of each of these calls is the same as that - returned by fread/fwrite, which should be the number of samples - successfully read/written, not the number of bytes. */ - -static int -read_16bit_samples(INT16 int16samples[], float speech[], int n) -{ - int i; - - /* Convert 16 bit integer samples to floating point values in the - range [-1,+1]. */ - - for (i = 0; i < n; i++) { - speech[i] = ((float) int16samples[i]) / 32768.0; - } - - return (n); -} - - - -static int -write_16bit_samples(INT16 int16samples[], float speech[], int n) -{ - int i; - float real_sample; - - /* Convert floating point samples in range [-1,+1] to 16 bit - integers. */ - for (i = 0; i < n; i++) { - real_sample = 32768.0 * speech[i]; - if (real_sample < -32768.0) { - int16samples[i] = -32768; - } else if (real_sample > 32767.0) { - int16samples[i] = 32767; - } else { - int16samples[i] = real_sample; - } - } - return (n); -} - -/* - -Write the bits in bits[0] through bits[len-1] to file f, in "packed" -format. - -bits is expected to be an array of len integer values, where each -integer is 0 to represent a 0 bit, and any other value represents a 1 -bit. This bit string is written to the file f in the form of several -8 bit characters. If len is not a multiple of 8, then the last -character is padded with 0 bits -- the padding is in the least -significant bits of the last byte. The 8 bit characters are "filled" -in order from most significant bit to least significant. - -*/ - -static void -write_bits(unsigned char *data, INT32 *bits, int len) -{ - int i; /* generic loop variable */ - unsigned char mask; /* The next bit position within the - variable "data" to place the next - bit. */ - - - /* Fill in the array bits. - * The first compressed output bit will be the most significant - * bit of the byte, so initialize mask to 0x80. The next byte of - * compressed data is initially 0, and the desired bits will be - * turned on below. - */ - mask = 0x80; - *data = 0; - - for (i = 0; i < len; i++) { - /* Turn on the next bit of output data, if necessary. */ - if (bits[i]) { - (*data) |= mask; - } - /* - * If the byte data is full, determined by mask becoming 0, - * then write the byte to the output file, and reinitialize - * data and mask for the next output byte. Also add the byte - * if (i == len-1), because if len is not a multiple of 8, - * then mask won't yet be 0. */ - mask >>= 1; - if ((mask == 0) || (i == len-1)) { - data++; - *data = 0; - mask = 0x80; - } - } -} - - - -/* - -Read bits from file f into bits[0] through bits[len-1], in "packed" -format. - -Read ceiling(len/8) characters from file f, if that many are available -to read, otherwise read to the end of the file. The first character's -8 bits, in order from MSB to LSB, are used to fill bits[0] through -bits[7]. The second character's bits are used to fill bits[8] through -bits[15], and so on. If ceiling(len/8) characters are available to -read, and len is not a multiple of 8, then some of the least -significant bits of the last character read are completely ignored. -Every entry of bits[] that is modified is changed to either a 0 or a -1. - -The number of bits successfully read is returned, and is always in the -range 0 to len, inclusive. If it is less than len, it will always be -a multiple of 8. - -*/ - -static int -read_bits(unsigned char *data, INT32 *bits, int len) -{ - int i,ind=0; /* generic loop variable */ - int c=0; - - /* Unpack the array bits into coded_frame. */ - for (i = 0; i < len; i++) { - if ((i % 8) == 0) { - c = (int)(data[ind]); - ind++; - } - if (c & (0x80 >> (i & 7))) { - bits[i] = 1; - } else { - bits[i] = 0; - } - } - return (len); -} - - - - -Codec *LPC10codec_new() -{ - LPC10Codec *obj; - - obj=(LPC10Codec*)malloc(sizeof(LPC10Codec)); - obj->baseclass._getinfo=&wlpc10_getinfo; - obj->baseclass._encode=&wlpc10_encode; - obj->baseclass._decode=&wlpc10_decode; - obj->baseclass._destroy=&wlpc10_destroy; - - obj->enc = create_lpc10_encoder_state(); - if (obj->enc == NULL) { - fprintf(stderr, "Couldn't allocate %d bytes for encoder state.\n", - sizeof(struct lpc10_encoder_state)); - return(NULL); - } - obj->dec = create_lpc10_decoder_state(); - if (obj->dec == NULL) { - fprintf(stderr, "Couldn't allocate %d bytes for decoder state.\n", - sizeof(struct lpc10_decoder_state)); - return(NULL); - } - return((Codec*)obj); -} - - - - -void wlpc10_getinfo(Codec *codec, struct codec_info *info) -{ - memcpy(info,&LPC10codec_info,sizeof(struct codec_info)); -} -void wlpc10_encode(Codec *codec, char *frame, char *data) -{ - float speech[LPC10_SAMPLES_PER_FRAME]; - INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME]; - LPC10Codec *obj=(LPC10Codec*)codec; /* we should make a few check to see if this codec is a LPC10...*/ - - read_16bit_samples((INT16*)frame, speech, LPC10_SAMPLES_PER_FRAME); - lpc10_encode(speech, bits, obj->enc); - write_bits(data, bits, LPC10_BITS_IN_COMPRESSED_FRAME); -} - -void wlpc10_decode(Codec *codec,char *data, char *frame) -{ - float speech[LPC10_SAMPLES_PER_FRAME]; - INT32 bits[LPC10_BITS_IN_COMPRESSED_FRAME]; - LPC10Codec *obj=(LPC10Codec*)codec; /* we should make a few check to see if this codec is a LPC10...*/ - - read_bits(data, bits, LPC10_BITS_IN_COMPRESSED_FRAME); - lpc10_decode(bits,speech, obj->dec); - write_16bit_samples((INT16*)frame, speech, LPC10_SAMPLES_PER_FRAME); -} - -void wlpc10_destroy(Codec *codec) -{ - LPC10Codec *obj=(LPC10Codec*)codec; /* we should make a few check to see if this codec is a LPC10...*/ - - free(obj->enc); - free(obj->dec); - free(obj); -} \ No newline at end of file diff --git a/linphone/lpc10-1.5/lpc10_wrapper.h b/linphone/lpc10-1.5/lpc10_wrapper.h deleted file mode 100644 index 73241b169..000000000 --- a/linphone/lpc10-1.5/lpc10_wrapper.h +++ /dev/null @@ -1,34 +0,0 @@ -#include "../console/codec.h" -#include "lpc10.h" - - -/* -int read_16bit_samples(INT16 int16samples[], float speech[], int n); -int write_16bit_samples(INT16 int16samples[], float speech[], int n); - - -void write_bits(unsigned char *data, INT32 *bits, int len); -int read_bits(unsigned char *data, INT32 *bits, int len); -*/ - -/* the following code has been added by Simon MORLAT to make lpc10 interface compatible with linphone*/ - -/*Class definition*/ - -typedef struct _LPC10Codec -{ - Codec baseclass; /* Codec must be the first element of the structure in order to have the object mechanism to work*/ - struct lpc10_encoder_state *enc; - struct lpc10_decoder_state *dec; -} LPC10Codec; - -/* this the constructor for derivate class LPC10Codec*/ -Codec *LPC10codec_new(); - -extern struct codec_info LPC10codec_info; - -/* these are the overrides for the base class 's functions*/ -void wlpc10_getinfo(Codec *codec,struct codec_info *info); -void wlpc10_encode(Codec *codec,char *frame, char *data); -void wlpc10_decode(Codec *codec,char *data, char *frame); -void wlpc10_destroy(Codec *codec); diff --git a/linphone/lpc10-1.5/lpcdec.c b/linphone/lpc10-1.5/lpcdec.c deleted file mode 100644 index 30cdba65b..000000000 --- a/linphone/lpc10-1.5/lpcdec.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - -$Log: lpcdec.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:30:11 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Changed name of function from lpcenc_ to lpc10_encode, simply to make - * all lpc10 functions have more consistent naming with each other. - * - * Revision 1.1 1996/08/19 22:31:48 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int lpcdec_(integer *bits, real *speech); -extern int initlpcdec_(void); -/* comlen contrl_ 12 */ -/*:ref: chanrd_ 14 5 4 4 4 4 4 */ -/*:ref: decode_ 14 7 4 4 4 4 4 6 6 */ -/*:ref: synths_ 14 6 4 4 6 6 6 4 */ -/*:ref: initdecode_ 14 0 */ -/*:ref: initsynths_ 14 0 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Common Block Declarations */ - -extern struct { - integer order, lframe; - logical corrp; -} contrl_; - -#define contrl_1 contrl_ - -/* Table of constant values */ - -static integer c__10 = 10; - -/* ***************************************************************** */ - -/* $Log: lpcdec.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:30:11 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Changed name of function from lpcenc_ to lpc10_encode, simply to make - * all lpc10 functions have more consistent naming with each other. - * - * Revision 1.1 1996/08/19 22:31:48 jaf - * Initial revision - * */ -/* Revision 1.1 1996/03/28 00:03:00 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* Decode 54 bits to one frame of 180 speech samples. */ - -/* Input: */ -/* BITS - 54 encoded bits, stored 1 per array element. */ -/* Indices 1 through 53 read (SYNC bit ignored). */ -/* Output: */ -/* SPEECH - Speech encoded as real values in the range [-1,+1]. */ -/* Indices 1 through 180 written. */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this filter, or */ -/* reinitialize its state for any other reason, call the ENTRY */ -/* INITLPCDEC. */ - -/* Subroutine */ int lpc10_decode(integer *bits, real *speech, - struct lpc10_decoder_state *st) -{ - integer irms, voice[2], pitch, ipitv; - extern /* Subroutine */ int decode_(integer *, integer *, integer *, - integer *, integer *, real *, real *, struct lpc10_decoder_state *); - real rc[10]; - extern /* Subroutine */ int chanrd_(integer *, integer *, integer *, - integer *, integer *), synths_(integer *, - integer *, real *, real *, real *, integer *, - struct lpc10_decoder_state *); - integer irc[10], len; - real rms; - -/* $Log: lpcdec.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:30:11 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Changed name of function from lpcenc_ to lpc10_encode, simply to make - * all lpc10 functions have more consistent naming with each other. - * - * Revision 1.1 1996/08/19 22:31:48 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Arguments */ -/* $Log: lpcdec.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:30:11 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Changed name of function from lpcenc_ to lpc10_encode, simply to make - * all lpc10 functions have more consistent naming with each other. - * - * Revision 1.1 1996/08/19 22:31:48 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:05:55 jaf */ -/* Commented out the common block variables that are not needed by the */ -/* embedded version. */ - -/* Revision 1.2 1996/03/26 19:34:50 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:44:09 jaf */ -/* Initial revision */ - -/* LPC Processing control variables: */ - -/* *** Read-only: initialized in setup */ - -/* Files for Speech, Parameter, and Bitstream Input & Output, */ -/* and message and debug outputs. */ - -/* Here are the only files which use these variables: */ - -/* lpcsim.f setup.f trans.f error.f vqsetup.f */ - -/* Many files which use fdebug are not listed, since it is only used in */ -/* those other files conditionally, to print trace statements. */ -/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* LPC order, Frame size, Quantization rate, Bits per frame, */ -/* Error correction */ -/* Subroutine SETUP is the only place where order is assigned a value, */ -/* and that value is 10. It could increase efficiency 1% or so to */ -/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as -*/ -/* a variable in a COMMON block, since it is used in many places in the */ -/* core of the coding and decoding routines. Actually, I take that back. -*/ -/* At least when compiling with f2c, the upper bound of DO loops is */ -/* stored in a local variable before the DO loop begins, and then that is -*/ -/* compared against on each iteration. */ -/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ -/* Similarly for quant, which is given a value of 2400 in SETUP. quant */ -/* is used in only a few places, and never in the core coding and */ -/* decoding routines, so it could be eliminated entirely. */ -/* nbits is similar to quant, and is given a value of 54 in SETUP. */ -/* corrp is given a value of .TRUE. in SETUP, and is only used in the */ -/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ -/* coder significantly whether it is .TRUE. or .FALSE., or whether it is -*/ -/* a constant or a variable, since it is only examined once per frame. */ -/* Leaving it as a variable that is set to .TRUE. seems like a good */ -/* idea, since it does enable some error-correction capability for */ -/* unvoiced frames, with no change in the coding rate, and no noticeable -*/ -/* quality difference in the decoded speech. */ -/* integer quant, nbits */ -/* *** Read/write: variables for debugging, not needed for LPC algorithm -*/ - -/* Current frame, Unstable frames, Output clip count, Max onset buffer, -*/ -/* Debug listing detail level, Line count on listing page */ - -/* nframe is not needed for an embedded LPC10 at all. */ -/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ -/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ -/* an application, I would recommend removing the call to ERROR in RCCHK, -*/ -/* and remove ERROR and nunsfm completely. */ -/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in -*/ -/* sread.f. When LPC10 is embedded into an application, one might want */ -/* to cause it to be incremented in a routine that takes the output of */ -/* SYNTHS and sends it to an audio device. It could be optionally */ -/* displayed, for those that might want to know what it is. */ -/* maxosp is never initialized to 0 in SETUP, although it probably should -*/ -/* be, and it is updated in subroutine ANALYS. I doubt that its value */ -/* would be of much interest to an application in which LPC10 is */ -/* embedded. */ -/* listl and lincnt are not needed for an embedded LPC10 at all. */ -/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* common /contrl/ quant, nbits */ -/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* Local variables that need not be saved */ -/* Uncoded speech parameters */ -/* Coded speech parameters */ -/* Others */ -/* Local state */ -/* None */ - /* Parameter adjustments */ - if (bits) { - --bits; - } - if (speech) { - --speech; - } - - /* Function Body */ - - chanrd_(&c__10, &ipitv, &irms, irc, &bits[1]); - decode_(&ipitv, &irms, irc, voice, &pitch, &rms, rc, st); - synths_(voice, &pitch, &rms, rc, &speech[1], &len, st); - return 0; -} /* lpcdec_ */ diff --git a/linphone/lpc10-1.5/lpcenc.c b/linphone/lpc10-1.5/lpcenc.c deleted file mode 100644 index 7805a0e8c..000000000 --- a/linphone/lpc10-1.5/lpcenc.c +++ /dev/null @@ -1,163 +0,0 @@ -/* - -$Log: lpcenc.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:31:21 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Changed name of function from lpcenc_ to lpc10_encode, simply to make - * all lpc10 functions have more consistent naming with each other. - * - * Revision 1.1 1996/08/19 22:31:44 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int lpcenc_(real *speech, integer *bits); -extern int initlpcenc_(void); -/*:ref: prepro_ 14 2 6 4 */ -/*:ref: analys_ 14 5 6 4 4 6 6 */ -/*:ref: encode_ 14 7 4 4 6 6 4 4 4 */ -/*:ref: chanwr_ 14 5 4 4 4 4 4 */ -/*:ref: initprepro_ 14 0 */ -/*:ref: initanalys_ 14 0 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Table of constant values */ - -static integer c__180 = 180; -static integer c__10 = 10; - -/* ***************************************************************** */ - -/* $Log: lpcenc.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:31:21 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Changed name of function from lpcenc_ to lpc10_encode, simply to make - * all lpc10 functions have more consistent naming with each other. - * - * Revision 1.1 1996/08/19 22:31:44 jaf - * Initial revision - * */ -/* Revision 1.2 1996/03/28 00:01:22 jaf */ -/* Commented out some trace statements. */ - -/* Revision 1.1 1996/03/28 00:00:27 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* Encode one frame of 180 speech samples to 54 bits. */ - -/* Input: */ -/* SPEECH - Speech encoded as real values in the range [-1,+1]. */ -/* Indices 1 through 180 read, and modified (by PREPRO). */ -/* Output: */ -/* BITS - 54 encoded bits, stored 1 per array element. */ -/* Indices 1 through 54 written. */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this filter, or */ -/* reinitialize its state for any other reason, call the ENTRY */ -/* INITLPCENC. */ - -/* Subroutine */ int lpc10_encode(real *speech, integer *bits, - struct lpc10_encoder_state *st) -{ - integer irms, voice[2], pitch, ipitv; - real rc[10]; - extern /* Subroutine */ int encode_(integer *, integer *, real *, real *, - integer *, integer *, integer *), chanwr_(integer *, integer *, - integer *, integer *, integer *, struct lpc10_encoder_state *), - analys_(real *, integer *, - integer *, real *, real *, struct lpc10_encoder_state *), - prepro_(real *, integer *, struct lpc10_encoder_state *); - integer irc[10]; - real rms; - -/* Arguments */ -/* $Log: lpcenc.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:31:21 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Changed name of function from lpcenc_ to lpc10_encode, simply to make - * all lpc10 functions have more consistent naming with each other. - * - * Revision 1.1 1996/08/19 22:31:44 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Local variables that need not be saved */ -/* Uncoded speech parameters */ -/* Coded speech parameters */ -/* Local state */ -/* None */ - /* Parameter adjustments */ - if (speech) { - --speech; - } - if (bits) { - --bits; - } - - /* Function Body */ - prepro_(&speech[1], &c__180, st); - analys_(&speech[1], voice, &pitch, &rms, rc, st); - encode_(voice, &pitch, &rms, rc, &ipitv, &irms, irc); - chanwr_(&c__10, &ipitv, &irms, irc, &bits[1], st); - return 0; -} /* lpcenc_ */ diff --git a/linphone/lpc10-1.5/lpcini.c b/linphone/lpc10-1.5/lpcini.c deleted file mode 100644 index 6d88bfb75..000000000 --- a/linphone/lpc10-1.5/lpcini.c +++ /dev/null @@ -1,399 +0,0 @@ -/* - -$Log: lpcini.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:35:41 jaf - * Added functions for allocating and initializing lpc10_encoder_state - * and lpc10_decoder_state structures. - * - * Revision 1.1 1996/08/19 22:31:40 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int lpcini_(void); -/* comlen contrl_ 12 */ -/*:ref: initlpcenc_ 14 0 */ -/*:ref: initlpcdec_ 14 0 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -#include - -/* Common Block Declarations */ - -struct { - integer order, lframe; - logical corrp; -} contrl_; - -#define contrl_1 contrl_ - -/* ***************************************************************** */ - -/* $Log: lpcini.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:35:41 jaf - * Added functions for allocating and initializing lpc10_encoder_state - * and lpc10_decoder_state structures. - * - * Revision 1.1 1996/08/19 22:31:40 jaf - * Initial revision - * */ -/* Revision 1.1 1996/03/28 00:04:05 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* Initialize COMMON block variables used by LPC-10 encoder and decoder, */ -/* and call initialization routines for both of them. */ - -/* Subroutine */ int lpcini_(void) -{ - -/* $Log: lpcini.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:35:41 jaf - * Added functions for allocating and initializing lpc10_encoder_state - * and lpc10_decoder_state structures. - * - * Revision 1.1 1996/08/19 22:31:40 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* $Log: lpcini.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:35:41 jaf - * Added functions for allocating and initializing lpc10_encoder_state - * and lpc10_decoder_state structures. - * - * Revision 1.1 1996/08/19 22:31:40 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:05:55 jaf */ -/* Commented out the common block variables that are not needed by the */ -/* embedded version. */ - -/* Revision 1.2 1996/03/26 19:34:50 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:44:09 jaf */ -/* Initial revision */ - -/* LPC Processing control variables: */ - -/* *** Read-only: initialized in setup */ - -/* Files for Speech, Parameter, and Bitstream Input & Output, */ -/* and message and debug outputs. */ - -/* Here are the only files which use these variables: */ - -/* lpcsim.f setup.f trans.f error.f vqsetup.f */ - -/* Many files which use fdebug are not listed, since it is only used in */ -/* those other files conditionally, to print trace statements. */ -/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* LPC order, Frame size, Quantization rate, Bits per frame, */ -/* Error correction */ -/* Subroutine SETUP is the only place where order is assigned a value, */ -/* and that value is 10. It could increase efficiency 1% or so to */ -/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as -*/ -/* a variable in a COMMON block, since it is used in many places in the */ -/* core of the coding and decoding routines. Actually, I take that back. -*/ -/* At least when compiling with f2c, the upper bound of DO loops is */ -/* stored in a local variable before the DO loop begins, and then that is -*/ -/* compared against on each iteration. */ -/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ -/* Similarly for quant, which is given a value of 2400 in SETUP. quant */ -/* is used in only a few places, and never in the core coding and */ -/* decoding routines, so it could be eliminated entirely. */ -/* nbits is similar to quant, and is given a value of 54 in SETUP. */ -/* corrp is given a value of .TRUE. in SETUP, and is only used in the */ -/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ -/* coder significantly whether it is .TRUE. or .FALSE., or whether it is -*/ -/* a constant or a variable, since it is only examined once per frame. */ -/* Leaving it as a variable that is set to .TRUE. seems like a good */ -/* idea, since it does enable some error-correction capability for */ -/* unvoiced frames, with no change in the coding rate, and no noticeable -*/ -/* quality difference in the decoded speech. */ -/* integer quant, nbits */ -/* *** Read/write: variables for debugging, not needed for LPC algorithm -*/ - -/* Current frame, Unstable frames, Output clip count, Max onset buffer, -*/ -/* Debug listing detail level, Line count on listing page */ - -/* nframe is not needed for an embedded LPC10 at all. */ -/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ -/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ -/* an application, I would recommend removing the call to ERROR in RCCHK, -*/ -/* and remove ERROR and nunsfm completely. */ -/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in -*/ -/* sread.f. When LPC10 is embedded into an application, one might want */ -/* to cause it to be incremented in a routine that takes the output of */ -/* SYNTHS and sends it to an audio device. It could be optionally */ -/* displayed, for those that might want to know what it is. */ -/* maxosp is never initialized to 0 in SETUP, although it probably should -*/ -/* be, and it is updated in subroutine ANALYS. I doubt that its value */ -/* would be of much interest to an application in which LPC10 is */ -/* embedded. */ -/* listl and lincnt are not needed for an embedded LPC10 at all. */ -/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* common /contrl/ quant, nbits */ -/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ - contrl_1.order = 10; - contrl_1.lframe = 180; - contrl_1.corrp = TRUE_; - return 0; -} /* lpcini_ */ - - - -/* Allocate memory for, and initialize, the state that needs to be - kept from encoding one frame to the next for a single - LPC-10-compressed audio stream. Return 0 if malloc fails, - otherwise return pointer to new structure. */ - -struct lpc10_encoder_state * -create_lpc10_encoder_state() -{ - struct lpc10_encoder_state *st; - - st = (struct lpc10_encoder_state *) - malloc((unsigned) sizeof (struct lpc10_encoder_state)); - if (st != 0) { - init_lpc10_encoder_state(st); - } - return (st); -} - - - -void init_lpc10_encoder_state(struct lpc10_encoder_state *st) -{ - int i; - - lpcini_(); - - /* State used only by function hp100 */ - st->z11 = 0.0f; - st->z21 = 0.0f; - st->z12 = 0.0f; - st->z22 = 0.0f; - - /* State used by function analys */ - for (i = 0; i < 540; i++) { - st->inbuf[i] = 0.0f; - st->pebuf[i] = 0.0f; - } - for (i = 0; i < 696; i++) { - st->lpbuf[i] = 0.0f; - } - for (i = 0; i < 312; i++) { - st->ivbuf[i] = 0.0f; - } - st->bias = 0.0f; - /* integer osbuf[10]; /* no initial value necessary */ - st->osptr = 1; - for (i = 0; i < 3; i++) { - st->obound[i] = 0; - } - st->vwin[4] = 307; - st->vwin[5] = 462; - st->awin[4] = 307; - st->awin[5] = 462; - for (i = 0; i < 8; i++) { - st->voibuf[i] = 0; - } - for (i = 0; i < 3; i++) { - st->rmsbuf[i] = 0.0f; - } - for (i = 0; i < 30; i++) { - st->rcbuf[i] = 0.0f; - } - st->zpre = 0.0f; - - - /* State used by function onset */ - st->n = 0.0f; - st->d__ = 1.0f; - /* real fpc; /* no initial value necessary */ - for (i = 0; i < 16; i++) { - st->l2buf[i] = 0.0f; - } - st->l2sum1 = 0.0f; - st->l2ptr1 = 1; - st->l2ptr2 = 9; - /* integer lasti; /* no initial value necessary */ - st->hyst = FALSE_; - - /* State used by function voicin */ - st->dither = 20.0f; - st->maxmin = 0.0f; - for (i = 0; i < 6; i++) { - st->voice[i] = 0.0f; - } - st->lbve = 3000; - st->fbve = 3000; - st->fbue = 187; - st->ofbue = 187; - st->sfbue = 187; - st->lbue = 93; - st->olbue = 93; - st->slbue = 93; - st->snr = (real) (st->fbve / st->fbue << 6); - - /* State used by function dyptrk */ - for (i = 0; i < 60; i++) { - st->s[i] = 0.0f; - } - for (i = 0; i < 120; i++) { - st->p[i] = 0; - } - st->ipoint = 0; - st->alphax = 0.0f; - - /* State used by function chanwr */ - st->isync = 0; - -} - - - -/* Allocate memory for, and initialize, the state that needs to be - kept from decoding one frame to the next for a single - LPC-10-compressed audio stream. Return 0 if malloc fails, - otherwise return pointer to new structure. */ - -struct lpc10_decoder_state * -create_lpc10_decoder_state() -{ - struct lpc10_decoder_state *st; - - st = (struct lpc10_decoder_state *) - malloc((unsigned) sizeof (struct lpc10_decoder_state)); - if (st != 0) { - init_lpc10_decoder_state(st); - } - return (st); -} - - - -void init_lpc10_decoder_state(struct lpc10_decoder_state *st) -{ - int i; - - lpcini_(); - - /* State used by function decode */ - st->iptold = 60; - st->first = TRUE_; - st->ivp2h = 0; - st->iovoic = 0; - st->iavgp = 60; - st->erate = 0; - for (i = 0; i < 30; i++) { - st->drc[i] = 0; - } - for (i = 0; i < 3; i++) { - st->dpit[i] = 0; - st->drms[i] = 0; - } - - /* State used by function synths */ - for (i = 0; i < 360; i++) { - st->buf[i] = 0.0f; - } - st->buflen = 180; - - /* State used by function pitsyn */ - /* ivoico; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ - /* ipito; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ - st->rmso = 1.0f; - /* rco[10]; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ - /* integer jsamp; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */ - st->first_pitsyn = TRUE_; - - /* State used by function bsynz */ - st->ipo = 0; - for (i = 0; i < 166; i++) { - st->exc[i] = 0.0f; - st->exc2[i] = 0.0f; - } - st->lpi1 = 0.0f; - st->lpi2 = 0.0f; - st->lpi3 = 0.0f; - st->hpi1 = 0.0f; - st->hpi2 = 0.0f; - st->hpi3 = 0.0f; - st->rmso_bsynz = 0.0f; - - /* State used by function random */ - st->j = 2; - st->k = 5; - st->y[0] = (shortint) -21161; - st->y[1] = (shortint) -8478; - st->y[2] = (shortint) 30892; - st->y[3] = (shortint) -10216; - st->y[4] = (shortint) 16950; - - /* State used by function deemp */ - st->dei1 = 0.0f; - st->dei2 = 0.0f; - st->deo1 = 0.0f; - st->deo2 = 0.0f; - st->deo3 = 0.0f; -} diff --git a/linphone/lpc10-1.5/lpfilt.c b/linphone/lpc10-1.5/lpfilt.c deleted file mode 100644 index 218140c2e..000000000 --- a/linphone/lpc10-1.5/lpfilt.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - -$Log: lpfilt.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:31:35 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int lpfilt_(real *inbuf, real *lpbuf, integer *len, integer *nsamp); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* *********************************************************************** */ - -/* LPFILT Version 55 */ - -/* $Log: lpfilt.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:31:35 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/15 16:53:49 jaf */ -/* Just put comment header in standard form. */ - -/* Revision 1.2 1996/03/12 23:58:06 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:47:44 jaf */ -/* Initial revision */ - - -/* *********************************************************************** */ - -/* 31 Point Equiripple FIR Low-Pass Filter */ -/* Linear phase, delay = 15 samples */ - -/* Passband: ripple = 0.25 dB, cutoff = 800 Hz */ -/* Stopband: atten. = 40. dB, cutoff = 1240 Hz */ - -/* Inputs: */ -/* LEN - Length of speech buffers */ -/* NSAMP - Number of samples to filter */ -/* INBUF - Input speech buffer */ -/* Indices len-nsamp-29 through len are read. */ -/* Output: */ -/* LPBUF - Low passed speech buffer (must be different array than INBUF) */ -/* Indices len+1-nsamp through len are written. */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int lpfilt_(real *inbuf, real *lpbuf, integer *len, integer * - nsamp) -{ - /* System generated locals */ - integer i__1; - - /* Local variables */ - integer j; - real t; - -/* Arguments */ -/* Parameters/constants */ -/* Local variables that need not be saved */ -/* Local state */ -/* None */ - /* Parameter adjustments */ - --lpbuf; - --inbuf; - - /* Function Body */ - i__1 = *len; - for (j = *len + 1 - *nsamp; j <= i__1; ++j) { - t = (inbuf[j] + inbuf[j - 30]) * -.0097201988f; - t += (inbuf[j - 1] + inbuf[j - 29]) * -.0105179986f; - t += (inbuf[j - 2] + inbuf[j - 28]) * -.0083479648f; - t += (inbuf[j - 3] + inbuf[j - 27]) * 5.860774e-4f; - t += (inbuf[j - 4] + inbuf[j - 26]) * .0130892089f; - t += (inbuf[j - 5] + inbuf[j - 25]) * .0217052232f; - t += (inbuf[j - 6] + inbuf[j - 24]) * .0184161253f; - t += (inbuf[j - 7] + inbuf[j - 23]) * 3.39723e-4f; - t += (inbuf[j - 8] + inbuf[j - 22]) * -.0260797087f; - t += (inbuf[j - 9] + inbuf[j - 21]) * -.0455563702f; - t += (inbuf[j - 10] + inbuf[j - 20]) * -.040306855f; - t += (inbuf[j - 11] + inbuf[j - 19]) * 5.029835e-4f; - t += (inbuf[j - 12] + inbuf[j - 18]) * .0729262903f; - t += (inbuf[j - 13] + inbuf[j - 17]) * .1572008878f; - t += (inbuf[j - 14] + inbuf[j - 16]) * .2247288674f; - t += inbuf[j - 15] * .250535965f; - lpbuf[j] = t; - } - return 0; -} /* lpfilt_ */ - diff --git a/linphone/lpc10-1.5/median.c b/linphone/lpc10-1.5/median.c deleted file mode 100644 index b6ee59aff..000000000 --- a/linphone/lpc10-1.5/median.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - -$Log: median.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:31:31 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern integer median_(integer *d1, integer *d2, integer *d3); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ********************************************************************* */ - -/* MEDIAN Version 45G */ - -/* $Log: median.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:31:31 jaf - * Initial revision - * */ -/* Revision 1.2 1996/03/14 22:30:22 jaf */ -/* Just rearranged the comments and local variable declarations a bit. */ - -/* Revision 1.1 1996/02/07 14:47:53 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* Find median of three values */ - -/* Input: */ -/* D1,D2,D3 - Three input values */ -/* Output: */ -/* MEDIAN - Median value */ - -integer median_(integer *d1, integer *d2, integer *d3) -{ - /* System generated locals */ - integer ret_val; - -/* Arguments */ - ret_val = *d2; - if (*d2 > *d1 && *d2 > *d3) { - ret_val = *d1; - if (*d3 > *d1) { - ret_val = *d3; - } - } else if (*d2 < *d1 && *d2 < *d3) { - ret_val = *d1; - if (*d3 < *d1) { - ret_val = *d3; - } - } - return ret_val; -} /* median_ */ - diff --git a/linphone/lpc10-1.5/mload.c b/linphone/lpc10-1.5/mload.c deleted file mode 100644 index 004a05897..000000000 --- a/linphone/lpc10-1.5/mload.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - -$Log: mload.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:31:25 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int mload_(integer *order, integer *awins, integer *awinf, real *speech, real *phi, real *psi); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ***************************************************************** */ - -/* MLOAD Version 48 */ - -/* $Log: mload.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:31:25 jaf - * Initial revision - * */ -/* Revision 1.5 1996/03/27 23:59:51 jaf */ -/* Added some more accurate comments about which indices of the argument */ -/* array SPEECH are read. I thought that this might be the cause of a */ -/* problem I've been having, but it isn't. */ - -/* Revision 1.4 1996/03/26 19:16:53 jaf */ -/* Commented out the code at the end that copied the lower triangular */ -/* half of PHI into the upper triangular half (making the resulting */ -/* matrix symmetric). The upper triangular half was never used by later */ -/* code in subroutine ANALYS. */ - -/* Revision 1.3 1996/03/18 21:16:00 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 16:47:41 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:48:01 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* Load a covariance matrix. */ - -/* Input: */ -/* ORDER - Analysis order */ -/* AWINS - Analysis window start */ -/* AWINF - Analysis window finish */ -/* SPEECH(AWINF) - Speech buffer */ -/* Indices MIN(AWINS, AWINF-(ORDER-1)) through */ -/* MAX(AWINF, AWINS+(ORDER-1)) read. */ -/* As long as (AWINF-AWINS) .GE. (ORDER-1), */ -/* this is just indices AWINS through AWINF. */ -/* Output: */ -/* PHI(ORDER,ORDER) - Covariance matrix */ -/* Lower triangular half and diagonal written, and read.*/ -/* Upper triangular half untouched. */ -/* PSI(ORDER) - Prediction vector */ -/* Indices 1 through ORDER written, */ -/* and most are read after that. */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int mload_(integer *order, integer *awins, integer *awinf, - real *speech, real *phi, real *psi) -{ - /* System generated locals */ - integer phi_dim1, phi_offset, i__1, i__2; - - /* Local variables */ - integer c__, i__, r__, start; - -/* Arguments */ -/* Local variables that need not be saved */ -/* Load first column of triangular covariance matrix PHI */ - /* Parameter adjustments */ - --psi; - phi_dim1 = *order; - phi_offset = phi_dim1 + 1; - phi -= phi_offset; - --speech; - - /* Function Body */ - start = *awins + *order; - i__1 = *order; - for (r__ = 1; r__ <= i__1; ++r__) { - phi[r__ + phi_dim1] = 0.f; - i__2 = *awinf; - for (i__ = start; i__ <= i__2; ++i__) { - phi[r__ + phi_dim1] += speech[i__ - 1] * speech[i__ - r__]; - } - } -/* Load last element of vector PSI */ - psi[*order] = 0.f; - i__1 = *awinf; - for (i__ = start; i__ <= i__1; ++i__) { - psi[*order] += speech[i__] * speech[i__ - *order]; - } -/* End correct to get additional columns of PHI */ - i__1 = *order; - for (r__ = 2; r__ <= i__1; ++r__) { - i__2 = r__; - for (c__ = 2; c__ <= i__2; ++c__) { - phi[r__ + c__ * phi_dim1] = phi[r__ - 1 + (c__ - 1) * phi_dim1] - - speech[*awinf + 1 - r__] * speech[*awinf + 1 - c__] + - speech[start - r__] * speech[start - c__]; - } - } -/* End correct to get additional elements of PSI */ - i__1 = *order - 1; - for (c__ = 1; c__ <= i__1; ++c__) { - psi[c__] = phi[c__ + 1 + phi_dim1] - speech[start - 1] * speech[start - - 1 - c__] + speech[*awinf] * speech[*awinf - c__]; - } -/* Copy lower triangular section into upper (why bother?) */ -/* I'm commenting this out, since the upper triangular half of PHI -*/ -/* is never used by later code, unless a sufficiently high level of -*/ -/* tracing is turned on. */ -/* DO R = 1,ORDER */ -/* DO C = 1,R-1 */ -/* PHI(C,R) = PHI(R,C) */ -/* END DO */ -/* END DO */ - return 0; -} /* mload_ */ - diff --git a/linphone/lpc10-1.5/onset.c b/linphone/lpc10-1.5/onset.c deleted file mode 100644 index e1b97a043..000000000 --- a/linphone/lpc10-1.5/onset.c +++ /dev/null @@ -1,306 +0,0 @@ -/* - -$Log: onset.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:37:55 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:31:18 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int onset_(real *pebuf, integer *osbuf, integer *osptr, integer *oslen, integer *sbufl, integer *sbufh, integer *lframe, struct lpc10_encoder_state *st); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Table of constant values */ - -static real c_b2 = 1.f; - -/* ****************************************************************** */ - -/* ONSET Version 49 */ - -/* $Log: onset.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:37:55 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:31:18 jaf - * Initial revision - * */ -/* Revision 1.5 1996/03/15 16:41:01 jaf */ -/* Just rearranged INITONSET assignment orders to be consistent with */ -/* order of DATA statements in ONSET. */ - -/* Revision 1.4 1996/03/15 15:48:27 jaf */ -/* Changed some comments, and only reordered the DATA statements (their */ -/* meaning wasn't changed). */ - -/* Revision 1.3 1996/03/14 23:53:06 jaf */ -/* Added an entry INITONSET that reinitializes the local state variables */ -/* of subroutine ONSET. */ - -/* Rearranged quite a few comments, adding more explaining which */ -/* arguments were inputs, and how the modified ones can be changed. */ - -/* Revision 1.2 1996/03/12 23:53:00 jaf */ -/* Lots of comments added about the local state of this subroutine that */ -/* must be saved from one invocation to the next. */ - -/* One constant 180 replaced with LFRAME, which should be "more general", */ -/* even though it would probably require many more changes than this to */ -/* get this coder to work for other frame sizes. */ - -/* Revision 1.1 1996/02/07 14:48:09 jaf */ -/* Initial revision */ - - -/* ****************************************************************** */ - -/* Floating point version */ - - -/* Detection of onsets in (or slightly preceding) the futuremost frame */ -/* of speech. */ - - -/* Input: */ -/* PEBUF(SBUFL:SBUFH) - Preemphasized speech */ -/* Indices SBUFH-LFRAME through SBUFH are read. */ -/* OSLEN - Maximum number of onsets that can be stored in OSBUF. */ -/* SBUFL, SBUFH - Range of PEBUF */ -/* LFRAME - length of a frame, in samples */ -/* Input/Output: */ -/* OSBUF(OSLEN) - Buffer which holds sorted indexes of onsets */ -/* Indices A through B are modified, where A */ -/* is the original value of OSPTR, and B is the final */ -/* value of OSPTR-1. B is at most OSLEN. */ -/* OSPTR - Free pointer into OSBUF */ -/* Initial value should be .LE. OSLEN+1. */ -/* If so, final value grows by one for each new onset */ -/* found, and final value will be .LE. OSLEN+1. */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this subroutine, or */ -/* reinitialize its state for any other reason, call the ENTRY INITONSET. */ - -/* Subroutine */ int onset_(real *pebuf, integer *osbuf, integer * - osptr, integer *oslen, integer *sbufl, integer *sbufh, integer * - lframe, struct lpc10_encoder_state *st) -{ - /* Initialized data */ - - real *n; - real *d__; - real *l2buf; - real *l2sum1; - integer *l2ptr1; - integer *l2ptr2; - logical *hyst; - - /* System generated locals */ - integer pebuf_offset, i__1; - real r__1; - - /* Builtin functions */ - double r_sign(real *, real *); - - /* Local variables */ - integer i__; - integer *lasti; - real l2sum2; - real *fpc; - -/* Arguments */ -/* $Log: onset.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:15 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:37:55 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:31:18 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Parameters/constants */ -/* Parameters for onset detection algorithm: */ -/* L2 Threshold for filtered slope of FPC (function of L2WID!) */ -/* L2LAG Lag due to both filters which compute filtered slope of FPC */ -/* L2WID Width of the filter which computes the slope of FPC */ -/* OSHYST The number of samples of slope(FPC) which must be below */ -/* the threshold before a new onset may be declared. */ -/* Local variables that need not be saved */ -/* Local state */ -/* Variables */ -/* N, D Numerator and denominator of prediction filters */ -/* FPC Current prediction coefs */ -/* L2BUF, L2SUM1, L2SUM2 State of slope filter */ -/* The only "significant" change I've made is to change L2SUM2 out -*/ -/* of the list of local variables that need to be saved, since it */ -/* didn't need to be. */ -/* L2SUM1 need not be, but avoiding saving it would require a small -*/ -/* change to the body of the code. See comments below for an */ -/* example of how the code could be changed to avoid saving L2SUM1. -*/ -/* FPC and LASTI are saved from one invocation to the next, but */ -/* they are not given initial values. This is acceptable, because -*/ -/* FPC will be assigned a value the first time that this function */ -/* is called after D is initialized to 1, since the formula to */ -/* change D will not change it to 0 in one step, and the IF (D */ -/* .NE. 0) statement will execute its THEN part, initializing FPC. -*/ - -/* LASTI's value will not be used until HYST is .TRUE., and */ -/* whenever HYST is changed from its initial value of .FALSE., */ -/* LASTI is assigned a value. */ -/* In a C version of this coder, it would be nice if all of these */ -/* saved things, in this and all other subroutines, could be stored -*/ -/* in a single struct lpc10_coder_state_t, initialized with a call -*/ -/* to a function like lpc10_init(&lpc10_coder_state). In this way, -*/ -/* a program that used these functions could conveniently alternate -*/ -/* coding more than one distinct audio stream. */ - - n = &(st->n); - d__ = &(st->d__); - fpc = &(st->fpc); - l2buf = &(st->l2buf[0]); - l2sum1 = &(st->l2sum1); - l2ptr1 = &(st->l2ptr1); - l2ptr2 = &(st->l2ptr2); - lasti = &(st->lasti); - hyst = &(st->hyst); - - /* Parameter adjustments */ - if (osbuf) { - --osbuf; - } - if (pebuf) { - pebuf_offset = *sbufl; - pebuf -= pebuf_offset; - } - - /* Function Body */ - -/* The following line subtracted a hard-coded "180" from LASTI, */ -/* instead of using a variable like LFRAME or a constant like */ -/* MAXFRM. I changed it to LFRAME, for "generality". */ - if (*hyst) { - *lasti -= *lframe; - } - i__1 = *sbufh; - for (i__ = *sbufh - *lframe + 1; i__ <= i__1; ++i__) { -/* Compute FPC; Use old FPC on divide by zero; Clamp FPC to +/- 1. -*/ - *n = (pebuf[i__] * pebuf[i__ - 1] + (*n) * 63.f) / 64.f; -/* Computing 2nd power */ - r__1 = pebuf[i__ - 1]; - *d__ = (r__1 * r__1 + (*d__) * 63.f) / 64.f; - if ((*d__) != 0.f) { - if (abs(*n) > (*d__)) { - *fpc = r_sign(&c_b2, n); - } else { - *fpc = (*n) / (*d__); - } - } -/* Filter FPC */ -/* In order to allow L2SUM1 not to be saved from one invocation -of */ -/* this subroutine to the next, one could change the sequence of - */ -/* assignments below, up to the IF statement, to the following. - In */ -/* addition, the initial value of L2PTR2 should be changed to */ -/* L2WID/2 instead of L2WID/2+1. */ - -/* L2SUM1 = L2BUF(L2PTR2) */ -/* L2PTR2 = MOD(L2PTR2,L2WID)+1 */ -/* L2SUM1 = L2SUM1 - L2BUF(L2PTR2) + FPC */ -/* L2BUF(L2PTR2) = L2SUM1 */ - -/* * The following lines didn't change from the original: */ -/* L2SUM2 = L2BUF(L2PTR1) */ -/* L2BUF(L2PTR1) = FPC */ -/* L2PTR1 = MOD(L2PTR1,L2WID)+1 */ - - l2sum2 = l2buf[*l2ptr1 - 1]; - *l2sum1 = *l2sum1 - l2buf[*l2ptr2 - 1] + *fpc; - l2buf[*l2ptr2 - 1] = *l2sum1; - l2buf[*l2ptr1 - 1] = *fpc; - *l2ptr1 = *l2ptr1 % 16 + 1; - *l2ptr2 = *l2ptr2 % 16 + 1; - if ((r__1 = *l2sum1 - l2sum2, abs(r__1)) > 1.7f) { - if (! (*hyst)) { -/* Ignore if buffer full */ - if (*osptr <= *oslen) { - osbuf[*osptr] = i__ - 9; - ++(*osptr); - } - *hyst = TRUE_; - } - *lasti = i__; -/* After one onset detection, at least OSHYST sample times m -ust go */ -/* by before another is allowed to occur. */ - } else if ((*hyst) && i__ - *lasti >= 10) { - *hyst = FALSE_; - } - } - return 0; -} /* onset_ */ diff --git a/linphone/lpc10-1.5/pitsyn.c b/linphone/lpc10-1.5/pitsyn.c deleted file mode 100644 index a4765a7bb..000000000 --- a/linphone/lpc10-1.5/pitsyn.c +++ /dev/null @@ -1,556 +0,0 @@ -/* - -$Log: pitsyn.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:40:12 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:31:12 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int pitsyn_(integer *order, integer *voice, integer *pitch, real *rms, real *rc, integer *lframe, integer *ivuv, integer *ipiti, real *rmsi, real *rci, integer *nout, real *ratio, struct lpc10_decoder_state *st); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ***************************************************************** */ - -/* PITSYN Version 53 */ - -/* $Log: pitsyn.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:40:12 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:31:12 jaf - * Initial revision - * */ -/* Revision 1.2 1996/03/25 18:49:07 jaf */ -/* Added commments about which indices of array arguments are read or */ -/* written. */ - -/* Rearranged local variable declarations to indicate which need to be */ -/* saved from one invocation to the next. Added entry INITPITSYN to */ -/* reinitialize local state variables, if desired. */ - -/* Added lots of comments about proving that the maximum number of pitch */ -/* periods (NOUT) that can be returned is 16. The call to STOP that */ -/* could happen if NOUT got too large was removed as a result. */ - -/* Also proved that the total number of samples returned from N calls, */ -/* each with identical values of LFRAME, will always be in the range */ -/* N*LFRAME-MAXPIT+1 to N*LFRAME. */ - -/* Revision 1.1 1996/02/07 14:48:18 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* Synthesize a single pitch epoch */ - -/* Input: */ -/* ORDER - Synthesis order (number of RC's) */ -/* VOICE - Half frame voicing decisions */ -/* Indices 1 through 2 read. */ -/* LFRAME - Length of speech buffer */ -/* Input/Output: */ -/* PITCH - Pitch */ -/* This value should be in the range MINPIT (20) to MAXPIT */ -/* (156), inclusive. */ -/* PITCH can be modified under some conditions. */ -/* RMS - Energy (can be modified) */ -/* RMS is changed to 1 if the value passed in is less than 1. */ -/* RC - Reflection coefficients */ -/* Indices 1 through ORDER can be temporarily overwritten with */ -/* RCO, and then replaced with original values, under some */ -/* conditions. */ -/* Output: */ -/* IVUV - Pitch epoch voicing decisions */ -/* Indices (I) of IVUV, IPITI, and RMSI are written, */ -/* and indices (J,I) of RCI are written, */ -/* where I ranges from 1 to NOUT, and J ranges from 1 to ORDER. */ -/* IPITI - Pitch epoch length */ -/* RMSI - Pitch epoch energy */ -/* RCI - Pitch epoch RC's */ -/* NOUT - Number of pitch periods in this frame */ -/* This is at least 0, at least 1 if MAXPIT .LT. LFRAME (this */ -/* is currently true on every call), and can never be more than */ -/* (LFRAME+MAXPIT-1)/PITCH, which is currently 16 with */ -/* LFRAME=180, MAXPIT=156, and PITCH .GE. 20, as SYNTHS */ -/* guarantees when it calls this subroutine. */ -/* RATIO - Previous to present energy ratio */ -/* Always assigned a value. */ - -/* Subroutine */ int pitsyn_(integer *order, integer *voice, - integer *pitch, real *rms, real *rc, integer *lframe, integer *ivuv, - integer *ipiti, real *rmsi, real *rci, integer *nout, real *ratio, - struct lpc10_decoder_state *st) -{ - /* Initialized data */ - - real *rmso; - logical *first; - - /* System generated locals */ - integer rci_dim1, rci_offset, i__1, i__2; - real r__1; - - /* Builtin functions */ - double log(doublereal), exp(doublereal); - - /* Local variables */ - real alrn, alro, yarc[10], prop; - integer i__, j, vflag, jused, lsamp; - integer *jsamp; - real slope; - integer *ipito; - real uvpit; - integer ip, nl, ivoice; - integer *ivoico; - integer istart; - real *rco; - real xxy; - -/* Arguments */ -/* $Log: pitsyn.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:40:12 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:31:12 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Local variables that need not be saved */ -/* LSAMP is initialized in the IF (FIRST) THEN clause, but it is */ -/* not used the first time through, and it is given a value before -*/ -/* use whenever FIRST is .FALSE., so it appears unnecessary to */ -/* assign it a value when FIRST is .TRUE. */ -/* Local state */ -/* FIRST - .TRUE. only on first call to PITSYN. */ -/* IVOICO - Previous VOICE(2) value. */ -/* IPITO - Previous PITCH value. */ -/* RMSO - Previous RMS value. */ -/* RCO - Previous RC values. */ - -/* JSAMP - If this routine is called N times with identical values of */ -/* LFRAME, then the total length of all pitch periods returned */ -/* is always N*LFRAME-JSAMP, and JSAMP is always in the range 0 -*/ -/* to MAXPIT-1 (see below for why this is so). Thus JSAMP is */ -/* the number of samples "left over" from the previous call to */ -/* PITSYN, that haven't been "used" in a pitch period returned */ -/* from this subroutine. Every time this subroutine is called, -*/ -/* it returns pitch periods with a total length of at most */ -/* LFRAME+JSAMP. */ - -/* IVOICO, IPITO, RCO, and JSAMP need not be assigned an initial value */ -/* with a DATA statement, because they are always initialized on the */ -/* first call to PITSYN. */ - -/* FIRST and RMSO should be initialized with DATA statements, because */ -/* even on the first call, they are used before being initialized. */ - /* Parameter adjustments */ - if (rc) { - --rc; - } - if (rci) { - rci_dim1 = *order; - rci_offset = rci_dim1 + 1; - rci -= rci_offset; - } - if (voice) { - --voice; - } - if (ivuv) { - --ivuv; - } - if (ipiti) { - --ipiti; - } - if (rmsi) { - --rmsi; - } - - /* Function Body */ - ivoico = &(st->ivoico); - ipito = &(st->ipito); - rmso = &(st->rmso); - rco = &(st->rco[0]); - jsamp = &(st->jsamp); - first = &(st->first_pitsyn); - - if (*rms < 1.f) { - *rms = 1.f; - } - if (*rmso < 1.f) { - *rmso = 1.f; - } - uvpit = 0.f; - *ratio = *rms / (*rmso + 8.f); - if (*first) { - lsamp = 0; - ivoice = voice[2]; - if (ivoice == 0) { - *pitch = *lframe / 4; - } - *nout = *lframe / *pitch; - *jsamp = *lframe - *nout * *pitch; - -/* SYNTHS only calls this subroutine with PITCH in the range -20 */ -/* to 156. LFRAME = MAXFRM = 180, so NOUT is somewhere in th -e */ -/* range 1 to 9. */ - -/* JSAMP is "LFRAME mod PITCH", so it is in the range 0 to */ -/* (PITCH-1), or 0 to MAXPIT-1=155, after the first call. */ - - i__1 = *nout; - for (i__ = 1; i__ <= i__1; ++i__) { - i__2 = *order; - for (j = 1; j <= i__2; ++j) { - rci[j + i__ * rci_dim1] = rc[j]; - } - ivuv[i__] = ivoice; - ipiti[i__] = *pitch; - rmsi[i__] = *rms; - } - *first = FALSE_; - } else { - vflag = 0; - lsamp = *lframe + *jsamp; - slope = (*pitch - *ipito) / (real) lsamp; - *nout = 0; - jused = 0; - istart = 1; - if (voice[1] == *ivoico && voice[2] == voice[1]) { - if (voice[2] == 0) { -/* SSUV - - 0 , 0 , 0 */ - *pitch = *lframe / 4; - *ipito = *pitch; - if (*ratio > 8.f) { - *rmso = *rms; - } - } -/* SSVC - - 1 , 1 , 1 */ - slope = (*pitch - *ipito) / (real) lsamp; - ivoice = voice[2]; - } else { - if (*ivoico != 1) { - if (*ivoico == voice[1]) { -/* UV2VC2 - - 0 , 0 , 1 */ - nl = lsamp - *lframe / 4; - } else { -/* UV2VC1 - - 0 , 1 , 1 */ - nl = lsamp - *lframe * 3 / 4; - } - ipiti[1] = nl / 2; - ipiti[2] = nl - ipiti[1]; - ivuv[1] = 0; - ivuv[2] = 0; - rmsi[1] = *rmso; - rmsi[2] = *rmso; - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - rci[i__ + rci_dim1] = rco[i__ - 1]; - rci[i__ + (rci_dim1 << 1)] = rco[i__ - 1]; - rco[i__ - 1] = rc[i__]; - } - slope = 0.f; - *nout = 2; - *ipito = *pitch; - jused = nl; - istart = nl + 1; - ivoice = 1; - } else { - if (*ivoico != voice[1]) { -/* VC2UV1 - - 1 , 0 , 0 */ - lsamp = *lframe / 4 + *jsamp; - } else { -/* VC2UV2 - - 1 , 1 , 0 */ - lsamp = *lframe * 3 / 4 + *jsamp; - } - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - yarc[i__ - 1] = rc[i__]; - rc[i__] = rco[i__ - 1]; - } - ivoice = 1; - slope = 0.f; - vflag = 1; - } - } -/* Here is the value of most variables that are used below, depending -on */ -/* the values of IVOICO, VOICE(1), and VOICE(2). VOICE(1) and VOICE(2 -) */ -/* are input arguments, and IVOICO is the value of VOICE(2) on the */ -/* previous call (see notes for the IF (NOUT .NE. 0) statement near th -e */ -/* end). Each of these three values is either 0 or 1. These three */ -/* values below are given as 3-bit long strings, in the order IVOICO, -*/ -/* VOICE(1), and VOICE(2). It appears that the code above assumes tha -t */ -/* the bit sequences 010 and 101 never occur, but I wonder whether a -*/ -/* large enough number of bit errors in the channel could cause such a - */ -/* thing to happen, and if so, could that cause NOUT to ever go over 1 -1? */ - -/* Note that all of the 180 values in the table are really LFRAME, but - */ -/* 180 has fewer characters, and it makes the table a little more */ -/* concrete. If LFRAME is ever changed, keep this in mind. Similarly -, */ -/* 135's are 3*LFRAME/4, and 45's are LFRAME/4. If LFRAME is not a */ -/* multiple of 4, then the 135 for NL-JSAMP is actually LFRAME-LFRAME/ -4, */ -/* and the 45 for NL-JSAMP is actually LFRAME-3*LFRAME/4. */ - -/* Note that LSAMP-JSAMP is given as the variable. This was just for -*/ -/* brevity, to avoid adding "+JSAMP" to all of the column entries. */ -/* Similarly for NL-JSAMP. */ - -/* Variable | 000 001 011,010 111 110 100,101 */ -/* ------------+-------------------------------------------------- */ -/* ISTART | 1 NL+1 NL+1 1 1 1 */ -/* LSAMP-JSAMP | 180 180 180 180 135 45 */ -/* IPITO | 45 PITCH PITCH oldPITCH oldPITCH oldPITCH */ -/* SLOPE | 0 0 0 seebelow 0 0 */ -/* JUSED | 0 NL NL 0 0 0 */ -/* PITCH | 45 PITCH PITCH PITCH PITCH PITCH */ -/* NL-JSAMP | -- 135 45 -- -- -- */ -/* VFLAG | 0 0 0 0 1 1 */ -/* NOUT | 0 2 2 0 0 0 */ -/* IVOICE | 0 1 1 1 1 1 */ - -/* while_loop | once once once once twice twice */ - -/* ISTART | -- -- -- -- JUSED+1 JUSED+1 */ -/* LSAMP-JSAMP | -- -- -- -- 180 180 */ -/* IPITO | -- -- -- -- oldPITCH oldPITCH */ -/* SLOPE | -- -- -- -- 0 0 */ -/* JUSED | -- -- -- -- ?? ?? */ -/* PITCH | -- -- -- -- PITCH PITCH */ -/* NL-JSAMP | -- -- -- -- -- -- */ -/* VFLAG | -- -- -- -- 0 0 */ -/* NOUT | -- -- -- -- ?? ?? */ -/* IVOICE | -- -- -- -- 0 0 */ - - -/* UVPIT is always 0.0 on the first pass through the DO WHILE (.TRUE.) - */ -/* loop below. */ - -/* The only possible non-0 value of SLOPE (in column 111) is */ -/* (PITCH-IPITO)/FLOAT(LSAMP) */ - -/* Column 101 is identical to 100. Any good properties we can prove -*/ -/* for 100 will also hold for 101. Similarly for 010 and 011. */ - -/* SYNTHS calls this subroutine with PITCH restricted to the range 20 -to */ -/* 156. IPITO is similarly restricted to this range, after the first -*/ -/* call. IP below is also restricted to this range, given the */ -/* definitions of IPITO, SLOPE, UVPIT, and that I is in the range ISTA -RT */ -/* to LSAMP. */ - - while(TRUE_) { - -/* JUSED is the total length of all pitch periods curr -ently */ -/* in the output arrays, in samples. */ - -/* An invariant of the DO I = ISTART,LSAMP loop below, - under */ -/* the condition that IP is always in the range 1 thro -ugh */ -/* MAXPIT, is: */ - -/* (I - MAXPIT) .LE. JUSED .LE. (I-1) */ - -/* Note that the final value of I is LSAMP+1, so that -after */ -/* the DO loop is complete, we know: */ - -/* (LSAMP - MAXPIT + 1) .LE. JUSED .LE. LSAMP */ - - i__1 = lsamp; - for (i__ = istart; i__ <= i__1; ++i__) { - r__1 = *ipito + slope * i__; - ip = r__1 + .5f; - if (uvpit != 0.f) { - ip = uvpit; - } - if (ip <= i__ - jused) { - ++(*nout); - -/* The following check is no longer nece -ssary, now that */ -/* we can prove that NOUT will never go -over 16. */ - -/* IF (NOUT .GT. 16) STOP 'PITSYN: too many epochs' -*/ - - ipiti[*nout] = ip; - *pitch = ip; - ivuv[*nout] = ivoice; - jused += ip; - prop = (jused - ip / 2) / (real) lsamp; - i__2 = *order; - for (j = 1; j <= i__2; ++j) { - alro = log((rco[j - 1] + 1) / (1 - rco[j - 1])); - alrn = log((rc[j] + 1) / (1 - rc[j])); - xxy = alro + prop * (alrn - alro); - xxy = exp(xxy); - rci[j + *nout * rci_dim1] = (xxy - 1) / (xxy + 1); - } - rmsi[*nout] = log(*rmso) + prop * (log(*rms) - log(*rmso)); - rmsi[*nout] = exp(rmsi[*nout]); - } - } - if (vflag != 1) { - goto L100; - } - -/* I want to prove what range UVPIT must lie in after -the */ -/* assignments to it below. To do this, I must determ -ine */ -/* what range (LSAMP-ISTART) must lie in, after the */ -/* assignments to ISTART and LSAMP below. */ - -/* Let oldLSAMP be the value of LSAMP at this point in - the */ -/* execution. This is 135+JSAMP in state 110, or 45+J -SAMP in */ -/* states 100 or 101. */ - -/* Given the loop invariant on JUSED above, we know th -at: */ - -/* (oldLSAMP - MAXPIT + 1) .LE. JUSED .LE. oldLSAMP */ - -/* ISTART is one more than this. */ - -/* Let newLSAMP be the value assigned to LSAMP below. - This */ -/* is 180+JSAMP. Thus (newLSAMP-oldLSAMP) is either 4 -5 or */ -/* 135, depending on the state. */ - -/* Thus, the range of newLSAMP-ISTART is: */ - -/* (newLSAMP-(oldLSAMP+1)) .LE. newLSAMP-ISTART */ -/* .LE. (newLSAMP-(oldLSAMP - MAXPIT + 2)) */ - -/* or: */ - -/* 46 .LE. newLSAMP-ISTART .LE. 133+MAXPIT .EQ. 289 */ - -/* Therefore, UVPIT is in the range 23 to 144 after th -e first */ -/* assignment to UVPIT below, and after the conditiona -l */ -/* assignment, it is in the range 23 to 90. */ - -/* The important thing is that it is in the range 20 t -o 156, */ -/* so that in the loop above, IP is always in this ran -ge. */ - - vflag = 0; - istart = jused + 1; - lsamp = *lframe + *jsamp; - slope = 0.f; - ivoice = 0; - uvpit = (real) ((lsamp - istart) / 2); - if (uvpit > 90.f) { - uvpit /= 2; - } - *rmso = *rms; - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - rc[i__] = yarc[i__ - 1]; - rco[i__ - 1] = yarc[i__ - 1]; - } - } -L100: - *jsamp = lsamp - jused; - } -/* Given that the maximum pitch period MAXPIT .LT. LFRAME (this is -*/ -/* currently true on every call, since SYNTHS always sets */ -/* LFRAME=180), NOUT will always be .GE. 1 at this point. */ - if (*nout != 0) { - *ivoico = voice[2]; - *ipito = *pitch; - *rmso = *rms; - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - rco[i__ - 1] = rc[i__]; - } - } - return 0; -} /* pitsyn_ */ diff --git a/linphone/lpc10-1.5/placea.c b/linphone/lpc10-1.5/placea.c deleted file mode 100644 index 0336f7fa3..000000000 --- a/linphone/lpc10-1.5/placea.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - -$Log: placea.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:31:07 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int placea_(integer *ipitch, integer *voibuf, integer *obound, integer *af, integer *vwin, integer *awin, integer *ewin, integer *lframe, integer *maxwin); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* *********************************************************************** */ - -/* PLACEA Version 48 */ - -/* $Log: placea.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:31:07 jaf - * Initial revision - * */ -/* Revision 1.5 1996/03/19 20:41:55 jaf */ -/* Added some conditions satisfied by the output values in EWIN. */ - -/* Revision 1.4 1996/03/19 20:24:17 jaf */ -/* Added some conditions satisfied by the output values in AWIN. */ - -/* Revision 1.3 1996/03/18 21:40:04 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 16:43:09 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:48:31 jaf */ -/* Initial revision */ - - -/* *********************************************************************** */ -/* Input: */ -/* IPITCH */ -/* VOIBUF */ -/* Indices (2,AF-2), (1,AF-1), (2,AF-1), (1,AF), and (2,AF) read.*/ -/* All other indices untouched. */ -/* OBOUND */ -/* AF */ -/* VWIN */ -/* Indices (1,AF) and (2,AF) read. */ -/* All other indices untouched. */ -/* LFRAME */ -/* MAXWIN */ -/* Input/Output: */ -/* AWIN */ -/* Index (1,AF-1) read. */ -/* Indices (1,AF) and (2,AF) written, and then read. */ -/* All other indices untouched. */ -/* In all cases (except possibly one), the final values will */ -/* satisfy the condition: AWIN(2,AF)-AWIN(1,AF)+1 = MAXWIN. */ -/* In that other case, */ -/* AWIN(1,AF)=VWIN(1,AF) and AWIN(2,AF)=VWIN(2,AF). */ -/* Output: */ -/* EWIN */ -/* Indices (1,AF) and (2,AF) written. */ -/* All other indices untouched. */ -/* In all cases, the final values will satisfy the condition: */ -/* AWIN(1,AF) .LE. EWIN(1,AF) .LE. EWIN(2,AF) .LE. AWIN(2,AF) */ -/* In other words, the energy window is a sub-window of */ -/* the analysis window. */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int placea_(integer *ipitch, integer *voibuf, integer * - obound, integer *af, integer *vwin, integer *awin, integer *ewin, - integer *lframe, integer *maxwin) -{ - /* System generated locals */ - real r__1; - - /* Builtin functions */ - integer i_nint(real *); - - /* Local variables */ - logical allv, winv; - integer i__, j, k, l, hrange; - logical ephase; - integer lrange; - -/* Arguments */ -/* Local variables that need not be saved */ - /* Parameter adjustments */ - ewin -= 3; - awin -= 3; - vwin -= 3; - --voibuf; - - /* Function Body */ - lrange = (*af - 2) * *lframe + 1; - hrange = *af * *lframe; -/* Place the Analysis window based on the voicing window */ -/* placement, onsets, tentative voicing decision, and pitch. */ - -/* Case 1: Sustained Voiced Speech */ -/* If the five most recent voicing decisions are */ -/* voiced, then the window is placed phase-synchronously with the */ -/* previous window, as close to the present voicing window if possible. -*/ -/* If onsets bound the voicing window, then preference is given to */ -/* a phase-synchronous placement which does not overlap these onsets. */ - -/* Case 2: Voiced Transition */ -/* If at least one voicing decision in AF is voicied, and there are no -*/ -/* onsets, then the window is placed as in case 1. */ - -/* Case 3: Unvoiced Speech or Onsets */ -/* If both voicing decisions in AF are unvoiced, or there are onsets, */ -/* then the window is placed coincident with the voicing window. */ - -/* Note: During phase-synchronous placement of windows, the length */ -/* is not altered from MAXWIN, since this would defeat the purpose */ -/* of phase-synchronous placement. */ -/* Check for case 1 and case 2 */ - allv = voibuf[(*af - 2 << 1) + 2] == 1; - allv = allv && voibuf[(*af - 1 << 1) + 1] == 1; - allv = allv && voibuf[(*af - 1 << 1) + 2] == 1; - allv = allv && voibuf[(*af << 1) + 1] == 1; - allv = allv && voibuf[(*af << 1) + 2] == 1; - winv = voibuf[(*af << 1) + 1] == 1 || voibuf[(*af << 1) + 2] == 1; - if (allv || winv && *obound == 0) { -/* APHASE: Phase synchronous window placement. */ -/* Get minimum lower index of the window. */ - i__ = (lrange + *ipitch - 1 - awin[(*af - 1 << 1) + 1]) / *ipitch; - i__ *= *ipitch; - i__ += awin[(*af - 1 << 1) + 1]; -/* L = the actual length of this frame's analysis window. */ - l = *maxwin; -/* Calculate the location where a perfectly centered window would star -t. */ - k = (vwin[(*af << 1) + 1] + vwin[(*af << 1) + 2] + 1 - l) / 2; -/* Choose the actual location to be the pitch multiple closest to this -. */ - r__1 = (real) (k - i__) / *ipitch; - awin[(*af << 1) + 1] = i__ + i_nint(&r__1) * *ipitch; - awin[(*af << 1) + 2] = awin[(*af << 1) + 1] + l - 1; -/* If there is an onset bounding the right of the voicing window and t -he */ -/* analysis window overlaps that, then move the analysis window backwa -rd */ -/* to avoid this onset. */ - if (*obound >= 2 && awin[(*af << 1) + 2] > vwin[(*af << 1) + 2]) { - awin[(*af << 1) + 1] -= *ipitch; - awin[(*af << 1) + 2] -= *ipitch; - } -/* Similarly for the left of the voicing window. */ - if ((*obound == 1 || *obound == 3) && awin[(*af << 1) + 1] < vwin[(* - af << 1) + 1]) { - awin[(*af << 1) + 1] += *ipitch; - awin[(*af << 1) + 2] += *ipitch; - } -/* If this placement puts the analysis window above HRANGE, then */ -/* move it backward an integer number of pitch periods. */ - while(awin[(*af << 1) + 2] > hrange) { - awin[(*af << 1) + 1] -= *ipitch; - awin[(*af << 1) + 2] -= *ipitch; - } -/* Similarly if the placement puts the analysis window below LRANGE. -*/ - while(awin[(*af << 1) + 1] < lrange) { - awin[(*af << 1) + 1] += *ipitch; - awin[(*af << 1) + 2] += *ipitch; - } -/* Make Energy window be phase-synchronous. */ - ephase = TRUE_; -/* Case 3 */ - } else { - awin[(*af << 1) + 1] = vwin[(*af << 1) + 1]; - awin[(*af << 1) + 2] = vwin[(*af << 1) + 2]; - ephase = FALSE_; - } -/* RMS is computed over an integer number of pitch periods in the analysis - */ -/*window. When it is not placed phase-synchronously, it is placed as clos -e*/ -/* as possible to onsets. */ - j = (awin[(*af << 1) + 2] - awin[(*af << 1) + 1] + 1) / *ipitch * *ipitch; - if (j == 0 || ! winv) { - ewin[(*af << 1) + 1] = vwin[(*af << 1) + 1]; - ewin[(*af << 1) + 2] = vwin[(*af << 1) + 2]; - } else if (! ephase && *obound == 2) { - ewin[(*af << 1) + 1] = awin[(*af << 1) + 2] - j + 1; - ewin[(*af << 1) + 2] = awin[(*af << 1) + 2]; - } else { - ewin[(*af << 1) + 1] = awin[(*af << 1) + 1]; - ewin[(*af << 1) + 2] = awin[(*af << 1) + 1] + j - 1; - } - return 0; -} /* placea_ */ - diff --git a/linphone/lpc10-1.5/placev.c b/linphone/lpc10-1.5/placev.c deleted file mode 100644 index a385a75fa..000000000 --- a/linphone/lpc10-1.5/placev.c +++ /dev/null @@ -1,257 +0,0 @@ -/* - -$Log: placev.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:31:02 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int placev_(integer *osbuf, integer *osptr, integer *oslen, integer *obound, integer *vwin, integer *af, integer *lframe, integer *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ****************************************************************** */ - -/* PLACEV Version 48 */ - -/* $Log: placev.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:31:02 jaf - * Initial revision - * */ -/* Revision 1.6 1996/03/19 20:42:19 jaf */ -/* Added some conditions satisfied by the output values in VWIN. */ - -/* Revision 1.5 1996/03/19 18:37:56 jaf */ -/* Strengthened the specification of which indices of VWIN are read and */ -/* written. */ - -/* Revision 1.4 1996/03/15 16:38:33 jaf */ -/* One tiny comment added. */ - -/* Revision 1.3 1996/03/15 16:36:13 jaf */ -/* Added comments giving In/Out status of arguments. */ - -/* Revision 1.2 1996/03/12 23:56:01 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:48:39 jaf */ -/* Initial revision */ - - -/* ****************************************************************** */ - -/* Input: */ -/* OSBUF Buffer which holds sorted indexes of onsets */ -/* I believe that only indices 1 through OSPTR-1 can be read. */ -/* OSLEN */ -/* OSPTR Free pointer into OSBUF */ -/* AF */ -/* LFRAME */ -/* MINWIN */ -/* MAXWIN */ -/* DVWINL */ -/* DVWINH (This argument is never used. Should it be?) */ -/* Input/Output: */ -/* VWIN Buffer of Voicing Window Positions (Modified) */ -/* Index (2,AF-1) is read. */ -/* Indices (1,AF) and (2,AF) are written, */ -/* and then possibly read. */ -/* All other indices are unused. */ -/* In all cases, the final values will satsify the condition:*/ -/* VWIN(2,AF)-VWIN(1,AF)+1 .LE. MAXWIN */ -/* I'm not certain yet, but they may also satisfy: */ -/* MINWIN .LE. VWIN(2,AF)-VWIN(1,AF)+1 */ -/* Output: */ -/* OBOUND This variable is set by this procedure and used */ -/* in placing analysis windows (PLACEA). Bit 1 */ -/* indicates whether an onset bounds the left side */ -/* of the voicing window, and bit 2 indicates whether */ -/* an onset bounds the right side of the voicing window. */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int placev_(integer *osbuf, integer *osptr, integer *oslen, - integer *obound, integer *vwin, integer *af, integer *lframe, integer - *minwin, integer *maxwin, integer *dvwinl, integer *dvwinh) -{ - /* System generated locals */ - integer i__1, i__2; - - /* Local variables */ - logical crit; - integer i__, q, osptr1, hrange, lrange; - -/* Arguments */ -/* Local variables that need not be saved */ -/* Variables */ -/* LRANGE, HRANGE Range in which window is placed */ -/* OSPTR1 OSPTR excluding samples in 3F */ -/* Local state */ -/* None */ -/* Voicing Window Placement */ - -/* __________________ __________________ ______________ */ -/* | | | */ -/* | 1F | 2F | 3F ... */ -/* |__________________|__________________|______________ */ - -/* Previous | */ -/* Window | */ -/* ...________| */ - -/* | | */ -/* ------>| This window's placement range |<------ */ -/* | | */ - -/* There are three cases. Note that these are different from those */ -/* given in the LPC-10e phase 1 report. */ - -/* 1. If there are no onsets in this range, then the voicing window */ -/* is centered in the pitch window. If such a placement is not within -*/ -/* the window's placement range, then the window is placed in the left- -*/ -/* most portion of the placement range. Its length is always MAXWIN. */ - -/* 2. If the first onset is in 2F and there is sufficient room to place - */ -/* the window immediately before this onset, then the window is placed -*/ -/* there, and its length is set to the maximum possible under these */ -/* constraints. */ - -/* "Critical Region Exception": If there is another onset in 2F */ -/* such that a window can be placed between the two onsets, the */ -/* window is placed there (ie, as in case 3). */ - -/* 3. Otherwise, the window is placed immediately after the onset. The - */ -/* window's length */ -/* is the longest length that can fit in the range under these constraint -s,*/ -/* except that the window may be shortened even further to avoid overlapp -ing*/ -/* other onsets in the placement range. In any case, the window's length -*/ -/* is at least MINWIN. */ - -/* Note that the values of MINWIN and LFRAME must be chosen such */ -/* that case 2 = false implies case 3 = true. This means that */ -/* MINWIN <= LFRAME/2. If this were not the case, then a fourth case */ -/* would have to be added for when the window cannot fit either before -*/ -/* or after the onset. */ - -/* Note also that onsets which weren't in 2F last time may be in 1F this - */ -/* time, due to the filter delays in computing onsets. The result is tha -t*/ -/* occasionally a voicing window will overlap that onset. The only way -*/ -/* to circumvent this problem is to add more delay in processing input -*/ -/* speech. In the trade-off between delay and window-placement, window -*/ -/* placement lost. */ -/* Compute the placement range */ - /* Parameter adjustments */ - --osbuf; - vwin -= 3; - - /* Function Body */ -/* Computing MAX */ - i__1 = vwin[(*af - 1 << 1) + 2] + 1, i__2 = (*af - 2) * *lframe + 1; - lrange = max(i__1,i__2); - hrange = *af * *lframe; -/* Compute OSPTR1, so the following code only looks at relevant onsets. */ - for (osptr1 = *osptr - 1; osptr1 >= 1; --osptr1) { - if (osbuf[osptr1] <= hrange) { - goto L90; - } - } -L90: - ++osptr1; -/* Check for case 1 first (fast case): */ - if (osptr1 <= 1 || osbuf[osptr1 - 1] < lrange) { -/* Computing MAX */ - i__1 = vwin[(*af - 1 << 1) + 2] + 1; - vwin[(*af << 1) + 1] = max(i__1,*dvwinl); - vwin[(*af << 1) + 2] = vwin[(*af << 1) + 1] + *maxwin - 1; - *obound = 0; - } else { -/* Search backward in OSBUF for first onset in range. */ -/* This code relies on the above check being performed first. */ - for (q = osptr1 - 1; q >= 1; --q) { - if (osbuf[q] < lrange) { - goto L100; - } - } -L100: - ++q; -/* Check for case 2 (placement before onset): */ -/* Check for critical region exception: */ - i__1 = osptr1 - 1; - for (i__ = q + 1; i__ <= i__1; ++i__) { - if (osbuf[i__] - osbuf[q] >= *minwin) { - crit = TRUE_; - goto L105; - } - } - crit = FALSE_; -L105: -/* Computing MAX */ - i__1 = (*af - 1) * *lframe, i__2 = lrange + *minwin - 1; - if (! crit && osbuf[q] > max(i__1,i__2)) { - vwin[(*af << 1) + 2] = osbuf[q] - 1; -/* Computing MAX */ - i__1 = lrange, i__2 = vwin[(*af << 1) + 2] - *maxwin + 1; - vwin[(*af << 1) + 1] = max(i__1,i__2); - *obound = 2; -/* Case 3 (placement after onset) */ - } else { - vwin[(*af << 1) + 1] = osbuf[q]; -L110: - ++q; - if (q >= osptr1) { - goto L120; - } - if (osbuf[q] > vwin[(*af << 1) + 1] + *maxwin) { - goto L120; - } - if (osbuf[q] < vwin[(*af << 1) + 1] + *minwin) { - goto L110; - } - vwin[(*af << 1) + 2] = osbuf[q] - 1; - *obound = 3; - return 0; -L120: -/* Computing MIN */ - i__1 = vwin[(*af << 1) + 1] + *maxwin - 1; - vwin[(*af << 1) + 2] = min(i__1,hrange); - *obound = 1; - } - } - return 0; -} /* placev_ */ - diff --git a/linphone/lpc10-1.5/preemp.c b/linphone/lpc10-1.5/preemp.c deleted file mode 100644 index 49bdab705..000000000 --- a/linphone/lpc10-1.5/preemp.c +++ /dev/null @@ -1,132 +0,0 @@ -/* - -$Log: preemp.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:30:58 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int preemp_(real *inbuf, real *pebuf, integer *nsamp, real *coef, real *z__); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ******************************************************************* */ - -/* PREEMP Version 55 */ - -/* $Log: preemp.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:30:58 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/14 23:16:29 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/11 23:23:34 jaf */ -/* Added a bunch of comments to an otherwise simple subroutine. */ - -/* Revision 1.1 1996/02/07 14:48:48 jaf */ -/* Initial revision */ - - -/* ******************************************************************* */ - -/* Preemphasize speech with a single-zero filter. */ -/* (When coef = .9375, preemphasis is as in LPC43.) */ - -/* Inputs: */ -/* NSAMP - Number of samples to filter */ -/* INBUF - Input speech buffer */ -/* Indices 1 through NSAMP are read. */ -/* COEF - Preemphasis coefficient */ -/* Input/Output: */ -/* Z - Filter state */ -/* Output: */ -/* PEBUF - Preemphasized speech buffer (can be equal to INBUF) */ -/* Indices 1 through NSAMP are modified. */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int preemp_(real *inbuf, real *pebuf, integer *nsamp, real * - coef, real *z__) -{ - /* System generated locals */ - integer i__1; - - /* Local variables */ - real temp; - integer i__; - -/* Arguments */ -/* Local variables */ - -/* None of these need to have their values saved from one */ -/* invocation to the next. */ - -/* Logically, this subroutine computes the output sequence */ -/* pebuf(1:nsamp) defined by: */ - -/* pebuf(i) = inbuf(i) - coef * inbuf(i-1) */ - -/* where inbuf(0) is defined by the value of z given as input to */ -/* this subroutine. */ - -/* What is this filter's frequency response and phase response? */ - -/* Why is this filter applied to the speech? */ - -/* Could it be more efficient to apply multiple filters */ -/* simultaneously, by combining them into one equivalent filter? */ - -/* Are there ever cases when "factoring" one high-order filter into -*/ -/* multiple smaller-order filter actually reduces the number of */ -/* arithmetic operations needed to perform them? */ -/* When I first read this subroutine, I didn't understand why the */ -/* variable temp was used. It seemed that the statements in the do -*/ -/* loop could be replaced with the following: */ - -/* pebuf(i) = inbuf(i) - coef * z */ -/* z = inbuf(i) */ - -/* The reason for temp is so that even if pebuf and inbuf are the */ -/* same arrays in memory (i.e., they are aliased), then this */ -/* subroutine will still work correctly. I didn't realize this */ -/* until seeing the comment after PEBUF above that says "(can be */ -/* equal to INBUF)". */ - /* Parameter adjustments */ - --pebuf; - --inbuf; - - /* Function Body */ - i__1 = *nsamp; - for (i__ = 1; i__ <= i__1; ++i__) { - temp = inbuf[i__] - *coef * *z__; - *z__ = inbuf[i__]; - pebuf[i__] = temp; -/* L10: */ - } - return 0; -} /* preemp_ */ - diff --git a/linphone/lpc10-1.5/prepro.c b/linphone/lpc10-1.5/prepro.c deleted file mode 100644 index 403dd8379..000000000 --- a/linphone/lpc10-1.5/prepro.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - -$Log: prepro.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:40:51 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:30:54 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int prepro_(real *speech, integer *length, - struct lpc10_encoder_state *st) -/*:ref: hp100_ 14 3 6 4 4 */ -/*:ref: inithp100_ 14 0 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Table of constant values */ - -static integer c__1 = 1; - -/* ********************************************************************* */ - -/* PREPRO Version 48 */ - -/* $Log: prepro.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:40:51 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:30:54 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/14 23:22:56 jaf */ -/* Added comments about when INITPREPRO should be used. */ - -/* Revision 1.2 1996/03/14 23:09:27 jaf */ -/* Added an entry named INITPREPRO that initializes the local state of */ -/* this subroutine, and those it calls (if any). */ - -/* Revision 1.1 1996/02/07 14:48:54 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* Pre-process input speech: */ - -/* Inputs: */ -/* LENGTH - Number of SPEECH samples */ -/* Input/Output: */ -/* SPEECH(LENGTH) - Speech data. */ -/* Indices 1 through LENGTH are read and modified. */ - -/* This subroutine has no local state maintained from one call to the */ -/* next, but HP100 does. If you want to switch to using a new audio */ -/* stream for this filter, or reinitialize its state for any other */ -/* reason, call the ENTRY INITPREPRO. */ - -/* Subroutine */ int prepro_(real *speech, integer *length, - struct lpc10_encoder_state *st) -{ - extern /* Subroutine */ int hp100_(real *, integer *, integer *, struct lpc10_encoder_state *); - -/* Arguments */ -/* High Pass Filter at 100 Hz */ - /* Parameter adjustments */ - if (speech) { - --speech; - } - - /* Function Body */ - hp100_(&speech[1], &c__1, length, st); - return 0; -} /* prepro_ */ diff --git a/linphone/lpc10-1.5/random.c b/linphone/lpc10-1.5/random.c deleted file mode 100644 index e83fff3eb..000000000 --- a/linphone/lpc10-1.5/random.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - -$Log: random.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:41:32 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:30:49 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern integer random_(struct lpc10_decoder_state *st); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ********************************************************************** */ - -/* RANDOM Version 49 */ - -/* $Log: random.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:41:32 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:30:49 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/20 16:13:54 jaf */ -/* Rearranged comments a little bit, and added comments explaining that */ -/* even though there is local state here, there is no need to create an */ -/* ENTRY for reinitializing it. */ - -/* Revision 1.2 1996/03/14 22:25:29 jaf */ -/* Just rearranged the comments and local variable declarations a bit. */ - -/* Revision 1.1 1996/02/07 14:49:01 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* Pseudo random number generator based on Knuth, Vol 2, p. 27. */ - -/* Function Return: */ -/* RANDOM - Integer variable, uniformly distributed over -32768 to 32767 */ - -/* This subroutine maintains local state from one call to the next. */ -/* In the context of the LPC10 coder, there is no reason to reinitialize */ -/* this local state when switching between audio streams, because its */ -/* results are only used to generate noise for unvoiced frames. */ - -integer random_(struct lpc10_decoder_state *st) -{ - /* Initialized data */ - - integer *j; - integer *k; - shortint *y; - - /* System generated locals */ - integer ret_val; - -/* Parameters/constants */ -/* Local state */ -/* The following is a 16 bit 2's complement addition, */ -/* with overflow checking disabled */ - - j = &(st->j); - k = &(st->k); - y = &(st->y[0]); - - y[*k - 1] += y[*j - 1]; - ret_val = y[*k - 1]; - --(*k); - if (*k <= 0) { - *k = 5; - } - --(*j); - if (*j <= 0) { - *j = 5; - } - return ret_val; -} /* random_ */ - diff --git a/linphone/lpc10-1.5/rcchk.c b/linphone/lpc10-1.5/rcchk.c deleted file mode 100644 index 008babb26..000000000 --- a/linphone/lpc10-1.5/rcchk.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - -$Log: rcchk.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:30:41 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int rcchk_(integer *order, real *rc1f, real *rc2f); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ********************************************************************* */ - -/* RCCHK Version 45G */ - -/* $Log: rcchk.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:30:41 jaf - * Initial revision - * */ -/* Revision 1.4 1996/03/27 18:13:47 jaf */ -/* Commented out a call to subroutine ERROR. */ - -/* Revision 1.3 1996/03/18 15:48:53 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 16:55:22 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:49:08 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* Check RC's, repeat previous frame's RC's if unstable */ - -/* Input: */ -/* ORDER - Number of RC's */ -/* RC1F - Previous frame's RC's */ -/* Indices 1 through ORDER may be read. */ -/* Input/Output: */ -/* RC2F - Present frame's RC's */ -/* Indices 1 through ORDER may be read, and written. */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int rcchk_(integer *order, real *rc1f, real *rc2f) -{ - /* System generated locals */ - integer i__1; - real r__1; - - /* Local variables */ - integer i__; - -/* Arguments */ -/* Local variables that need not be saved */ - /* Parameter adjustments */ - --rc2f; - --rc1f; - - /* Function Body */ - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - if ((r__1 = rc2f[i__], abs(r__1)) > .99f) { - goto L10; - } - } - return 0; -/* Note: In version embedded in other software, all calls to ERROR -*/ -/* should probably be removed. */ -L10: - -/* This call to ERROR is only needed for debugging purposes. */ - -/* CALL ERROR('RCCHK',2,I) */ - i__1 = *order; - for (i__ = 1; i__ <= i__1; ++i__) { - rc2f[i__] = rc1f[i__]; - } - return 0; -} /* rcchk_ */ - diff --git a/linphone/lpc10-1.5/synths.c b/linphone/lpc10-1.5/synths.c deleted file mode 100644 index b126b8154..000000000 --- a/linphone/lpc10-1.5/synths.c +++ /dev/null @@ -1,392 +0,0 @@ -/* - -$Log: synths.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:42:59 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:30:33 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int synths_(integer *voice, integer *pitch, real *rms, real *rc, real *speech, integer *k, struct lpc10_decoder_state *st); -/* comlen contrl_ 12 */ -/*:ref: pitsyn_ 14 12 4 4 4 6 6 4 4 4 6 6 4 6 */ -/*:ref: irc2pc_ 14 5 6 6 4 6 6 */ -/*:ref: bsynz_ 14 7 6 4 4 6 6 6 6 */ -/*:ref: deemp_ 14 2 6 4 */ -/*:ref: initpitsyn_ 14 0 */ -/*:ref: initbsynz_ 14 0 */ -/*:ref: initdeemp_ 14 0 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Common Block Declarations */ - -extern struct { - integer order, lframe; - logical corrp; -} contrl_; - -#define contrl_1 contrl_ - -/* Table of constant values */ - -static real c_b2 = .7f; - -/* ***************************************************************** */ - -/* SYNTHS Version 54 */ - -/* $Log: synths.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:42:59 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:30:33 jaf - * Initial revision - * */ -/* Revision 1.5 1996/03/26 19:31:58 jaf */ -/* Commented out trace statements. */ - -/* Revision 1.4 1996/03/25 19:41:01 jaf */ -/* Changed so that MAXFRM samples are always returned in the output array */ -/* SPEECH. */ - -/* This required delaying the returned samples by MAXFRM sample times, */ -/* and remembering any "left over" samples returned by PITSYN from one */ -/* call of SYNTHS to the next. */ - -/* Changed size of SPEECH from 2*MAXFRM to MAXFRM. Removed local */ -/* variable SOUT. Added local state variables BUF and BUFLEN. */ - -/* Revision 1.3 1996/03/25 19:20:10 jaf */ -/* Added comments about the range of possible return values for argument */ -/* K, and increased the size of the arrays filled in by PITSYN from 11 to */ -/* 16, as has been already done inside of PITSYN. */ - -/* Revision 1.2 1996/03/22 00:18:18 jaf */ -/* Added comments explaining meanings of input and output parameters, and */ -/* indicating which array indices can be read or written. */ - -/* Added entry INITSYNTHS, which does nothing except call the */ -/* corresponding initialization entries for subroutines PITSYN, BSYNZ, */ -/* and DEEMP. */ - -/* Revision 1.1 1996/02/07 14:49:44 jaf */ -/* Initial revision */ - - -/* ***************************************************************** */ - -/* The note below is from the distributed version of the LPC10 coder. */ -/* The version of the code below has been modified so that SYNTHS always */ -/* has a constant frame length output of MAXFRM. */ - -/* Also, BSYNZ and DEEMP need not be modified to work on variable */ -/* positions within an array. It is only necessary to pass the first */ -/* index desired as the array argument. What actually gets passed is the */ -/* address of that array position, which the subroutine treats as the */ -/* first index of the array. */ - -/* This technique is used in subroutine ANALYS when calling PREEMP, so it */ -/* appears that multiple people wrote different parts of this LPC10 code, */ -/* and that they didn't necessarily have equivalent knowledge of Fortran */ -/* (not surprising). */ - -/* NOTE: There is excessive buffering here, BSYNZ and DEEMP should be */ -/* changed to operate on variable positions within SOUT. Also, */ -/* the output length parameter is bogus, and PITSYN should be */ -/* rewritten to allow a constant frame length output. */ - -/* Input: */ -/* VOICE - Half frame voicing decisions */ -/* Indices 1 through 2 read. */ -/* Input/Output: */ -/* PITCH - Pitch */ -/* PITCH is restricted to range 20 to 156, inclusive, */ -/* before calling subroutine PITSYN, and then PITSYN */ -/* can modify it further under some conditions. */ -/* RMS - Energy */ -/* Only use is for debugging, and passed to PITSYN. */ -/* See comments there for how it can be modified. */ -/* RC - Reflection coefficients */ -/* Indices 1 through ORDER restricted to range -.99 to .99, */ -/* before calling subroutine PITSYN, and then PITSYN */ -/* can modify it further under some conditions. */ -/* Output: */ -/* SPEECH - Synthesized speech samples. */ -/* Indices 1 through the final value of K are written. */ -/* K - Number of samples placed into array SPEECH. */ -/* This is always MAXFRM. */ - -/* Subroutine */ int synths_(integer *voice, integer *pitch, real * - rms, real *rc, real *speech, integer *k, struct lpc10_decoder_state *st) -{ - /* Initialized data */ - - real *buf; - integer *buflen; - - /* System generated locals */ - integer i__1; - real r__1, r__2; - - /* Local variables */ - real rmsi[16]; - integer nout, ivuv[16], i__, j; - extern /* Subroutine */ int deemp_(real *, integer *, struct lpc10_decoder_state *); - real ratio; - integer ipiti[16]; - extern /* Subroutine */ bsynz_(real *, integer *, - integer *, real *, real *, real *, real *, struct lpc10_decoder_state *), irc2pc_(real *, real * - , integer *, real *, real *); - real g2pass; - real pc[10]; - extern /* Subroutine */ int pitsyn_(integer *, integer *, integer *, real - *, real *, integer *, integer *, integer *, real *, real *, - integer *, real *, struct lpc10_decoder_state *); - real rci[160] /* was [10][16] */; - -/* $Log: synths.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:42:59 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:30:33 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:03:47 jaf */ -/* Removed definitions for any constants that were no longer used. */ - -/* Revision 1.2 1996/03/26 19:34:33 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:43:51 jaf */ -/* Initial revision */ - -/* LPC Configuration parameters: */ -/* Frame size, Prediction order, Pitch period */ -/* Arguments */ -/* $Log: synths.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:42:59 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_decoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_decoder_state(). - * - * Revision 1.1 1996/08/19 22:30:33 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:05:55 jaf */ -/* Commented out the common block variables that are not needed by the */ -/* embedded version. */ - -/* Revision 1.2 1996/03/26 19:34:50 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:44:09 jaf */ -/* Initial revision */ - -/* LPC Processing control variables: */ - -/* *** Read-only: initialized in setup */ - -/* Files for Speech, Parameter, and Bitstream Input & Output, */ -/* and message and debug outputs. */ - -/* Here are the only files which use these variables: */ - -/* lpcsim.f setup.f trans.f error.f vqsetup.f */ - -/* Many files which use fdebug are not listed, since it is only used in */ -/* those other files conditionally, to print trace statements. */ -/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* LPC order, Frame size, Quantization rate, Bits per frame, */ -/* Error correction */ -/* Subroutine SETUP is the only place where order is assigned a value, */ -/* and that value is 10. It could increase efficiency 1% or so to */ -/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as -*/ -/* a variable in a COMMON block, since it is used in many places in the */ -/* core of the coding and decoding routines. Actually, I take that back. -*/ -/* At least when compiling with f2c, the upper bound of DO loops is */ -/* stored in a local variable before the DO loop begins, and then that is -*/ -/* compared against on each iteration. */ -/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ -/* Similarly for quant, which is given a value of 2400 in SETUP. quant */ -/* is used in only a few places, and never in the core coding and */ -/* decoding routines, so it could be eliminated entirely. */ -/* nbits is similar to quant, and is given a value of 54 in SETUP. */ -/* corrp is given a value of .TRUE. in SETUP, and is only used in the */ -/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ -/* coder significantly whether it is .TRUE. or .FALSE., or whether it is -*/ -/* a constant or a variable, since it is only examined once per frame. */ -/* Leaving it as a variable that is set to .TRUE. seems like a good */ -/* idea, since it does enable some error-correction capability for */ -/* unvoiced frames, with no change in the coding rate, and no noticeable -*/ -/* quality difference in the decoded speech. */ -/* integer quant, nbits */ -/* *** Read/write: variables for debugging, not needed for LPC algorithm -*/ - -/* Current frame, Unstable frames, Output clip count, Max onset buffer, -*/ -/* Debug listing detail level, Line count on listing page */ - -/* nframe is not needed for an embedded LPC10 at all. */ -/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ -/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ -/* an application, I would recommend removing the call to ERROR in RCCHK, -*/ -/* and remove ERROR and nunsfm completely. */ -/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in -*/ -/* sread.f. When LPC10 is embedded into an application, one might want */ -/* to cause it to be incremented in a routine that takes the output of */ -/* SYNTHS and sends it to an audio device. It could be optionally */ -/* displayed, for those that might want to know what it is. */ -/* maxosp is never initialized to 0 in SETUP, although it probably should -*/ -/* be, and it is updated in subroutine ANALYS. I doubt that its value */ -/* would be of much interest to an application in which LPC10 is */ -/* embedded. */ -/* listl and lincnt are not needed for an embedded LPC10 at all. */ -/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* common /contrl/ quant, nbits */ -/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* Parameters/constants */ -/* Local variables that need not be saved */ -/* Local state */ -/* BUF is a buffer of speech samples that would have been returned -*/ -/* by the older version of SYNTHS, but the newer version doesn't, */ -/* so that the newer version can always return MAXFRM samples on */ -/* every call. This has the effect of delaying the return of */ -/* samples for one additional frame time. */ - -/* Indices 1 through BUFLEN contain samples that are left over from -*/ -/* the last call to SYNTHS. Given the way that PITSYN works, */ -/* BUFLEN should always be in the range MAXFRM-MAXPIT+1 through */ -/* MAXFRM, inclusive, after a call to SYNTHS is complete. */ - -/* On the first call to SYNTHS (or the first call after */ -/* reinitializing with the entry INITSYNTHS), BUFLEN is MAXFRM, and -*/ -/* a frame of silence is always returned. */ - /* Parameter adjustments */ - if (voice) { - --voice; - } - if (rc) { - --rc; - } - if (speech) { - --speech; - } - - /* Function Body */ - buf = &(st->buf[0]); - buflen = &(st->buflen); - -/* Computing MAX */ - i__1 = min(*pitch,156); - *pitch = max(i__1,20); - i__1 = contrl_1.order; - for (i__ = 1; i__ <= i__1; ++i__) { -/* Computing MAX */ -/* Computing MIN */ - r__2 = rc[i__]; - r__1 = min(r__2,.99f); - rc[i__] = max(r__1,-.99f); - } - pitsyn_(&contrl_1.order, &voice[1], pitch, rms, &rc[1], &contrl_1.lframe, - ivuv, ipiti, rmsi, rci, &nout, &ratio, st); - if (nout > 0) { - i__1 = nout; - for (j = 1; j <= i__1; ++j) { - -/* Add synthesized speech for pitch period J to the en -d of */ -/* BUF. */ - - irc2pc_(&rci[j * 10 - 10], pc, &contrl_1.order, &c_b2, &g2pass); - bsynz_(pc, &ipiti[j - 1], &ivuv[j - 1], &buf[*buflen], &rmsi[j - 1] - , &ratio, &g2pass, st); - deemp_(&buf[*buflen], &ipiti[j - 1], st); - *buflen += ipiti[j - 1]; - } - -/* Copy first MAXFRM samples from BUF to output array SPEECH -*/ -/* (scaling them), and then remove them from the beginning of - */ -/* BUF. */ - - for (i__ = 1; i__ <= 180; ++i__) { - speech[i__] = buf[i__ - 1] / 4096.f; - } - *k = 180; - *buflen += -180; - i__1 = *buflen; - for (i__ = 1; i__ <= i__1; ++i__) { - buf[i__ - 1] = buf[i__ + 179]; - } - } - return 0; -} /* synths_ */ diff --git a/linphone/lpc10-1.5/tbdm.c b/linphone/lpc10-1.5/tbdm.c deleted file mode 100644 index 845642845..000000000 --- a/linphone/lpc10-1.5/tbdm.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - -$Log: tbdm.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:30:26 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int tbdm_(real *speech, integer *lpita, integer *tau, integer *ltau, real *amdf, integer *minptr, integer *maxptr, integer *mintau); -/*:ref: difmag_ 14 8 6 4 4 4 4 6 4 4 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* ********************************************************************** */ - -/* TBDM Version 49 */ - -/* $Log: tbdm.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:16 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:30:26 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/18 22:14:00 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 14:48:37 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:49:54 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/*TURBO DIFMAG: Compute High Resolution Average Magnitude Difference Function -*/ - -/* Note: There are several constants in here that appear to depend on a */ -/* particular TAU table. That's not a problem for the LPC10 coder, but */ -/* watch out if you change the contents of TAU in the subroutine ANALYS. */ - -/* Input: */ -/* SPEECH - Low pass filtered speech */ -/* Indices 1 through MAX+LPITA-1 are read, where: */ -/* MAX = (TAU(LTAU)-TAU(1))/2+1 */ -/* (If TAU(1) .LT. 39, then larger indices could be read */ -/* by the last call to DIFMAG below.) */ -/* LPITA - Length of speech buffer */ -/* TAU - Table of lags, sorted in increasing order. */ -/* Indices 1 through LTAU read. */ -/* LTAU - Number of lag values to compute */ -/* Output: */ -/* AMDF - Average Magnitude Difference for each lag in TAU */ -/* Indices 1 through LTAU written, and several might then be read.*/ -/* MINPTR - Index of minimum AMDF value */ -/* MAXPTR - Index of maximum AMDF value within +/- 1/2 octave of min */ -/* MINTAU - Lag corresponding to minimum AMDF value */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int tbdm_(real *speech, integer *lpita, integer *tau, - integer *ltau, real *amdf, integer *minptr, integer *maxptr, integer * - mintau) -{ - /* System generated locals */ - integer i__1, i__2, i__3, i__4; - - /* Local variables */ - real amdf2[6]; - integer minp2, ltau2, maxp2, i__; - extern /* Subroutine */ int difmag_(real *, integer *, integer *, integer - *, integer *, real *, integer *, integer *); - integer minamd, ptr, tau2[6]; - -/* Arguments */ -/* REAL SPEECH(LPITA+TAU(LTAU)), AMDF(LTAU) */ -/* Stupid TOAST doesn't understand expressions */ -/* Local variables that need not be saved */ -/* Local state */ -/* None */ -/* Compute full AMDF using log spaced lags, find coarse minimum */ - /* Parameter adjustments */ - --speech; - --amdf; - --tau; - - /* Function Body */ - difmag_(&speech[1], lpita, &tau[1], ltau, &tau[*ltau], &amdf[1], minptr, - maxptr); - *mintau = tau[*minptr]; - minamd = amdf[*minptr]; -/* Build table containing all lags within +/- 3 of the AMDF minimum */ -/* excluding all that have already been computed */ - ltau2 = 0; - ptr = *minptr - 2; -/* Computing MAX */ - i__1 = *mintau - 3; -/* Computing MIN */ - i__3 = *mintau + 3, i__4 = tau[*ltau] - 1; - i__2 = min(i__3,i__4); - for (i__ = max(i__1,41); i__ <= i__2; ++i__) { - while(tau[ptr] < i__) { - ++ptr; - } - if (tau[ptr] != i__) { - ++ltau2; - tau2[ltau2 - 1] = i__; - } - } -/* Compute AMDF of the new lags, if there are any, and choose one */ -/* if it is better than the coarse minimum */ - if (ltau2 > 0) { - difmag_(&speech[1], lpita, tau2, <au2, &tau[*ltau], amdf2, &minp2, & - maxp2); - if (amdf2[minp2 - 1] < (real) minamd) { - *mintau = tau2[minp2 - 1]; - minamd = amdf2[minp2 - 1]; - } - } -/* Check one octave up, if there are any lags not yet computed */ - if (*mintau >= 80) { - i__ = *mintau / 2; - if ((i__ & 1) == 0) { - ltau2 = 2; - tau2[0] = i__ - 1; - tau2[1] = i__ + 1; - } else { - ltau2 = 1; - tau2[0] = i__; - } - difmag_(&speech[1], lpita, tau2, <au2, &tau[*ltau], amdf2, &minp2, & - maxp2); - if (amdf2[minp2 - 1] < (real) minamd) { - *mintau = tau2[minp2 - 1]; - minamd = amdf2[minp2 - 1]; - *minptr += -20; - } - } -/* Force minimum of the AMDF array to the high resolution minimum */ - amdf[*minptr] = (real) minamd; -/* Find maximum of AMDF within 1/2 octave of minimum */ -/* Computing MAX */ - i__2 = *minptr - 5; - *maxptr = max(i__2,1); -/* Computing MIN */ - i__1 = *minptr + 5; - i__2 = min(i__1,*ltau); - for (i__ = *maxptr + 1; i__ <= i__2; ++i__) { - if (amdf[i__] > amdf[*maxptr]) { - *maxptr = i__; - } - } - return 0; -} /* tbdm_ */ - diff --git a/linphone/lpc10-1.5/voicin.c b/linphone/lpc10-1.5/voicin.c deleted file mode 100644 index 0782404e7..000000000 --- a/linphone/lpc10-1.5/voicin.c +++ /dev/null @@ -1,759 +0,0 @@ -/* - -$Log: voicin.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:17 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.2 1996/08/20 20:45:00 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:30:14 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int voicin_(integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *minamd, real *maxamd, integer *mintau, real *ivrc, integer *obound, integer *voibuf, integer *af, struct lpc10_encoder_state *st); -/* comlen contrl_ 12 */ -/*:ref: vparms_ 14 14 4 6 6 4 4 6 4 4 4 4 6 6 6 6 */ -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Common Block Declarations */ - -extern struct { - integer order, lframe; - logical corrp; -} contrl_; - -#define contrl_1 contrl_ - -/****************************************************************************/ - -/* VOICIN Version 52 */ - -/* $Log: voicin.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:17 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:45:00 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:30:14 jaf - * Initial revision - * */ -/* Revision 1.10 1996/03/29 17:59:14 jaf */ -/* Avoided using VALUE(9), although it shouldn't affect the function of */ -/* the code at all, because it was always multiplied by VDC(9,SNRL), */ -/* which is 0 for all values of SNRL. Still, if VALUE(9) had an initial */ -/* value of IEEE NaN, it might cause trouble (I don't know how IEEE */ -/* defines Nan * 0. It should either be NaN or 0.) */ - -/* Revision 1.9 1996/03/29 17:54:46 jaf */ -/* Added a few comments about the accesses made to argument array VOIBUF */ -/* and the local saved array VOICE. */ - -/* Revision 1.8 1996/03/27 18:19:54 jaf */ -/* Added an assignment to VSTATE that does not affect the function of the */ -/* program at all. The only reason I put it in was so that the tracing */ -/* statements at the end, when enabled, will print a consistent value for */ -/* VSTATE when HALF .EQ. 1, rather than a garbage value that could change */ -/* from one call to the next. */ - -/* Revision 1.7 1996/03/26 20:00:06 jaf */ -/* Removed the inclusion of the file "vcomm.fh", and put its contents */ -/* into this file. It was included nowhere else but here. */ - -/* Revision 1.6 1996/03/26 19:38:09 jaf */ -/* Commented out trace statements. */ - -/* Revision 1.5 1996/03/19 20:43:45 jaf */ -/* Added comments about which indices of OBOUND and VOIBUF can be */ -/* accessed, and whether they are read or written. VOIBUF is fairly */ -/* messy. */ - -/* Revision 1.4 1996/03/19 15:00:58 jaf */ -/* Moved the DATA statements for the *VDC* variables later, as it is */ -/* apparently illegal to have DATA statements before local variable */ -/* declarations. */ - -/* Revision 1.3 1996/03/19 00:10:49 jaf */ -/* Heavily commented the local variables that are saved from one */ -/* invocation to the next, and how the local variable FIRST is used to */ -/* avoid the need to assign most of them initial values with DATA */ -/* statements. */ - -/* A few should be initialized, but aren't. I've guessed initial values */ -/* for two of these, SFBUE and SLBUE, and I've convinced myself that for */ -/* VOICE, the effects of uninitialized values will die out after 2 or 3 */ -/* frame times. It would still be good to choose initial values for */ -/* these, but I don't know what reasonable values would be (0 comes to */ -/* mind). */ - -/* Revision 1.2 1996/03/13 16:09:28 jaf */ -/* Comments added explaining which of the local variables of this */ -/* subroutine need to be saved from one invocation to the next, and which */ -/* do not. */ - -/* WARNING! Some of them that should are never given initial values in */ -/* this code. Hopefully, Fortran 77 defines initial values for them, but */ -/* even so, giving them explicit initial values is preferable. */ - -/* WARNING! VALUE(9) is used, but never assigned a value. It should */ -/* probably be eliminated from the code. */ - -/* Revision 1.1 1996/02/07 14:50:28 jaf */ -/* Initial revision */ - - -/****************************************************************************/ - -/* Voicing Detection (VOICIN) makes voicing decisions for each half */ -/* frame of input speech. Tentative voicing decisions are made two frames*/ -/* in the future (2F) for each half frame. These decisions are carried */ -/* through one frame in the future (1F) to the present (P) frame where */ -/* they are examined and smoothed, resulting in the final voicing */ -/* decisions for each half frame. */ -/* The voicing parameter (signal measurement) column vector (VALUE) */ -/* is based on a rectangular window of speech samples determined by the */ -/* window placement algorithm. The voicing parameter vector contains the*/ -/* AMDF windowed maximum-to-minimum ratio, the zero crossing rate, energy*/ -/* measures, reflection coefficients, and prediction gains. The voicing */ -/* window is placed to avoid contamination of the voicing parameter vector*/ -/* with speech onsets. */ -/* The input signal is then classified as unvoiced (including */ -/* silence) or voiced. This decision is made by a linear discriminant */ -/* function consisting of a dot product of the voicing decision */ -/* coefficient (VDC) row vector with the measurement column vector */ -/* (VALUE). The VDC vector is 2-dimensional, each row vector is optimized*/ -/* for a particular signal-to-noise ratio (SNR). So, before the dot */ -/* product is performed, the SNR is estimated to select the appropriate */ -/* VDC vector. */ -/* The smoothing algorithm is a modified median smoother. The */ -/* voicing discriminant function is used by the smoother to determine how*/ -/* strongly voiced or unvoiced a signal is. The smoothing is further */ -/* modified if a speech onset and a voicing decision transition occur */ -/* within one half frame. In this case, the voicing decision transition */ -/* is extended to the speech onset. For transmission purposes, there are*/ -/* constraints on the duration and transition of voicing decisions. The */ -/* smoother takes these constraints into account. */ -/* Finally, the energy estimates are updated along with the dither */ -/* threshold used to calculate the zero crossing rate (ZC). */ - -/* Inputs: */ -/* VWIN - Voicing window limits */ -/* The indices read of arrays VWIN, INBUF, LPBUF, and BUFLIM */ -/* are the same as those read by subroutine VPARMS. */ -/* INBUF - Input speech buffer */ -/* LPBUF - Low-pass filtered speech buffer */ -/* BUFLIM - INBUF and LPBUF limits */ -/* HALF - Present analysis half frame number */ -/* MINAMD - Minimum value of the AMDF */ -/* MAXAMD - Maximum value of the AMDF */ -/* MINTAU - Pointer to the lag of the minimum AMDF value */ -/* IVRC(2) - Inverse filter's RC's */ -/* Only index 2 of array IVRC read under normal operation. */ -/* (Index 1 is also read when debugging is turned on.) */ -/* OBOUND - Onset boundary descriptions */ -/* Indices 1 through 3 read if (HALF .NE. 1), otherwise untouched. -*/ -/* AF - The analysis frame number */ -/* Output: */ -/* VOIBUF(2,0:AF) - Buffer of voicing decisions */ -/* Index (HALF,3) written. */ -/* If (HALF .EQ. 1), skip down to "Read (HALF,3)" below. */ -/* Indices (1,2), (2,1), (1,2), and (2,2) read. */ -/* One of the following is then done: */ -/* read (1,3) and possibly write (1,2) */ -/* read (1,3) and write (1,2) or (2,2) */ -/* write (2,1) */ -/* write (2,1) or (1,2) */ -/* read (1,0) and (1,3) and then write (2,2) or (1,1) */ -/* no reads or writes on VOIBUF */ -/* Finally, read (HALF,3) */ -/* Internal: */ -/* QS - Ratio of preemphasized to full-band energies */ -/* RC1 - First reflection coefficient */ -/* AR_B - Product of the causal forward and reverse pitch prediction gain -s*/ -/* AR_F - Product of the noncausal forward and rev. pitch prediction gain -s*/ -/* ZC - Zero crossing rate */ -/* DITHER - Zero crossing threshold level */ -/* MAXMIN - AMDF's 1 octave windowed maximum-to-minimum ratio */ -/* MINPTR - Location of minimum AMDF value */ -/* NVDC - Number of elements in each VDC vector */ -/* NVDCL - Number of VDC vectors */ -/* VDCL - SNR values corresponding to the set of VDC's */ -/* VDC - 2-D voicing decision coefficient vector */ -/* VALUE(9) - Voicing Parameters */ -/* VOICE(2,3)- History of LDA results */ -/* On every call when (HALF .EQ. 1), VOICE(*,I+1) is */ -/* shifted back to VOICE(*,I), for I=1,2. */ -/* VOICE(HALF,3) is written on every call. */ -/* Depending on several conditions, one or more of */ -/* (1,1), (1,2), (2,1), and (2,2) might then be read. */ -/* LBE - Ratio of low-band instantaneous to average energies */ -/* FBE - Ratio of full-band instantaneous to average energies */ -/* LBVE - Low band voiced energy */ -/* LBUE - Low band unvoiced energy */ -/* FBVE - Full band voiced energy */ -/* FBUE - Full band unvoiced energy */ -/* OFBUE - Previous full-band unvoiced energy */ -/* OLBUE - Previous low-band unvoiced energy */ -/* REF - Reference energy for initialization and DITHER threshold */ -/* SNR - Estimate of signal-to-noise ratio */ -/* SNR2 - Estimate of low-band signal-to-noise ratio */ -/* SNRL - SNR level number */ -/* OT - Onset transition present */ -/* VSTATE - Decimal interpretation of binary voicing classifications */ -/* FIRST - First call flag */ - -/* This subroutine maintains local state from one call to the next. If */ -/* you want to switch to using a new audio stream for this filter, or */ -/* reinitialize its state for any other reason, call the ENTRY */ -/* INITVOICIN. */ - -/* Subroutine */ int voicin_(integer *vwin, real *inbuf, real * - lpbuf, integer *buflim, integer *half, real *minamd, real *maxamd, - integer *mintau, real *ivrc, integer *obound, integer *voibuf, - integer *af, struct lpc10_encoder_state *st) -{ - /* Initialized data */ - - real *dither; - static real vdc[100] /* was [10][10] */ = { 0.f,1714.f,-110.f, - 334.f,-4096.f,-654.f,3752.f,3769.f,0.f,1181.f,0.f,874.f,-97.f, - 300.f,-4096.f,-1021.f,2451.f,2527.f,0.f,-500.f,0.f,510.f,-70.f, - 250.f,-4096.f,-1270.f,2194.f,2491.f,0.f,-1500.f,0.f,500.f,-10.f, - 200.f,-4096.f,-1300.f,2e3f,2e3f,0.f,-2e3f,0.f,500.f,0.f,0.f, - -4096.f,-1300.f,2e3f,2e3f,0.f,-2500.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f, - 0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f, - 0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f, - 0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f }; - static integer nvdcl = 5; - static real vdcl[10] = { 600.f,450.f,300.f,200.f,0.f,0.f,0.f,0.f,0.f,0.f } - ; - - /* System generated locals */ - integer inbuf_offset, lpbuf_offset, i__1, i__2; - real r__1, r__2; - - /* Builtin functions */ - integer i_nint(real *); - double sqrt(doublereal); - - /* Local variables */ - real ar_b__, ar_f__; - integer *lbve, *lbue, *fbve, *fbue; - integer snrl, i__; - integer *ofbue, *sfbue; - real *voice; - integer *olbue, *slbue; - real value[9]; - integer zc; - logical ot; - real qs; - real *maxmin; - integer vstate; - real rc1; - extern /* Subroutine */ int vparms_(integer *, real *, real *, integer *, - integer *, real *, integer *, integer *, integer *, integer *, - real *, real *, real *, real *); - integer fbe, lbe; - real *snr; - real snr2; - -/* Global Variables: */ -/* Arguments */ -/* $Log: voicin.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:17 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.2 1996/08/20 20:45:00 jaf - * Removed all static local variables that were SAVE'd in the Fortran - * code, and put them in struct lpc10_encoder_state that is passed as an - * argument. - * - * Removed init function, since all initialization is now done in - * init_lpc10_encoder_state(). - * - * Revision 1.1 1996/08/19 22:30:14 jaf - * Initial revision - * */ -/* Revision 1.3 1996/03/29 22:05:55 jaf */ -/* Commented out the common block variables that are not needed by the */ -/* embedded version. */ - -/* Revision 1.2 1996/03/26 19:34:50 jaf */ -/* Added comments indicating which constants are not needed in an */ -/* application that uses the LPC-10 coder. */ - -/* Revision 1.1 1996/02/07 14:44:09 jaf */ -/* Initial revision */ - -/* LPC Processing control variables: */ - -/* *** Read-only: initialized in setup */ - -/* Files for Speech, Parameter, and Bitstream Input & Output, */ -/* and message and debug outputs. */ - -/* Here are the only files which use these variables: */ - -/* lpcsim.f setup.f trans.f error.f vqsetup.f */ - -/* Many files which use fdebug are not listed, since it is only used in */ -/* those other files conditionally, to print trace statements. */ -/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* LPC order, Frame size, Quantization rate, Bits per frame, */ -/* Error correction */ -/* Subroutine SETUP is the only place where order is assigned a value, */ -/* and that value is 10. It could increase efficiency 1% or so to */ -/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as -*/ -/* a variable in a COMMON block, since it is used in many places in the */ -/* core of the coding and decoding routines. Actually, I take that back. -*/ -/* At least when compiling with f2c, the upper bound of DO loops is */ -/* stored in a local variable before the DO loop begins, and then that is -*/ -/* compared against on each iteration. */ -/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */ -/* Similarly for quant, which is given a value of 2400 in SETUP. quant */ -/* is used in only a few places, and never in the core coding and */ -/* decoding routines, so it could be eliminated entirely. */ -/* nbits is similar to quant, and is given a value of 54 in SETUP. */ -/* corrp is given a value of .TRUE. in SETUP, and is only used in the */ -/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */ -/* coder significantly whether it is .TRUE. or .FALSE., or whether it is -*/ -/* a constant or a variable, since it is only examined once per frame. */ -/* Leaving it as a variable that is set to .TRUE. seems like a good */ -/* idea, since it does enable some error-correction capability for */ -/* unvoiced frames, with no change in the coding rate, and no noticeable -*/ -/* quality difference in the decoded speech. */ -/* integer quant, nbits */ -/* *** Read/write: variables for debugging, not needed for LPC algorithm -*/ - -/* Current frame, Unstable frames, Output clip count, Max onset buffer, -*/ -/* Debug listing detail level, Line count on listing page */ - -/* nframe is not needed for an embedded LPC10 at all. */ -/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */ -/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */ -/* an application, I would recommend removing the call to ERROR in RCCHK, -*/ -/* and remove ERROR and nunsfm completely. */ -/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in -*/ -/* sread.f. When LPC10 is embedded into an application, one might want */ -/* to cause it to be incremented in a routine that takes the output of */ -/* SYNTHS and sends it to an audio device. It could be optionally */ -/* displayed, for those that might want to know what it is. */ -/* maxosp is never initialized to 0 in SETUP, although it probably should -*/ -/* be, and it is updated in subroutine ANALYS. I doubt that its value */ -/* would be of much interest to an application in which LPC10 is */ -/* embedded. */ -/* listl and lincnt are not needed for an embedded LPC10 at all. */ -/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */ -/* common /contrl/ quant, nbits */ -/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */ -/* Parameters/constants */ -/* Voicing coefficient and Linear Discriminant Analysis variables: -*/ -/* Max number of VDC's and VDC levels */ -/* The following are not Fortran PARAMETER's, but they are */ -/* initialized with DATA statements, and never modified. */ -/* Actual number of VDC's and levels */ -/* Local variables that need not be saved */ -/* Note: */ - -/* VALUE(1) through VALUE(8) are assigned values, but VALUE(9) */ -/* never is. Yet VALUE(9) is read in the loop that begins "DO I = -*/ -/* 1, 9" below. I believe that this doesn't cause any problems in -*/ -/* this subroutine, because all VDC(9,*) array elements are 0, and -*/ -/* this is what is multiplied by VALUE(9) in all cases. Still, it -*/ -/* would save a multiplication to change the loop to "DO I = 1, 8". -*/ -/* Local state */ -/* WARNING! */ - -/* VOICE, SFBUE, and SLBUE should be saved from one invocation to */ -/* the next, but they are never given an initial value. */ - -/* Does Fortran 77 specify some default initial value, like 0, or */ -/* is it undefined? If it is undefined, then this code should be */ -/* corrected to specify an initial value. */ - -/* For VOICE, note that it is "shifted" in the statement that */ -/* begins "IF (HALF .EQ. 1) THEN" below. Also, uninitialized */ -/* values in the VOICE array can only affect entries in the VOIBUF -*/ -/* array that are for the same frame, or for an older frame. Thus -*/ -/* the effects of uninitialized values in VOICE cannot linger on */ -/* for more than 2 or 3 frame times. */ - -/* For SFBUE and SLBUE, the effects of uninitialized values can */ -/* linger on for many frame times, because their previous values */ -/* are exponentially decayed. Thus it is more important to choose -*/ -/* initial values for these variables. I would guess that a */ -/* reasonable initial value for SFBUE is REF/16, the same as used */ -/* for FBUE and OFBUE. Similarly, SLBUE can be initialized to */ -/* REF/32, the same as for LBUE and OLBUE. */ - -/* These guessed initial values should be validated by re-running */ -/* the modified program on some audio samples. */ - -/* Declare and initialize filters: */ - - dither = (&st->dither); - snr = (&st->snr); - maxmin = (&st->maxmin); - voice = (&st->voice[0]); - lbve = (&st->lbve); - lbue = (&st->lbue); - fbve = (&st->fbve); - fbue = (&st->fbue); - ofbue = (&st->ofbue); - olbue = (&st->olbue); - sfbue = (&st->sfbue); - slbue = (&st->slbue); - - /* Parameter adjustments */ - if (vwin) { - --vwin; - } - if (buflim) { - --buflim; - } - if (inbuf) { - inbuf_offset = buflim[1]; - inbuf -= inbuf_offset; - } - if (lpbuf) { - lpbuf_offset = buflim[3]; - lpbuf -= lpbuf_offset; - } - if (ivrc) { - --ivrc; - } - if (obound) { - --obound; - } - if (voibuf) { - --voibuf; - } - - /* Function Body */ - -/* The following variables are saved from one invocation to the */ -/* next, but are not initialized with DATA statements. This is */ -/* acceptable, because FIRST is initialized ot .TRUE., and the */ -/* first time that this subroutine is then called, they are all */ -/* given initial values. */ - -/* SNR */ -/* LBVE, LBUE, FBVE, FBUE, OFBUE, OLBUE */ - -/* MAXMIN is initialized on the first call, assuming that HALF */ -/* .EQ. 1 on first call. This is how ANALYS calls this subroutine. -*/ - -/* Voicing Decision Parameter vector (* denotes zero coefficient): */ - -/* * MAXMIN */ -/* LBE/LBVE */ -/* ZC */ -/* RC1 */ -/* QS */ -/* IVRC2 */ -/* aR_B */ -/* aR_F */ -/* * LOG(LBE/LBVE) */ -/* Define 2-D voicing decision coefficient vector according to the voicin -g*/ -/* parameter order above. Each row (VDC vector) is optimized for a speci -fic*/ -/* SNR. The last element of the vector is the constant. */ -/* E ZC RC1 Qs IVRC2 aRb aRf c */ - -/* The VOICE array contains the result of the linear discriminant functio -n*/ -/* (analog values). The VOIBUF array contains the hard-limited binary -*/ -/* voicing decisions. The VOICE and VOIBUF arrays, according to FORTRAN - */ -/* memory allocation, are addressed as: */ - -/* (half-frame number, future-frame number) */ - -/* | Past | Present | Future1 | Future2 | */ -/* | 1,0 | 2,0 | 1,1 | 2,1 | 1,2 | 2,2 | 1,3 | 2,3 | ---> time */ - -/* Update linear discriminant function history each frame: */ - if (*half == 1) { - voice[0] = voice[2]; - voice[1] = voice[3]; - voice[2] = voice[4]; - voice[3] = voice[5]; - *maxmin = *maxamd / max(*minamd,1.f); - } -/* Calculate voicing parameters twice per frame: */ - vparms_(&vwin[1], &inbuf[inbuf_offset], &lpbuf[lpbuf_offset], &buflim[1], - half, dither, mintau, &zc, &lbe, &fbe, &qs, &rc1, &ar_b__, & - ar_f__); -/* Estimate signal-to-noise ratio to select the appropriate VDC vector. -*/ -/* The SNR is estimated as the running average of the ratio of the */ -/* running average full-band voiced energy to the running average */ -/* full-band unvoiced energy. SNR filter has gain of 63. */ - r__1 = (*snr + *fbve / (real) max(*fbue,1)) * 63 / 64.f; - *snr = (real) i_nint(&r__1); - snr2 = *snr * *fbue / max(*lbue,1); -/* Quantize SNR to SNRL according to VDCL thresholds. */ - snrl = 1; - i__1 = nvdcl - 1; - for (snrl = 1; snrl <= i__1; ++snrl) { - if (snr2 > vdcl[snrl - 1]) { - goto L69; - } - } -/* (Note: SNRL = NVDCL here) */ -L69: -/* Linear discriminant voicing parameters: */ - value[0] = *maxmin; - value[1] = (real) lbe / max(*lbve,1); - value[2] = (real) zc; - value[3] = rc1; - value[4] = qs; - value[5] = ivrc[2]; - value[6] = ar_b__; - value[7] = ar_f__; -/* Evaluation of linear discriminant function: */ - voice[*half + 3] = vdc[snrl * 10 - 1]; - for (i__ = 1; i__ <= 8; ++i__) { - voice[*half + 3] += vdc[i__ + snrl * 10 - 11] * value[i__ - 1]; - } -/* Classify as voiced if discriminant > 0, otherwise unvoiced */ -/* Voicing decision for current half-frame: 1 = Voiced; 0 = Unvoiced */ - if (voice[*half + 3] > 0.f) { - voibuf[*half + 6] = 1; - } else { - voibuf[*half + 6] = 0; - } -/* Skip voicing decision smoothing in first half-frame: */ -/* Give a value to VSTATE, so that trace statements below will print -*/ -/* a consistent value from one call to the next when HALF .EQ. 1. */ -/* The value of VSTATE is not used for any other purpose when this is -*/ -/* true. */ - vstate = -1; - if (*half == 1) { - goto L99; - } -/* Voicing decision smoothing rules (override of linear combination): */ - -/* Unvoiced half-frames: At least two in a row. */ -/* -------------------- */ - -/* Voiced half-frames: At least two in a row in one frame. */ -/* ------------------- Otherwise at least three in a row. */ -/* (Due to the way transition frames are encoded) */ - -/* In many cases, the discriminant function determines how to smooth. */ -/* In the following chart, the decisions marked with a * may be overridden -.*/ - -/* Voicing override of transitions at onsets: */ -/* If a V/UV or UV/V voicing decision transition occurs within one-half -*/ -/* frame of an onset bounding a voicing window, then the transition is */ -/* moved to occur at the onset. */ - -/* P 1F */ -/* ----- ----- */ -/* 0 0 0 0 */ -/* 0 0 0* 1 (If there is an onset there) */ -/* 0 0 1* 0* (Based on 2F and discriminant distance) */ -/* 0 0 1 1 */ -/* 0 1* 0 0 (Always) */ -/* 0 1* 0* 1 (Based on discriminant distance) */ -/* 0* 1 1 0* (Based on past, 2F, and discriminant distance) */ -/* 0 1* 1 1 (If there is an onset there) */ -/* 1 0* 0 0 (If there is an onset there) */ -/* 1 0 0 1 */ -/* 1 0* 1* 0 (Based on discriminant distance) */ -/* 1 0* 1 1 (Always) */ -/* 1 1 0 0 */ -/* 1 1 0* 1* (Based on 2F and discriminant distance) */ -/* 1 1 1* 0 (If there is an onset there) */ -/* 1 1 1 1 */ - -/* Determine if there is an onset transition between P and 1F. */ -/* OT (Onset Transition) is true if there is an onset between */ -/* P and 1F but not after 1F. */ - ot = ((obound[1] & 2) != 0 || obound[2] == 1) && (obound[3] & 1) == 0; -/* Multi-way dispatch on voicing decision history: */ - vstate = (voibuf[3] << 3) + (voibuf[4] << 2) + (voibuf[5] << 1) + voibuf[ - 6]; - switch (vstate + 1) { - case 1: goto L99; - case 2: goto L1; - case 3: goto L2; - case 4: goto L99; - case 5: goto L4; - case 6: goto L5; - case 7: goto L6; - case 8: goto L7; - case 9: goto L8; - case 10: goto L99; - case 11: goto L10; - case 12: goto L11; - case 13: goto L99; - case 14: goto L13; - case 15: goto L14; - case 16: goto L99; - } -L1: - if (ot && voibuf[7] == 1) { - voibuf[5] = 1; - } - goto L99; -L2: - if (voibuf[7] == 0 || voice[2] < -voice[3]) { - voibuf[5] = 0; - } else { - voibuf[6] = 1; - } - goto L99; -L4: - voibuf[4] = 0; - goto L99; -L5: - if (voice[1] < -voice[2]) { - voibuf[4] = 0; - } else { - voibuf[5] = 1; - } - goto L99; -/* VOIBUF(2,0) must be 0 */ -L6: - if (voibuf[1] == 1 || voibuf[7] == 1 || voice[3] > voice[0]) { - voibuf[6] = 1; - } else { - voibuf[3] = 1; - } - goto L99; -L7: - if (ot) { - voibuf[4] = 0; - } - goto L99; -L8: - if (ot) { - voibuf[4] = 1; - } - goto L99; -L10: - if (voice[2] < -voice[1]) { - voibuf[5] = 0; - } else { - voibuf[4] = 1; - } - goto L99; -L11: - voibuf[4] = 1; - goto L99; -L13: - if (voibuf[7] == 0 && voice[3] < -voice[2]) { - voibuf[6] = 0; - } else { - voibuf[5] = 1; - } - goto L99; -L14: - if (ot && voibuf[7] == 0) { - voibuf[5] = 0; - } -/* GOTO 99 */ -L99: -/* Now update parameters: */ -/* ---------------------- */ - -/* During unvoiced half-frames, update the low band and full band unvoice -d*/ -/* energy estimates (LBUE and FBUE) and also the zero crossing */ -/* threshold (DITHER). (The input to the unvoiced energy filters is */ -/* restricted to be less than 10dB above the previous inputs of the */ -/* filters.) */ -/* During voiced half-frames, update the low-pass (LBVE) and all-pass */ -/* (FBVE) voiced energy estimates. */ - if (voibuf[*half + 6] == 0) { -/* Computing MIN */ - i__1 = fbe, i__2 = *ofbue * 3; - r__1 = (*sfbue * 63 + (min(i__1,i__2) << 3)) / 64.f; - *sfbue = i_nint(&r__1); - *fbue = *sfbue / 8; - *ofbue = fbe; -/* Computing MIN */ - i__1 = lbe, i__2 = *olbue * 3; - r__1 = (*slbue * 63 + (min(i__1,i__2) << 3)) / 64.f; - *slbue = i_nint(&r__1); - *lbue = *slbue / 8; - *olbue = lbe; - } else { - r__1 = (*lbve * 63 + lbe) / 64.f; - *lbve = i_nint(&r__1); - r__1 = (*fbve * 63 + fbe) / 64.f; - *fbve = i_nint(&r__1); - } -/* Set dither threshold to yield proper zero crossing rates in the */ -/* presence of low frequency noise and low level signal input. */ -/* NOTE: The divisor is a function of REF, the expected energies. */ -/* Computing MIN */ -/* Computing MAX */ - r__2 = sqrt((real) (*lbue * *lbve)) * 64 / 3000; - r__1 = max(r__2,1.f); - *dither = min(r__1,20.f); -/* Voicing decisions are returned in VOIBUF. */ - return 0; -} /* voicin_ */ diff --git a/linphone/lpc10-1.5/vparms.c b/linphone/lpc10-1.5/vparms.c deleted file mode 100644 index 63c25ea7a..000000000 --- a/linphone/lpc10-1.5/vparms.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - -$Log: vparms.c,v $ -Revision 1.1.1.1 2001/11/19 19:50:17 smorlat -First cvs. - -Revision 1.1.1.1 2001/08/08 21:29:08 simon -First import - - * Revision 1.1 1996/08/19 22:30:04 jaf - * Initial revision - * - -*/ - -#ifdef P_R_O_T_O_T_Y_P_E_S -extern int vparms_(integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *dither, integer *mintau, integer *zc, integer *lbe, integer *fbe, real *qs, real *rc1, real *ar_b__, real *ar_f__); -#endif - -/* -- translated by f2c (version 19951025). - You must link the resulting object file with the libraries: - -lf2c -lm (in that order) -*/ - -#include "f2c.h" - -/* Table of constant values */ - -static real c_b2 = 1.f; - -/* ********************************************************************* */ - -/* VPARMS Version 50 */ - -/* $Log: vparms.c,v $ -/* Revision 1.1.1.1 2001/11/19 19:50:17 smorlat -/* First cvs. -/* -/* Revision 1.1.1.1 2001/08/08 21:29:08 simon -/* First import -/* - * Revision 1.1 1996/08/19 22:30:04 jaf - * Initial revision - * */ -/* Revision 1.6 1996/03/29 18:01:16 jaf */ -/* Added some more comments about the range of INBUF and LPBUF that can */ -/* be read. Note that it is possible for index VWIN(2)+1 to be read from */ -/* INBUF, which might be outside of its defined range, although that will */ -/* require more careful checking. */ - -/* Revision 1.5 1996/03/19 00:02:02 jaf */ -/* I just noticed that the argument DITHER is modified inside of this */ -/* subroutine. Comments were added explaining the possible final values. */ - -/* Revision 1.4 1996/03/18 22:22:59 jaf */ -/* Finishing the job I said I did with the last check-in comments. */ - -/* Revision 1.3 1996/03/18 22:22:17 jaf */ -/* Just added a few comments about which array indices of the arguments */ -/* are used, and mentioning that this subroutine has no local state. */ - -/* Revision 1.2 1996/03/13 15:02:58 jaf */ -/* Comments added explaining that none of the local variables of this */ -/* subroutine need to be saved from one invocation to the next. */ - -/* Revision 1.1 1996/02/07 14:50:42 jaf */ -/* Initial revision */ - - -/* ********************************************************************* */ - -/* Calculate voicing parameters: */ - -/* Input: */ -/* VWIN - Voicing window limits */ -/* Indices 1 through 2 read. */ -/* INBUF - Input speech buffer */ -/* Indices START-1 through STOP read, */ -/* where START and STOP are defined in the code (only written once). -*/ -/* Note that STOP can be as large as VWIN(2)+1 ! */ -/* LPBUF - Low pass filtered speech */ -/* Indices START-MINTAU through STOP+MINTAU read, */ -/* where START and STOP are defined in the code (only written once). -*/ -/* BUFLIM - Array bounds for INBUF and LPBUF */ -/* Indices 1 through 4 read. */ -/* HALF - Half frame (1 or 2) */ -/* MINTAU - Lag corresponding to minimum AMDF value (pitch estimate) */ -/* Input/Output: */ -/* DITHER - Zero crossing threshold */ -/* The resulting value might be the negation of the input */ -/* value. It might always be the same as the input value, */ -/* if the DO loop below always executes an even number of times. */ -/* Output: (all of them are written on every call) */ -/* ZC - Zero crossing rate */ -/* LBE - Low band energy (sum of magnitudes - SM) */ -/* FBE - Full band energy (SM) */ -/* QS - Ratio of 6 dB/oct preemphasized energy to full band energy */ -/* RC1 - First reflection coefficient */ -/* AR_B - Product of the causal forward and reverse pitch */ -/* prediction gains */ -/* AR_F - Product of the noncausal forward and reverse pitch */ -/* prediction gains */ -/* Internal: */ -/* OLDSGN - Previous sign of dithered signal */ -/* VLEN - Length of voicing window */ -/* START - Lower address of current half of voicing window */ -/* STOP - Upper address of current half of voicing window */ -/* E_0 - Energy of LPF speech (sum of squares - SS) */ -/* E_B - Energy of LPF speech backward one pitch period (SS) */ -/* E_F - Energy of LPF speech forward one pitch period (SS) */ -/* R_B - Autocovariance of LPF speech backward one pitch period */ -/* R_F - Autocovariance of LPF speech forward one pitch period */ -/* LP_RMS - Energy of LPF speech (sum of magnitudes - SM) */ -/* AP_RMS - Energy of all-pass speech (SM) */ -/* E_PRE - Energy of 6dB preemphasized speech (SM) */ -/* E0AP - Energy of all-pass speech (SS) */ - -/* This subroutine has no local state. */ - -/* Subroutine */ int vparms_(integer *vwin, real *inbuf, real *lpbuf, integer - *buflim, integer *half, real *dither, integer *mintau, integer *zc, - integer *lbe, integer *fbe, real *qs, real *rc1, real *ar_b__, real * - ar_f__) -{ - /* System generated locals */ - integer inbuf_offset, lpbuf_offset, i__1; - real r__1, r__2; - - /* Builtin functions */ - double r_sign(real *, real *); - integer i_nint(real *); - - /* Local variables */ - integer vlen, stop, i__; - real e_pre__; - integer start; - real ap_rms__, e_0__, oldsgn, lp_rms__, e_b__, e_f__, r_b__, r_f__, e0ap; - -/* Arguments */ -/* Local variables that need not be saved */ -/* Calculate zero crossings (ZC) and several energy and correlation */ -/* measures on low band and full band speech. Each measure is taken */ -/* over either the first or the second half of the voicing window, */ -/* depending on the variable HALF. */ - /* Parameter adjustments */ - --vwin; - --buflim; - lpbuf_offset = buflim[3]; - lpbuf -= lpbuf_offset; - inbuf_offset = buflim[1]; - inbuf -= inbuf_offset; - - /* Function Body */ - lp_rms__ = 0.f; - ap_rms__ = 0.f; - e_pre__ = 0.f; - e0ap = 0.f; - *rc1 = 0.f; - e_0__ = 0.f; - e_b__ = 0.f; - e_f__ = 0.f; - r_f__ = 0.f; - r_b__ = 0.f; - *zc = 0; - vlen = vwin[2] - vwin[1] + 1; - start = vwin[1] + (*half - 1) * vlen / 2 + 1; - stop = start + vlen / 2 - 1; - -/* I'll use the symbol HVL in the table below to represent the value */ -/* VLEN/2. Note that if VLEN is odd, then HVL should be rounded down, */ -/* i.e., HVL = (VLEN-1)/2. */ - -/* HALF START STOP */ - -/* 1 VWIN(1)+1 VWIN(1)+HVL */ -/* 2 VWIN(1)+HVL+1 VWIN(1)+2*HVL */ - -/* Note that if VLEN is even and HALF is 2, then STOP will be */ -/* VWIN(1)+VLEN = VWIN(2)+1. That could be bad, if that index of INBUF */ -/* is undefined. */ - - r__1 = inbuf[start - 1] - *dither; - oldsgn = r_sign(&c_b2, &r__1); - i__1 = stop; - for (i__ = start; i__ <= i__1; ++i__) { - lp_rms__ += (r__1 = lpbuf[i__], abs(r__1)); - ap_rms__ += (r__1 = inbuf[i__], abs(r__1)); - e_pre__ += (r__1 = inbuf[i__] - inbuf[i__ - 1], abs(r__1)); -/* Computing 2nd power */ - r__1 = inbuf[i__]; - e0ap += r__1 * r__1; - *rc1 += inbuf[i__] * inbuf[i__ - 1]; -/* Computing 2nd power */ - r__1 = lpbuf[i__]; - e_0__ += r__1 * r__1; -/* Computing 2nd power */ - r__1 = lpbuf[i__ - *mintau]; - e_b__ += r__1 * r__1; -/* Computing 2nd power */ - r__1 = lpbuf[i__ + *mintau]; - e_f__ += r__1 * r__1; - r_f__ += lpbuf[i__] * lpbuf[i__ + *mintau]; - r_b__ += lpbuf[i__] * lpbuf[i__ - *mintau]; - r__1 = inbuf[i__] + *dither; - if (r_sign(&c_b2, &r__1) != oldsgn) { - ++(*zc); - oldsgn = -oldsgn; - } - *dither = -(*dither); - } -/* Normalized short-term autocovariance coefficient at unit sample delay - */ - *rc1 /= max(e0ap,1.f); -/* Ratio of the energy of the first difference signal (6 dB/oct preemphas -is)*/ -/* to the energy of the full band signal */ -/* Computing MAX */ - r__1 = ap_rms__ * 2.f; - *qs = e_pre__ / max(r__1,1.f); -/* aR_b is the product of the forward and reverse prediction gains, */ -/* looking backward in time (the causal case). */ - *ar_b__ = r_b__ / max(e_b__,1.f) * (r_b__ / max(e_0__,1.f)); -/* aR_f is the same as aR_b, but looking forward in time (non causal case -).*/ - *ar_f__ = r_f__ / max(e_f__,1.f) * (r_f__ / max(e_0__,1.f)); -/* Normalize ZC, LBE, and FBE to old fixed window length of 180. */ -/* (The fraction 90/VLEN has a range of .58 to 1) */ - r__2 = (real) (*zc << 1); - r__1 = r__2 * (90.f / vlen); - *zc = i_nint(&r__1); -/* Computing MIN */ - r__1 = lp_rms__ / 4 * (90.f / vlen); - i__1 = i_nint(&r__1); - *lbe = min(i__1,32767); -/* Computing MIN */ - r__1 = ap_rms__ / 4 * (90.f / vlen); - i__1 = i_nint(&r__1); - *fbe = min(i__1,32767); - return 0; -} /* vparms_ */ -