a lot of cleanups (old deprecated files removed)

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@583 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
This commit is contained in:
smorlat 2009-08-19 19:14:51 +00:00
parent d1b0f8aaff
commit 4b320bbe62
152 changed files with 3 additions and 40361 deletions

View file

@ -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)

View file

@ -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=<path to linphone's tar.gz>
# ./build.mk all LINPHONE=<path to linphone's tar.gz> GLIB=<path to glib>2.2's tar.gz>
# LIBOSIP=<path to libosip's tar.gz>
#
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

View file

@ -1,2 +0,0 @@
Makefile
Makefile.in

View file

@ -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 <simon.morlat@linphone.org> ">>changelog
date -R >>changelog
touch changelog.stamp
changelog.stamp:
touch changelog.stamp

View file

@ -1,14 +0,0 @@
Source: linphone
Section: sound
Priority: optional
Maintainer: Uwe Steinmann <uwe@steinmann.cx>
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.

View file

@ -1,10 +0,0 @@
This package was debianized by Uwe Steinmann <uwe@steinmann.cx> on
Thu, 28 Feb 2002 08:29:57 +0100.
It was downloaded from http://www.linphone.org
Upstream Author(s): Simon Morlat <simon.morlat@linphone.org>
Copyright:
GPL

View file

@ -1,2 +0,0 @@
usr/bin
usr/sbin

View file

@ -1,3 +0,0 @@
BUGS
NEWS
README

View file

@ -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 <n> 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<whatever>\fP and
.\" \fI<whatever>\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 <uwe@steinmann.cx>,
for the Debian GNU/Linux system (but may be used by others).

View file

