* #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/42/427fc6955d98a733724206812ae953c31b4c9140.svn-base b/jni/pjproject-android/.svn/pristine/42/427fc6955d98a733724206812ae953c31b4c9140.svn-base
new file mode 100644
index 0000000..f0043ad
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/42/427fc6955d98a733724206812ae953c31b4c9140.svn-base
@@ -0,0 +1,36 @@
+#
+# PJLIB OS specific configuration for SunOS target.
+#
+
+#
+# PJLIB_OBJS specified here are object files to be included in PJLIB
+# (the library) for this specific operating system. Object files common
+# to all operating systems should go in Makefile instead.
+#
+export PJLIB_OBJS += addr_resolv_sock.o file_access_unistd.o \
+ file_io_ansi.o guid_simple.o \
+ log_writer_stdout.o os_core_unix.o \
+ os_error_unix.o os_time_unix.o \
+ os_timestamp_common.o os_timestamp_posix.o \
+ pool_policy_malloc.o sock_bsd.o sock_select.o
+
+export PJLIB_OBJS += ioqueue_select.o
+#export PJLIB_OBJS += ioqueue_epoll.o
+
+#
+# TEST_OBJS are operating system specific object files to be included in
+# the test application.
+#
+export TEST_OBJS += main.o
+
+#
+# Additional LDFLAGS for pjlib-test
+#
+export TEST_LDFLAGS += -lm
+
+#
+# TARGETS are make targets in the Makefile, to be executed for this given
+# operating system.
+#
+export TARGETS = pjlib pjlib-test
+
diff --git a/jni/pjproject-android/.svn/pristine/42/4281cddac55f9c81ac54ff43519e1f2dbcf62282.svn-base b/jni/pjproject-android/.svn/pristine/42/4281cddac55f9c81ac54ff43519e1f2dbcf62282.svn-base
new file mode 100644
index 0000000..2e080e3
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/42/4281cddac55f9c81ac54ff43519e1f2dbcf62282.svn-base
Binary files differ
diff --git a/jni/pjproject-android/.svn/pristine/42/429d1e3bd9d4c52fd0a6cca4633a76061815a78f.svn-base b/jni/pjproject-android/.svn/pristine/42/429d1e3bd9d4c52fd0a6cca4633a76061815a78f.svn-base
new file mode 100644
index 0000000..9f4df39
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/42/429d1e3bd9d4c52fd0a6cca4633a76061815a78f.svn-base
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<!-- 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 -->
+<!-- -->
+<!-- Sipp default 'uas' scenario. -->
+<!-- -->
+
+<scenario name="Basic UAS responder">
+ <!-- By adding rrs="true" (Record Route Sets), the route sets -->
+ <!-- are saved and used for following messages sent. Useful to test -->
+ <!-- against stateful SIP proxies/B2BUAs. -->
+ <recv request="INVITE" crlf="true">
+ </recv>
+
+ <!-- The '[last_*]' keyword is replaced automatically by the -->
+ <!-- specified header if it was present in the last message received -->
+ <!-- (except if it was a retransmission). If the header was not -->
+ <!-- present or if no message has been received, the '[last_*]' -->
+ <!-- keyword is discarded, and all bytes until the end of the line -->
+ <!-- are also discarded. -->
+ <!-- -->
+ <!-- If the specified header was present several times in the -->
+ <!-- message, all occurences are concatenated (CRLF seperated) -->
+ <!-- to be used in place of the '[last_*]' keyword. -->
+
+ <send retrans="500">
+ <![CDATA[
+
+ SIP/2.0 422 Session Timer too small
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Min-SE: 5400
+ Content-Length: 0
+
+ ]]>
+ </send>
+
+ <recv request="ACK"
+ optional="true"
+ rtd="true"
+ crlf="true">
+ </recv>
+
+
+ <recv request="INVITE" crlf="true">
+ </recv>
+
+ <send retrans="500">
+ <![CDATA[
+
+ SIP/2.0 200 OK
+ [last_Via:]
+ [last_From:]
+ [last_To:];tag=[call_number]
+ [last_Call-ID:]
+ [last_CSeq:]
+ Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY, INFO, REGISTER
+ Allow-Events: telephone-event
+ Contact: <sip:[local_ip]:[local_port];transport=[transport]>
+ Supported: replaces
+ Session-Expires: 3600;refresher=uas
+ Require: timer
+ Content-Type: application/sdp
+ Content-Disposition: session;handling=required
+ Content-Length: [len]
+
+ v=0
+ o=Some-UserAgent 68 210 IN IP4 [local_ip]
+ s=SIP Call
+ c=IN IP4 [local_ip]
+ t=0 0
+ m=audio 17294 RTP/AVP 0 101
+ c=IN IP4 [local_ip]
+ a=rtpmap:0 PCMU/8000
+ a=rtpmap:101 telephone-event/8000
+ a=fmtp:101 0-16
+ a=ptime:20
+
+ ]]>
+ </send>
+
+ <recv request="ACK"
+ rtd="true"
+ crlf="true">
+ </recv>
+
+
+ <!-- Keep the call open for a while in case the 200 is lost to be -->
+ <!-- able to retransmit it if we receive the BYE again. -->
+ <pause milliseconds="4000"/>
+
+
+ <!-- definition of the response time repartition table (unit is ms) -->
+ <ResponseTimeRepartition value="10, 20, 30, 40, 50, 100, 150, 200"/>
+
+ <!-- definition of the call length repartition table (unit is ms) -->
+ <CallLengthRepartition value="10, 50, 100, 500, 1000, 5000, 10000"/>
+
+</scenario>
+
diff --git a/jni/pjproject-android/.svn/pristine/42/429fdf182f25d2deae23766b82a2b43b46ad5b54.svn-base b/jni/pjproject-android/.svn/pristine/42/429fdf182f25d2deae23766b82a2b43b46ad5b54.svn-base
new file mode 100644
index 0000000..a568462
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/42/429fdf182f25d2deae23766b82a2b43b46ad5b54.svn-base
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2003 Commonwealth Scientific and Industrial Research
+ Organisation (CSIRO) Australia
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ - Neither the name of CSIRO Australia nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* An inline macro is required for use of the inline keyword as not all C compilers support */
+/* inline. It is officially C99 and C++ only */
+
+#ifdef __WINS__
+
+#define inline __inline
+
+/* Disable some pointless/stupid warnings */
+
+#pragma warning(disable: 4100) /* unreferenced formal parameter */
+#pragma warning(disable: 4127) /* conditional expression is constant */
+#pragma warning(disable: 4305) /* truncation from '...' to '...' */
+#pragma warning(disable: 4244) /* conversion from '...' to '...', possible loss of data */
+#pragma warning(disable: 4701) /* local variable may be be used without having been initialized */
+
+#endif /* ! __WINS__ */
+
+/* Use only fixed point arithmetic */
+
+#define FIXED_POINT 1
+#define USE_KISS_FFT
+#define EXPORT
+
+#endif /* ! CONFIG_H */
diff --git a/jni/pjproject-android/.svn/pristine/42/42b8f32678efcc3c229449896331a26b9e8660d0.svn-base b/jni/pjproject-android/.svn/pristine/42/42b8f32678efcc3c229449896331a26b9e8660d0.svn-base
new file mode 100644
index 0000000..54eef8d
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/42/42b8f32678efcc3c229449896331a26b9e8660d0.svn-base
@@ -0,0 +1,340 @@
+/* Copyright (C) 2007 Jean-Marc Valin
+
+ File: speex_resampler.h
+ Resampling code
+
+ The design goals of this code are:
+ - Very fast algorithm
+ - Low memory requirement
+ - Good *perceptual* quality (and not best SNR)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#ifndef SPEEX_RESAMPLER_H
+#define SPEEX_RESAMPLER_H
+
+#ifdef OUTSIDE_SPEEX
+
+/********* WARNING: MENTAL SANITY ENDS HERE *************/
+
+/* If the resampler is defined outside of Speex, we change the symbol names so that
+ there won't be any clash if linking with Speex later on. */
+
+/* #define RANDOM_PREFIX your software name here */
+#ifndef RANDOM_PREFIX
+#error "Please define RANDOM_PREFIX (above) to something specific to your project to prevent symbol name clashes"
+#endif
+
+#define CAT_PREFIX2(a,b) a ## b
+#define CAT_PREFIX(a,b) CAT_PREFIX2(a, b)
+
+#define speex_resampler_init CAT_PREFIX(RANDOM_PREFIX,_resampler_init)
+#define speex_resampler_init_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_init_frac)
+#define speex_resampler_destroy CAT_PREFIX(RANDOM_PREFIX,_resampler_destroy)
+#define speex_resampler_process_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_float)
+#define speex_resampler_process_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_int)
+#define speex_resampler_process_interleaved_float CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_float)
+#define speex_resampler_process_interleaved_int CAT_PREFIX(RANDOM_PREFIX,_resampler_process_interleaved_int)
+#define speex_resampler_set_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate)
+#define speex_resampler_get_rate CAT_PREFIX(RANDOM_PREFIX,_resampler_get_rate)
+#define speex_resampler_set_rate_frac CAT_PREFIX(RANDOM_PREFIX,_resampler_set_rate_frac)
+#define speex_resampler_get_ratio CAT_PREFIX(RANDOM_PREFIX,_resampler_get_ratio)
+#define speex_resampler_set_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_set_quality)
+#define speex_resampler_get_quality CAT_PREFIX(RANDOM_PREFIX,_resampler_get_quality)
+#define speex_resampler_set_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_input_stride)
+#define speex_resampler_get_input_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_stride)
+#define speex_resampler_set_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_set_output_stride)
+#define speex_resampler_get_output_stride CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_stride)
+#define speex_resampler_get_input_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_input_latency)
+#define speex_resampler_get_output_latency CAT_PREFIX(RANDOM_PREFIX,_resampler_get_output_latency)
+#define speex_resampler_skip_zeros CAT_PREFIX(RANDOM_PREFIX,_resampler_skip_zeros)
+#define speex_resampler_reset_mem CAT_PREFIX(RANDOM_PREFIX,_resampler_reset_mem)
+#define speex_resampler_strerror CAT_PREFIX(RANDOM_PREFIX,_resampler_strerror)
+
+#define spx_int16_t short
+#define spx_int32_t int
+#define spx_uint16_t unsigned short
+#define spx_uint32_t unsigned int
+
+#else /* OUTSIDE_SPEEX */
+
+#include "speex/speex_types.h"
+
+#endif /* OUTSIDE_SPEEX */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SPEEX_RESAMPLER_QUALITY_MAX 10
+#define SPEEX_RESAMPLER_QUALITY_MIN 0
+#define SPEEX_RESAMPLER_QUALITY_DEFAULT 4
+#define SPEEX_RESAMPLER_QUALITY_VOIP 3
+#define SPEEX_RESAMPLER_QUALITY_DESKTOP 5
+
+enum {
+ RESAMPLER_ERR_SUCCESS = 0,
+ RESAMPLER_ERR_ALLOC_FAILED = 1,
+ RESAMPLER_ERR_BAD_STATE = 2,
+ RESAMPLER_ERR_INVALID_ARG = 3,
+ RESAMPLER_ERR_PTR_OVERLAP = 4,
+
+ RESAMPLER_ERR_MAX_ERROR
+};
+
+struct SpeexResamplerState_;
+typedef struct SpeexResamplerState_ SpeexResamplerState;
+
+/** Create a new resampler with integer input and output rates.
+ * @param nb_channels Number of channels to be processed
+ * @param in_rate Input sampling rate (integer number of Hz).
+ * @param out_rate Output sampling rate (integer number of Hz).
+ * @param quality Resampling quality between 0 and 10, where 0 has poor quality
+ * and 10 has very high quality.
+ * @return Newly created resampler state
+ * @retval NULL Error: not enough memory
+ */
+SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels,
+ spx_uint32_t in_rate,
+ spx_uint32_t out_rate,
+ int quality,
+ int *err);
+
+/** Create a new resampler with fractional input/output rates. The sampling
+ * rate ratio is an arbitrary rational number with both the numerator and
+ * denominator being 32-bit integers.
+ * @param nb_channels Number of channels to be processed
+ * @param ratio_num Numerator of the sampling rate ratio
+ * @param ratio_den Denominator of the sampling rate ratio
+ * @param in_rate Input sampling rate rounded to the nearest integer (in Hz).
+ * @param out_rate Output sampling rate rounded to the nearest integer (in Hz).
+ * @param quality Resampling quality between 0 and 10, where 0 has poor quality
+ * and 10 has very high quality.
+ * @return Newly created resampler state
+ * @retval NULL Error: not enough memory
+ */
+SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels,
+ spx_uint32_t ratio_num,
+ spx_uint32_t ratio_den,
+ spx_uint32_t in_rate,
+ spx_uint32_t out_rate,
+ int quality,
+ int *err);
+
+/** Destroy a resampler state.
+ * @param st Resampler state
+ */
+void speex_resampler_destroy(SpeexResamplerState *st);
+
+/** Resample a float array. The input and output buffers must *not* overlap.
+ * @param st Resampler state
+ * @param channel_index Index of the channel to process for the multi-channel
+ * base (0 otherwise)
+ * @param in Input buffer
+ * @param in_len Number of input samples in the input buffer. Returns the
+ * number of samples processed
+ * @param out Output buffer
+ * @param out_len Size of the output buffer. Returns the number of samples written
+ */
+int speex_resampler_process_float(SpeexResamplerState *st,
+ spx_uint32_t channel_index,
+ const float *in,
+ spx_uint32_t *in_len,
+ float *out,
+ spx_uint32_t *out_len);
+
+/** Resample an int array. The input and output buffers must *not* overlap.
+ * @param st Resampler state
+ * @param channel_index Index of the channel to process for the multi-channel
+ * base (0 otherwise)
+ * @param in Input buffer
+ * @param in_len Number of input samples in the input buffer. Returns the number
+ * of samples processed
+ * @param out Output buffer
+ * @param out_len Size of the output buffer. Returns the number of samples written
+ */
+int speex_resampler_process_int(SpeexResamplerState *st,
+ spx_uint32_t channel_index,
+ const spx_int16_t *in,
+ spx_uint32_t *in_len,
+ spx_int16_t *out,
+ spx_uint32_t *out_len);
+
+/** Resample an interleaved float array. The input and output buffers must *not* overlap.
+ * @param st Resampler state
+ * @param in Input buffer
+ * @param in_len Number of input samples in the input buffer. Returns the number
+ * of samples processed. This is all per-channel.
+ * @param out Output buffer
+ * @param out_len Size of the output buffer. Returns the number of samples written.
+ * This is all per-channel.
+ */
+int speex_resampler_process_interleaved_float(SpeexResamplerState *st,
+ const float *in,
+ spx_uint32_t *in_len,
+ float *out,
+ spx_uint32_t *out_len);
+
+/** Resample an interleaved int array. The input and output buffers must *not* overlap.
+ * @param st Resampler state
+ * @param in Input buffer
+ * @param in_len Number of input samples in the input buffer. Returns the number
+ * of samples processed. This is all per-channel.
+ * @param out Output buffer
+ * @param out_len Size of the output buffer. Returns the number of samples written.
+ * This is all per-channel.
+ */
+int speex_resampler_process_interleaved_int(SpeexResamplerState *st,
+ const spx_int16_t *in,
+ spx_uint32_t *in_len,
+ spx_int16_t *out,
+ spx_uint32_t *out_len);
+
+/** Set (change) the input/output sampling rates (integer value).
+ * @param st Resampler state
+ * @param in_rate Input sampling rate (integer number of Hz).
+ * @param out_rate Output sampling rate (integer number of Hz).
+ */
+int speex_resampler_set_rate(SpeexResamplerState *st,
+ spx_uint32_t in_rate,
+ spx_uint32_t out_rate);
+
+/** Get the current input/output sampling rates (integer value).
+ * @param st Resampler state
+ * @param in_rate Input sampling rate (integer number of Hz) copied.
+ * @param out_rate Output sampling rate (integer number of Hz) copied.
+ */
+void speex_resampler_get_rate(SpeexResamplerState *st,
+ spx_uint32_t *in_rate,
+ spx_uint32_t *out_rate);
+
+/** Set (change) the input/output sampling rates and resampling ratio
+ * (fractional values in Hz supported).
+ * @param st Resampler state
+ * @param ratio_num Numerator of the sampling rate ratio
+ * @param ratio_den Denominator of the sampling rate ratio
+ * @param in_rate Input sampling rate rounded to the nearest integer (in Hz).
+ * @param out_rate Output sampling rate rounded to the nearest integer (in Hz).
+ */
+int speex_resampler_set_rate_frac(SpeexResamplerState *st,
+ spx_uint32_t ratio_num,
+ spx_uint32_t ratio_den,
+ spx_uint32_t in_rate,
+ spx_uint32_t out_rate);
+
+/** Get the current resampling ratio. This will be reduced to the least
+ * common denominator.
+ * @param st Resampler state
+ * @param ratio_num Numerator of the sampling rate ratio copied
+ * @param ratio_den Denominator of the sampling rate ratio copied
+ */
+void speex_resampler_get_ratio(SpeexResamplerState *st,
+ spx_uint32_t *ratio_num,
+ spx_uint32_t *ratio_den);
+
+/** Set (change) the conversion quality.
+ * @param st Resampler state
+ * @param quality Resampling quality between 0 and 10, where 0 has poor
+ * quality and 10 has very high quality.
+ */
+int speex_resampler_set_quality(SpeexResamplerState *st,
+ int quality);
+
+/** Get the conversion quality.
+ * @param st Resampler state
+ * @param quality Resampling quality between 0 and 10, where 0 has poor
+ * quality and 10 has very high quality.
+ */
+void speex_resampler_get_quality(SpeexResamplerState *st,
+ int *quality);
+
+/** Set (change) the input stride.
+ * @param st Resampler state
+ * @param stride Input stride
+ */
+void speex_resampler_set_input_stride(SpeexResamplerState *st,
+ spx_uint32_t stride);
+
+/** Get the input stride.
+ * @param st Resampler state
+ * @param stride Input stride copied
+ */
+void speex_resampler_get_input_stride(SpeexResamplerState *st,
+ spx_uint32_t *stride);
+
+/** Set (change) the output stride.
+ * @param st Resampler state
+ * @param stride Output stride
+ */
+void speex_resampler_set_output_stride(SpeexResamplerState *st,
+ spx_uint32_t stride);
+
+/** Get the output stride.
+ * @param st Resampler state copied
+ * @param stride Output stride
+ */
+void speex_resampler_get_output_stride(SpeexResamplerState *st,
+ spx_uint32_t *stride);
+
+/** Get the latency in input samples introduced by the resampler.
+ * @param st Resampler state
+ */
+int speex_resampler_get_input_latency(SpeexResamplerState *st);
+
+/** Get the latency in output samples introduced by the resampler.
+ * @param st Resampler state
+ */
+int speex_resampler_get_output_latency(SpeexResamplerState *st);
+
+/** Make sure that the first samples to go out of the resamplers don't have
+ * leading zeros. This is only useful before starting to use a newly created
+ * resampler. It is recommended to use that when resampling an audio file, as
+ * it will generate a file with the same length. For real-time processing,
+ * it is probably easier not to use this call (so that the output duration
+ * is the same for the first frame).
+ * @param st Resampler state
+ */
+int speex_resampler_skip_zeros(SpeexResamplerState *st);
+
+/** Reset a resampler so a new (unrelated) stream can be processed.
+ * @param st Resampler state
+ */
+int speex_resampler_reset_mem(SpeexResamplerState *st);
+
+/** Returns the English meaning for an error code
+ * @param err Error code
+ * @return English string
+ */
+const char *speex_resampler_strerror(int err);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/jni/pjproject-android/.svn/pristine/42/42c1c750dd66f8ab816414c759ec16eac4ea3e69.svn-base b/jni/pjproject-android/.svn/pristine/42/42c1c750dd66f8ab816414c759ec16eac4ea3e69.svn-base
new file mode 100644
index 0000000..6b83fd4
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/42/42c1c750dd66f8ab816414c759ec16eac4ea3e69.svn-base
@@ -0,0 +1 @@
+#include "../../../portaudio/src/hostapi/coreaudio/pa_mac_core_blocking.h"
diff --git a/jni/pjproject-android/.svn/pristine/42/42d736aafd19d099e8806b839080aca1ec6d3dcf.svn-base b/jni/pjproject-android/.svn/pristine/42/42d736aafd19d099e8806b839080aca1ec6d3dcf.svn-base
new file mode 100644
index 0000000..10116ff
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/42/42d736aafd19d099e8806b839080aca1ec6d3dcf.svn-base
@@ -0,0 +1,217 @@
+/* $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.h>
+#include <pjlib-util.h>
+#include <pjlib.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "util.h"
+
+
+/**
+ * \page page_pjmedia_samples_playfile_c Samples: Playing WAV File to Sound Device
+ *
+ * This is a very simple example to use the @ref PJMEDIA_FILE_PLAY and
+ * @ref PJMED_SND_PORT. In this example, we open both the file and sound
+ * device, and connect the two of them, and voila! Sound will be playing
+ * the contents of the file.
+ *
+ * @see page_pjmedia_samples_recfile_c
+ *
+ * This file is pjsip-apps/src/samples/playfile.c
+ *
+ * \includelineno playfile.c
+ */
+
+
+/*
+ * playfile.c
+ *
+ * PURPOSE:
+ * Play a WAV file to sound player device.
+ *
+ * USAGE:
+ * playfile FILE.WAV
+ *
+ * The WAV file could have mono or stereo channels with arbitrary
+ * sampling rate, but MUST contain uncompressed (i.e. 16bit) PCM.
+ *
+ */
+
+
+/* For logging purpose. */
+#define THIS_FILE "playfile.c"
+
+
+static const char *desc =
+" FILE \n"
+" \n"
+" playfile.c \n"
+" \n"
+" PURPOSE \n"
+" \n"
+" Demonstrate how to play a WAV file. \n"
+" \n"
+" USAGE \n"
+" \n"
+" playfile FILE.WAV \n"
+" \n"
+" The WAV file could have mono or stereo channels with arbitrary \n"
+" sampling rate, but MUST contain uncompressed (i.e. 16bit) PCM. \n";
+
+
+/*
+ * main()
+ */
+int main(int argc, char *argv[])
+{
+ pj_caching_pool cp;
+ pjmedia_endpt *med_endpt;
+ pj_pool_t *pool;
+ pjmedia_port *file_port;
+ pjmedia_snd_port *snd_port;
+ char tmp[10];
+ pj_status_t status;
+
+
+ if (argc != 2) {
+ puts("Error: filename required");
+ puts(desc);
+ return 1;
+ }
+
+
+ /* Must init PJLIB first: */
+ status = pj_init();
+ PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+ /* Must create a pool factory before we can allocate any memory. */
+ pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
+
+ /*
+ * Initialize media endpoint.
+ * This will implicitly initialize PJMEDIA too.
+ */
+ status = pjmedia_endpt_create(&cp.factory, NULL, 1, &med_endpt);
+ PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+ /* Create memory pool for our file player */
+ pool = pj_pool_create( &cp.factory, /* pool factory */
+ "wav", /* pool name. */
+ 4000, /* init size */
+ 4000, /* increment size */
+ NULL /* callback on error */
+ );
+
+ /* Create file media port from the WAV file */
+ status = pjmedia_wav_player_port_create( pool, /* memory pool */
+ argv[1], /* file to play */
+ 20, /* ptime. */
+ 0, /* flags */
+ 0, /* default buffer */
+ &file_port/* returned port */
+ );
+ if (status != PJ_SUCCESS) {
+ app_perror(THIS_FILE, "Unable to use WAV file", status);
+ return 1;
+ }
+
+ /* Create sound player port. */
+ status = pjmedia_snd_port_create_player(
+ pool, /* pool */
+ -1, /* use default dev. */
+ PJMEDIA_PIA_SRATE(&file_port->info),/* clock rate. */
+ PJMEDIA_PIA_CCNT(&file_port->info),/* # of channels. */
+ PJMEDIA_PIA_SPF(&file_port->info), /* samples per frame. */
+ PJMEDIA_PIA_BITS(&file_port->info),/* bits per sample. */
+ 0, /* options */
+ &snd_port /* returned port */
+ );
+ if (status != PJ_SUCCESS) {
+ app_perror(THIS_FILE, "Unable to open sound device", status);
+ return 1;
+ }
+
+ /* Connect file port to the sound player.
+ * Stream playing will commence immediately.
+ */
+ status = pjmedia_snd_port_connect( snd_port, file_port);
+ PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+
+ /*
+ * File should be playing and looping now, using sound device's thread.
+ */
+
+
+ /* Sleep to allow log messages to flush */
+ pj_thread_sleep(100);
+
+
+ printf("Playing %s..\n", argv[1]);
+ puts("");
+ puts("Press <ENTER> to stop playing and quit");
+
+ if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
+ puts("EOF while reading stdin, will quit now..");
+ }
+
+
+ /* Start deinitialization: */
+
+ /* Disconnect sound port from file port */
+ status = pjmedia_snd_port_disconnect(snd_port);
+ PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+ /* Without this sleep, Windows/DirectSound will repeteadly
+ * play the last frame during destroy.
+ */
+ pj_thread_sleep(100);
+
+ /* Destroy sound device */
+ status = pjmedia_snd_port_destroy( snd_port );
+ PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+ /* Destroy file port */
+ status = pjmedia_port_destroy( file_port );
+ PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
+
+
+ /* Release application pool */
+ pj_pool_release( pool );
+
+ /* Destroy media endpoint. */
+ pjmedia_endpt_destroy( med_endpt );
+
+ /* Destroy pool factory */
+ pj_caching_pool_destroy( &cp );
+
+ /* Shutdown PJLIB */
+ pj_shutdown();
+
+
+ /* Done. */
+ return 0;
+}
+
diff --git a/jni/pjproject-android/.svn/pristine/42/42e74e5e5bf75b9fc4a9e17beafc3dbc7132ced3.svn-base b/jni/pjproject-android/.svn/pristine/42/42e74e5e5bf75b9fc4a9e17beafc3dbc7132ced3.svn-base
new file mode 100644
index 0000000..a398b8c
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/42/42e74e5e5bf75b9fc4a9e17beafc3dbc7132ced3.svn-base
@@ -0,0 +1,678 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <pjmedia-videodev/videodev_imp.h>
+#include <pjmedia-videodev/avi_dev.h>
+#include <pj/assert.h>
+#include <pj/log.h>
+#include <pj/os.h>
+#include <pj/rand.h>
+#include <pjmedia/vid_codec.h>
+
+#if defined(PJMEDIA_VIDEO_DEV_HAS_AVI) && PJMEDIA_VIDEO_DEV_HAS_AVI != 0 && \
+ defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
+
+#define THIS_FILE "avi_dev.c"
+#define DRIVER_NAME "AVIDev"
+#define DEFAULT_CLOCK_RATE 90000
+#define DEFAULT_WIDTH 640
+#define DEFAULT_HEIGHT 480
+#define DEFAULT_FPS 25
+
+typedef struct avi_dev_strm avi_dev_strm;
+
+/* avi_ device info */
+struct avi_dev_info
+{
+ pjmedia_vid_dev_info info;
+
+ pj_pool_t *pool;
+ pj_str_t fpath;
+ pj_str_t title;
+ pjmedia_avi_streams *avi;
+ pjmedia_port *vid;
+ avi_dev_strm *strm;
+ pjmedia_vid_codec *codec;
+ pj_uint8_t *enc_buf;
+ pj_size_t enc_buf_size;
+};
+
+/* avi_ factory */
+struct avi_factory
+{
+ pjmedia_vid_dev_factory base;
+ pj_pool_t *pool;
+ pj_pool_factory *pf;
+
+ unsigned dev_count;
+ struct avi_dev_info *dev_info;
+};
+
+/* Video stream. */
+struct avi_dev_strm
+{
+ pjmedia_vid_dev_stream base; /**< Base stream */
+ pjmedia_vid_dev_param param; /**< Settings */
+ pj_pool_t *pool; /**< Memory pool. */
+ struct avi_dev_info *adi;
+
+ pjmedia_vid_dev_cb vid_cb; /**< Stream callback. */
+ void *user_data; /**< Application data. */
+};
+
+
+/* Prototypes */
+static pj_status_t avi_factory_init(pjmedia_vid_dev_factory *f);
+static pj_status_t avi_factory_destroy(pjmedia_vid_dev_factory *f);
+static pj_status_t avi_factory_refresh(pjmedia_vid_dev_factory *f);
+static unsigned avi_factory_get_dev_count(pjmedia_vid_dev_factory *f);
+static pj_status_t avi_factory_get_dev_info(pjmedia_vid_dev_factory *f,
+ unsigned index,
+ pjmedia_vid_dev_info *info);
+static pj_status_t avi_factory_default_param(pj_pool_t *pool,
+ pjmedia_vid_dev_factory *f,
+ unsigned index,
+ pjmedia_vid_dev_param *param);
+static pj_status_t avi_factory_create_stream(
+ pjmedia_vid_dev_factory *f,
+ pjmedia_vid_dev_param *param,
+ const pjmedia_vid_dev_cb *cb,
+ void *user_data,
+ pjmedia_vid_dev_stream **p_vid_strm);
+
+static pj_status_t avi_dev_strm_get_param(pjmedia_vid_dev_stream *strm,
+ pjmedia_vid_dev_param *param);
+static pj_status_t avi_dev_strm_get_cap(pjmedia_vid_dev_stream *strm,
+ pjmedia_vid_dev_cap cap,
+ void *value);
+static pj_status_t avi_dev_strm_set_cap(pjmedia_vid_dev_stream *strm,
+ pjmedia_vid_dev_cap cap,
+ const void *value);
+static pj_status_t avi_dev_strm_get_frame(pjmedia_vid_dev_stream *strm,
+ pjmedia_frame *frame);
+static pj_status_t avi_dev_strm_start(pjmedia_vid_dev_stream *strm);
+static pj_status_t avi_dev_strm_stop(pjmedia_vid_dev_stream *strm);
+static pj_status_t avi_dev_strm_destroy(pjmedia_vid_dev_stream *strm);
+
+static void reset_dev_info(struct avi_dev_info *adi);
+
+/* Operations */
+static pjmedia_vid_dev_factory_op factory_op =
+{
+ &avi_factory_init,
+ &avi_factory_destroy,
+ &avi_factory_get_dev_count,
+ &avi_factory_get_dev_info,
+ &avi_factory_default_param,
+ &avi_factory_create_stream,
+ &avi_factory_refresh
+};
+
+static pjmedia_vid_dev_stream_op stream_op =
+{
+ &avi_dev_strm_get_param,
+ &avi_dev_strm_get_cap,
+ &avi_dev_strm_set_cap,
+ &avi_dev_strm_start,
+ &avi_dev_strm_get_frame,
+ NULL,
+ &avi_dev_strm_stop,
+ &avi_dev_strm_destroy
+};
+
+
+/****************************************************************************
+ * Factory operations
+ */
+
+/* API */
+PJ_DEF(pj_status_t) pjmedia_avi_dev_create_factory(
+ pj_pool_factory *pf,
+ unsigned max_dev,
+ pjmedia_vid_dev_factory **p_ret)
+{
+ struct avi_factory *cf;
+ pj_pool_t *pool;
+ pj_status_t status;
+
+ pool = pj_pool_create(pf, "avidevfc%p", 512, 512, NULL);
+ cf = PJ_POOL_ZALLOC_T(pool, struct avi_factory);
+ cf->pf = pf;
+ cf->pool = pool;
+ cf->dev_count = max_dev;
+ cf->base.op = &factory_op;
+
+ cf->dev_info = (struct avi_dev_info*)
+ pj_pool_calloc(cf->pool, cf->dev_count,
+ sizeof(struct avi_dev_info));
+
+ if (p_ret) {
+ *p_ret = &cf->base;
+ }
+
+ status = pjmedia_vid_register_factory(NULL, &cf->base);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ PJ_LOG(4, (THIS_FILE, "AVI dev factory created with %d virtual device(s)",
+ cf->dev_count));
+
+ return PJ_SUCCESS;
+}
+
+/* API: init factory */
+static pj_status_t avi_factory_init(pjmedia_vid_dev_factory *f)
+{
+ struct avi_factory *cf = (struct avi_factory*)f;
+ unsigned i;
+
+ for (i=0; i<cf->dev_count; ++i) {
+ reset_dev_info(&cf->dev_info[i]);
+ }
+
+ return PJ_SUCCESS;
+}
+
+/* API: destroy factory */
+static pj_status_t avi_factory_destroy(pjmedia_vid_dev_factory *f)
+{
+ struct avi_factory *cf = (struct avi_factory*)f;
+ pj_pool_t *pool = cf->pool;
+
+ cf->pool = NULL;
+ pj_pool_release(pool);
+
+ return PJ_SUCCESS;
+}
+
+/* API: refresh the list of devices */
+static pj_status_t avi_factory_refresh(pjmedia_vid_dev_factory *f)
+{
+ PJ_UNUSED_ARG(f);
+ return PJ_SUCCESS;
+}
+
+/* API: get number of devices */
+static unsigned avi_factory_get_dev_count(pjmedia_vid_dev_factory *f)
+{
+ struct avi_factory *cf = (struct avi_factory*)f;
+ return cf->dev_count;
+}
+
+/* API: get device info */
+static pj_status_t avi_factory_get_dev_info(pjmedia_vid_dev_factory *f,
+ unsigned index,
+ pjmedia_vid_dev_info *info)
+{
+ struct avi_factory *cf = (struct avi_factory*)f;
+
+ PJ_ASSERT_RETURN(index < cf->dev_count, PJMEDIA_EVID_INVDEV);
+
+ pj_memcpy(info, &cf->dev_info[index].info, sizeof(*info));
+
+ return PJ_SUCCESS;
+}
+
+/* API: create default device parameter */
+static pj_status_t avi_factory_default_param(pj_pool_t *pool,
+ pjmedia_vid_dev_factory *f,
+ unsigned index,
+ pjmedia_vid_dev_param *param)
+{
+ struct avi_factory *cf = (struct avi_factory*)f;
+ struct avi_dev_info *di = &cf->dev_info[index];
+
+ PJ_ASSERT_RETURN(index < cf->dev_count, PJMEDIA_EVID_INVDEV);
+
+ PJ_UNUSED_ARG(pool);
+
+ pj_bzero(param, sizeof(*param));
+ param->dir = PJMEDIA_DIR_CAPTURE;
+ param->cap_id = index;
+ param->rend_id = PJMEDIA_VID_INVALID_DEV;
+ param->flags = PJMEDIA_VID_DEV_CAP_FORMAT;
+ param->clock_rate = DEFAULT_CLOCK_RATE;
+ pj_memcpy(¶m->fmt, &di->info.fmt[0], sizeof(param->fmt));
+
+ return PJ_SUCCESS;
+}
+
+/* reset dev info */
+static void reset_dev_info(struct avi_dev_info *adi)
+{
+ /* Close avi streams */
+ if (adi->avi) {
+ unsigned i, cnt;
+
+ cnt = pjmedia_avi_streams_get_num_streams(adi->avi);
+ for (i=0; i<cnt; ++i) {
+ pjmedia_avi_stream *as;
+
+ as = pjmedia_avi_streams_get_stream(adi->avi, i);
+ if (as) {
+ pjmedia_port *port;
+ port = pjmedia_avi_stream_get_port(as);
+ pjmedia_port_destroy(port);
+ }
+ }
+ adi->avi = NULL;
+ }
+
+ if (adi->codec) {
+ pjmedia_vid_codec_close(adi->codec);
+ adi->codec = NULL;
+ }
+
+ if (adi->pool)
+ pj_pool_release(adi->pool);
+
+ pj_bzero(adi, sizeof(*adi));
+
+ /* Fill up with *dummy" device info */
+ pj_ansi_strncpy(adi->info.name, "AVI Player", sizeof(adi->info.name)-1);
+ pj_ansi_strncpy(adi->info.driver, DRIVER_NAME, sizeof(adi->info.driver)-1);
+ adi->info.dir = PJMEDIA_DIR_CAPTURE;
+ adi->info.has_callback = PJ_FALSE;
+}
+
+/* API: release resources */
+PJ_DEF(pj_status_t) pjmedia_avi_dev_free(pjmedia_vid_dev_index id)
+{
+ pjmedia_vid_dev_factory *f;
+ struct avi_factory *cf;
+ unsigned local_idx;
+ struct avi_dev_info *adi;
+ pj_status_t status;
+
+ /* Lookup the factory and local device index */
+ status = pjmedia_vid_dev_get_local_index(id, &f, &local_idx);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* The factory must be AVI factory */
+ PJ_ASSERT_RETURN(f->op->init == &avi_factory_init, PJMEDIA_EVID_INVDEV);
+ cf = (struct avi_factory*)f;
+
+ /* Device index should be valid */
+ PJ_ASSERT_RETURN(local_idx <= cf->dev_count, PJ_EBUG);
+ adi = &cf->dev_info[local_idx];
+
+ /* Cannot configure if stream is running */
+ if (adi->strm)
+ return PJ_EBUSY;
+
+ /* Reset */
+ reset_dev_info(adi);
+ return PJ_SUCCESS;
+}
+
+/* API: get param */
+PJ_DEF(pj_status_t) pjmedia_avi_dev_get_param(pjmedia_vid_dev_index id,
+ pjmedia_avi_dev_param *prm)
+{
+ pjmedia_vid_dev_factory *f;
+ struct avi_factory *cf;
+ unsigned local_idx;
+ struct avi_dev_info *adi;
+ pj_status_t status;
+
+ /* Lookup the factory and local device index */
+ status = pjmedia_vid_dev_get_local_index(id, &f, &local_idx);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* The factory must be factory */
+ PJ_ASSERT_RETURN(f->op->init == &avi_factory_init, PJMEDIA_EVID_INVDEV);
+ cf = (struct avi_factory*)f;
+
+ /* Device index should be valid */
+ PJ_ASSERT_RETURN(local_idx <= cf->dev_count, PJ_EBUG);
+ adi = &cf->dev_info[local_idx];
+
+ pj_bzero(prm, sizeof(*prm));
+ prm->path = adi->fpath;
+ prm->title = adi->title;
+ prm->avi_streams = adi->avi;
+
+ return PJ_SUCCESS;
+}
+
+PJ_DEF(void) pjmedia_avi_dev_param_default(pjmedia_avi_dev_param *p)
+{
+ pj_bzero(p, sizeof(*p));
+}
+
+/* API: configure the AVI */
+PJ_DEF(pj_status_t) pjmedia_avi_dev_alloc( pjmedia_vid_dev_factory *f,
+ pjmedia_avi_dev_param *p,
+ pjmedia_vid_dev_index *p_id)
+{
+ pjmedia_vid_dev_index id;
+ struct avi_factory *cf = (struct avi_factory*)f;
+ unsigned local_idx;
+ struct avi_dev_info *adi = NULL;
+ pjmedia_format avi_fmt;
+ const pjmedia_video_format_info *vfi;
+ pj_status_t status;
+
+ PJ_ASSERT_RETURN(f && p && p_id, PJ_EINVAL);
+
+ if (p_id)
+ *p_id = PJMEDIA_VID_INVALID_DEV;
+
+ /* Get a free dev */
+ for (local_idx=0; local_idx<cf->dev_count; ++local_idx) {
+ if (cf->dev_info[local_idx].avi == NULL) {
+ adi = &cf->dev_info[local_idx];
+ break;
+ }
+ }
+
+ if (!adi)
+ return PJ_ETOOMANY;
+
+ /* Convert local ID to global id */
+ status = pjmedia_vid_dev_get_global_index(&cf->base, local_idx, &id);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* Reset */
+ if (adi->pool) {
+ pj_pool_release(adi->pool);
+ }
+ pj_bzero(adi, sizeof(*adi));
+
+ /* Reinit */
+ PJ_ASSERT_RETURN(p->path.slen, PJ_EINVAL);
+ adi->pool = pj_pool_create(cf->pf, "avidi%p", 512, 512, NULL);
+
+
+ /* Open the AVI */
+ pj_strdup_with_null(adi->pool, &adi->fpath, &p->path);
+ status = pjmedia_avi_player_create_streams(adi->pool, adi->fpath.ptr, 0,
+ &adi->avi);
+ if (status != PJ_SUCCESS) {
+ goto on_error;
+ }
+
+ adi->vid = pjmedia_avi_streams_get_stream_by_media(adi->avi, 0,
+ PJMEDIA_TYPE_VIDEO);
+ if (!adi->vid) {
+ status = PJMEDIA_EVID_BADFORMAT;
+ PJ_LOG(4,(THIS_FILE, "Error: cannot find video in AVI %s",
+ adi->fpath.ptr));
+ goto on_error;
+ }
+
+ pjmedia_format_copy(&avi_fmt, &adi->vid->info.fmt);
+ vfi = pjmedia_get_video_format_info(NULL, avi_fmt.id);
+ /* Check whether the frame is encoded. */
+ if (!vfi || vfi->bpp == 0) {
+ /* Yes, prepare codec */
+ const pjmedia_vid_codec_info *codec_info;
+ pjmedia_vid_codec_param codec_param;
+ pjmedia_video_apply_fmt_param vafp;
+
+ /* Lookup codec */
+ status = pjmedia_vid_codec_mgr_get_codec_info2(NULL,
+ avi_fmt.id,
+ &codec_info);
+ if (status != PJ_SUCCESS || !codec_info)
+ goto on_error;
+
+ status = pjmedia_vid_codec_mgr_get_default_param(NULL, codec_info,
+ &codec_param);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+
+ /* Open codec */
+ status = pjmedia_vid_codec_mgr_alloc_codec(NULL, codec_info,
+ &adi->codec);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+
+ status = pjmedia_vid_codec_init(adi->codec, adi->pool);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+
+ codec_param.dir = PJMEDIA_DIR_DECODING;
+ codec_param.packing = PJMEDIA_VID_PACKING_WHOLE;
+ status = pjmedia_vid_codec_open(adi->codec, &codec_param);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+
+ /* Allocate buffer */
+ avi_fmt.id = codec_info->dec_fmt_id[0];
+ vfi = pjmedia_get_video_format_info(NULL, avi_fmt.id);
+ pj_bzero(&vafp, sizeof(vafp));
+ vafp.size = avi_fmt.det.vid.size;
+ status = vfi->apply_fmt(vfi, &vafp);
+ if (status != PJ_SUCCESS)
+ goto on_error;
+
+ adi->enc_buf = pj_pool_alloc(adi->pool, vafp.framebytes);
+ adi->enc_buf_size = vafp.framebytes;
+ }
+
+ /* Calculate title */
+ if (p->title.slen) {
+ pj_strdup_with_null(adi->pool, &adi->title, &p->title);
+ } else {
+ char *start = p->path.ptr + p->path.slen;
+ pj_str_t tmp;
+
+ while (start >= p->path.ptr) {
+ if (*start == '/' || *start == '\\')
+ break;
+ --start;
+ }
+ tmp.ptr = start + 1;
+ tmp.slen = p->path.ptr + p->path.slen - tmp.ptr;
+ pj_strdup_with_null(adi->pool, &adi->title, &tmp);
+ }
+
+ /* Init device info */
+ pj_ansi_strncpy(adi->info.name, adi->title.ptr, sizeof(adi->info.name)-1);
+ pj_ansi_strncpy(adi->info.driver, DRIVER_NAME, sizeof(adi->info.driver)-1);
+ adi->info.dir = PJMEDIA_DIR_CAPTURE;
+ adi->info.has_callback = PJ_FALSE;
+
+ adi->info.caps = PJMEDIA_VID_DEV_CAP_FORMAT;
+ adi->info.fmt_cnt = 1;
+ pjmedia_format_copy(&adi->info.fmt[0], &avi_fmt);
+
+ /* Set out vars */
+ if (p_id)
+ *p_id = id;
+ p->avi_streams = adi->avi;
+ if (p->title.slen == 0)
+ p->title = adi->title;
+
+ return PJ_SUCCESS;
+
+on_error:
+ if (adi->codec) {
+ pjmedia_vid_codec_close(adi->codec);
+ adi->codec = NULL;
+ }
+ if (adi->pool) {
+ pj_pool_release(adi->pool);
+ adi->pool = NULL;
+ }
+ pjmedia_avi_dev_free(id);
+ return status;
+}
+
+
+/* API: create stream */
+static pj_status_t avi_factory_create_stream(
+ pjmedia_vid_dev_factory *f,
+ pjmedia_vid_dev_param *param,
+ const pjmedia_vid_dev_cb *cb,
+ void *user_data,
+ pjmedia_vid_dev_stream **p_vid_strm)
+{
+ struct avi_factory *cf = (struct avi_factory*)f;
+ pj_pool_t *pool = NULL;
+ struct avi_dev_info *adi;
+ struct avi_dev_strm *strm;
+
+ PJ_ASSERT_RETURN(f && param && p_vid_strm, PJ_EINVAL);
+ PJ_ASSERT_RETURN(param->fmt.type == PJMEDIA_TYPE_VIDEO &&
+ param->fmt.detail_type == PJMEDIA_FORMAT_DETAIL_VIDEO &&
+ param->dir == PJMEDIA_DIR_CAPTURE,
+ PJ_EINVAL);
+
+ /* Device must have been configured with pjmedia_avi_dev_set_param() */
+ adi = &cf->dev_info[param->cap_id];
+ PJ_ASSERT_RETURN(adi->avi != NULL, PJ_EINVALIDOP);
+
+ /* Cannot create while stream is already active */
+ PJ_ASSERT_RETURN(adi->strm==NULL, PJ_EINVALIDOP);
+
+ /* Create and initialize basic stream descriptor */
+ pool = pj_pool_create(cf->pf, "avidev%p", 512, 512, NULL);
+ PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);
+
+ strm = PJ_POOL_ZALLOC_T(pool, struct avi_dev_strm);
+ pj_memcpy(&strm->param, param, sizeof(*param));
+ strm->pool = pool;
+ pj_memcpy(&strm->vid_cb, cb, sizeof(*cb));
+ strm->user_data = user_data;
+ strm->adi = adi;
+
+ pjmedia_format_copy(¶m->fmt, &adi->info.fmt[0]);
+
+ /* Done */
+ strm->base.op = &stream_op;
+ adi->strm = strm;
+ *p_vid_strm = &strm->base;
+
+ return PJ_SUCCESS;
+}
+
+/* API: Get stream info. */
+static pj_status_t avi_dev_strm_get_param(pjmedia_vid_dev_stream *s,
+ pjmedia_vid_dev_param *pi)
+{
+ struct avi_dev_strm *strm = (struct avi_dev_strm*)s;
+
+ PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL);
+
+ pj_memcpy(pi, &strm->param, sizeof(*pi));
+
+ return PJ_SUCCESS;
+}
+
+/* API: get capability */
+static pj_status_t avi_dev_strm_get_cap(pjmedia_vid_dev_stream *s,
+ pjmedia_vid_dev_cap cap,
+ void *pval)
+{
+ struct avi_dev_strm *strm = (struct avi_dev_strm*)s;
+
+ PJ_UNUSED_ARG(strm);
+ PJ_UNUSED_ARG(cap);
+ PJ_UNUSED_ARG(pval);
+
+ PJ_ASSERT_RETURN(s && pval, PJ_EINVAL);
+
+ return PJMEDIA_EVID_INVCAP;
+}
+
+/* API: set capability */
+static pj_status_t avi_dev_strm_set_cap(pjmedia_vid_dev_stream *s,
+ pjmedia_vid_dev_cap cap,
+ const void *pval)
+{
+ struct avi_dev_strm *strm = (struct avi_dev_strm*)s;
+
+ PJ_UNUSED_ARG(strm);
+ PJ_UNUSED_ARG(cap);
+ PJ_UNUSED_ARG(pval);
+
+ PJ_ASSERT_RETURN(s && pval, PJ_EINVAL);
+
+ return PJMEDIA_EVID_INVCAP;
+}
+
+/* API: Get frame from stream */
+static pj_status_t avi_dev_strm_get_frame(pjmedia_vid_dev_stream *strm,
+ pjmedia_frame *frame)
+{
+ struct avi_dev_strm *stream = (struct avi_dev_strm*)strm;
+
+ if (stream->adi->codec) {
+ pjmedia_frame enc_frame;
+ pj_status_t status;
+
+ enc_frame.buf = stream->adi->enc_buf;
+ enc_frame.size = stream->adi->enc_buf_size;
+ status = pjmedia_port_get_frame(stream->adi->vid, &enc_frame);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ return pjmedia_vid_codec_decode(stream->adi->codec, 1, &enc_frame,
+ (unsigned)frame->size, frame);
+ } else {
+ return pjmedia_port_get_frame(stream->adi->vid, frame);
+ }
+}
+
+/* API: Start stream. */
+static pj_status_t avi_dev_strm_start(pjmedia_vid_dev_stream *strm)
+{
+ struct avi_dev_strm *stream = (struct avi_dev_strm*)strm;
+
+ PJ_UNUSED_ARG(stream);
+
+ PJ_LOG(4, (THIS_FILE, "Starting avi video stream"));
+
+ return PJ_SUCCESS;
+}
+
+/* API: Stop stream. */
+static pj_status_t avi_dev_strm_stop(pjmedia_vid_dev_stream *strm)
+{
+ struct avi_dev_strm *stream = (struct avi_dev_strm*)strm;
+
+ PJ_UNUSED_ARG(stream);
+
+ PJ_LOG(4, (THIS_FILE, "Stopping avi video stream"));
+
+ return PJ_SUCCESS;
+}
+
+
+/* API: Destroy stream. */
+static pj_status_t avi_dev_strm_destroy(pjmedia_vid_dev_stream *strm)
+{
+ struct avi_dev_strm *stream = (struct avi_dev_strm*)strm;
+
+ PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL);
+
+ avi_dev_strm_stop(strm);
+
+ stream->adi->strm = NULL;
+ stream->adi = NULL;
+ pj_pool_release(stream->pool);
+
+ return PJ_SUCCESS;
+}
+
+#endif /* PJMEDIA_VIDEO_DEV_HAS_AVI */