* #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/0a/0a009893635b994c10f1cc178e7792446631b9ae.svn-base b/jni/pjproject-android/.svn/pristine/0a/0a009893635b994c10f1cc178e7792446631b9ae.svn-base
new file mode 100644
index 0000000..51ab669
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0a009893635b994c10f1cc178e7792446631b9ae.svn-base
@@ -0,0 +1,28 @@
+/* $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/log.h>
+#include <pj/os.h>
+
+PJ_DEF(void) pj_log_write(int level, const char *buffer, int len)
+{
+ PJ_CHECK_STACK();
+ printk(KERN_INFO "%s", buffer);
+}
+
diff --git a/jni/pjproject-android/.svn/pristine/0a/0a0562ffe1705b70017947f0bfd65db119717640.svn-base b/jni/pjproject-android/.svn/pristine/0a/0a0562ffe1705b70017947f0bfd65db119717640.svn-base
new file mode 100644
index 0000000..c9192b5
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0a0562ffe1705b70017947f0bfd65db119717640.svn-base
@@ -0,0 +1,203 @@
+/* $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
+ */
+
+/* See http://trac.pjsip.org/repos/wiki/MeasuringSoundLatency on
+ * how to use this program.
+ */
+
+#include <pjmedia.h>
+#include <pjlib.h>
+
+#include <stdio.h>
+
+#define THIS_FILE "lacency.c"
+
+
+/* Util to display the error message for the specified error code */
+static int app_perror( const char *sender, const char *title,
+ pj_status_t status)
+{
+ char errmsg[PJ_ERR_MSG_SIZE];
+
+ PJ_UNUSED_ARG(sender);
+
+ pj_strerror(status, errmsg, sizeof(errmsg));
+
+ printf("%s: %s [code=%d]\n", title, errmsg, status);
+ return 1;
+}
+
+/*
+ * Find out latency
+ */
+static int calculate_latency(pj_pool_t *pool, pjmedia_port *wav)
+{
+ pjmedia_frame frm;
+ short *buf;
+ unsigned i, samples_per_frame;
+ pj_size_t read, len;
+ unsigned start_pos;
+ pj_status_t status;
+
+ unsigned lat_sum = 0,
+ lat_cnt = 0,
+ lat_min = 10000,
+ lat_max = 0;
+
+ samples_per_frame = PJMEDIA_PIA_SPF(&wav->info);
+ frm.buf = pj_pool_alloc(pool, samples_per_frame * 2);
+ frm.size = samples_per_frame * 2;
+ len = pjmedia_wav_player_get_len(wav);
+ buf = pj_pool_alloc(pool, len + samples_per_frame);
+
+ read = 0;
+ while (read < len/2) {
+ status = pjmedia_port_get_frame(wav, &frm);
+ if (status != PJ_SUCCESS)
+ break;
+
+ pjmedia_copy_samples(buf+read, (short*)frm.buf, samples_per_frame);
+ read += samples_per_frame;
+ }
+
+ if (read < 2 * PJMEDIA_PIA_SRATE(&wav->info)) {
+ puts("Error: too short");
+ return -1;
+ }
+
+ start_pos = 0;
+ while (start_pos < len/2 - PJMEDIA_PIA_SRATE(&wav->info)) {
+ int max_signal = 0;
+ unsigned max_signal_pos = start_pos;
+ unsigned max_echo_pos = 0;
+ unsigned pos;
+ unsigned lat;
+
+ /* Get the largest signal in the next 0.7s */
+ for (i=start_pos; i<start_pos + PJMEDIA_PIA_SRATE(&wav->info) * 700 / 1000; ++i) {
+ if (abs(buf[i]) > max_signal) {
+ max_signal = abs(buf[i]);
+ max_signal_pos = i;
+ }
+ }
+
+ /* Advance 10ms from max_signal_pos */
+ pos = max_signal_pos + 10 * PJMEDIA_PIA_SRATE(&wav->info) / 1000;
+
+ /* Get the largest signal in the next 500ms */
+ max_signal = 0;
+ max_echo_pos = pos;
+ for (i=pos; i<pos+PJMEDIA_PIA_SRATE(&wav->info)/2; ++i) {
+ if (abs(buf[i]) > max_signal) {
+ max_signal = abs(buf[i]);
+ max_echo_pos = i;
+ }
+ }
+
+ lat = (max_echo_pos - max_signal_pos) * 1000 / PJMEDIA_PIA_SRATE(&wav->info);
+
+#if 0
+ printf("Latency = %u\n", lat);
+#endif
+
+ lat_sum += lat;
+ lat_cnt++;
+ if (lat < lat_min)
+ lat_min = lat;
+ if (lat > lat_max)
+ lat_max = lat;
+
+ /* Advance next loop */
+ start_pos += PJMEDIA_PIA_SRATE(&wav->info);
+ }
+
+ printf("Latency average = %u\n", lat_sum / lat_cnt);
+ printf("Latency minimum = %u\n", lat_min);
+ printf("Latency maximum = %u\n", lat_max);
+ printf("Number of data = %u\n", lat_cnt);
+ return 0;
+}
+
+
+/*
+ * main()
+ */
+int main(int argc, char *argv[])
+{
+ enum { NSAMPLES = 160, COUNT=100 };
+ pj_caching_pool cp;
+ pj_pool_t *pool;
+ pjmedia_port *wav;
+ pj_status_t status;
+
+
+ /* Verify cmd line arguments. */
+ if (argc != 2) {
+ puts("Error: missing argument(s)");
+ puts("Usage: latency REV.WAV");
+ return 1;
+ }
+
+ pj_log_set_level(0);
+
+ status = pj_init();
+ PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+ pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
+
+ pool = pj_pool_create( &cp.factory, /* pool factory */
+ "wav", /* pool name. */
+ 4000, /* init size */
+ 4000, /* increment size */
+ NULL /* callback on error */
+ );
+
+ status = pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
+ &pjmedia_strerror);
+ pj_assert(status == PJ_SUCCESS);
+
+ /* Wav */
+ status = pjmedia_wav_player_port_create( pool, /* memory pool */
+ argv[1], /* file to play */
+ 0, /* use default ptime*/
+ 0, /* flags */
+ 0, /* default buffer */
+ &wav /* returned port */
+ );
+ if (status != PJ_SUCCESS) {
+ app_perror(THIS_FILE, argv[1], status);
+ return 1;
+ }
+
+ status = calculate_latency(pool, wav);
+ if (status != PJ_SUCCESS)
+ return 1;
+
+ status = pjmedia_port_destroy( wav );
+ PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+ pj_pool_release( pool );
+ pj_caching_pool_destroy( &cp );
+ pj_shutdown();
+
+ /* Done. */
+ return 0;
+}
+
diff --git a/jni/pjproject-android/.svn/pristine/0a/0a189f663d89cb32c9d1dd10ee6ba66d3557cbf6.svn-base b/jni/pjproject-android/.svn/pristine/0a/0a189f663d89cb32c9d1dd10ee6ba66d3557cbf6.svn-base
new file mode 100644
index 0000000..3c96144
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0a189f663d89cb32c9d1dd10ee6ba66d3557cbf6.svn-base
Binary files differ
diff --git a/jni/pjproject-android/.svn/pristine/0a/0a385be90490ff86d5d90c02f93590c7c21a2e1b.svn-base b/jni/pjproject-android/.svn/pristine/0a/0a385be90490ff86d5d90c02f93590c7c21a2e1b.svn-base
new file mode 100644
index 0000000..8dd408f
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0a385be90490ff86d5d90c02f93590c7c21a2e1b.svn-base
@@ -0,0 +1,66 @@
+/* Copyright (C) 2002 Jean-Marc Valin
+ File: hexc_10_32_table.c
+ Codebook for high-band excitation in SB-CELP mode (4000 bps)
+
+ 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.
+*/
+
+const signed char hexc_10_32_table[320] = {
+-3, -2, -1, 0, -4, 5, 35, -40, -9, 13,
+-44, 5, -27, -1, -7, 6, -11, 7, -8, 7,
+19, -14, 15, -4, 9, -10, 10, -8, 10, -9,
+-1, 1, 0, 0, 2, 5, -18, 22, -53, 50,
+1, -23, 50, -36, 15, 3, -13, 14, -10, 6,
+1, 5, -3, 4, -2, 5, -32, 25, 5, -2,
+-1, -4, 1, 11, -29, 26, -6, -15, 30, -18,
+0, 15, -17, 40, -41, 3, 9, -2, -2, 3,
+-3, -1, -5, 2, 21, -6, -16, -21, 23, 2,
+60, 15, 16, -16, -9, 14, 9, -1, 7, -9,
+0, 1, 1, 0, -1, -6, 17, -28, 54, -45,
+-1, 1, -1, -6, -6, 2, 11, 26, -29, -2,
+46, -21, 34, 12, -23, 32, -23, 16, -10, 3,
+66, 19, -20, 24, 7, 11, -3, 0, -3, -1,
+-50, -46, 2, -18, -3, 4, -1, -2, 3, -3,
+-19, 41, -36, 9, 11, -24, 21, -16, 9, -3,
+-25, -3, 10, 18, -9, -2, -5, -1, -5, 6,
+-4, -3, 2, -26, 21, -19, 35, -15, 7, -13,
+17, -19, 39, -43, 48, -31, 16, -9, 7, -2,
+-5, 3, -4, 9, -19, 27, -55, 63, -35, 10,
+26, -44, -2, 9, 4, 1, -6, 8, -9, 5,
+-8, -1, -3, -16, 45, -42, 5, 15, -16, 10,
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+-16, 24, -55, 47, -38, 27, -19, 7, -3, 1,
+16, 27, 20, -19, 18, 5, -7, 1, -5, 2,
+-6, 8, -22, 0, -3, -3, 8, -1, 7, -8,
+1, -3, 5, 0, 17, -48, 58, -52, 29, -7,
+-2, 3, -10, 6, -26, 58, -31, 1, -6, 3,
+93, -29, 39, 3, 17, 5, 6, -1, -1, -1,
+27, 13, 10, 19, -7, -34, 12, 10, -4, 9,
+-76, 9, 8, -28, -2, -11, 2, -1, 3, 1,
+-83, 38, -39, 4, -16, -6, -2, -5, 5, -2,
+};
diff --git a/jni/pjproject-android/.svn/pristine/0a/0a3aae1a94dead2639b6a8cfeb1fd8e703de055e.svn-base b/jni/pjproject-android/.svn/pristine/0a/0a3aae1a94dead2639b6a8cfeb1fd8e703de055e.svn-base
new file mode 100644
index 0000000..243ad6e
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0a3aae1a94dead2639b6a8cfeb1fd8e703de055e.svn-base
@@ -0,0 +1,112 @@
+/*
+ * getopt.c
+ *
+ * a minimal implementation of the getopt() function, written so that
+ * test applications that use that function can run on non-POSIX
+ * platforms
+ *
+ */
+/*
+ *
+ * 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 <stdlib.h> /* for NULL */
+
+int optind_s = 0;
+
+char *optarg_s;
+
+#define GETOPT_FOUND_WITHOUT_ARGUMENT 2
+#define GETOPT_FOUND_WITH_ARGUMENT 1
+#define GETOPT_NOT_FOUND 0
+
+static int
+getopt_check_character(char c, const char *string) {
+ unsigned int max_string_len = 128;
+
+ while (*string != 0) {
+ if (max_string_len == 0) {
+ return '?';
+ }
+ if (*string++ == c) {
+ if (*string == ':') {
+ return GETOPT_FOUND_WITH_ARGUMENT;
+ } else {
+ return GETOPT_FOUND_WITHOUT_ARGUMENT;
+ }
+ }
+ }
+ return GETOPT_NOT_FOUND;
+}
+
+int
+getopt_s(int argc,
+ char * const argv[],
+ const char *optstring) {
+
+
+ while (optind_s + 1 < argc) {
+ char *string;
+
+ /* move 'string' on to next argument */
+ optind_s++;
+ string = argv[optind_s];
+
+ if (string == NULL)
+ return '?'; /* NULL argument string */
+
+ if (string[0] != '-')
+ return -1; /* found an unexpected character */
+
+ switch(getopt_check_character(string[1], optstring)) {
+ case GETOPT_FOUND_WITH_ARGUMENT:
+ if (optind_s + 1 < argc) {
+ optind_s++;
+ optarg_s = argv[optind_s];
+ return string[1];
+ } else {
+ return '?'; /* argument missing */
+ }
+ case GETOPT_FOUND_WITHOUT_ARGUMENT:
+ return string[1];
+ case GETOPT_NOT_FOUND:
+ default:
+ return '?'; /* didn't find expected character */
+ break;
+ }
+ }
+
+ return -1;
+}
diff --git a/jni/pjproject-android/.svn/pristine/0a/0a45a8e6bece3227ba79081ac8c95f98a2f526b6.svn-base b/jni/pjproject-android/.svn/pristine/0a/0a45a8e6bece3227ba79081ac8c95f98a2f526b6.svn-base
new file mode 100644
index 0000000..09cc44a
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0a45a8e6bece3227ba79081ac8c95f98a2f526b6.svn-base
@@ -0,0 +1,101 @@
+/*
+ * stat-driver.c
+ *
+ * test driver for the stat_test functions
+ *
+ * David A. McGrew
+ * Cisco Systems, Inc.
+ */
+
+
+#include <stdio.h> /* for printf() */
+
+#include "err.h"
+#include "stat.h"
+
+#include "cipher.h"
+
+typedef struct {
+ void *state;
+} random_source_t;
+
+err_status_t
+random_source_alloc(void);
+
+void
+err_check(err_status_t s) {
+ if (s) {
+ printf("error (code %d)\n", s);
+ exit(1);
+ }
+}
+
+int
+main (int argc, char *argv[]) {
+ uint8_t buffer[2500];
+ unsigned int buf_len = 2500;
+ int i, j;
+ extern cipher_type_t aes_icm;
+ cipher_t *c;
+ uint8_t key[30] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05
+ };
+ v128_t nonce;
+ int num_trials = 500;
+ int num_fail;
+
+ printf("statistical tests driver\n");
+
+ for (i=0; i < 2500; i++)
+ buffer[i] = 0;
+
+ /* run tests */
+ printf("running stat_tests on all-null buffer, expecting failure\n");
+ printf("monobit %d\n", stat_test_monobit(buffer));
+ printf("poker %d\n", stat_test_poker(buffer));
+ printf("runs %d\n", stat_test_runs(buffer));
+
+ for (i=0; i < 2500; i++)
+ buffer[i] = rand();
+ printf("running stat_tests on rand(), expecting success\n");
+ printf("monobit %d\n", stat_test_monobit(buffer));
+ printf("poker %d\n", stat_test_poker(buffer));
+ printf("runs %d\n", stat_test_runs(buffer));
+
+ printf("running stat_tests on AES-128-ICM, expecting success\n");
+ /* set buffer to cipher output */
+ for (i=0; i < 2500; i++)
+ buffer[i] = 0;
+ err_check(cipher_type_alloc(&aes_icm, &c, 30));
+ err_check(cipher_init(c, key, direction_encrypt));
+ err_check(cipher_set_iv(c, &nonce));
+ err_check(cipher_encrypt(c, buffer, &buf_len));
+ /* run tests on cipher outout */
+ printf("monobit %d\n", stat_test_monobit(buffer));
+ printf("poker %d\n", stat_test_poker(buffer));
+ printf("runs %d\n", stat_test_runs(buffer));
+
+ printf("runs test (please be patient): ");
+ fflush(stdout);
+ num_fail = 0;
+ v128_set_to_zero(&nonce);
+ for(j=0; j < num_trials; j++) {
+ for (i=0; i < 2500; i++)
+ buffer[i] = 0;
+ nonce.v32[3] = i;
+ err_check(cipher_set_iv(c, &nonce));
+ err_check(cipher_encrypt(c, buffer, &buf_len));
+ if (stat_test_runs(buffer)) {
+ num_fail++;
+ }
+ }
+
+ printf("%d failures in %d tests\n", num_fail, num_trials);
+ printf("(nota bene: a small fraction of stat_test failures does not \n"
+ "indicate that the random source is invalid)\n");
+
+ return 0;
+}
diff --git a/jni/pjproject-android/.svn/pristine/0a/0a49efb72e33959ce265531a0a42a8ac5a50605a.svn-base b/jni/pjproject-android/.svn/pristine/0a/0a49efb72e33959ce265531a0a42a8ac5a50605a.svn-base
new file mode 100644
index 0000000..a874fea
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0a49efb72e33959ce265531a0a42a8ac5a50605a.svn-base
Binary files differ
diff --git a/jni/pjproject-android/.svn/pristine/0a/0a58af3883f2e6ecdd1155aeb186cacd236eea4f.svn-base b/jni/pjproject-android/.svn/pristine/0a/0a58af3883f2e6ecdd1155aeb186cacd236eea4f.svn-base
new file mode 100644
index 0000000..d2ea7eb
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0a58af3883f2e6ecdd1155aeb186cacd236eea4f.svn-base
@@ -0,0 +1 @@
+#include "../../../portaudio/src/os/win/pa_win_util.c"
diff --git a/jni/pjproject-android/.svn/pristine/0a/0a5a10d9524e3035c5668ea9f0084ae262c43160.svn-base b/jni/pjproject-android/.svn/pristine/0a/0a5a10d9524e3035c5668ea9f0084ae262c43160.svn-base
new file mode 100644
index 0000000..54733f5
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0a5a10d9524e3035c5668ea9f0084ae262c43160.svn-base
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="pjproject-vs8-wm6-common-defaults"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;$(ARCHFAM);$(_ARCHFAM_)"
+ DebugInformationFormat="3"
+ DisableSpecificWarnings="4214;4201"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="9"
+ StackReserveSize="65536"
+ StackCommitSize="4096"
+ EntryPointSymbol="WinMainCRTStartup"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;$(ARCHFAM);$(_ARCHFAM_)"
+ />
+ <UserMacro
+ Name="TargetCPU"
+ Value="armv4i"
+ />
+</VisualStudioPropertySheet>
diff --git a/jni/pjproject-android/.svn/pristine/0a/0acc561c546f23998188dd79759fdb03916cca62.svn-base b/jni/pjproject-android/.svn/pristine/0a/0acc561c546f23998188dd79759fdb03916cca62.svn-base
new file mode 100644
index 0000000..a40cd7e
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0acc561c546f23998188dd79759fdb03916cca62.svn-base
@@ -0,0 +1,17 @@
+# $Id$
+#
+from inc_cfg import *
+
+# Call with L16/8000/2 codec
+test_param = TestParam(
+ "PESQ defaults pjsua settings",
+ [
+ InstanceParam("UA1", "--stereo --max-calls=1 --clock-rate 8000 --add-codec L16/8000/2 --play-file wavs/input.2.8.wav --null-audio"),
+ InstanceParam("UA2", "--stereo --max-calls=1 --clock-rate 8000 --add-codec L16/8000/2 --rec-file wavs/tmp.2.8.wav --auto-answer 200")
+ ]
+ )
+
+if (HAS_SND_DEV == 0):
+ test_param.skip = True
+
+pesq_threshold = None
diff --git a/jni/pjproject-android/.svn/pristine/0a/0ada9bb6aa361737f7da31f12b693429b31054b0.svn-base b/jni/pjproject-android/.svn/pristine/0a/0ada9bb6aa361737f7da31f12b693429b31054b0.svn-base
new file mode 100644
index 0000000..1a9d2eb
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0ada9bb6aa361737f7da31f12b693429b31054b0.svn-base
@@ -0,0 +1,957 @@
+/* $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/endpoint.h>
+#include <pjmedia/errno.h>
+#include <pjmedia/sdp.h>
+#include <pjmedia/vid_codec.h>
+#include <pjmedia-audiodev/audiodev.h>
+#include <pj/assert.h>
+#include <pj/ioqueue.h>
+#include <pj/lock.h>
+#include <pj/log.h>
+#include <pj/os.h>
+#include <pj/pool.h>
+#include <pj/sock.h>
+#include <pj/string.h>
+
+
+#define THIS_FILE "endpoint.c"
+
+static const pj_str_t STR_AUDIO = { "audio", 5};
+static const pj_str_t STR_VIDEO = { "video", 5};
+static const pj_str_t STR_IN = { "IN", 2 };
+static const pj_str_t STR_IP4 = { "IP4", 3};
+static const pj_str_t STR_IP6 = { "IP6", 3};
+static const pj_str_t STR_RTP_AVP = { "RTP/AVP", 7 };
+static const pj_str_t STR_SDP_NAME = { "pjmedia", 7 };
+static const pj_str_t STR_SENDRECV = { "sendrecv", 8 };
+
+
+
+/* Config to control rtpmap inclusion for static payload types */
+pj_bool_t pjmedia_add_rtpmap_for_static_pt =
+ PJMEDIA_ADD_RTPMAP_FOR_STATIC_PT;
+
+/* Config to control use of RFC3890 TIAS */
+pj_bool_t pjmedia_add_bandwidth_tias_in_sdp =
+ PJMEDIA_ADD_BANDWIDTH_TIAS_IN_SDP;
+
+
+
+/* Worker thread proc. */
+static int PJ_THREAD_FUNC worker_proc(void*);
+
+
+#define MAX_THREADS 16
+
+
+/* List of media endpoint exit callback. */
+typedef struct exit_cb
+{
+ PJ_DECL_LIST_MEMBER (struct exit_cb);
+ pjmedia_endpt_exit_callback func;
+} exit_cb;
+
+
+/** Concrete declaration of media endpoint. */
+struct pjmedia_endpt
+{
+ /** Pool. */
+ pj_pool_t *pool;
+
+ /** Pool factory. */
+ pj_pool_factory *pf;
+
+ /** Codec manager. */
+ pjmedia_codec_mgr codec_mgr;
+
+ /** IOqueue instance. */
+ pj_ioqueue_t *ioqueue;
+
+ /** Do we own the ioqueue? */
+ pj_bool_t own_ioqueue;
+
+ /** Number of threads. */
+ unsigned thread_cnt;
+
+ /** IOqueue polling thread, if any. */
+ pj_thread_t *thread[MAX_THREADS];
+
+ /** To signal polling thread to quit. */
+ pj_bool_t quit_flag;
+
+ /** Is telephone-event enable */
+ pj_bool_t has_telephone_event;
+
+ /** List of exit callback. */
+ exit_cb exit_cb_list;
+};
+
+/**
+ * Initialize and get the instance of media endpoint.
+ */
+PJ_DEF(pj_status_t) pjmedia_endpt_create(pj_pool_factory *pf,
+ pj_ioqueue_t *ioqueue,
+ unsigned worker_cnt,
+ pjmedia_endpt **p_endpt)
+{
+ pj_pool_t *pool;
+ pjmedia_endpt *endpt;
+ unsigned i;
+ pj_status_t status;
+
+ status = pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE,
+ &pjmedia_strerror);
+ pj_assert(status == PJ_SUCCESS);
+
+ PJ_ASSERT_RETURN(pf && p_endpt, PJ_EINVAL);
+ PJ_ASSERT_RETURN(worker_cnt <= MAX_THREADS, PJ_EINVAL);
+
+ pool = pj_pool_create(pf, "med-ept", 512, 512, NULL);
+ if (!pool)
+ return PJ_ENOMEM;
+
+ endpt = PJ_POOL_ZALLOC_T(pool, struct pjmedia_endpt);
+ endpt->pool = pool;
+ endpt->pf = pf;
+ endpt->ioqueue = ioqueue;
+ endpt->thread_cnt = worker_cnt;
+ endpt->has_telephone_event = PJ_TRUE;
+
+ /* Sound */
+ status = pjmedia_aud_subsys_init(pf);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+
+ /* Init codec manager. */
+ status = pjmedia_codec_mgr_init(&endpt->codec_mgr, endpt->pf);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+
+ /* Initialize exit callback list. */
+ pj_list_init(&endpt->exit_cb_list);
+
+ /* Create ioqueue if none is specified. */
+ if (endpt->ioqueue == NULL) {
+
+ endpt->own_ioqueue = PJ_TRUE;
+
+ status = pj_ioqueue_create( endpt->pool, PJ_IOQUEUE_MAX_HANDLES,
+ &endpt->ioqueue);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+
+ if (worker_cnt == 0) {
+ PJ_LOG(4,(THIS_FILE, "Warning: no worker thread is created in"
+ "media endpoint for internal ioqueue"));
+ }
+ }
+
+ /* Create worker threads if asked. */
+ for (i=0; i<worker_cnt; ++i) {
+ status = pj_thread_create( endpt->pool, "media", &worker_proc,
+ endpt, 0, 0, &endpt->thread[i]);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+ }
+
+
+ *p_endpt = endpt;
+ return PJ_SUCCESS;
+
+on_error:
+
+ /* Destroy threads */
+ for (i=0; i<endpt->thread_cnt; ++i) {
+ if (endpt->thread[i]) {
+ pj_thread_destroy(endpt->thread[i]);
+ }
+ }
+
+ /* Destroy internal ioqueue */
+ if (endpt->ioqueue && endpt->own_ioqueue)
+ pj_ioqueue_destroy(endpt->ioqueue);
+
+ pjmedia_codec_mgr_destroy(&endpt->codec_mgr);
+ pjmedia_aud_subsys_shutdown();
+ pj_pool_release(pool);
+ return status;
+}
+
+/**
+ * Get the codec manager instance.
+ */
+PJ_DEF(pjmedia_codec_mgr*) pjmedia_endpt_get_codec_mgr(pjmedia_endpt *endpt)
+{
+ return &endpt->codec_mgr;
+}
+
+/**
+ * Deinitialize media endpoint.
+ */
+PJ_DEF(pj_status_t) pjmedia_endpt_destroy (pjmedia_endpt *endpt)
+{
+ exit_cb *ecb;
+
+ pjmedia_endpt_stop_threads(endpt);
+
+ /* Destroy internal ioqueue */
+ if (endpt->ioqueue && endpt->own_ioqueue) {
+ pj_ioqueue_destroy(endpt->ioqueue);
+ endpt->ioqueue = NULL;
+ }
+
+ endpt->pf = NULL;
+
+ pjmedia_codec_mgr_destroy(&endpt->codec_mgr);
+ pjmedia_aud_subsys_shutdown();
+
+ /* Call all registered exit callbacks */
+ ecb = endpt->exit_cb_list.next;
+ while (ecb != &endpt->exit_cb_list) {
+ (*ecb->func)(endpt);
+ ecb = ecb->next;
+ }
+
+ pj_pool_release (endpt->pool);
+
+ return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pjmedia_endpt_set_flag( pjmedia_endpt *endpt,
+ pjmedia_endpt_flag flag,
+ const void *value)
+{
+ PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
+
+ switch (flag) {
+ case PJMEDIA_ENDPT_HAS_TELEPHONE_EVENT_FLAG:
+ endpt->has_telephone_event = *(pj_bool_t*)value;
+ break;
+ default:
+ return PJ_EINVAL;
+ }
+
+ return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pjmedia_endpt_get_flag( pjmedia_endpt *endpt,
+ pjmedia_endpt_flag flag,
+ void *value)
+{
+ PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
+
+ switch (flag) {
+ case PJMEDIA_ENDPT_HAS_TELEPHONE_EVENT_FLAG:
+ *(pj_bool_t*)value = endpt->has_telephone_event;
+ break;
+ default:
+ return PJ_EINVAL;
+ }
+
+ return PJ_SUCCESS;
+}
+
+/**
+ * Get the ioqueue instance of the media endpoint.
+ */
+PJ_DEF(pj_ioqueue_t*) pjmedia_endpt_get_ioqueue(pjmedia_endpt *endpt)
+{
+ PJ_ASSERT_RETURN(endpt, NULL);
+ return endpt->ioqueue;
+}
+
+/**
+ * Get the number of worker threads in media endpoint.
+ */
+PJ_DEF(unsigned) pjmedia_endpt_get_thread_count(pjmedia_endpt *endpt)
+{
+ PJ_ASSERT_RETURN(endpt, 0);
+ return endpt->thread_cnt;
+}
+
+/**
+ * Get a reference to one of the worker threads of the media endpoint
+ */
+PJ_DEF(pj_thread_t*) pjmedia_endpt_get_thread(pjmedia_endpt *endpt,
+ unsigned index)
+{
+ PJ_ASSERT_RETURN(endpt, NULL);
+ PJ_ASSERT_RETURN(index < endpt->thread_cnt, NULL);
+
+ /* here should be an assert on index >= 0 < endpt->thread_cnt */
+
+ return endpt->thread[index];
+}
+
+/**
+ * Stop and destroy the worker threads of the media endpoint
+ */
+PJ_DEF(pj_status_t) pjmedia_endpt_stop_threads(pjmedia_endpt *endpt)
+{
+ unsigned i;
+
+ PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
+
+ endpt->quit_flag = 1;
+
+ /* Destroy threads */
+ for (i=0; i<endpt->thread_cnt; ++i) {
+ if (endpt->thread[i]) {
+ pj_thread_join(endpt->thread[i]);
+ pj_thread_destroy(endpt->thread[i]);
+ endpt->thread[i] = NULL;
+ }
+ }
+
+ return PJ_SUCCESS;
+}
+
+/**
+ * Worker thread proc.
+ */
+static int PJ_THREAD_FUNC worker_proc(void *arg)
+{
+ pjmedia_endpt *endpt = (pjmedia_endpt*) arg;
+
+ while (!endpt->quit_flag) {
+ pj_time_val timeout = { 0, 500 };
+ pj_ioqueue_poll(endpt->ioqueue, &timeout);
+ }
+
+ return 0;
+}
+
+/**
+ * Create pool.
+ */
+PJ_DEF(pj_pool_t*) pjmedia_endpt_create_pool( pjmedia_endpt *endpt,
+ const char *name,
+ pj_size_t initial,
+ pj_size_t increment)
+{
+ pj_assert(endpt != NULL);
+
+ return pj_pool_create(endpt->pf, name, initial, increment, NULL);
+}
+
+/* Common initialization for both audio and video SDP media line */
+static pj_status_t init_sdp_media(pjmedia_sdp_media *m,
+ pj_pool_t *pool,
+ const pj_str_t *media_type,
+ const pjmedia_sock_info *sock_info)
+{
+ char tmp_addr[PJ_INET6_ADDRSTRLEN];
+ pjmedia_sdp_attr *attr;
+ const pj_sockaddr *addr;
+
+ pj_strdup(pool, &m->desc.media, media_type);
+
+ addr = &sock_info->rtp_addr_name;
+
+ /* Validate address family */
+ PJ_ASSERT_RETURN(addr->addr.sa_family == pj_AF_INET() ||
+ addr->addr.sa_family == pj_AF_INET6(),
+ PJ_EAFNOTSUP);
+
+ /* SDP connection line */
+ m->conn = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_conn);
+ m->conn->net_type = STR_IN;
+ m->conn->addr_type = (addr->addr.sa_family==pj_AF_INET())? STR_IP4:STR_IP6;
+ pj_sockaddr_print(addr, tmp_addr, sizeof(tmp_addr), 0);
+ pj_strdup2(pool, &m->conn->addr, tmp_addr);
+
+ /* Port and transport in media description */
+ m->desc.port = pj_sockaddr_get_port(addr);
+ m->desc.port_count = 1;
+ pj_strdup (pool, &m->desc.transport, &STR_RTP_AVP);
+
+ /* Add "rtcp" attribute */
+#if defined(PJMEDIA_HAS_RTCP_IN_SDP) && PJMEDIA_HAS_RTCP_IN_SDP!=0
+ if (sock_info->rtcp_addr_name.addr.sa_family != 0) {
+ attr = pjmedia_sdp_attr_create_rtcp(pool, &sock_info->rtcp_addr_name);
+ if (attr)
+ pjmedia_sdp_attr_add(&m->attr_count, m->attr, attr);
+ }
+#endif
+
+ /* Add sendrecv attribute. */
+ attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
+ attr->name = STR_SENDRECV;
+ m->attr[m->attr_count++] = attr;
+
+ return PJ_SUCCESS;
+}
+
+/* Create m=audio SDP media line */
+PJ_DEF(pj_status_t) pjmedia_endpt_create_audio_sdp(pjmedia_endpt *endpt,
+ pj_pool_t *pool,
+ const pjmedia_sock_info *si,
+ unsigned options,
+ pjmedia_sdp_media **p_m)
+{
+ const pj_str_t STR_AUDIO = { "audio", 5 };
+ pjmedia_sdp_media *m;
+ pjmedia_sdp_attr *attr;
+ unsigned i;
+ unsigned max_bitrate = 0;
+ pj_status_t status;
+
+ PJ_UNUSED_ARG(options);
+
+ /* Check that there are not too many codecs */
+ PJ_ASSERT_RETURN(endpt->codec_mgr.codec_cnt <= PJMEDIA_MAX_SDP_FMT,
+ PJ_ETOOMANY);
+
+ /* Create and init basic SDP media */
+ m = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media);
+ status = init_sdp_media(m, pool, &STR_AUDIO, si);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* Add format, rtpmap, and fmtp (when applicable) for each codec */
+ for (i=0; i<endpt->codec_mgr.codec_cnt; ++i) {
+
+ pjmedia_codec_info *codec_info;
+ pjmedia_sdp_rtpmap rtpmap;
+ char tmp_param[3];
+ pjmedia_codec_param codec_param;
+ pj_str_t *fmt;
+
+ if (endpt->codec_mgr.codec_desc[i].prio == PJMEDIA_CODEC_PRIO_DISABLED)
+ break;
+
+ codec_info = &endpt->codec_mgr.codec_desc[i].info;
+ pjmedia_codec_mgr_get_default_param(&endpt->codec_mgr, codec_info,
+ &codec_param);
+ fmt = &m->desc.fmt[m->desc.fmt_count++];
+
+ fmt->ptr = (char*) pj_pool_alloc(pool, 8);
+ fmt->slen = pj_utoa(codec_info->pt, fmt->ptr);
+
+ rtpmap.pt = *fmt;
+ rtpmap.enc_name = codec_info->encoding_name;
+
+#if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG != 0)
+ if (codec_info->pt == PJMEDIA_RTP_PT_G722)
+ rtpmap.clock_rate = 8000;
+ else
+ rtpmap.clock_rate = codec_info->clock_rate;
+#else
+ rtpmap.clock_rate = codec_info->clock_rate;
+#endif
+
+ /* For audio codecs, rtpmap parameters denotes the number
+ * of channels, which can be omited if the value is 1.
+ */
+ if (codec_info->type == PJMEDIA_TYPE_AUDIO &&
+ codec_info->channel_cnt > 1)
+ {
+ /* Can only support one digit channel count */
+ pj_assert(codec_info->channel_cnt < 10);
+
+ tmp_param[0] = (char)('0' + codec_info->channel_cnt);
+
+ rtpmap.param.ptr = tmp_param;
+ rtpmap.param.slen = 1;
+
+ } else {
+ rtpmap.param.ptr = "";
+ rtpmap.param.slen = 0;
+ }
+
+ if (codec_info->pt >= 96 || pjmedia_add_rtpmap_for_static_pt) {
+ pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr);
+ m->attr[m->attr_count++] = attr;
+ }
+
+ /* Add fmtp params */
+ if (codec_param.setting.dec_fmtp.cnt > 0) {
+ enum { MAX_FMTP_STR_LEN = 160 };
+ char buf[MAX_FMTP_STR_LEN];
+ unsigned buf_len = 0, i;
+ pjmedia_codec_fmtp *dec_fmtp = &codec_param.setting.dec_fmtp;
+
+ /* Print codec PT */
+ buf_len += pj_ansi_snprintf(buf,
+ MAX_FMTP_STR_LEN - buf_len,
+ "%d",
+ codec_info->pt);
+
+ for (i = 0; i < dec_fmtp->cnt; ++i) {
+ pj_size_t test_len = 2;
+
+ /* Check if buf still available */
+ test_len = dec_fmtp->param[i].val.slen +
+ dec_fmtp->param[i].name.slen;
+ if (test_len + buf_len >= MAX_FMTP_STR_LEN)
+ return PJ_ETOOBIG;
+
+ /* Print delimiter */
+ buf_len += pj_ansi_snprintf(&buf[buf_len],
+ MAX_FMTP_STR_LEN - buf_len,
+ (i == 0?" ":";"));
+
+ /* Print an fmtp param */
+ if (dec_fmtp->param[i].name.slen)
+ buf_len += pj_ansi_snprintf(
+ &buf[buf_len],
+ MAX_FMTP_STR_LEN - buf_len,
+ "%.*s=%.*s",
+ (int)dec_fmtp->param[i].name.slen,
+ dec_fmtp->param[i].name.ptr,
+ (int)dec_fmtp->param[i].val.slen,
+ dec_fmtp->param[i].val.ptr);
+ else
+ buf_len += pj_ansi_snprintf(&buf[buf_len],
+ MAX_FMTP_STR_LEN - buf_len,
+ "%.*s",
+ (int)dec_fmtp->param[i].val.slen,
+ dec_fmtp->param[i].val.ptr);
+ }
+
+ attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
+
+ attr->name = pj_str("fmtp");
+ attr->value = pj_strdup3(pool, buf);
+ m->attr[m->attr_count++] = attr;
+ }
+
+ /* Find maximum bitrate in this media */
+ if (max_bitrate < codec_param.info.max_bps)
+ max_bitrate = codec_param.info.max_bps;
+ }
+
+#if defined(PJMEDIA_RTP_PT_TELEPHONE_EVENTS) && \
+ PJMEDIA_RTP_PT_TELEPHONE_EVENTS != 0
+ /*
+ * Add support telephony event
+ */
+ if (endpt->has_telephone_event) {
+ m->desc.fmt[m->desc.fmt_count++] =
+ pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR);
+
+ /* Add rtpmap. */
+ attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
+ attr->name = pj_str("rtpmap");
+ attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR
+ " telephone-event/8000");
+ m->attr[m->attr_count++] = attr;
+
+ /* Add fmtp */
+ attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
+ attr->name = pj_str("fmtp");
+ attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR " 0-15");
+ m->attr[m->attr_count++] = attr;
+ }
+#endif
+
+ /* Put bandwidth info in media level using bandwidth modifier "TIAS"
+ * (RFC3890).
+ */
+ if (max_bitrate && pjmedia_add_bandwidth_tias_in_sdp) {
+ const pj_str_t STR_BANDW_MODIFIER = { "TIAS", 4 };
+ pjmedia_sdp_bandw *b;
+
+ b = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_bandw);
+ b->modifier = STR_BANDW_MODIFIER;
+ b->value = max_bitrate;
+ m->bandw[m->bandw_count++] = b;
+ }
+
+ *p_m = m;
+ return PJ_SUCCESS;
+}
+
+
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+
+/* Create m=video SDP media line */
+PJ_DEF(pj_status_t) pjmedia_endpt_create_video_sdp(pjmedia_endpt *endpt,
+ pj_pool_t *pool,
+ const pjmedia_sock_info *si,
+ unsigned options,
+ pjmedia_sdp_media **p_m)
+{
+
+
+ const pj_str_t STR_VIDEO = { "video", 5 };
+ pjmedia_sdp_media *m;
+ pjmedia_vid_codec_info codec_info[PJMEDIA_VID_CODEC_MGR_MAX_CODECS];
+ unsigned codec_prio[PJMEDIA_VID_CODEC_MGR_MAX_CODECS];
+ pjmedia_sdp_attr *attr;
+ unsigned cnt, i;
+ unsigned max_bitrate = 0;
+ pj_status_t status;
+
+ PJ_UNUSED_ARG(options);
+
+ /* Make sure video codec manager is instantiated */
+ if (!pjmedia_vid_codec_mgr_instance())
+ pjmedia_vid_codec_mgr_create(endpt->pool, NULL);
+
+ /* Create and init basic SDP media */
+ m = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media);
+ status = init_sdp_media(m, pool, &STR_VIDEO, si);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ cnt = PJ_ARRAY_SIZE(codec_info);
+ status = pjmedia_vid_codec_mgr_enum_codecs(NULL, &cnt,
+ codec_info, codec_prio);
+
+ /* Check that there are not too many codecs */
+ PJ_ASSERT_RETURN(0 <= PJMEDIA_MAX_SDP_FMT,
+ PJ_ETOOMANY);
+
+ /* Add format, rtpmap, and fmtp (when applicable) for each codec */
+ for (i=0; i<cnt; ++i) {
+ pjmedia_sdp_rtpmap rtpmap;
+ pjmedia_vid_codec_param codec_param;
+ pj_str_t *fmt;
+ pjmedia_video_format_detail *vfd;
+
+ pj_bzero(&rtpmap, sizeof(rtpmap));
+
+ if (codec_prio[i] == PJMEDIA_CODEC_PRIO_DISABLED)
+ break;
+
+ if (i > PJMEDIA_MAX_SDP_FMT) {
+ /* Too many codecs, perhaps it is better to tell application by
+ * returning appropriate status code.
+ */
+ PJ_PERROR(3,(THIS_FILE, PJ_ETOOMANY,
+ "Skipping some video codecs"));
+ break;
+ }
+
+ /* Must support RTP packetization and bidirectional */
+ if ((codec_info[i].packings & PJMEDIA_VID_PACKING_PACKETS) == 0 ||
+ codec_info[i].dir != PJMEDIA_DIR_ENCODING_DECODING)
+ {
+ continue;
+ }
+
+ pjmedia_vid_codec_mgr_get_default_param(NULL, &codec_info[i],
+ &codec_param);
+
+ fmt = &m->desc.fmt[m->desc.fmt_count++];
+ fmt->ptr = (char*) pj_pool_alloc(pool, 8);
+ fmt->slen = pj_utoa(codec_info[i].pt, fmt->ptr);
+ rtpmap.pt = *fmt;
+
+ /* Encoding name */
+ rtpmap.enc_name = codec_info[i].encoding_name;
+
+ /* Clock rate */
+ rtpmap.clock_rate = codec_info[i].clock_rate;
+
+ if (codec_info[i].pt >= 96 || pjmedia_add_rtpmap_for_static_pt) {
+ pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr);
+ m->attr[m->attr_count++] = attr;
+ }
+
+ /* Add fmtp params */
+ if (codec_param.dec_fmtp.cnt > 0) {
+ enum { MAX_FMTP_STR_LEN = 160 };
+ char buf[MAX_FMTP_STR_LEN];
+ unsigned buf_len = 0, j;
+ pjmedia_codec_fmtp *dec_fmtp = &codec_param.dec_fmtp;
+
+ /* Print codec PT */
+ buf_len += pj_ansi_snprintf(buf,
+ MAX_FMTP_STR_LEN - buf_len,
+ "%d",
+ codec_info[i].pt);
+
+ for (j = 0; j < dec_fmtp->cnt; ++j) {
+ pj_size_t test_len = 2;
+
+ /* Check if buf still available */
+ test_len = dec_fmtp->param[j].val.slen +
+ dec_fmtp->param[j].name.slen;
+ if (test_len + buf_len >= MAX_FMTP_STR_LEN)
+ return PJ_ETOOBIG;
+
+ /* Print delimiter */
+ buf_len += pj_ansi_snprintf(&buf[buf_len],
+ MAX_FMTP_STR_LEN - buf_len,
+ (j == 0?" ":";"));
+
+ /* Print an fmtp param */
+ if (dec_fmtp->param[j].name.slen)
+ buf_len += pj_ansi_snprintf(
+ &buf[buf_len],
+ MAX_FMTP_STR_LEN - buf_len,
+ "%.*s=%.*s",
+ (int)dec_fmtp->param[j].name.slen,
+ dec_fmtp->param[j].name.ptr,
+ (int)dec_fmtp->param[j].val.slen,
+ dec_fmtp->param[j].val.ptr);
+ else
+ buf_len += pj_ansi_snprintf(&buf[buf_len],
+ MAX_FMTP_STR_LEN - buf_len,
+ "%.*s",
+ (int)dec_fmtp->param[j].val.slen,
+ dec_fmtp->param[j].val.ptr);
+ }
+
+ attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
+
+ attr->name = pj_str("fmtp");
+ attr->value = pj_strdup3(pool, buf);
+ m->attr[m->attr_count++] = attr;
+ }
+
+ /* Find maximum bitrate in this media */
+ vfd = pjmedia_format_get_video_format_detail(&codec_param.enc_fmt,
+ PJ_TRUE);
+ if (vfd && max_bitrate < vfd->max_bps)
+ max_bitrate = vfd->max_bps;
+ }
+
+ /* Put bandwidth info in media level using bandwidth modifier "TIAS"
+ * (RFC3890).
+ */
+ if (max_bitrate && pjmedia_add_bandwidth_tias_in_sdp) {
+ const pj_str_t STR_BANDW_MODIFIER = { "TIAS", 4 };
+ pjmedia_sdp_bandw *b;
+
+ b = PJ_POOL_ALLOC_T(pool, pjmedia_sdp_bandw);
+ b->modifier = STR_BANDW_MODIFIER;
+ b->value = max_bitrate;
+ m->bandw[m->bandw_count++] = b;
+ }
+
+ *p_m = m;
+ return PJ_SUCCESS;
+}
+
+#endif /* PJMEDIA_HAS_VIDEO */
+
+
+/**
+ * Create a "blank" SDP session description. The SDP will contain basic SDP
+ * fields such as origin, time, and name, but without any media lines.
+ */
+PJ_DEF(pj_status_t) pjmedia_endpt_create_base_sdp( pjmedia_endpt *endpt,
+ pj_pool_t *pool,
+ const pj_str_t *sess_name,
+ const pj_sockaddr *origin,
+ pjmedia_sdp_session **p_sdp)
+{
+ pj_time_val tv;
+ pjmedia_sdp_session *sdp;
+
+ /* Sanity check arguments */
+ PJ_ASSERT_RETURN(endpt && pool && p_sdp, PJ_EINVAL);
+
+ sdp = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_session);
+
+ pj_gettimeofday(&tv);
+ sdp->origin.user = pj_str("-");
+ sdp->origin.version = sdp->origin.id = tv.sec + 2208988800UL;
+ sdp->origin.net_type = STR_IN;
+
+ if (origin->addr.sa_family == pj_AF_INET()) {
+ sdp->origin.addr_type = STR_IP4;
+ pj_strdup2(pool, &sdp->origin.addr,
+ pj_inet_ntoa(origin->ipv4.sin_addr));
+ } else if (origin->addr.sa_family == pj_AF_INET6()) {
+ char tmp_addr[PJ_INET6_ADDRSTRLEN];
+
+ sdp->origin.addr_type = STR_IP6;
+ pj_strdup2(pool, &sdp->origin.addr,
+ pj_sockaddr_print(origin, tmp_addr, sizeof(tmp_addr), 0));
+
+ } else {
+ pj_assert(!"Invalid address family");
+ return PJ_EAFNOTSUP;
+ }
+
+ if (sess_name)
+ pj_strdup(pool, &sdp->name, sess_name);
+ else
+ sdp->name = STR_SDP_NAME;
+
+ /* SDP time and attributes. */
+ sdp->time.start = sdp->time.stop = 0;
+ sdp->attr_count = 0;
+
+ /* Done */
+ *p_sdp = sdp;
+
+ return PJ_SUCCESS;
+}
+
+/**
+ * Create a SDP session description that describes the endpoint
+ * capability.
+ */
+PJ_DEF(pj_status_t) pjmedia_endpt_create_sdp( pjmedia_endpt *endpt,
+ pj_pool_t *pool,
+ unsigned stream_cnt,
+ const pjmedia_sock_info sock_info[],
+ pjmedia_sdp_session **p_sdp )
+{
+ const pj_sockaddr *addr0;
+ pjmedia_sdp_session *sdp;
+ pjmedia_sdp_media *m;
+ pj_status_t status;
+
+ /* Sanity check arguments */
+ PJ_ASSERT_RETURN(endpt && pool && p_sdp && stream_cnt, PJ_EINVAL);
+ PJ_ASSERT_RETURN(stream_cnt < PJMEDIA_MAX_SDP_MEDIA, PJ_ETOOMANY);
+
+ addr0 = &sock_info[0].rtp_addr_name;
+
+ /* Create and initialize basic SDP session */
+ status = pjmedia_endpt_create_base_sdp(endpt, pool, NULL, addr0, &sdp);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* Audio is first, by convention */
+ status = pjmedia_endpt_create_audio_sdp(endpt, pool,
+ &sock_info[0], 0, &m);
+ if (status != PJ_SUCCESS)
+ return status;
+ sdp->media[sdp->media_count++] = m;
+
+#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+ {
+ unsigned i;
+
+ /* The remaining stream, if any, are videos (by convention as well) */
+ for (i=1; i<stream_cnt; ++i) {
+ status = pjmedia_endpt_create_video_sdp(endpt, pool,
+ &sock_info[i], 0, &m);
+ if (status != PJ_SUCCESS)
+ return status;
+ sdp->media[sdp->media_count++] = m;
+ }
+ }
+#endif
+
+ /* Done */
+ *p_sdp = sdp;
+
+ return PJ_SUCCESS;
+}
+
+
+
+#if PJ_LOG_MAX_LEVEL >= 3
+static const char *good_number(char *buf, pj_int32_t val)
+{
+ if (val < 1000) {
+ pj_ansi_sprintf(buf, "%d", val);
+ } else if (val < 1000000) {
+ pj_ansi_sprintf(buf, "%d.%dK",
+ val / 1000,
+ (val % 1000) / 100);
+ } else {
+ pj_ansi_sprintf(buf, "%d.%02dM",
+ val / 1000000,
+ (val % 1000000) / 10000);
+ }
+
+ return buf;
+}
+#endif
+
+PJ_DEF(pj_status_t) pjmedia_endpt_dump(pjmedia_endpt *endpt)
+{
+
+#if PJ_LOG_MAX_LEVEL >= 3
+ unsigned i, count;
+ pjmedia_codec_info codec_info[32];
+ unsigned prio[32];
+
+ PJ_LOG(3,(THIS_FILE, "Dumping PJMEDIA capabilities:"));
+
+ count = PJ_ARRAY_SIZE(codec_info);
+ if (pjmedia_codec_mgr_enum_codecs(&endpt->codec_mgr,
+ &count, codec_info, prio) != PJ_SUCCESS)
+ {
+ PJ_LOG(3,(THIS_FILE, " -error: failed to enum codecs"));
+ return PJ_SUCCESS;
+ }
+
+ PJ_LOG(3,(THIS_FILE, " Total number of installed codecs: %d", count));
+ for (i=0; i<count; ++i) {
+ const char *type;
+ pjmedia_codec_param param;
+ char bps[32];
+
+ switch (codec_info[i].type) {
+ case PJMEDIA_TYPE_AUDIO:
+ type = "Audio"; break;
+ case PJMEDIA_TYPE_VIDEO:
+ type = "Video"; break;
+ default:
+ type = "Unknown type"; break;
+ }
+
+ if (pjmedia_codec_mgr_get_default_param(&endpt->codec_mgr,
+ &codec_info[i],
+ ¶m) != PJ_SUCCESS)
+ {
+ pj_bzero(¶m, sizeof(pjmedia_codec_param));
+ }
+
+ PJ_LOG(3,(THIS_FILE,
+ " %s codec #%2d: pt=%d (%.*s @%dKHz/%d, %sbps, %dms%s%s%s%s%s)",
+ type, i, codec_info[i].pt,
+ (int)codec_info[i].encoding_name.slen,
+ codec_info[i].encoding_name.ptr,
+ codec_info[i].clock_rate/1000,
+ codec_info[i].channel_cnt,
+ good_number(bps, param.info.avg_bps),
+ param.info.frm_ptime * param.setting.frm_per_pkt,
+ (param.setting.vad ? " vad" : ""),
+ (param.setting.cng ? " cng" : ""),
+ (param.setting.plc ? " plc" : ""),
+ (param.setting.penh ? " penh" : ""),
+ (prio[i]==PJMEDIA_CODEC_PRIO_DISABLED?" disabled":"")));
+ }
+#endif
+
+ return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pjmedia_endpt_atexit( pjmedia_endpt *endpt,
+ pjmedia_endpt_exit_callback func)
+{
+ exit_cb *new_cb;
+
+ PJ_ASSERT_RETURN(endpt && func, PJ_EINVAL);
+
+ if (endpt->quit_flag)
+ return PJ_EINVALIDOP;
+
+ new_cb = PJ_POOL_ZALLOC_T(endpt->pool, exit_cb);
+ new_cb->func = func;
+
+ pj_enter_critical_section();
+ pj_list_push_back(&endpt->exit_cb_list, new_cb);
+ pj_leave_critical_section();
+
+ return PJ_SUCCESS;
+}
diff --git a/jni/pjproject-android/.svn/pristine/0a/0af5f9344032588ac4ac09679d48bafeccc68d6c.svn-base b/jni/pjproject-android/.svn/pristine/0a/0af5f9344032588ac4ac09679d48bafeccc68d6c.svn-base
new file mode 100644
index 0000000..934a22a
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/0a/0af5f9344032588ac4ac09679d48bafeccc68d6c.svn-base
@@ -0,0 +1,326 @@
+/* $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
+ */
+
+/*
+ * - Many thanks for Zetron, Inc. and Phil Torre <ptorre@zetron.com> for
+ * donating this file and the RTEMS port in general!
+ */
+
+#include "test.h"
+
+#include <pj/errno.h>
+#include <pj/string.h>
+#include <pj/sock.h>
+#include <pj/log.h>
+
+extern int param_echo_sock_type;
+extern const char *param_echo_server;
+extern int param_echo_port;
+
+#include <bsp.h>
+
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 300
+#define CONFIGURE_MAXIMUM_TASKS 50
+#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES rtems_resource_unlimited(10)
+#define CONFIGURE_MAXIMUM_SEMAPHORES rtems_resource_unlimited(10)
+#define CONFIGURE_MAXIMUM_TIMERS 50
+#define CONFIGURE_MAXIMUM_REGIONS 3
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
+#define CONFIGURE_TICKS_PER_TIMESLICE 2
+//#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+#define CONFIGURE_POSIX_INIT_THREAD_TABLE
+
+
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES rtems_resource_unlimited(16)
+#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES rtems_resource_unlimited(5)
+#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES rtems_resource_unlimited(16)
+#define CONFIGURE_MAXIMUM_POSIX_TIMERS rtems_resource_unlimited(5)
+#define CONFIGURE_MAXIMUM_POSIX_THREADS rtems_resource_unlimited(16)
+#define CONFIGURE_MAXIMUM_POSIX_KEYS rtems_resource_unlimited(16)
+
+#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE 4096
+
+/* Make sure that stack size is at least 4096 */
+#define SZ (4096-RTEMS_MINIMUM_STACK_SIZE)
+#define CONFIGURE_EXTRA_TASK_STACKS ((SZ)<0 ? 0 : (SZ))
+
+#define CONFIGURE_INIT
+#define STACK_CHECKER_ON
+
+rtems_task Init(rtems_task_argument Argument) ;
+void *POSIX_Init(void *argument);
+
+#include <confdefs.h>
+#include <rtems.h>
+
+/* Any tests that want to build a linked executable for RTEMS must include
+ these headers to get a default config for the network stack. */
+#include <rtems/rtems_bsdnet.h>
+#include "rtems_network_config.h"
+
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define THIS_FILE "main_rtems.c"
+
+static void* pjlib_test_main(void* unused);
+static void initialize_network();
+static void test_sock(void);
+
+static void my_perror(pj_status_t status, const char *title)
+{
+ char err[PJ_ERR_MSG_SIZE];
+
+ pj_strerror(status, err, sizeof(err));
+ printf("%s: %s [%d]\n", title, err, status);
+}
+
+#define TEST(expr) { int rc;\
+ /*PJ_LOG(3,(THIS_FILE,"%s", #expr));*/ \
+ /*sleep(1);*/ \
+ rc=expr; \
+ if (rc) my_perror(PJ_STATUS_FROM_OS(rc),#expr); }
+
+
+
+//rtems_task Init(rtems_task_argument Argument)
+void *POSIX_Init(void *argument)
+{
+ pthread_attr_t threadAttr;
+ pthread_t theThread;
+ struct sched_param sched_param;
+ size_t stack_size;
+ int result;
+ char data[1000];
+
+
+ memset(data, 1, sizeof(data));
+
+ /* Set the TOD clock, so that gettimeofday() will work */
+ rtems_time_of_day fakeTime = { 2006, 3, 15, 17, 30, 0, 0 };
+
+ if (RTEMS_SUCCESSFUL != rtems_clock_set(&fakeTime))
+ {
+ assert(0);
+ }
+
+ /* Bring up the network stack so we can run the socket tests. */
+ initialize_network();
+
+ /* Start a POSIX thread for pjlib_test_main(), since that's what it
+ * thinks it is running in.
+ */
+
+ /* Initialize attribute */
+ TEST( pthread_attr_init(&threadAttr) );
+
+ /* Looks like the rest of the attributes must be fully initialized too,
+ * or otherwise pthread_create will return EINVAL.
+ */
+
+ /* Specify explicit scheduling request */
+ TEST( pthread_attr_setinheritsched(&threadAttr, PTHREAD_EXPLICIT_SCHED));
+
+ /* Timeslicing is needed by thread test, and this is accomplished by
+ * SCHED_RR.
+ */
+ TEST( pthread_attr_setschedpolicy(&threadAttr, SCHED_RR));
+
+ /* Set priority */
+ TEST( pthread_attr_getschedparam(&threadAttr, &sched_param));
+ sched_param.sched_priority = NETWORK_STACK_PRIORITY - 10;
+ TEST( pthread_attr_setschedparam(&threadAttr, &sched_param));
+
+ /* Must have sufficient stack size (large size is needed by
+ * logger, because default settings for logger is to use message buffer
+ * from the stack).
+ */
+ TEST( pthread_attr_getstacksize(&threadAttr, &stack_size));
+ if (stack_size < 8192)
+ TEST( pthread_attr_setstacksize(&threadAttr, 8192));
+
+
+ /* Create the thread for application */
+ result = pthread_create(&theThread, &threadAttr, &pjlib_test_main, NULL);
+ if (result != 0) {
+ my_perror(PJ_STATUS_FROM_OS(result),
+ "Error creating pjlib_test_main thread");
+ assert(!"Error creating main thread");
+ }
+
+ return NULL;
+}
+
+
+
+#define boost()
+#define init_signals()
+
+static void*
+pjlib_test_main(void* unused)
+{
+ int rc;
+
+ /* Drop our priority to below that of the network stack, otherwise
+ * select() tests will fail. */
+ struct sched_param schedParam;
+ int schedPolicy;
+
+ printf("pjlib_test_main thread started..\n");
+
+ TEST( pthread_getschedparam(pthread_self(), &schedPolicy, &schedParam) );
+
+ schedParam.sched_priority = NETWORK_STACK_PRIORITY - 10;
+
+ TEST( pthread_setschedparam(pthread_self(), schedPolicy, &schedParam) );
+
+ boost();
+ init_signals();
+
+ //my_test_thread("from pjlib_test_main");
+ //test_sock();
+
+ rc = test_main();
+
+ return (void*)rc;
+}
+
+# include <sys/types.h>
+# include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+# include <unistd.h>
+
+/*
+ * Send UDP packet to some host. We can then use Ethereal to sniff the packet
+ * to see if this target really transmits UDP packet.
+ */
+static void
+send_udp(const char *target)
+{
+ int sock, rc;
+ struct sockaddr_in addr;
+
+ PJ_LOG(3,("main_rtems.c", "IP addr=%s/%s, gw=%s",
+ DEFAULT_IP_ADDRESS_STRING,
+ DEFAULT_NETMASK_STRING,
+ DEFAULT_GATEWAY_STRING));
+
+ sock = socket(AF_INET, SOCK_DGRAM, 0);
+ assert(sock > 0);
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+
+ rc = bind(sock, (struct sockaddr*)&addr, sizeof(addr));
+ assert("bind error" && rc==0);
+
+ addr.sin_addr.s_addr = inet_addr(target);
+ addr.sin_port = htons(4444);
+
+ while(1) {
+ const char *data = "hello";
+
+ rc = sendto(sock, data, 5, 0, (struct sockaddr*)&addr, sizeof(addr));
+ PJ_LOG(3,("main_rtems.c", "pinging %s..(rc=%d)", target, rc));
+ sleep(1);
+ }
+}
+
+
+static void test_sock(void)
+{
+ int sock;
+ struct sockaddr_in addr;
+ int rc;
+
+ sock = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sock < 0) {
+ printf("socket() error\n");
+ goto end;
+ }
+
+ memset(&addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+ addr.sin_port = htons(5000);
+
+ rc = bind(sock, (struct sockaddr*)&addr, sizeof(addr));
+ if (rc != 0) {
+ printf("bind() error %d\n", rc);
+ close(sock);
+ goto end;
+ }
+
+ puts("Bind socket success");
+
+ close(sock);
+
+end:
+ while(1) sleep(1);
+}
+
+/*
+ * Initialize the network stack and Ethernet driver, using the configuration
+ * in rtems-network-config.h
+ */
+static void
+initialize_network()
+{
+ unsigned32 fd, result;
+ char ip_address_string[] = DEFAULT_IP_ADDRESS_STRING;
+ char netmask_string[] = DEFAULT_NETMASK_STRING;
+ char gateway_string[] = DEFAULT_GATEWAY_STRING;
+
+ // Write the network config files to /etc/hosts and /etc/host.conf
+ result = mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO);
+ fd = open("/etc/host.conf", O_RDWR | O_CREAT, 0744);
+ result = write(fd, "hosts,bind\n", 11);
+ result = close(fd);
+ fd = open("/etc/hosts", O_RDWR | O_CREAT, 0744);
+ result = write(fd, "127.0.0.1 localhost\n", 41);
+ result = write(fd, ip_address_string, strlen(ip_address_string));
+ result = write(fd, " pjsip-test\n", 32);
+ result = close(fd);
+
+ netdriver_config.ip_address = ip_address_string;
+ netdriver_config.ip_netmask = netmask_string;
+ rtems_bsdnet_config.gateway = gateway_string;
+
+ if (0 != rtems_bsdnet_initialize_network())
+ PJ_LOG(3,(THIS_FILE, "Error: Unable to initialize network stack!"));
+ else
+ PJ_LOG(3,(THIS_FILE, "IP addr=%s/%s, gw=%s",
+ ip_address_string,
+ netmask_string,
+ gateway_string));
+
+ //rtems_rdbg_initialize();
+ //enterRdbg();
+ //send_udp("192.168.0.1");
+ //test_sock();
+}
+
+