@ -1,152 +0,0 @@
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
<!-- Process this file with docbook-to-man to generate an nroff manual
page: `docbook-to-man manpage.sgml > 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.
-->
<!-- Fill in your name for FIRSTNAME and SURNAME. -->
<!ENTITY dhfirstname "<firstname>FIRSTNAME</firstname>">
<!ENTITY dhsurname "<surname>SURNAME</surname>">
<!-- Please adjust the date whenever revising the manpage. -->
<!ENTITY dhdate "<date>February 28, 2002</date>">
<!-- SECTION should be 1-8, maybe w/ subsection other parameters are
allowed: see man(7), man(1). -->
<!ENTITY dhsection "<manvolnum>SECTION</manvolnum>">
<!ENTITY dhemail "<email>uwe@steinmann.cx</email>">
<!ENTITY dhusername "Uwe Steinmann">
<!ENTITY dhucpackage "<refentrytitle>LINPHONE</refentrytitle>">
<!ENTITY dhpackage "linphone">
<!ENTITY debian "<productname>Debian</productname>">
<!ENTITY gnu "<acronym>GNU</acronym>">
]>
<refentry>
<refentryinfo>
<address>
&dhemail;
</address>
<author>
&dhfirstname;
&dhsurname;
</author>
<copyright>
<year>2001</year>
<holder>&dhusername;</holder>
</copyright>
&dhdate;
</refentryinfo>
<refmeta>
&dhucpackage;
&dhsection;
</refmeta>
<refnamediv>
<refname>&dhpackage;</refname>
<refpurpose>program to do something</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>&dhpackage;</command>
<arg><option>-e <replaceable>this</replaceable></option></arg>
<arg><option>--example <replaceable>that</replaceable></option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>This manual page documents briefly the
<command>&dhpackage;</command> and <command>bar</command>
commands.</para>
<para>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;
<application>Info</application> format; see below.</para>
<para><command>&dhpackage;</command> is a program that...</para>
</refsect1>
<refsect1>
<title>OPTIONS</title>
<para>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
<application>Info</application> files.</para>
<variablelist>
<varlistentry>
<term><option>-h</option>
<option>--help</option>
</term>
<listitem>
<para>Show summary of options.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option>
<option>--version</option>
</term>
<listitem>
<para>Show version of program.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>bar (1), baz (1).</para>
<para>The programs are documented fully by <citetitle>The Rise and
Fall of a Fooish Bar</citetitle> available via the
<application>Info</application> system.</para>
</refsect1>
<refsect1>
<title>AUTHOR</title>
<para>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 <acronym>GNU</acronym> 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.</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -1,2 +0,0 @@
Makefile
Makefile.in

View file

@ -1,2 +0,0 @@
Makefile.in
Makefile

View file

@ -1,6 +0,0 @@
.deps
.libs
Makefile
Makefile.in
*.lo
*.la

View file

@ -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)

File diff suppressed because it is too large Load diff

View file

@ -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 <mpatrol.h>
#endif
#ifndef __EXOSIP_H__
#define __EXOSIP_H__
#include <osipparser2/osip_parser.h>
#include <osip2/osip_negotiation.h>
#include <time.h>
/**
* @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.
*
* <P>
*/
#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

View file

@ -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 <mpatrol.h>
#endif
#ifndef __EXOSIP2_H__
#define __EXOSIP2_H__
#ifdef WIN32
#include <stdio.h>
#include <stdlib.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#define snprintf _snprintf
#define close(s) closesocket(s)
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#include <stdio.h>
#include <osip2/osip.h>
#include <osip2/osip_dialog.h>
#include <osip2/osip_negotiation.h>
#include <eXosip_cfg.h>
#include <eXosip.h>
#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

View file

@ -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 <mpatrol.h>
#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

View file

@ -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 <mpatrol.h>
#endif
#include <osipparser2/osip_port.h>
#include "eXosip2.h"
extern eXosip_t eXosip;
#ifdef WIN32
/* You need the Platform SDK to compile this. */
#include <Windows.h>
#else /* sun, *BSD, linux, and other? */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <unistd.h>
#include <sys/param.h>
#include <stdio.h>
#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;
}

View file

@ -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

View file

@ -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 <mpatrol.h>
#endif
#include "eXosip2.h"
#include <eXosip.h>
#include <eXosip_cfg.h>
#include <osip2/osip_mt.h>
#include <osip2/osip_condv.h>
/* #include <osip2/global.h> */
#include <osipparser2/osip_md5.h>
/* 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;
}

View file

@ -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 <mpatrol.h>
#endif
#include "eXosip2.h"
#include <eXosip_cfg.h>
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);
}

File diff suppressed because it is too large Load diff

View file

@ -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 <mpatrol.h>
#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);
}

View file

@ -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 <mpatrol.h>
#endif
#include "eXosip2.h"
#include <eXosip.h>
#include <osip2/osip_condv.h>
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 <sys/types.h>
#include <sys/timeb.h>
#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;
}

View file

@ -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 <mpatrol.h>
#endif
#include "eXosip2.h"
#include <eXosip_cfg.h>
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;
}

View file

@ -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 <mpatrol.h>
#endif
#include "eXosip2.h"
#include <eXosip_cfg.h>
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;
}

View file

@ -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 <mpatrol.h>
#endif
#include "eXosip2.h"
#include <eXosip_cfg.h>
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, "<?xml version=\"1.0\"?>\n\
<!DOCTYPE presence\n\
PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
<presence>\n\
<presentity uri=\"%s;method=SUBSCRIBE\" />\n\
<atom id=\"%i\">\n\
<address uri=\"%s;user=ip\" priority=\"0.800000\">\n\
<status status=\"open\" />\n\
<msnsubstatus substatus=\"online\" />\n\
</address>\n\
</atom>\n\
</presence>", jn->n_contact_info, atom_id, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_BUSY)
{
sprintf(buf, "<?xml version=\"1.0\"?>\n\
<!DOCTYPE presence\n\
PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
<presence>\n\
<presentity uri=\"%s;method=SUBSCRIBE\" />\n\
<atom id=\"%i\">\n\
<address uri=\"%s;user=ip\" priority=\"0.800000\">\n\
<status status=\"inuse\" />\n\
<msnsubstatus substatus=\"busy\" />\n\
</address>\n\
</atom>\n\
</presence>", jn->n_contact_info, atom_id, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_BERIGHTBACK)
{
sprintf(buf, "<?xml version=\"1.0\"?>\n\
<!DOCTYPE presence\n\
PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
<presence>\n\
<presentity uri=\"%s;method=SUBSCRIBE\" />\n\
<atom id=\"%i\">\n\
<address uri=\"%s;user=ip\" priority=\"0.800000\">\n\
<status status=\"inactive\" />\n\
<msnsubstatus substatus=\"berightback\" />\n\
</address>\n\
</atom>\n\
</presence>", jn->n_contact_info, atom_id, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_AWAY)
{
sprintf(buf, "<?xml version=\"1.0\"?>\n\
<!DOCTYPE presence\n\
PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
<presence>\n\
<presentity uri=\"%s;method=SUBSCRIBE\" />\n\
<atom id=\"%i\">\n\
<address uri=\"%s;user=ip\" priority=\"0.800000\">\n\
<status status=\"inactive\" />\n\
<msnsubstatus substatus=\"away\" />\n\
</address>\n\
</atom>\n\
</presence>", jn->n_contact_info, atom_id, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_ONTHEPHONE)
{
sprintf(buf, "<?xml version=\"1.0\"?>\n\
<!DOCTYPE presence\n\
PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
<presence>\n\
<presentity uri=\"%s;method=SUBSCRIBE\" />\n\
<atom id=\"%i\">\n\
<address uri=\"%s;user=ip\" priority=\"0.800000\">\n\
<status status=\"inuse\" />\n\
<msnsubstatus substatus=\"onthephone\" />\n\
</address>\n\
</atom>\n\
</presence>", jn->n_contact_info, atom_id, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_OUTTOLUNCH)
{
sprintf(buf, "<?xml version=\"1.0\"?>\n\
<!DOCTYPE presence\n\
PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
<presence>\n\
<presentity uri=\"%s;method=SUBSCRIBE\" />\n\
<atom id=\"%i\">\n\
<address uri=\"%s;user=ip\" priority=\"0.800000\">\n\
<status status=\"inactive\" />\n\
<msnsubstatus substatus=\"outtolunch\" />\n\
</address>\n\
</atom>\n\
</presence>", jn->n_contact_info, atom_id, jn->n_contact_info);
}
else
{
sprintf(buf, "<?xml version=\"1.0\"?>\n\
<!DOCTYPE presence\n\
PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n\
<presence>\n\
<presentity uri=\"%s;method=SUBSCRIBE\" />\n\
<atom id=\"%i\">\n\
<address uri=\"%s;user=ip\" priority=\"0.800000\">\n\
<status status=\"inactive\" />\n\
<msnsubstatus substatus=\"away\" />\n\
</address>\n\
</atom>\n\
</presence>", 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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n\
entity=\"%s\">\n\
<tuple id=\"sg89ae\">\n\
<status>\n\
<basic>open</basic>\n\
</status>\n\
<contact priority=\"0.8\">%s</contact>\n\
<note>online</note>\n\
</tuple>\n\
</presence>",
jn->n_contact_info, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_BUSY)
{
sprintf(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n\
xmlns:es=\"urn:ietf:params:xml:ns:pidf:status:rpid-status\"\n\
entity=\"%s\">\n\
<tuple id=\"sg89ae\">\n\
<status>\n\
<basic>open</basic>\n\
<es:activities>\n\
<es:activity>busy</es:activity>\n\
</es:activities>\n\
</status>\n\
<contact priority=\"0.8\">%s</contact>\n\
<note>busy</note>\n\
</tuple>\n\
</presence>",
jn->n_contact_info, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_BERIGHTBACK)
{
sprintf(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n\
xmlns:es=\"urn:ietf:params:xml:ns:pidf:status:rpid-status\"\n\
entity=\"%s\">\n\
<tuple id=\"sg89ae\">\n\
<status>\n\
<basic>open</basic>\n\
<es:activities>\n\
<es:activity>in-transit</es:activity>\n\
</es:activities>\n\
</status>\n\
<contact priority=\"0.8\">%s</contact>\n\
<note>be right back</note>\n\
</tuple>\n\
</presence>",
jn->n_contact_info, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_AWAY)
{
sprintf(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n\
xmlns:es=\"urn:ietf:params:xml:ns:pidf:status:rpid-status\"\n\
entity=\"%s\">\n\
<tuple id=\"sg89ae\">\n\
<status>\n\
<basic>open</basic>\n\
<es:activities>\n\
<es:activity>away</es:activity>\n\
</es:activities>\n\
</status>\n\
<contact priority=\"0.8\">%s</contact>\n\
<note>away</note>\n\
</tuple>\n\
</presence>",
jn->n_contact_info, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_ONTHEPHONE)
{
sprintf(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n\
xmlns:es=\"urn:ietf:params:xml:ns:pidf:status:rpid-status\"\n\
entity=\"%s\">\n\
<tuple id=\"sg89ae\">\n\
<status>\n\
<basic>open</basic>\n\
<es:activities>\n\
<es:activity>on-the-phone</es:activity>\n\
</es:activities>\n\
</status>\n\
<contact priority=\"0.8\">%s</contact>\n\
<note>on the phone</note>\n\
</tuple>\n\
</presence>",
jn->n_contact_info, jn->n_contact_info);
}
else if (jn->n_online_status==EXOSIP_NOTIFY_OUTTOLUNCH)
{
sprintf(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n\
xmlns:es=\"urn:ietf:params:xml:ns:pidf:status:rpid-status\"\n\
entity=\"%s\">\n\
<tuple id=\"sg89ae\">\n\
<status>\n\
<basic>open</basic>\n\
<es:activities>\n\
<es:activity>meal</es:activity>\n\
</es:activities>\n\
</status>\n\
<contact priority=\"0.8\">%s</contact>\n\
<note>out to lunch</note>\n\
</tuple>\n\
</presence>",
jn->n_contact_info, jn->n_contact_info);
}
else
{
/* */
sprintf(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n\
xmlns:es=\"urn:ietf:params:xml:ns:pidf:status:rpid-status\"\n\
entity=\"%s\">\n%s",
jn->n_contact_info,
"<tuple id=\"sg89ae\">\n\
<status>\n\
<basic>closed</basic>\n\
<es:activities>\n\
<es:activity>permanent-absence</e:activity>\n\
</es:activities>\n\
</status>\n\
</tuple>\n\
\n</presence>\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);
}

View file

@ -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 <mpatrol.h>
#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

View file

@ -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 <eXosip.h>
#ifndef WIN32
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
#ifdef WIN32
#include <windows.h>
#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

View file

@ -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 <mpatrol.h>
#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);
}

View file

@ -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 <mpatrol.h>
#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;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -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 <mpatrol.h>
#endif
#include "eXosip2.h"
#include <eXosip_cfg.h>
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;
}

View file

@ -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 <mpatrol.h>
#endif
#include "eXosip2.h"
#include <eXosip.h>
#include <eXosip_cfg.h>
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;
}

View file

@ -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 <mpatrol.h>
#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;
}

View file

@ -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 <mpatrol.h>
#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;
}

File diff suppressed because it is too large Load diff

View file

@ -1,6 +0,0 @@
*.lo
.deps
.libs
Makefile
Makefile.in
libgsm.la

View file

@ -1,16 +0,0 @@
Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann,
Technische Universitaet Berlin
Any use of this software is permitted provided that this notice is not
removed and that neither the authors nor the Technische Universitaet Berlin
are deemed to have made any representations as to the suitability of this
software for any purpose nor are held responsible for any defects of
this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
As a matter of courtesy, the authors request to be informed about uses
this software has found, about bugs in this software, and about any
improvements that may be of general interest.
Berlin, 28.11.1994
Jutta Degener
Carsten Bormann

View file

@ -1,80 +0,0 @@
Fri Jul 5 19:26:37 1996 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 10
src/toast_alaw.c: exchanged A-law tables for something
slightly more A-law.
Tue Jul 2 12:18:20 1996 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 9
src/long_term.c: in FLOAT_MUL mode, an array was accessed past its end
src/gsm_option.c: three options related to WAV #49 packing
src/gsm_encode.c: support WAV #49-style encoding.
src/gsm_decode.c: support WAV #49-style decoding.
tls/sour.c: generate the WAV bit shifting code, encode
tls/ginger.c: generate the WAV bit shifting code, decode
The WAV code goes back to an inofficial patch #8 that
Jeff Chilton sent us (hence the jump from 7 to 9).
src/toast.c: add _fsetmode() calls to set stdin/stdout to
binary (from an OS/2 port by Arnd Gronenberg.)
Tue Mar 7 01:55:10 1995 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 7
src/long_term.c: Yet another 16-bit overflow
src/toast.c: -C option to toast, cuts LPC time
src/gsm_option.c: corresponding LPC_CUT option to GSM library
Fri Dec 30 23:33:50 1994 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 6
src/lpc.c: fixed 16-bit addition overflow in Autocorrelation code
src/add.c: gsm_L_asl should fall back on gsm_L_asr, not gsm_asr
Mon Nov 28 20:49:57 1994 Jutta Degener (jutta@cs.tu-berlin.de)
* Release 1.0 Patchlevel 5
src/toast_audio.c: initialization should return -1 on error
src/gsm_destroy.c: #include configuration header file
src/add.c: gsm_sub should cast its parameters to longword
man/*: bug reports to {jutta,cabo}@cs.tu-berlin.de, not to toast@tub
inc/private.h: longword long by default, not int
inc/toast.h: read/write fopen modes "rb" and "wb", not just "r"
src/toast.c: better (or different, anyway) error handling in process()
Tue May 10 19:41:34 1994 Jutta Degener (jutta at kugelbus)
* Release 1.0 Patchlevel 4
inc/private.h: GSM_ADD should cast to ulongword, not to unsigned.
src/long_term.c: missing cast to longword.
add-test/add_test.c: Test macros too, not only functions,
thanks to Simao Ferraz de Campos Neto, simao@dragon.cpqd.ansp.br
General cleanup: remove unused variables, add function prototypes.
Tue Jan 25 22:53:40 1994 Jutta Degener (jutta at kugelbus)
* Release 1.0 Patchlevel 3
changed rpe.c's STEP macro to work with 16-bit integers,
thanks to Dr Alex Lee (alexlee@solomon.technet.sg);
removed non-fatal bugs from add-test.dta, private.h
and toast_audio.c, thanks to P. Emanuelsson.
Fri Jan 29 19:02:12 1993 Jutta Degener (jutta at kraftbus)
* Release 1.0 Patchlevel 2
fixed L_add(0,-1) in src/add.c and inc/private.h,
thanks to Raphael Trommer at AT&T Bell Laboratories;
various other ANSI C compatibility details
Fri Oct 30 17:58:54 1992 Jutta Degener (jutta at kraftbus)
* Release 1.0 Patchlevel 1
Switched uid/gid in toast's [f]chown calls.
Wed Oct 28 14:12:35 1992 Carsten Bormann (cabo at kubus)
* Release 1.0: released
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.

View file

@ -1,99 +0,0 @@
How to get started:
Edit the Makefile.
You should configure a few machine-dependencies and what
compiler you want to use.
The code works both with ANSI and K&R-C. Use
-DNeedFunctionPrototypes to compile with, or
-UNeedFunctionPrototypes to compile without, function
prototypes in the header files.
Make addtst
The "add" program that will be compiled and run checks whether
the basic math functions of the gsm library work with your
compiler. If it prints anything to stderr, complain (to us).
Edit inc/config.h.
Make
Local versions of the gsm library and the "compress"-like filters
toast, untoast and tcat will be generated.
If the compilation aborts because of a missing function,
declaration, or header file, see if there's something in
inc/config.h to work around it. If not, complain.
Try it
Grab an audio file from somewhere (raw u-law or Sun .au is fine,
linear 16-bit in host byte order will do), copy it, toast it,
untoast it, and listen to the result.
The GSM-encoded and -decoded audio should have the quality
of a good phone line. If the resulting audio is noisier than
your original, or if you hear compression artifacts, complain;
that's a bug in our software, not a bug in the GSM encoding
standard itself.
Installation
You can install the gsm library interface, or the toast binaries,
or both.
Edit the Makefile
Fill in the directories where you want to install the
library, header files, manual pages, and binaries.
Turn off the installation of one half of the distribution
(i.e., gsm library or toast binaries) by not setting the
corresponding directory root Makefile macro.
make install
will install the programs "toast" with two links named
"tcat" and "untoast", and the gsm library "libgsm.a" with
a "gsm.h" header file, and their respective manual pages.
Optimizing
This code was developed on a machine without an integer
multiplication instruction, where we obtained the fastest result by
replacing some of the integer multiplications with floating point
multiplications.
If your machine does multiply integers fast enough,
leave USE_FLOAT_MUL undefined. The results should be the
same in both cases.
On machines with fast floating point arithmetic, defining
both USE_FLOAT_MUL and FAST makes a run-time library
option available that will (in a few crucial places) use
``native'' floating point operations rather than the bit-by-bit
defined ones of the GSM standard. If you use this fast
option, the outcome will not be bitwise identical to the
results prescribed by the standard, but it is compatible with
the standard encoding, and a user is unlikely to notice a
difference.
Bug Reports
Please direct bug reports, questions, and comments to
jutta@cs.tu-berlin.de and cabo@informatik.uni-bremen.de.
Good luck,
Jutta Degener,
Carsten Bormann
--
Copyright 1992, 1993, 1994, by Jutta Degener and Carsten Bormann,
Technische Universitaet Berlin. See the accompanying file "COPYRIGHT"
for details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.

View file

@ -1,11 +0,0 @@
The gsm library has been tested successfully on the following platforms:
- Various Sun4's running SunOS 4.1.2
- SPARC1 (SunOS 4.1.1)
- Integrated Solutions 68k Optimum running 4.3BSD UNIX with a Green Hills cc
- NeXTstation running NeXT-OS/Mach 3.0
- No-name AT/386 with Xenix 2.3.2 (using -DSTUPID_COMPILER)
- RS/6000-350 running AIX 3.2.0
- RS/6000-320 running AIX 3.1.5
- Alliant FX80 (Concentrix 5.7)
- SGI Indigo XS4000 (IRIX 4.0.5F)

View file

@ -1,59 +0,0 @@
gsm-1.0/COPYRIGHT
gsm-1.0/ChangeLog
gsm-1.0/INSTALL
gsm-1.0/MACHINES
gsm-1.0/MANIFEST
gsm-1.0/Makefile
gsm-1.0/README
gsm-1.0/add-test/add_test.c
gsm-1.0/add-test/add_test.dta
gsm-1.0/inc/gsm.h
gsm-1.0/inc/proto.h
gsm-1.0/inc/unproto.h
gsm-1.0/inc/config.h
gsm-1.0/inc/private.h
gsm-1.0/inc/toast.h
gsm-1.0/man/bitter.1
gsm-1.0/man/gsm.3
gsm-1.0/man/gsm_explode.3
gsm-1.0/man/gsm_print.3
gsm-1.0/man/gsm_option.3
gsm-1.0/man/toast.1
gsm-1.0/src/add.c
gsm-1.0/src/code.c
gsm-1.0/src/debug.c
gsm-1.0/src/decode.c
gsm-1.0/src/gsm_destroy.c
gsm-1.0/src/gsm_decode.c
gsm-1.0/src/gsm_encode.c
gsm-1.0/src/gsm_explode.c
gsm-1.0/src/gsm_implode.c
gsm-1.0/src/gsm_create.c
gsm-1.0/src/gsm_print.c
gsm-1.0/src/gsm_option.c
gsm-1.0/src/long_term.c
gsm-1.0/src/lpc.c
gsm-1.0/src/preprocess.c
gsm-1.0/src/rpe.c
gsm-1.0/src/short_term.c
gsm-1.0/src/table.c
gsm-1.0/src/toast.c
gsm-1.0/src/toast_alaw.c
gsm-1.0/src/toast_audio.c
gsm-1.0/src/toast_lin.c
gsm-1.0/src/toast_ulaw.c
gsm-1.0/tls/bitter.c
gsm-1.0/tls/bitter.dta
gsm-1.0/tls/taste.c
gsm-1.0/tls/taste.h
gsm-1.0/tls/sweet.c
gsm-1.0/tls/sour.c
gsm-1.0/tls/sour1.dta
gsm-1.0/tls/sour2.dta
gsm-1.0/tls/ginger.c
gsm-1.0/tst/cod2lin.c
gsm-1.0/tst/cod2txt.c
gsm-1.0/tst/gsm2cod.c
gsm-1.0/tst/lin2cod.c
gsm-1.0/tst/lin2txt.c
gsm-1.0/tst/run

View file

@ -1,26 +0,0 @@
EXTRA_DIST= ChangeLog INSTALL MACHINES MANIFEST README COPYRIGHT
noinst_LTLIBRARIES= libgsm.la
libgsm_la_SOURCES= gsmadd.c proto.h unproto.h config.h private.h gsm.h toast.h \
code.c proto.h unproto.h config.h private.h gsm.h toast.h \
debug.c proto.h unproto.h config.h private.h gsm.h toast.h \
decode.c proto.h unproto.h config.h private.h gsm.h toast.h \
long_term.c proto.h unproto.h config.h private.h gsm.h toast.h \
lpc.c proto.h unproto.h config.h private.h gsm.h toast.h \
preprocess.c proto.h unproto.h config.h private.h gsm.h toast.h \
rpe.c proto.h unproto.h config.h private.h gsm.h toast.h \
gsm_destroy.c proto.h unproto.h config.h private.h gsm.h toast.h \
gsm_decode.c proto.h unproto.h config.h private.h gsm.h toast.h \
gsm_encode.c proto.h unproto.h config.h private.h gsm.h toast.h \
gsm_explode.c proto.h unproto.h config.h private.h gsm.h toast.h \
gsm_implode.c proto.h unproto.h config.h private.h gsm.h toast.h \
gsm_create.c proto.h unproto.h config.h private.h gsm.h toast.h \
gsm_print.c proto.h unproto.h config.h private.h gsm.h toast.h \
gsm_option.c proto.h unproto.h config.h private.h gsm.h toast.h \
short_term.c proto.h unproto.h config.h private.h gsm.h toast.h \
table.c proto.h unproto.h config.h private.h gsm.h toast.h
AM_CFLAGS=-w

View file

@ -1,37 +0,0 @@
GSM 06.10 13 kbit/s RPE/LTP speech compression available
--------------------------------------------------------
The Communications and Operating Systems Research Group (KBS) at the
Technische Universitaet Berlin is currently working on a set of
UNIX-based tools for computer-mediated telecooperation that will be
made freely available.
As part of this effort we are publishing an implementation of the
European GSM 06.10 provisional standard for full-rate speech
transcoding, prI-ETS 300 036, which uses RPE/LTP (residual pulse
excitation/long term prediction) coding at 13 kbit/s.
GSM 06.10 compresses frames of 160 13-bit samples (8 kHz sampling
rate, i.e. a frame rate of 50 Hz) into 260 bits; for compatibility
with typical UNIX applications, our implementation turns frames of 160
16-bit linear samples into 33-byte frames (1650 Bytes/s).
The quality of the algorithm is good enough for reliable speaker
recognition; even music often survives transcoding in recognizable
form (given the bandwidth limitations of 8 kHz sampling rate).
The interfaces offered are a front end modelled after compress(1), and
a library API. Compression and decompression run faster than realtime
on most SPARCstations. The implementation has been verified against the
ETSI standard test patterns.
Jutta Degener (jutta@cs.tu-berlin.de)
Carsten Bormann (cabo@cs.tu-berlin.de)
Communications and Operating Systems Research Group, TU Berlin
Fax: +49.30.31425156, Phone: +49.30.31424315
--
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.

View file

@ -1,99 +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/code.c,v 1.1.1.1 2001/11/19 19:50:11 smorlat Exp $ */
#include "config.h"
#ifdef HAS_STDLIB_H
#include <stdlib.h>
#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) );
}

View file

@ -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 */

View file

@ -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 <stdio.h>
#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

View file

@ -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 <stdio.h>
#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);
}

View file

@ -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 <stdio.h> /* 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 */

View file

@ -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 <string.h>
#else
# include "proto.h"
extern char * memset P((char *, int, int));
#endif
#ifdef HAS_STDLIB_H
# include <stdlib.h>
#else
# ifdef HAS_MALLOC_H
# include <malloc.h>
# else
extern char * malloc();
# endif
#endif
#include <stdio.h>
#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;
}

View file

@ -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;
}

View file

@ -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 <stdlib.h>
#else
# ifdef HAS_MALLOC_H
# include <malloc.h>
# else
extern void free();
# endif
#endif
void gsm_destroy P1((S), gsm S)
{
if (S) free((char *)S);
}

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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 <stdio.h>
#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;
}

View file

@ -1,67 +0,0 @@
#include "gsm_wrapper.h"
#include <stdlib.h>
/* 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);
}

View file

@ -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

View file

@ -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 <stdio.h>
#include <assert.h>
#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;
}

View file

@ -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 <stdio.h>
#include <assert.h>
#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 ];
}

View file

@ -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 <stdio.h>
#include <assert.h>
#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 : (temp<MIC ? 0 : temp - MIC); \
LAR++;
STEP( 20480, 0, 31, -32 );
STEP( 20480, 0, 31, -32 );
STEP( 20480, 2048, 15, -16 );
STEP( 20480, -2560, 15, -16 );
STEP( 13964, 94, 7, -8 );
STEP( 15360, -1792, 7, -8 );
STEP( 8534, -341, 3, -4 );
STEP( 9036, -1144, 3, -4 );
# undef STEP
}
void Gsm_LPC_Analysis P3((S, s,LARc),
struct gsm_state *S,
word * s, /* 0..159 signals IN/OUT */
word * LARc) /* 0..7 LARc's OUT */
{
longword L_ACF[9];
#if defined(USE_FLOAT_MUL) && defined(FAST)
if (S->fast) 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);
}

View file

@ -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 <stdio.h>
#include <assert.h>
#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;
}

View file

@ -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 */

View file

@ -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 */

View file

@ -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 <stdio.h>
#include <assert.h>
#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 );
}

View file

@ -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 <stdio.h>
#include <assert.h>
#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);
}

View file

@ -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 };

View file

@ -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 <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <errno.h>
#ifndef HAS_ERRNO_DECL
extern int errno;
#endif
#ifdef HAS_LIMITS_H
#include <limits.h>
#endif
#ifdef HAS_FCNTL_H
# include <fcntl.h>
#endif
#ifdef HAS_UTIME
# ifdef HAS_UTIME_H
# include <utime.h>
# 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 <string.h>
#else
# ifdef HAS_STRINGS_H
# include <strings.h>
# 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 <stdlib.h>
#else
# include "proto.h"
# ifdef HAS_MALLOC_H
# include <malloc.h>
# else
extern char * malloc P((unsigned));
# endif
extern int exit P((int));
# include "unproto.h"
#endif
#ifdef HAS_UNISTD_H
# include <unistd.h>
#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 */

View file

@ -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 */

View file

@ -1,5 +0,0 @@
.deps
.libs
Makefile
Makefile.in
linphone

View file

@ -1,32 +0,0 @@
<oaf_info>
<oaf_server iid="OAFIID:GNOME_LinphoneApplet_Factory"
type="exe"
location="@LIBEXECDIR@/linphone_applet">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:Bonobo/GenericFactory:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" value="Linphone Applet Factory"/>
<oaf_attribute name="description" type="string" value="Linphone Applet Factory"/>
</oaf_server>
<oaf_server iid="OAFIID:GNOME_LinphoneApplet"
type="factory"
location="OAFIID:GNOME_LinphoneApplet_Factory">
<oaf_attribute name="repo_ids" type="stringv">
<item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
<item value="IDL:Bonobo/Control:1.0"/>
<item value="IDL:Bonobo/Unknown:1.0"/>
</oaf_attribute>
<oaf_attribute name="name" type="string" _value="Linphone"/>
<oaf_attribute name="description" type="string" _value="Linphone"/>
<oaf_attribute name="panel:category" type="string" _value="Internet"/>
<oaf_attribute name="panel:icon" type="string" value="linphone/linphone2.png"/>
</oaf_server>
</oaf_info>

View file

@ -1,7 +0,0 @@
<Root>
<popups>
<popup name="button3">
<menuitem name="About" verb="About" _label="_About..." pixtype="stock" pixname="gnome-stock-about"/>
</popup>
</popups>
</Root>

View file

@ -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

View file

@ -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 <<sip:truc@bidule>>" */
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));
}

View file

@ -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

View file

@ -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 <panel-applet.h>
#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)

View file

@ -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 <gdk/gdkkeysyms.h>
#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));
}

View file

@ -1,545 +0,0 @@
#include <gtk/gtk.h>
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);

View file

@ -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);
}

View file

@ -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 <interface.h>
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);

View file

@ -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);
}

View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -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);

View file

@ -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 <config.h>
#endif
#include "linphone.h"
#include "support.h"
#include "interface.h"
#include "callbacks.h"
#include "gui_utils.h"
#include "lpconfig.h"
#include <glib.h>
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);
}

View file

@ -1,68 +0,0 @@
#ifndef LINPHONE_H
#define LINPHONE_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libintl.h>
#define _(String) gettext (String)
#include <linphonecore.h>
#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

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -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 <config.h>
#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);

View file

@ -1,144 +0,0 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>
#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);
}
}

Some files were not shown because too many files have changed in this diff Show more