* #27232: jni: added pjproject checkout as regular git content
We will remove it once the next release of pjsip (with Android support)
comes out and is merged into SFLphone.
diff --git a/jni/pjproject-android/.svn/pristine/58/588133fef5786b18b54a15678c28b42983ea9ed2.svn-base b/jni/pjproject-android/.svn/pristine/58/588133fef5786b18b54a15678c28b42983ea9ed2.svn-base
new file mode 100644
index 0000000..d718b65
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/58/588133fef5786b18b54a15678c28b42983ea9ed2.svn-base
@@ -0,0 +1,1266 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.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
+ */
+#ifndef __PJMEDIA_CONFIG_H__
+#define __PJMEDIA_CONFIG_H__
+
+/**
+ * @file pjmedia/config.h Compile time config
+ * @brief Contains some compile time constants.
+ */
+#include <pj/config.h>
+
+/**
+ * @defgroup PJMEDIA_BASE Base Types and Configurations
+ */
+
+/**
+ * @defgroup PJMEDIA_CONFIG Compile time configuration
+ * @ingroup PJMEDIA_BASE
+ * @brief Some compile time configuration settings.
+ * @{
+ */
+
+/*
+ * Include config_auto.h if autoconf is used (PJ_AUTOCONF is set)
+ */
+#if defined(PJ_AUTOCONF)
+# include <pjmedia/config_auto.h>
+#endif
+
+/**
+ * Specify whether we prefer to use audio switch board rather than
+ * conference bridge.
+ *
+ * Audio switch board is a kind of simplified version of conference
+ * bridge, but not really the subset of conference bridge. It has
+ * stricter rules on audio routing among the pjmedia ports and has
+ * no audio mixing capability. The power of it is it could work with
+ * encoded audio frames where conference brigde couldn't.
+ *
+ * Default: 0
+ */
+#ifndef PJMEDIA_CONF_USE_SWITCH_BOARD
+# define PJMEDIA_CONF_USE_SWITCH_BOARD 0
+#endif
+
+/**
+ * Specify buffer size for audio switch board, in bytes. This buffer will
+ * be used for transmitting/receiving audio frame data (and some overheads,
+ * i.e: pjmedia_frame structure) among conference ports in the audio
+ * switch board. For example, if a port uses PCM format @44100Hz mono
+ * and frame time 20ms, the PCM audio data will require 1764 bytes,
+ * so with overhead, a safe buffer size will be ~1900 bytes.
+ *
+ * Default: PJMEDIA_MAX_MTU
+ */
+#ifndef PJMEDIA_CONF_SWITCH_BOARD_BUF_SIZE
+# define PJMEDIA_CONF_SWITCH_BOARD_BUF_SIZE PJMEDIA_MAX_MTU
+#endif
+
+
+/*
+ * Types of sound stream backends.
+ */
+
+/**
+ * This macro has been deprecated in releasee 1.1. Please see
+ * http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more information.
+ */
+#if defined(PJMEDIA_SOUND_IMPLEMENTATION)
+# error PJMEDIA_SOUND_IMPLEMENTATION has been deprecated
+#endif
+
+/**
+ * This macro has been deprecated in releasee 1.1. Please see
+ * http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more information.
+ */
+#if defined(PJMEDIA_PREFER_DIRECT_SOUND)
+# error PJMEDIA_PREFER_DIRECT_SOUND has been deprecated
+#endif
+
+/**
+ * This macro controls whether the legacy sound device API is to be
+ * implemented, for applications that still use the old sound device
+ * API (sound.h). If this macro is set to non-zero, the sound_legacy.c
+ * will be included in the compilation. The sound_legacy.c is an
+ * implementation of old sound device (sound.h) using the new Audio
+ * Device API.
+ *
+ * Please see http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more
+ * info.
+ */
+#ifndef PJMEDIA_HAS_LEGACY_SOUND_API
+# define PJMEDIA_HAS_LEGACY_SOUND_API 1
+#endif
+
+/**
+ * Specify default sound device latency, in milisecond.
+ */
+#ifndef PJMEDIA_SND_DEFAULT_REC_LATENCY
+# define PJMEDIA_SND_DEFAULT_REC_LATENCY 100
+#endif
+
+/**
+ * Specify default sound device latency, in milisecond.
+ *
+ * Default is 160ms for Windows Mobile and 140ms for other platforms.
+ */
+#ifndef PJMEDIA_SND_DEFAULT_PLAY_LATENCY
+# if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0
+# define PJMEDIA_SND_DEFAULT_PLAY_LATENCY 160
+# else
+# define PJMEDIA_SND_DEFAULT_PLAY_LATENCY 140
+# endif
+#endif
+
+
+/*
+ * Types of WSOLA backend algorithm.
+ */
+
+/**
+ * This denotes implementation of WSOLA using null algorithm. Expansion
+ * will generate zero frames, and compression will just discard some
+ * samples from the input.
+ *
+ * This type of implementation may be used as it requires the least
+ * processing power.
+ */
+#define PJMEDIA_WSOLA_IMP_NULL 0
+
+/**
+ * This denotes implementation of WSOLA using fixed or floating point WSOLA
+ * algorithm. This implementation provides the best quality of the result,
+ * at the expense of one frame delay and intensive processing power
+ * requirement.
+ */
+#define PJMEDIA_WSOLA_IMP_WSOLA 1
+
+/**
+ * This denotes implementation of WSOLA algorithm with faster waveform
+ * similarity calculation. This implementation provides fair quality of
+ * the result with the main advantage of low processing power requirement.
+ */
+#define PJMEDIA_WSOLA_IMP_WSOLA_LITE 2
+
+/**
+ * Specify type of Waveform based Similarity Overlap and Add (WSOLA) backend
+ * implementation to be used. WSOLA is an algorithm to expand and/or compress
+ * audio frames without changing the pitch, and used by the delaybuf and as PLC
+ * backend algorithm.
+ *
+ * Default is PJMEDIA_WSOLA_IMP_WSOLA
+ */
+#ifndef PJMEDIA_WSOLA_IMP
+# define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA
+#endif
+
+
+/**
+ * Specify the default maximum duration of synthetic audio that is generated
+ * by WSOLA. This value should be long enough to cover burst of packet losses.
+ * but not too long, because as the duration increases the quality would
+ * degrade considerably.
+ *
+ * Note that this limit is only applied when fading is enabled in the WSOLA
+ * session.
+ *
+ * Default: 80
+ */
+#ifndef PJMEDIA_WSOLA_MAX_EXPAND_MSEC
+# define PJMEDIA_WSOLA_MAX_EXPAND_MSEC 80
+#endif
+
+
+/**
+ * Specify WSOLA template length, in milliseconds. The longer the template,
+ * the smoother signal to be generated at the expense of more computation
+ * needed, since the algorithm will have to compare more samples to find
+ * the most similar pitch.
+ *
+ * Default: 5
+ */
+#ifndef PJMEDIA_WSOLA_TEMPLATE_LENGTH_MSEC
+# define PJMEDIA_WSOLA_TEMPLATE_LENGTH_MSEC 5
+#endif
+
+
+/**
+ * Specify WSOLA algorithm delay, in milliseconds. The algorithm delay is
+ * used to merge synthetic samples with real samples in the transition
+ * between real to synthetic and vice versa. The longer the delay, the
+ * smoother signal to be generated, at the expense of longer latency and
+ * a slighty more computation.
+ *
+ * Default: 5
+ */
+#ifndef PJMEDIA_WSOLA_DELAY_MSEC
+# define PJMEDIA_WSOLA_DELAY_MSEC 5
+#endif
+
+
+/**
+ * Set this to non-zero to disable fade-out/in effect in the PLC when it
+ * instructs WSOLA to generate synthetic frames. The use of fading may
+ * or may not improve the quality of audio, depending on the nature of
+ * packet loss and the type of audio input (e.g. speech vs music).
+ * Disabling fading also implicitly remove the maximum limit of synthetic
+ * audio samples generated by WSOLA (see PJMEDIA_WSOLA_MAX_EXPAND_MSEC).
+ *
+ * Default: 0
+ */
+#ifndef PJMEDIA_WSOLA_PLC_NO_FADING
+# define PJMEDIA_WSOLA_PLC_NO_FADING 0
+#endif
+
+
+/**
+ * Limit the number of calls by stream to the PLC to generate synthetic
+ * frames to this duration. If packets are still lost after this maximum
+ * duration, silence will be generated by the stream instead. Since the
+ * PLC normally should have its own limit on the maximum duration of
+ * synthetic frames to be generated (for PJMEDIA's PLC, the limit is
+ * PJMEDIA_WSOLA_MAX_EXPAND_MSEC), we can set this value to a large number
+ * to give additional flexibility should the PLC wants to do something
+ * clever with the lost frames.
+ *
+ * Default: 240 ms
+ */
+#ifndef PJMEDIA_MAX_PLC_DURATION_MSEC
+# define PJMEDIA_MAX_PLC_DURATION_MSEC 240
+#endif
+
+
+/**
+ * Specify number of sound buffers. Larger number is better for sound
+ * stability and to accommodate sound devices that are unable to send frames
+ * in timely manner, however it would probably cause more audio delay (and
+ * definitely will take more memory). One individual buffer is normally 10ms
+ * or 20 ms long, depending on ptime settings (samples_per_frame value).
+ *
+ * The setting here currently is used by the conference bridge, the splitter
+ * combiner port, and dsound.c.
+ *
+ * Default: (PJMEDIA_SND_DEFAULT_PLAY_LATENCY+20)/20
+ */
+#ifndef PJMEDIA_SOUND_BUFFER_COUNT
+# define PJMEDIA_SOUND_BUFFER_COUNT ((PJMEDIA_SND_DEFAULT_PLAY_LATENCY+20)/20)
+#endif
+
+
+/**
+ * Specify which A-law/U-law conversion algorithm to use.
+ * By default the conversion algorithm uses A-law/U-law table which gives
+ * the best performance, at the expense of 33 KBytes of static data.
+ * If this option is disabled, a smaller but slower algorithm will be used.
+ */
+#ifndef PJMEDIA_HAS_ALAW_ULAW_TABLE
+# define PJMEDIA_HAS_ALAW_ULAW_TABLE 1
+#endif
+
+
+/**
+ * Unless specified otherwise, G711 codec is included by default.
+ */
+#ifndef PJMEDIA_HAS_G711_CODEC
+# define PJMEDIA_HAS_G711_CODEC 1
+#endif
+
+
+/*
+ * Warn about obsolete macros.
+ *
+ * PJMEDIA_HAS_SMALL_FILTER has been deprecated in 0.7.
+ */
+#if defined(PJMEDIA_HAS_SMALL_FILTER)
+# ifdef _MSC_VER
+# pragma message("Warning: PJMEDIA_HAS_SMALL_FILTER macro is deprecated"\
+ " and has no effect")
+# else
+# warning "PJMEDIA_HAS_SMALL_FILTER macro is deprecated and has no effect"
+# endif
+#endif
+
+
+/*
+ * Warn about obsolete macros.
+ *
+ * PJMEDIA_HAS_LARGE_FILTER has been deprecated in 0.7.
+ */
+#if defined(PJMEDIA_HAS_LARGE_FILTER)
+# ifdef _MSC_VER
+# pragma message("Warning: PJMEDIA_HAS_LARGE_FILTER macro is deprecated"\
+ " and has no effect")
+# else
+# warning "PJMEDIA_HAS_LARGE_FILTER macro is deprecated"
+# endif
+#endif
+
+
+/*
+ * These macros are obsolete in 0.7.1 so it will trigger compilation error.
+ * Please use PJMEDIA_RESAMPLE_IMP to select the resample implementation
+ * to use.
+ */
+#ifdef PJMEDIA_HAS_LIBRESAMPLE
+# error "PJMEDIA_HAS_LIBRESAMPLE macro is deprecated. Use '#define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_LIBRESAMPLE'"
+#endif
+
+#ifdef PJMEDIA_HAS_SPEEX_RESAMPLE
+# error "PJMEDIA_HAS_SPEEX_RESAMPLE macro is deprecated. Use '#define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_SPEEX'"
+#endif
+
+
+/*
+ * Sample rate conversion backends.
+ * Select one of these backends in PJMEDIA_RESAMPLE_IMP.
+ */
+#define PJMEDIA_RESAMPLE_NONE 1 /**< No resampling. */
+#define PJMEDIA_RESAMPLE_LIBRESAMPLE 2 /**< Sample rate conversion
+ using libresample. */
+#define PJMEDIA_RESAMPLE_SPEEX 3 /**< Sample rate conversion
+ using Speex. */
+#define PJMEDIA_RESAMPLE_LIBSAMPLERATE 4 /**< Sample rate conversion
+ using libsamplerate
+ (a.k.a Secret Rabbit Code)
+ */
+
+/**
+ * Select which resample implementation to use. Currently pjmedia supports:
+ * - #PJMEDIA_RESAMPLE_LIBRESAMPLE, to use libresample-1.7, this is the default
+ * implementation to be used.
+ * - #PJMEDIA_RESAMPLE_LIBSAMPLERATE, to use libsamplerate implementation
+ * (a.k.a. Secret Rabbit Code).
+ * - #PJMEDIA_RESAMPLE_SPEEX, to use experimental sample rate conversion in
+ * Speex library.
+ * - #PJMEDIA_RESAMPLE_NONE, to disable sample rate conversion. Any calls to
+ * resample function will return error.
+ *
+ * Default is PJMEDIA_RESAMPLE_LIBRESAMPLE
+ */
+#ifndef PJMEDIA_RESAMPLE_IMP
+# define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_LIBRESAMPLE
+#endif
+
+
+/**
+ * Specify whether libsamplerate, when used, should be linked statically
+ * into the application. This option is only useful for Visual Studio
+ * projects, and when this static linking is enabled
+ */
+
+
+/**
+ * Default file player/writer buffer size.
+ */
+#ifndef PJMEDIA_FILE_PORT_BUFSIZE
+# define PJMEDIA_FILE_PORT_BUFSIZE 4000
+#endif
+
+
+/**
+ * Maximum frame duration (in msec) to be supported.
+ * This (among other thing) will affect the size of buffers to be allocated
+ * for outgoing packets.
+ */
+#ifndef PJMEDIA_MAX_FRAME_DURATION_MS
+# define PJMEDIA_MAX_FRAME_DURATION_MS 200
+#endif
+
+
+/**
+ * Max packet size for transmitting direction.
+ */
+#ifndef PJMEDIA_MAX_MTU
+# define PJMEDIA_MAX_MTU 1500
+#endif
+
+
+/**
+ * Max packet size for receiving direction.
+ */
+#ifndef PJMEDIA_MAX_MRU
+# define PJMEDIA_MAX_MRU 2000
+#endif
+
+
+/**
+ * DTMF/telephone-event duration, in timestamp.
+ */
+#ifndef PJMEDIA_DTMF_DURATION
+# define PJMEDIA_DTMF_DURATION 1600 /* in timestamp */
+#endif
+
+
+/**
+ * Number of RTP packets received from different source IP address from the
+ * remote address required to make the stream switch transmission
+ * to the source address.
+ */
+#ifndef PJMEDIA_RTP_NAT_PROBATION_CNT
+# define PJMEDIA_RTP_NAT_PROBATION_CNT 10
+#endif
+
+
+/**
+ * Number of RTCP packets received from different source IP address from the
+ * remote address required to make the stream switch RTCP transmission
+ * to the source address.
+ */
+#ifndef PJMEDIA_RTCP_NAT_PROBATION_CNT
+# define PJMEDIA_RTCP_NAT_PROBATION_CNT 3
+#endif
+
+
+/**
+ * Specify whether RTCP should be advertised in SDP. This setting would
+ * affect whether RTCP candidate will be added in SDP when ICE is used.
+ * Application might want to disable RTCP advertisement in SDP to
+ * reduce the message size.
+ *
+ * Default: 1 (yes)
+ */
+#ifndef PJMEDIA_ADVERTISE_RTCP
+# define PJMEDIA_ADVERTISE_RTCP 1
+#endif
+
+
+/**
+ * Interval to send RTCP packets, in msec
+ */
+#ifndef PJMEDIA_RTCP_INTERVAL
+# define PJMEDIA_RTCP_INTERVAL 5000 /* msec*/
+#endif
+
+
+/**
+ * Tell RTCP to ignore the first N packets when calculating the
+ * jitter statistics. From experimentation, the first few packets
+ * (25 or so) have relatively big jitter, possibly because during
+ * this time, the program is also busy setting up the signaling,
+ * so they make the average jitter big.
+ *
+ * Default: 25.
+ */
+#ifndef PJMEDIA_RTCP_IGNORE_FIRST_PACKETS
+# define PJMEDIA_RTCP_IGNORE_FIRST_PACKETS 25
+#endif
+
+
+/**
+ * Specify whether RTCP statistics includes raw jitter statistics.
+ * Raw jitter is defined as absolute value of network transit time
+ * difference of two consecutive packets; refering to "difference D"
+ * term in interarrival jitter calculation in RFC 3550 section 6.4.1.
+ *
+ * Default: 0 (no).
+ */
+#ifndef PJMEDIA_RTCP_STAT_HAS_RAW_JITTER
+# define PJMEDIA_RTCP_STAT_HAS_RAW_JITTER 0
+#endif
+
+/**
+ * Specify the factor with wich RTCP RTT statistics should be normalized
+ * if exceptionally high. For e.g. mobile networks with potentially large
+ * fluctuations, this might be unwanted.
+ *
+ * Use (0) to disable this feature.
+ *
+ * Default: 3.
+ */
+#ifndef PJMEDIA_RTCP_NORMALIZE_FACTOR
+# define PJMEDIA_RTCP_NORMALIZE_FACTOR 3
+#endif
+
+
+/**
+ * Specify whether RTCP statistics includes IP Delay Variation statistics.
+ * IPDV is defined as network transit time difference of two consecutive
+ * packets. The IPDV statistic can be useful to inspect clock skew existance
+ * and level, e.g: when the IPDV mean values were stable in positive numbers,
+ * then the remote clock (used in sending RTP packets) is faster than local
+ * system clock. Ideally, the IPDV mean values are always equal to 0.
+ *
+ * Default: 0 (no).
+ */
+#ifndef PJMEDIA_RTCP_STAT_HAS_IPDV
+# define PJMEDIA_RTCP_STAT_HAS_IPDV 0
+#endif
+
+
+/**
+ * Specify whether RTCP XR support should be built into PJMEDIA. Disabling
+ * this feature will reduce footprint slightly. Note that even when this
+ * setting is enabled, RTCP XR processing will only be performed in stream
+ * if it is enabled on run-time on per stream basis. See
+ * PJMEDIA_STREAM_ENABLE_XR setting for more info.
+ *
+ * Default: 0 (no).
+ */
+#ifndef PJMEDIA_HAS_RTCP_XR
+# define PJMEDIA_HAS_RTCP_XR 0
+#endif
+
+
+/**
+ * The RTCP XR feature is activated and used by stream if \a enable_rtcp_xr
+ * field of \a pjmedia_stream_info structure is non-zero. This setting
+ * controls the default value of this field.
+ *
+ * Default: 0 (disabled)
+ */
+#ifndef PJMEDIA_STREAM_ENABLE_XR
+# define PJMEDIA_STREAM_ENABLE_XR 0
+#endif
+
+
+/**
+ * Specify the buffer length for storing any received RTCP SDES text
+ * in a stream session. Usually RTCP contains only the mandatory SDES
+ * field, i.e: CNAME.
+ *
+ * Default: 64 bytes.
+ */
+#ifndef PJMEDIA_RTCP_RX_SDES_BUF_LEN
+# define PJMEDIA_RTCP_RX_SDES_BUF_LEN 64
+#endif
+
+
+/**
+ * Specify how long (in miliseconds) the stream should suspend the
+ * silence detector/voice activity detector (VAD) during the initial
+ * period of the session. This feature is useful to open bindings in
+ * all NAT routers between local and remote endpoint since most NATs
+ * do not allow incoming packet to get in before local endpoint sends
+ * outgoing packets.
+ *
+ * Specify zero to disable this feature.
+ *
+ * Default: 600 msec (which gives good probability that some RTP
+ * packets will reach the destination, but without
+ * filling up the jitter buffer on the remote end).
+ */
+#ifndef PJMEDIA_STREAM_VAD_SUSPEND_MSEC
+# define PJMEDIA_STREAM_VAD_SUSPEND_MSEC 600
+#endif
+
+/**
+ * Perform RTP payload type checking in the stream. Normally the peer
+ * MUST send RTP with payload type as we specified in our SDP. Certain
+ * agents may not be able to follow this hence the only way to have
+ * communication is to disable this check.
+ *
+ * Default: 1
+ */
+#ifndef PJMEDIA_STREAM_CHECK_RTP_PT
+# define PJMEDIA_STREAM_CHECK_RTP_PT 1
+#endif
+
+/**
+ * Reserve some space for application extra data, e.g: SRTP auth tag,
+ * in RTP payload, so the total payload length will not exceed the MTU.
+ */
+#ifndef PJMEDIA_STREAM_RESV_PAYLOAD_LEN
+# define PJMEDIA_STREAM_RESV_PAYLOAD_LEN 20
+#endif
+
+
+/**
+ * Specify the maximum duration of silence period in the codec, in msec.
+ * This is useful for example to keep NAT binding open in the firewall
+ * and to prevent server from disconnecting the call because no
+ * RTP packet is received.
+ *
+ * This only applies to codecs that use PJMEDIA's VAD (pretty much
+ * everything including iLBC, except Speex, which has its own DTX
+ * mechanism).
+ *
+ * Use (-1) to disable this feature.
+ *
+ * Default: 5000 ms
+ *
+ */
+#ifndef PJMEDIA_CODEC_MAX_SILENCE_PERIOD
+# define PJMEDIA_CODEC_MAX_SILENCE_PERIOD 5000
+#endif
+
+
+/**
+ * Suggested or default threshold to be set for fixed silence detection
+ * or as starting threshold for adaptive silence detection. The threshold
+ * has the range from zero to 0xFFFF.
+ */
+#ifndef PJMEDIA_SILENCE_DET_THRESHOLD
+# define PJMEDIA_SILENCE_DET_THRESHOLD 4
+#endif
+
+
+/**
+ * Maximum silence threshold in the silence detector. The silence detector
+ * will not cut the audio transmission if the audio level is above this
+ * level.
+ *
+ * Use 0x10000 (or greater) to disable this feature.
+ *
+ * Default: 0x10000 (disabled)
+ */
+#ifndef PJMEDIA_SILENCE_DET_MAX_THRESHOLD
+# define PJMEDIA_SILENCE_DET_MAX_THRESHOLD 0x10000
+#endif
+
+
+/**
+ * Speex Accoustic Echo Cancellation (AEC).
+ * By default is enabled.
+ */
+#ifndef PJMEDIA_HAS_SPEEX_AEC
+# define PJMEDIA_HAS_SPEEX_AEC 1
+#endif
+
+
+/**
+ * Maximum number of parameters in SDP fmtp attribute.
+ *
+ * Default: 16
+ */
+#ifndef PJMEDIA_CODEC_MAX_FMTP_CNT
+# define PJMEDIA_CODEC_MAX_FMTP_CNT 16
+#endif
+
+
+/**
+ * This specifies the behavior of the SDP negotiator when responding to an
+ * offer, whether it should rather use the codec preference as set by
+ * remote, or should it rather use the codec preference as specified by
+ * local endpoint.
+ *
+ * For example, suppose incoming call has codec order "8 0 3", while
+ * local codec order is "3 0 8". If remote codec order is preferable,
+ * the selected codec will be 8, while if local codec order is preferable,
+ * the selected codec will be 3.
+ *
+ * If set to non-zero, the negotiator will use the codec order as specified
+ * by remote in the offer.
+ *
+ * Note that this behavior can be changed during run-time by calling
+ * pjmedia_sdp_neg_set_prefer_remote_codec_order().
+ *
+ * Default is 1 (to maintain backward compatibility)
+ */
+#ifndef PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER
+# define PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER 1
+#endif
+
+
+/**
+ * This specifies the maximum number of the customized SDP format
+ * negotiation callbacks.
+ */
+#ifndef PJMEDIA_SDP_NEG_MAX_CUSTOM_FMT_NEG_CB
+# define PJMEDIA_SDP_NEG_MAX_CUSTOM_FMT_NEG_CB 8
+#endif
+
+
+/**
+ * This specifies if the SDP negotiator should rewrite answer payload
+ * type numbers to use the same payload type numbers as the remote offer
+ * for all matched codecs.
+ *
+ * Default is 1 (yes)
+ */
+#ifndef PJMEDIA_SDP_NEG_ANSWER_SYMMETRIC_PT
+# define PJMEDIA_SDP_NEG_ANSWER_SYMMETRIC_PT 1
+#endif
+
+
+/**
+ * Support for sending and decoding RTCP port in SDP (RFC 3605).
+ * Default is equal to PJMEDIA_ADVERTISE_RTCP setting.
+ */
+#ifndef PJMEDIA_HAS_RTCP_IN_SDP
+# define PJMEDIA_HAS_RTCP_IN_SDP (PJMEDIA_ADVERTISE_RTCP)
+#endif
+
+
+/**
+ * This macro controls whether pjmedia should include SDP
+ * bandwidth modifier "TIAS" (RFC3890).
+ *
+ * Note that there is also a run-time variable to turn this setting
+ * on or off, defined in endpoint.c. To access this variable, use
+ * the following construct
+ *
+ \verbatim
+ extern pj_bool_t pjmedia_add_bandwidth_tias_in_sdp;
+
+ // Do not enable bandwidth information inclusion in sdp
+ pjmedia_add_bandwidth_tias_in_sdp = PJ_FALSE;
+ \endverbatim
+ *
+ * Default: 1 (yes)
+ */
+#ifndef PJMEDIA_ADD_BANDWIDTH_TIAS_IN_SDP
+# define PJMEDIA_ADD_BANDWIDTH_TIAS_IN_SDP 1
+#endif
+
+
+/**
+ * This macro controls whether pjmedia should include SDP rtpmap
+ * attribute for static payload types. SDP rtpmap for static
+ * payload types are optional, although they are normally included
+ * for interoperability reason.
+ *
+ * Note that there is also a run-time variable to turn this setting
+ * on or off, defined in endpoint.c. To access this variable, use
+ * the following construct
+ *
+ \verbatim
+ extern pj_bool_t pjmedia_add_rtpmap_for_static_pt;
+
+ // Do not include rtpmap for static payload types (<96)
+ pjmedia_add_rtpmap_for_static_pt = PJ_FALSE;
+ \endverbatim
+ *
+ * Default: 1 (yes)
+ */
+#ifndef PJMEDIA_ADD_RTPMAP_FOR_STATIC_PT
+# define PJMEDIA_ADD_RTPMAP_FOR_STATIC_PT 1
+#endif
+
+
+/**
+ * This macro declares the payload type for telephone-event
+ * that is advertised by PJMEDIA for outgoing SDP. If this macro
+ * is set to zero, telephone events would not be advertised nor
+ * supported.
+ *
+ * If this value is changed to other number, please update the
+ * PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR too.
+ */
+#ifndef PJMEDIA_RTP_PT_TELEPHONE_EVENTS
+# define PJMEDIA_RTP_PT_TELEPHONE_EVENTS 96
+#endif
+
+
+/**
+ * Macro to get the string representation of the telephone-event
+ * payload type.
+ */
+#ifndef PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR
+# define PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR "96"
+#endif
+
+
+/**
+ * Maximum tones/digits that can be enqueued in the tone generator.
+ */
+#ifndef PJMEDIA_TONEGEN_MAX_DIGITS
+# define PJMEDIA_TONEGEN_MAX_DIGITS 32
+#endif
+
+
+/*
+ * Below specifies the various tone generator backend algorithm.
+ */
+
+/**
+ * The math's sine(), floating point. This has very good precision
+ * but it's the slowest and requires floating point support and
+ * linking with the math library.
+ */
+#define PJMEDIA_TONEGEN_SINE 1
+
+/**
+ * Floating point approximation of sine(). This has relatively good
+ * precision and much faster than plain sine(), but it requires floating-
+ * point support and linking with the math library.
+ */
+#define PJMEDIA_TONEGEN_FLOATING_POINT 2
+
+/**
+ * Fixed point using sine signal generated by Cordic algorithm. This
+ * algorithm can be tuned to provide balance between precision and
+ * performance by tuning the PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP
+ * setting, and may be suitable for platforms that lack floating-point
+ * support.
+ */
+#define PJMEDIA_TONEGEN_FIXED_POINT_CORDIC 3
+
+/**
+ * Fast fixed point using some approximation to generate sine waves.
+ * The tone generated by this algorithm is not very precise, however
+ * the algorithm is very fast.
+ */
+#define PJMEDIA_TONEGEN_FAST_FIXED_POINT 4
+
+
+/**
+ * Specify the tone generator algorithm to be used. Please see
+ * http://trac.pjsip.org/repos/wiki/Tone_Generator for the performance
+ * analysis results of the various tone generator algorithms.
+ *
+ * Default value:
+ * - PJMEDIA_TONEGEN_FLOATING_POINT when PJ_HAS_FLOATING_POINT is set
+ * - PJMEDIA_TONEGEN_FIXED_POINT_CORDIC when PJ_HAS_FLOATING_POINT is not set
+ */
+#ifndef PJMEDIA_TONEGEN_ALG
+# if defined(PJ_HAS_FLOATING_POINT) && PJ_HAS_FLOATING_POINT
+# define PJMEDIA_TONEGEN_ALG PJMEDIA_TONEGEN_FLOATING_POINT
+# else
+# define PJMEDIA_TONEGEN_ALG PJMEDIA_TONEGEN_FIXED_POINT_CORDIC
+# endif
+#endif
+
+
+/**
+ * Specify the number of calculation loops to generate the tone, when
+ * PJMEDIA_TONEGEN_FIXED_POINT_CORDIC algorithm is used. With more calculation
+ * loops, the tone signal gets more precise, but this will add more
+ * processing.
+ *
+ * Valid values are 1 to 28.
+ *
+ * Default value: 10
+ */
+#ifndef PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP
+# define PJMEDIA_TONEGEN_FIXED_POINT_CORDIC_LOOP 10
+#endif
+
+
+/**
+ * Enable high quality of tone generation, the better quality will cost
+ * more CPU load. This is only applied to floating point enabled machines.
+ *
+ * By default it is enabled when PJ_HAS_FLOATING_POINT is set.
+ *
+ * This macro has been deprecated in version 1.0-rc3.
+ */
+#ifdef PJMEDIA_USE_HIGH_QUALITY_TONEGEN
+# error "The PJMEDIA_USE_HIGH_QUALITY_TONEGEN macro is obsolete"
+#endif
+
+
+/**
+ * Fade-in duration for the tone, in milliseconds. Set to zero to disable
+ * this feature.
+ *
+ * Default: 1 (msec)
+ */
+#ifndef PJMEDIA_TONEGEN_FADE_IN_TIME
+# define PJMEDIA_TONEGEN_FADE_IN_TIME 1
+#endif
+
+
+/**
+ * Fade-out duration for the tone, in milliseconds. Set to zero to disable
+ * this feature.
+ *
+ * Default: 2 (msec)
+ */
+#ifndef PJMEDIA_TONEGEN_FADE_OUT_TIME
+# define PJMEDIA_TONEGEN_FADE_OUT_TIME 2
+#endif
+
+
+/**
+ * The default tone generator amplitude (1-32767).
+ *
+ * Default value: 12288
+ */
+#ifndef PJMEDIA_TONEGEN_VOLUME
+# define PJMEDIA_TONEGEN_VOLUME 12288
+#endif
+
+
+/**
+ * Enable support for SRTP media transport. This will require linking
+ * with libsrtp from the third_party directory.
+ *
+ * By default it is enabled.
+ */
+#ifndef PJMEDIA_HAS_SRTP
+# define PJMEDIA_HAS_SRTP 1
+#endif
+
+
+/**
+ * Enable support to handle codecs with inconsistent clock rate
+ * between clock rate in SDP/RTP & the clock rate that is actually used.
+ * This happens for example with G.722 and MPEG audio codecs.
+ * See:
+ * - G.722 : RFC 3551 4.5.2
+ * - MPEG audio : RFC 3551 4.5.13 & RFC 3119
+ *
+ * Also when this feature is enabled, some handling will be performed
+ * to deal with clock rate incompatibilities of some phones.
+ *
+ * By default it is enabled.
+ */
+#ifndef PJMEDIA_HANDLE_G722_MPEG_BUG
+# define PJMEDIA_HANDLE_G722_MPEG_BUG 1
+#endif
+
+
+/**
+ * Transport info (pjmedia_transport_info) contains a socket info and list
+ * of transport specific info, since transports can be chained together
+ * (for example, SRTP transport uses UDP transport as the underlying
+ * transport). This constant specifies maximum number of transport specific
+ * infos that can be held in a transport info.
+ */
+#ifndef PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT
+# define PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXCNT 4
+#endif
+
+
+/**
+ * Maximum size in bytes of storage buffer of a transport specific info.
+ */
+#ifndef PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE
+# define PJMEDIA_TRANSPORT_SPECIFIC_INFO_MAXSIZE (36*sizeof(long))
+#endif
+
+
+/**
+ * Value to be specified in PJMEDIA_STREAM_ENABLE_KA setting.
+ * This indicates that an empty RTP packet should be used as
+ * the keep-alive packet.
+ */
+#define PJMEDIA_STREAM_KA_EMPTY_RTP 1
+
+/**
+ * Value to be specified in PJMEDIA_STREAM_ENABLE_KA setting.
+ * This indicates that a user defined packet should be used
+ * as the keep-alive packet. The content of the user-defined
+ * packet is specified by PJMEDIA_STREAM_KA_USER_PKT. Default
+ * content is a CR-LF packet.
+ */
+#define PJMEDIA_STREAM_KA_USER 2
+
+/**
+ * The content of the user defined keep-alive packet. The format
+ * of the packet is initializer to pj_str_t structure. Note that
+ * the content may contain NULL character.
+ */
+#ifndef PJMEDIA_STREAM_KA_USER_PKT
+# define PJMEDIA_STREAM_KA_USER_PKT { "\r\n", 2 }
+#endif
+
+/**
+ * Specify another type of keep-alive and NAT hole punching
+ * mechanism (the other type is PJMEDIA_STREAM_VAD_SUSPEND_MSEC
+ * and PJMEDIA_CODEC_MAX_SILENCE_PERIOD) to be used by stream.
+ * When this feature is enabled, the stream will initially
+ * transmit one packet to punch a hole in NAT, and periodically
+ * transmit keep-alive packets.
+ *
+ * When this alternative keep-alive mechanism is used, application
+ * may disable the other keep-alive mechanisms, i.e: by setting
+ * PJMEDIA_STREAM_VAD_SUSPEND_MSEC to zero and
+ * PJMEDIA_CODEC_MAX_SILENCE_PERIOD to -1.
+ *
+ * The value of this macro specifies the type of packet used
+ * for the keep-alive mechanism. Valid values are
+ * PJMEDIA_STREAM_KA_EMPTY_RTP and PJMEDIA_STREAM_KA_USER.
+ *
+ * The duration of the keep-alive interval further can be set
+ * with PJMEDIA_STREAM_KA_INTERVAL setting.
+ *
+ * Default: 0 (disabled)
+ */
+#ifndef PJMEDIA_STREAM_ENABLE_KA
+# define PJMEDIA_STREAM_ENABLE_KA 0
+#endif
+
+
+/**
+ * Specify the keep-alive interval of PJMEDIA_STREAM_ENABLE_KA
+ * mechanism, in seconds.
+ *
+ * Default: 5 seconds
+ */
+#ifndef PJMEDIA_STREAM_KA_INTERVAL
+# define PJMEDIA_STREAM_KA_INTERVAL 5
+#endif
+
+
+/*
+ * .... new stuffs ...
+ */
+
+/*
+ * Video
+ */
+
+/**
+ * Top level option to enable/disable video features.
+ *
+ * Default: 0 (disabled)
+ */
+#ifndef PJMEDIA_HAS_VIDEO
+# define PJMEDIA_HAS_VIDEO 0
+#endif
+
+
+/**
+ * Specify if FFMPEG is available. The value here will be used as the default
+ * value for other FFMPEG settings below.
+ *
+ * Default: 0
+ */
+#ifndef PJMEDIA_HAS_FFMPEG
+# define PJMEDIA_HAS_FFMPEG 0
+#endif
+
+/**
+ * Specify if FFMPEG libavformat is available.
+ *
+ * Default: PJMEDIA_HAS_FFMPEG (or detected by configure)
+ */
+#ifndef PJMEDIA_HAS_LIBAVFORMAT
+# define PJMEDIA_HAS_LIBAVFORMAT PJMEDIA_HAS_FFMPEG
+#endif
+
+/**
+ * Specify if FFMPEG libavformat is available.
+ *
+ * Default: PJMEDIA_HAS_FFMPEG (or detected by configure)
+ */
+#ifndef PJMEDIA_HAS_LIBAVCODEC
+# define PJMEDIA_HAS_LIBAVCODEC PJMEDIA_HAS_FFMPEG
+#endif
+
+/**
+ * Specify if FFMPEG libavutil is available.
+ *
+ * Default: PJMEDIA_HAS_FFMPEG (or detected by configure)
+ */
+#ifndef PJMEDIA_HAS_LIBAVUTIL
+# define PJMEDIA_HAS_LIBAVUTIL PJMEDIA_HAS_FFMPEG
+#endif
+
+/**
+ * Specify if FFMPEG libswscale is available.
+ *
+ * Default: PJMEDIA_HAS_FFMPEG (or detected by configure)
+ */
+#ifndef PJMEDIA_HAS_LIBSWSCALE
+# define PJMEDIA_HAS_LIBSWSCALE PJMEDIA_HAS_FFMPEG
+#endif
+
+/**
+ * Specify if FFMPEG libavdevice is available.
+ *
+ * Default: PJMEDIA_HAS_FFMPEG (or detected by configure)
+ */
+#ifndef PJMEDIA_HAS_LIBAVDEVICE
+# define PJMEDIA_HAS_LIBAVDEVICE PJMEDIA_HAS_FFMPEG
+#endif
+
+/**
+ * Specify if FFMPEG libavcore is available.
+ *
+ * Default: PJMEDIA_HAS_FFMPEG (or detected by configure)
+ */
+#ifndef PJMEDIA_HAS_LIBAVCORE
+# define PJMEDIA_HAS_LIBAVCORE PJMEDIA_HAS_FFMPEG
+#endif
+
+/**
+ * Maximum video planes.
+ *
+ * Default: 4
+ */
+#ifndef PJMEDIA_MAX_VIDEO_PLANES
+# define PJMEDIA_MAX_VIDEO_PLANES 4
+#endif
+
+/**
+ * Maximum number of video formats.
+ *
+ * Default: 32
+ */
+#ifndef PJMEDIA_MAX_VIDEO_FORMATS
+# define PJMEDIA_MAX_VIDEO_FORMATS 32
+#endif
+
+/**
+ * Specify the maximum time difference (in ms) for synchronization between
+ * two medias. If the synchronization media source is ahead of time
+ * greater than this duration, it is considered to make a very large jump
+ * and the synchronization will be reset.
+ *
+ * Default: 20000
+ */
+#ifndef PJMEDIA_CLOCK_SYNC_MAX_SYNC_MSEC
+# define PJMEDIA_CLOCK_SYNC_MAX_SYNC_MSEC 20000
+#endif
+
+/**
+ * Maximum video frame size.
+ * Default: 128kB
+ */
+#ifndef PJMEDIA_MAX_VIDEO_ENC_FRAME_SIZE
+# define PJMEDIA_MAX_VIDEO_ENC_FRAME_SIZE (1<<17)
+#endif
+
+
+/**
+ * Specify the maximum duration (in ms) for resynchronization. When a media
+ * is late to another media it is supposed to be synchronized to, it is
+ * guaranteed to be synchronized again after this duration. While if the
+ * media is ahead/early by t ms, it is guaranteed to be synchronized after
+ * t + this duration. This timing only applies if there is no additional
+ * resynchronization required during the specified duration.
+ *
+ * Default: 2000
+ */
+#ifndef PJMEDIA_CLOCK_SYNC_MAX_RESYNC_DURATION
+# define PJMEDIA_CLOCK_SYNC_MAX_RESYNC_DURATION 2000
+#endif
+
+
+/**
+ * Minimum gap between two consecutive discards in jitter buffer,
+ * in milliseconds.
+ *
+ * Default: 200 ms
+ */
+#ifndef PJMEDIA_JBUF_DISC_MIN_GAP
+# define PJMEDIA_JBUF_DISC_MIN_GAP 200
+#endif
+
+
+/**
+ * Minimum burst level reference used for calculating discard duration
+ * in jitter buffer progressive discard algorithm, in frames.
+ *
+ * Default: 1 frame
+ */
+#ifndef PJMEDIA_JBUF_PRO_DISC_MIN_BURST
+# define PJMEDIA_JBUF_PRO_DISC_MIN_BURST 1
+#endif
+
+
+/**
+ * Maximum burst level reference used for calculating discard duration
+ * in jitter buffer progressive discard algorithm, in frames.
+ *
+ * Default: 200 frames
+ */
+#ifndef PJMEDIA_JBUF_PRO_DISC_MAX_BURST
+# define PJMEDIA_JBUF_PRO_DISC_MAX_BURST 100
+#endif
+
+
+/**
+ * Duration for progressive discard algotithm in jitter buffer to discard
+ * an excessive frame when burst is equal to or lower than
+ * PJMEDIA_JBUF_PRO_DISC_MIN_BURST, in milliseconds.
+ *
+ * Default: 2000 ms
+ */
+#ifndef PJMEDIA_JBUF_PRO_DISC_T1
+# define PJMEDIA_JBUF_PRO_DISC_T1 2000
+#endif
+
+
+/**
+ * Duration for progressive discard algotithm in jitter buffer to discard
+ * an excessive frame when burst is equal to or greater than
+ * PJMEDIA_JBUF_PRO_DISC_MAX_BURST, in milliseconds.
+ *
+ * Default: 10000 ms
+ */
+#ifndef PJMEDIA_JBUF_PRO_DISC_T2
+# define PJMEDIA_JBUF_PRO_DISC_T2 10000
+#endif
+
+
+/**
+ * Video stream will discard old picture from the jitter buffer as soon as
+ * new picture is received, to reduce latency.
+ *
+ * Default: 0
+ */
+#ifndef PJMEDIA_VID_STREAM_SKIP_PACKETS_TO_REDUCE_LATENCY
+# define PJMEDIA_VID_STREAM_SKIP_PACKETS_TO_REDUCE_LATENCY 0
+#endif
+
+
+/**
+ * Maximum video payload size. Note that this must not be greater than
+ * PJMEDIA_MAX_MTU.
+ *
+ * Default: (PJMEDIA_MAX_MTU - 100)
+ */
+#ifndef PJMEDIA_MAX_VID_PAYLOAD_SIZE
+# define PJMEDIA_MAX_VID_PAYLOAD_SIZE (PJMEDIA_MAX_MTU - 100)
+#endif
+
+
+/**
+ * Specify target value for socket receive buffer size. It will be
+ * applied to RTP socket of media transport using setsockopt(). When
+ * transport failed to set the specified size, it will try with lower
+ * value until the highest possible is successfully set.
+ *
+ * Setting this to zero will leave the socket receive buffer size to
+ * OS default (e.g: usually 8 KB on desktop platforms).
+ *
+ * Default: 64 KB when video is enabled, otherwise zero (OS default)
+ */
+#ifndef PJMEDIA_TRANSPORT_SO_RCVBUF_SIZE
+# if PJMEDIA_HAS_VIDEO
+# define PJMEDIA_TRANSPORT_SO_RCVBUF_SIZE (64*1024)
+# else
+# define PJMEDIA_TRANSPORT_SO_RCVBUF_SIZE 0
+# endif
+#endif
+
+
+/**
+ * Specify target value for socket send buffer size. It will be
+ * applied to RTP socket of media transport using setsockopt(). When
+ * transport failed to set the specified size, it will try with lower
+ * value until the highest possible is successfully set.
+ *
+ * Setting this to zero will leave the socket send buffer size to
+ * OS default (e.g: usually 8 KB on desktop platforms).
+ *
+ * Default: 64 KB when video is enabled, otherwise zero (OS default)
+ */
+#ifndef PJMEDIA_TRANSPORT_SO_SNDBUF_SIZE
+# if PJMEDIA_HAS_VIDEO
+# define PJMEDIA_TRANSPORT_SO_SNDBUF_SIZE (64*1024)
+# else
+# define PJMEDIA_TRANSPORT_SO_SNDBUF_SIZE 0
+# endif
+#endif
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_CONFIG_H__ */
+
+
diff --git a/jni/pjproject-android/.svn/pristine/58/589aa995228ea2f8a74ef2e18e89b8c431f88e31.svn-base b/jni/pjproject-android/.svn/pristine/58/589aa995228ea2f8a74ef2e18e89b8c431f88e31.svn-base
new file mode 100644
index 0000000..35b0504
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/58/589aa995228ea2f8a74ef2e18e89b8c431f88e31.svn-base
@@ -0,0 +1,560 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2010-2011 Teluu Inc. (http://www.teluu.com)
+ *
+ * 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 <pjmedia.h>
+#include <pjmedia/converter.h>
+#include <pjmedia-codec.h>
+#include <pjlib-util.h>
+#include <pjlib.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "util.h"
+
+/**
+ * \page page_pjmedia_samples_aviplay_c Samples: Playing AVI File to
+ * Video and Sound Devices
+ *
+ * This is a very simple example to use the @ref PJMEDIA_FILE_PLAY,
+ * @ref PJMED_SND_PORT, and @ref PJMEDIA_VID_PORT. In this example, we
+ * open the file, video, and sound devices, then connect the file to both
+ * video and sound devices to play the contents of the file.
+ *
+ *
+ * This file is pjsip-apps/src/samples/aviplay.c
+ *
+ * \includelineno aviplay.c
+ */
+
+
+/*
+ * aviplay.c
+ *
+ * PURPOSE:
+ * Play a AVI file to video and sound devices.
+ *
+ * USAGE:
+ * aviplay FILE.AVI
+ */
+
+
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+
+
+/* For logging purpose. */
+#define THIS_FILE "aviplay.c"
+
+static const char *desc =
+" FILE \n"
+" \n"
+" aviplay.c \n"
+" \n"
+" PURPOSE \n"
+" \n"
+" Demonstrate how to play a AVI file. \n"
+" \n"
+" USAGE \n"
+" \n"
+" aviplay FILE.AVI \n";
+
+struct codec_fmt {
+ pj_uint32_t pjmedia_id;
+ const char *codec_id;
+ /* Do we need to convert the decoded frame? */
+ pj_bool_t need_conversion;
+ /* If conversion is needed, dst_fmt indicates the destination format */
+ pjmedia_format_id dst_fmt;
+} codec_fmts[] = {{PJMEDIA_FORMAT_MJPEG, "mjpeg",
+ PJ_TRUE , PJMEDIA_FORMAT_I420},
+ {PJMEDIA_FORMAT_H263 , "h263" ,
+ PJ_FALSE, 0},
+ {PJMEDIA_FORMAT_MPEG4, "mp4v"},
+ {PJMEDIA_FORMAT_H264 , "h264"}
+ };
+
+typedef struct avi_port_t
+{
+ pjmedia_vid_port *vid_port;
+ pjmedia_snd_port *snd_port;
+ pj_bool_t is_running;
+ pj_bool_t is_quitting;
+} avi_port_t;
+
+typedef struct codec_port_data_t
+{
+ pjmedia_vid_codec *codec;
+ pjmedia_port *src_port;
+ pj_uint8_t *enc_buf;
+ pj_size_t enc_buf_size;
+
+ pjmedia_converter *conv;
+} codec_port_data_t;
+
+static pj_status_t avi_event_cb(pjmedia_event *event,
+ void *user_data)
+{
+ avi_port_t *ap = (avi_port_t *)user_data;
+
+ switch (event->type) {
+ case PJMEDIA_EVENT_WND_CLOSED:
+ ap->is_quitting = PJ_TRUE;
+ break;
+ case PJMEDIA_EVENT_MOUSE_BTN_DOWN:
+ if (ap->is_running) {
+ pjmedia_vid_port_stop(ap->vid_port);
+ if (ap->snd_port)
+ pjmedia_aud_stream_stop(
+ pjmedia_snd_port_get_snd_stream(ap->snd_port));
+ } else {
+ pjmedia_vid_port_start(ap->vid_port);
+ if (ap->snd_port)
+ pjmedia_aud_stream_start(
+ pjmedia_snd_port_get_snd_stream(ap->snd_port));
+ }
+ ap->is_running = !ap->is_running;
+ break;
+ default:
+ return PJ_SUCCESS;
+ }
+
+ /* We handled the event on our own, so return non-PJ_SUCCESS here */
+ return -1;
+}
+
+static pj_status_t codec_get_frame(pjmedia_port *port,
+ pjmedia_frame *frame)
+{
+ codec_port_data_t *port_data = (codec_port_data_t*)port->port_data.pdata;
+ pjmedia_vid_codec *codec = port_data->codec;
+ pjmedia_frame enc_frame;
+ pj_status_t status;
+
+ enc_frame.buf = port_data->enc_buf;
+ enc_frame.size = port_data->enc_buf_size;
+
+ if (port_data->conv) {
+ pj_size_t frame_size = frame->size;
+
+ status = pjmedia_port_get_frame(port_data->src_port, frame);
+ if (status != PJ_SUCCESS) goto on_error;
+
+ status = pjmedia_vid_codec_decode(codec, 1, frame,
+ (unsigned)frame->size, &enc_frame);
+ if (status != PJ_SUCCESS) goto on_error;
+
+ frame->size = frame_size;
+ status = pjmedia_converter_convert(port_data->conv, &enc_frame, frame);
+ if (status != PJ_SUCCESS) goto on_error;
+
+ return PJ_SUCCESS;
+ }
+
+ status = pjmedia_port_get_frame(port_data->src_port, &enc_frame);
+ if (status != PJ_SUCCESS) goto on_error;
+
+ status = pjmedia_vid_codec_decode(codec, 1, &enc_frame,
+ (unsigned)frame->size, frame);
+ if (status != PJ_SUCCESS) goto on_error;
+
+ return PJ_SUCCESS;
+
+on_error:
+ pj_perror(3, THIS_FILE, status, "codec_get_frame() error");
+ return status;
+}
+
+static int aviplay(pj_pool_t *pool, const char *fname)
+{
+ pjmedia_vid_port *renderer=NULL;
+ pjmedia_vid_port_param param;
+ const pjmedia_video_format_info *vfi;
+ pjmedia_video_format_detail *vfd;
+ pjmedia_snd_port *snd_port = NULL;
+ pj_status_t status;
+ int rc = 0;
+ pjmedia_avi_streams *avi_streams;
+ pjmedia_avi_stream *vid_stream, *aud_stream;
+ pjmedia_port *vid_port = NULL, *aud_port = NULL;
+ pjmedia_vid_codec *codec=NULL;
+ avi_port_t avi_port;
+
+ pj_bzero(&avi_port, sizeof(avi_port));
+
+ status = pjmedia_avi_player_create_streams(pool, fname, 0, &avi_streams);
+ if (status != PJ_SUCCESS) {
+ PJ_PERROR(2,("", status, " Error playing %s", fname));
+ rc = 210; goto on_return;
+ }
+
+ vid_stream = pjmedia_avi_streams_get_stream_by_media(avi_streams,
+ 0,
+ PJMEDIA_TYPE_VIDEO);
+ vid_port = pjmedia_avi_stream_get_port(vid_stream);
+
+ if (vid_port) {
+ pjmedia_vid_port_param_default(¶m);
+
+ status = pjmedia_vid_dev_default_param(pool,
+ PJMEDIA_VID_DEFAULT_RENDER_DEV,
+ ¶m.vidparam);
+ if (status != PJ_SUCCESS) {
+ rc = 220; goto on_return;
+ }
+
+ /* Create renderer, set it to active */
+ param.active = PJ_TRUE;
+ param.vidparam.dir = PJMEDIA_DIR_RENDER;
+ vfd = pjmedia_format_get_video_format_detail(&vid_port->info.fmt,
+ PJ_TRUE);
+ pjmedia_format_init_video(¶m.vidparam.fmt,
+ vid_port->info.fmt.id,
+ vfd->size.w, vfd->size.h,
+ vfd->fps.num, vfd->fps.denum);
+
+ vfi = pjmedia_get_video_format_info(
+ pjmedia_video_format_mgr_instance(),
+ vid_port->info.fmt.id);
+ /* Check whether the frame is encoded */
+ if (!vfi || vfi->bpp == 0) {
+ /* Yes, prepare codec */
+ pj_str_t codec_id_st;
+ unsigned info_cnt = 1, i, k;
+ const pjmedia_vid_codec_info *codec_info;
+ pj_str_t port_name = {"codec", 5};
+ pj_uint8_t *enc_buf = NULL;
+ pj_size_t enc_buf_size = 0;
+ pjmedia_vid_dev_info rdr_info;
+ pjmedia_port codec_port;
+ codec_port_data_t codec_port_data;
+ pjmedia_vid_codec_param codec_param;
+ struct codec_fmt *codecp = NULL;
+
+ /* Lookup codec */
+ for (i = 0; i < sizeof(codec_fmts)/sizeof(codec_fmts[0]); i++) {
+ if (vid_port->info.fmt.id == codec_fmts[i].pjmedia_id) {
+ codecp = &codec_fmts[i];
+ break;
+ }
+ }
+ if (!codecp) {
+ rc = 242; goto on_return;
+ }
+ pj_cstr(&codec_id_st, codecp->codec_id);
+ status = pjmedia_vid_codec_mgr_find_codecs_by_id(NULL,
+ &codec_id_st,
+ &info_cnt,
+ &codec_info,
+ NULL);
+ if (status != PJ_SUCCESS) {
+ rc = 245; goto on_return;
+ }
+ status = pjmedia_vid_codec_mgr_get_default_param(NULL, codec_info,
+ &codec_param);
+ if (status != PJ_SUCCESS) {
+ rc = 246; goto on_return;
+ }
+
+ pjmedia_format_copy(&codec_param.enc_fmt, ¶m.vidparam.fmt);
+
+ pjmedia_vid_dev_get_info(param.vidparam.rend_id, &rdr_info);
+ for (i=0; i<codec_info->dec_fmt_id_cnt; ++i) {
+ for (k=0; k<rdr_info.fmt_cnt; ++k) {
+ if (codec_info->dec_fmt_id[i]==(int)rdr_info.fmt[k].id)
+ {
+ param.vidparam.fmt.id = codec_info->dec_fmt_id[i];
+ i = codec_info->dec_fmt_id_cnt;
+ break;
+ }
+ }
+ }
+
+ /* Open codec */
+ status = pjmedia_vid_codec_mgr_alloc_codec(NULL, codec_info,
+ &codec);
+ if (status != PJ_SUCCESS) {
+ rc = 250; goto on_return;
+ }
+
+ status = pjmedia_vid_codec_init(codec, pool);
+ if (status != PJ_SUCCESS) {
+ rc = 251; goto on_return;
+ }
+
+ pjmedia_format_copy(&codec_param.dec_fmt, ¶m.vidparam.fmt);
+ codec_param.dir = PJMEDIA_DIR_DECODING;
+ codec_param.packing = PJMEDIA_VID_PACKING_WHOLE;
+ status = pjmedia_vid_codec_open(codec, &codec_param);
+ if (status != PJ_SUCCESS) {
+ rc = 252; goto on_return;
+ }
+
+ /* Alloc encoding buffer */
+ enc_buf_size = codec_param.dec_fmt.det.vid.size.w *
+ codec_param.dec_fmt.det.vid.size.h * 4
+ + 16; /*< padding, just in case */
+ enc_buf = pj_pool_alloc(pool,enc_buf_size);
+
+ /* Init codec port */
+ pj_bzero(&codec_port, sizeof(codec_port));
+ status = pjmedia_port_info_init2(&codec_port.info, &port_name,
+ 0x1234,
+ PJMEDIA_DIR_ENCODING,
+ &codec_param.dec_fmt);
+ if (status != PJ_SUCCESS) {
+ rc = 260; goto on_return;
+ }
+ pj_bzero(&codec_port_data, sizeof(codec_port_data));
+ codec_port_data.codec = codec;
+ codec_port_data.src_port = vid_port;
+ codec_port_data.enc_buf = enc_buf;
+ codec_port_data.enc_buf_size = enc_buf_size;
+
+ codec_port.get_frame = &codec_get_frame;
+ codec_port.port_data.pdata = &codec_port_data;
+
+ /* Check whether we need to convert the decoded frame */
+ if (codecp->need_conversion) {
+ pjmedia_conversion_param conv_param;
+
+ pjmedia_format_copy(&conv_param.src, ¶m.vidparam.fmt);
+ pjmedia_format_copy(&conv_param.dst, ¶m.vidparam.fmt);
+ conv_param.dst.id = codecp->dst_fmt;
+ param.vidparam.fmt.id = conv_param.dst.id;
+
+ status = pjmedia_converter_create(NULL, pool, &conv_param,
+ &codec_port_data.conv);
+ if (status != PJ_SUCCESS) {
+ rc = 270; goto on_return;
+ }
+ }
+
+ status = pjmedia_vid_port_create(pool, ¶m, &renderer);
+ if (status != PJ_SUCCESS) {
+ rc = 230; goto on_return;
+ }
+
+ status = pjmedia_vid_port_connect(renderer, &codec_port,
+ PJ_FALSE);
+ } else {
+ status = pjmedia_vid_port_create(pool, ¶m, &renderer);
+ if (status != PJ_SUCCESS) {
+ rc = 230; goto on_return;
+ }
+
+ /* Connect avi port to renderer */
+ status = pjmedia_vid_port_connect(renderer, vid_port,
+ PJ_FALSE);
+ }
+
+ if (status != PJ_SUCCESS) {
+ rc = 240; goto on_return;
+ }
+ }
+
+ aud_stream = pjmedia_avi_streams_get_stream_by_media(avi_streams,
+ 0,
+ PJMEDIA_TYPE_AUDIO);
+ aud_port = pjmedia_avi_stream_get_port(aud_stream);
+
+ if (aud_port) {
+ /* Create sound player port. */
+ status = pjmedia_snd_port_create_player(
+ pool, /* pool */
+ -1, /* use default dev. */
+ PJMEDIA_PIA_SRATE(&aud_port->info),/* clock rate. */
+ PJMEDIA_PIA_CCNT(&aud_port->info), /* # of channels. */
+ PJMEDIA_PIA_SPF(&aud_port->info), /* samples per frame. */
+ PJMEDIA_PIA_BITS(&aud_port->info), /* bits per sample. */
+ 0, /* options */
+ &snd_port /* returned port */
+ );
+ if (status != PJ_SUCCESS) {
+ rc = 310; goto on_return;
+ }
+
+ /* Connect file port to the sound player.
+ * Stream playing will commence immediately.
+ */
+ status = pjmedia_snd_port_connect(snd_port, aud_port);
+ if (status != PJ_SUCCESS) {
+ rc = 330; goto on_return;
+ }
+ }
+
+ if (vid_port) {
+ pjmedia_vid_dev_cb cb;
+
+ pj_bzero(&cb, sizeof(cb));
+ avi_port.snd_port = snd_port;
+ avi_port.vid_port = renderer;
+ avi_port.is_running = PJ_TRUE;
+ pjmedia_vid_port_set_cb(renderer, &cb, &avi_port);
+
+ /* subscribe events */
+ pjmedia_event_subscribe(NULL, &avi_event_cb, &avi_port,
+ renderer);
+
+ if (snd_port) {
+ /* Synchronize video rendering and audio playback */
+ pjmedia_vid_port_set_clock_src(
+ renderer,
+ pjmedia_snd_port_get_clock_src(
+ snd_port, PJMEDIA_DIR_PLAYBACK));
+ }
+
+
+ /* Start video streaming.. */
+ status = pjmedia_vid_port_start(renderer);
+ if (status != PJ_SUCCESS) {
+ rc = 270; goto on_return;
+ }
+ }
+
+ while (!avi_port.is_quitting) {
+ pj_thread_sleep(100);
+ }
+
+on_return:
+ if (snd_port) {
+ pjmedia_snd_port_disconnect(snd_port);
+ /* Without this sleep, Windows/DirectSound will repeteadly
+ * play the last frame during destroy.
+ */
+ pj_thread_sleep(100);
+ pjmedia_snd_port_destroy(snd_port);
+ }
+ if (renderer) {
+ pjmedia_event_unsubscribe(NULL, &avi_event_cb, &avi_port,
+ renderer);
+ pjmedia_vid_port_destroy(renderer);
+ }
+ if (aud_port)
+ pjmedia_port_destroy(aud_port);
+ if (vid_port)
+ pjmedia_port_destroy(vid_port);
+ if (codec) {
+ pjmedia_vid_codec_close(codec);
+ pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec);
+ }
+
+ return rc;
+}
+
+
+static int main_func(int argc, char *argv[])
+{
+ pj_caching_pool cp;
+ pj_pool_t *pool;
+ int rc = 0;
+ pj_status_t status = PJ_SUCCESS;
+
+ if (argc != 2) {
+ puts("Error: filename required");
+ puts(desc);
+ return 1;
+ }
+
+
+ /* Must init PJLIB first: */
+ status = pj_init();
+ PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+ /* Must create a pool factory before we can allocate any memory. */
+ pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
+
+ /* Create memory pool for our file player */
+ pool = pj_pool_create( &cp.factory, /* pool factory */
+ "AVI", /* pool name. */
+ 4000, /* init size */
+ 4000, /* increment size */
+ NULL /* callback on error */
+ );
+
+ pjmedia_video_format_mgr_create(pool, 64, 0, NULL);
+ pjmedia_converter_mgr_create(pool, NULL);
+ pjmedia_event_mgr_create(pool, 0, NULL);
+ pjmedia_vid_codec_mgr_create(pool, NULL);
+
+ status = pjmedia_vid_dev_subsys_init(&cp.factory);
+ if (status != PJ_SUCCESS)
+ goto on_return;
+
+ status = pjmedia_aud_subsys_init(&cp.factory);
+ if (status != PJ_SUCCESS) {
+ goto on_return;
+ }
+
+#if PJMEDIA_HAS_FFMPEG_VID_CODEC
+ status = pjmedia_codec_ffmpeg_vid_init(NULL, &cp.factory);
+ if (status != PJ_SUCCESS)
+ goto on_return;
+#endif
+
+ rc = aviplay(pool, argv[1]);
+
+ /*
+ * File should be playing and looping now
+ */
+
+ /* Without this sleep, Windows/DirectSound will repeteadly
+ * play the last frame during destroy.
+ */
+ pj_thread_sleep(100);
+
+on_return:
+#if PJMEDIA_HAS_FFMPEG_VID_CODEC
+ pjmedia_codec_ffmpeg_vid_deinit();
+#endif
+ pjmedia_aud_subsys_shutdown();
+ pjmedia_vid_dev_subsys_shutdown();
+
+ pjmedia_video_format_mgr_destroy(pjmedia_video_format_mgr_instance());
+ pjmedia_converter_mgr_destroy(pjmedia_converter_mgr_instance());
+ pjmedia_event_mgr_destroy(pjmedia_event_mgr_instance());
+ pjmedia_vid_codec_mgr_destroy(pjmedia_vid_codec_mgr_instance());
+
+ /* Release application pool */
+ pj_pool_release( pool );
+
+ /* Destroy pool factory */
+ pj_caching_pool_destroy( &cp );
+
+ /* Shutdown PJLIB */
+ pj_shutdown();
+
+ /* Done. */
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ return pj_run_app(&main_func, argc, argv, 0);
+}
+
+#else
+
+int main(int argc, char *argv[])
+{
+ PJ_UNUSED_ARG(argc);
+ PJ_UNUSED_ARG(argv);
+ puts("Error: this sample requires video capability (PJMEDIA_HAS_VIDEO == 1)");
+ return -1;
+}
+
+#endif /* PJMEDIA_HAS_VIDEO */
diff --git a/jni/pjproject-android/.svn/pristine/58/58a487951c315a502b28459aef17c6bc1a767415.svn-base b/jni/pjproject-android/.svn/pristine/58/58a487951c315a502b28459aef17c6bc1a767415.svn-base
new file mode 100644
index 0000000..058aa4c
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/58/58a487951c315a502b28459aef17c6bc1a767415.svn-base
@@ -0,0 +1,430 @@
+/*
+ * 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: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/short_term.c,v 1.2 1994/05/10 20:18:47 jutta Exp $ */
+
+#include "config.h"
+#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);
+}
diff --git a/jni/pjproject-android/.svn/pristine/58/58afbb90d70bd80feafe6496b63bd2a0fb94304f.svn-base b/jni/pjproject-android/.svn/pristine/58/58afbb90d70bd80feafe6496b63bd2a0fb94304f.svn-base
new file mode 100644
index 0000000..1e435bc
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/58/58afbb90d70bd80feafe6496b63bd2a0fb94304f.svn-base
@@ -0,0 +1,141 @@
+/* Copyright (C) 2002 Jean-Marc Valin */
+/**
+ @file ltp.h
+ @brief Long-Term Prediction functions
+*/
+/*
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ - Neither the name of the Xiph.org Foundation nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <speex/speex_bits.h>
+#include "arch.h"
+
+/** LTP parameters. */
+typedef struct {
+ const signed char *gain_cdbk;
+ int gain_bits;
+ int pitch_bits;
+} ltp_params;
+
+#ifdef FIXED_POINT
+#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -SHR16(g[0],1)) + (g[2]>0 ? g[2] : -SHR16(g[2],1)))
+#else
+#define gain_3tap_to_1tap(g) (ABS(g[1]) + (g[0]>0 ? g[0] : -.5*g[0]) + (g[2]>0 ? g[2] : -.5*g[2]))
+#endif
+
+spx_word32_t inner_prod(const spx_word16_t *x, const spx_word16_t *y, int len);
+void pitch_xcorr(const spx_word16_t *_x, const spx_word16_t *_y, spx_word32_t *corr, int len, int nb_pitch, char *stack);
+
+void open_loop_nbest_pitch(spx_word16_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack);
+
+
+/** Finds the best quantized 3-tap pitch predictor by analysis by synthesis */
+int pitch_search_3tap(
+spx_word16_t target[], /* Target vector */
+spx_word16_t *sw,
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
+spx_sig_t exc[], /* Overlapping codebook */
+const void *par,
+int start, /* Smallest pitch value allowed */
+int end, /* Largest pitch value allowed */
+spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
+int p, /* Number of LPC coeffs */
+int nsf, /* Number of samples in subframe */
+SpeexBits *bits,
+char *stack,
+spx_word16_t *exc2,
+spx_word16_t *r,
+int complexity,
+int cdbk_offset,
+int plc_tuning,
+spx_word32_t *cumul_gain
+);
+
+/*Unquantize adaptive codebook and update pitch contribution*/
+void pitch_unquant_3tap(
+spx_word16_t exc[], /* Input excitation */
+spx_word32_t exc_out[], /* Output excitation */
+int start, /* Smallest pitch value allowed */
+int end, /* Largest pitch value allowed */
+spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
+const void *par,
+int nsf, /* Number of samples in subframe */
+int *pitch_val,
+spx_word16_t *gain_val,
+SpeexBits *bits,
+char *stack,
+int lost,
+int subframe_offset,
+spx_word16_t last_pitch_gain,
+int cdbk_offset
+);
+
+/** Forced pitch delay and gain */
+int forced_pitch_quant(
+spx_word16_t target[], /* Target vector */
+spx_word16_t *sw,
+spx_coef_t ak[], /* LPCs for this subframe */
+spx_coef_t awk1[], /* Weighted LPCs #1 for this subframe */
+spx_coef_t awk2[], /* Weighted LPCs #2 for this subframe */
+spx_sig_t exc[], /* Excitation */
+const void *par,
+int start, /* Smallest pitch value allowed */
+int end, /* Largest pitch value allowed */
+spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
+int p, /* Number of LPC coeffs */
+int nsf, /* Number of samples in subframe */
+SpeexBits *bits,
+char *stack,
+spx_word16_t *exc2,
+spx_word16_t *r,
+int complexity,
+int cdbk_offset,
+int plc_tuning,
+spx_word32_t *cumul_gain
+);
+
+/** Unquantize forced pitch delay and gain */
+void forced_pitch_unquant(
+spx_word16_t exc[], /* Input excitation */
+spx_word32_t exc_out[], /* Output excitation */
+int start, /* Smallest pitch value allowed */
+int end, /* Largest pitch value allowed */
+spx_word16_t pitch_coef, /* Voicing (pitch) coefficient */
+const void *par,
+int nsf, /* Number of samples in subframe */
+int *pitch_val,
+spx_word16_t *gain_val,
+SpeexBits *bits,
+char *stack,
+int lost,
+int subframe_offset,
+spx_word16_t last_pitch_gain,
+int cdbk_offset
+);
diff --git a/jni/pjproject-android/.svn/pristine/58/58bc4f37aeb2e5e77d11d258d881cb22464b8991.svn-base b/jni/pjproject-android/.svn/pristine/58/58bc4f37aeb2e5e77d11d258d881cb22464b8991.svn-base
new file mode 100644
index 0000000..d40c171
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/58/58bc4f37aeb2e5e77d11d258d881cb22464b8991.svn-base
@@ -0,0 +1,387 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.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
+ */
+#include "test.h"
+
+#if INCLUDE_IOQUEUE_UNREG_TEST
+/*
+ * This tests the thread safety of ioqueue unregistration operation.
+ */
+
+#include <pj/errno.h>
+#include <pj/ioqueue.h>
+#include <pj/log.h>
+#include <pj/os.h>
+#include <pj/pool.h>
+#include <pj/sock.h>
+#include <pj/compat/socket.h>
+#include <pj/string.h>
+
+
+#define THIS_FILE "ioq_unreg.c"
+
+
+enum test_method
+{
+ UNREGISTER_IN_APP,
+ UNREGISTER_IN_CALLBACK,
+};
+
+static int thread_quitting;
+static enum test_method test_method;
+static pj_time_val time_to_unregister;
+
+struct sock_data
+{
+ pj_sock_t sock;
+ pj_sock_t csock;
+ pj_pool_t *pool;
+ pj_ioqueue_key_t *key;
+ pj_mutex_t *mutex;
+ pj_ioqueue_op_key_t *op_key;
+ char *buffer;
+ pj_size_t bufsize;
+ pj_bool_t unregistered;
+ pj_ssize_t received;
+} sock_data;
+
+static void on_read_complete(pj_ioqueue_key_t *key,
+ pj_ioqueue_op_key_t *op_key,
+ pj_ssize_t bytes_read)
+{
+ pj_ssize_t size;
+ char *sendbuf = "Hello world";
+ pj_status_t status;
+
+ if (sock_data.unregistered)
+ return;
+
+ pj_mutex_lock(sock_data.mutex);
+
+ if (sock_data.unregistered) {
+ pj_mutex_unlock(sock_data.mutex);
+ return;
+ }
+
+ if (bytes_read < 0) {
+ if (-bytes_read != PJ_STATUS_FROM_OS(PJ_BLOCKING_ERROR_VAL))
+ app_perror("ioqueue reported recv error", (pj_status_t)-bytes_read);
+ } else {
+ sock_data.received += bytes_read;
+ }
+
+ if (test_method == UNREGISTER_IN_CALLBACK) {
+ pj_time_val now;
+
+ pj_gettimeofday(&now);
+ if (PJ_TIME_VAL_GTE(now, time_to_unregister)) {
+ sock_data.unregistered = 1;
+ pj_ioqueue_unregister(key);
+ pj_mutex_unlock(sock_data.mutex);
+ return;
+ }
+ }
+
+ do {
+ size = sock_data.bufsize;
+ status = pj_ioqueue_recv(key, op_key, sock_data.buffer, &size, 0);
+ if (status != PJ_EPENDING && status != PJ_SUCCESS)
+ app_perror("recv() error", status);
+
+ } while (status == PJ_SUCCESS);
+
+ pj_mutex_unlock(sock_data.mutex);
+
+ size = pj_ansi_strlen(sendbuf);
+ status = pj_sock_send(sock_data.csock, sendbuf, &size, 0);
+ if (status != PJ_SUCCESS)
+ app_perror("send() error", status);
+
+ size = pj_ansi_strlen(sendbuf);
+ status = pj_sock_send(sock_data.csock, sendbuf, &size, 0);
+ if (status != PJ_SUCCESS)
+ app_perror("send() error", status);
+
+}
+
+static int worker_thread(void *arg)
+{
+ pj_ioqueue_t *ioqueue = (pj_ioqueue_t*) arg;
+
+ while (!thread_quitting) {
+ pj_time_val timeout = { 0, 20 };
+ pj_ioqueue_poll(ioqueue, &timeout);
+ }
+
+ return 0;
+}
+
+/*
+ * Perform unregistration test.
+ *
+ * This will create ioqueue and register a server socket. Depending
+ * on the test method, either the callback or the main thread will
+ * unregister and destroy the server socket after some period of time.
+ */
+static int perform_unreg_test(pj_ioqueue_t *ioqueue,
+ pj_pool_t *test_pool,
+ const char *title,
+ pj_bool_t other_socket)
+{
+ enum { WORKER_CNT = 1, MSEC = 500, QUIT_MSEC = 500 };
+ int i;
+ pj_thread_t *thread[WORKER_CNT];
+ struct sock_data osd;
+ pj_ioqueue_callback callback;
+ pj_time_val end_time;
+ pj_status_t status;
+
+
+ /* Sometimes its important to have other sockets registered to
+ * the ioqueue, because when no sockets are registered, the ioqueue
+ * will return from the poll early.
+ */
+ if (other_socket) {
+ status = app_socket(pj_AF_INET(), pj_SOCK_DGRAM(), 0, 56127, &osd.sock);
+ if (status != PJ_SUCCESS) {
+ app_perror("Error creating other socket", status);
+ return -12;
+ }
+
+ pj_bzero(&callback, sizeof(callback));
+ status = pj_ioqueue_register_sock(test_pool, ioqueue, osd.sock,
+ NULL, &callback, &osd.key);
+ if (status != PJ_SUCCESS) {
+ app_perror("Error registering other socket", status);
+ return -13;
+ }
+
+ } else {
+ osd.key = NULL;
+ osd.sock = PJ_INVALID_SOCKET;
+ }
+
+ /* Init both time duration of testing */
+ thread_quitting = 0;
+ pj_gettimeofday(&time_to_unregister);
+ time_to_unregister.msec += MSEC;
+ pj_time_val_normalize(&time_to_unregister);
+
+ end_time = time_to_unregister;
+ end_time.msec += QUIT_MSEC;
+ pj_time_val_normalize(&end_time);
+
+
+ /* Create polling thread */
+ for (i=0; i<WORKER_CNT; ++i) {
+ status = pj_thread_create(test_pool, "unregtest", &worker_thread,
+ ioqueue, 0, 0, &thread[i]);
+ if (status != PJ_SUCCESS) {
+ app_perror("Error creating thread", status);
+ return -20;
+ }
+ }
+
+ /* Create pair of client/server sockets */
+ status = app_socketpair(pj_AF_INET(), pj_SOCK_DGRAM(), 0,
+ &sock_data.sock, &sock_data.csock);
+ if (status != PJ_SUCCESS) {
+ app_perror("app_socketpair error", status);
+ return -30;
+ }
+
+
+ /* Initialize test data */
+ sock_data.pool = pj_pool_create(mem, "sd", 1000, 1000, NULL);
+ sock_data.buffer = (char*) pj_pool_alloc(sock_data.pool, 128);
+ sock_data.bufsize = 128;
+ sock_data.op_key = (pj_ioqueue_op_key_t*)
+ pj_pool_alloc(sock_data.pool,
+ sizeof(*sock_data.op_key));
+ sock_data.received = 0;
+ sock_data.unregistered = 0;
+
+ pj_ioqueue_op_key_init(sock_data.op_key, sizeof(*sock_data.op_key));
+
+ status = pj_mutex_create_simple(sock_data.pool, "sd", &sock_data.mutex);
+ if (status != PJ_SUCCESS) {
+ app_perror("create_mutex() error", status);
+ return -35;
+ }
+
+ /* Register socket to ioqueue */
+ pj_bzero(&callback, sizeof(callback));
+ callback.on_read_complete = &on_read_complete;
+ status = pj_ioqueue_register_sock(sock_data.pool, ioqueue, sock_data.sock,
+ NULL, &callback, &sock_data.key);
+ if (status != PJ_SUCCESS) {
+ app_perror("pj_ioqueue_register error", status);
+ return -40;
+ }
+
+ /* Bootstrap the first send/receive */
+ on_read_complete(sock_data.key, sock_data.op_key, 0);
+
+ /* Loop until test time ends */
+ for (;;) {
+ pj_time_val now, timeout;
+ int n;
+
+ pj_gettimeofday(&now);
+
+ if (test_method == UNREGISTER_IN_APP &&
+ PJ_TIME_VAL_GTE(now, time_to_unregister) &&
+ !sock_data.unregistered)
+ {
+ sock_data.unregistered = 1;
+ /* Wait (as much as possible) for callback to complete */
+ pj_mutex_lock(sock_data.mutex);
+ pj_mutex_unlock(sock_data.mutex);
+ pj_ioqueue_unregister(sock_data.key);
+ }
+
+ if (PJ_TIME_VAL_GT(now, end_time) && sock_data.unregistered)
+ break;
+
+ timeout.sec = 0; timeout.msec = 10;
+ n = pj_ioqueue_poll(ioqueue, &timeout);
+ if (n < 0) {
+ app_perror("pj_ioqueue_poll error", -n);
+ pj_thread_sleep(1);
+ }
+ }
+
+ thread_quitting = 1;
+
+ for (i=0; i<WORKER_CNT; ++i) {
+ pj_thread_join(thread[i]);
+ pj_thread_destroy(thread[i]);
+ }
+
+ /* Destroy data */
+ pj_mutex_destroy(sock_data.mutex);
+ pj_pool_release(sock_data.pool);
+ sock_data.pool = NULL;
+
+ if (other_socket) {
+ pj_ioqueue_unregister(osd.key);
+ }
+
+ pj_sock_close(sock_data.csock);
+
+ PJ_LOG(3,(THIS_FILE, "....%s: done (%d KB/s)",
+ title, sock_data.received * 1000 / MSEC / 1000));
+ return 0;
+}
+
+static int udp_ioqueue_unreg_test_imp(pj_bool_t allow_concur)
+{
+ enum { LOOP = 10 };
+ int i, rc;
+ char title[30];
+ pj_ioqueue_t *ioqueue;
+ pj_pool_t *test_pool;
+
+ PJ_LOG(3,(THIS_FILE, "..testing with concurency=%d", allow_concur));
+
+ test_method = UNREGISTER_IN_APP;
+
+ test_pool = pj_pool_create(mem, "unregtest", 4000, 4000, NULL);
+
+ rc = pj_ioqueue_create(test_pool, 16, &ioqueue);
+ if (rc != PJ_SUCCESS) {
+ app_perror("Error creating ioqueue", rc);
+ return -10;
+ }
+
+ rc = pj_ioqueue_set_default_concurrency(ioqueue, allow_concur);
+ if (rc != PJ_SUCCESS) {
+ app_perror("Error in pj_ioqueue_set_default_concurrency()", rc);
+ return -12;
+ }
+
+ PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 0/3, unregister in app (%s)",
+ pj_ioqueue_name()));
+ for (i=0; i<LOOP; ++i) {
+ pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
+ rc = perform_unreg_test(ioqueue, test_pool, title, 0);
+ if (rc != 0)
+ return rc;
+ }
+
+
+ PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 1/3, unregister in app (%s)",
+ pj_ioqueue_name()));
+ for (i=0; i<LOOP; ++i) {
+ pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
+ rc = perform_unreg_test(ioqueue, test_pool, title, 1);
+ if (rc != 0)
+ return rc;
+ }
+
+ test_method = UNREGISTER_IN_CALLBACK;
+
+ PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 2/3, unregister in cb (%s)",
+ pj_ioqueue_name()));
+ for (i=0; i<LOOP; ++i) {
+ pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
+ rc = perform_unreg_test(ioqueue, test_pool, title, 0);
+ if (rc != 0)
+ return rc;
+ }
+
+
+ PJ_LOG(3, (THIS_FILE, "...ioqueue unregister stress test 3/3, unregister in cb (%s)",
+ pj_ioqueue_name()));
+ for (i=0; i<LOOP; ++i) {
+ pj_ansi_sprintf(title, "repeat %d/%d", i, LOOP);
+ rc = perform_unreg_test(ioqueue, test_pool, title, 1);
+ if (rc != 0)
+ return rc;
+ }
+
+ pj_ioqueue_destroy(ioqueue);
+ pj_pool_release(test_pool);
+
+ return 0;
+}
+
+int udp_ioqueue_unreg_test(void)
+{
+ int rc;
+
+ rc = udp_ioqueue_unreg_test_imp(PJ_TRUE);
+ if (rc != 0)
+ return rc;
+
+ rc = udp_ioqueue_unreg_test_imp(PJ_FALSE);
+ if (rc != 0)
+ return rc;
+
+ return 0;
+}
+
+#else
+/* To prevent warning about "translation unit is empty"
+ * when this test is disabled.
+ */
+int dummy_uiq_unreg;
+#endif /* INCLUDE_IOQUEUE_UNREG_TEST */
+
+
diff --git a/jni/pjproject-android/.svn/pristine/58/58d0184753035f3ebee5e3b5d49eaa12ac8f86f1.svn-base b/jni/pjproject-android/.svn/pristine/58/58d0184753035f3ebee5e3b5d49eaa12ac8f86f1.svn-base
new file mode 100644
index 0000000..9fa4584
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/58/58d0184753035f3ebee5e3b5d49eaa12ac8f86f1.svn-base
@@ -0,0 +1,270 @@
+
+ /******************************************************************
+
+ iLBC Speech Coder ANSI-C Source Code
+
+ doCPLC.c
+
+ Copyright (C) The Internet Society (2004).
+ All Rights Reserved.
+
+ ******************************************************************/
+
+ #include <math.h>
+ #include <string.h>
+ #include <stdio.h>
+
+
+
+
+
+ #include "iLBC_define.h"
+
+ /*----------------------------------------------------------------*
+ * Compute cross correlation and pitch gain for pitch prediction
+ * of last subframe at given lag.
+ *---------------------------------------------------------------*/
+
+ void compCorr(
+ float *cc, /* (o) cross correlation coefficient */
+ float *gc, /* (o) gain */
+ float *pm,
+ float *buffer, /* (i) signal buffer */
+ int lag, /* (i) pitch lag */
+ int bLen, /* (i) length of buffer */
+ int sRange /* (i) correlation search length */
+ ){
+ int i;
+ float ftmp1, ftmp2, ftmp3;
+
+ /* Guard against getting outside buffer */
+ if ((bLen-sRange-lag)<0) {
+ sRange=bLen-lag;
+ }
+
+ ftmp1 = 0.0;
+ ftmp2 = 0.0;
+ ftmp3 = 0.0;
+ for (i=0; i<sRange; i++) {
+ ftmp1 += buffer[bLen-sRange+i] *
+ buffer[bLen-sRange+i-lag];
+ ftmp2 += buffer[bLen-sRange+i-lag] *
+ buffer[bLen-sRange+i-lag];
+ ftmp3 += buffer[bLen-sRange+i] *
+ buffer[bLen-sRange+i];
+ }
+
+ if (ftmp2 > 0.0) {
+ *cc = ftmp1*ftmp1/ftmp2;
+ *gc = (float)fabs(ftmp1/ftmp2);
+ *pm=(float)fabs(ftmp1)/
+ ((float)sqrt(ftmp2)*(float)sqrt(ftmp3));
+ }
+ else {
+ *cc = 0.0;
+ *gc = 0.0;
+ *pm=0.0;
+ }
+ }
+
+
+
+
+
+ /*----------------------------------------------------------------*
+ * Packet loss concealment routine. Conceals a residual signal
+ * and LP parameters. If no packet loss, update state.
+ *---------------------------------------------------------------*/
+
+ void doThePLC(
+ float *PLCresidual, /* (o) concealed residual */
+ float *PLClpc, /* (o) concealed LP parameters */
+ int PLI, /* (i) packet loss indicator
+ 0 - no PL, 1 = PL */
+ float *decresidual, /* (i) decoded residual */
+ float *lpc, /* (i) decoded LPC (only used for no PL) */
+ int inlag, /* (i) pitch lag */
+ iLBC_Dec_Inst_t *iLBCdec_inst
+ /* (i/o) decoder instance */
+ ){
+ int lag=20, randlag;
+ float gain, maxcc;
+ float use_gain;
+ float gain_comp, maxcc_comp, per, max_per=0;
+ int i, pick, use_lag;
+ float ftmp, randvec[BLOCKL_MAX], pitchfact, energy;
+
+ /* Packet Loss */
+
+ if (PLI == 1) {
+
+ iLBCdec_inst->consPLICount += 1;
+
+ /* if previous frame not lost,
+ determine pitch pred. gain */
+
+ if (iLBCdec_inst->prevPLI != 1) {
+
+ /* Search around the previous lag to find the
+ best pitch period */
+
+ lag=inlag-3;
+ compCorr(&maxcc, &gain, &max_per,
+ iLBCdec_inst->prevResidual,
+ lag, iLBCdec_inst->blockl, 60);
+ for (i=inlag-2;i<=inlag+3;i++) {
+ compCorr(&maxcc_comp, &gain_comp, &per,
+ iLBCdec_inst->prevResidual,
+ i, iLBCdec_inst->blockl, 60);
+
+ if (maxcc_comp>maxcc) {
+ maxcc=maxcc_comp;
+
+
+
+
+
+ gain=gain_comp;
+ lag=i;
+ max_per=per;
+ }
+ }
+
+ }
+
+ /* previous frame lost, use recorded lag and periodicity */
+
+ else {
+ lag=iLBCdec_inst->prevLag;
+ max_per=iLBCdec_inst->per;
+ }
+
+ /* downscaling */
+
+ use_gain=1.0;
+ if (iLBCdec_inst->consPLICount*iLBCdec_inst->blockl>320)
+ use_gain=(float)0.9;
+ else if (iLBCdec_inst->consPLICount*
+ iLBCdec_inst->blockl>2*320)
+ use_gain=(float)0.7;
+ else if (iLBCdec_inst->consPLICount*
+ iLBCdec_inst->blockl>3*320)
+ use_gain=(float)0.5;
+ else if (iLBCdec_inst->consPLICount*
+ iLBCdec_inst->blockl>4*320)
+ use_gain=(float)0.0;
+
+ /* mix noise and pitch repeatition */
+ ftmp=(float)sqrt(max_per);
+ if (ftmp>(float)0.7)
+ pitchfact=(float)1.0;
+ else if (ftmp>(float)0.4)
+ pitchfact=(ftmp-(float)0.4)/((float)0.7-(float)0.4);
+ else
+ pitchfact=0.0;
+
+
+ /* avoid repetition of same pitch cycle */
+ use_lag=lag;
+ if (lag<80) {
+ use_lag=2*lag;
+ }
+
+ /* compute concealed residual */
+
+
+
+
+
+
+ energy = 0.0;
+ for (i=0; i<iLBCdec_inst->blockl; i++) {
+
+ /* noise component */
+
+ iLBCdec_inst->seed=(iLBCdec_inst->seed*69069L+1) &
+ (0x80000000L-1);
+ randlag = 50 + ((signed long) iLBCdec_inst->seed)%70;
+ pick = i - randlag;
+
+ if (pick < 0) {
+ randvec[i] =
+ iLBCdec_inst->prevResidual[
+ iLBCdec_inst->blockl+pick];
+ } else {
+ randvec[i] = randvec[pick];
+ }
+
+ /* pitch repeatition component */
+ pick = i - use_lag;
+
+ if (pick < 0) {
+ PLCresidual[i] =
+ iLBCdec_inst->prevResidual[
+ iLBCdec_inst->blockl+pick];
+ } else {
+ PLCresidual[i] = PLCresidual[pick];
+ }
+
+ /* mix random and periodicity component */
+
+ if (i<80)
+ PLCresidual[i] = use_gain*(pitchfact *
+ PLCresidual[i] +
+ ((float)1.0 - pitchfact) * randvec[i]);
+ else if (i<160)
+ PLCresidual[i] = (float)0.95*use_gain*(pitchfact *
+ PLCresidual[i] +
+ ((float)1.0 - pitchfact) * randvec[i]);
+ else
+ PLCresidual[i] = (float)0.9*use_gain*(pitchfact *
+ PLCresidual[i] +
+ ((float)1.0 - pitchfact) * randvec[i]);
+
+ energy += PLCresidual[i] * PLCresidual[i];
+ }
+
+ /* less than 30 dB, use only noise */
+
+
+
+
+
+
+ if (sqrt(energy/(float)iLBCdec_inst->blockl) < 30.0) {
+ gain=0.0;
+ for (i=0; i<iLBCdec_inst->blockl; i++) {
+ PLCresidual[i] = randvec[i];
+ }
+ }
+
+ /* use old LPC */
+
+ memcpy(PLClpc,iLBCdec_inst->prevLpc,
+ (LPC_FILTERORDER+1)*sizeof(float));
+
+ }
+
+ /* no packet loss, copy input */
+
+ else {
+ memcpy(PLCresidual, decresidual,
+ iLBCdec_inst->blockl*sizeof(float));
+ memcpy(PLClpc, lpc, (LPC_FILTERORDER+1)*sizeof(float));
+ iLBCdec_inst->consPLICount = 0;
+ }
+
+ /* update state */
+
+ if (PLI) {
+ iLBCdec_inst->prevLag = lag;
+ iLBCdec_inst->per=max_per;
+ }
+
+ iLBCdec_inst->prevPLI = PLI;
+ memcpy(iLBCdec_inst->prevLpc, PLClpc,
+ (LPC_FILTERORDER+1)*sizeof(float));
+ memcpy(iLBCdec_inst->prevResidual, PLCresidual,
+ iLBCdec_inst->blockl*sizeof(float));
+ }
+