* #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/66/66023abfa0bd80659165bc0c56fc444c12475fef.svn-base b/jni/pjproject-android/.svn/pristine/66/66023abfa0bd80659165bc0c56fc444c12475fef.svn-base
new file mode 100644
index 0000000..68c24fd
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/66023abfa0bd80659165bc0c56fc444c12475fef.svn-base
@@ -0,0 +1 @@
+#include "../../../portaudio/src/os/unix/pa_unix_util.c"
diff --git a/jni/pjproject-android/.svn/pristine/66/6640fb60f0cd6c088c0de65d0daa3851f810e936.svn-base b/jni/pjproject-android/.svn/pristine/66/6640fb60f0cd6c088c0de65d0daa3851f810e936.svn-base
new file mode 100644
index 0000000..9c586cc
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/6640fb60f0cd6c088c0de65d0daa3851f810e936.svn-base
@@ -0,0 +1,2552 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#include "test.h"
+#include <pjmedia-codec.h>
+
+/* Define your CPU MIPS here!! */
+
+#ifndef CPU_IPS
+    /*
+    For complete table see:
+    http://en.wikipedia.org/wiki/Million_instructions_per_second
+
+    Processor			    IPS/MHz
+    -------------------------------------------
+    PowerPC G3			    2.253 MIPS/MHz
+    Intel Pentium III		    2.708 MIPS/MHz
+    AMD Athlon			    2.967 MIPS/MHz
+    Pentium 4 Extreme Edition	    3.039 MIPS/MHz
+    AMD Athlon FX-57		    4.285 MIPS/MHz
+
+
+    From: http://en.wikipedia.org/wiki/ARM_architecture
+
+    Family	Arch		Core	    IPS/MHz
+    -------------------------------------------------------
+    ARM7TDMI	ARMv4T		ARM7TDMI    0.892 MIPS/MHz
+				ARM710T	    0.900 MIPS/MHz
+				ARM720T	    1.003 MIPS/MHz
+    ARM9TDMI	ARMv4T		ARM920T	    1.111 MIPS/MHz
+    ARM9E	ARMv5TEJ	ARM926EJ-S  1.100 MIPS/MHz
+    XScale	ARMv5TE		PXA255	    1.000 MIPS/MHz (?)
+				PXA27x	    1.282 MIPS/MHz
+    Cortex	ARMv7-A		Cortex-A8   2.000 MIPS/MHz
+				Cortex-A9   2.000 MIPS/MHz
+		ARMv7-M		Cortex-M3   1.250 MIPS/MHz
+    */
+
+#   define CPU_MHZ	    (2666)
+#   define CPU_IPS	    (3.039 * CPU_MHZ * MEGA)	/* P4 2.6GHz	*/
+
+//#   define CPU_MHZ	    700
+//#   define CPU_IPS	    (700 * MEGA * 2.708)	/* P3 700Mhz	*/
+
+//#   define CPU_MHZ	    180
+//#   define CPU_IPS	    (CPU_MHZ * MEGA * 1.1)	/* ARM926EJ-S */
+
+//#   define CPU_MHZ	    312
+//#   define CPU_IPS	    (CPU_MHZ * MEGA * 1.282)	/* Dell Axim PDA */
+
+#endif
+
+
+
+/* Sample speech data, 360ms length, encoded at 8Khz */
+static const pj_int16_t ref_signal[] = {
+         0,    -4,     0,     0,     1,     8,     8,     7,    12,    16,
+        20,    29,    28,    48,    40,    48,    56,    76,    68,    76,
+        96,   100,   104,   124,   117,   120,   144,   120,   136,   168,
+       184,   188,   176,   216,   237,   235,   268,   301,   312,   316,
+       367,   356,   384,   400,   344,   409,   392,   416,   380,   432,
+       404,   444,   457,   456,   453,   512,   499,   512,   584,   584,
+       544,   584,   608,   596,   552,   628,   600,   667,   728,   672,
+       681,   755,   736,   764,   752,   764,   724,   769,   792,   840,
+       820,   895,   841,   856,   852,   867,   944,   944,   939,   944,
+       907,   928,   920,   960,   833,   881,  1004,  1007,  1000,  1057,
+      1032,  1056,  1016,  1056,  1072,  1080,  1108,  1028,  1076,  1072,
+       956,  1020,  1080,  1008,  1095,   992,  1056,  1028,   940,   976,
+      1008,   940,   916,   968,   849,   868,   956,   940,   852,   892,
+       968,   860,   777,   904,   825,   716,   764,   708,   635,   728,
+       620,   648,   472,   724,   548,   448,   472,   372,   272,   437,
+       419,   260,   237,   371,   196,   136,   177,   264,    49,   120,
+        40,   124,    32,   136,    71,   120,   -95,   -20,   -76,  -140,
+      -304,    12,  -148,  -168,  -192,   -63,  -212,   -36,  -288,  -232,
+      -352,  -128,  -397,  -308,  -431,  -280,  -675,  -497,  -761,  -336,
+      -760,  -471, -1088,  3013, -1596, -2000,   412,  -968,   213,  -668,
+     -1096, -1048, -1039,  -825,  -580,  -612, -1056,  -888, -1324, -1064,
+     -1164,  -819,  -940,  -780, -1236,  -688, -1931,    -1,  -464, -1804,
+      1088, -1605, -1208,  -664,  -912,  -905,  -832, -1167,  -512,  1832,
+      -924,   -60,   660, -2143,   248, -1660,  1496, -3464,  -164,  2072,
+     -3040,   539,  2904,  2040, -3488,  2600,  2412,   820,  -551, -1401,
+      1068,  -385,   397, -2112,  -980,  1064, -1244,  -736, -1335,   332,
+     -1232, -1852,   -12, -1073, -1747, -3328,  -796, -2241, -4901, -3248,
+     -3124, -3432, -5892, -3840, -3968, -4752, -5668, -4796, -3580, -5909,
+     -5412, -6144, -5800, -5908, -6696, -6460, -8609, -3804, -5668, -8499,
+     -4636, -5744, -2377, -7132, -3712, -7221, -6608,  1656,-11728, -6656,
+     -3736,  -204, -8580, -4808,  -591, -5752,  -472,-10308, -2116,  -257,
+     -4720, -7640, -1279,  6412,-16404, -1495,  6204, -8072,  -335, -3877,
+     -2363,   464,   441, -6872,  1447,  7884,-13197,   936,  5009, -4416,
+     -4445,  3956,  2280, -2844,  2036, -4285,   744,  4161, -7216,  5548,
+       172,  -964, -2873,  3296,  2184, -7424,  4300,  1855,  1453,   -32,
+      1585,  2160, -3440,   448,  4084, -1617,  1928,  3944, -3728,  4699,
+      4556, -5556,  4096, 12928, -8287, -4320, 10739,  3172, -6068,  3684,
+      6484,  1652, -1104, -1820, 11964, -1567, -4117,  7197,  5112, -2608,
+     -2363,  7379,   936,  1596,   217,  6508,  3284,  3960,     0,  2691,
+     11324, -6140,  6720,  6188,  3596, -1120,  5319,  9420, -9360,  5780,
+      5135,   623, -1844,  3473,  8488, -4532,  2844,  8368,  4387, -8628,
+     14180,  3196, -4852,  9092,  5540,  -600,  3088,  9864, -4992, 13984,
+      2536, -5932, 10584,  7044, -2548,   388, 12597, -4776,  -247,  7728,
+      6048, -6152,  6449,  9644, -8924,  8993,  6319,   877,  1108,  9804,
+      -696,  2584,  9097, -3236,  4308,  5444, -2660,  -365, 11427, -6900,
+      -803,  9388, -2444, -1068,  9160,   703, -5632, 12088, -2964, -1077,
+      9804, -1263, -3679, 10161,  3337, -9755, 11601,  -160, -6421, 11008,
+     -1952, -3411,  6792, -1665, -1344,  9116, -2545, -4100, 11577,   240,
+     -3612,  5140,   603, -2100,  4284,  -784,   108,   968, -1244,  3500,
+      3696,  -108,  3780,  3836,   -16,  4035,  2772,  1300,  -688,  1544,
+      2268, -2144,  1156,  -564,   628, -1040,  -168,   491,   -72,  -408,
+     -1812,  3460, -2083,   -72,   797,  1436, -3824,  1200,   308, -3512,
+       572, -4060,   540,   -84, -4492, -1808,  4644, -4340, -3224,  5832,
+     -2180, -2544,  1475,  2224, -2588,  1312,  1452, -1676,  -428, -1596,
+      -860,  -116, -4000,  -364,   148, -3680, -2229, -1632,   236, -3004,
+     -1917,   124, -1748, -2991,  -644,  -752, -3691, -1945, -3236, -2005,
+     -4388, -2084, -2052, -3788, -3100,  -824, -2432, -3419, -1905, -2520,
+     -2120, -2904, -2200, -1712, -2500, -2796, -1140, -2460, -2955,  -984,
+     -1519,  -400,  -412,   356,    97,  -389,  1708,  -115,   452,  1140,
+      -820,  1912,  1421, -1604,   556,  -632, -1991, -1409, -1904, -3604,
+     -3292, -3405, -5584, -4891, -5436, -8940, -6280, -6604,-11764, -6389,
+     -9081,-10928, -7784, -8492,-11263, -8292, -8829, -9632, -7828, -8920,
+    -10224, -8912, -9836, -7313, -2916,-10240, -3748,  2860, -3308, -1236,
+      6816,  4580,  1585,  9808,  7484,  5612,  6868,  7399,  6244,  5064,
+      3823,  5159,  4940,   316,  4496,  4864,  1020,  3997,  6236,  3316,
+      5712,  7032,  5568,  7329,  6135,  6904,  6431,  3768,  2580,  3724,
+       504, -2213,  -661, -3320, -6660, -6696, -7971,-11208,-11316,-11784,
+    -14212,-13651,-16312,-15876,-15984,-20283,-15168,  2073,-23888, -5839,
+     13360, -8568,  1240, 18480, 11440,  4236, 23916, 15388, 14072, 15960,
+     15064, 14840,  9395,  6981,  8584,  6540, -5453,  3568,   928, -7741,
+     -5260,   -12, -5692, -7608,  1408,  2136,   776,  1775, 13568, 10992,
+      8445, 17527, 21084, 14851, 15820, 23060, 15988, 11560, 15088, 14164,
+      3376,  4059,  5212, -2520, -5891, -3596, -5080,-11752, -8861, -8124,
+    -12104,-12076,-10028,-12333,-14180,-12516,-16036,-15559,-20416, -4240,
+     -1077,-31052, 14840,  7405,-12660, 11896, 23572,  2829, 10932, 28444,
+     10268, 15412, 13896, 16976, 10161,  6172,  5336,  9639, -2208, -7160,
+      6544, -7188,-11280, -3308, -2428,-13447, -4880,  -824, -6664, -1436,
+      4608,  7473,  2688, 14275, 14921, 13564, 15960, 20393, 16976, 14832,
+     17540, 13524, 10744,  6876,  7328,  1772, -2340, -3528, -4516, -9576,
+    -10872, -8640,-13092,-12825,-14076,-12192,-16620,-16207,-17004,-17548,
+    -22088,-21700,-20320,  2836,-29576,-15860, 25811,-22555, -1868, 23624,
+      9872, -4044, 29472, 16037,  7433, 16640, 14577, 13119,  3120,  7072,
+      5828,  2285,-12087,  3180, -4031,-17840, -6349, -5300,-15452,-13852,
+     -2659,-12079, -8568, -4492,  -672,   660,  5424,  3040, 16488, 11408,
+      8996, 24976, 15120,  9940, 21400, 16885,  2624, 13939,  8644, -2815,
+       332,  -160, -9312,-10172, -8320,-14033,-13056,-16200,-14113,-15712,
+    -18153,-18664,-15937,-21692,-23500,-18597,-25948, -8597,-10368,-32768,
+     16916, -4469,-17121, 18448, 14791, -4252, 18880, 22312,  4347, 17672,
+     12672, 12964,  7384,  5404,  5176,  5668, -7692, -2356,  1148,-14872,
+     -8920, -5593,-12753,-14600, -6429,-10608,-10372, -6757, -4857, -2044,
+     -2720,  8995,  5088,  6516, 18384, 12853, 14952, 18048, 17439, 13920,
+     15512, 10960, 10268,  5136,  2888,  1184, -4271, -7104, -7376, -9688,
+    -14691,-11336,-14073,-17056,-14268,-16776,-17957,-19460,-18068,-23056,
+    -20512,-24004, -3396,-19239,-27272, 22283,-16439, -7300, 19484,  9020,
+     -1088, 22895, 15868,  9640, 17344, 11443, 17912,  6084,  6712,  9988,
+      6104, -8559,  6403, -1196,-13152, -3632, -5388,-11924,-11973, -5748,
+    -10292, -8420, -8468, -2256, -2829, -4132,  6344,  8785,  7444,  9508,
+     22152, 15108, 13151, 22536, 20725, 10672, 17028, 17052,  5536,  6192,
+      7484,   403, -5520, -2132, -5532,-11527,-10644, -9572,-13316,-16124,
+    -10883,-15965,-17335,-17316,-16064,-20436,-21660, -8547, -3732,-32768,
+     14672,  2213,-17200, 17964, 14387,  4232, 14800, 24296, 11288, 21368,
+     11144, 22992, 13599,  6973, 14444, 12312, -2340,  4436,  8060, -9008,
+     -2188, -2164, -5756,-10268, -5076, -6292, -6472, -7916, -2336,   327,
+     -4492,  7144,  7696,  5691, 16352, 14244, 17764, 19852, 17296, 23160,
+     18496, 14197, 19564, 13356,  5779, 10559,  4576, -2736,  -528, -3211,
+     -8796, -8428, -9153,-10928,-13296,-12101,-12528,-14985,-16036,-14600,
+    -15888,-18792,-19604, -3176, -8887,-29240, 21405, -6999, -9568, 19052,
+     11952,  3037, 20055, 18376, 14501, 18672, 11023, 24776,  9488,  7921,
+     15896, 11068, -4484,  9667,  4328, -7544, -1240, -1456, -7204, -9192,
+     -5084, -5816, -6864, -9444,   276, -2316, -2852,  4640,  9600,  4412,
+     13300, 16856, 12836, 18892, 17632, 18336, 16031, 14808, 13860, 12052,
+      4284,  7372,  2623, -4284, -2172, -5036,-10163, -9788,-10384,-13205,
+    -13180,-13453,-14460,-15540,-16580,-15472,-17961,-19148,-18824, -8063,
+     -8620,-28300, 14323, -6748,-10204, 13100, 10548,   956, 16056, 14640,
+     12680, 14171,  9672, 19741,  7524,  6615, 11825,  8788, -5080,  7224,
+      1112, -6024, -4176, -1912, -7968, -8576, -7184, -5640, -8200, -9388,
+     -1980, -2064, -4040,   240,  9327,  2192,  8451, 13604, 13124, 10057,
+     16505, 15099, 11008, 10344, 12405,  7244,  1948,  4420,   132, -5312,
+     -6072, -5772,-11608,-11756,-11660,-12684,-14335,-14548,-12400,-15268,
+    -15277,-14949,-14889,-17376,-16640,-15656, -1128,-23476, -6084,  7268,
+    -13880,   400, 10984,  1468,  4388, 14156,  6600, 13684,  5428, 12240,
+     11815,  5460,  3663, 13164, -1269,   772,  3884,  -788, -5536, -1652,
+     -4857, -4596, -7912, -6152, -4132, -7201, -6288, -1196, -1332, -4236,
+      5020,  5020,  1648,  8572, 10224,  6256,  9816,  9404,  8124,  6644,
+      4380,  4707,   636, -3300, -3208, -4395, -9716, -7540, -8175, -9980,
+    -10237, -7680,-12172, -9981,-10459, -9712, -8451,-13008,-10196, -9308,
+    -13109,-11700,-11636, -6143, -9472,-12117,   985, -3627, -6120,  2828,
+      5268,    33,  6984,  6488,  7803,  6265,  6992,  8032,  7892,  3408,
+      6021,  6224,  1016,  2053,  2632,  -648, -1936, -1796, -2504, -2865,
+     -4400, -2524, -2388, -2524, -1432,   283,   696,  1180,  2912,  3996,
+      3328,  3948,  5101,  4905,  3396,  3500,  3323,  2472,  -152,  1580,
+      -860, -2109, -1331, -2460, -2960, -3396, -3476, -2616, -5172, -3352,
+     -4036, -4440, -5480, -4028, -4220, -5876, -4656, -5233, -4621, -5465,
+     -6417, -4936, -5092, -1860, -5651, -2699,  1273,  -920,  -888,  4279,
+      3260,  2952,  5861,  5584,  5980,  6428,  5732,  6516,  6825,  4156,
+      5000,  5071,  2669,  1764,  3273,  1148,  1312,   880,  1788,  1457,
+      1299,   648,  3172,  2004,  1060,  3544,  1963,  2516,  3192,  3057,
+      2936,  2892,  2896,  2224,  3188,  1524,  1541,  3120,   624,   917,
+      1472,  1128,  -317,   687,   400, -1131,   164,  -812, -1232, -1120,
+     -1311, -1364, -1500, -1660, -2380, -1835, -2456, -2468, -2168, -2785,
+     -2824, -2408, -3316,  -552, -1204, -3153,  1188,  1572,  -752,  1756,
+      4108,  2344,  3595,  4504,  4152,  4556,  4224,  3568,  4801,  3165,
+      2776,  2808,  3233,  1300,  2411,  1536,  1828,  1424,  1576,  1412,
+      1880,   895,  1601,  1916,  1763,   944,  2599,  1349,  1873,  1988,
+      1744,  1956,  1667,  1548,  1812,  1048,  1528,   488,  1428,   832,
+       232,   207,   632,  -152,  -520,    20,    15, -1580,  -841,  -948,
+     -1120, -1455, -2004, -1244, -1344, -2236, -1312, -1344, -2156, -1420,
+     -1856, -1637, -1847, -1460, -1780, -1372,  -508, -1256,  -752,     0,
+       600,   859,  1156,  1532,  2364,  2204,  2059,  2269,  2240,  1928,
+      1889,  2055,  1205,  1068,  1268,   892,  1371,  1036,   413,  1552,
+       572,   -84,  1364,   260,   624,   820,  -160,  1492,   188,   204,
+       796,   468,   552,   945,  -504,   697,  -936,   284, -1116,  -204,
+     -1052,  -700, -1637,  -673, -2744,   -25, -2163, -1728, -1704, -1260,
+     -2228, -2512,  -496, -3992,  -824, -2699, -2172, -2196, -1684, -3376,
+      -540, -3047, -2220,  -376, -3416,     8, -2424,  -428, -1111,  -927,
+        68, -1152,   640, -1308,   276,   536,   592,  -292,  2256,  -368,
+       680,  2532,  -536,  1548,   780,   -92,  1596,    56,   444,   348,
+       356,   500, -2168,  1527, -1632,  -677,  -980,  -904,  -868,   480,
+     -1476,  -804, -1515,  -335, -2472, -1533, -1007,  -644, -2308, -1592,
+      -104, -3860,  -984, -2364,     0, -1372, -2500, -2548,  1280, -3767,
+     -2228,  -440, -2168, -2691,   628, -2013, -3773, -4292,  3796, -6452,
+     -1268,  -156, -1320, -3779,  2612, -2924,  -864,  -619,  1227, -3408,
+      3016,  -200, -1432,  2219,   -45, -1356,  5744, -2069,  4396,   488,
+      3048,  -801,  3876,   857,  2064,    80,  4240,  -700,  1928,  1568,
+     -1992,  3431,   600,  2221,   657, -3116,  5888, -2668,  4871, -7963,
+      8016, -4907,  1264, -1969,  3688, -4396, -1276,  2448, -3760,  2156,
+     -3039, -3064,   940,  2384, -7907,  4520, -2876,  2384, -5784,  4484,
+     -5487,  1907, -4064,  1991, -3496,  1304, -4521,  5255, -4189,  1136,
+     -2397,  -152,   768, -1671,  2084, -2709,  6413, -1460,  1952,   448,
+      7064,  -444,  6256,   600,  8872,  2115,  4672,  7628,  6264,  2993,
+      8920,  2876,  7744,  3956,  4848,  7236,   804,  7684,  5201,  2216,
+      6360,  4900,  -340,  6885,  1307,  2468,  1884,  4812, -1376,  4740,
+      1751,   135,  1124,  3284, -3228,  3968,  1748, -4453,  1587, -1515,
+      3084, -3300, -2548,  -544,  -296,   396, -7808,  4956, -5164,  -292,
+     -4947,   212, -4055,  -108, -4301, -2088, -2912,  3016,   952, -1888,
+      4972,  4441,  6136,  1464,  9387,  4137,  6812,  6281,  2440,  6940,
+      3928,  2704, -1204,  4260, -2289,  -712, -1768,  -383, -1195,   920,
+     -1200,  -336,  4372,   720,  4392,  1291,  5819,  4528,  7532,   992,
+      8176,  5588,  2760,  2836,  3412,  1132,   531,  2236, -5044,   621,
+     -2916, -3964, -5849,  -864, -6300,-10019, -3964, -5524, -7004, -6833,
+     -7236, -9484, -2528,-10112,-12900, -4199, -8580,-12427,-10924, -8604,
+    -11520, -9636, -6560, -1647, -6948,  -460,  1752,  2952,  4196,  4360,
+      4215,  8156,  4528,  2464,  2500,  3299, -2224, -3812, -2568, -5875,
+     -5556, -7728, -8288, -5765, -6448, -7620, -5288, -2680, -4368,  -972,
+       472,  1716,  2467,  4408,  5141,  4724,  7316,  4132,  3493,  5935,
+      3564,    96,  1068,   868, -2160, -2736, -3449, -5428, -3339, -5200,
+     -7156, -4189, -7928, -8064, -7532, -7999,-12124, -8509, -9888,-12420,
+    -13568,-13187,-15384,-14996,-15152,-15284,-17059,-15292,-11792, -1160,
+     -7300, -8284,  7237,  7241,  1616,  6327, 12064,  7920,  9564,  3556,
+      4612,  6980,   261, -6365, -2028, -1701,-10136, -9573, -6901, -7747,
+     -7868, -8076, -6123, -1508,  -100, -3048,  2004,  6704,  4507,  3256,
+      9432,  8672,  7673,  6804,  7632,  8777,  6908,  3332,  3771,  6552,
+      3153,   400,  3029,  4388,  1328,   160,  2304,  2023,  1325, -2640,
+     -2356, -1544, -3436, -8584, -6939, -7180,-10455,-12928,-12296,-14653,
+    -15243,-16436,-15240,-16672,-15476,-14628,  7004, -1360,-10100, 16344,
+     18300,  9108, 12869, 22541, 16119, 17856, 10697,  6720, 12128,  6904,
+     -8184, -3440,  2592,-10440,-11735, -4739, -4455, -5457, -2432, -1476,
+      4520, 10045,  5512,  7988, 17032, 15052,  9211, 13309, 14624, 10324,
+     10488,  7809,  6908,  9896,  5861,  3284,  8348, 10505,  5189,  8144,
+     13280, 11732, 10035, 12559, 12104, 12456, 10148,  6520,  5944,  5603,
+     -1848, -4196, -2544, -5876,-11416,-10032,-10248,-12753,-13344,-14900,
+    -14320,-11265,-14220,-17067, -1440, 20120, -9884,  2783, 32220, 22208,
+      9032, 22661, 26820, 19916, 17747,  5288,  8628, 14293, -3331,-15672,
+      1252,  -324,-18236,-11592, -1172, -3384, -3864,  1052,  3640, 13099,
+     13691,  6520, 14320, 22856, 12887,  7152, 14764, 13276,  4060,  2568,
+      2268,  2224,  3312, -3336,  -875,  9000,  6180,  1872, 10851, 17464,
+     12312, 11197, 15388, 17816, 12024,  8332,  7119,  8096,  1608, -5611,
+     -5964, -4729,-11317,-14784,-12833,-11272,-14888,-16128,-15012,-12028,
+    -14472,-16227,-15356,-14484,-15056, 11496,   352,-14108, 19216, 24616,
+      3724,  7872, 25948, 13832,  9680,  7492,  2052,  5220,  1188,-16112,
+    -11340,   703,-15400,-21572, -5816, -3320,-12072, -5664,  2296,  3101,
+      6708,  5396,  5735, 13601, 12040,  1924,  6071, 10420,   984, -4904,
+      -204, -1945, -6229, -7460, -5636,  2864,  -476, -2832,  6104, 13160,
+      7151,  7148, 13063, 13596,  8796,  5092,  5976,  5668,  -431, -7624,
+     -6741, -5676,-14332,-18700,-13396,-12387,-18576,-17516,-14184,-14124,
+    -15972,-17456,-16323,-14712,-18056,-23213,-10744, 12016,-14824,-12636,
+     21656, 14112, -4085,  9255, 20864,  8196,  6384,  1223,  2244,  5304,
+     -6660,-19192, -4961, -2875,-22564,-18400, -3220, -8488,-14544, -5040,
+      -324,   820,  2732,   628,  5484, 11924,  4813,  -852,  8656,  7160,
+     -3924, -2955,  1337, -3268, -7359, -2552, -2528,  -532,   128,   411,
+      5324,  9301,  5601,  6200, 11684, 10072,  4924,  5508,  6660,  1568,
+     -2332, -4268, -5628, -7987,-12004,-13760,-11567,-12104,-16539,-14437,
+    -12012,-14309,-16736,-14573,-13604,-15468,-18204,-19103, -9140, 10132,
+    -13631, -9568, 22580, 13756, -3548, 12112, 23891,  8144,  5964,  7240,
+      7216,  4284, -4800,-11761, -1308, -3044,-19584,-13808,  -759, -7968,
+    -14524, -1503,  3072,  -396,  1936,  5900,  9264, 10769,  7240,  5961,
+     13112,  8788,   660,  2807,  7980,  -449, -2477,  3940,  2792,  1584,
+      2791,  5603,  7528,  9692,  5924,  9123, 15240,  9636,  4924, 11044,
+     11113,   956,   756,  2812, -1832, -6920, -7120, -7192, -7711, -9717,
+    -12704, -8736, -7508,-12067,-13176, -8133, -9304,-13160,-13437,-13268,
+     -4084, 11400,-12785,  -700, 24992, 12168, -1268, 19404, 25183,  8373,
+     10256, 13664, 11200,  5879,   -60, -3656,  4556, -2972,-14688, -4932,
+      2432, -9279,-10691,  4280,  3180, -2444,  4088,  9992,  9176,  9156,
+      9520, 11164, 14484,  8608,  4919, 10556,  9792,  2740,  3456,  8840,
+      6424,  2348,  5696,  9420,  6596,  5380,  8364, 10952,  8499,  6800,
+      8728,  9641,  5412,  2340,  3596,  2039, -2864, -5489, -3616, -5596,
+     -9232, -8744, -7788, -9860,-11104, -9356, -9464,-11188,-11312,-11036,
+    -11736,-13564, -6016,  8744,-11784, -1196, 18972,  9512,  -572, 17407,
+     20316,  7472,  9784, 13369,  8952,  5092,  1003, -2004,  2755, -3952,
+    -12761, -4648,  -744,-11667,-10240,  1556, -1572, -5872,  2196,  6011,
+      3900,  5384,  7529,  8924,  9629,  6324,  5744,  9484,  7829,  3420,
+      4384,  8644,  4360,  1500,  5248,  5921,  2200,  2564,  5212,  5037,
+      2849,  2836,  3985,  3952,   875,  -560,   416, -1052, -5228, -5185,
+     -4996, -7820, -9616, -9076,-10644,-11239,-11816,-12360,-12228,-12420,
+    -13560,-12940,-13044,-15648,-11664,  1945, -9676, -9088,  9676,  6708,
+     -3048,  8185, 15520,  4620,  5764, 10716,  6584,  2684,  2276, -1436,
+       -56, -2948, -9140, -6611, -2868, -9897,-10565, -2012, -3948, -7916,
+     -1440,  2420,  -241,  1164,  4428,  4932,  5461,  3884,  4476,  6620,
+      7724,  1779,  3172,  8256,  3132,  -749,  5192,  4300, -1388,  1192,
+      3575,   789,  -228,  1185,   995,   937,  -952, -2624,  -449, -1992,
+     -6204, -4648, -3000, -7604, -8536, -5868, -9024,-10507,-10064, -9296,
+    -12896,-11120,-11776,-13288,-14137,-12668,-15780,-14157, -8392, -7444,
+    -11156, -2300,  2828, -1747,  1164,  8152,  6280,  4876,  7912,  7604,
+      5609,  5164,  2600,  1620,  1592, -3237, -4441, -2068, -5052, -8268,
+     -4503, -3304, -6332, -4460,  -388,  -297,  -319,  1911,  4071,  4272,
+      4659,  8368,  6933,  6720,  8764,  8640,  6412,  6384,  5927,  3820,
+      3488,  2648,  1104,  1220,   884,  -692,   327,   616,  -972,  -160,
+       713,  -593,  -652,   179,  -651, -2005,  -656, -1536, -2968, -3748,
+     -2640, -5052, -5548, -3476, -6151, -6388, -5168, -6099, -7416, -5752,
+     -7579, -8220, -8312, -8472, -5287, -8056, -3527, -2356, -1704,  1892,
+      2408,  2893,  5965,  8121,  5136,  8480,  8928,  7364,  6408,  7960,
+      4315,  4392,  3864,  1353,   928,  1436, -1480,  -488,  1640,  -380,
+       -36,  3420,  4044,  4432,  5185,  8044,  8740,  7983,  7912,  9588,
+      8588,  6804,  6944,  6700,  4308,  2852,  3252,  2192,  -136,   876,
+      1008,   244,   160,   205,   992,  1684,  -136,   984,  3312,   853,
+      -772,  2372,   436, -3008, -1024,  -136, -3800, -2263, -3212, -2749,
+     -3688, -2424, -5372, -2136, -3288, -4952, -3596, -2028, -4640, -5797,
+     -2696, -4040, -7152, -4055, -2568, -6460, -4228, -1092, -2780, -2492,
+       468,  -235,  1620,  3500,  2040,  2840,  6300,  4488,  2488,  5707,
+      5576,  3537,  2291,  4301,  2844,  3364,  1153,  2500,  3340,  3160,
+      1224,  3220,  4016,  2228,  1788,  4199,  3604,  2096,  1763,  3237,
+      2044,  -564,  1280,   876,  -584, -1904,    24,   -60, -2948, -1440,
+     -1228, -1824, -2092, -1945, -3912,  -227, -2411, -3219, -2252, -1808,
+     -3044, -1035, -3092, -1456, -3724, -2284, -3149, -3028, -2788, -1804,
+     -3360, -1276, -4097, -2531, -2248, -1635, -3215, -2376, -2468, -2596,
+     -2825, -2792, -1980, -4036, -1721, -2059, -4117,   364, -1452, -2772,
+     -1336,   480, -1043,   244, -2904,   924, -1329,   968, -1891,   523,
+      -624,  -464,  -564,   187,  -852,   584,  -764,  -260,  -147,   160,
+       339,   -32,   936,  -896,   288,   136,    56,   -36,  -736,  -683,
+      -332,   696, -2319,  -259,   564, -2196,  -860,  1108, -2177,  -728,
+      1344, -2520,  -440,  1080,  -780, -3513,  3272, -1635, -1597,  -188,
+       744, -1944,   140,  -636, -1644,  -141,  -596, -1132,  -816,  1168,
+     -2836,   196,   312,   136, -1381,   628,  -223,  -368,  -425,   604,
+      -776,   595,  -628,  -128,  -884,   960, -1092,    76,   144,     8,
+       161,  -504,   760,  -808,   336,   185,   100,   404,   120,   236,
+        68,  -148,   -64,   312,   320,  -560,   117,   -28,   236,  -231,
+       -92,    60,   356,  -176,   176,   212,   124,   -57,   -76,   168,
+        88,  -140,   -37,   160,     0,   -92,    96,    24,   -84,     0,
+};
+
+#define THIS_FILE	    "mips_test.c"
+#define DURATION	    5000
+#define PTIME		    20	/* MUST be 20! */
+#define MEGA		    1000000
+#define GIGA		    1000000000
+
+enum op
+{
+    OP_GET  = 1,
+    OP_PUT  = 2,
+    OP_GET_PUT = 4,
+    OP_PUT_GET = 8
+};
+
+enum clock_rate
+{
+    K8	= 1,
+    K16	= 2,
+    K32	= 4,
+};
+
+
+struct test_entry
+{
+    const char	    *title;
+    unsigned	     valid_op;
+    unsigned	     valid_clock_rate;
+
+    pjmedia_port*  (*init)(pj_pool_t *pool,
+			  unsigned clock_rate,
+			  unsigned channel_count,
+			  unsigned samples_per_frame,
+			  unsigned flags,
+			  struct test_entry *);
+    void	   (*custom_run)(struct test_entry*);
+    void	   (*custom_deinit)(struct test_entry*);
+
+    void	    *pdata[4];
+    unsigned	     idata[4];
+};
+
+
+/***************************************************************************/
+/* pjmedia_port to supply with continuous frames */
+static pjmedia_port* create_gen_port(pj_pool_t *pool,
+				     unsigned clock_rate,
+				     unsigned channel_count,
+				     unsigned samples_per_frame,
+				     unsigned pct_level)
+{
+    pjmedia_port *port;
+    pj_status_t status;
+
+    if (pct_level == 100 && channel_count==1) {
+	status = pjmedia_mem_player_create(pool, ref_signal, 
+					   sizeof(ref_signal), clock_rate, 
+					   channel_count, samples_per_frame,
+					   16, 0, &port);
+    } else {
+	pj_int16_t *buf;
+	unsigned c;
+
+	buf = (pj_int16_t*)
+	      pj_pool_alloc(pool, sizeof(ref_signal)*channel_count);
+	for (c=0; c<channel_count; ++c) {
+	    unsigned i;
+	    pj_int16_t *p;
+
+	    p = buf+c;
+	    for (i=0; i<PJ_ARRAY_SIZE(ref_signal); ++i) {
+		*p = (pj_int16_t)(ref_signal[i] * pct_level / 100);
+		p += channel_count;
+	    }
+	}
+	status = pjmedia_mem_player_create(pool, buf, 
+					   sizeof(ref_signal)*channel_count, 
+					   clock_rate,  channel_count, 
+					   samples_per_frame,
+					   16, 0, &port);
+    }
+
+    return status==PJ_SUCCESS? port : NULL;
+}
+
+/***************************************************************************/
+static pjmedia_port* gen_port_test_init(pj_pool_t *pool,
+				        unsigned clock_rate,
+				        unsigned channel_count,
+				        unsigned samples_per_frame,
+				        unsigned flags,
+				        struct test_entry *te)
+{
+    PJ_UNUSED_ARG(flags);
+    PJ_UNUSED_ARG(te);
+    return create_gen_port(pool, clock_rate, channel_count, samples_per_frame,
+			   100);
+}
+
+
+/***************************************************************************/
+static pjmedia_port* init_conf_port(unsigned nb_participant,
+				    pj_pool_t *pool,
+				    unsigned clock_rate,
+				    unsigned channel_count,
+				    unsigned samples_per_frame,
+				    unsigned flags,
+				    struct test_entry *te)
+{
+    pjmedia_conf *conf;
+    unsigned i;
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(flags);
+    PJ_UNUSED_ARG(te);
+
+    /* Create conf */
+    status = pjmedia_conf_create(pool, 2+nb_participant*2, clock_rate, 
+				 channel_count, samples_per_frame, 16, 
+				 PJMEDIA_CONF_NO_DEVICE, &conf);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    for (i=0; i<nb_participant; ++i) {
+	pjmedia_port *gen_port, *null_port;
+	unsigned slot1, slot2;
+
+	/* Create gen_port for source audio */
+	gen_port = create_gen_port(pool, clock_rate, channel_count,
+				   samples_per_frame, 100 / nb_participant);
+	if (!gen_port)
+	    return NULL;
+
+	/* Add port */
+	status = pjmedia_conf_add_port(conf, pool, gen_port, NULL, &slot1);
+	if (status != PJ_SUCCESS)
+	    return NULL;
+
+	/* Connect gen_port to sound dev */
+	status = pjmedia_conf_connect_port(conf, slot1, 0, 0);
+	if (status != PJ_SUCCESS)
+	    return NULL;
+
+	/* Create null sink frame */
+	status = pjmedia_null_port_create(pool, clock_rate, channel_count,
+					  samples_per_frame, 16, &null_port);
+	if (status != PJ_SUCCESS)
+	    return NULL;
+
+	/* add null port */
+	status = pjmedia_conf_add_port(conf, pool, null_port, NULL, &slot2);
+	if (status != PJ_SUCCESS)
+	    return NULL;
+
+	/* connect sound to null sink port */
+	status = pjmedia_conf_connect_port(conf, 0, slot2, 0);
+	if (status != PJ_SUCCESS)
+	    return NULL;
+
+	/* connect gen_port to null sink port */
+#if 0
+	status = pjmedia_conf_connect_port(conf, slot1, slot2, 0);
+	if (status != PJ_SUCCESS)
+	    return NULL;
+#endif	
+    }
+
+    return pjmedia_conf_get_master_port(conf);
+}
+
+
+/***************************************************************************/
+/* Benchmark conf with 1 participant, no mixing */
+static pjmedia_port* conf1_test_init(pj_pool_t *pool,
+				     unsigned clock_rate,
+				     unsigned channel_count,
+				     unsigned samples_per_frame,
+				     unsigned flags,
+				     struct test_entry *te)
+{
+    return init_conf_port(1, pool, clock_rate, channel_count, 
+			  samples_per_frame, flags, te);
+}
+
+
+/***************************************************************************/
+/* Benchmark conf with 2 participants, mixing to/from snd dev */
+static pjmedia_port* conf2_test_init(pj_pool_t *pool,
+				     unsigned clock_rate,
+				     unsigned channel_count,
+				     unsigned samples_per_frame,
+				     unsigned flags,
+				     struct test_entry *te)
+{
+    return init_conf_port(2, pool, clock_rate, channel_count, 
+			  samples_per_frame, flags, te);
+}
+
+/***************************************************************************/
+/* Benchmark conf with 4 participants, mixing to/from snd dev */
+static pjmedia_port* conf4_test_init(pj_pool_t *pool,
+				     unsigned clock_rate,
+				     unsigned channel_count,
+				     unsigned samples_per_frame,
+				     unsigned flags,
+				     struct test_entry *te)
+{
+    return init_conf_port(4, pool, clock_rate, channel_count, 
+			  samples_per_frame, flags, te);
+}
+
+/***************************************************************************/
+/* Benchmark conf with 8 participants, mixing to/from snd dev */
+static pjmedia_port* conf8_test_init(pj_pool_t *pool,
+				     unsigned clock_rate,
+				     unsigned channel_count,
+				     unsigned samples_per_frame,
+				     unsigned flags,
+				     struct test_entry *te)
+{
+    return init_conf_port(8, pool, clock_rate, channel_count, 
+			  samples_per_frame, flags, te);
+}
+
+/***************************************************************************/
+/* Benchmark conf with 16 participants, mixing to/from snd dev */
+static pjmedia_port* conf16_test_init(pj_pool_t *pool,
+				      unsigned clock_rate,
+				      unsigned channel_count,
+				      unsigned samples_per_frame,
+				      unsigned flags,
+				      struct test_entry *te)
+{
+    PJ_UNUSED_ARG(flags);
+    return init_conf_port(16, pool, clock_rate, channel_count, 
+			  samples_per_frame, flags, te);
+}
+
+/***************************************************************************/
+/* Up and downsample */
+static pjmedia_port* updown_resample_get(pj_pool_t *pool,
+					 pj_bool_t high_quality,
+					 pj_bool_t large_filter,
+				         unsigned clock_rate,
+				         unsigned channel_count,
+				         unsigned samples_per_frame,
+				         unsigned flags,
+				         struct test_entry *te)
+{
+    pjmedia_port *gen_port, *up, *down;
+    unsigned opt = 0;
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(flags);
+    PJ_UNUSED_ARG(te);
+
+    if (!high_quality)
+	opt |= PJMEDIA_RESAMPLE_USE_LINEAR;
+    if (!large_filter)
+	opt |= PJMEDIA_RESAMPLE_USE_SMALL_FILTER;
+
+    gen_port = create_gen_port(pool, clock_rate, channel_count,
+			       samples_per_frame, 100);
+    status = pjmedia_resample_port_create(pool, gen_port, clock_rate*2, opt, &up);
+    if (status != PJ_SUCCESS)
+	return NULL;
+    status = pjmedia_resample_port_create(pool, up, clock_rate, opt, &down);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    return down;
+}
+
+/* Linear resampling */
+static pjmedia_port* linear_resample( pj_pool_t *pool,
+				      unsigned clock_rate,
+				      unsigned channel_count,
+				      unsigned samples_per_frame,
+				      unsigned flags,
+				      struct test_entry *te)
+{
+    return updown_resample_get(pool, PJ_FALSE, PJ_FALSE, clock_rate,
+			       channel_count, samples_per_frame, flags, te);
+}
+
+/* Small filter resampling */
+static pjmedia_port* small_filt_resample( pj_pool_t *pool,
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned flags,
+					  struct test_entry *te)
+{
+    return updown_resample_get(pool, PJ_TRUE, PJ_FALSE, clock_rate,
+			       channel_count, samples_per_frame, flags, te);
+}
+
+/* Larger filter resampling */
+static pjmedia_port* large_filt_resample( pj_pool_t *pool,
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned flags,
+					  struct test_entry *te)
+{
+    return updown_resample_get(pool, PJ_TRUE, PJ_TRUE, clock_rate,
+			       channel_count, samples_per_frame, flags, te);
+}
+
+
+/***************************************************************************/
+/* Codec encode/decode */
+
+struct codec_port
+{
+    pjmedia_port     base;
+    pjmedia_endpt   *endpt;
+    pjmedia_codec   *codec;
+    pj_status_t	   (*codec_deinit)();
+    pj_uint8_t	     pkt[640];
+    pj_uint16_t	     pcm[32000 * PTIME / 1000];
+};
+
+
+static pj_status_t codec_put_frame(struct pjmedia_port *this_port, 
+				   pjmedia_frame *frame)
+{
+    struct codec_port *cp = (struct codec_port*)this_port;
+    pjmedia_frame out_frame;
+    pj_status_t status;
+
+    out_frame.buf = cp->pkt;
+    out_frame.size = sizeof(cp->pkt);
+    status = pjmedia_codec_encode(cp->codec, frame, sizeof(cp->pkt),
+				  &out_frame);
+    pj_assert(status == PJ_SUCCESS);
+
+    if (out_frame.size != 0) {
+	pjmedia_frame parsed_frm[2], pcm_frm;
+	unsigned frame_cnt = PJ_ARRAY_SIZE(parsed_frm);
+	unsigned i;
+
+	status = pjmedia_codec_parse(cp->codec, out_frame.buf, 
+				     out_frame.size, &out_frame.timestamp,
+				     &frame_cnt, parsed_frm);
+	pj_assert(status == PJ_SUCCESS);
+	
+	for (i=0; i<frame_cnt; ++i) {
+	    pcm_frm.buf = cp->pcm;
+	    pcm_frm.size = sizeof(cp->pkt);
+	    status = pjmedia_codec_decode(cp->codec, &parsed_frm[i], 
+					  sizeof(cp->pcm), &pcm_frm);
+	    pj_assert(status == PJ_SUCCESS);
+	}
+    }
+
+    return PJ_SUCCESS;
+}
+
+static pj_status_t codec_on_destroy(struct pjmedia_port *this_port)
+{
+    struct codec_port *cp = (struct codec_port*)this_port;
+
+    pjmedia_codec_close(cp->codec);
+    pjmedia_codec_mgr_dealloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt),
+				    cp->codec);
+    cp->codec_deinit();
+    pjmedia_endpt_destroy(cp->endpt);
+    return PJ_SUCCESS;
+}
+
+static pjmedia_port* codec_encode_decode( pj_pool_t *pool,
+					  const char *codec,
+					  pj_status_t (*codec_init)(pjmedia_endpt*),
+					  pj_status_t (*codec_deinit)(),
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned flags,
+					  struct test_entry *te)
+{
+    struct codec_port *cp;
+    pj_str_t codec_id;
+    const pjmedia_codec_info *ci[1];
+    unsigned count;
+    pjmedia_codec_param codec_param;
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(flags);
+    PJ_UNUSED_ARG(te);
+
+    codec_id = pj_str((char*)codec);
+    cp = PJ_POOL_ZALLOC_T(pool, struct codec_port);
+    pjmedia_port_info_init(&cp->base.info, &codec_id, 0x123456, clock_rate,
+			   channel_count, 16, samples_per_frame);
+    cp->base.put_frame = &codec_put_frame;
+    cp->base.on_destroy = &codec_on_destroy;
+    cp->codec_deinit = codec_deinit;
+
+    status = pjmedia_endpt_create(mem, NULL, 0, &cp->endpt);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    status = codec_init(cp->endpt);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    count = 1;
+    status = pjmedia_codec_mgr_find_codecs_by_id(pjmedia_endpt_get_codec_mgr(cp->endpt),
+						 &codec_id, &count, ci, NULL);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    status = pjmedia_codec_mgr_alloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt),
+					   ci[0], &cp->codec);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    status = pjmedia_codec_mgr_get_default_param(pjmedia_endpt_get_codec_mgr(cp->endpt),
+						 ci[0], &codec_param);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    status = pjmedia_codec_init(cp->codec, pool);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    status = pjmedia_codec_open(cp->codec, &codec_param);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    return &cp->base;
+}
+
+#if PJMEDIA_HAS_G711_CODEC
+/* G.711 benchmark */
+static pjmedia_port* g711_encode_decode(  pj_pool_t *pool,
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned flags,
+					  struct test_entry *te)
+{
+    return codec_encode_decode(pool, "pcmu", &pjmedia_codec_g711_init, 
+			       &pjmedia_codec_g711_deinit,
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+#endif
+
+/* GSM benchmark */
+#if PJMEDIA_HAS_GSM_CODEC
+static pjmedia_port* gsm_encode_decode(  pj_pool_t *pool,
+					 unsigned clock_rate,
+					 unsigned channel_count,
+					 unsigned samples_per_frame,
+					 unsigned flags,
+					 struct test_entry *te)
+{
+    return codec_encode_decode(pool, "gsm", &pjmedia_codec_gsm_init, 
+			       &pjmedia_codec_gsm_deinit, 
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+#endif
+
+#if PJMEDIA_HAS_ILBC_CODEC
+static pj_status_t ilbc_init(pjmedia_endpt *endpt)
+{
+    return pjmedia_codec_ilbc_init(endpt, 20);
+}
+
+/* iLBC benchmark */
+static pjmedia_port* ilbc_encode_decode( pj_pool_t *pool,
+					 unsigned clock_rate,
+					 unsigned channel_count,
+					 unsigned samples_per_frame,
+					 unsigned flags,
+					 struct test_entry *te)
+{
+    samples_per_frame = 30 * clock_rate / 1000;
+    return codec_encode_decode(pool, "ilbc", &ilbc_init, 
+			       &pjmedia_codec_ilbc_deinit, clock_rate, 
+			       channel_count, samples_per_frame, flags, te);
+}
+#endif
+
+#if PJMEDIA_HAS_SPEEX_CODEC
+/* Speex narrowband benchmark */
+static pjmedia_port* speex8_encode_decode(pj_pool_t *pool,
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned flags,
+					  struct test_entry *te)
+{
+    return codec_encode_decode(pool, "speex/8000", 
+			       &pjmedia_codec_speex_init_default, 
+			       &pjmedia_codec_speex_deinit, 
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+
+/* Speex wideband benchmark */
+static pjmedia_port* speex16_encode_decode(pj_pool_t *pool,
+					   unsigned clock_rate,
+					   unsigned channel_count,
+					   unsigned samples_per_frame,
+					   unsigned flags,
+					   struct test_entry *te)
+{
+    return codec_encode_decode(pool, "speex/16000", 
+			       &pjmedia_codec_speex_init_default, 
+			       &pjmedia_codec_speex_deinit, 
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+#endif
+
+#if PJMEDIA_HAS_G722_CODEC
+/* G.722 benchmark benchmark */
+static pjmedia_port* g722_encode_decode(pj_pool_t *pool,
+					unsigned clock_rate,
+					unsigned channel_count,
+					unsigned samples_per_frame,
+					unsigned flags,
+					struct test_entry *te)
+{
+    return codec_encode_decode(pool, "g722", &pjmedia_codec_g722_init, 
+			       &pjmedia_codec_g722_deinit, 
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+#endif
+
+#if PJMEDIA_HAS_G7221_CODEC
+/* G.722.1 benchmark benchmark */
+static pjmedia_port* g7221_encode_decode(pj_pool_t *pool,
+					 unsigned clock_rate,
+					 unsigned channel_count,
+					 unsigned samples_per_frame,
+					 unsigned flags,
+					 struct test_entry *te)
+{
+    return codec_encode_decode(pool, "g7221/16000", 
+			       &pjmedia_codec_g7221_init,
+			       &pjmedia_codec_g7221_deinit,
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+
+/* G.722.1 Annex C benchmark benchmark */
+static pjmedia_port* g7221c_encode_decode(pj_pool_t *pool,
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned flags,
+					  struct test_entry *te)
+{
+    return codec_encode_decode(pool, "g7221/32000", 
+			       &pjmedia_codec_g7221_init,
+			       &pjmedia_codec_g7221_deinit,
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+#endif	/* PJMEDIA_HAS_G7221_CODEC */
+
+#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC
+/* AMR-NB benchmark benchmark */
+static pjmedia_port* amr_encode_decode(pj_pool_t *pool,
+                                       unsigned clock_rate,
+                                       unsigned channel_count,
+                                       unsigned samples_per_frame,
+                                       unsigned flags,
+                                       struct test_entry *te)
+{
+    return codec_encode_decode(pool, "AMR/8000", 
+			       &pjmedia_codec_opencore_amrnb_init,
+			       &pjmedia_codec_opencore_amrnb_deinit,
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+#endif	/* PJMEDIA_HAS_OPENCORE_AMRNB_CODEC */
+
+#if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC
+/* AMR-WB benchmark benchmark */
+static pjmedia_port* amrwb_encode_decode(pj_pool_t *pool,
+                                         unsigned clock_rate,
+                                         unsigned channel_count,
+                                         unsigned samples_per_frame,
+                                         unsigned flags,
+                                         struct test_entry *te)
+{
+    return codec_encode_decode(pool, "AMR/16000",
+			       &pjmedia_codec_opencore_amr_init_default,
+			       &pjmedia_codec_opencore_amr_deinit,
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+#endif	/* PJMEDIA_HAS_OPENCORE_AMRWB_CODEC */
+
+#if defined(PJMEDIA_HAS_L16_CODEC) && PJMEDIA_HAS_L16_CODEC!=0
+static pj_status_t init_l16_default(pjmedia_endpt *endpt)
+{
+    return pjmedia_codec_l16_init(endpt, 0);
+}
+
+/* L16/8000/1 benchmark */
+static pjmedia_port* l16_8_encode_decode(pj_pool_t *pool,
+					 unsigned clock_rate,
+					 unsigned channel_count,
+					 unsigned samples_per_frame,
+					 unsigned flags,
+					 struct test_entry *te)
+{
+    return codec_encode_decode(pool, "L16/8000/1", &init_l16_default, 
+			       &pjmedia_codec_l16_deinit, 
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+
+/* L16/16000/1 benchmark */
+static pjmedia_port* l16_16_encode_decode(pj_pool_t *pool,
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned flags,
+					  struct test_entry *te)
+{
+    return codec_encode_decode(pool, "L16/16000/1", &init_l16_default, 
+			       &pjmedia_codec_l16_deinit, 
+			       clock_rate, channel_count,
+			       samples_per_frame, flags, te);
+}
+#endif
+
+/***************************************************************************/
+/* WSOLA PLC mode */
+
+struct wsola_plc_port
+{
+    pjmedia_port     base;
+    pjmedia_wsola   *wsola;
+    pjmedia_port    *gen_port;
+    int		     loss_pct;
+    pj_bool_t	     prev_lost;
+};
+
+
+static pj_status_t wsola_plc_get_frame(struct pjmedia_port *this_port, 
+				       pjmedia_frame *frame)
+{
+    struct wsola_plc_port *wp = (struct wsola_plc_port*)this_port;
+    pj_status_t status;
+
+
+    if ((pj_rand() % 100) > wp->loss_pct) {
+	status = pjmedia_port_get_frame(wp->gen_port, frame);
+	pj_assert(status == PJ_SUCCESS);
+
+	status = pjmedia_wsola_save(wp->wsola, (short*)frame->buf, 
+				    wp->prev_lost);
+	pj_assert(status == PJ_SUCCESS);
+
+	wp->prev_lost = PJ_FALSE;
+    } else {
+	status = pjmedia_wsola_generate(wp->wsola, (short*)frame->buf);
+	wp->prev_lost = PJ_TRUE;
+    }
+
+    return PJ_SUCCESS;
+}
+
+static pj_status_t wsola_plc_on_destroy(struct pjmedia_port *this_port)
+{
+    struct wsola_plc_port *wp = (struct wsola_plc_port*)this_port;
+    pjmedia_port_destroy(wp->gen_port);
+    pjmedia_wsola_destroy(wp->wsola);
+    return PJ_SUCCESS;
+}
+
+static pjmedia_port* create_wsola_plc(unsigned loss_pct,
+				      pj_pool_t *pool,
+				      unsigned clock_rate,
+				      unsigned channel_count,
+				      unsigned samples_per_frame,
+				      unsigned flags,
+				      struct test_entry *te)
+{
+    struct wsola_plc_port *wp;
+    pj_str_t name = pj_str("wsola");
+    unsigned opt = 0;
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(flags);
+    PJ_UNUSED_ARG(te);
+
+    wp = PJ_POOL_ZALLOC_T(pool, struct wsola_plc_port);
+    wp->loss_pct = loss_pct;
+    wp->base.get_frame = &wsola_plc_get_frame;
+    wp->base.on_destroy = &wsola_plc_on_destroy;
+    pjmedia_port_info_init(&wp->base.info, &name, 0x4123, clock_rate, 
+			   channel_count, 16, samples_per_frame);
+
+    if (loss_pct == 0)
+	opt |= PJMEDIA_WSOLA_NO_PLC;
+
+    status = pjmedia_wsola_create(pool, clock_rate, samples_per_frame,
+				  channel_count, 0, &wp->wsola);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    wp->gen_port = create_gen_port(pool, clock_rate, channel_count, 
+				   samples_per_frame, 100);
+    if (wp->gen_port == NULL)
+	return NULL;
+
+    return &wp->base;
+}
+
+
+/* WSOLA PLC with 0% packet loss */
+static pjmedia_port* wsola_plc_0( pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_wsola_plc(0, pool, clock_rate, channel_count, 
+			    samples_per_frame, flags, te);
+}
+
+
+/* WSOLA PLC with 2% packet loss */
+static pjmedia_port* wsola_plc_2( pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_wsola_plc(2, pool, clock_rate, channel_count, 
+			    samples_per_frame, flags, te);
+}
+
+/* WSOLA PLC with 5% packet loss */
+static pjmedia_port* wsola_plc_5( pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_wsola_plc(5, pool, clock_rate, channel_count, 
+			    samples_per_frame, flags, te);
+}
+
+/* WSOLA PLC with 10% packet loss */
+static pjmedia_port* wsola_plc_10(pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_wsola_plc(10, pool, clock_rate, channel_count, 
+			    samples_per_frame, flags, te);
+}
+
+/* WSOLA PLC with 20% packet loss */
+static pjmedia_port* wsola_plc_20(pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_wsola_plc(20, pool, clock_rate, channel_count, 
+			    samples_per_frame, flags, te);
+}
+
+/* WSOLA PLC with 50% packet loss */
+static pjmedia_port* wsola_plc_50(pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_wsola_plc(50, pool, clock_rate, channel_count, 
+			    samples_per_frame, flags, te);
+}
+
+
+
+/***************************************************************************/
+/* WSOLA discard mode */
+enum { CIRC_BUF_FRAME_CNT = 4 };
+struct wsola_discard_port
+{
+    pjmedia_port	 base;
+    pjmedia_port	*gen_port;
+    pjmedia_wsola	*wsola;
+    pjmedia_circ_buf	*circbuf;
+    unsigned		 discard_pct;
+};
+
+
+static pj_status_t wsola_discard_get_frame(struct pjmedia_port *this_port, 
+					   pjmedia_frame *frame)
+{
+    struct wsola_discard_port *wp = (struct wsola_discard_port*)this_port;
+    pj_status_t status;
+
+    while (pjmedia_circ_buf_get_len(wp->circbuf) <
+		PJMEDIA_PIA_SPF(&wp->base.info) * (CIRC_BUF_FRAME_CNT-1))
+    {
+	status = pjmedia_port_get_frame(wp->gen_port, frame);
+	pj_assert(status==PJ_SUCCESS);
+
+	status = pjmedia_circ_buf_write(wp->circbuf, (short*)frame->buf, 
+					PJMEDIA_PIA_SPF(&wp->base.info));
+	pj_assert(status==PJ_SUCCESS);
+    }
+    
+    if ((pj_rand() % 100) < (int)wp->discard_pct) {
+	pj_int16_t *reg1, *reg2;
+	unsigned reg1_len, reg2_len;
+	unsigned del_cnt;
+
+	pjmedia_circ_buf_get_read_regions(wp->circbuf, &reg1, &reg1_len,
+					  &reg2, &reg2_len);
+
+	del_cnt = PJMEDIA_PIA_SPF(&wp->base.info);
+	status = pjmedia_wsola_discard(wp->wsola, reg1, reg1_len, reg2, 
+				       reg2_len, &del_cnt);
+	pj_assert(status==PJ_SUCCESS);
+
+	status = pjmedia_circ_buf_adv_read_ptr(wp->circbuf, del_cnt);
+	pj_assert(status==PJ_SUCCESS);
+    }
+
+    return PJ_SUCCESS;
+}
+
+static pj_status_t wsola_discard_on_destroy(struct pjmedia_port *this_port)
+{
+    struct wsola_discard_port *wp = (struct wsola_discard_port*)this_port;
+    pjmedia_port_destroy(wp->gen_port);
+    pjmedia_wsola_destroy(wp->wsola);
+    return PJ_SUCCESS;
+}
+
+
+static pjmedia_port* create_wsola_discard(unsigned discard_pct,
+					  pj_pool_t *pool,
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned flags,
+					  struct test_entry *te)
+{
+    struct wsola_discard_port *wp;
+    pj_str_t name = pj_str("wsola");
+    unsigned i, opt = 0;
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(flags);
+    PJ_UNUSED_ARG(te);
+
+    wp = PJ_POOL_ZALLOC_T(pool, struct wsola_discard_port);
+    wp->discard_pct = discard_pct;
+    wp->base.get_frame = &wsola_discard_get_frame;
+    wp->base.on_destroy = &wsola_discard_on_destroy;
+    pjmedia_port_info_init(&wp->base.info, &name, 0x4123, clock_rate, 
+			   channel_count, 16, samples_per_frame);
+
+    if (discard_pct == 0)
+	opt |= PJMEDIA_WSOLA_NO_DISCARD;
+
+    status = pjmedia_wsola_create(pool, clock_rate, samples_per_frame,
+				  channel_count, 0, &wp->wsola);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    wp->gen_port = create_gen_port(pool, clock_rate, channel_count, 
+				   samples_per_frame, 100);
+    if (wp->gen_port == NULL)
+	return NULL;
+
+    status = pjmedia_circ_buf_create(pool, samples_per_frame * CIRC_BUF_FRAME_CNT, 
+				     &wp->circbuf);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    /* fill up the circbuf */
+    for (i=0; i<CIRC_BUF_FRAME_CNT; ++i) {
+	short pcm[320];
+	pjmedia_frame frm;
+
+	pj_assert(PJ_ARRAY_SIZE(pcm) >= samples_per_frame);
+	frm.buf = pcm;
+	frm.size = samples_per_frame * 2;
+
+	status = pjmedia_port_get_frame(wp->gen_port, &frm);
+	pj_assert(status==PJ_SUCCESS);
+
+	status = pjmedia_circ_buf_write(wp->circbuf, pcm, samples_per_frame);
+	pj_assert(status==PJ_SUCCESS);
+    }
+
+    return &wp->base;
+}
+
+
+/* WSOLA with 2% discard rate */
+static pjmedia_port* wsola_discard_2( pj_pool_t *pool,
+				      unsigned clock_rate,
+				      unsigned channel_count,
+				      unsigned samples_per_frame,
+				      unsigned flags,
+				      struct test_entry *te)
+{
+    return create_wsola_discard(2, pool, clock_rate, channel_count, 
+			        samples_per_frame, flags, te);
+}
+
+/* WSOLA with 5% discard rate */
+static pjmedia_port* wsola_discard_5( pj_pool_t *pool,
+				      unsigned clock_rate,
+				      unsigned channel_count,
+				      unsigned samples_per_frame,
+				      unsigned flags,
+				      struct test_entry *te)
+{
+    return create_wsola_discard(5, pool, clock_rate, channel_count, 
+			        samples_per_frame, flags, te);
+}
+
+/* WSOLA with 10% discard rate */
+static pjmedia_port* wsola_discard_10(pj_pool_t *pool,
+				      unsigned clock_rate,
+				      unsigned channel_count,
+				      unsigned samples_per_frame,
+				      unsigned flags,
+				      struct test_entry *te)
+{
+    return create_wsola_discard(10, pool, clock_rate, channel_count, 
+			        samples_per_frame, flags, te);
+}
+
+/* WSOLA with 20% discard rate */
+static pjmedia_port* wsola_discard_20(pj_pool_t *pool,
+				      unsigned clock_rate,
+				      unsigned channel_count,
+				      unsigned samples_per_frame,
+				      unsigned flags,
+				      struct test_entry *te)
+{
+    return create_wsola_discard(20, pool, clock_rate, channel_count, 
+			        samples_per_frame, flags, te);
+}
+
+/* WSOLA with 50% discard rate */
+static pjmedia_port* wsola_discard_50(pj_pool_t *pool,
+				      unsigned clock_rate,
+				      unsigned channel_count,
+				      unsigned samples_per_frame,
+				      unsigned flags,
+				      struct test_entry *te)
+{
+    return create_wsola_discard(50, pool, clock_rate, channel_count, 
+			        samples_per_frame, flags, te);
+}
+
+
+
+/***************************************************************************/
+
+static pjmedia_port* ec_create(unsigned ec_tail_msec,
+			       pj_pool_t *pool,
+			       unsigned clock_rate,
+			       unsigned channel_count,
+			       unsigned samples_per_frame,
+			       unsigned flags,
+			       struct test_entry *te)
+{
+    pjmedia_port *gen_port, *ec_port;
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(te);
+
+    gen_port = create_gen_port(pool, clock_rate, channel_count, 
+			       samples_per_frame, 100);
+    if (gen_port == NULL)
+	return NULL;
+
+    status = pjmedia_echo_port_create(pool, gen_port, ec_tail_msec, 0,
+				      flags, &ec_port);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    return ec_port;
+}
+
+/* EC with 100ms tail length */
+static pjmedia_port* ec_create_100(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = 0;
+    return ec_create(100, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* EC with 128ms tail length */
+static pjmedia_port* ec_create_128(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = 0;
+    return ec_create(128, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* EC with 200ms tail length */
+static pjmedia_port* ec_create_200(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = 0;
+    return ec_create(200, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* EC with 256ms tail length */
+static pjmedia_port* ec_create_256(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = 0;
+    return ec_create(256, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+
+/* EC with 400ms tail length */
+static pjmedia_port* ec_create_400(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = 0;
+    return ec_create(400, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* EC with 500ms tail length */
+static pjmedia_port* ec_create_500(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = 0;
+    return ec_create(500, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* EC with 512ms tail length */
+static pjmedia_port* ec_create_512(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = 0;
+    return ec_create(512, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* EC with 600ms tail length */
+static pjmedia_port* ec_create_600(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = 0;
+    return ec_create(600, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* EC with 800ms tail length */
+static pjmedia_port* ec_create_800(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = 0;
+    return ec_create(800, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+
+
+/* Echo suppressor with 100ms tail length */
+static pjmedia_port* es_create_100(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = PJMEDIA_ECHO_SIMPLE;
+    return ec_create(100, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* Echo suppressor with 128ms tail length */
+static pjmedia_port* es_create_128(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = PJMEDIA_ECHO_SIMPLE;
+    return ec_create(128, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* Echo suppressor with 200ms tail length */
+static pjmedia_port* es_create_200(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = PJMEDIA_ECHO_SIMPLE;
+    return ec_create(200, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* Echo suppressor with 256ms tail length */
+static pjmedia_port* es_create_256(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = PJMEDIA_ECHO_SIMPLE;
+    return ec_create(256, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+
+/* Echo suppressor with 400ms tail length */
+static pjmedia_port* es_create_400(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = PJMEDIA_ECHO_SIMPLE;
+    return ec_create(400, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* Echo suppressor with 500ms tail length */
+static pjmedia_port* es_create_500(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = PJMEDIA_ECHO_SIMPLE;
+    return ec_create(500, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* Echo suppressor with 512ms tail length */
+static pjmedia_port* es_create_512(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = PJMEDIA_ECHO_SIMPLE;
+    return ec_create(512, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* Echo suppressor with 600ms tail length */
+static pjmedia_port* es_create_600(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = PJMEDIA_ECHO_SIMPLE;
+    return ec_create(600, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+/* Echo suppressor with 800ms tail length */
+static pjmedia_port* es_create_800(pj_pool_t *pool,
+				   unsigned clock_rate,
+				   unsigned channel_count,
+				   unsigned samples_per_frame,
+				   unsigned flags,
+				   struct test_entry *te)
+{
+    flags = PJMEDIA_ECHO_SIMPLE;
+    return ec_create(800, pool, clock_rate, channel_count, samples_per_frame,
+		     flags, te);
+}
+
+
+/***************************************************************************/
+/* Tone generator, single frequency */
+static pjmedia_port* create_tonegen(unsigned freq1,
+				    unsigned freq2,
+				    pj_pool_t *pool,
+				    unsigned clock_rate,
+				    unsigned channel_count,
+				    unsigned samples_per_frame,
+				    unsigned flags,
+				    struct test_entry *te)
+{
+    pjmedia_port *tonegen;
+    pjmedia_tone_desc tones[2];
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(flags);
+    PJ_UNUSED_ARG(te);
+
+    status = pjmedia_tonegen_create(pool, clock_rate, channel_count,
+				    samples_per_frame, 16, 
+				    PJMEDIA_TONEGEN_LOOP, &tonegen);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    pj_bzero(tones, sizeof(tones));
+    tones[0].freq1 = (short)freq1;
+    tones[0].freq2 = (short)freq2;
+    tones[0].on_msec = 400;
+    tones[0].off_msec = 0;
+    tones[1].freq1 = (short)freq1;
+    tones[1].freq2 = (short)freq2;
+    tones[1].on_msec = 400;
+    tones[1].off_msec = 100;
+
+    status = pjmedia_tonegen_play(tonegen, PJ_ARRAY_SIZE(tones), tones, 
+				  PJMEDIA_TONEGEN_LOOP);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    return tonegen;
+}
+
+/* Tonegen with single frequency */
+static pjmedia_port* create_tonegen1(pj_pool_t *pool,
+				     unsigned clock_rate,
+				     unsigned channel_count,
+				     unsigned samples_per_frame,
+				     unsigned flags,
+				     struct test_entry *te)
+{
+    return create_tonegen(400, 0, pool, clock_rate, channel_count,
+			  samples_per_frame, flags, te);
+}
+
+/* Tonegen with dual frequency */
+static pjmedia_port* create_tonegen2(pj_pool_t *pool,
+				     unsigned clock_rate,
+				     unsigned channel_count,
+				     unsigned samples_per_frame,
+				     unsigned flags,
+				     struct test_entry *te)
+{
+    return create_tonegen(400, 440, pool, clock_rate, channel_count,
+			  samples_per_frame, flags, te);
+}
+
+
+
+/***************************************************************************/
+/* Stream */
+
+struct stream_port
+{
+    pjmedia_port	 base;
+    pj_status_t	       (*codec_deinit)();
+    pjmedia_endpt	*endpt;
+    pjmedia_stream	*stream;
+    pjmedia_transport	*transport;
+};
+
+
+static void stream_port_custom_deinit(struct test_entry *te)
+{
+    struct stream_port *sp = (struct stream_port*) te->pdata[0];
+
+    pjmedia_stream_destroy(sp->stream);
+    pjmedia_transport_close(sp->transport);
+    sp->codec_deinit();
+    pjmedia_endpt_destroy(sp->endpt);
+
+}
+
+static pjmedia_port* create_stream( pj_pool_t *pool,
+				    const char *codec,
+				    pj_status_t (*codec_init)(pjmedia_endpt*),
+				    pj_status_t (*codec_deinit)(),
+				    pj_bool_t srtp_enabled,
+				    pj_bool_t srtp_80,
+				    pj_bool_t srtp_auth,
+				    unsigned clock_rate,
+				    unsigned channel_count,
+				    unsigned samples_per_frame,
+				    unsigned flags,
+				    struct test_entry *te)
+{
+    struct stream_port *sp;
+    pj_str_t codec_id;
+    pjmedia_port *port;
+    const pjmedia_codec_info *ci[1];
+    unsigned count;
+    pjmedia_codec_param codec_param;
+    pjmedia_stream_info si;
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(flags);
+
+    codec_id = pj_str((char*)codec);
+    sp = PJ_POOL_ZALLOC_T(pool, struct stream_port);
+    pjmedia_port_info_init(&sp->base.info, &codec_id, 0x123456, clock_rate,
+			   channel_count, 16, samples_per_frame);
+
+    te->pdata[0] = sp;
+    te->custom_deinit = &stream_port_custom_deinit;
+    sp->codec_deinit = codec_deinit;
+
+    status = pjmedia_endpt_create(mem, NULL, 0, &sp->endpt);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    status = codec_init(sp->endpt);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    count = 1;
+    status = pjmedia_codec_mgr_find_codecs_by_id(pjmedia_endpt_get_codec_mgr(sp->endpt),
+						 &codec_id, &count, ci, NULL);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+
+
+    status = pjmedia_codec_mgr_get_default_param(pjmedia_endpt_get_codec_mgr(sp->endpt),
+						 ci[0], &codec_param);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    /* Create stream info */
+    pj_bzero(&si, sizeof(si));
+    si.type = PJMEDIA_TYPE_AUDIO;
+    si.proto = PJMEDIA_TP_PROTO_RTP_AVP;
+    si.dir = PJMEDIA_DIR_ENCODING_DECODING;
+    pj_sockaddr_in_init(&si.rem_addr.ipv4, NULL, 4000);
+    pj_sockaddr_in_init(&si.rem_rtcp.ipv4, NULL, 4001);
+    pj_memcpy(&si.fmt, ci[0], sizeof(pjmedia_codec_info));
+    si.param = NULL;
+    si.tx_pt = ci[0]->pt;
+    si.tx_event_pt = 101;
+    si.rx_event_pt = 101;
+    si.ssrc = pj_rand();
+    si.jb_init = si.jb_min_pre = si.jb_max_pre = si.jb_max = -1;
+
+    /* Create loop transport */
+    status = pjmedia_transport_loop_create(sp->endpt, &sp->transport);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+#if PJMEDIA_HAS_SRTP
+    if (srtp_enabled) {
+	pjmedia_srtp_setting opt;
+	pjmedia_srtp_crypto crypto;
+	pjmedia_transport *srtp;
+
+	pjmedia_srtp_setting_default(&opt);
+	opt.close_member_tp = PJ_TRUE;
+	opt.use = PJMEDIA_SRTP_MANDATORY;
+
+	status = pjmedia_transport_srtp_create(sp->endpt, sp->transport, &opt,
+					       &srtp);
+	if (status != PJ_SUCCESS)
+	    return NULL;
+
+	pj_bzero(&crypto, sizeof(crypto));
+	if (srtp_80) {
+	    crypto.key = pj_str("123456789012345678901234567890");
+	    crypto.name = pj_str("AES_CM_128_HMAC_SHA1_80");
+	} else {
+	    crypto.key = pj_str("123456789012345678901234567890");
+	    crypto.name = pj_str("AES_CM_128_HMAC_SHA1_32");
+	}
+
+	if (!srtp_auth)
+	    crypto.flags = PJMEDIA_SRTP_NO_AUTHENTICATION;
+
+	status = pjmedia_transport_srtp_start(srtp, &crypto, &crypto);
+	if (status != PJ_SUCCESS)
+	    return NULL;
+
+	sp->transport = srtp;
+    }
+#endif
+
+    /* Create stream */
+    status = pjmedia_stream_create(sp->endpt, pool, &si, sp->transport, NULL, 
+				   &sp->stream);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    /* Start stream */
+    status = pjmedia_stream_start(sp->stream);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    status = pjmedia_stream_get_port(sp->stream, &port);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    return port;
+}
+
+#if PJMEDIA_HAS_G711_CODEC
+/* G.711 stream, no SRTP */
+static pjmedia_port* create_stream_pcmu( pj_pool_t *pool,
+					 unsigned clock_rate,
+					 unsigned channel_count,
+					 unsigned samples_per_frame,
+					 unsigned flags,
+					 struct test_entry *te)
+{
+    return create_stream(pool, "pcmu", &pjmedia_codec_g711_init, 
+			 &pjmedia_codec_g711_deinit,
+			 PJ_FALSE, PJ_FALSE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+
+/* G.711 stream, SRTP 32bit key no auth */
+static pjmedia_port* create_stream_pcmu_srtp32_no_auth( pj_pool_t *pool,
+							unsigned clock_rate,
+							unsigned channel_count,
+							unsigned samples_per_frame,
+							unsigned flags,
+							struct test_entry *te)
+{
+    return create_stream(pool, "pcmu", &pjmedia_codec_g711_init, 
+			 &pjmedia_codec_g711_deinit,
+			 PJ_TRUE, PJ_FALSE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+
+/* G.711 stream, SRTP 32bit key with auth */
+static pjmedia_port* create_stream_pcmu_srtp32_with_auth(pj_pool_t *pool,
+							 unsigned clock_rate,
+							 unsigned channel_count,
+							 unsigned samples_per_frame,
+							 unsigned flags,
+							 struct test_entry *te)
+{
+    return create_stream(pool, "pcmu", &pjmedia_codec_g711_init, 
+			 &pjmedia_codec_g711_deinit,
+			 PJ_TRUE, PJ_FALSE, PJ_TRUE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+
+/* G.711 stream, SRTP 80bit key no auth */
+static pjmedia_port* create_stream_pcmu_srtp80_no_auth( pj_pool_t *pool,
+							unsigned clock_rate,
+							unsigned channel_count,
+							unsigned samples_per_frame,
+							unsigned flags,
+							struct test_entry *te)
+{
+    return create_stream(pool, "pcmu", &pjmedia_codec_g711_init, 
+			 &pjmedia_codec_g711_deinit,
+			 PJ_TRUE, PJ_TRUE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+
+/* G.711 stream, SRTP 80bit key with auth */
+static pjmedia_port* create_stream_pcmu_srtp80_with_auth(pj_pool_t *pool,
+							 unsigned clock_rate,
+							 unsigned channel_count,
+							 unsigned samples_per_frame,
+							 unsigned flags,
+							 struct test_entry *te)
+{
+    return create_stream(pool, "pcmu", &pjmedia_codec_g711_init, 
+			 &pjmedia_codec_g711_deinit,
+			 PJ_TRUE, PJ_TRUE, PJ_TRUE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+#endif
+
+#if PJMEDIA_HAS_GSM_CODEC
+/* GSM stream */
+static pjmedia_port* create_stream_gsm(  pj_pool_t *pool,
+					 unsigned clock_rate,
+					 unsigned channel_count,
+					 unsigned samples_per_frame,
+					 unsigned flags,
+					 struct test_entry *te)
+{
+    return create_stream(pool, "gsm", &pjmedia_codec_gsm_init, 
+			 &pjmedia_codec_gsm_deinit, 
+			 PJ_FALSE, PJ_FALSE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+
+/* GSM stream, SRTP 32bit, no auth */
+static pjmedia_port* create_stream_gsm_srtp32_no_auth(pj_pool_t *pool,
+						      unsigned clock_rate,
+						      unsigned channel_count,
+						      unsigned samples_per_frame,
+						      unsigned flags,
+						      struct test_entry *te)
+{
+    return create_stream(pool, "gsm", &pjmedia_codec_gsm_init, 
+			 &pjmedia_codec_gsm_deinit, 
+			 PJ_TRUE, PJ_FALSE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+
+/* GSM stream, SRTP 32bit, with auth */
+static pjmedia_port* create_stream_gsm_srtp32_with_auth(pj_pool_t *pool,
+						        unsigned clock_rate,
+						        unsigned channel_count,
+						        unsigned samples_per_frame,
+						        unsigned flags,
+						        struct test_entry *te)
+{
+    return create_stream(pool, "gsm", &pjmedia_codec_gsm_init, 
+			 &pjmedia_codec_gsm_deinit, 
+			 PJ_TRUE, PJ_FALSE, PJ_TRUE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+
+/* GSM stream, SRTP 80bit, no auth */
+static pjmedia_port* create_stream_gsm_srtp80_no_auth(pj_pool_t *pool,
+						      unsigned clock_rate,
+						      unsigned channel_count,
+						      unsigned samples_per_frame,
+						      unsigned flags,
+						      struct test_entry *te)
+{
+    return create_stream(pool, "gsm", &pjmedia_codec_gsm_init, 
+			 &pjmedia_codec_gsm_deinit, 
+			 PJ_TRUE, PJ_TRUE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+
+/* GSM stream, SRTP 80bit, with auth */
+static pjmedia_port* create_stream_gsm_srtp80_with_auth(pj_pool_t *pool,
+						        unsigned clock_rate,
+						        unsigned channel_count,
+						        unsigned samples_per_frame,
+						        unsigned flags,
+						        struct test_entry *te)
+{
+    return create_stream(pool, "gsm", &pjmedia_codec_gsm_init, 
+			 &pjmedia_codec_gsm_deinit, 
+			 PJ_TRUE, PJ_TRUE, PJ_TRUE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+#endif
+
+#if PJMEDIA_HAS_G722_CODEC
+/* G722 stream */
+static pjmedia_port* create_stream_g722( pj_pool_t *pool,
+					 unsigned clock_rate,
+					 unsigned channel_count,
+					 unsigned samples_per_frame,
+					 unsigned flags,
+					 struct test_entry *te)
+{
+    return create_stream(pool, "g722", &pjmedia_codec_g722_init, 
+			 &pjmedia_codec_g722_deinit, 
+			 PJ_FALSE, PJ_FALSE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+#endif
+
+#if PJMEDIA_HAS_G7221_CODEC
+/* G722.1 stream */
+static pjmedia_port* create_stream_g7221( pj_pool_t *pool,
+					  unsigned clock_rate,
+					  unsigned channel_count,
+					  unsigned samples_per_frame,
+					  unsigned flags,
+					  struct test_entry *te)
+{
+    return create_stream(pool, "g7221/16000", &pjmedia_codec_g7221_init, 
+			 &pjmedia_codec_g7221_deinit, 
+			 PJ_FALSE, PJ_FALSE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+
+/* G722.1 Annex C stream */
+static pjmedia_port* create_stream_g7221c( pj_pool_t *pool,
+					   unsigned clock_rate,
+					   unsigned channel_count,
+					   unsigned samples_per_frame,
+					   unsigned flags,
+					   struct test_entry *te)
+{
+    return create_stream(pool, "g7221/32000", &pjmedia_codec_g7221_init,
+			 &pjmedia_codec_g7221_deinit, 
+			 PJ_FALSE, PJ_FALSE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+#endif	/* PJMEDIA_HAS_G7221_CODEC */ 
+
+/* AMR-NB stream */
+#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC
+static pjmedia_port* create_stream_amr( pj_pool_t *pool,
+                                        unsigned clock_rate,
+                                        unsigned channel_count,
+                                        unsigned samples_per_frame,
+                                        unsigned flags,
+                                        struct test_entry *te)
+{
+    return create_stream(pool, "AMR/8000", &pjmedia_codec_opencore_amrnb_init, 
+			 &pjmedia_codec_opencore_amrnb_deinit, 
+			 PJ_FALSE, PJ_FALSE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+#endif	/* PJMEDIA_HAS_OPENCORE_AMRNB_CODEC */
+
+/* AMR-WB stream */
+#if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC
+static pjmedia_port* create_stream_amrwb( pj_pool_t *pool,
+                                         unsigned clock_rate,
+                                         unsigned channel_count,
+                                         unsigned samples_per_frame,
+                                         unsigned flags,
+                                         struct test_entry *te)
+{
+    return create_stream(pool, "AMR/16000",
+                         &pjmedia_codec_opencore_amr_init_default,
+			 &pjmedia_codec_opencore_amr_deinit,
+			 PJ_FALSE, PJ_FALSE, PJ_FALSE,
+			 clock_rate, channel_count,
+			 samples_per_frame, flags, te);
+}
+#endif	/* PJMEDIA_HAS_OPENCORE_AMRWB_CODEC */
+
+/***************************************************************************/
+/* Delay buffer */
+enum {DELAY_BUF_MAX_DELAY = 80};
+struct delaybuf_port
+{
+    pjmedia_port	 base;
+    pjmedia_delay_buf   *delaybuf;
+    pjmedia_port	*gen_port;
+    int			 drift_pct;
+};
+
+
+static pj_status_t delaybuf_get_frame(struct pjmedia_port *this_port, 
+				      pjmedia_frame *frame)
+{
+    struct delaybuf_port *dp = (struct delaybuf_port*)this_port;
+    pj_status_t status;
+
+    status = pjmedia_delay_buf_get(dp->delaybuf, (pj_int16_t*)frame->buf);
+    pj_assert(status == PJ_SUCCESS);
+
+    /* Additional GET when drift_pct is negative */
+    if (dp->drift_pct < 0) {
+	int rnd;
+	rnd = pj_rand() % 100;
+
+	if (rnd < -dp->drift_pct) {
+	    status = pjmedia_delay_buf_get(dp->delaybuf, (pj_int16_t*)frame->buf);
+	    pj_assert(status == PJ_SUCCESS);
+	}
+    }
+
+    return PJ_SUCCESS;
+}
+
+static pj_status_t delaybuf_put_frame(struct pjmedia_port *this_port, 
+				      pjmedia_frame *frame)
+{
+    struct delaybuf_port *dp = (struct delaybuf_port*)this_port;
+    pj_status_t status;
+    pjmedia_frame f = *frame;
+
+    status = pjmedia_port_get_frame(dp->gen_port, &f);
+    pj_assert(status == PJ_SUCCESS);
+    status = pjmedia_delay_buf_put(dp->delaybuf, (pj_int16_t*)f.buf);
+    pj_assert(status == PJ_SUCCESS);
+
+    /* Additional PUT when drift_pct is possitive */
+    if (dp->drift_pct > 0) {
+	int rnd;
+	rnd = pj_rand() % 100;
+
+	if (rnd < dp->drift_pct) {
+	    status = pjmedia_port_get_frame(dp->gen_port, &f);
+	    pj_assert(status == PJ_SUCCESS);
+	    status = pjmedia_delay_buf_put(dp->delaybuf, (pj_int16_t*)f.buf);
+	    pj_assert(status == PJ_SUCCESS);
+	}
+    }
+
+    return PJ_SUCCESS;
+}
+
+static pj_status_t delaybuf_on_destroy(struct pjmedia_port *this_port)
+{
+    struct delaybuf_port *dp = (struct delaybuf_port*)this_port;
+    pjmedia_port_destroy(dp->gen_port);
+    pjmedia_delay_buf_destroy(dp->delaybuf);
+    return PJ_SUCCESS;
+}
+
+static pjmedia_port* create_delaybuf(int drift_pct,
+				     pj_pool_t *pool,
+				     unsigned clock_rate,
+				     unsigned channel_count,
+				     unsigned samples_per_frame,
+				     unsigned flags,
+				     struct test_entry *te)
+{
+    struct delaybuf_port *dp;
+    pj_str_t name = pj_str("delaybuf");
+    unsigned opt = 0;
+    pj_status_t status;
+
+    PJ_UNUSED_ARG(flags);
+    PJ_UNUSED_ARG(te);
+
+    dp = PJ_POOL_ZALLOC_T(pool, struct delaybuf_port);
+    dp->drift_pct = drift_pct;
+    dp->base.get_frame = &delaybuf_get_frame;
+    dp->base.put_frame = &delaybuf_put_frame;
+    dp->base.on_destroy = &delaybuf_on_destroy;
+    pjmedia_port_info_init(&dp->base.info, &name, 0x5678, clock_rate, 
+			   channel_count, 16, samples_per_frame);
+
+    status = pjmedia_delay_buf_create(pool, "mips_test", clock_rate, 
+				      samples_per_frame, channel_count, 
+				      DELAY_BUF_MAX_DELAY,
+				      opt, &dp->delaybuf);
+    if (status != PJ_SUCCESS)
+	return NULL;
+
+    dp->gen_port = create_gen_port(pool, clock_rate, channel_count, 
+				   samples_per_frame, 100);
+    if (dp->gen_port == NULL)
+	return NULL;
+
+    return &dp->base;
+}
+
+
+/* Delay buffer without drift */
+static pjmedia_port* delaybuf_0( pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_delaybuf(0, pool, clock_rate, channel_count, 
+			   samples_per_frame, flags, te);
+}
+
+
+/* Delay buffer with 2% drift */
+static pjmedia_port* delaybuf_p2( pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_delaybuf(2, pool, clock_rate, channel_count, 
+			   samples_per_frame, flags, te);
+}
+
+/* Delay buffer with 5% drift */
+static pjmedia_port* delaybuf_p5( pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_delaybuf(5, pool, clock_rate, channel_count, 
+			   samples_per_frame, flags, te);
+}
+
+/* Delay buffer with 10% drift */
+static pjmedia_port* delaybuf_p10(pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_delaybuf(10, pool, clock_rate, channel_count, 
+			   samples_per_frame, flags, te);
+}
+
+/* Delay buffer with 20% drift */
+static pjmedia_port* delaybuf_p20(pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_delaybuf(20, pool, clock_rate, channel_count, 
+			   samples_per_frame, flags, te);
+}
+
+/* Delay buffer with -2% drift */
+static pjmedia_port* delaybuf_n2( pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_delaybuf(-2, pool, clock_rate, channel_count, 
+			   samples_per_frame, flags, te);
+}
+
+/* Delay buffer with -5% drift */
+static pjmedia_port* delaybuf_n5( pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_delaybuf(-5, pool, clock_rate, channel_count, 
+			   samples_per_frame, flags, te);
+}
+
+/* Delay buffer with -10% drift */
+static pjmedia_port* delaybuf_n10(pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_delaybuf(-10, pool, clock_rate, channel_count, 
+			   samples_per_frame, flags, te);
+}
+
+/* Delay buffer with -20% drift */
+static pjmedia_port* delaybuf_n20(pj_pool_t *pool,
+				  unsigned clock_rate,
+				  unsigned channel_count,
+				  unsigned samples_per_frame,
+				  unsigned flags,
+				  struct test_entry *te)
+{
+    return create_delaybuf(-20, pool, clock_rate, channel_count, 
+			   samples_per_frame, flags, te);
+}
+
+
+/***************************************************************************/
+/* Run test entry, return elapsed time */
+static pj_timestamp run_entry(unsigned clock_rate, struct test_entry *e)
+{
+    pj_pool_t *pool;
+    pjmedia_port *port;
+    pj_timestamp t0, t1;
+    unsigned j, samples_per_frame;
+    pj_int16_t pcm[32000 * PTIME / 1000];
+    pjmedia_port *gen_port;
+    pj_status_t status;
+
+    samples_per_frame = clock_rate * PTIME / 1000;
+
+    pool = pj_pool_create(mem, "pool", 1024, 1024, NULL);
+    port = e->init(pool, clock_rate, 1, samples_per_frame, 0, e);
+    if (port == NULL) {
+	t0.u64 = 0;
+	pj_pool_release(pool);
+	PJ_LOG(1,(THIS_FILE, " init error"));
+	return t0;
+    }
+
+    /* Port may decide to use different ptime (e.g. iLBC) */
+    samples_per_frame = PJMEDIA_PIA_SPF(&port->info);
+
+    gen_port = create_gen_port(pool, clock_rate, 1, 
+			       samples_per_frame, 100);
+    if (gen_port == NULL) {
+	t0.u64 = 0;
+	pj_pool_release(pool);
+	return t0;
+    }
+
+    pj_get_timestamp(&t0);
+    for (j=0; j<DURATION*clock_rate/samples_per_frame/1000; ++j) {
+	pjmedia_frame frm;
+
+	if (e->valid_op==OP_GET_PUT) {
+	    frm.buf = (void*)pcm;
+	    frm.size = samples_per_frame * 2;
+	    frm.type = PJMEDIA_FRAME_TYPE_NONE;
+
+	    status = pjmedia_port_get_frame(port, &frm);
+	    pj_assert(status == PJ_SUCCESS);
+
+	    status = pjmedia_port_put_frame(port, &frm);
+	    pj_assert(status == PJ_SUCCESS);
+
+	} else if (e->valid_op == OP_GET) {
+	    frm.buf = (void*)pcm;
+	    frm.size = samples_per_frame * 2;
+	    frm.type = PJMEDIA_FRAME_TYPE_NONE;
+
+	    status = pjmedia_port_get_frame(port, &frm);
+	    pj_assert(status == PJ_SUCCESS);
+
+	} else if (e->valid_op == OP_PUT) {
+	    frm.buf = (void*)pcm;
+	    frm.size = samples_per_frame * 2;
+	    frm.type = PJMEDIA_FRAME_TYPE_NONE;
+
+	    status = pjmedia_port_get_frame(gen_port, &frm);
+	    pj_assert(status == PJ_SUCCESS);
+
+	    status = pjmedia_port_put_frame(port, &frm);
+	    pj_assert(status == PJ_SUCCESS);
+
+	} else if (e->valid_op == OP_PUT_GET) {
+	    frm.buf = (void*)pcm;
+	    frm.size = samples_per_frame * 2;
+	    frm.type = PJMEDIA_FRAME_TYPE_NONE;
+
+	    status = pjmedia_port_get_frame(gen_port, &frm);
+	    pj_assert(status == PJ_SUCCESS);
+
+	    status = pjmedia_port_put_frame(port, &frm);
+	    pj_assert(status == PJ_SUCCESS);
+
+	    status = pjmedia_port_get_frame(port, &frm);
+	    pj_assert(status == PJ_SUCCESS);
+	}
+    }
+    pj_get_timestamp(&t1);
+
+    pj_sub_timestamp(&t1, &t0);
+
+    if (e->custom_deinit)
+	e->custom_deinit(e);
+
+    pjmedia_port_destroy(port);
+    pj_pool_release(pool);
+
+    return t1;
+}
+
+/***************************************************************************/
+int mips_test(void)
+{
+    struct test_entry entries[] = {
+	{ "get from memplayer", OP_GET, K8|K16, &gen_port_test_init},
+	{ "conference bridge with 1 call", OP_GET_PUT, K8|K16, &conf1_test_init},
+	{ "conference bridge with 2 calls", OP_GET_PUT, K8|K16, &conf2_test_init},
+	{ "conference bridge with 4 calls", OP_GET_PUT, K8|K16, &conf4_test_init},
+	{ "conference bridge with 8 calls", OP_GET_PUT, K8|K16, &conf8_test_init},
+	{ "conference bridge with 16 calls", OP_GET_PUT, K8|K16, &conf16_test_init},
+	{ "upsample+downsample - linear", OP_GET, K8|K16, &linear_resample},
+	{ "upsample+downsample - small filter", OP_GET, K8|K16, &small_filt_resample},
+	{ "upsample+downsample - large filter", OP_GET, K8|K16, &large_filt_resample},
+	{ "WSOLA PLC - 0% loss", OP_GET, K8|K16, &wsola_plc_0},
+	{ "WSOLA PLC - 2% loss", OP_GET, K8|K16, &wsola_plc_2},
+	{ "WSOLA PLC - 5% loss", OP_GET, K8|K16, &wsola_plc_5},
+	{ "WSOLA PLC - 10% loss", OP_GET, K8|K16, &wsola_plc_10},
+	{ "WSOLA PLC - 20% loss", OP_GET, K8|K16, &wsola_plc_20},
+	{ "WSOLA PLC - 50% loss", OP_GET, K8|K16, &wsola_plc_50},
+	{ "WSOLA discard 2% excess", OP_GET, K8|K16, &wsola_discard_2},
+	{ "WSOLA discard 5% excess", OP_GET, K8|K16, &wsola_discard_5},
+	{ "WSOLA discard 10% excess", OP_GET, K8|K16, &wsola_discard_10},
+	{ "WSOLA discard 20% excess", OP_GET, K8|K16, &wsola_discard_20},
+	{ "WSOLA discard 50% excess", OP_GET, K8|K16, &wsola_discard_50},
+	{ "Delay buffer", OP_GET_PUT, K8|K16, &delaybuf_0},
+	{ "Delay buffer - drift -2%", OP_GET_PUT, K8|K16, &delaybuf_n2},
+	{ "Delay buffer - drift -5%", OP_GET_PUT, K8|K16, &delaybuf_n5},
+	{ "Delay buffer - drift -10%", OP_GET_PUT, K8|K16, &delaybuf_n10},
+	{ "Delay buffer - drift -20%", OP_GET_PUT, K8|K16, &delaybuf_n20},
+	{ "Delay buffer - drift +2%", OP_GET_PUT, K8|K16, &delaybuf_p2},
+	{ "Delay buffer - drift +5%", OP_GET_PUT, K8|K16, &delaybuf_p5},
+	{ "Delay buffer - drift +10%", OP_GET_PUT, K8|K16, &delaybuf_p10},
+	{ "Delay buffer - drift +20%", OP_GET_PUT, K8|K16, &delaybuf_p20},
+	{ "echo canceller 100ms tail len", OP_GET_PUT, K8|K16, &ec_create_100},
+	{ "echo canceller 128ms tail len", OP_GET_PUT, K8|K16, &ec_create_128},
+	{ "echo canceller 200ms tail len", OP_GET_PUT, K8|K16, &ec_create_200},
+	{ "echo canceller 256ms tail len", OP_GET_PUT, K8|K16, &ec_create_256},
+	{ "echo canceller 400ms tail len", OP_GET_PUT, K8|K16, &ec_create_400},
+	{ "echo canceller 500ms tail len", OP_GET_PUT, K8|K16, &ec_create_500},
+	{ "echo canceller 512ms tail len", OP_GET_PUT, K8|K16, &ec_create_512},
+	{ "echo canceller 600ms tail len", OP_GET_PUT, K8|K16, &ec_create_600},
+	{ "echo canceller 800ms tail len", OP_GET_PUT, K8|K16, &ec_create_800},
+	{ "echo suppressor 100ms tail len", OP_GET_PUT, K8|K16, &es_create_100},
+	{ "echo suppressor 128ms tail len", OP_GET_PUT, K8|K16, &es_create_128},
+	{ "echo suppressor 200ms tail len", OP_GET_PUT, K8|K16, &es_create_200},
+	{ "echo suppressor 256ms tail len", OP_GET_PUT, K8|K16, &es_create_256},
+	{ "echo suppressor 400ms tail len", OP_GET_PUT, K8|K16, &es_create_400},
+	{ "echo suppressor 500ms tail len", OP_GET_PUT, K8|K16, &es_create_500},
+	{ "echo suppressor 512ms tail len", OP_GET_PUT, K8|K16, &es_create_512},
+	{ "echo suppressor 600ms tail len", OP_GET_PUT, K8|K16, &es_create_600},
+	{ "echo suppressor 800ms tail len", OP_GET_PUT, K8|K16, &es_create_800},
+	{ "tone generator with single freq", OP_GET, K8|K16, &create_tonegen1},
+	{ "tone generator with dual freq", OP_GET, K8|K16, &create_tonegen2},
+#if PJMEDIA_HAS_G711_CODEC
+	{ "codec encode/decode - G.711", OP_PUT, K8, &g711_encode_decode},
+#endif
+#if PJMEDIA_HAS_G722_CODEC
+	{ "codec encode/decode - G.722", OP_PUT, K16, &g722_encode_decode},
+#endif
+#if PJMEDIA_HAS_GSM_CODEC
+	{ "codec encode/decode - GSM", OP_PUT, K8, &gsm_encode_decode},
+#endif
+#if PJMEDIA_HAS_ILBC_CODEC
+	{ "codec encode/decode - iLBC", OP_PUT, K8, &ilbc_encode_decode},
+#endif
+#if PJMEDIA_HAS_SPEEX_CODEC
+	{ "codec encode/decode - Speex 8Khz", OP_PUT, K8, &speex8_encode_decode},
+	{ "codec encode/decode - Speex 16Khz", OP_PUT, K16, &speex16_encode_decode},
+#endif
+#if PJMEDIA_HAS_G7221_CODEC
+	{ "codec encode/decode - G.722.1", OP_PUT, K16, &g7221_encode_decode},
+	{ "codec encode/decode - G.722.1c", OP_PUT, K32, &g7221c_encode_decode},
+#endif
+#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC
+	{ "codec encode/decode - AMR-NB", OP_PUT, K8, &amr_encode_decode},
+#endif
+#if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC
+	{ "codec encode/decode - AMR-WB", OP_PUT, K16, &amrwb_encode_decode},
+#endif
+#if PJMEDIA_HAS_L16_CODEC
+	{ "codec encode/decode - L16/8000/1", OP_PUT, K8, &l16_8_encode_decode},
+	{ "codec encode/decode - L16/16000/1", OP_PUT, K16, &l16_16_encode_decode},
+#endif
+#if PJMEDIA_HAS_G711_CODEC
+	{ "stream TX/RX - G.711", OP_PUT_GET, K8, &create_stream_pcmu},
+	{ "stream TX/RX - G.711 SRTP 32bit", OP_PUT_GET, K8, &create_stream_pcmu_srtp32_no_auth},
+	{ "stream TX/RX - G.711 SRTP 32bit +auth", OP_PUT_GET, K8, &create_stream_pcmu_srtp32_with_auth},
+	{ "stream TX/RX - G.711 SRTP 80bit", OP_PUT_GET, K8, &create_stream_pcmu_srtp80_no_auth},
+	{ "stream TX/RX - G.711 SRTP 80bit +auth", OP_PUT_GET, K8, &create_stream_pcmu_srtp80_with_auth},
+#endif
+#if PJMEDIA_HAS_G722_CODEC
+	{ "stream TX/RX - G.722", OP_PUT_GET, K16, &create_stream_g722},
+#endif
+#if PJMEDIA_HAS_GSM_CODEC
+	{ "stream TX/RX - GSM", OP_PUT_GET, K8, &create_stream_gsm},
+	{ "stream TX/RX - GSM SRTP 32bit", OP_PUT_GET, K8, &create_stream_gsm_srtp32_no_auth},
+	{ "stream TX/RX - GSM SRTP 32bit + auth", OP_PUT_GET, K8, &create_stream_gsm_srtp32_with_auth},
+	{ "stream TX/RX - GSM SRTP 80bit", OP_PUT_GET, K8, &create_stream_gsm_srtp80_no_auth},
+	{ "stream TX/RX - GSM SRTP 80bit + auth", OP_PUT_GET, K8, &create_stream_gsm_srtp80_with_auth},
+#endif
+#if PJMEDIA_HAS_G7221_CODEC
+	{ "stream TX/RX - G.722.1", OP_PUT_GET, K16, &create_stream_g7221},
+	{ "stream TX/RX - G.722.1c", OP_PUT_GET, K32, &create_stream_g7221c},
+#endif
+#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC
+	{ "stream TX/RX - AMR-NB", OP_PUT_GET, K8, &create_stream_amr},
+#endif
+#if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC
+	{ "stream TX/RX - AMR-WB", OP_PUT_GET, K16, &create_stream_amrwb},
+#endif
+    };
+
+    unsigned i, c, k[3] = {K8, K16, K32}, clock_rates[3] = {8000, 16000, 32000};
+
+    PJ_LOG(3,(THIS_FILE, "MIPS test, with CPU=%dMhz, %6.1f MIPS", CPU_MHZ, CPU_IPS / 1000000));
+    PJ_LOG(3,(THIS_FILE, "Clock  Item                                      Time     CPU    MIPS"));
+    PJ_LOG(3,(THIS_FILE, " Rate                                           (usec)    (%%)       "));
+    PJ_LOG(3,(THIS_FILE, "----------------------------------------------------------------------"));
+
+    for (c=0; c<PJ_ARRAY_SIZE(clock_rates); ++c) {
+	for (i=0; i<PJ_ARRAY_SIZE(entries); ++i) {
+	    enum 
+	    {
+		RETRY	= 5,	/* number of test retries */
+	    };
+	    struct test_entry *e = &entries[i];
+	    pj_timestamp times[RETRY], tzero;
+	    int usec;
+	    float cpu_pct, mips_val;
+	    unsigned j, clock_rate = clock_rates[c];
+
+	    if ((e->valid_clock_rate & k[c]) == 0)
+		continue;
+
+	    /* Run test */
+	    for (j=0; j<RETRY; ++j) {
+		pj_thread_sleep(1);
+		times[j] = run_entry(clock_rate, e);
+	    }
+
+	    /* Sort ascending */
+	    for (j=0; j<RETRY; ++j) {
+		unsigned k;
+		for (k=j+1; k<RETRY; ++k) {
+		    if (times[k].u64 < times[j].u64) {
+			pj_timestamp tmp = times[j];
+			times[j] = times[k];
+			times[k] = tmp;
+		    }
+		}
+	    }
+
+	    /* Calculate usec elapsed as average of two best times */
+	    tzero.u32.hi = tzero.u32.lo = 0;
+	    usec = (pj_elapsed_usec(&tzero, &times[0]) + 
+		    pj_elapsed_usec(&tzero, &times[1])) / 2;
+
+	    usec = usec / (DURATION / 1000);
+
+	    mips_val = (float)(CPU_IPS * usec / 1000000.0 / 1000000);
+	    cpu_pct = (float)(100.0 * usec / 1000000);
+	    PJ_LOG(3,(THIS_FILE, "%2dKHz %-38s % 8d %8.3f %7.2f", 
+		      clock_rate/1000, e->title, usec, cpu_pct, mips_val));
+
+	}
+    }
+
+    return 0;
+}
+
+
+
diff --git a/jni/pjproject-android/.svn/pristine/66/666b05e80f4686beef7e447797e2bd1f74bdbe5c.svn-base b/jni/pjproject-android/.svn/pristine/66/666b05e80f4686beef7e447797e2bd1f74bdbe5c.svn-base
new file mode 100644
index 0000000..deb0436
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/666b05e80f4686beef7e447797e2bd1f74bdbe5c.svn-base
@@ -0,0 +1,1353 @@
+/* $Id$ */

+/*

+ * Copyright (C) 2010 Teluu Inc. (http://www.teluu.com)

+ *

+ * This program is free software; you can redistribute it and/or modify

+ * it under the terms of the GNU General Public License as published by

+ * the Free Software Foundation; either version 2 of the License, or

+ * (at your option) any later version.

+ *

+ * This program is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

+ * GNU General Public License for more details.

+ *

+ * You should have received a copy of the GNU General Public License

+ * along with this program; if not, write to the Free Software

+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

+ */

+

+#include <pjlib-util/cli_imp.h>

+#include <pj/assert.h>

+#include <pj/errno.h>

+#include <pj/except.h>

+#include <pj/hash.h>

+#include <pj/os.h>

+#include <pj/pool.h>

+#include <pj/string.h>

+#include <pjlib-util/errno.h>

+#include <pjlib-util/scanner.h>

+#include <pjlib-util/xml.h>

+

+#define CMD_HASH_TABLE_SIZE 63	/* Hash table size */

+

+#define CLI_CMD_CHANGE_LOG  30000

+#define CLI_CMD_EXIT        30001

+

+#define MAX_CMD_HASH_NAME_LENGTH 64

+#define MAX_CMD_ID_LENGTH 16

+

+#if 1

+    /* Enable some tracing */

+    #define THIS_FILE   "cli.c"

+    #define TRACE_(arg)	PJ_LOG(3,arg)

+#else

+    #define TRACE_(arg)

+#endif

+

+/**

+ * This structure describes the full specification of a CLI command. A CLI

+ * command mainly consists of the name of the command, zero or more arguments,

+ * and a callback function to be called to execute the command.

+ *

+ * Application can create this specification by forming an XML document and

+ * calling pj_cli_add_cmd_from_xml() to instantiate the spec. A sample XML

+ * document containing a command spec is as follows:

+ *

+ \verbatim

+  <CMD name='makecall' id='101' sc='m,mc' desc='Make outgoing call'>

+      <ARGS>

+	  <ARG name='target' type='text' desc='The destination'/>

+      </ARGS>

+  </CMD>

+ \endverbatim

+ */

+struct pj_cli_cmd_spec

+{

+    /**

+     * To make list of child cmds.

+     */

+    PJ_DECL_LIST_MEMBER(struct pj_cli_cmd_spec);

+

+    /**

+     * Command ID assigned to this command by the application during command

+     * creation. If this value is PJ_CLI_CMD_ID_GROUP (-2), then this is

+     * a command group and it can't be executed.

+     */

+    pj_cli_cmd_id id;

+

+    /**

+     * The command name.

+     */

+    pj_str_t name;

+

+    /**

+     * The full description of the command.

+     */

+    pj_str_t desc;

+

+    /**

+     * Number of optional shortcuts

+     */

+    unsigned sc_cnt;

+

+    /**

+     * Optional array of shortcuts, if any. Shortcut is a short name version

+     * of the command. If the command doesn't have any shortcuts, this

+     * will be initialized to NULL.

+     */

+    pj_str_t *sc;

+

+    /**

+     * The command handler, to be executed when a command matching this command

+     * specification is invoked by the end user. The value may be NULL if this

+     * is a command group.

+     */

+    pj_cli_cmd_handler handler;

+

+    /**

+     * Number of arguments.

+     */

+    unsigned arg_cnt;

+

+    /**

+     * Array of arguments.

+     */

+    pj_cli_arg_spec *arg;

+

+    /**

+     * Child commands, if any. A command will only have subcommands if it is

+     * a group. If the command doesn't have subcommands, this field will be

+     * initialized with NULL.

+     */

+    pj_cli_cmd_spec *sub_cmd;

+};

+

+struct pj_cli_t

+{

+    pj_pool_t	       *pool;           /* Pool to allocate memory from */

+    pj_cli_cfg          cfg;            /* CLI configuration */

+    pj_cli_cmd_spec     root;           /* Root of command tree structure */

+    pj_cli_front_end    fe_head;        /* List of front-ends */

+    pj_hash_table_t    *cmd_name_hash;  /* Command name hash table, this will 

+					   include the command name and shortcut 

+					   as hash key */

+    pj_hash_table_t    *cmd_id_hash;    /* Command id hash table */

+

+    pj_bool_t           is_quitting;

+    pj_bool_t           is_restarting;

+};

+

+/**

+ * Reserved command id constants.

+ */

+typedef enum pj_cli_std_cmd_id

+{

+    /**

+     * Constant to indicate an invalid command id.

+     */

+    PJ_CLI_INVALID_CMD_ID = -1,

+

+    /**

+     * A special command id to indicate that a command id denotes

+     * a command group.

+     */

+    PJ_CLI_CMD_ID_GROUP = -2

+

+} pj_cli_std_cmd_id;

+

+/**

+ * This describes the type of an argument (pj_cli_arg_spec).

+ */

+typedef enum pj_cli_arg_type

+{

+    /**

+     * Unformatted string.

+     */

+    PJ_CLI_ARG_TEXT,

+

+    /**

+     * An integral number.

+     */

+    PJ_CLI_ARG_INT,

+

+    /**

+     * Choice type

+    */

+    PJ_CLI_ARG_CHOICE

+

+} pj_cli_arg_type;

+

+struct arg_type

+{

+    const pj_str_t msg;

+} arg_type[3] = 

+{

+    {{"Text", 4}},

+    {{"Int", 3}},

+    {{"Choice", 6}}

+};

+

+/**

+ * This structure describe the specification of a command argument.

+ */

+struct pj_cli_arg_spec

+{

+    /**

+     * Argument id

+     */

+    pj_cli_arg_id id;

+

+    /**

+     * Argument name.

+     */

+    pj_str_t name;

+

+    /**

+     * Helpful description of the argument. This text will be used when

+     * displaying help texts for the command/argument.

+     */

+    pj_str_t desc;

+

+    /**

+     * Argument type, which will be used for rendering the argument and

+     * to perform basic validation against an input value.

+     */

+    pj_cli_arg_type type;

+

+    /**

+     * Argument status

+     */

+    pj_bool_t optional;

+

+    /**

+     * Validate choice values

+     */

+    pj_bool_t validate;

+

+    /**

+     * Static Choice Values count

+     */

+    unsigned stat_choice_cnt; 

+

+    /**

+     * Static Choice Values

+     */

+    pj_cli_arg_choice_val *stat_choice_val; 

+

+    /**

+     * Argument callback to get the valid values

+     */

+    pj_cli_get_dyn_choice get_dyn_choice;

+

+};

+

+/**

+ * This describe the parse mode of the command line

+ */

+typedef enum pj_cli_parse_mode {

+    PARSE_NONE,

+    PARSE_COMPLETION,	/* Complete the command line */

+    PARSE_NEXT_AVAIL,   /* Find the next available command line */

+    PARSE_EXEC		/* Exec the command line */

+} pj_cli_parse_mode;

+

+/** 

+ * This is used to get the matched command/argument from the 

+ * command/argument structure.

+ * 

+ * @param sess		The session on which the command is execute on.

+ * @param cmd		The active command.

+ * @param cmd_val	The command value to match.

+ * @param argc		The number of argument that the 

+ *			current active command have.

+ * @param pool		The memory pool to allocate memory.

+ * @param get_cmd	Set true to search matching command from sub command.

+ * @param parse_mode	The parse mode.

+ * @param p_cmd		The command that mathes the command value.

+ * @param info		The output information containing any hints for 

+ *			matching command/arg.

+ * @return		This function return the status of the 

+ *			matching process.Please see the return value

+ * 			of pj_cli_sess_parse() for possible return values.

+ */

+static pj_status_t get_available_cmds(pj_cli_sess *sess,

+				      pj_cli_cmd_spec *cmd, 

+				      pj_str_t *cmd_val,

+				      unsigned argc,

+				      pj_pool_t *pool,

+				      pj_bool_t get_cmd,

+				      pj_cli_parse_mode parse_mode,

+				      pj_cli_cmd_spec **p_cmd,

+				      pj_cli_exec_info *info);

+

+PJ_DEF(pj_cli_cmd_id) pj_cli_get_cmd_id(const pj_cli_cmd_spec *cmd)

+{

+    return cmd->id;

+}

+

+PJ_DEF(void) pj_cli_cfg_default(pj_cli_cfg *param)

+{

+    pj_assert(param);

+    pj_bzero(param, sizeof(*param));

+    pj_strset2(&param->name, "");

+}

+

+PJ_DEF(void) pj_cli_exec_info_default(pj_cli_exec_info *param)

+{

+    pj_assert(param);

+    pj_bzero(param, sizeof(*param));

+    param->err_pos = -1;

+    param->cmd_id = PJ_CLI_INVALID_CMD_ID;

+    param->cmd_ret = PJ_SUCCESS;

+}

+

+PJ_DEF(void) pj_cli_write_log(pj_cli_t *cli,

+                              int level,

+                              const char *buffer,

+                              int len)

+{

+    struct pj_cli_front_end *fe;

+

+    pj_assert(cli);

+

+    fe = cli->fe_head.next;

+    while (fe != &cli->fe_head) {

+        if (fe->op && fe->op->on_write_log)

+            (*fe->op->on_write_log)(fe, level, buffer, len);

+        fe = fe->next;

+    }

+}

+

+PJ_DEF(void) pj_cli_sess_write_msg(pj_cli_sess *sess,                               

+				   const char *buffer,

+				   pj_size_t len)

+{

+    struct pj_cli_front_end *fe;

+

+    pj_assert(sess);

+

+    fe = sess->fe;

+    if (fe->op && fe->op->on_write_log)

+        (*fe->op->on_write_log)(fe, 0, buffer, len);

+}

+

+/* Command handler */

+static pj_status_t cmd_handler(pj_cli_cmd_val *cval)

+{

+    unsigned level;

+

+    switch(cval->cmd->id) {

+    case CLI_CMD_CHANGE_LOG:

+        level = pj_strtoul(&cval->argv[1]);

+        if (!level && cval->argv[1].slen > 0 && (cval->argv[1].ptr[0] < '0' ||

+            cval->argv[1].ptr[0] > '9'))

+	{

+            return PJ_CLI_EINVARG;

+	}

+        cval->sess->log_level = level;

+        return PJ_SUCCESS;

+    case CLI_CMD_EXIT:

+        pj_cli_sess_end_session(cval->sess);

+        return PJ_CLI_EEXIT;

+    default:

+        return PJ_SUCCESS;

+    }

+}

+

+PJ_DEF(pj_status_t) pj_cli_create(pj_cli_cfg *cfg,

+                                  pj_cli_t **p_cli)

+{

+    pj_pool_t *pool;

+    pj_cli_t *cli;    

+    unsigned i;

+

+    /* This is an example of the command structure */

+    char* cmd_xmls[] = {

+     "<CMD name='log' id='30000' sc='' desc='Change log level'>"

+     "    <ARG name='level' type='int' optional='0' desc='Log level'/>"

+     "</CMD>",     

+     "<CMD name='exit' id='30001' sc='' desc='Exit session'>"     

+     "</CMD>",

+    };

+

+    PJ_ASSERT_RETURN(cfg && cfg->pf && p_cli, PJ_EINVAL);

+

+    pool = pj_pool_create(cfg->pf, "cli", PJ_CLI_POOL_SIZE, 

+                          PJ_CLI_POOL_INC, NULL);

+    if (!pool)

+        return PJ_ENOMEM;

+    cli = PJ_POOL_ZALLOC_T(pool, struct pj_cli_t);

+

+    pj_memcpy(&cli->cfg, cfg, sizeof(*cfg));

+    cli->pool = pool;

+    pj_list_init(&cli->fe_head);

+

+    cli->cmd_name_hash = pj_hash_create(pool, CMD_HASH_TABLE_SIZE);

+    cli->cmd_id_hash = pj_hash_create(pool, CMD_HASH_TABLE_SIZE);

+

+    cli->root.sub_cmd = PJ_POOL_ZALLOC_T(pool, pj_cli_cmd_spec);

+    pj_list_init(cli->root.sub_cmd);

+

+    /* Register some standard commands. */

+    for (i = 0; i < sizeof(cmd_xmls)/sizeof(cmd_xmls[0]); i++) {

+        pj_str_t xml = pj_str(cmd_xmls[i]);

+

+        if (pj_cli_add_cmd_from_xml(cli, NULL, &xml, 

+				    &cmd_handler, NULL, NULL) != PJ_SUCCESS) 

+	{

+            TRACE_((THIS_FILE, "Failed to add command #%d", i));

+	}

+    }

+

+    *p_cli = cli;

+

+    return PJ_SUCCESS;

+}

+

+PJ_DEF(pj_cli_cfg*) pj_cli_get_param(pj_cli_t *cli)

+{

+    PJ_ASSERT_RETURN(cli, NULL);

+

+    return &cli->cfg;

+}

+

+PJ_DEF(void) pj_cli_register_front_end(pj_cli_t *cli,

+                                       pj_cli_front_end *fe)

+{

+    pj_list_push_back(&cli->fe_head, fe);

+}

+

+PJ_DEF(void) pj_cli_quit(pj_cli_t *cli, pj_cli_sess *req,

+			 pj_bool_t restart)

+{

+    pj_cli_front_end *fe;

+

+    pj_assert(cli);

+    if (cli->is_quitting)

+	return;

+

+    cli->is_quitting = PJ_TRUE;

+    cli->is_restarting = restart;

+

+    fe = cli->fe_head.next;

+    while (fe != &cli->fe_head) {

+        if (fe->op && fe->op->on_quit)

+            (*fe->op->on_quit)(fe, req);

+        fe = fe->next;

+    }

+}

+

+PJ_DEF(pj_bool_t) pj_cli_is_quitting(pj_cli_t *cli)

+{

+    PJ_ASSERT_RETURN(cli, PJ_FALSE);

+

+    return cli->is_quitting;

+}

+

+PJ_DEF(pj_bool_t) pj_cli_is_restarting(pj_cli_t *cli)

+{

+    PJ_ASSERT_RETURN(cli, PJ_FALSE);

+

+    return cli->is_restarting;

+}

+

+PJ_DEF(void) pj_cli_destroy(pj_cli_t *cli)

+{

+    pj_cli_front_end *fe;

+

+    if (!cli)

+	return;

+

+    if (!pj_cli_is_quitting(cli))

+        pj_cli_quit(cli, NULL, PJ_FALSE);

+

+    fe = cli->fe_head.next;

+    while (fe != &cli->fe_head) {

+        pj_list_erase(fe);

+	if (fe->op && fe->op->on_destroy)

+	    (*fe->op->on_destroy)(fe);

+

+        fe = cli->fe_head.next;

+    }

+    cli->is_quitting = PJ_FALSE;

+    pj_pool_release(cli->pool);

+}

+

+PJ_DEF(void) pj_cli_sess_end_session(pj_cli_sess *sess)

+{

+    pj_assert(sess);

+

+    if (sess->op && sess->op->destroy)

+        (*sess->op->destroy)(sess);

+}

+

+/* Syntax error handler for parser. */

+static void on_syntax_error(pj_scanner *scanner)

+{

+    PJ_UNUSED_ARG(scanner);

+    PJ_THROW(PJ_EINVAL);

+}

+

+/* Get the command from the command hash */

+static pj_cli_cmd_spec *get_cmd_name(const pj_cli_t *cli, 

+				     const pj_cli_cmd_spec *group, 

+				     const pj_str_t *cmd)

+{

+    pj_str_t cmd_val;

+    char cmd_ptr[MAX_CMD_HASH_NAME_LENGTH];

+

+    cmd_val.ptr = cmd_ptr;

+    cmd_val.slen = 0;

+

+    if (group) {

+	char cmd_str[MAX_CMD_ID_LENGTH];

+	pj_ansi_sprintf(cmd_str, "%d", group->id);

+	pj_strcat2(&cmd_val, cmd_str);	

+    }

+    pj_strcat(&cmd_val, cmd);

+    return (pj_cli_cmd_spec *)pj_hash_get(cli->cmd_name_hash, cmd_val.ptr, 

+					  (unsigned)cmd_val.slen, NULL);

+}

+

+/* Add command to the command hash */

+static void add_cmd_name(pj_cli_t *cli, pj_cli_cmd_spec *group, 

+			 pj_cli_cmd_spec *cmd, pj_str_t *cmd_name)

+{

+    pj_str_t cmd_val;

+    pj_str_t add_cmd;

+    char cmd_ptr[MAX_CMD_HASH_NAME_LENGTH];

+

+    cmd_val.ptr = cmd_ptr;

+    cmd_val.slen = 0;

+

+    if (group) {

+	char cmd_str[MAX_CMD_ID_LENGTH];

+	pj_ansi_sprintf(cmd_str, "%d", group->id);

+	pj_strcat2(&cmd_val, cmd_str);	

+    }

+    pj_strcat(&cmd_val, cmd_name);

+    pj_strdup(cli->pool, &add_cmd, &cmd_val);

+    

+    pj_hash_set(cli->pool, cli->cmd_name_hash, cmd_val.ptr, 

+		(unsigned)cmd_val.slen, 0, cmd);

+}

+

+/**

+ * This method is to parse and add the choice type 

+ * argument values to command structure.

+ **/

+static pj_status_t add_choice_node(pj_cli_t *cli,

+				   pj_xml_node *xml_node,

+				   pj_cli_arg_spec *arg,

+				   pj_cli_get_dyn_choice get_choice)

+{

+    pj_xml_node *choice_node;

+    pj_xml_node *sub_node;

+    pj_cli_arg_choice_val choice_values[PJ_CLI_MAX_CHOICE_VAL];

+    pj_status_t status = PJ_SUCCESS;

+

+    sub_node = xml_node;

+    arg->type = PJ_CLI_ARG_CHOICE;

+    arg->get_dyn_choice = get_choice;						

+

+    choice_node = sub_node->node_head.next;

+    while (choice_node != (pj_xml_node*)&sub_node->node_head) {

+	pj_xml_attr *choice_attr;

+	unsigned *stat_cnt = &arg->stat_choice_cnt;

+	pj_cli_arg_choice_val *choice_val = &choice_values[*stat_cnt];		     

+	pj_bzero(choice_val, sizeof(*choice_val));

+

+	choice_attr = choice_node->attr_head.next;

+	while (choice_attr != &choice_node->attr_head) {

+	    if (!pj_stricmp2(&choice_attr->name, "value")) {

+		pj_strassign(&choice_val->value, &choice_attr->value);

+	    } else if (!pj_stricmp2(&choice_attr->name, "desc")) {

+		pj_strassign(&choice_val->desc, &choice_attr->value);

+	    }

+	    choice_attr = choice_attr->next;

+	}		

+	if (++(*stat_cnt) >= PJ_CLI_MAX_CHOICE_VAL)

+	    break;

+	choice_node = choice_node->next;

+    }    

+    if (arg->stat_choice_cnt > 0) {

+        unsigned i;

+

+	arg->stat_choice_val = (pj_cli_arg_choice_val *)

+				pj_pool_zalloc(cli->pool, 

+					       arg->stat_choice_cnt *

+					       sizeof(pj_cli_arg_choice_val));

+

+        for (i = 0; i < arg->stat_choice_cnt; i++) {

+	    pj_strdup(cli->pool, &arg->stat_choice_val[i].value, 

+		      &choice_values[i].value);

+            pj_strdup(cli->pool, &arg->stat_choice_val[i].desc, 

+		      &choice_values[i].desc);            

+        }

+    }

+    return status;

+}

+

+/**

+ * This method is to parse and add the argument attribute to command structure.

+ **/

+static pj_status_t add_arg_node(pj_cli_t *cli,

+				pj_xml_node *xml_node,

+				pj_cli_cmd_spec *cmd,

+				pj_cli_arg_spec *arg,

+				pj_cli_get_dyn_choice get_choice)

+{    

+    pj_xml_attr *attr;

+    pj_status_t status = PJ_SUCCESS;

+    pj_xml_node *sub_node = xml_node;

+

+    if (cmd->arg_cnt >= PJ_CLI_MAX_ARGS)

+	return PJ_CLI_ETOOMANYARGS;

+    

+    pj_bzero(arg, sizeof(*arg));

+    attr = sub_node->attr_head.next;

+    arg->optional = PJ_FALSE;

+    arg->validate = PJ_TRUE;

+    while (attr != &sub_node->attr_head) {	

+	if (!pj_stricmp2(&attr->name, "name")) {

+	    pj_strassign(&arg->name, &attr->value);

+	} else if (!pj_stricmp2(&attr->name, "id")) {

+	    arg->id = pj_strtol(&attr->value);

+	} else if (!pj_stricmp2(&attr->name, "type")) {

+	    if (!pj_stricmp2(&attr->value, "text")) {

+		arg->type = PJ_CLI_ARG_TEXT;

+	    } else if (!pj_stricmp2(&attr->value, "int")) {

+		arg->type = PJ_CLI_ARG_INT;

+	    } else if (!pj_stricmp2(&attr->value, "choice")) {

+		/* Get choice value */

+		add_choice_node(cli, xml_node, arg, get_choice);

+	    } 

+	} else if (!pj_stricmp2(&attr->name, "desc")) {

+	    pj_strassign(&arg->desc, &attr->value);

+	} else if (!pj_stricmp2(&attr->name, "optional")) {

+	    if (!pj_strcmp2(&attr->value, "1")) {

+		arg->optional = PJ_TRUE;

+	    }

+	} else if (!pj_stricmp2(&attr->name, "validate")) {

+	    if (!pj_strcmp2(&attr->value, "1")) {

+		arg->validate = PJ_TRUE;

+	    } else {

+		arg->validate = PJ_FALSE;

+	    }	

+	} 

+	attr = attr->next;

+    }

+    cmd->arg_cnt++;

+    return status;

+}

+

+/**

+ * This method is to parse and add the command attribute to command structure.

+ **/

+static pj_status_t add_cmd_node(pj_cli_t *cli,				  

+				pj_cli_cmd_spec *group,					 

+				pj_xml_node *xml_node,

+				pj_cli_cmd_handler handler,

+				pj_cli_cmd_spec **p_cmd,

+				pj_cli_get_dyn_choice get_choice)

+{

+    pj_xml_node *root = xml_node;

+    pj_xml_attr *attr;

+    pj_xml_node *sub_node;

+    pj_cli_cmd_spec *cmd;

+    pj_cli_arg_spec args[PJ_CLI_MAX_ARGS];

+    pj_str_t sc[PJ_CLI_MAX_SHORTCUTS];

+    pj_status_t status = PJ_SUCCESS;

+

+    if (pj_stricmp2(&root->name, "CMD"))

+        return PJ_EINVAL;

+

+    /* Initialize the command spec */

+    cmd = PJ_POOL_ZALLOC_T(cli->pool, struct pj_cli_cmd_spec);

+    

+    /* Get the command attributes */

+    attr = root->attr_head.next;

+    while (attr != &root->attr_head) {

+        if (!pj_stricmp2(&attr->name, "name")) {

+            pj_strltrim(&attr->value);

+            if (!attr->value.slen || 

+		(get_cmd_name(cli, group, &attr->value)))                

+            {

+                return PJ_CLI_EBADNAME;

+            }

+            pj_strdup(cli->pool, &cmd->name, &attr->value);

+        } else if (!pj_stricmp2(&attr->name, "id")) {	    

+	    pj_bool_t is_valid = PJ_FALSE;

+            if (attr->value.slen) {		

+		pj_cli_cmd_id cmd_id = pj_strtol(&attr->value);

+		if (!pj_hash_get(cli->cmd_id_hash, &cmd_id, 

+		                 sizeof(pj_cli_cmd_id), NULL))

+		    is_valid = PJ_TRUE;

+	    } 

+	    if (!is_valid)

+		return PJ_CLI_EBADID;

+            cmd->id = (pj_cli_cmd_id)pj_strtol(&attr->value);

+        } else if (!pj_stricmp2(&attr->name, "sc")) {

+            pj_scanner scanner;

+            pj_str_t str;

+

+            PJ_USE_EXCEPTION;

+

+            pj_scan_init(&scanner, attr->value.ptr, attr->value.slen,

+                         PJ_SCAN_AUTOSKIP_WS, &on_syntax_error);

+

+            PJ_TRY {

+                while (!pj_scan_is_eof(&scanner)) {

+                    pj_scan_get_until_ch(&scanner, ',', &str);

+                    pj_strrtrim(&str);

+                    if (!pj_scan_is_eof(&scanner))

+                        pj_scan_advance_n(&scanner, 1, PJ_TRUE);

+                    if (!str.slen)

+                        continue;

+

+                    if (cmd->sc_cnt >= PJ_CLI_MAX_SHORTCUTS) {

+                        PJ_THROW(PJ_CLI_ETOOMANYARGS);

+                    }

+                    /* Check whether the shortcuts are already used */

+                    if (get_cmd_name(cli, &cli->root, &str)) {

+                        PJ_THROW(PJ_CLI_EBADNAME);

+                    }

+

+                    pj_strassign(&sc[cmd->sc_cnt++], &str);

+                }

+            }

+            PJ_CATCH_ANY {

+                pj_scan_fini(&scanner);

+                return (PJ_GET_EXCEPTION());

+            }

+            PJ_END;

+            

+        } else if (!pj_stricmp2(&attr->name, "desc")) {

+            pj_strdup(cli->pool, &cmd->desc, &attr->value);

+        }

+        attr = attr->next;

+    }

+

+    /* Get the command childs/arguments */

+    sub_node = root->node_head.next;

+    while (sub_node != (pj_xml_node*)&root->node_head) {

+	if (!pj_stricmp2(&sub_node->name, "CMD")) {

+	    status = add_cmd_node(cli, cmd, sub_node, handler, NULL, 

+				  get_choice);

+	    if (status != PJ_SUCCESS)

+		return status;

+	} else if (!pj_stricmp2(&sub_node->name, "ARG")) {

+	    /* Get argument attribute */

+	    status = add_arg_node(cli, sub_node, 

+			          cmd, &args[cmd->arg_cnt], 

+		                  get_choice);

+

+	    if (status != PJ_SUCCESS)

+		return status;

+        }

+        sub_node = sub_node->next;

+    }

+

+    if (!cmd->name.slen)

+        return PJ_CLI_EBADNAME;

+

+    if (!cmd->id)

+        return PJ_CLI_EBADID;

+

+    if (cmd->arg_cnt) {

+        unsigned i;

+

+        cmd->arg = (pj_cli_arg_spec *)pj_pool_zalloc(cli->pool, cmd->arg_cnt *

+                                                     sizeof(pj_cli_arg_spec));

+	

+        for (i = 0; i < cmd->arg_cnt; i++) {

+            pj_strdup(cli->pool, &cmd->arg[i].name, &args[i].name);

+            pj_strdup(cli->pool, &cmd->arg[i].desc, &args[i].desc);

+	    cmd->arg[i].id = args[i].id;

+            cmd->arg[i].type = args[i].type;

+	    cmd->arg[i].optional = args[i].optional;

+	    cmd->arg[i].validate = args[i].validate;

+	    cmd->arg[i].get_dyn_choice = args[i].get_dyn_choice;

+	    cmd->arg[i].stat_choice_cnt = args[i].stat_choice_cnt;

+	    cmd->arg[i].stat_choice_val = args[i].stat_choice_val;

+        }

+    }

+

+    if (cmd->sc_cnt) {

+        unsigned i;

+

+        cmd->sc = (pj_str_t *)pj_pool_zalloc(cli->pool, cmd->sc_cnt *

+                                             sizeof(pj_str_t));

+        for (i = 0; i < cmd->sc_cnt; i++) {

+            pj_strdup(cli->pool, &cmd->sc[i], &sc[i]);	

+	    /** Add shortcut to root command **/

+	    add_cmd_name(cli, &cli->root, cmd, &sc[i]);

+        }

+    }

+    

+    add_cmd_name(cli, group, cmd, &cmd->name);    

+    pj_hash_set(cli->pool, cli->cmd_id_hash, 

+		&cmd->id, sizeof(pj_cli_cmd_id), 0, cmd);

+

+    cmd->handler = handler;

+

+    if (group) {

+	if (!group->sub_cmd) {

+	    group->sub_cmd = PJ_POOL_ALLOC_T(cli->pool, struct pj_cli_cmd_spec);

+	    pj_list_init(group->sub_cmd);

+	}

+        pj_list_push_back(group->sub_cmd, cmd);

+    } else {

+        pj_list_push_back(cli->root.sub_cmd, cmd);

+    }

+

+    if (p_cmd)

+        *p_cmd = cmd;

+

+    return status;

+}

+

+PJ_DEF(pj_status_t) pj_cli_add_cmd_from_xml(pj_cli_t *cli,

+					    pj_cli_cmd_spec *group,

+                                            const pj_str_t *xml,

+                                            pj_cli_cmd_handler handler,

+                                            pj_cli_cmd_spec **p_cmd, 

+					    pj_cli_get_dyn_choice get_choice)

+{ 

+    pj_pool_t *pool;

+    pj_xml_node *root;

+    pj_status_t status = PJ_SUCCESS;

+    

+    PJ_ASSERT_RETURN(cli && xml, PJ_EINVAL);

+

+    /* Parse the xml */

+    pool = pj_pool_create(cli->cfg.pf, "xml", 1024, 1024, NULL);

+    if (!pool)

+        return PJ_ENOMEM;

+

+    root = pj_xml_parse(pool, xml->ptr, xml->slen);

+    if (!root) {

+	TRACE_((THIS_FILE, "Error: unable to parse XML"));

+	pj_pool_release(pool);

+	return PJ_CLI_EBADXML;

+    }    

+    status = add_cmd_node(cli, group, root, handler, p_cmd, get_choice);

+    pj_pool_release(pool);

+    return status;

+}

+

+PJ_DEF(pj_status_t) pj_cli_sess_parse(pj_cli_sess *sess,

+				      char *cmdline,

+				      pj_cli_cmd_val *val,

+				      pj_pool_t *pool,

+				      pj_cli_exec_info *info)

+{    

+    pj_scanner scanner;

+    pj_str_t str;

+    pj_size_t len;    

+    pj_cli_cmd_spec *cmd;

+    pj_cli_cmd_spec *next_cmd;

+    pj_status_t status = PJ_SUCCESS;

+    pj_cli_parse_mode parse_mode = PARSE_NONE;    

+

+    PJ_USE_EXCEPTION;

+

+    PJ_ASSERT_RETURN(sess && cmdline && val, PJ_EINVAL);

+

+    PJ_UNUSED_ARG(pool);

+

+    str.slen = 0;

+    pj_cli_exec_info_default(info);

+

+    /* Set the parse mode based on the latest char. */

+    len = pj_ansi_strlen(cmdline);

+    if (len > 0 && ((cmdline[len - 1] == '\r')||(cmdline[len - 1] == '\n'))) {

+        cmdline[--len] = 0;

+	parse_mode = PARSE_EXEC;

+    } else if (len > 0 && 

+	       (cmdline[len - 1] == '\t' || cmdline[len - 1] == '?')) 

+    {

+	cmdline[--len] = 0;

+	if (len == 0) {

+	    parse_mode = PARSE_NEXT_AVAIL;

+	} else {

+	    if (cmdline[len - 1] == ' ') 

+		parse_mode = PARSE_NEXT_AVAIL;

+	    else 

+		parse_mode = PARSE_COMPLETION;

+	}

+    }

+    val->argc = 0;

+    info->err_pos = 0;

+    cmd = &sess->fe->cli->root;

+    if (len > 0) {

+	pj_scan_init(&scanner, cmdline, len, PJ_SCAN_AUTOSKIP_WS, 

+		     &on_syntax_error);

+	PJ_TRY {

+	    val->argc = 0;	    

+	    while (!pj_scan_is_eof(&scanner)) {

+		info->err_pos = (int)(scanner.curptr - scanner.begin);

+		if (*scanner.curptr == '\'' || *scanner.curptr == '"' ||

+		    *scanner.curptr == '{')

+		{

+		    pj_scan_get_quotes(&scanner, "'\"{", "'\"}", 3, &str);

+		    /* Remove the quotes */

+		    str.ptr++;

+		    str.slen -= 2;

+		} else {

+		    pj_scan_get_until_chr(&scanner, " \t\r\n", &str);

+		}

+		++val->argc;

+		if (val->argc == PJ_CLI_MAX_ARGS)

+		    PJ_THROW(PJ_CLI_ETOOMANYARGS);		

+		

+		status = get_available_cmds(sess, cmd, &str, val->argc-1, 

+					    pool, PJ_TRUE, parse_mode, 

+					    &next_cmd, info);

+

+		if (status != PJ_SUCCESS)

+		    PJ_THROW(status);

+		

+		if (cmd != next_cmd) {

+		    /* Found new command, set it as the active command */

+		    cmd = next_cmd;

+		    val->argc = 1;

+		    val->cmd = cmd;

+		}

+		if (parse_mode == PARSE_EXEC) 

+		    pj_strassign(&val->argv[val->argc-1], &info->hint->name);

+		else 

+		    pj_strassign(&val->argv[val->argc-1], &str);

+

+	    }            

+	    if (!pj_scan_is_eof(&scanner)) 

+		PJ_THROW(PJ_CLI_EINVARG);

+

+	}

+	PJ_CATCH_ANY {

+	    pj_scan_fini(&scanner);

+	    return PJ_GET_EXCEPTION();

+	}

+	PJ_END;

+    } 

+    

+    if ((parse_mode == PARSE_NEXT_AVAIL) || (parse_mode == PARSE_EXEC)) {

+	/* If exec mode, just get the matching argument */

+	status = get_available_cmds(sess, cmd, NULL, val->argc, pool, 

+				    (parse_mode==PARSE_NEXT_AVAIL), 

+				    parse_mode,

+				    NULL, info);

+	if ((status != PJ_SUCCESS) && (status != PJ_CLI_EINVARG)) {

+	    pj_str_t data = pj_str(cmdline);

+	    pj_strrtrim(&data);

+	    data.ptr[data.slen] = ' ';

+	    data.ptr[data.slen+1] = 0;

+

+	    info->err_pos = (int)pj_ansi_strlen(cmdline);

+	}

+    } 

+   

+    val->sess = sess;

+    return status;

+}

+

+PJ_DECL(pj_status_t) pj_cli_sess_exec(pj_cli_sess *sess,

+				      char *cmdline,

+				      pj_pool_t *pool,

+				      pj_cli_exec_info *info)

+{

+    pj_cli_cmd_val val;

+    pj_status_t status;

+    pj_cli_exec_info einfo;

+    pj_str_t cmd;

+

+    PJ_ASSERT_RETURN(sess && cmdline, PJ_EINVAL);

+

+    PJ_UNUSED_ARG(pool);

+

+    cmd.ptr = cmdline;

+    cmd.slen = pj_ansi_strlen(cmdline);

+

+    if (pj_strtrim(&cmd)->slen == 0)

+	return PJ_SUCCESS;

+

+    if (!info)

+        info = &einfo;

+	

+    status = pj_cli_sess_parse(sess, cmdline, &val, pool, info);

+    if (status != PJ_SUCCESS)

+        return status;

+

+    if ((val.argc > 0) && (val.cmd->handler)) {

+        info->cmd_ret = (*val.cmd->handler)(&val);

+        if (info->cmd_ret == PJ_CLI_EINVARG ||

+            info->cmd_ret == PJ_CLI_EEXIT)

+	{

+            return info->cmd_ret;

+	}

+    }

+

+    return PJ_SUCCESS;

+}

+

+static pj_bool_t hint_inserted(const pj_str_t *name, 

+			       const pj_str_t *desc, 

+			       const pj_str_t *type, 

+			       pj_cli_exec_info *info)

+{

+    unsigned i;

+    for(i=0; i<info->hint_cnt; ++i) {

+	pj_cli_hint_info *hint = &info->hint[i];

+	if ((!pj_strncmp(&hint->name, name, hint->name.slen)) &&

+	    (!pj_strncmp(&hint->desc, desc, hint->desc.slen)) &&

+	    (!pj_strncmp(&hint->type, type, hint->type.slen)))

+	{

+	    return PJ_TRUE;

+	}

+    }

+    return PJ_FALSE;

+}

+

+/** This will insert new hint with the option to check for the same 

+    previous entry **/

+static pj_status_t insert_new_hint2(pj_pool_t *pool, 

+				    pj_bool_t unique_insert,

+				    const pj_str_t *name, 

+				    const pj_str_t *desc, 

+				    const pj_str_t *type, 

+				    pj_cli_exec_info *info)

+{

+    pj_cli_hint_info *hint;

+    PJ_ASSERT_RETURN(pool && info, PJ_EINVAL);

+    PJ_ASSERT_RETURN((info->hint_cnt < PJ_CLI_MAX_HINTS), PJ_EINVAL);

+

+    if ((unique_insert) && (hint_inserted(name, desc, type, info)))

+	return PJ_SUCCESS;

+

+    hint = &info->hint[info->hint_cnt];

+

+    pj_strdup(pool, &hint->name, name);

+

+    if (desc && (desc->slen > 0))  {

+	pj_strdup(pool, &hint->desc, desc);

+    } else {

+	hint->desc.slen = 0;

+    }

+    

+    if (type && (type->slen > 0)) {

+	pj_strdup(pool, &hint->type, type);

+    } else {

+	hint->type.slen = 0;

+    }

+

+    ++info->hint_cnt;    

+    return PJ_SUCCESS;

+}

+

+/** This will insert new hint without checking for the same previous entry **/

+static pj_status_t insert_new_hint(pj_pool_t *pool, 

+				   const pj_str_t *name, 

+				   const pj_str_t *desc, 

+				   const pj_str_t *type, 

+				   pj_cli_exec_info *info)

+{        

+    return insert_new_hint2(pool, PJ_FALSE, name, desc, type, info);

+}

+

+/** This will get a complete/exact match of a command from the cmd hash **/

+static pj_status_t get_comp_match_cmds(const pj_cli_t *cli, 

+				       const pj_cli_cmd_spec *group,

+				       const pj_str_t *cmd_val,	

+				       pj_pool_t *pool, 

+				       pj_cli_cmd_spec **p_cmd,

+				       pj_cli_exec_info *info)

+{

+    pj_cli_cmd_spec *cmd;    

+    PJ_ASSERT_RETURN(cli && group && cmd_val && pool && info, PJ_EINVAL);   

+

+    cmd = get_cmd_name(cli, group, cmd_val);

+

+    if (cmd) {

+	pj_status_t status;    

+	status = insert_new_hint(pool, cmd_val, &cmd->desc, NULL, info);

+

+	if (status != PJ_SUCCESS)

+	    return status;

+

+	*p_cmd = cmd;

+    }

+

+    return PJ_SUCCESS;

+}

+

+/** This method will search for any shortcut with pattern match to the input

+    command. This method should be called from root command, as shortcut could

+    only be executed from root **/

+static pj_status_t get_pattern_match_shortcut(const pj_cli_t *cli,

+					      const pj_str_t *cmd_val,

+					      pj_pool_t *pool, 

+					      pj_cli_cmd_spec **p_cmd,

+					      pj_cli_exec_info *info)

+{

+    pj_hash_iterator_t it_buf, *it;

+    pj_status_t status;

+    PJ_ASSERT_RETURN(cli && pool && cmd_val && info, PJ_EINVAL);

+  

+    it = pj_hash_first(cli->cmd_name_hash, &it_buf);

+    while (it) {

+	unsigned i;

+	pj_cli_cmd_spec *cmd = (pj_cli_cmd_spec *)

+			       pj_hash_this(cli->cmd_name_hash, it);

+

+	PJ_ASSERT_RETURN(cmd, PJ_EINVAL);	    

+	

+	for (i=0; i < cmd->sc_cnt; ++i) {

+	    static const pj_str_t SHORTCUT = {"SC", 2};

+	    pj_str_t *sc = &cmd->sc[i];

+	    PJ_ASSERT_RETURN(sc, PJ_EINVAL);

+

+	    if (!pj_strncmp(sc, cmd_val, cmd_val->slen)) {

+		/** Unique hints needed because cmd hash contain command name

+		    and shortcut referencing to the same command **/

+		status = insert_new_hint2(pool, PJ_TRUE, sc, &cmd->desc, 

+					  &SHORTCUT, info);

+		if (status != PJ_SUCCESS)

+		    return status;

+

+		if (p_cmd)

+		    *p_cmd = cmd;

+	    }

+	}

+	

+	it = pj_hash_next(cli->cmd_name_hash, it);

+    }

+

+    return PJ_SUCCESS;

+}

+

+/** This method will search a pattern match to the input command from the child

+    command list of the current/active command. **/

+static pj_status_t get_pattern_match_cmds(pj_cli_cmd_spec *cmd, 

+					  const pj_str_t *cmd_val,				      

+					  pj_pool_t *pool, 

+					  pj_cli_cmd_spec **p_cmd, 

+					  pj_cli_parse_mode parse_mode,

+					  pj_cli_exec_info *info)

+{

+    pj_status_t status;

+    PJ_ASSERT_RETURN(cmd && pool && info && cmd_val, PJ_EINVAL);   

+

+    if (p_cmd)

+	*p_cmd = cmd;

+

+    /* Get matching command */

+    if (cmd->sub_cmd) {

+	pj_cli_cmd_spec *child_cmd = cmd->sub_cmd->next;

+	while (child_cmd != cmd->sub_cmd) {

+	    pj_bool_t found = PJ_FALSE;

+	    if (!pj_strncmp(&child_cmd->name, cmd_val, cmd_val->slen)) {		

+		status = insert_new_hint(pool, &child_cmd->name, 

+					 &child_cmd->desc, NULL, info);

+		if (status != PJ_SUCCESS)

+		    return status;

+

+		found = PJ_TRUE;

+	    }

+	    if (found) {

+		if (parse_mode == PARSE_NEXT_AVAIL) {

+		    /** Only insert shortcut on next available commands mode **/

+		    unsigned i;

+		    for (i=0; i < child_cmd->sc_cnt; ++i) {

+			static const pj_str_t SHORTCUT = {"SC", 2};

+			pj_str_t *sc = &child_cmd->sc[i];

+			PJ_ASSERT_RETURN(sc, PJ_EINVAL);

+

+			status = insert_new_hint(pool, sc, 

+						 &child_cmd->desc, &SHORTCUT, 

+						 info);

+			if (status != PJ_SUCCESS)

+			    return status;

+		    }

+		}

+

+		if (p_cmd)

+		    *p_cmd = child_cmd;			    

+	    }	

+	    child_cmd = child_cmd->next;

+	}

+    }

+    return PJ_SUCCESS;

+}

+

+/** This will match the arguments passed to the command with the argument list

+    of the specified command list. **/

+static pj_status_t get_match_args(pj_cli_sess *sess,

+				  pj_cli_cmd_spec *cmd, 

+				  const pj_str_t *cmd_val,

+				  unsigned argc,

+				  pj_pool_t *pool, 

+				  pj_cli_parse_mode parse_mode,

+				  pj_cli_exec_info *info)

+{

+    pj_cli_arg_spec *arg;

+    pj_status_t status = PJ_SUCCESS;

+

+    PJ_ASSERT_RETURN(cmd && pool && cmd_val && info, PJ_EINVAL);

+

+    if ((argc > cmd->arg_cnt) && (!cmd->sub_cmd)) {

+	if (cmd_val->slen > 0)

+	    return PJ_CLI_ETOOMANYARGS;

+	else

+	    return PJ_SUCCESS;

+    }

+

+    if (cmd->arg_cnt > 0) {

+	arg = &cmd->arg[argc-1];

+	PJ_ASSERT_RETURN(arg, PJ_EINVAL);

+	if (arg->type == PJ_CLI_ARG_CHOICE) {	    

+	    unsigned j;	    	    

+

+	    if ((parse_mode == PARSE_EXEC) && (!arg->validate)) {

+		/* If no validation needed, then insert the values */

+		status = insert_new_hint(pool, cmd_val, NULL, NULL, info);		

+		return status;

+	    }

+

+	    for (j=0; j < arg->stat_choice_cnt; ++j) {

+		pj_cli_arg_choice_val *choice_val = &arg->stat_choice_val[j];		

+    	    

+		PJ_ASSERT_RETURN(choice_val, PJ_EINVAL);		

+    	    

+		if (!pj_strncmp(&choice_val->value, cmd_val, cmd_val->slen)) {		    

+		    status = insert_new_hint(pool, 

+					     &choice_val->value, 

+					     &choice_val->desc, 

+					     &arg_type[PJ_CLI_ARG_CHOICE].msg, 

+					     info);

+		    if (status != PJ_SUCCESS)

+			return status;		    

+		}

+	    }

+	    if (arg->get_dyn_choice) {

+		pj_cli_dyn_choice_param dyn_choice_param;

+		static pj_str_t choice_str = {"choice", 6};

+

+		/* Get the dynamic choice values */	    

+		dyn_choice_param.sess = sess;

+		dyn_choice_param.cmd = cmd;

+		dyn_choice_param.arg_id = arg->id;

+		dyn_choice_param.max_cnt = PJ_CLI_MAX_CHOICE_VAL;

+		dyn_choice_param.pool = pool;

+		dyn_choice_param.cnt = 0;	    

+

+		(*arg->get_dyn_choice)(&dyn_choice_param);

+		for (j=0; j < dyn_choice_param.cnt; ++j) {

+		    pj_cli_arg_choice_val *choice = &dyn_choice_param.choice[j];

+		    if (!pj_strncmp(&choice->value, cmd_val, cmd_val->slen)) {

+			pj_strassign(&info->hint[info->hint_cnt].name, 

+				     &choice->value);

+			pj_strassign(&info->hint[info->hint_cnt].type, 

+				     &choice_str);

+			pj_strassign(&info->hint[info->hint_cnt].desc, 

+				     &choice->desc);

+			if ((++info->hint_cnt) >= PJ_CLI_MAX_HINTS)

+			    break;

+		    }

+		}

+		if ((info->hint_cnt == 0) && (!arg->optional))

+		    return PJ_CLI_EMISSINGARG;

+	    }

+	} else {

+	    if (cmd_val->slen == 0) {

+		if (info->hint_cnt == 0) {

+		    if (!((parse_mode == PARSE_EXEC) && (arg->optional))) {

+			/* For exec mode,no need to insert hint if optional */

+			status = insert_new_hint(pool, 

+						 &arg->name, 

+				  	         &arg->desc, 

+						 &arg_type[arg->type].msg,

+						 info);

+			if (status != PJ_SUCCESS)

+			    return status;

+		    }

+		    if (!arg->optional)

+			return PJ_CLI_EMISSINGARG;

+		} 

+	    } else {

+		return insert_new_hint(pool, cmd_val, NULL, NULL, info);

+	    }

+	}

+    } 

+    return status;

+}

+

+/** This will check for a match of the commands/arguments input. Any match 

+    will be inserted to the hint data. **/

+static pj_status_t get_available_cmds(pj_cli_sess *sess,

+				      pj_cli_cmd_spec *cmd, 

+				      pj_str_t *cmd_val,

+				      unsigned argc,

+				      pj_pool_t *pool,

+				      pj_bool_t get_cmd,

+				      pj_cli_parse_mode parse_mode,

+				      pj_cli_cmd_spec **p_cmd,

+				      pj_cli_exec_info *info)

+{

+    pj_status_t status = PJ_SUCCESS;

+    pj_str_t *prefix;

+    pj_str_t EMPTY_STR = {NULL, 0};

+

+    prefix = cmd_val?(pj_strtrim(cmd_val)):(&EMPTY_STR);

+

+    info->hint_cnt = 0;    

+

+    if (get_cmd) {

+	status = get_comp_match_cmds(sess->fe->cli, cmd, prefix, pool, p_cmd, 

+				     info);

+	if (status != PJ_SUCCESS)

+	    return status;

+	

+	/** If exact match found, then no need to search for pattern match **/

+	if (info->hint_cnt == 0) {

+	    if ((parse_mode != PARSE_NEXT_AVAIL) && 

+		(cmd == &sess->fe->cli->root)) 

+	    {

+		/** Pattern match for shortcut needed on root command only **/

+		status = get_pattern_match_shortcut(sess->fe->cli, prefix, pool,

+						    p_cmd, info);

+

+		if (status != PJ_SUCCESS)

+		    return status;

+	    }

+

+	    status = get_pattern_match_cmds(cmd, prefix, pool, p_cmd, 

+					    parse_mode, info);

+	}

+

+	if (status != PJ_SUCCESS)

+	    return status;

+    }

+

+    if (argc > 0)

+	status = get_match_args(sess, cmd, prefix, argc, 

+			        pool, parse_mode, info);

+

+    if (status == PJ_SUCCESS) {	

+	if (prefix->slen > 0) {

+	    /** If a command entered is not a an empty command, and have a 

+		single match in the command list then it is a valid command **/

+	    if (info->hint_cnt == 0) {

+		status = PJ_CLI_EINVARG;

+	    } else if (info->hint_cnt > 1) {

+		status = PJ_CLI_EAMBIGUOUS;

+	    }

+	} else {

+	    if (info->hint_cnt > 0)

+		status = PJ_CLI_EAMBIGUOUS;

+	}

+    } 

+

+    return status;

+}

+

diff --git a/jni/pjproject-android/.svn/pristine/66/6672fd77ada04ca87b77d162cdbd0a483cc3c07c.svn-base b/jni/pjproject-android/.svn/pristine/66/6672fd77ada04ca87b77d162cdbd0a483cc3c07c.svn-base
new file mode 100644
index 0000000..7de31c9
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/6672fd77ada04ca87b77d162cdbd0a483cc3c07c.svn-base
@@ -0,0 +1,262 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2010 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
+ */
+
+/*
+ * Sample CLI application
+ */
+#include <pjlib-util/cli.h>
+#include <pjlib-util/cli_imp.h>
+#include <pjlib-util/cli_console.h>
+#include <pjlib-util/cli_telnet.h>
+#include <pjlib-util/errno.h>
+#include <pjlib.h>
+
+#define THIS_FILE	"clidemo.c"
+
+/* Set this to 1 if you want to let the system assign a port
+ * for the CLI telnet daemon.
+ * Default: 1
+ */
+#define USE_RANDOM_PORT 1
+
+struct cmd_xml_t {
+    char * xml;
+    pj_cli_cmd_handler handler;
+};
+
+/*
+ * Declaration of system specific main loop, which will be defined in
+ * a separate file.
+ */
+pj_status_t app_main(pj_cli_t *cli);
+
+#define print_msg(arg) \
+    do { \
+        unsigned d = pj_log_get_decor(); \
+        pj_log_set_decor(0); \
+        PJ_LOG(1, arg); \
+        pj_log_set_decor(d); \
+    } while (0)
+
+static pj_cli_t *cli = NULL;
+
+/* Handler for sayhello command */
+static pj_status_t sayhello(pj_cli_cmd_val *cval)
+{
+    print_msg(("", "Hello %.*s!\r\n", 
+              (int)cval->argv[1].slen, cval->argv[1].ptr));
+    return PJ_SUCCESS;
+}
+
+/* Handler for saybye command */
+static pj_status_t saybye(pj_cli_cmd_val *cval)
+{
+    print_msg(("", "Bye %.*s!\r\n",
+              (int)cval->argv[1].slen, cval->argv[1].ptr));
+    return PJ_SUCCESS;
+}
+
+/* Handler for say command */
+static pj_status_t say(pj_cli_cmd_val *cval)
+{
+    print_msg(("", "%.*s %.*s\r\n",
+              (int)cval->argv[1].slen, cval->argv[1].ptr,
+              (int)cval->argv[2].slen, cval->argv[2].ptr));
+    return PJ_SUCCESS;
+}
+
+static pj_status_t quit_app(pj_cli_cmd_val *cval)
+{
+    PJ_UNUSED_ARG(cval);
+    pj_cli_quit(cval->sess->fe->cli, cval->sess, PJ_FALSE);
+
+    return PJ_CLI_EEXIT;
+}
+
+static void get_codec_list(pj_cli_dyn_choice_param *param)
+{
+    if (param->arg_id == 3) {
+	param->cnt = 2;
+	pj_strdup2(param->pool, &param->choice[0].value, "iLbc");
+	pj_strdup2(param->pool, &param->choice[0].desc, "iLbc Codec");
+	pj_strdup2(param->pool, &param->choice[1].value, "g729");
+	pj_strdup2(param->pool, &param->choice[1].desc, "g729 Codec");
+    }
+}
+
+static struct cmd_xml_t cmd_xmls[] = {
+    {"<CMD name='sayhello' id='1' sc='  ,h , ,, sh  ,' desc='Will say hello'>"
+     "    <ARG name='whom' type='text' desc='Whom to say hello to'/>"
+     "</CMD>",
+     &sayhello},
+    {"<CMD name='saybye' id='2' sc='b,sb' desc='Will say bye'>"
+     "    <ARG name='whom' type='text' desc='Whom to say bye to'/>"
+     "</CMD>",
+     &saybye},
+    {"<CMD name='saymsg' id='3' sc='s' desc='Will say something'>"
+     "    <ARG name='msg' type='text' desc='Message to say'/>"
+     "    <ARG name='whom' type='text' desc='Whom to say to'/>"
+     "</CMD>",
+     &say},
+    {"<CMD name='vid' id='1' desc='Video Command'>"
+     "   <CMD name='help' id='2' desc='Show Help' />"
+     "   <CMD name='enable' id='3' desc='Enable Video' />"
+     "   <CMD name='disable' id='4' desc='Disable Video' />"
+     "   <CMD name='call' id='5' desc='Video call' >"
+     "            <CMD name='add' id='6' desc='Add Call' />"
+     "            <CMD name='cap' id='7' desc='Capture Call' >"
+     "               <ARG name='streamno' type='int' desc='Stream No' id='1'/>"
+     "               <ARG name='devid' type='int' desc='Device Id' id='2'/>"
+     "            </CMD>"
+     "   </CMD>"     
+     "</CMD>",
+     NULL},
+    {"<CMD name='disable_codec' id='8' desc='Disable codec'>"
+     "	<ARG name='codec_list' type='choice' id='3' desc='Codec list'>"
+     "	    <CHOICE value='g711' desc='G711 Codec'/>"
+     "	    <CHOICE value='g722' desc='G722 Codec'/>"
+     "	</ARG>"
+     "</CMD>",
+     NULL},
+    {"<CMD name='quit_app' id='999' sc='qa' desc='Quit the application'>"
+     "</CMD>",
+     &quit_app},
+};
+
+static void log_writer(int level, const char *buffer, int len)
+{
+    if (cli)
+        pj_cli_write_log(cli, level, buffer, len);
+}
+
+int main()
+{
+    pj_caching_pool cp;
+    pj_cli_cfg cli_cfg;
+    pj_cli_telnet_cfg tcfg;
+    pj_str_t xml;
+    pj_status_t status;
+    int i;        
+
+    pj_init();
+    pj_caching_pool_init(&cp, NULL, 0);
+    pjlib_util_init();
+
+    /*
+     * Create CLI app.
+     */
+    pj_cli_cfg_default(&cli_cfg);
+    cli_cfg.pf = &cp.factory;
+    cli_cfg.name = pj_str("mycliapp");
+    cli_cfg.title = pj_str("My CLI Application");
+
+    status = pj_cli_create(&cli_cfg, &cli);
+    if (status != PJ_SUCCESS)
+	goto on_return;
+
+    /*
+     * Register some commands.
+     */
+    for (i = 0; i < sizeof(cmd_xmls)/sizeof(cmd_xmls[0]); i++) {
+        xml = pj_str(cmd_xmls[i].xml);	
+        status = pj_cli_add_cmd_from_xml(cli, NULL, &xml, 
+	    cmd_xmls[i].handler, NULL, get_codec_list);
+        if (status != PJ_SUCCESS)
+	    goto on_return;
+    }
+
+    /*
+     * Start telnet daemon
+     */
+    pj_cli_telnet_cfg_default(&tcfg);
+//    tcfg.passwd = pj_str("pjsip");
+#if USE_RANDOM_PORT
+    tcfg.port = 0;
+#else
+    tcfg.port = 2233;
+#endif    
+    tcfg.prompt_str = pj_str("CoolWater% ");
+    status = pj_cli_telnet_create(cli, &tcfg, NULL);
+    if (status != PJ_SUCCESS)
+	goto on_return;
+
+    /*
+     * Run the system specific main loop.
+     */
+    status = app_main(cli);
+
+on_return:
+
+    /*
+     * Destroy
+     */
+    pj_cli_destroy(cli);
+    cli = NULL;
+    pj_caching_pool_destroy(&cp);
+    pj_shutdown();
+
+    return (status != PJ_SUCCESS ? 1 : 0);
+}
+
+
+/*xxxxxxxxxxxxxxxxxxxxxxxxxxxxx main_console.c xxxxxxxxxxxxxxxxxxxxxxxxxxxx */
+/*
+ * Simple implementation of app_main() for console targets
+ */
+pj_status_t app_main(pj_cli_t *cli)
+{
+    pj_status_t status;
+    pj_cli_sess *sess;
+    pj_cli_console_cfg console_cfg;
+
+    pj_cli_console_cfg_default(&console_cfg);
+    console_cfg.prompt_str = pj_str("HotWater> ");
+    
+    /*
+     * Create the console front end
+     */
+    status = pj_cli_console_create(cli, &console_cfg, &sess, NULL);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    pj_log_set_log_func(&log_writer);
+
+    /*
+     * Main loop.
+     */
+    for (;;) {
+	char cmdline[PJ_CLI_MAX_CMDBUF];
+        pj_status_t status;
+
+        status = pj_cli_console_process(sess, &cmdline[0], sizeof(cmdline));
+	if (status != PJ_SUCCESS)
+	    break;
+
+	//pj_ansi_strcpy(cmdline, "sayhello {Teluu Inc.}");	
+	if (status == PJ_CLI_EEXIT) {
+	    /* exit is called */
+	    break;
+	} else if (status != PJ_SUCCESS) {
+	    /* Something wrong with the cmdline */
+	    PJ_PERROR(1,(THIS_FILE, status, "Exec error"));
+	}
+    }
+
+    return PJ_SUCCESS;
+}
diff --git a/jni/pjproject-android/.svn/pristine/66/667a6f789e42db46313cb90fa1ea5b33d36c0552.svn-base b/jni/pjproject-android/.svn/pristine/66/667a6f789e42db46313cb90fa1ea5b33d36c0552.svn-base
new file mode 100644
index 0000000..eef6e3f
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/667a6f789e42db46313cb90fa1ea5b33d36c0552.svn-base
@@ -0,0 +1,35 @@
+/*
+========================================================================
+ Name        : pjsuaApplication.h
+ Author      : nanang
+ Copyright   : Copyright (C) 2013 Teluu Inc. (http://www.teluu.com)
+ Description : 
+========================================================================
+*/
+#ifndef PJSUAAPPLICATION_H
+#define PJSUAAPPLICATION_H
+
+// [[[ begin generated region: do not modify [Generated Includes]
+#include <aknapp.h>
+// ]]] end generated region [Generated Includes]
+
+// [[[ begin generated region: do not modify [Generated Constants]
+const TUid KUidpjsuaApplication = { 0xE44C2D02 };
+// ]]] end generated region [Generated Constants]
+
+/**
+ *
+ * @class	CpjsuaApplication pjsuaApplication.h
+ * @brief	A CAknApplication-derived class is required by the S60 application 
+ *          framework. It is subclassed to create the application's document 
+ *          object.
+ */
+class CpjsuaApplication : public CAknApplication
+	{
+private:
+	TUid AppDllUid() const;
+	CApaDocument* CreateDocumentL();
+	
+	};
+			
+#endif // PJSUAAPPLICATION_H		
diff --git a/jni/pjproject-android/.svn/pristine/66/669af941efc2c87b02626fe8dab666920f49ebf9.svn-base b/jni/pjproject-android/.svn/pristine/66/669af941efc2c87b02626fe8dab666920f49ebf9.svn-base
new file mode 100644
index 0000000..e92369d
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/669af941efc2c87b02626fe8dab666920f49ebf9.svn-base
@@ -0,0 +1,16 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+pjsua = "--null-audio --id=sip:CLIENT --registrar sip:127.0.0.1:$PORT " + \
+	"--auto-update-nat=0"
+
+req1 = sip.RecvfromTransaction("Registration", 200,
+				include=["REGISTER sip"], 
+				exclude=["Authorization"],
+				resp_hdr=["Server: Snake Registrar", "Expires: 221", "Contact: sip:localhost"],
+				expect="registration success"
+			  )
+
+recvfrom_cfg = sip.RecvfromCfg("Simple registration test",
+			       pjsua, [req1])
diff --git a/jni/pjproject-android/.svn/pristine/66/669ebada599eae1afe3c8b91b072bd06f2dd4946.svn-base b/jni/pjproject-android/.svn/pristine/66/669ebada599eae1afe3c8b91b072bd06f2dd4946.svn-base
new file mode 100644
index 0000000..c6e6a6d
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/669ebada599eae1afe3c8b91b072bd06f2dd4946.svn-base
@@ -0,0 +1,1042 @@
+# Doxyfile 1.3-rc3
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = libSRTP
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = 1.3.22
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = 
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, 
+# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en 
+# (Japanese with english messages), Korean, Norwegian, Polish, Portuguese, 
+# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = YES
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these class will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = NO
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show
+# all inherited members of a class in the documentation of that class
+# as if those members were ordinary class members. Constructors,
+# destructors and assignment operators of the base classes will not be
+# shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. It is allowed to use relative paths in the argument list.
+
+STRIP_FROM_PATH        = 
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower case letters. If set to YES upper case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# users are adviced to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments  will behave just like the Qt-style comments (thus requiring an 
+# explict @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF      = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the DETAILS_AT_TOP tag is set to YES then Doxygen 
+# will output the detailed description near the top, like JavaDoc.
+# If set to NO, the detailed description appears after the member 
+# documentation.
+
+DETAILS_AT_TOP         = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# reimplements.
+
+INHERIT_DOCS           = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 3
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consist of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 
+# only. Doxygen will then generate output that is more tailored for C. 
+# For instance some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources 
+# only. Doxygen will then generate output that is more tailored for Java. 
+# For instance namespaces will be presented as packages, qualified scopes 
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text.
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = intro.txt ../include/srtp.h ../crypto/include/crypto_types.h ../crypto/include/err.h ../crypto/include/crypto.h  crypto_kernel.txt 
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
+# *.h++ *.idl *.odl
+
+FILE_PATTERNS          = 
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = 
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
+# that are symbolic links (a Unix filesystem feature) are excluded from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories.
+
+EXCLUDE_PATTERNS       = 
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = 
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.
+
+INPUT_FILTER           = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default) 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = NO
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = 
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = 
+
+# The HTML_STYLESHEET tag can be used to specify a user defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet
+
+HTML_STYLESHEET        = 
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output dir.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non empty doxygen will try to run 
+# the html help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the Html help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = letter 
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = header.tex
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimised for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assigments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_XML           = NO
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed.
+
+PREDEFINED             = 
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse the 
+# parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES tag can be used to specify one or more tagfiles.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or 
+# super classes. Setting the tag to NO turns the diagrams off. Note that this 
+# option is superceded by the HAVE_DOT option below. This is only a fallback. It is 
+# recommended to install and use dot, since it yield more powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found on the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+
+MAX_DOT_GRAPH_WIDTH    = 1024
+
+# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height 
+# (in pixels) of the graphs generated by dot. If a graph becomes larger than 
+# this value, doxygen will try to truncate the graph, so that it fits within 
+# the specified constraint. Beware that most browsers cannot cope with very 
+# large images.
+
+MAX_DOT_GRAPH_HEIGHT   = 1024
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermedate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE           = NO
+
+# The CGI_NAME tag should be the name of the CGI script that 
+# starts the search engine (doxysearch) with the correct parameters. 
+# A script with this name will be generated by doxygen.
+
+CGI_NAME               = search.cgi
+
+# The CGI_URL tag should be the absolute URL to the directory where the 
+# cgi binaries are located. See the documentation of your http daemon for 
+# details.
+
+CGI_URL                = 
+
+# The DOC_URL tag should be the absolute URL to the directory where the 
+# documentation is located. If left blank the absolute path to the 
+# documentation, with file:// prepended to it, will be used.
+
+DOC_URL                = 
+
+# The DOC_ABSPATH tag should be the absolute path to the directory where the 
+# documentation is located. If left blank the directory on the local machine 
+# will be used.
+
+DOC_ABSPATH            = 
+
+# The BIN_ABSPATH tag must point to the directory where the doxysearch binary 
+# is installed.
+
+BIN_ABSPATH            = /usr/local/bin/
+
+# The EXT_DOC_PATHS tag can be used to specify one or more paths to 
+# documentation generated for other projects. This allows doxysearch to search 
+# the documentation for these projects as well.
+
+EXT_DOC_PATHS          = 
diff --git a/jni/pjproject-android/.svn/pristine/66/66afa4af262a222ec9e3e2dffb89b7506bf0fd71.svn-base b/jni/pjproject-android/.svn/pristine/66/66afa4af262a222ec9e3e2dffb89b7506bf0fd71.svn-base
new file mode 100644
index 0000000..47e7123
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/66afa4af262a222ec9e3e2dffb89b7506bf0fd71.svn-base
@@ -0,0 +1,553 @@
+//------------------------------------------------------------------------------

+// File: WXList.h

+//

+// Desc: DirectShow base classes - defines a non-MFC generic template list

+//       class.

+//

+// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.

+//------------------------------------------------------------------------------

+

+

+/* A generic list of pointers to objects.

+   No storage management or copying is done on the objects pointed to.

+   Objectives: avoid using MFC libraries in ndm kernel mode and

+   provide a really useful list type.

+

+   The class is thread safe in that separate threads may add and

+   delete items in the list concurrently although the application

+   must ensure that constructor and destructor access is suitably

+   synchronised. An application can cause deadlock with operations

+   which use two lists by simultaneously calling

+   list1->Operation(list2) and list2->Operation(list1).  So don't!

+

+   The names must not conflict with MFC classes as an application

+   may use both.

+   */

+

+#ifndef __WXLIST__

+#define __WXLIST__

+

+   /* A POSITION represents (in some fashion that's opaque) a cursor

+      on the list that can be set to identify any element.  NULL is

+      a valid value and several operations regard NULL as the position

+      "one step off the end of the list".  (In an n element list there

+      are n+1 places to insert and NULL is that "n+1-th" value).

+      The POSITION of an element in the list is only invalidated if

+      that element is deleted.  Move operations may mean that what

+      was a valid POSITION in one list is now a valid POSITION in

+      a different list.

+

+      Some operations which at first sight are illegal are allowed as

+      harmless no-ops.  For instance RemoveHead is legal on an empty

+      list and it returns NULL.  This allows an atomic way to test if

+      there is an element there, and if so, get it.  The two operations

+      AddTail and RemoveHead thus implement a MONITOR (See Hoare's paper).

+

+      Single element operations return POSITIONs, non-NULL means it worked.

+      whole list operations return a BOOL.  TRUE means it all worked.

+

+      This definition is the same as the POSITION type for MFCs, so we must

+      avoid defining it twice.

+   */

+#ifndef __AFX_H__

+struct __POSITION { int unused; };

+typedef __POSITION* POSITION;

+#endif

+

+const int DEFAULTCACHE = 10;    /* Default node object cache size */

+

+/* A class representing one node in a list.

+   Each node knows a pointer to it's adjacent nodes and also a pointer

+   to the object that it looks after.

+   All of these pointers can be retrieved or set through member functions.

+*/

+class CBaseList 

+#ifdef DEBUG

+    : public CBaseObject

+#endif

+{

+    /* Making these classes inherit from CBaseObject does nothing

+       functionally but it allows us to check there are no memory

+       leaks in debug builds. 

+    */

+

+public:

+

+#ifdef DEBUG

+    class CNode : public CBaseObject {

+#else

+    class CNode {

+#endif

+

+        CNode *m_pPrev;         /* Previous node in the list */

+        CNode *m_pNext;         /* Next node in the list */

+        void *m_pObject;      /* Pointer to the object */

+

+    public:

+

+        /* Constructor - initialise the object's pointers */

+        CNode()

+#ifdef DEBUG

+            : CBaseObject(NAME("List node"))

+#endif

+        {

+        };

+

+

+        /* Return the previous node before this one */

+        __out CNode *Prev() const { return m_pPrev; };

+

+

+        /* Return the next node after this one */

+        __out CNode *Next() const { return m_pNext; };

+

+

+        /* Set the previous node before this one */

+        void SetPrev(__in_opt CNode *p) { m_pPrev = p; };

+

+

+        /* Set the next node after this one */

+        void SetNext(__in_opt CNode *p) { m_pNext = p; };

+

+

+        /* Get the pointer to the object for this node */

+        __out void *GetData() const { return m_pObject; };

+

+

+        /* Set the pointer to the object for this node */

+        void SetData(__in void *p) { m_pObject = p; };

+    };

+

+    class CNodeCache

+    {

+    public:

+        CNodeCache(INT iCacheSize) : m_iCacheSize(iCacheSize),

+                                     m_pHead(NULL),

+                                     m_iUsed(0)

+                                     {};

+        ~CNodeCache() {

+            CNode *pNode = m_pHead;

+            while (pNode) {

+                CNode *pCurrent = pNode;

+                pNode = pNode->Next();

+                delete pCurrent;

+            }

+        };

+        void AddToCache(__inout CNode *pNode)

+        {

+            if (m_iUsed < m_iCacheSize) {

+                pNode->SetNext(m_pHead);

+                m_pHead = pNode;

+                m_iUsed++;

+            } else {

+                delete pNode;

+            }

+        };

+        CNode *RemoveFromCache()

+        {

+            CNode *pNode = m_pHead;

+            if (pNode != NULL) {

+                m_pHead = pNode->Next();

+                m_iUsed--;

+                ASSERT(m_iUsed >= 0);

+            } else {

+                ASSERT(m_iUsed == 0);

+            }

+            return pNode;

+        };

+    private:

+        INT m_iCacheSize;

+        INT m_iUsed;

+        CNode *m_pHead;

+    };

+

+protected:

+

+    CNode* m_pFirst;    /* Pointer to first node in the list */

+    CNode* m_pLast;     /* Pointer to the last node in the list */

+    LONG m_Count;       /* Number of nodes currently in the list */

+

+private:

+

+    CNodeCache m_Cache; /* Cache of unused node pointers */

+

+private:

+

+    /* These override the default copy constructor and assignment

+       operator for all list classes. They are in the private class

+       declaration section so that anybody trying to pass a list

+       object by value will generate a compile time error of

+       "cannot access the private member function". If these were

+       not here then the compiler will create default constructors

+       and assignment operators which when executed first take a

+       copy of all member variables and then during destruction

+       delete them all. This must not be done for any heap

+       allocated data.

+    */

+    CBaseList(const CBaseList &refList);

+    CBaseList &operator=(const CBaseList &refList);

+

+public:

+

+    CBaseList(__in_opt LPCTSTR pName,

+              INT iItems);

+

+    CBaseList(__in_opt LPCTSTR pName);

+#ifdef UNICODE

+    CBaseList(__in_opt LPCSTR pName,

+              INT iItems);

+

+    CBaseList(__in_opt LPCSTR pName);

+#endif

+    ~CBaseList();

+

+    /* Remove all the nodes from *this i.e. make the list empty */

+    void RemoveAll();

+

+

+    /* Return a cursor which identifies the first element of *this */

+    __out_opt POSITION GetHeadPositionI() const;

+

+

+    /* Return a cursor which identifies the last element of *this */

+    __out_opt POSITION GetTailPositionI() const;

+

+

+    /* Return the number of objects in *this */

+    int GetCountI() const;

+

+protected:

+    /* Return the pointer to the object at rp,

+       Update rp to the next node in *this

+       but make it NULL if it was at the end of *this.

+       This is a wart retained for backwards compatibility.

+       GetPrev is not implemented.

+       Use Next, Prev and Get separately.

+    */

+    __out void *GetNextI(__inout POSITION& rp) const;

+

+

+    /* Return a pointer to the object at p

+       Asking for the object at NULL will return NULL harmlessly.

+    */

+    __out_opt void *GetI(__in_opt POSITION p) const;

+    __out void *GetValidI(__in POSITION p) const;

+

+public:

+    /* return the next / prev position in *this

+       return NULL when going past the end/start.

+       Next(NULL) is same as GetHeadPosition()

+       Prev(NULL) is same as GetTailPosition()

+       An n element list therefore behaves like a n+1 element

+       cycle with NULL at the start/end.

+

+       !!WARNING!! - This handling of NULL is DIFFERENT from GetNext.

+

+       Some reasons are:

+       1. For a list of n items there are n+1 positions to insert

+          These are conveniently encoded as the n POSITIONs and NULL.

+       2. If you are keeping a list sorted (fairly common) and you

+          search forward for an element to insert before and don't

+          find it you finish up with NULL as the element before which

+          to insert.  You then want that NULL to be a valid POSITION

+          so that you can insert before it and you want that insertion

+          point to mean the (n+1)-th one that doesn't have a POSITION.

+          (symmetrically if you are working backwards through the list).

+       3. It simplifies the algebra which the methods generate.

+          e.g. AddBefore(p,x) is identical to AddAfter(Prev(p),x)

+          in ALL cases.  All the other arguments probably are reflections

+          of the algebraic point.

+    */

+    __out_opt POSITION Next(__in_opt POSITION pos) const

+    {

+        if (pos == NULL) {

+            return (POSITION) m_pFirst;

+        }

+        CNode *pn = (CNode *) pos;

+        return (POSITION) pn->Next();

+    } //Next

+

+    // See Next

+    __out_opt POSITION Prev(__in_opt POSITION pos) const

+    {

+        if (pos == NULL) {

+            return (POSITION) m_pLast;

+        }

+        CNode *pn = (CNode *) pos;

+        return (POSITION) pn->Prev();

+    } //Prev

+

+

+    /* Return the first position in *this which holds the given

+       pointer.  Return NULL if the pointer was not not found.

+    */

+protected:

+    __out_opt POSITION FindI( __in void * pObj) const;

+

+    // ??? Should there be (or even should there be only)

+    // ??? POSITION FindNextAfter(void * pObj, POSITION p)

+    // ??? And of course FindPrevBefore too.

+    // ??? List.Find(&Obj) then becomes List.FindNextAfter(&Obj, NULL)

+

+

+    /* Remove the first node in *this (deletes the pointer to its

+       object from the list, does not free the object itself).

+       Return the pointer to its object.

+       If *this was already empty it will harmlessly return NULL.

+    */

+    __out_opt void *RemoveHeadI();

+

+

+    /* Remove the last node in *this (deletes the pointer to its

+       object from the list, does not free the object itself).

+       Return the pointer to its object.

+       If *this was already empty it will harmlessly return NULL.

+    */

+    __out_opt void *RemoveTailI();

+

+

+    /* Remove the node identified by p from the list (deletes the pointer

+       to its object from the list, does not free the object itself).

+       Asking to Remove the object at NULL will harmlessly return NULL.

+       Return the pointer to the object removed.

+    */

+    __out_opt void *RemoveI(__in_opt POSITION p);

+

+    /* Add single object *pObj to become a new last element of the list.

+       Return the new tail position, NULL if it fails.

+       If you are adding a COM objects, you might want AddRef it first.

+       Other existing POSITIONs in *this are still valid

+    */

+    __out_opt POSITION AddTailI(__in void * pObj);

+public:

+

+

+    /* Add all the elements in *pList to the tail of *this.

+       This duplicates all the nodes in *pList (i.e. duplicates

+       all its pointers to objects).  It does not duplicate the objects.

+       If you are adding a list of pointers to a COM object into the list

+       it's a good idea to AddRef them all  it when you AddTail it.

+       Return TRUE if it all worked, FALSE if it didn't.

+       If it fails some elements may have been added.

+       Existing POSITIONs in *this are still valid

+

+       If you actually want to MOVE the elements, use MoveToTail instead.

+    */

+    BOOL AddTail(__in CBaseList *pList);

+

+

+    /* Mirror images of AddHead: */

+

+    /* Add single object to become a new first element of the list.

+       Return the new head position, NULL if it fails.

+       Existing POSITIONs in *this are still valid

+    */

+protected:

+    __out_opt POSITION AddHeadI(__in void * pObj);

+public:

+

+    /* Add all the elements in *pList to the head of *this.

+       Same warnings apply as for AddTail.

+       Return TRUE if it all worked, FALSE if it didn't.

+       If it fails some of the objects may have been added.

+

+       If you actually want to MOVE the elements, use MoveToHead instead.

+    */

+    BOOL AddHead(__in CBaseList *pList);

+

+

+    /* Add the object *pObj to *this after position p in *this.

+       AddAfter(NULL,x) adds x to the start - equivalent to AddHead

+       Return the position of the object added, NULL if it failed.

+       Existing POSITIONs in *this are undisturbed, including p.

+    */

+protected:

+    __out_opt POSITION AddAfterI(__in_opt POSITION p, __in void * pObj);

+public:

+

+    /* Add the list *pList to *this after position p in *this

+       AddAfter(NULL,x) adds x to the start - equivalent to AddHead

+       Return TRUE if it all worked, FALSE if it didn't.

+       If it fails, some of the objects may be added

+       Existing POSITIONs in *this are undisturbed, including p.

+    */

+    BOOL AddAfter(__in_opt POSITION p, __in CBaseList *pList);

+

+

+    /* Mirror images:

+       Add the object *pObj to this-List after position p in *this.

+       AddBefore(NULL,x) adds x to the end - equivalent to AddTail

+       Return the position of the new object, NULL if it fails

+       Existing POSITIONs in *this are undisturbed, including p.

+    */

+    protected:

+    __out_opt POSITION AddBeforeI(__in_opt POSITION p, __in void * pObj);

+    public:

+

+    /* Add the list *pList to *this before position p in *this

+       AddAfter(NULL,x) adds x to the start - equivalent to AddHead

+       Return TRUE if it all worked, FALSE if it didn't.

+       If it fails, some of the objects may be added

+       Existing POSITIONs in *this are undisturbed, including p.

+    */

+    BOOL AddBefore(__in_opt POSITION p, __in CBaseList *pList);

+

+

+    /* Note that AddAfter(p,x) is equivalent to AddBefore(Next(p),x)

+       even in cases where p is NULL or Next(p) is NULL.

+       Similarly for mirror images etc.

+       This may make it easier to argue about programs.

+    */

+

+

+

+    /* The following operations do not copy any elements.

+       They move existing blocks of elements around by switching pointers.

+       They are fairly efficient for long lists as for short lists.

+       (Alas, the Count slows things down).

+

+       They split the list into two parts.

+       One part remains as the original list, the other part

+       is appended to the second list.  There are eight possible

+       variations:

+       Split the list {after/before} a given element

+       keep the {head/tail} portion in the original list

+       append the rest to the {head/tail} of the new list.

+

+       Since After is strictly equivalent to Before Next

+       we are not in serious need of the Before/After variants.

+       That leaves only four.

+

+       If you are processing a list left to right and dumping

+       the bits that you have processed into another list as

+       you go, the Tail/Tail variant gives the most natural result.

+       If you are processing in reverse order, Head/Head is best.

+

+       By using NULL positions and empty lists judiciously either

+       of the other two can be built up in two operations.

+

+       The definition of NULL (see Next/Prev etc) means that

+       degenerate cases include

+          "move all elements to new list"

+          "Split a list into two lists"

+          "Concatenate two lists"

+          (and quite a few no-ops)

+

+       !!WARNING!! The type checking won't buy you much if you get list

+       positions muddled up - e.g. use a POSITION that's in a different

+       list and see what a mess you get!

+    */

+

+    /* Split *this after position p in *this

+       Retain as *this the tail portion of the original *this

+       Add the head portion to the tail end of *pList

+       Return TRUE if it all worked, FALSE if it didn't.

+

+       e.g.

+          foo->MoveToTail(foo->GetHeadPosition(), bar);

+              moves one element from the head of foo to the tail of bar

+          foo->MoveToTail(NULL, bar);

+              is a no-op, returns NULL

+          foo->MoveToTail(foo->GetTailPosition, bar);

+              concatenates foo onto the end of bar and empties foo.

+

+       A better, except excessively long name might be

+           MoveElementsFromHeadThroughPositionToOtherTail

+    */

+    BOOL MoveToTail(__in_opt POSITION pos, __in CBaseList *pList);

+

+

+    /* Mirror image:

+       Split *this before position p in *this.

+       Retain in *this the head portion of the original *this

+       Add the tail portion to the start (i.e. head) of *pList

+

+       e.g.

+          foo->MoveToHead(foo->GetTailPosition(), bar);

+              moves one element from the tail of foo to the head of bar

+          foo->MoveToHead(NULL, bar);

+              is a no-op, returns NULL

+          foo->MoveToHead(foo->GetHeadPosition, bar);

+              concatenates foo onto the start of bar and empties foo.

+    */

+    BOOL MoveToHead(__in_opt POSITION pos, __in CBaseList *pList);

+

+

+    /* Reverse the order of the [pointers to] objects in *this

+    */

+    void Reverse();

+

+

+    /* set cursor to the position of each element of list in turn  */

+    #define TRAVERSELIST(list, cursor)               \

+    for ( cursor = (list).GetHeadPosition()           \

+        ; cursor!=NULL                               \

+        ; cursor = (list).Next(cursor)                \

+        )

+

+

+    /* set cursor to the position of each element of list in turn

+       in reverse order

+    */

+    #define REVERSETRAVERSELIST(list, cursor)        \

+    for ( cursor = (list).GetTailPosition()           \

+        ; cursor!=NULL                               \

+        ; cursor = (list).Prev(cursor)                \

+        )

+

+}; // end of class declaration

+

+template<class OBJECT> class CGenericList : public CBaseList

+{

+public:

+    CGenericList(__in_opt LPCTSTR pName,

+                 INT iItems,

+                 BOOL bLock = TRUE,

+                 BOOL bAlert = FALSE) :

+                     CBaseList(pName, iItems) {

+        UNREFERENCED_PARAMETER(bAlert);

+        UNREFERENCED_PARAMETER(bLock);

+    };

+    CGenericList(__in_opt LPCTSTR pName) :

+                     CBaseList(pName) {

+    };

+

+    __out_opt POSITION GetHeadPosition() const { return (POSITION)m_pFirst; }

+    __out_opt POSITION GetTailPosition() const { return (POSITION)m_pLast; }

+    int GetCount() const { return m_Count; }

+

+    __out OBJECT *GetNext(__inout POSITION& rp) const { return (OBJECT *) GetNextI(rp); }

+

+    __out_opt OBJECT *Get(__in_opt POSITION p) const { return (OBJECT *) GetI(p); }

+    __out OBJECT *GetValid(__in POSITION p) const { return (OBJECT *) GetValidI(p); }

+    __out_opt OBJECT *GetHead() const  { return Get(GetHeadPosition()); }

+

+    __out_opt OBJECT *RemoveHead() { return (OBJECT *) RemoveHeadI(); }

+

+    __out_opt OBJECT *RemoveTail() { return (OBJECT *) RemoveTailI(); }

+

+    __out_opt OBJECT *Remove(__in_opt POSITION p) { return (OBJECT *) RemoveI(p); }

+    __out_opt POSITION AddBefore(__in_opt POSITION p, __in OBJECT * pObj) { return AddBeforeI(p, pObj); }

+    __out_opt POSITION AddAfter(__in_opt POSITION p, __in OBJECT * pObj)  { return AddAfterI(p, pObj); }

+    __out_opt POSITION AddHead(__in OBJECT * pObj) { return AddHeadI(pObj); }

+    __out_opt POSITION AddTail(__in OBJECT * pObj)  { return AddTailI(pObj); }

+    BOOL AddTail(__in CGenericList<OBJECT> *pList)

+            { return CBaseList::AddTail((CBaseList *) pList); }

+    BOOL AddHead(__in CGenericList<OBJECT> *pList)

+            { return CBaseList::AddHead((CBaseList *) pList); }

+    BOOL AddAfter(__in_opt POSITION p, __in CGenericList<OBJECT> *pList)

+            { return CBaseList::AddAfter(p, (CBaseList *) pList); };

+    BOOL AddBefore(__in_opt POSITION p, __in CGenericList<OBJECT> *pList)

+            { return CBaseList::AddBefore(p, (CBaseList *) pList); };

+    __out_opt POSITION Find( __in OBJECT * pObj) const { return FindI(pObj); }

+}; // end of class declaration

+

+

+

+/* These define the standard list types */

+

+typedef CGenericList<CBaseObject> CBaseObjectList;

+typedef CGenericList<IUnknown> CBaseInterfaceList;

+

+#endif /* __WXLIST__ */

+

diff --git a/jni/pjproject-android/.svn/pristine/66/66d325be5381e57dc957abe6874db748ecf8d233.svn-base b/jni/pjproject-android/.svn/pristine/66/66d325be5381e57dc957abe6874db748ecf8d233.svn-base
new file mode 100644
index 0000000..2f5d407
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/66d325be5381e57dc957abe6874db748ecf8d233.svn-base
@@ -0,0 +1,94 @@
+/* $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/string.h>
+
+
+PJ_IDEF(pj_size_t) pj_pool_get_capacity( pj_pool_t *pool )
+{
+    return pool->capacity;
+}
+
+PJ_IDEF(pj_size_t) pj_pool_get_used_size( pj_pool_t *pool )
+{
+    pj_pool_block *b = pool->block_list.next;
+    pj_size_t used_size = sizeof(pj_pool_t);
+    while (b != &pool->block_list) {
+	used_size += (b->cur - b->buf) + sizeof(pj_pool_block);
+	b = b->next;
+    }
+    return used_size;
+}
+
+PJ_IDEF(void*) pj_pool_alloc_from_block( pj_pool_block *block, pj_size_t size )
+{
+    /* The operation below is valid for size==0. 
+     * When size==0, the function will return the pointer to the pool
+     * memory address, but no memory will be allocated.
+     */
+    if (size & (PJ_POOL_ALIGNMENT-1)) {
+	size = (size + PJ_POOL_ALIGNMENT) & ~(PJ_POOL_ALIGNMENT-1);
+    }
+    if ((pj_size_t)(block->end - block->cur) >= size) {
+	void *ptr = block->cur;
+	block->cur += size;
+	return ptr;
+    }
+    return NULL;
+}
+
+PJ_IDEF(void*) pj_pool_alloc( pj_pool_t *pool, pj_size_t size)
+{
+    void *ptr = pj_pool_alloc_from_block(pool->block_list.next, size);
+    if (!ptr)
+	ptr = pj_pool_allocate_find(pool, size);
+    return ptr;
+}
+
+
+PJ_IDEF(void*) pj_pool_calloc( pj_pool_t *pool, pj_size_t count, pj_size_t size)
+{
+    void *buf = pj_pool_alloc( pool, size*count);
+    if (buf)
+	pj_bzero(buf, size * count);
+    return buf;
+}
+
+PJ_IDEF(const char *) pj_pool_getobjname( const pj_pool_t *pool )
+{
+    return pool->obj_name;
+}
+
+PJ_IDEF(pj_pool_t*) pj_pool_create( pj_pool_factory *f, 
+				    const char *name,
+				    pj_size_t initial_size, 
+				    pj_size_t increment_size,
+				    pj_pool_callback *callback)
+{
+    return (*f->create_pool)(f, name, initial_size, increment_size, callback);
+}
+
+PJ_IDEF(void) pj_pool_release( pj_pool_t *pool )
+{
+    if (pool->factory->release_pool)
+	(*pool->factory->release_pool)(pool->factory, pool);
+}
+
diff --git a/jni/pjproject-android/.svn/pristine/66/66ddaaf1d5426f2a06568257fafd2fdbfa5cd08b.svn-base b/jni/pjproject-android/.svn/pristine/66/66ddaaf1d5426f2a06568257fafd2fdbfa5cd08b.svn-base
new file mode 100644
index 0000000..b43c3ab
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/66ddaaf1d5426f2a06568257fafd2fdbfa5cd08b.svn-base
@@ -0,0 +1,240 @@
+/* $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/file_io.h>
+#include <pj/unicode.h>
+#include <pj/errno.h>
+#include <pj/assert.h>
+
+#include <windows.h>
+
+#ifndef INVALID_SET_FILE_POINTER
+#   define INVALID_SET_FILE_POINTER     ((DWORD)-1)
+#endif
+
+/**
+ * Check for end-of-file condition on the specified descriptor.
+ *
+ * @param fd            The file descriptor.
+ * @param access        The desired access.
+ *
+ * @return              Non-zero if file is EOF.
+ */
+PJ_DECL(pj_bool_t) pj_file_eof(pj_oshandle_t fd, 
+                               enum pj_file_access access);
+
+
+PJ_DEF(pj_status_t) pj_file_open( pj_pool_t *pool,
+                                  const char *pathname, 
+                                  unsigned flags,
+                                  pj_oshandle_t *fd)
+{
+    PJ_DECL_UNICODE_TEMP_BUF(wpathname,256)
+    HANDLE hFile;
+    DWORD dwDesiredAccess = 0;
+    DWORD dwShareMode = 0;
+    DWORD dwCreationDisposition = 0;
+    DWORD dwFlagsAndAttributes = 0;
+
+    PJ_UNUSED_ARG(pool);
+
+    PJ_ASSERT_RETURN(pathname!=NULL, PJ_EINVAL);
+
+    if ((flags & PJ_O_WRONLY) == PJ_O_WRONLY) {
+        dwDesiredAccess |= GENERIC_WRITE;
+        if ((flags & PJ_O_APPEND) == PJ_O_APPEND) {
+#if !defined(PJ_WIN32_WINCE) || !PJ_WIN32_WINCE
+	    /* FILE_APPEND_DATA is invalid on WM2003 and WM5, but it seems
+	     * to be working on WM6. All are tested on emulator though.
+	     * Removing this also seem to work (i.e. data is appended), so
+	     * I guess this flag is "optional".
+	     * See http://trac.pjsip.org/repos/ticket/825
+	     */
+            dwDesiredAccess |= FILE_APPEND_DATA;
+#endif
+	    dwCreationDisposition |= OPEN_ALWAYS;
+        } else {
+            dwDesiredAccess &= ~(FILE_APPEND_DATA);
+            dwCreationDisposition |= CREATE_ALWAYS;
+        }
+    }
+    if ((flags & PJ_O_RDONLY) == PJ_O_RDONLY) {
+        dwDesiredAccess |= GENERIC_READ;
+        if (flags == PJ_O_RDONLY)
+            dwCreationDisposition |= OPEN_EXISTING;
+    }
+
+    if (dwDesiredAccess == 0) {
+        pj_assert(!"Invalid file open flags");
+        return PJ_EINVAL;
+    }
+
+    dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+    dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
+
+    hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname,wpathname,sizeof(wpathname)), 
+		       dwDesiredAccess, dwShareMode, NULL,
+                       dwCreationDisposition, dwFlagsAndAttributes, NULL);
+    if (hFile == INVALID_HANDLE_VALUE) {
+        *fd = 0;
+        return PJ_RETURN_OS_ERROR(GetLastError());
+    }
+
+    if ((flags & PJ_O_APPEND) == PJ_O_APPEND) {
+	pj_status_t status;
+
+	status = pj_file_setpos(hFile, 0, PJ_SEEK_END);
+	if (status != PJ_SUCCESS) {
+	    pj_file_close(hFile);
+	    return status;
+	}
+    }
+
+    *fd = hFile;
+    return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pj_file_close(pj_oshandle_t fd)
+{
+    if (CloseHandle(fd)==0)
+        return PJ_RETURN_OS_ERROR(GetLastError());
+    return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pj_file_write( pj_oshandle_t fd,
+                                   const void *data,
+                                   pj_ssize_t *size)
+{
+    BOOL rc;
+    DWORD bytesWritten;
+
+    rc = WriteFile(fd, data, (DWORD)*size, &bytesWritten, NULL);
+    if (!rc) {
+        *size = -1;
+        return PJ_RETURN_OS_ERROR(GetLastError());
+    }
+
+    *size = bytesWritten;
+    return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pj_file_read( pj_oshandle_t fd,
+                                  void *data,
+                                  pj_ssize_t *size)
+{
+    BOOL rc;
+    DWORD bytesRead;
+
+    rc = ReadFile(fd, data, (DWORD)*size, &bytesRead, NULL);
+    if (!rc) {
+        *size = -1;
+        return PJ_RETURN_OS_ERROR(GetLastError());
+    }
+
+    *size = bytesRead;
+    return PJ_SUCCESS;
+}
+
+/*
+PJ_DEF(pj_bool_t) pj_file_eof(pj_oshandle_t fd, enum pj_file_access access)
+{
+    BOOL rc;
+    DWORD dummy = 0, bytes;
+    DWORD dwStatus;
+
+    if ((access & PJ_O_RDONLY) == PJ_O_RDONLY) {
+        rc = ReadFile(fd, &dummy, 0, &bytes, NULL);
+    } else if ((access & PJ_O_WRONLY) == PJ_O_WRONLY) {
+        rc = WriteFile(fd, &dummy, 0, &bytes, NULL);
+    } else {
+        pj_assert(!"Invalid access");
+        return PJ_TRUE;
+    }
+
+    dwStatus = GetLastError();
+    if (dwStatus==ERROR_HANDLE_EOF)
+        return PJ_TRUE;
+
+    return 0;
+}
+*/
+
+PJ_DEF(pj_status_t) pj_file_setpos( pj_oshandle_t fd,
+                                    pj_off_t offset,
+                                    enum pj_file_seek_type whence)
+{
+    DWORD dwMoveMethod;
+    DWORD dwNewPos;
+    LONG  hi32;
+
+    if (whence == PJ_SEEK_SET)
+        dwMoveMethod = FILE_BEGIN;
+    else if (whence == PJ_SEEK_CUR)
+        dwMoveMethod = FILE_CURRENT;
+    else if (whence == PJ_SEEK_END)
+        dwMoveMethod = FILE_END;
+    else {
+        pj_assert(!"Invalid whence in file_setpos");
+        return PJ_EINVAL;
+    }
+
+    hi32 = (LONG)(offset >> 32);
+    dwNewPos = SetFilePointer(fd, (long)offset, &hi32, dwMoveMethod);
+    if (dwNewPos == (DWORD)INVALID_SET_FILE_POINTER) {
+        DWORD dwStatus = GetLastError();
+        if (dwStatus != 0)
+            return PJ_RETURN_OS_ERROR(dwStatus);
+        /* dwNewPos actually is not an error. */
+    }
+
+    return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pj_file_getpos( pj_oshandle_t fd,
+                                    pj_off_t *pos)
+{
+    LONG hi32 = 0;
+    DWORD lo32;
+
+    lo32 = SetFilePointer(fd, 0, &hi32, FILE_CURRENT);
+    if (lo32 == (DWORD)INVALID_SET_FILE_POINTER) {
+        DWORD dwStatus = GetLastError();
+        if (dwStatus != 0)
+            return PJ_RETURN_OS_ERROR(dwStatus);
+    }
+
+    *pos = hi32;
+    *pos = (*pos << 32) + lo32;
+    return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pj_file_flush(pj_oshandle_t fd)
+{
+    BOOL rc;
+
+    rc = FlushFileBuffers(fd);
+
+    if (!rc) {
+	DWORD dwStatus = GetLastError();
+        if (dwStatus != 0)
+            return PJ_RETURN_OS_ERROR(dwStatus);
+    }
+
+    return PJ_SUCCESS;
+}
diff --git a/jni/pjproject-android/.svn/pristine/66/66e01444aa6e796724567293095577418d7c15b9.svn-base b/jni/pjproject-android/.svn/pristine/66/66e01444aa6e796724567293095577418d7c15b9.svn-base
new file mode 100644
index 0000000..9042ef9
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/66/66e01444aa6e796724567293095577418d7c15b9.svn-base
@@ -0,0 +1,405 @@
+/* $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/delaybuf.h>
+#include <pjmedia/circbuf.h>
+#include <pjmedia/errno.h>
+#include <pjmedia/frame.h>
+#include <pjmedia/wsola.h>
+#include <pj/assert.h>
+#include <pj/lock.h>
+#include <pj/log.h>
+#include <pj/math.h>
+#include <pj/pool.h>
+
+
+#if 0
+#   define TRACE__(x) PJ_LOG(3,x)
+#else
+#   define TRACE__(x)
+#endif
+
+/* Operation types of delay buffer */
+enum OP
+{
+    OP_PUT,
+    OP_GET
+};
+
+/* Specify time for delaybuf to recalculate effective delay, in ms.
+ */
+#define RECALC_TIME	    2000
+
+/* Default value of maximum delay, in ms, this value is used when 
+ * maximum delay requested is less than ptime (one frame length).
+ */
+#define DEFAULT_MAX_DELAY   400
+
+/* Number of frames to add to learnt level for additional stability.
+ */
+#define SAFE_MARGIN	    0
+
+/* This structure describes internal delaybuf settings and states.
+ */
+struct pjmedia_delay_buf
+{
+    /* Properties and configuration */
+    char	     obj_name[PJ_MAX_OBJ_NAME];
+    pj_lock_t	    *lock;		/**< Lock object.		     */
+    unsigned	     samples_per_frame; /**< Number of samples in one frame  */
+    unsigned	     ptime;		/**< Frame time, in ms		     */
+    unsigned	     channel_count;	/**< Channel count, in ms	     */
+    pjmedia_circ_buf *circ_buf;		/**< Circular buffer to store audio
+					     samples			     */
+    unsigned	     max_cnt;		/**< Maximum samples to be buffered  */
+    unsigned	     eff_cnt;		/**< Effective count of buffered 
+					     samples to keep the optimum
+					     balance between delay and 
+					     stability. This is calculated 
+					     based on burst level.	     */
+
+    /* Learning vars */
+    unsigned	     level;		/**< Burst level counter	     */
+    enum OP	     last_op;		/**< Last op (GET or PUT) of learning*/
+    int		     recalc_timer;	/**< Timer for recalculating max_level*/
+    unsigned	     max_level;		/**< Current max burst level	     */
+
+    /* Drift handler */
+    pjmedia_wsola   *wsola;		/**< Drift handler		     */
+};
+
+
+PJ_DEF(pj_status_t) pjmedia_delay_buf_create( pj_pool_t *pool,
+					      const char *name,
+					      unsigned clock_rate,
+					      unsigned samples_per_frame,
+					      unsigned channel_count,
+					      unsigned max_delay,
+					      unsigned options,
+					      pjmedia_delay_buf **p_b)
+{
+    pjmedia_delay_buf *b;
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(pool && samples_per_frame && clock_rate && channel_count &&
+		     p_b, PJ_EINVAL);
+
+    if (!name) {
+	name = "delaybuf";
+    }
+
+    b = PJ_POOL_ZALLOC_T(pool, pjmedia_delay_buf);
+
+    pj_ansi_strncpy(b->obj_name, name, PJ_MAX_OBJ_NAME-1);
+
+    b->samples_per_frame = samples_per_frame;
+    b->channel_count = channel_count;
+    b->ptime = samples_per_frame * 1000 / clock_rate / channel_count;
+    if (max_delay < b->ptime)
+	max_delay = PJ_MAX(DEFAULT_MAX_DELAY, b->ptime);
+
+    b->max_cnt = samples_per_frame * max_delay / b->ptime;
+    b->eff_cnt = b->max_cnt >> 1;
+    b->recalc_timer = RECALC_TIME;
+
+    /* Create circular buffer */
+    status = pjmedia_circ_buf_create(pool, b->max_cnt, &b->circ_buf);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    if (!(options & PJMEDIA_DELAY_BUF_SIMPLE_FIFO)) {
+        /* Create WSOLA */
+        status = pjmedia_wsola_create(pool, clock_rate, samples_per_frame, 1,
+				      PJMEDIA_WSOLA_NO_FADING, &b->wsola);
+        if (status != PJ_SUCCESS)
+	    return status;
+        PJ_LOG(5, (b->obj_name, "Using delay buffer with WSOLA."));
+    } else {
+        PJ_LOG(5, (b->obj_name, "Using simple FIFO delay buffer."));
+    }
+
+    /* Finally, create mutex */
+    status = pj_lock_create_recursive_mutex(pool, b->obj_name, 
+					    &b->lock);
+    if (status != PJ_SUCCESS)
+	return status;
+
+    *p_b = b;
+
+    TRACE__((b->obj_name,"Delay buffer created"));
+
+    return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pjmedia_delay_buf_destroy(pjmedia_delay_buf *b)
+{
+    pj_status_t status = PJ_SUCCESS;
+
+    PJ_ASSERT_RETURN(b, PJ_EINVAL);
+
+    pj_lock_acquire(b->lock);
+
+    if (b->wsola) {
+        status = pjmedia_wsola_destroy(b->wsola);
+        if (status == PJ_SUCCESS)
+	    b->wsola = NULL;
+    }
+
+    pj_lock_release(b->lock);
+
+    pj_lock_destroy(b->lock);
+    b->lock = NULL;
+
+    return status;
+}
+
+/* This function will erase samples from delay buffer.
+ * The number of erased samples is guaranteed to be >= erase_cnt.
+ */
+static void shrink_buffer(pjmedia_delay_buf *b, unsigned erase_cnt)
+{
+    pj_int16_t *buf1, *buf2;
+    unsigned buf1len;
+    unsigned buf2len;
+    pj_status_t status;
+
+    pj_assert(b && erase_cnt && pjmedia_circ_buf_get_len(b->circ_buf));
+
+    pjmedia_circ_buf_get_read_regions(b->circ_buf, &buf1, &buf1len, 
+				      &buf2, &buf2len);
+    status = pjmedia_wsola_discard(b->wsola, buf1, buf1len, buf2, buf2len,
+				   &erase_cnt);
+
+    if ((status == PJ_SUCCESS) && (erase_cnt > 0)) {
+	/* WSOLA discard will manage the first buffer to be full, unless 
+	 * erase_cnt is greater than second buffer length. So it is safe
+	 * to just set the circular buffer length.
+	 */
+
+	pjmedia_circ_buf_set_len(b->circ_buf, 
+				 pjmedia_circ_buf_get_len(b->circ_buf) - 
+				 erase_cnt);
+
+	PJ_LOG(5,(b->obj_name,"%d samples reduced, buf_cnt=%d", 
+	       erase_cnt, pjmedia_circ_buf_get_len(b->circ_buf)));
+    }
+}
+
+/* Fast increase, slow decrease */
+#define AGC_UP(cur, target) cur = (cur + target*3) >> 2
+#define AGC_DOWN(cur, target) cur = (cur*3 + target) >> 2
+#define AGC(cur, target) \
+    if (cur < target) AGC_UP(cur, target); \
+    else AGC_DOWN(cur, target)
+
+static void update(pjmedia_delay_buf *b, enum OP op)
+{
+    /* Sequential operation */
+    if (op == b->last_op) {
+	++b->level;
+	return;
+    } 
+
+    /* Switching operation */
+    if (b->level > b->max_level)
+	b->max_level = b->level;
+
+    b->recalc_timer -= (b->level * b->ptime) >> 1;
+
+    b->last_op = op;
+    b->level = 1;
+
+    /* Recalculate effective count based on max_level */
+    if (b->recalc_timer <= 0) {
+	unsigned new_eff_cnt = (b->max_level+SAFE_MARGIN)*b->samples_per_frame;
+
+	/* Smoothening effective count transition */
+	AGC(b->eff_cnt, new_eff_cnt);
+	
+	/* Make sure the new effective count is multiplication of 
+	 * channel_count, so let's round it up.
+	 */
+	if (b->eff_cnt % b->channel_count)
+	    b->eff_cnt += b->channel_count - (b->eff_cnt % b->channel_count);
+
+	TRACE__((b->obj_name,"Cur eff_cnt=%d", b->eff_cnt));
+	
+	b->max_level = 0;
+	b->recalc_timer = RECALC_TIME;
+    }
+
+    /* See if we need to shrink the buffer to reduce delay */
+    if (op == OP_PUT && pjmedia_circ_buf_get_len(b->circ_buf) > 
+	b->samples_per_frame + b->eff_cnt)
+    {
+	unsigned erase_cnt = b->samples_per_frame >> 1;
+	unsigned old_buf_cnt = pjmedia_circ_buf_get_len(b->circ_buf);
+
+	shrink_buffer(b, erase_cnt);
+	PJ_LOG(4,(b->obj_name,"Buffer size adjusted from %d to %d (eff_cnt=%d)",
+	          old_buf_cnt,
+		  pjmedia_circ_buf_get_len(b->circ_buf),
+		  b->eff_cnt));
+    }
+}
+
+PJ_DEF(pj_status_t) pjmedia_delay_buf_put(pjmedia_delay_buf *b,
+					   pj_int16_t frame[])
+{
+    pj_status_t status;
+
+    PJ_ASSERT_RETURN(b && frame, PJ_EINVAL);
+
+    pj_lock_acquire(b->lock);
+
+    if (b->wsola) {
+        update(b, OP_PUT);
+    
+        status = pjmedia_wsola_save(b->wsola, frame, PJ_FALSE);
+        if (status != PJ_SUCCESS) {
+	    pj_lock_release(b->lock);
+	    return status;
+        }
+    }
+
+    /* Overflow checking */
+    if (pjmedia_circ_buf_get_len(b->circ_buf) + b->samples_per_frame > 
+	b->max_cnt)
+    {
+	unsigned erase_cnt;
+
+        if (b->wsola) {
+	    /* shrink one frame or just the diff? */
+	    //erase_cnt = b->samples_per_frame;
+	    erase_cnt = pjmedia_circ_buf_get_len(b->circ_buf) + 
+		        b->samples_per_frame - b->max_cnt;
+
+	    shrink_buffer(b, erase_cnt);
+        }
+
+	/* Check if shrinking failed or erased count is less than requested,
+	 * delaybuf needs to drop eldest samples, this is bad since the voice
+	 * samples get rough transition which may produce tick noise.
+	 */
+	if (pjmedia_circ_buf_get_len(b->circ_buf) + b->samples_per_frame > 
+	    b->max_cnt) 
+	{
+	    erase_cnt = pjmedia_circ_buf_get_len(b->circ_buf) + 
+			b->samples_per_frame - b->max_cnt;
+
+	    pjmedia_circ_buf_adv_read_ptr(b->circ_buf, erase_cnt);
+
+	    PJ_LOG(4,(b->obj_name,"%sDropping %d eldest samples, buf_cnt=%d",
+                      (b->wsola? "Shrinking failed or insufficient. ": ""),
+                      erase_cnt, pjmedia_circ_buf_get_len(b->circ_buf)));
+	}
+    }
+
+    pjmedia_circ_buf_write(b->circ_buf, frame, b->samples_per_frame);
+
+    pj_lock_release(b->lock);
+    return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pjmedia_delay_buf_get( pjmedia_delay_buf *b,
+					   pj_int16_t frame[])
+{
+    pj_status_t status = PJ_SUCCESS;
+
+    PJ_ASSERT_RETURN(b && frame, PJ_EINVAL);
+
+    pj_lock_acquire(b->lock);
+
+    if (b->wsola)
+        update(b, OP_GET);
+
+    /* Starvation checking */
+    if (pjmedia_circ_buf_get_len(b->circ_buf) < b->samples_per_frame) {
+
+	PJ_LOG(4,(b->obj_name,"Underflow, buf_cnt=%d, will generate 1 frame",
+		  pjmedia_circ_buf_get_len(b->circ_buf)));
+
+        if (b->wsola) {
+            status = pjmedia_wsola_generate(b->wsola, frame);
+
+	    if (status == PJ_SUCCESS) {
+	        TRACE__((b->obj_name,"Successfully generate 1 frame"));
+	        if (pjmedia_circ_buf_get_len(b->circ_buf) == 0) {
+		    pj_lock_release(b->lock);
+		    return PJ_SUCCESS;
+	        }
+
+	        /* Put generated frame into buffer */
+	        pjmedia_circ_buf_write(b->circ_buf, frame,
+                                       b->samples_per_frame);
+            }
+        }
+
+	if (!b->wsola || status != PJ_SUCCESS) {
+	    unsigned buf_len = pjmedia_circ_buf_get_len(b->circ_buf);
+	    
+	    /* Give all what delay buffer has, then pad with zeroes */
+            if (b->wsola)
+	        PJ_LOG(4,(b->obj_name,"Error generating frame, status=%d", 
+		          status));
+
+	    pjmedia_circ_buf_read(b->circ_buf, frame, buf_len);
+	    pjmedia_zero_samples(&frame[buf_len], 
+				 b->samples_per_frame - buf_len);
+
+	    /* The buffer is empty now, reset it */
+	    pjmedia_circ_buf_reset(b->circ_buf);
+
+	    pj_lock_release(b->lock);
+
+	    return PJ_SUCCESS;
+	}
+    }
+
+    pjmedia_circ_buf_read(b->circ_buf, frame, b->samples_per_frame);
+
+    pj_lock_release(b->lock);
+
+    return PJ_SUCCESS;
+}
+
+
+PJ_DEF(pj_status_t) pjmedia_delay_buf_reset(pjmedia_delay_buf *b)
+{
+    PJ_ASSERT_RETURN(b, PJ_EINVAL);
+
+    pj_lock_acquire(b->lock);
+
+    b->recalc_timer = RECALC_TIME;
+
+    /* Reset buffer */
+    pjmedia_circ_buf_reset(b->circ_buf);
+
+    /* Reset WSOLA */
+    if (b->wsola)
+        pjmedia_wsola_reset(b->wsola, 0);
+
+    pj_lock_release(b->lock);
+
+    PJ_LOG(5,(b->obj_name,"Delay buffer is reset"));
+
+    return PJ_SUCCESS;
+}
+