* #36737: switch back to svn repo, remove assert in sip_transaction.c
diff --git a/jni/pjproject-android/.svn/pristine/2c/2c127f2028b77061b019e6b443f5308fde75a070.svn-base b/jni/pjproject-android/.svn/pristine/2c/2c127f2028b77061b019e6b443f5308fde75a070.svn-base
new file mode 100644
index 0000000..24bae56
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/2c/2c127f2028b77061b019e6b443f5308fde75a070.svn-base
@@ -0,0 +1,24 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2009-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
+ */
+
+/*
+ * This file is a C++ wrapper, see ticket #886 for details.
+ */
+
+#include "sdp.c"
diff --git a/jni/pjproject-android/.svn/pristine/2c/2c3364b9c531a0043a324029d5a38dc057c944d2.svn-base b/jni/pjproject-android/.svn/pristine/2c/2c3364b9c531a0043a324029d5a38dc057c944d2.svn-base
new file mode 100644
index 0000000..b4a23c7
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/2c/2c3364b9c531a0043a324029d5a38dc057c944d2.svn-base
@@ -0,0 +1,304 @@
+/* $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 <pjmedia/sdp.h>
+#include <pjmedia/errno.h>
+#include <pj/assert.h>
+#include <pj/string.h>
+
+
+/* Compare connection line. */
+static pj_status_t compare_conn(const pjmedia_sdp_conn *c1,
+ const pjmedia_sdp_conn *c2)
+{
+ /* Compare network type. */
+ if (pj_strcmp(&c1->net_type, &c2->net_type) != 0)
+ return PJMEDIA_SDP_ECONNNOTEQUAL;
+
+ /* Compare address type. */
+ if (pj_strcmp(&c1->addr_type, &c2->addr_type) != 0)
+ return PJMEDIA_SDP_ECONNNOTEQUAL;
+
+ /* Compare address. */
+ if (pj_strcmp(&c1->addr, &c2->addr) != 0)
+ return PJMEDIA_SDP_ECONNNOTEQUAL;
+
+ return PJ_SUCCESS;
+}
+
+/* Compare attributes array. */
+static pj_status_t compare_attr_imp(unsigned count1,
+ pjmedia_sdp_attr *const attr1[],
+ unsigned count2,
+ pjmedia_sdp_attr *const attr2[])
+{
+ pj_status_t status;
+ unsigned i;
+ const pj_str_t inactive = { "inactive", 8 };
+ const pj_str_t sendrecv = { "sendrecv", 8 };
+ const pj_str_t sendonly = { "sendonly", 8 };
+ const pj_str_t recvonly = { "recvonly", 8 };
+ const pj_str_t fmtp = { "fmtp", 4 };
+ const pj_str_t rtpmap = { "rtpmap", 6 };
+
+ /* For simplicity, we only compare the following attributes, and ignore
+ * the others:
+ * - direction, eg. inactive, sendonly, recvonly, sendrecv
+ * - fmtp for each payload.
+ * - rtpmap for each payload.
+ */
+ for (i=0; i<count1; ++i) {
+ const pjmedia_sdp_attr *a1 = attr1[i];
+
+ if (pj_strcmp(&a1->name, &inactive) == 0 ||
+ pj_strcmp(&a1->name, &sendrecv) == 0 ||
+ pj_strcmp(&a1->name, &sendonly) == 0 ||
+ pj_strcmp(&a1->name, &recvonly) == 0)
+ {
+ /* For inactive, sendrecv, sendonly, and recvonly attributes,
+ * the same attribute must be present on the other SDP.
+ */
+ const pjmedia_sdp_attr *a2;
+ a2 = pjmedia_sdp_attr_find(count2, attr2, &a1->name, NULL);
+ if (!a2)
+ return PJMEDIA_SDP_EDIRNOTEQUAL;
+
+ } else if (pj_strcmp(&a1->name, &fmtp) == 0) {
+ /* For fmtp attribute, find the fmtp attribute in the other SDP
+ * for the same payload type, and compare the fmtp param/value.
+ */
+ pjmedia_sdp_fmtp fmtp1, fmtp2;
+ const pjmedia_sdp_attr *a2;
+
+ status = pjmedia_sdp_attr_get_fmtp(a1, &fmtp1);
+ if (status != PJ_SUCCESS)
+ return PJMEDIA_SDP_EFMTPNOTEQUAL;
+
+ a2 = pjmedia_sdp_attr_find(count2, attr2, &a1->name, &fmtp1.fmt);
+ if (!a2)
+ return PJMEDIA_SDP_EFMTPNOTEQUAL;
+
+ status = pjmedia_sdp_attr_get_fmtp(a2, &fmtp2);
+ if (status != PJ_SUCCESS)
+ return PJMEDIA_SDP_EFMTPNOTEQUAL;
+
+ if (pj_strcmp(&fmtp1.fmt_param, &fmtp2.fmt_param) != 0)
+ return PJMEDIA_SDP_EFMTPNOTEQUAL;
+
+ } else if (pj_strcmp(&a1->name, &rtpmap) == 0) {
+ /* For rtpmap attribute, find rtpmap attribute on the other SDP
+ * for the same payload type, and compare both rtpmap atribute
+ * values.
+ */
+ pjmedia_sdp_rtpmap r1, r2;
+ const pjmedia_sdp_attr *a2;
+
+ status = pjmedia_sdp_attr_get_rtpmap(a1, &r1);
+ if (status != PJ_SUCCESS)
+ return PJMEDIA_SDP_ERTPMAPNOTEQUAL;
+
+ a2 = pjmedia_sdp_attr_find(count2, attr2, &a1->name, &r1.pt);
+ if (!a2)
+ return PJMEDIA_SDP_ERTPMAPNOTEQUAL;
+
+ status = pjmedia_sdp_attr_get_rtpmap(a2, &r2);
+ if (status != PJ_SUCCESS)
+ return PJMEDIA_SDP_ERTPMAPNOTEQUAL;
+
+ if (pj_strcmp(&r1.pt, &r2.pt) != 0)
+ return PJMEDIA_SDP_ERTPMAPNOTEQUAL;
+ if (pj_strcmp(&r1.enc_name, &r2.enc_name) != 0)
+ return PJMEDIA_SDP_ERTPMAPNOTEQUAL;
+ if (r1.clock_rate != r2.clock_rate)
+ return PJMEDIA_SDP_ERTPMAPNOTEQUAL;
+ if (pj_strcmp(&r1.param, &r2.param) != 0)
+ return PJMEDIA_SDP_ERTPMAPNOTEQUAL;
+ }
+ }
+
+ return PJ_SUCCESS;
+}
+
+
+/* Compare attributes array. */
+static pj_status_t compare_attr(unsigned count1,
+ pjmedia_sdp_attr *const attr1[],
+ unsigned count2,
+ pjmedia_sdp_attr *const attr2[])
+{
+ pj_status_t status;
+
+ status = compare_attr_imp(count1, attr1, count2, attr2);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ status = compare_attr_imp(count2, attr2, count1, attr1);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ return PJ_SUCCESS;
+}
+
+/* Compare media descriptor */
+PJ_DEF(pj_status_t) pjmedia_sdp_media_cmp( const pjmedia_sdp_media *sd1,
+ const pjmedia_sdp_media *sd2,
+ unsigned option)
+{
+ unsigned i;
+ pj_status_t status;
+
+ PJ_ASSERT_RETURN(sd1 && sd2 && option==0, PJ_EINVAL);
+
+ PJ_UNUSED_ARG(option);
+
+ /* Compare media type. */
+ if (pj_strcmp(&sd1->desc.media, &sd2->desc.media) != 0)
+ return PJMEDIA_SDP_EMEDIANOTEQUAL;
+
+ /* Compare port number. */
+ if (sd1->desc.port != sd2->desc.port)
+ return PJMEDIA_SDP_EPORTNOTEQUAL;
+
+ /* Compare port count. */
+ if (sd1->desc.port_count != sd2->desc.port_count)
+ return PJMEDIA_SDP_EPORTNOTEQUAL;
+
+ /* Compare transports. */
+ if (pj_strcmp(&sd1->desc.transport, &sd2->desc.transport) != 0)
+ return PJMEDIA_SDP_ETPORTNOTEQUAL;
+
+ /* For zeroed port media, stop comparing here */
+ if (sd1->desc.port == 0)
+ return PJ_SUCCESS;
+
+ /* Compare number of formats. */
+ if (sd1->desc.fmt_count != sd2->desc.fmt_count)
+ return PJMEDIA_SDP_EFORMATNOTEQUAL;
+
+ /* Compare formats, in order. */
+ for (i=0; i<sd1->desc.fmt_count; ++i) {
+ if (pj_strcmp(&sd1->desc.fmt[i], &sd2->desc.fmt[i]) != 0)
+ return PJMEDIA_SDP_EFORMATNOTEQUAL;
+ }
+
+ /* Compare connection line, if they exist. */
+ if (sd1->conn) {
+ if (!sd2->conn)
+ return PJMEDIA_SDP_EMEDIANOTEQUAL;
+ status = compare_conn(sd1->conn, sd2->conn);
+ } else {
+ if (sd2->conn)
+ return PJMEDIA_SDP_EMEDIANOTEQUAL;
+ }
+
+ /* Compare attributes. */
+ status = compare_attr(sd1->attr_count, sd1->attr,
+ sd2->attr_count, sd2->attr);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* Looks equal */
+ return PJ_SUCCESS;
+}
+
+/*
+ * Compare two SDP session for equality.
+ */
+PJ_DEF(pj_status_t) pjmedia_sdp_session_cmp( const pjmedia_sdp_session *sd1,
+ const pjmedia_sdp_session *sd2,
+ unsigned option)
+{
+ unsigned i;
+ pj_status_t status;
+
+ PJ_ASSERT_RETURN(sd1 && sd2 && option==0, PJ_EINVAL);
+
+ PJ_UNUSED_ARG(option);
+
+ /* Compare the origin line. */
+ if (pj_strcmp(&sd1->origin.user, &sd2->origin.user) != 0)
+ return PJMEDIA_SDP_EORIGINNOTEQUAL;
+
+ if (sd1->origin.id != sd2->origin.id)
+ return PJMEDIA_SDP_EORIGINNOTEQUAL;
+
+ if (sd1->origin.version != sd2->origin.version)
+ return PJMEDIA_SDP_EORIGINNOTEQUAL;
+
+ if (pj_strcmp(&sd1->origin.net_type, &sd2->origin.net_type) != 0)
+ return PJMEDIA_SDP_EORIGINNOTEQUAL;
+
+ if (pj_strcmp(&sd1->origin.addr_type, &sd2->origin.addr_type) != 0)
+ return PJMEDIA_SDP_EORIGINNOTEQUAL;
+
+ if (pj_strcmp(&sd1->origin.addr, &sd2->origin.addr) != 0)
+ return PJMEDIA_SDP_EORIGINNOTEQUAL;
+
+
+ /* Compare the subject line. */
+ if (pj_strcmp(&sd1->name, &sd2->name) != 0)
+ return PJMEDIA_SDP_ENAMENOTEQUAL;
+
+ /* Compare connection line, when they exist */
+ if (sd1->conn) {
+ if (!sd2->conn)
+ return PJMEDIA_SDP_ECONNNOTEQUAL;
+ status = compare_conn(sd1->conn, sd2->conn);
+ if (status != PJ_SUCCESS)
+ return status;
+ } else {
+ if (sd2->conn)
+ return PJMEDIA_SDP_ECONNNOTEQUAL;
+ }
+
+ /* Compare time line. */
+ if (sd1->time.start != sd2->time.start)
+ return PJMEDIA_SDP_ETIMENOTEQUAL;
+
+ if (sd1->time.stop != sd2->time.stop)
+ return PJMEDIA_SDP_ETIMENOTEQUAL;
+
+ /* Compare attributes. */
+ status = compare_attr(sd1->attr_count, sd1->attr,
+ sd2->attr_count, sd2->attr);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* Compare media lines. */
+ if (sd1->media_count != sd2->media_count)
+ return PJMEDIA_SDP_EMEDIANOTEQUAL;
+
+ for (i=0; i<sd1->media_count; ++i) {
+ status = pjmedia_sdp_media_cmp(sd1->media[i], sd2->media[i], 0);
+ if (status != PJ_SUCCESS)
+ return status;
+ }
+
+ /* Looks equal. */
+ return PJ_SUCCESS;
+}
+
+
+PJ_DEF(pj_status_t) pjmedia_sdp_conn_cmp(const pjmedia_sdp_conn *conn1,
+ const pjmedia_sdp_conn *conn2,
+ unsigned option)
+{
+ PJ_UNUSED_ARG(option);
+ return compare_conn(conn1, conn2);
+}
diff --git a/jni/pjproject-android/.svn/pristine/2c/2c58769a108e379d88c3567538070325ff3598cd.svn-base b/jni/pjproject-android/.svn/pristine/2c/2c58769a108e379d88c3567538070325ff3598cd.svn-base
new file mode 100644
index 0000000..e15a90b
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/2c/2c58769a108e379d88c3567538070325ff3598cd.svn-base
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.teluu.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>NSMainNibFile</key>
+ <string>MainWindow</string>
+ <key>UIBackgroundModes</key>
+ <array>
+ <string>audio</string>
+ </array>
+</dict>
+</plist>
diff --git a/jni/pjproject-android/.svn/pristine/2c/2c62d1a2d7988893340c03f3f86624a90f1aec0f.svn-base b/jni/pjproject-android/.svn/pristine/2c/2c62d1a2d7988893340c03f3f86624a90f1aec0f.svn-base
new file mode 100644
index 0000000..28fd97c
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/2c/2c62d1a2d7988893340c03f3f86624a90f1aec0f.svn-base
@@ -0,0 +1,12 @@
+QMAKE_TARGET = PjsuaBB
+LUPDATE = $(QNX_HOST)/usr/bin/lupdate
+LRELEASE = $(QNX_HOST)/usr/bin/lrelease
+
+update: $(QMAKE_TARGET).pro FORCE
+ $(LUPDATE) $(QMAKE_TARGET).pro
+
+release: $(QMAKE_TARGET).pro $(QMAKE_TARGET).ts
+ $(LRELEASE) $(QMAKE_TARGET).pro
+
+FORCE:
+
diff --git a/jni/pjproject-android/.svn/pristine/2c/2c6360759048e0af92ac8ae8792fd12d75ba2634.svn-base b/jni/pjproject-android/.svn/pristine/2c/2c6360759048e0af92ac8ae8792fd12d75ba2634.svn-base
new file mode 100644
index 0000000..dd33a10
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/2c/2c6360759048e0af92ac8ae8792fd12d75ba2634.svn-base
@@ -0,0 +1,335 @@
+/* $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_CLOCK_H__
+#define __PJMEDIA_CLOCK_H__
+
+/**
+ * @file clock.h
+ * @brief Media clock.
+ */
+#include <pjmedia/types.h>
+
+
+/**
+ * @defgroup PJMEDIA_PORT_CLOCK Clock/Timing
+ * @ingroup PJMEDIA_PORT
+ * @brief Various types of classes that provide timing.
+ * @{
+
+ The media clock/timing extends the media port concept that is explained
+ in @ref PJMEDIA_PORT. When clock is present in the ports
+ interconnection, media will flow automatically (and with correct timing too!)
+ from one media port to another.
+
+ There are few objects in PJMEDIA that are able to provide clock/timing
+ to media ports interconnection:
+
+ - @ref PJMED_SND_PORT\n
+ The sound device makes a good candidate as the clock source, and
+ PJMEDIA @ref PJMED_SND is designed so that it is able to invoke
+ operations according to timing driven by the sound hardware clock
+ (this may sound complicated, but actually it just means that
+ the sound device abstraction provides callbacks to be called when
+ it has/wants media frames).\n
+ See @ref PJMED_SND_PORT for more details.
+
+ - @ref PJMEDIA_MASTER_PORT\n
+ The master port uses @ref PJMEDIA_CLOCK as the clock source. By using
+ @ref PJMEDIA_MASTER_PORT, it is possible to interconnect passive
+ media ports and let the frames flow automatically in timely manner.\n
+ Please see @ref PJMEDIA_MASTER_PORT for more details.
+
+ @}
+ */
+
+
+/**
+ * @addtogroup PJMEDIA_CLOCK Clock Generator
+ * @ingroup PJMEDIA_PORT_CLOCK
+ * @brief Interface for generating clock.
+ * @{
+ *
+ * The clock generator provides the application with media timing,
+ * and it is used by the @ref PJMEDIA_MASTER_PORT for its sound clock.
+ *
+ * The clock generator may be configured to run <b>asynchronously</b>
+ * (the default behavior) or <b>synchronously</b>. When it is run
+ * asynchronously, it will call the application's callback every time
+ * the clock <b>tick</b> expires. When it is run synchronously,
+ * application must continuously polls the clock generator to synchronize
+ * the timing.
+ */
+
+PJ_BEGIN_DECL
+
+/**
+ * Media clock source.
+ */
+typedef struct pjmedia_clock_src
+{
+ pjmedia_type media_type; /**< Media type. */
+ unsigned clock_rate; /**< Clock rate. */
+ unsigned ptime_usec; /**< Frame interval (in usec). */
+ /**
+ * The timestamp field holds an increasing value in samples and its
+ * value is expected to be increased by clock_rate samples per second.
+ */
+ pj_timestamp timestamp;
+ /**
+ * Timestamp's last update. The last_update field contains a value in
+ * ticks, and it is expected to be increased by pj_get_timestamp_freq()
+ * ticks per second.
+ */
+ pj_timestamp last_update;
+} pjmedia_clock_src;
+
+/**
+ * This is an auxiliary function to initialize the media clock source.
+ *
+ * @param clocksrc The clock source to be initialized.
+ * @param media_type The media type.
+ * @param clock_rate The clock rate.
+ * @param ptime_usec Media frame interval (in usec).
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_src_init( pjmedia_clock_src *clocksrc,
+ pjmedia_type media_type,
+ unsigned clock_rate,
+ unsigned ptime_usec );
+
+/**
+ * This function updates the clock source's timestamp. Application should
+ * use this function instead of updating the timestamp directly since this
+ * function will also update the last_update field of the clock source.
+ *
+ * @param clocksrc The clock source to be updated.
+ * @param timestamp The new timestamp, can be NULL if the current
+ * timestamp does not change (in this case it
+ * will only update the last_update field).
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_src_update( pjmedia_clock_src *clocksrc,
+ const pj_timestamp *timestamp );
+
+/**
+ * This function gets the clock source's current timestamp. Application
+ * should use this function instead of accessing the timestamp directly
+ * since this function will calculate the predicted timestamp for current
+ * time, based on the values of timestamp, last_update, and clock_rate.
+ *
+ * @param clocksrc The clock source.
+ * @param timestamp Argument to receive the current timestamp
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_clock_src_get_current_timestamp( const pjmedia_clock_src *clocksrc,
+ pj_timestamp *timestamp);
+
+/**
+ * This function gets the clock source's time in msec.
+ *
+ * @param clocksrc The clock source.
+ *
+ * @return The clock source's time (in msec).
+ */
+PJ_DECL(pj_uint32_t)
+pjmedia_clock_src_get_time_msec( const pjmedia_clock_src *clocksrc );
+
+
+/**
+ * Opaque declaration for media clock.
+ */
+typedef struct pjmedia_clock pjmedia_clock;
+
+
+/**
+ * Options when creating the clock.
+ */
+enum pjmedia_clock_options
+{
+ /**
+ * Prevents the clock from running asynchronously. In this case,
+ * application must poll the clock continuously by calling
+ * #pjmedia_clock_wait() in order to synchronize timing.
+ */
+ PJMEDIA_CLOCK_NO_ASYNC = 1,
+
+ /**
+ * Prevent the clock from setting it's thread to highest priority.
+ */
+ PJMEDIA_CLOCK_NO_HIGHEST_PRIO = 2
+};
+
+
+typedef struct pjmedia_clock_param
+{
+ /**
+ * The frame interval, in microseconds.
+ */
+ unsigned usec_interval;
+ /**
+ * The media clock rate, to determine timestamp
+ * increment for each call.
+ */
+ unsigned clock_rate;
+} pjmedia_clock_param;
+
+/**
+ * Type of media clock callback.
+ *
+ * @param ts Current timestamp, in samples.
+ * @param user_data Application data that is passed when
+ * the clock was created.
+ */
+typedef void pjmedia_clock_callback(const pj_timestamp *ts,
+ void *user_data);
+
+
+
+/**
+ * Create media clock. This creates a media clock object that will run
+ * periodically at an interval that is calculated from the audio parameters.
+ * Once created, application must call #pjmedia_clock_start() to actually
+ * start the clock.
+ *
+ * @see pjmedia_clock_create2()
+ *
+ * @param pool Pool to allocate memory.
+ * @param clock_rate Number of samples per second.
+ * @param channel_count Number of channel.
+ * @param samples_per_frame Number of samples per frame. This argument
+ * along with clock_rate and channel_count, specifies
+ * the interval of each clock run (or clock ticks).
+ * @param options Bitmask of pjmedia_clock_options.
+ * @param cb Callback to be called for each clock tick.
+ * @param user_data User data, which will be passed to the callback.
+ * @param p_clock Pointer to receive the clock instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_create( pj_pool_t *pool,
+ unsigned clock_rate,
+ unsigned channel_count,
+ unsigned samples_per_frame,
+ unsigned options,
+ pjmedia_clock_callback *cb,
+ void *user_data,
+ pjmedia_clock **p_clock);
+
+
+/**
+ * Create media clock. This creates a media clock object that will run
+ * periodically at the specified interval. Once created, application must
+ * call #pjmedia_clock_start() to actually start the clock.
+ *
+ * @param pool Pool to allocate memory.
+ * @param param The clock parameter.
+ * @param options Bitmask of pjmedia_clock_options.
+ * @param cb Callback to be called for each clock tick.
+ * @param user_data User data, which will be passed to the callback.
+ * @param p_clock Pointer to receive the clock instance.
+ *
+ * @return PJ_SUCCESS on success, or the appropriate error
+ * code.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_create2(pj_pool_t *pool,
+ const pjmedia_clock_param *param,
+ unsigned options,
+ pjmedia_clock_callback *cb,
+ void *user_data,
+ pjmedia_clock **p_clock);
+
+/**
+ * Start the clock. For clock created with asynchronous flag set to TRUE,
+ * this may start a worker thread for the clock (depending on the
+ * backend clock implementation being used).
+ *
+ * @param clock The media clock.
+ *
+ * @return PJ_SUCCES on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_start(pjmedia_clock *clock);
+
+
+/**
+ * Stop the clock.
+ *
+ * @param clock The media clock.
+ *
+ * @return PJ_SUCCES on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_stop(pjmedia_clock *clock);
+
+
+/**
+ * Modify the clock's parameter.
+ *
+ * @param clock The media clock.
+ * @param param The clock's new parameter.
+ * @return PJ_SUCCES on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_modify(pjmedia_clock *clock,
+ const pjmedia_clock_param *param);
+
+
+/**
+ * Poll the media clock, and execute the callback when the clock tick has
+ * elapsed. This operation is only valid if the clock is created with async
+ * flag set to FALSE.
+ *
+ * @param clock The media clock.
+ * @param wait If non-zero, then the function will block until
+ * a clock tick elapsed and callback has been called.
+ * @param ts Optional argument to receive the current
+ * timestamp.
+ *
+ * @return Non-zero if clock tick has elapsed, or FALSE if
+ * the function returns before a clock tick has
+ * elapsed.
+ */
+PJ_DECL(pj_bool_t) pjmedia_clock_wait(pjmedia_clock *clock,
+ pj_bool_t wait,
+ pj_timestamp *ts);
+
+
+/**
+ * Destroy the clock.
+ *
+ * @param clock The media clock.
+ *
+ * @return PJ_SUCCES on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_clock_destroy(pjmedia_clock *clock);
+
+
+
+PJ_END_DECL
+
+/**
+ * @}
+ */
+
+
+#endif /* __PJMEDIA_CLOCK_H__ */
+
diff --git a/jni/pjproject-android/.svn/pristine/2c/2c8808e5565296b9a506f96af2773a7263623641.svn-base b/jni/pjproject-android/.svn/pristine/2c/2c8808e5565296b9a506f96af2773a7263623641.svn-base
new file mode 100644
index 0000000..8a081fb
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/2c/2c8808e5565296b9a506f96af2773a7263623641.svn-base
@@ -0,0 +1,36 @@
+
+ /******************************************************************
+
+ iLBC Speech Coder ANSI-C Source Code
+
+ enhancer.h
+
+ Copyright (C) The Internet Society (2004).
+ All Rights Reserved.
+
+
+
+
+
+ ******************************************************************/
+
+ #ifndef __ENHANCER_H
+ #define __ENHANCER_H
+
+ #include "iLBC_define.h"
+
+ float xCorrCoef(
+ float *target, /* (i) first array */
+ float *regressor, /* (i) second array */
+ int subl /* (i) dimension arrays */
+ );
+
+ int enhancerInterface(
+ float *out, /* (o) the enhanced recidual signal */
+ float *in, /* (i) the recidual signal to enhance */
+ iLBC_Dec_Inst_t *iLBCdec_inst
+ /* (i/o) the decoder state structure */
+ );
+
+ #endif
+
diff --git a/jni/pjproject-android/.svn/pristine/2c/2c9a8909ef2aa8d1e2dcb34a09162e0922ac533f.svn-base b/jni/pjproject-android/.svn/pristine/2c/2c9a8909ef2aa8d1e2dcb34a09162e0922ac533f.svn-base
new file mode 100644
index 0000000..cfd6d61
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/2c/2c9a8909ef2aa8d1e2dcb34a09162e0922ac533f.svn-base
@@ -0,0 +1,11 @@
+<p> </p>
+<hr><center>
+PJLIB-UTIL Open Source, small footprint, and portable asynchronous/caching DNS resolver, text scanner, STUN client, and XML library<br>
+Copyright (C) 2006-2009 Teluu Inc.
+</center>
+
+
+<!--#include virtual="/footer.html" -->
+
+</BODY>
+</HTML>
diff --git a/jni/pjproject-android/.svn/pristine/2c/2ca6a0ae4a776c5ccebbfd28cea62458334c816b.svn-base b/jni/pjproject-android/.svn/pristine/2c/2ca6a0ae4a776c5ccebbfd28cea62458334c816b.svn-base
new file mode 100644
index 0000000..8fc6a32
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/2c/2ca6a0ae4a776c5ccebbfd28cea62458334c816b.svn-base
@@ -0,0 +1,444 @@
+/*
+ * aes_cbc.c
+ *
+ * AES Cipher Block Chaining Mode
+ *
+ * David A. McGrew
+ * Cisco Systems, Inc.
+ */
+
+/*
+ *
+ * Copyright (c) 2001-2006, Cisco Systems, Inc.
+ * All rights reserved.
+ *
+ * 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 Cisco Systems, Inc. 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
+ * COPYRIGHT HOLDERS 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 "aes_cbc.h"
+#include "alloc.h"
+
+debug_module_t mod_aes_cbc = {
+ 0, /* debugging is off by default */
+ "aes cbc" /* printable module name */
+};
+
+
+
+err_status_t
+aes_cbc_alloc(cipher_t **c, int key_len) {
+ extern cipher_type_t aes_cbc;
+ uint8_t *pointer;
+ int tmp;
+
+ debug_print(mod_aes_cbc,
+ "allocating cipher with key length %d", key_len);
+
+ if (key_len != 16)
+ return err_status_bad_param;
+
+ /* allocate memory a cipher of type aes_icm */
+ tmp = (sizeof(aes_cbc_ctx_t) + sizeof(cipher_t));
+ pointer = (uint8_t*)crypto_alloc(tmp);
+ if (pointer == NULL)
+ return err_status_alloc_fail;
+
+ /* set pointers */
+ *c = (cipher_t *)pointer;
+ (*c)->type = &aes_cbc;
+ (*c)->state = pointer + sizeof(cipher_t);
+
+ /* increment ref_count */
+ aes_cbc.ref_count++;
+
+ /* set key size */
+ (*c)->key_len = key_len;
+
+ return err_status_ok;
+}
+
+err_status_t
+aes_cbc_dealloc(cipher_t *c) {
+ extern cipher_type_t aes_cbc;
+
+ /* zeroize entire state*/
+ octet_string_set_to_zero((uint8_t *)c,
+ sizeof(aes_cbc_ctx_t) + sizeof(cipher_t));
+
+ /* free memory */
+ crypto_free(c);
+
+ /* decrement ref_count */
+ aes_cbc.ref_count--;
+
+ return err_status_ok;
+}
+
+err_status_t
+aes_cbc_context_init(aes_cbc_ctx_t *c, const uint8_t *key,
+ cipher_direction_t dir) {
+ v128_t tmp_key;
+
+ /* set tmp_key (for alignment) */
+ v128_copy_octet_string(&tmp_key, key);
+
+ debug_print(mod_aes_cbc,
+ "key: %s", v128_hex_string(&tmp_key));
+
+ /* expand key for the appropriate direction */
+ switch (dir) {
+ case (direction_encrypt):
+ aes_expand_encryption_key(&tmp_key, c->expanded_key);
+ break;
+ case (direction_decrypt):
+ aes_expand_decryption_key(&tmp_key, c->expanded_key);
+ break;
+ default:
+ return err_status_bad_param;
+ }
+
+
+ return err_status_ok;
+}
+
+
+err_status_t
+aes_cbc_set_iv(aes_cbc_ctx_t *c, void *iv) {
+ int i;
+/* v128_t *input = iv; */
+ uint8_t *input = (uint8_t*) iv;
+
+ /* set state and 'previous' block to iv */
+ for (i=0; i < 16; i++)
+ c->previous.v8[i] = c->state.v8[i] = input[i];
+
+ debug_print(mod_aes_cbc, "setting iv: %s", v128_hex_string(&c->state));
+
+ return err_status_ok;
+}
+
+err_status_t
+aes_cbc_encrypt(aes_cbc_ctx_t *c,
+ unsigned char *data,
+ unsigned int *bytes_in_data) {
+ int i;
+ unsigned char *input = data; /* pointer to data being read */
+ unsigned char *output = data; /* pointer to data being written */
+ int bytes_to_encr = *bytes_in_data;
+
+ /*
+ * verify that we're 16-octet aligned
+ */
+ if (*bytes_in_data & 0xf)
+ return err_status_bad_param;
+
+ /*
+ * note that we assume that the initialization vector has already
+ * been set, e.g. by calling aes_cbc_set_iv()
+ */
+ debug_print(mod_aes_cbc, "iv: %s",
+ v128_hex_string(&c->state));
+
+ /*
+ * loop over plaintext blocks, exoring state into plaintext then
+ * encrypting and writing to output
+ */
+ while (bytes_to_encr > 0) {
+
+ /* exor plaintext into state */
+ for (i=0; i < 16; i++)
+ c->state.v8[i] ^= *input++;
+
+ debug_print(mod_aes_cbc, "inblock: %s",
+ v128_hex_string(&c->state));
+
+ aes_encrypt(&c->state, c->expanded_key);
+
+ debug_print(mod_aes_cbc, "outblock: %s",
+ v128_hex_string(&c->state));
+
+ /* copy ciphertext to output */
+ for (i=0; i < 16; i++)
+ *output++ = c->state.v8[i];
+
+ bytes_to_encr -= 16;
+ }
+
+ return err_status_ok;
+}
+
+err_status_t
+aes_cbc_decrypt(aes_cbc_ctx_t *c,
+ unsigned char *data,
+ unsigned int *bytes_in_data) {
+ int i;
+ v128_t state, previous;
+ unsigned char *input = data; /* pointer to data being read */
+ unsigned char *output = data; /* pointer to data being written */
+ int bytes_to_encr = *bytes_in_data;
+ uint8_t tmp;
+
+ /*
+ * verify that we're 16-octet aligned
+ */
+ if (*bytes_in_data & 0x0f)
+ return err_status_bad_param;
+
+ /* set 'previous' block to iv*/
+ for (i=0; i < 16; i++) {
+ previous.v8[i] = c->previous.v8[i];
+ }
+
+ debug_print(mod_aes_cbc, "iv: %s",
+ v128_hex_string(&previous));
+
+ /*
+ * loop over ciphertext blocks, decrypting then exoring with state
+ * then writing plaintext to output
+ */
+ while (bytes_to_encr > 0) {
+
+ /* set state to ciphertext input block */
+ for (i=0; i < 16; i++) {
+ state.v8[i] = *input++;
+ }
+
+ debug_print(mod_aes_cbc, "inblock: %s",
+ v128_hex_string(&state));
+
+ /* decrypt state */
+ aes_decrypt(&state, c->expanded_key);
+
+ debug_print(mod_aes_cbc, "outblock: %s",
+ v128_hex_string(&state));
+
+ /*
+ * exor previous ciphertext block out of plaintext, and write new
+ * plaintext block to output, while copying old ciphertext block
+ * to the 'previous' block
+ */
+ for (i=0; i < 16; i++) {
+ tmp = *output;
+ *output++ = state.v8[i] ^ previous.v8[i];
+ previous.v8[i] = tmp;
+ }
+
+ bytes_to_encr -= 16;
+ }
+
+ return err_status_ok;
+}
+
+
+err_status_t
+aes_cbc_nist_encrypt(aes_cbc_ctx_t *c,
+ unsigned char *data,
+ unsigned int *bytes_in_data) {
+ int i;
+ unsigned char *pad_start;
+ int num_pad_bytes;
+ err_status_t status;
+
+ /*
+ * determine the number of padding bytes that we need to add -
+ * this value is always between 1 and 16, inclusive.
+ */
+ num_pad_bytes = 16 - (*bytes_in_data & 0xf);
+ pad_start = data;
+ pad_start += *bytes_in_data;
+ *pad_start++ = 0xa0;
+ for (i=0; i < num_pad_bytes; i++)
+ *pad_start++ = 0x00;
+
+ /*
+ * increment the data size
+ */
+ *bytes_in_data += num_pad_bytes;
+
+ /*
+ * now cbc encrypt the padded data
+ */
+ status = aes_cbc_encrypt(c, data, bytes_in_data);
+ if (status)
+ return status;
+
+ return err_status_ok;
+}
+
+
+err_status_t
+aes_cbc_nist_decrypt(aes_cbc_ctx_t *c,
+ unsigned char *data,
+ unsigned int *bytes_in_data) {
+ unsigned char *pad_end;
+ int num_pad_bytes;
+ err_status_t status;
+
+ /*
+ * cbc decrypt the padded data
+ */
+ status = aes_cbc_decrypt(c, data, bytes_in_data);
+ if (status)
+ return status;
+
+ /*
+ * determine the number of padding bytes in the decrypted plaintext
+ * - this value is always between 1 and 16, inclusive.
+ */
+ num_pad_bytes = 1;
+ pad_end = data + (*bytes_in_data - 1);
+ while (*pad_end != 0xa0) { /* note: should check padding correctness */
+ pad_end--;
+ num_pad_bytes++;
+ }
+
+ /* decrement data size */
+ *bytes_in_data -= num_pad_bytes;
+
+ return err_status_ok;
+}
+
+
+char
+aes_cbc_description[] = "aes cipher block chaining (cbc) mode";
+
+/*
+ * Test case 0 is derived from FIPS 197 Appendix A; it uses an
+ * all-zero IV, so that the first block encryption matches the test
+ * case in that appendix. This property provides a check of the base
+ * AES encryption and decryption algorithms; if CBC fails on some
+ * particular platform, then you should print out AES intermediate
+ * data and compare with the detailed info provided in that appendix.
+ *
+ */
+
+
+uint8_t aes_cbc_test_case_0_key[16] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
+uint8_t aes_cbc_test_case_0_plaintext[64] = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
+};
+
+uint8_t aes_cbc_test_case_0_ciphertext[80] = {
+ 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
+ 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a,
+ 0x03, 0x35, 0xed, 0x27, 0x67, 0xf2, 0x6d, 0xf1,
+ 0x64, 0x83, 0x2e, 0x23, 0x44, 0x38, 0x70, 0x8b
+
+};
+
+uint8_t aes_cbc_test_case_0_iv[16] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+
+cipher_test_case_t aes_cbc_test_case_0 = {
+ 16, /* octets in key */
+ aes_cbc_test_case_0_key, /* key */
+ aes_cbc_test_case_0_iv, /* initialization vector */
+ 16, /* octets in plaintext */
+ aes_cbc_test_case_0_plaintext, /* plaintext */
+ 32, /* octets in ciphertext */
+ aes_cbc_test_case_0_ciphertext, /* ciphertext */
+ NULL /* pointer to next testcase */
+};
+
+
+/*
+ * this test case is taken directly from Appendix F.2 of NIST Special
+ * Publication SP 800-38A
+ */
+
+uint8_t aes_cbc_test_case_1_key[16] = {
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c,
+};
+
+uint8_t aes_cbc_test_case_1_plaintext[64] = {
+ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10
+};
+
+uint8_t aes_cbc_test_case_1_ciphertext[80] = {
+ 0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46,
+ 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d,
+ 0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee,
+ 0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2,
+ 0x73, 0xbe, 0xd6, 0xb8, 0xe3, 0xc1, 0x74, 0x3b,
+ 0x71, 0x16, 0xe6, 0x9e, 0x22, 0x22, 0x95, 0x16,
+ 0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09,
+ 0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7,
+ 0x39, 0x34, 0x07, 0x03, 0x36, 0xd0, 0x77, 0x99,
+ 0xe0, 0xc4, 0x2f, 0xdd, 0xa8, 0xdf, 0x4c, 0xa3
+};
+
+uint8_t aes_cbc_test_case_1_iv[16] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
+};
+
+cipher_test_case_t aes_cbc_test_case_1 = {
+ 16, /* octets in key */
+ aes_cbc_test_case_1_key, /* key */
+ aes_cbc_test_case_1_iv, /* initialization vector */
+ 64, /* octets in plaintext */
+ aes_cbc_test_case_1_plaintext, /* plaintext */
+ 80, /* octets in ciphertext */
+ aes_cbc_test_case_1_ciphertext, /* ciphertext */
+ &aes_cbc_test_case_0 /* pointer to next testcase */
+};
+
+cipher_type_t aes_cbc = {
+ (cipher_alloc_func_t) aes_cbc_alloc,
+ (cipher_dealloc_func_t) aes_cbc_dealloc,
+ (cipher_init_func_t) aes_cbc_context_init,
+ (cipher_encrypt_func_t) aes_cbc_nist_encrypt,
+ (cipher_decrypt_func_t) aes_cbc_nist_decrypt,
+ (cipher_set_iv_func_t) aes_cbc_set_iv,
+ (char *) aes_cbc_description,
+ (int) 0, /* instance count */
+ (cipher_test_case_t *) &aes_cbc_test_case_0,
+ (debug_module_t *) &mod_aes_cbc
+};
+
+
diff --git a/jni/pjproject-android/.svn/pristine/2c/2cd7b044fe18565cadf4ab9a80c2674968381668.svn-base b/jni/pjproject-android/.svn/pristine/2c/2cd7b044fe18565cadf4ab9a80c2674968381668.svn-base
new file mode 100644
index 0000000..924155f
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/2c/2cd7b044fe18565cadf4ab9a80c2674968381668.svn-base
@@ -0,0 +1,201 @@
+/* $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 <pj/addr_resolv.h>
+#include <pj/assert.h>
+#include <pj/errno.h>
+#include <pj/ip_helper.h>
+#include <pj/log.h>
+#include <pj/sock.h>
+#include <pj/string.h>
+#include <pj/unicode.h>
+
+#include "os_symbian.h"
+
+#define THIS_FILE "addr_resolv_symbian.cpp"
+#define TRACE_ME 0
+
+
+// PJLIB API: resolve hostname
+PJ_DEF(pj_status_t) pj_gethostbyname(const pj_str_t *name, pj_hostent *he)
+{
+ static pj_addrinfo ai;
+ static char *aliases[2];
+ static char *addrlist[2];
+ unsigned count = 1;
+ pj_status_t status;
+
+ status = pj_getaddrinfo(PJ_AF_INET, name, &count, &ai);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ aliases[0] = ai.ai_canonname;
+ aliases[1] = NULL;
+
+ addrlist[0] = (char*) &ai.ai_addr.ipv4.sin_addr;
+ addrlist[1] = NULL;
+
+ pj_bzero(he, sizeof(*he));
+ he->h_name = aliases[0];
+ he->h_aliases = aliases;
+ he->h_addrtype = PJ_AF_INET;
+ he->h_length = 4;
+ he->h_addr_list = addrlist;
+
+ return PJ_SUCCESS;
+}
+
+
+// Resolve for specific address family
+static pj_status_t getaddrinfo_by_af(int af, const pj_str_t *name,
+ unsigned *count, pj_addrinfo ai[])
+{
+ unsigned i;
+ pj_status_t status;
+
+ PJ_ASSERT_RETURN(name && count && ai, PJ_EINVAL);
+
+#if !defined(PJ_HAS_IPV6) || !PJ_HAS_IPV6
+ if (af == PJ_AF_INET6)
+ return PJ_EIPV6NOTSUP;
+#endif
+
+ // Return failure if access point is marked as down by app.
+ PJ_SYMBIAN_CHECK_CONNECTION();
+
+ // Get resolver for the specified address family
+ RHostResolver &resv = PjSymbianOS::Instance()->GetResolver(af);
+
+ // Convert name to Unicode
+ wchar_t name16[PJ_MAX_HOSTNAME];
+ pj_ansi_to_unicode(name->ptr, name->slen, name16, PJ_ARRAY_SIZE(name16));
+ TPtrC16 data((const TUint16*)name16);
+
+ // Resolve!
+ TNameEntry nameEntry;
+ TRequestStatus reqStatus;
+
+ resv.GetByName(data, nameEntry, reqStatus);
+ User::WaitForRequest(reqStatus);
+
+ // Iterate each result
+ i = 0;
+ while (reqStatus == KErrNone && i < *count) {
+
+ // Get the resolved TInetAddr
+ TInetAddr inetAddr(nameEntry().iAddr);
+ int addrlen;
+
+#if TRACE_ME
+ if (1) {
+ pj_sockaddr a;
+ char ipaddr[PJ_INET6_ADDRSTRLEN+2];
+ int namelen;
+
+ namelen = sizeof(pj_sockaddr);
+ if (PjSymbianOS::Addr2pj(inetAddr, a, &namelen,
+ PJ_FALSE) == PJ_SUCCESS)
+ {
+ PJ_LOG(5,(THIS_FILE, "resolve %.*s: %s",
+ (int)name->slen, name->ptr,
+ pj_sockaddr_print(&a, ipaddr, sizeof(ipaddr), 2)));
+ }
+ }
+#endif
+
+ // Ignore if this is not the same address family
+ // Not a good idea, as Symbian mapps IPv4 to IPv6.
+ //fam = inetAddr.Family();
+ //if (fam != af) {
+ // resv.Next(nameEntry, reqStatus);
+ // User::WaitForRequest(reqStatus);
+ // continue;
+ //}
+
+ // Convert IP address first to get IPv4 mapped address
+ addrlen = sizeof(ai[i].ai_addr);
+ status = PjSymbianOS::Addr2pj(inetAddr, ai[i].ai_addr,
+ &addrlen, PJ_TRUE);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ // Ignore if address family doesn't match
+ if (ai[i].ai_addr.addr.sa_family != af) {
+ resv.Next(nameEntry, reqStatus);
+ User::WaitForRequest(reqStatus);
+ continue;
+ }
+
+ // Convert the official address to ANSI.
+ pj_unicode_to_ansi((const wchar_t*)nameEntry().iName.Ptr(),
+ nameEntry().iName.Length(),
+ ai[i].ai_canonname, sizeof(ai[i].ai_canonname));
+
+ // Next
+ ++i;
+ resv.Next(nameEntry, reqStatus);
+ User::WaitForRequest(reqStatus);
+ }
+
+ *count = i;
+ return PJ_SUCCESS;
+}
+
+/* Resolve IPv4/IPv6 address */
+PJ_DEF(pj_status_t) pj_getaddrinfo(int af, const pj_str_t *nodename,
+ unsigned *count, pj_addrinfo ai[])
+{
+ unsigned start;
+ pj_status_t status = PJ_EAFNOTSUP;
+
+ PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6 || af==PJ_AF_UNSPEC,
+ PJ_EAFNOTSUP);
+ PJ_ASSERT_RETURN(nodename && count && *count && ai, PJ_EINVAL);
+
+ start = 0;
+
+ if (af==PJ_AF_INET6 || af==PJ_AF_UNSPEC) {
+ unsigned max = *count;
+ status = getaddrinfo_by_af(PJ_AF_INET6, nodename,
+ &max, &ai[start]);
+ if (status == PJ_SUCCESS) {
+ (*count) -= max;
+ start += max;
+ }
+ }
+
+ if (af==PJ_AF_INET || af==PJ_AF_UNSPEC) {
+ unsigned max = *count;
+ status = getaddrinfo_by_af(PJ_AF_INET, nodename,
+ &max, &ai[start]);
+ if (status == PJ_SUCCESS) {
+ (*count) -= max;
+ start += max;
+ }
+ }
+
+ *count = start;
+
+ if (*count) {
+ return PJ_SUCCESS;
+ } else {
+ return status!=PJ_SUCCESS ? status : PJ_ENOTFOUND;
+ }
+}
+