* #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/69/69282b11f74328fce376c2a8be8f160d51cd91f4.svn-base b/jni/pjproject-android/.svn/pristine/69/69282b11f74328fce376c2a8be8f160d51cd91f4.svn-base
new file mode 100644
index 0000000..efda319
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/69/69282b11f74328fce376c2a8be8f160d51cd91f4.svn-base
@@ -0,0 +1,980 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2009-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2007-2009 Keystream AB and Konftel AB, All rights reserved.
+ *                         Author: <dan.aberg@keystream.se>
+ *
+ * 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_audiodev.h>
+#include <pj/assert.h>
+#include <pj/log.h>
+#include <pj/os.h>
+#include <pj/pool.h>
+#include <pjmedia/errno.h>
+
+#if defined(PJMEDIA_AUDIO_DEV_HAS_ALSA) && PJMEDIA_AUDIO_DEV_HAS_ALSA
+
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/select.h>
+#include <pthread.h>
+#include <errno.h>
+#include <alsa/asoundlib.h>
+
+
+#define THIS_FILE 			"alsa_dev.c"
+#define ALSA_DEVICE_NAME 		"plughw:%d,%d"
+#define ALSASOUND_PLAYBACK 		1
+#define ALSASOUND_CAPTURE  		2
+#define MAX_SOUND_CARDS 		5
+#define MAX_SOUND_DEVICES_PER_CARD 	5
+#define MAX_DEVICES			16
+
+/* Set to 1 to enable tracing */
+#if 0
+#	define TRACE_(expr)		PJ_LOG(5,expr)
+#else
+#	define TRACE_(expr)
+#endif
+
+/*
+ * Factory prototypes
+ */
+static pj_status_t alsa_factory_init(pjmedia_aud_dev_factory *f);
+static pj_status_t alsa_factory_destroy(pjmedia_aud_dev_factory *f);
+static pj_status_t alsa_factory_refresh(pjmedia_aud_dev_factory *f);
+static unsigned    alsa_factory_get_dev_count(pjmedia_aud_dev_factory *f);
+static pj_status_t alsa_factory_get_dev_info(pjmedia_aud_dev_factory *f,
+					     unsigned index,
+					     pjmedia_aud_dev_info *info);
+static pj_status_t alsa_factory_default_param(pjmedia_aud_dev_factory *f,
+					      unsigned index,
+					      pjmedia_aud_param *param);
+static pj_status_t alsa_factory_create_stream(pjmedia_aud_dev_factory *f,
+					      const pjmedia_aud_param *param,
+					      pjmedia_aud_rec_cb rec_cb,
+					      pjmedia_aud_play_cb play_cb,
+					      void *user_data,
+					      pjmedia_aud_stream **p_strm);
+
+/*
+ * Stream prototypes
+ */
+static pj_status_t alsa_stream_get_param(pjmedia_aud_stream *strm,
+					 pjmedia_aud_param *param);
+static pj_status_t alsa_stream_get_cap(pjmedia_aud_stream *strm,
+				       pjmedia_aud_dev_cap cap,
+				       void *value);
+static pj_status_t alsa_stream_set_cap(pjmedia_aud_stream *strm,
+				       pjmedia_aud_dev_cap cap,
+				       const void *value);
+static pj_status_t alsa_stream_start(pjmedia_aud_stream *strm);
+static pj_status_t alsa_stream_stop(pjmedia_aud_stream *strm);
+static pj_status_t alsa_stream_destroy(pjmedia_aud_stream *strm);
+
+
+struct alsa_factory
+{
+    pjmedia_aud_dev_factory	 base;
+    pj_pool_factory		*pf;
+    pj_pool_t			*pool;
+    pj_pool_t			*base_pool;
+
+    unsigned			 dev_cnt;
+    pjmedia_aud_dev_info	 devs[MAX_DEVICES];
+};
+
+struct alsa_stream
+{
+    pjmedia_aud_stream	 base;
+
+    /* Common */
+    pj_pool_t		*pool;
+    struct alsa_factory *af;
+    void		*user_data;
+    pjmedia_aud_param	 param;		/* Running parameter 		*/
+    int                  rec_id;      	/* Capture device id		*/
+    int                  quit;
+
+    /* Playback */
+    snd_pcm_t		*pb_pcm;
+    snd_pcm_uframes_t    pb_frames; 	/* samples_per_frame		*/
+    pjmedia_aud_play_cb  pb_cb;
+    unsigned             pb_buf_size;
+    char		*pb_buf;
+    pj_thread_t		*pb_thread;
+
+    /* Capture */
+    snd_pcm_t		*ca_pcm;
+    snd_pcm_uframes_t    ca_frames; 	/* samples_per_frame		*/
+    pjmedia_aud_rec_cb   ca_cb;
+    unsigned             ca_buf_size;
+    char		*ca_buf;
+    pj_thread_t		*ca_thread;
+};
+
+static pjmedia_aud_dev_factory_op alsa_factory_op =
+{
+    &alsa_factory_init,
+    &alsa_factory_destroy,
+    &alsa_factory_get_dev_count,
+    &alsa_factory_get_dev_info,
+    &alsa_factory_default_param,
+    &alsa_factory_create_stream,
+    &alsa_factory_refresh
+};
+
+static pjmedia_aud_stream_op alsa_stream_op =
+{
+    &alsa_stream_get_param,
+    &alsa_stream_get_cap,
+    &alsa_stream_set_cap,
+    &alsa_stream_start,
+    &alsa_stream_stop,
+    &alsa_stream_destroy
+};
+
+static void null_alsa_error_handler (const char *file,
+				int line,
+				const char *function,
+				int err,
+				const char *fmt,
+				...)
+{
+    PJ_UNUSED_ARG(file);
+    PJ_UNUSED_ARG(line);
+    PJ_UNUSED_ARG(function);
+    PJ_UNUSED_ARG(err);
+    PJ_UNUSED_ARG(fmt);
+}
+
+static void alsa_error_handler (const char *file,
+				int line,
+				const char *function,
+				int err,
+				const char *fmt,
+				...)
+{
+    char err_msg[128];
+    int index;
+    va_list arg;
+
+#ifndef NDEBUG
+    index = snprintf (err_msg, sizeof(err_msg), "ALSA lib %s:%i:(%s) ",
+		      file, line, function);
+#else
+    index = snprintf (err_msg, sizeof(err_msg), "ALSA lib: ");
+#endif
+    va_start (arg, fmt);
+    if (index < sizeof(err_msg)-1)
+	index += vsnprintf (err_msg+index, sizeof(err_msg)-index, fmt, arg);
+    va_end(arg);
+    if (err && index < sizeof(err_msg)-1)
+	index += snprintf (err_msg+index, sizeof(err_msg)-index, ": %s",
+			   snd_strerror(err));
+    PJ_LOG (4,(THIS_FILE, "%s", err_msg));
+}
+
+
+static pj_status_t add_dev (struct alsa_factory *af, const char *dev_name)
+{
+    pjmedia_aud_dev_info *adi;
+    snd_pcm_t* pcm;
+    int pb_result, ca_result;
+
+    if (af->dev_cnt >= PJ_ARRAY_SIZE(af->devs))
+	return PJ_ETOOMANY;
+
+    adi = &af->devs[af->dev_cnt];
+
+    TRACE_((THIS_FILE, "add_dev (%s): Enter", dev_name));
+
+    /* Try to open the device in playback mode */
+    pb_result = snd_pcm_open (&pcm, dev_name, SND_PCM_STREAM_PLAYBACK, 0);
+    if (pb_result >= 0) {
+	TRACE_((THIS_FILE, "Try to open the device for playback - success"));
+	snd_pcm_close (pcm);
+    } else {
+	TRACE_((THIS_FILE, "Try to open the device for playback - failure"));
+    }
+
+    /* Try to open the device in capture mode */
+    ca_result = snd_pcm_open (&pcm, dev_name, SND_PCM_STREAM_CAPTURE, 0);
+    if (ca_result >= 0) {
+	TRACE_((THIS_FILE, "Try to open the device for capture - success"));
+	snd_pcm_close (pcm);
+    } else {
+	TRACE_((THIS_FILE, "Try to open the device for capture - failure"));
+    }
+
+    /* Check if the device could be opened in playback or capture mode */
+    if (pb_result<0 && ca_result<0) {
+	TRACE_((THIS_FILE, "Unable to open sound device %s", dev_name));
+	return PJMEDIA_EAUD_NODEV;
+    }
+
+    /* Reset device info */
+    pj_bzero(adi, sizeof(*adi));
+
+    /* Set device name */
+    strncpy(adi->name, dev_name, sizeof(adi->name));
+
+    /* Check the number of playback channels */
+    adi->output_count = (pb_result>=0) ? 1 : 0;
+
+    /* Check the number of capture channels */
+    adi->input_count = (ca_result>=0) ? 1 : 0;
+
+    /* Set the default sample rate */
+    adi->default_samples_per_sec = 8000;
+
+    /* Driver name */
+    strcpy(adi->driver, "ALSA");
+
+    ++af->dev_cnt;
+
+    PJ_LOG (5,(THIS_FILE, "Added sound device %s", adi->name));
+
+    return PJ_SUCCESS;
+}
+
+
+/* Create ALSA audio driver. */
+pjmedia_aud_dev_factory* pjmedia_alsa_factory(pj_pool_factory *pf)
+{
+    struct alsa_factory *af;
+    pj_pool_t *pool;
+
+    pool = pj_pool_create(pf, "alsa_aud_base", 256, 256, NULL);
+    af = PJ_POOL_ZALLOC_T(pool, struct alsa_factory);
+    af->pf = pf;
+    af->base_pool = pool;
+    af->base.op = &alsa_factory_op;
+
+    return &af->base;
+}
+
+
+/* API: init factory */
+static pj_status_t alsa_factory_init(pjmedia_aud_dev_factory *f)
+{
+    pj_status_t status = alsa_factory_refresh(f);
+    if (PJ_SUCCESS != status)
+	return status;
+
+    PJ_LOG(4,(THIS_FILE, "ALSA initialized"));
+    return PJ_SUCCESS;
+}
+
+
+/* API: destroy factory */
+static pj_status_t alsa_factory_destroy(pjmedia_aud_dev_factory *f)
+{
+    struct alsa_factory *af = (struct alsa_factory*)f;
+
+    if (af->pool)
+	pj_pool_release(af->pool);
+
+    if (af->base_pool) {
+	pj_pool_t *pool = af->base_pool;
+	af->base_pool = NULL;
+	pj_pool_release(pool);
+    }
+
+    /* Restore handler */
+    snd_lib_error_set_handler(NULL);
+
+    return PJ_SUCCESS;
+}
+
+
+/* API: refresh the device list */
+static pj_status_t alsa_factory_refresh(pjmedia_aud_dev_factory *f)
+{
+    struct alsa_factory *af = (struct alsa_factory*)f;
+    char **hints, **n;
+    int err;
+
+    TRACE_((THIS_FILE, "pjmedia_snd_init: Enumerate sound devices"));
+
+    if (af->pool != NULL) {
+	pj_pool_release(af->pool);
+	af->pool = NULL;
+    }
+
+    af->pool = pj_pool_create(af->pf, "alsa_aud", 256, 256, NULL);
+    af->dev_cnt = 0;
+
+    /* Enumerate sound devices */
+    err = snd_device_name_hint(-1, "pcm", (void***)&hints);
+    if (err != 0)
+	return PJMEDIA_EAUD_SYSERR;
+
+    /* Set a null error handler prior to enumeration to suppress errors */
+    snd_lib_error_set_handler(null_alsa_error_handler);
+
+    n = hints;
+    while (*n != NULL) {
+	char *name = snd_device_name_get_hint(*n, "NAME");
+	if (name != NULL && 0 != strcmp("null", name)) {
+	    add_dev(af, name);
+	    free(name);
+	}
+	n++;
+    }
+
+    /* Install error handler after enumeration, otherwise we'll get many
+     * error messages about invalid card/device ID.
+     */
+    snd_lib_error_set_handler(alsa_error_handler);
+
+    err = snd_device_name_free_hint((void**)hints);
+
+    PJ_LOG(4,(THIS_FILE, "ALSA driver found %d devices", af->dev_cnt));
+
+    return PJ_SUCCESS;
+}
+
+
+/* API: get device count */
+static unsigned  alsa_factory_get_dev_count(pjmedia_aud_dev_factory *f)
+{
+    struct alsa_factory *af = (struct alsa_factory*)f;
+    return af->dev_cnt;
+}
+
+
+/* API: get device info */
+static pj_status_t alsa_factory_get_dev_info(pjmedia_aud_dev_factory *f,
+					     unsigned index,
+					     pjmedia_aud_dev_info *info)
+{
+    struct alsa_factory *af = (struct alsa_factory*)f;
+
+    PJ_ASSERT_RETURN(index>=0 && index<af->dev_cnt, PJ_EINVAL);
+
+    pj_memcpy(info, &af->devs[index], sizeof(*info));
+    info->caps = PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY |
+		 PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY;
+    return PJ_SUCCESS;
+}
+
+/* API: create default parameter */
+static pj_status_t alsa_factory_default_param(pjmedia_aud_dev_factory *f,
+					      unsigned index,
+					      pjmedia_aud_param *param)
+{
+    struct alsa_factory *af = (struct alsa_factory*)f;
+    pjmedia_aud_dev_info *adi;
+
+    PJ_ASSERT_RETURN(index>=0 && index<af->dev_cnt, PJ_EINVAL);
+
+    adi = &af->devs[index];
+
+    pj_bzero(param, sizeof(*param));
+    if (adi->input_count && adi->output_count) {
+	param->dir = PJMEDIA_DIR_CAPTURE_PLAYBACK;
+	param->rec_id = index;
+	param->play_id = index;
+    } else if (adi->input_count) {
+	param->dir = PJMEDIA_DIR_CAPTURE;
+	param->rec_id = index;
+	param->play_id = PJMEDIA_AUD_INVALID_DEV;
+    } else if (adi->output_count) {
+	param->dir = PJMEDIA_DIR_PLAYBACK;
+	param->play_id = index;
+	param->rec_id = PJMEDIA_AUD_INVALID_DEV;
+    } else {
+	return PJMEDIA_EAUD_INVDEV;
+    }
+
+    param->clock_rate = adi->default_samples_per_sec;
+    param->channel_count = 1;
+    param->samples_per_frame = adi->default_samples_per_sec * 20 / 1000;
+    param->bits_per_sample = 16;
+    param->flags = adi->caps;
+    param->input_latency_ms = PJMEDIA_SND_DEFAULT_REC_LATENCY;
+    param->output_latency_ms = PJMEDIA_SND_DEFAULT_PLAY_LATENCY;
+
+    return PJ_SUCCESS;
+}
+
+
+static int pb_thread_func (void *arg)
+{
+    struct alsa_stream* stream = (struct alsa_stream*) arg;
+    snd_pcm_t* pcm             = stream->pb_pcm;
+    int size                   = stream->pb_buf_size;
+    snd_pcm_uframes_t nframes  = stream->pb_frames;
+    void* user_data            = stream->user_data;
+    char* buf 		       = stream->pb_buf;
+    pj_timestamp tstamp;
+    int result;
+
+    pj_bzero (buf, size);
+    tstamp.u64 = 0;
+
+    TRACE_((THIS_FILE, "pb_thread_func(%u): Started",
+	    (unsigned)syscall(SYS_gettid)));
+
+    snd_pcm_prepare (pcm);
+
+    while (!stream->quit) {
+	pjmedia_frame frame;
+
+	frame.type = PJMEDIA_FRAME_TYPE_AUDIO;
+	frame.buf = buf;
+	frame.size = size;
+	frame.timestamp.u64 = tstamp.u64;
+	frame.bit_info = 0;
+
+	result = stream->pb_cb (user_data, &frame);
+	if (result != PJ_SUCCESS || stream->quit)
+	    break;
+
+	if (frame.type != PJMEDIA_FRAME_TYPE_AUDIO)
+	    pj_bzero (buf, size);
+
+	result = snd_pcm_writei (pcm, buf, nframes);
+	if (result == -EPIPE) {
+	    PJ_LOG (4,(THIS_FILE, "pb_thread_func: underrun!"));
+	    snd_pcm_prepare (pcm);
+	} else if (result < 0) {
+	    PJ_LOG (4,(THIS_FILE, "pb_thread_func: error writing data!"));
+	}
+
+	tstamp.u64 += nframes;
+    }
+
+    snd_pcm_drain (pcm);
+    TRACE_((THIS_FILE, "pb_thread_func: Stopped"));
+    return PJ_SUCCESS;
+}
+
+
+
+static int ca_thread_func (void *arg)
+{
+    struct alsa_stream* stream = (struct alsa_stream*) arg;
+    snd_pcm_t* pcm             = stream->ca_pcm;
+    int size                   = stream->ca_buf_size;
+    snd_pcm_uframes_t nframes  = stream->ca_frames;
+    void* user_data            = stream->user_data;
+    char* buf 		       = stream->ca_buf;
+    pj_timestamp tstamp;
+    int result;
+    struct sched_param param;
+    pthread_t* thid;
+
+    thid = (pthread_t*) pj_thread_get_os_handle (pj_thread_this());
+    param.sched_priority = sched_get_priority_max (SCHED_RR);
+    PJ_LOG (5,(THIS_FILE, "ca_thread_func(%u): Set thread priority "
+		          "for audio capture thread.",
+		          (unsigned)syscall(SYS_gettid)));
+    result = pthread_setschedparam (*thid, SCHED_RR, &param);
+    if (result) {
+	if (result == EPERM)
+	    PJ_LOG (5,(THIS_FILE, "Unable to increase thread priority, "
+				  "root access needed."));
+	else
+	    PJ_LOG (5,(THIS_FILE, "Unable to increase thread priority, "
+				  "error: %d",
+				  result));
+    }
+
+    pj_bzero (buf, size);
+    tstamp.u64 = 0;
+
+    TRACE_((THIS_FILE, "ca_thread_func(%u): Started",
+	    (unsigned)syscall(SYS_gettid)));
+
+    snd_pcm_prepare (pcm);
+
+    while (!stream->quit) {
+	pjmedia_frame frame;
+
+	pj_bzero (buf, size);
+	result = snd_pcm_readi (pcm, buf, nframes);
+	if (result == -EPIPE) {
+	    PJ_LOG (4,(THIS_FILE, "ca_thread_func: overrun!"));
+	    snd_pcm_prepare (pcm);
+	    continue;
+	} else if (result < 0) {
+	    PJ_LOG (4,(THIS_FILE, "ca_thread_func: error reading data!"));
+	}
+	if (stream->quit)
+	    break;
+
+	frame.type = PJMEDIA_FRAME_TYPE_AUDIO;
+	frame.buf = (void*) buf;
+	frame.size = size;
+	frame.timestamp.u64 = tstamp.u64;
+	frame.bit_info = 0;
+
+	result = stream->ca_cb (user_data, &frame);
+	if (result != PJ_SUCCESS || stream->quit)
+	    break;
+
+	tstamp.u64 += nframes;
+    }
+    snd_pcm_drain (pcm);
+    TRACE_((THIS_FILE, "ca_thread_func: Stopped"));
+
+    return PJ_SUCCESS;
+}
+
+
+static pj_status_t open_playback (struct alsa_stream* stream,
+			          const pjmedia_aud_param *param)
+{
+    snd_pcm_hw_params_t* params;
+    snd_pcm_format_t format;
+    int result;
+    unsigned int rate;
+    snd_pcm_uframes_t tmp_buf_size;
+    snd_pcm_uframes_t tmp_period_size;
+
+    if (param->play_id < 0 || param->play_id >= stream->af->dev_cnt)
+	return PJMEDIA_EAUD_INVDEV;
+
+    /* Open PCM for playback */
+    PJ_LOG (5,(THIS_FILE, "open_playback: Open playback device '%s'",
+	       stream->af->devs[param->play_id].name));
+    result = snd_pcm_open (&stream->pb_pcm,
+			   stream->af->devs[param->play_id].name,
+			   SND_PCM_STREAM_PLAYBACK,
+			   0);
+    if (result < 0)
+	return PJMEDIA_EAUD_SYSERR;
+
+    /* Allocate a hardware parameters object. */
+    snd_pcm_hw_params_alloca (&params);
+
+    /* Fill it in with default values. */
+    snd_pcm_hw_params_any (stream->pb_pcm, params);
+
+    /* Set interleaved mode */
+    snd_pcm_hw_params_set_access (stream->pb_pcm, params,
+				  SND_PCM_ACCESS_RW_INTERLEAVED);
+
+    /* Set format */
+    switch (param->bits_per_sample) {
+    case 8:
+	TRACE_((THIS_FILE, "open_playback: set format SND_PCM_FORMAT_S8"));
+	format = SND_PCM_FORMAT_S8;
+	break;
+    case 16:
+	TRACE_((THIS_FILE, "open_playback: set format SND_PCM_FORMAT_S16_LE"));
+	format = SND_PCM_FORMAT_S16_LE;
+	break;
+    case 24:
+	TRACE_((THIS_FILE, "open_playback: set format SND_PCM_FORMAT_S24_LE"));
+	format = SND_PCM_FORMAT_S24_LE;
+	break;
+    case 32:
+	TRACE_((THIS_FILE, "open_playback: set format SND_PCM_FORMAT_S32_LE"));
+	format = SND_PCM_FORMAT_S32_LE;
+	break;
+    default:
+	TRACE_((THIS_FILE, "open_playback: set format SND_PCM_FORMAT_S16_LE"));
+	format = SND_PCM_FORMAT_S16_LE;
+	break;
+    }
+    snd_pcm_hw_params_set_format (stream->pb_pcm, params, format);
+
+    /* Set number of channels */
+    TRACE_((THIS_FILE, "open_playback: set channels: %d",
+		       param->channel_count));
+    snd_pcm_hw_params_set_channels (stream->pb_pcm, params,
+				    param->channel_count);
+
+    /* Set clock rate */
+    rate = param->clock_rate;
+    TRACE_((THIS_FILE, "open_playback: set clock rate: %d", rate));
+    snd_pcm_hw_params_set_rate_near (stream->pb_pcm, params, &rate, NULL);
+    TRACE_((THIS_FILE, "open_playback: clock rate set to: %d", rate));
+
+    /* Set period size to samples_per_frame frames. */
+    stream->pb_frames = (snd_pcm_uframes_t) param->samples_per_frame /
+					    param->channel_count;
+    TRACE_((THIS_FILE, "open_playback: set period size: %d",
+	    stream->pb_frames));
+    tmp_period_size = stream->pb_frames;
+    snd_pcm_hw_params_set_period_size_near (stream->pb_pcm, params,
+					    &tmp_period_size, NULL);
+    TRACE_((THIS_FILE, "open_playback: period size set to: %d",
+	    tmp_period_size));
+
+    /* Set the sound device buffer size and latency */
+    if (param->flags & PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY)
+	tmp_buf_size = (rate / 1000) * param->output_latency_ms;
+    else
+	tmp_buf_size = (rate / 1000) * PJMEDIA_SND_DEFAULT_PLAY_LATENCY;
+    snd_pcm_hw_params_set_buffer_size_near (stream->pb_pcm, params,
+					    &tmp_buf_size);
+    stream->param.output_latency_ms = tmp_buf_size / (rate / 1000);
+
+    /* Set our buffer */
+    stream->pb_buf_size = stream->pb_frames * param->channel_count *
+			  (param->bits_per_sample/8);
+    stream->pb_buf = (char*) pj_pool_alloc(stream->pool, stream->pb_buf_size);
+
+    TRACE_((THIS_FILE, "open_playback: buffer size set to: %d",
+	    (int)tmp_buf_size));
+    TRACE_((THIS_FILE, "open_playback: playback_latency set to: %d ms",
+	    (int)stream->param.output_latency_ms));
+
+    /* Activate the parameters */
+    result = snd_pcm_hw_params (stream->pb_pcm, params);
+    if (result < 0) {
+	snd_pcm_close (stream->pb_pcm);
+	return PJMEDIA_EAUD_SYSERR;
+    }
+
+    PJ_LOG (5,(THIS_FILE, "Opened device alsa(%s) for playing, sample rate=%d"
+	       ", ch=%d, bits=%d, period size=%d frames, latency=%d ms",
+	       stream->af->devs[param->play_id].name,
+	       rate, param->channel_count,
+	       param->bits_per_sample, stream->pb_frames,
+	       (int)stream->param.output_latency_ms));
+
+    return PJ_SUCCESS;
+}
+
+
+static pj_status_t open_capture (struct alsa_stream* stream,
+			         const pjmedia_aud_param *param)
+{
+    snd_pcm_hw_params_t* params;
+    snd_pcm_format_t format;
+    int result;
+    unsigned int rate;
+    snd_pcm_uframes_t tmp_buf_size;
+    snd_pcm_uframes_t tmp_period_size;
+
+    if (param->rec_id < 0 || param->rec_id >= stream->af->dev_cnt)
+	return PJMEDIA_EAUD_INVDEV;
+
+    /* Open PCM for capture */
+    PJ_LOG (5,(THIS_FILE, "open_capture: Open capture device '%s'",
+	       stream->af->devs[param->rec_id].name));
+    result = snd_pcm_open (&stream->ca_pcm,
+		            stream->af->devs[param->rec_id].name,
+			   SND_PCM_STREAM_CAPTURE,
+			   0);
+    if (result < 0)
+	return PJMEDIA_EAUD_SYSERR;
+
+    /* Allocate a hardware parameters object. */
+    snd_pcm_hw_params_alloca (&params);
+
+    /* Fill it in with default values. */
+    snd_pcm_hw_params_any (stream->ca_pcm, params);
+
+    /* Set interleaved mode */
+    snd_pcm_hw_params_set_access (stream->ca_pcm, params,
+				  SND_PCM_ACCESS_RW_INTERLEAVED);
+
+    /* Set format */
+    switch (param->bits_per_sample) {
+    case 8:
+	TRACE_((THIS_FILE, "open_capture: set format SND_PCM_FORMAT_S8"));
+	format = SND_PCM_FORMAT_S8;
+	break;
+    case 16:
+	TRACE_((THIS_FILE, "open_capture: set format SND_PCM_FORMAT_S16_LE"));
+	format = SND_PCM_FORMAT_S16_LE;
+	break;
+    case 24:
+	TRACE_((THIS_FILE, "open_capture: set format SND_PCM_FORMAT_S24_LE"));
+	format = SND_PCM_FORMAT_S24_LE;
+	break;
+    case 32:
+	TRACE_((THIS_FILE, "open_capture: set format SND_PCM_FORMAT_S32_LE"));
+	format = SND_PCM_FORMAT_S32_LE;
+	break;
+    default:
+	TRACE_((THIS_FILE, "open_capture: set format SND_PCM_FORMAT_S16_LE"));
+	format = SND_PCM_FORMAT_S16_LE;
+	break;
+    }
+    snd_pcm_hw_params_set_format (stream->ca_pcm, params, format);
+
+    /* Set number of channels */
+    TRACE_((THIS_FILE, "open_capture: set channels: %d",
+	    param->channel_count));
+    snd_pcm_hw_params_set_channels (stream->ca_pcm, params,
+				    param->channel_count);
+
+    /* Set clock rate */
+    rate = param->clock_rate;
+    TRACE_((THIS_FILE, "open_capture: set clock rate: %d", rate));
+    snd_pcm_hw_params_set_rate_near (stream->ca_pcm, params, &rate, NULL);
+    TRACE_((THIS_FILE, "open_capture: clock rate set to: %d", rate));
+
+    /* Set period size to samples_per_frame frames. */
+    stream->ca_frames = (snd_pcm_uframes_t) param->samples_per_frame /
+					    param->channel_count;
+    TRACE_((THIS_FILE, "open_capture: set period size: %d",
+	    stream->ca_frames));
+    tmp_period_size = stream->ca_frames;
+    snd_pcm_hw_params_set_period_size_near (stream->ca_pcm, params,
+					    &tmp_period_size, NULL);
+    TRACE_((THIS_FILE, "open_capture: period size set to: %d",
+	    tmp_period_size));
+
+    /* Set the sound device buffer size and latency */
+    if (param->flags & PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY)
+	tmp_buf_size = (rate / 1000) * param->input_latency_ms;
+    else
+	tmp_buf_size = (rate / 1000) * PJMEDIA_SND_DEFAULT_REC_LATENCY;
+    snd_pcm_hw_params_set_buffer_size_near (stream->ca_pcm, params,
+					    &tmp_buf_size);
+    stream->param.input_latency_ms = tmp_buf_size / (rate / 1000);
+
+    /* Set our buffer */
+    stream->ca_buf_size = stream->ca_frames * param->channel_count *
+			  (param->bits_per_sample/8);
+    stream->ca_buf = (char*) pj_pool_alloc (stream->pool, stream->ca_buf_size);
+
+    TRACE_((THIS_FILE, "open_capture: buffer size set to: %d",
+	    (int)tmp_buf_size));
+    TRACE_((THIS_FILE, "open_capture: capture_latency set to: %d ms",
+	    (int)stream->param.input_latency_ms));
+
+    /* Activate the parameters */
+    result = snd_pcm_hw_params (stream->ca_pcm, params);
+    if (result < 0) {
+	snd_pcm_close (stream->ca_pcm);
+	return PJMEDIA_EAUD_SYSERR;
+    }
+
+    PJ_LOG (5,(THIS_FILE, "Opened device alsa(%s) for capture, sample rate=%d"
+	       ", ch=%d, bits=%d, period size=%d frames, latency=%d ms",
+	       stream->af->devs[param->rec_id].name,
+	       rate, param->channel_count,
+	       param->bits_per_sample, stream->ca_frames,
+	       (int)stream->param.input_latency_ms));
+
+    return PJ_SUCCESS;
+}
+
+
+/* API: create stream */
+static pj_status_t alsa_factory_create_stream(pjmedia_aud_dev_factory *f,
+					      const pjmedia_aud_param *param,
+					      pjmedia_aud_rec_cb rec_cb,
+					      pjmedia_aud_play_cb play_cb,
+					      void *user_data,
+					      pjmedia_aud_stream **p_strm)
+{
+    struct alsa_factory *af = (struct alsa_factory*)f;
+    pj_status_t status;
+    pj_pool_t* pool;
+    struct alsa_stream* stream;
+
+    pool = pj_pool_create (af->pf, "alsa%p", 1024, 1024, NULL);
+    if (!pool)
+	return PJ_ENOMEM;
+
+    /* Allocate and initialize comon stream data */
+    stream = PJ_POOL_ZALLOC_T (pool, struct alsa_stream);
+    stream->base.op = &alsa_stream_op;
+    stream->pool      = pool;
+    stream->af 	      = af;
+    stream->user_data = user_data;
+    stream->pb_cb     = play_cb;
+    stream->ca_cb     = rec_cb;
+    stream->quit      = 0;
+    pj_memcpy(&stream->param, param, sizeof(*param));
+
+    /* Init playback */
+    if (param->dir & PJMEDIA_DIR_PLAYBACK) {
+	status = open_playback (stream, param);
+	if (status != PJ_SUCCESS) {
+	    pj_pool_release (pool);
+	    return status;
+	}
+    }
+
+    /* Init capture */
+    if (param->dir & PJMEDIA_DIR_CAPTURE) {
+	status = open_capture (stream, param);
+	if (status != PJ_SUCCESS) {
+	    if (param->dir & PJMEDIA_DIR_PLAYBACK)
+		snd_pcm_close (stream->pb_pcm);
+	    pj_pool_release (pool);
+	    return status;
+	}
+    }
+
+    *p_strm = &stream->base;
+    return PJ_SUCCESS;
+}
+
+
+/* API: get running parameter */
+static pj_status_t alsa_stream_get_param(pjmedia_aud_stream *s,
+					 pjmedia_aud_param *pi)
+{
+    struct alsa_stream *stream = (struct alsa_stream*)s;
+
+    PJ_ASSERT_RETURN(s && pi, PJ_EINVAL);
+
+    pj_memcpy(pi, &stream->param, sizeof(*pi));
+
+    return PJ_SUCCESS;
+}
+
+
+/* API: get capability */
+static pj_status_t alsa_stream_get_cap(pjmedia_aud_stream *s,
+				       pjmedia_aud_dev_cap cap,
+				       void *pval)
+{
+    struct alsa_stream *stream = (struct alsa_stream*)s;
+
+    PJ_ASSERT_RETURN(s && pval, PJ_EINVAL);
+
+    if (cap==PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY &&
+	(stream->param.dir & PJMEDIA_DIR_CAPTURE))
+    {
+	/* Recording latency */
+	*(unsigned*)pval = stream->param.input_latency_ms;
+	return PJ_SUCCESS;
+    } else if (cap==PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY &&
+	       (stream->param.dir & PJMEDIA_DIR_PLAYBACK))
+    {
+	/* Playback latency */
+	*(unsigned*)pval = stream->param.output_latency_ms;
+	return PJ_SUCCESS;
+    } else {
+	return PJMEDIA_EAUD_INVCAP;
+    }
+}
+
+
+/* API: set capability */
+static pj_status_t alsa_stream_set_cap(pjmedia_aud_stream *strm,
+				       pjmedia_aud_dev_cap cap,
+				       const void *value)
+{
+    PJ_UNUSED_ARG(strm);
+    PJ_UNUSED_ARG(cap);
+    PJ_UNUSED_ARG(value);
+
+    return PJMEDIA_EAUD_INVCAP;
+}
+
+
+/* API: start stream */
+static pj_status_t alsa_stream_start (pjmedia_aud_stream *s)
+{
+    struct alsa_stream *stream = (struct alsa_stream*)s;
+    pj_status_t status = PJ_SUCCESS;
+
+    stream->quit = 0;
+    if (stream->param.dir & PJMEDIA_DIR_PLAYBACK) {
+	status = pj_thread_create (stream->pool,
+				   "alsasound_playback",
+				   pb_thread_func,
+				   stream,
+				   0, //ZERO,
+				   0,
+				   &stream->pb_thread);
+	if (status != PJ_SUCCESS)
+	    return status;
+    }
+
+    if (stream->param.dir & PJMEDIA_DIR_CAPTURE) {
+	status = pj_thread_create (stream->pool,
+				   "alsasound_playback",
+				   ca_thread_func,
+				   stream,
+				   0, //ZERO,
+				   0,
+				   &stream->ca_thread);
+	if (status != PJ_SUCCESS) {
+	    stream->quit = PJ_TRUE;
+	    pj_thread_join(stream->pb_thread);
+	    pj_thread_destroy(stream->pb_thread);
+	    stream->pb_thread = NULL;
+	}
+    }
+
+    return status;
+}
+
+
+/* API: stop stream */
+static pj_status_t alsa_stream_stop (pjmedia_aud_stream *s)
+{
+    struct alsa_stream *stream = (struct alsa_stream*)s;
+
+    stream->quit = 1;
+
+    if (stream->pb_thread) {
+	TRACE_((THIS_FILE,
+		   "alsa_stream_stop(%u): Waiting for playback to stop.",
+		   (unsigned)syscall(SYS_gettid)));
+	pj_thread_join (stream->pb_thread);
+	TRACE_((THIS_FILE,
+		   "alsa_stream_stop(%u): playback stopped.",
+		   (unsigned)syscall(SYS_gettid)));
+	pj_thread_destroy(stream->pb_thread);
+	stream->pb_thread = NULL;
+    }
+
+    if (stream->ca_thread) {
+	TRACE_((THIS_FILE,
+		   "alsa_stream_stop(%u): Waiting for capture to stop.",
+		   (unsigned)syscall(SYS_gettid)));
+	pj_thread_join (stream->ca_thread);
+	TRACE_((THIS_FILE,
+		   "alsa_stream_stop(%u): capture stopped.",
+		   (unsigned)syscall(SYS_gettid)));
+	pj_thread_destroy(stream->ca_thread);
+	stream->ca_thread = NULL;
+    }
+
+    return PJ_SUCCESS;
+}
+
+
+
+static pj_status_t alsa_stream_destroy (pjmedia_aud_stream *s)
+{
+    struct alsa_stream *stream = (struct alsa_stream*)s;
+
+    alsa_stream_stop (s);
+
+    if (stream->param.dir & PJMEDIA_DIR_PLAYBACK) {
+	snd_pcm_close (stream->pb_pcm);
+	stream->pb_pcm = NULL;
+    }
+    if (stream->param.dir & PJMEDIA_DIR_CAPTURE) {
+	snd_pcm_close (stream->ca_pcm);
+	stream->ca_pcm = NULL;
+    }
+
+    pj_pool_release (stream->pool);
+
+    return PJ_SUCCESS;
+}
+
+#endif	/* PJMEDIA_AUDIO_DEV_HAS_ALSA */
diff --git a/jni/pjproject-android/.svn/pristine/69/693681842dbb1125017d7780e1e6a1c5f405fe32.svn-base b/jni/pjproject-android/.svn/pristine/69/693681842dbb1125017d7780e1e6a1c5f405fe32.svn-base
new file mode 100644
index 0000000..1b892756
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/69/693681842dbb1125017d7780e1e6a1c5f405fe32.svn-base
@@ -0,0 +1,15 @@
+//
+//  ipjsuaViewController.h
+//  ipjsua
+//
+//  Created by Liong Sauw Ming on 13/3/13.
+//  Copyright (c) 2013 Teluu. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ipjsuaViewController : UIViewController
+
+@property (nonatomic, retain) IBOutlet UILabel *textLabel;
+
+@end
diff --git a/jni/pjproject-android/.svn/pristine/69/6945e474834e50dbe6df418f16f335e5dfb585bd.svn-base b/jni/pjproject-android/.svn/pristine/69/6945e474834e50dbe6df418f16f335e5dfb585bd.svn-base
new file mode 100644
index 0000000..a928485
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/69/6945e474834e50dbe6df418f16f335e5dfb585bd.svn-base
@@ -0,0 +1,220 @@
+/* $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-audiodev/errno.h>
+#include <pj/string.h>
+#include <pj/unicode.h>
+#if PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO
+#   include <portaudio.h>
+#endif
+#if PJMEDIA_AUDIO_DEV_HAS_WMME
+#   ifdef _MSC_VER
+#	pragma warning(push, 3)
+#   endif
+#   include <windows.h>
+#   include <mmsystem.h>
+#   ifdef _MSC_VER
+#	pragma warning(pop)
+#   endif
+#endif
+
+/* PJMEDIA-Audiodev's own error codes/messages 
+ * MUST KEEP THIS ARRAY SORTED!!
+ * Message must be limited to 64 chars!
+ */
+
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
+static const struct 
+{
+    int code;
+    const char *msg;
+} err_str[] = 
+{
+    PJ_BUILD_ERR( PJMEDIA_EAUD_ERR,	    "Unspecified audio device error" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_SYSERR,	    "Unknown error from audio driver" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_INIT,	    "Audio subsystem not initialized" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_INVDEV,	    "Invalid audio device" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_NODEV,	    "Found no audio devices" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_NODEFDEV,    "Unable to find default audio device" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_NOTREADY,    "Audio device not ready" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_INVCAP,	    "Invalid or unsupported audio capability" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_INVOP,	    "Invalid or unsupported audio device operation" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_BADFORMAT,   "Bad or invalid audio device format" ),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_SAMPFORMAT,  "Invalid audio device sample format"),
+    PJ_BUILD_ERR( PJMEDIA_EAUD_BADLATENCY,  "Bad audio latency setting")
+
+};
+
+#endif	/* PJ_HAS_ERROR_STRING */
+
+
+
+/*
+ * pjmedia_audiodev_strerror()
+ */
+PJ_DEF(pj_str_t) pjmedia_audiodev_strerror(pj_status_t statcode, 
+					   char *buf, pj_size_t bufsize )
+{
+    pj_str_t errstr;
+
+#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
+
+
+    /* See if the error comes from Core Audio. */
+#if PJMEDIA_AUDIO_DEV_HAS_COREAUDIO
+    if (statcode >= PJMEDIA_AUDIODEV_COREAUDIO_ERRNO_START &&
+	statcode <= PJMEDIA_AUDIODEV_COREAUDIO_ERRNO_END)
+    {
+	int ca_err = PJMEDIA_AUDIODEV_COREAUDIO_ERRNO_START - statcode;
+
+	PJ_UNUSED_ARG(ca_err);
+	// TODO: create more helpful error messages
+	errstr.ptr = buf;
+	pj_strcpy2(&errstr, "Core audio error");
+	return errstr;
+    } else
+#endif
+
+    /* See if the error comes from PortAudio. */
+#if PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO
+    if (statcode >= PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START &&
+	statcode <= PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_END)
+    {
+
+	//int pa_err = statcode - PJMEDIA_ERRNO_FROM_PORTAUDIO(0);
+	int pa_err = PJMEDIA_AUDIODEV_PORTAUDIO_ERRNO_START - statcode;
+	pj_str_t msg;
+	
+	msg.ptr = (char*)Pa_GetErrorText(pa_err);
+	msg.slen = pj_ansi_strlen(msg.ptr);
+
+	errstr.ptr = buf;
+	pj_strncpy_with_null(&errstr, &msg, bufsize);
+	return errstr;
+
+    } else 
+#endif	/* PJMEDIA_SOUND_IMPLEMENTATION */
+
+    /* See if the error comes from WMME */
+#if PJMEDIA_AUDIO_DEV_HAS_WMME
+    if ((statcode >= PJMEDIA_AUDIODEV_WMME_IN_ERROR_START &&
+	 statcode < PJMEDIA_AUDIODEV_WMME_IN_ERROR_END) ||
+	(statcode >= PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START &&
+	 statcode < PJMEDIA_AUDIODEV_WMME_OUT_ERROR_END))
+    {
+	MMRESULT native_err, mr;
+	MMRESULT (WINAPI *waveGetErrText)(UINT mmrError, LPTSTR pszText, UINT cchText);
+	PJ_DECL_UNICODE_TEMP_BUF(wbuf, 80)
+
+	if (statcode >= PJMEDIA_AUDIODEV_WMME_IN_ERROR_START &&
+	    statcode <= PJMEDIA_AUDIODEV_WMME_IN_ERROR_END)
+	{
+	    native_err = statcode - PJMEDIA_AUDIODEV_WMME_IN_ERROR_START;
+	    waveGetErrText = &waveInGetErrorText;
+	} else {
+	    native_err = statcode - PJMEDIA_AUDIODEV_WMME_OUT_ERROR_START;
+	    waveGetErrText = &waveOutGetErrorText;
+	}
+
+#if PJ_NATIVE_STRING_IS_UNICODE
+	mr = (*waveGetErrText)(native_err, wbuf, PJ_ARRAY_SIZE(wbuf));
+	if (mr == MMSYSERR_NOERROR) {
+	    int len = wcslen(wbuf);
+	    pj_unicode_to_ansi(wbuf, len, buf, bufsize);
+	}
+#else
+	mr = (*waveGetErrText)(native_err, buf, (UINT)bufsize);
+#endif
+
+	if (mr==MMSYSERR_NOERROR) {
+	    errstr.ptr = buf;
+	    errstr.slen = pj_ansi_strlen(buf);
+	    return errstr;
+	} else {
+	    pj_ansi_snprintf(buf, bufsize, "MMSYSTEM native error %d", 
+			     native_err);
+	    return pj_str(buf);
+	}
+
+    } else
+#endif
+
+/* See if the error comes from BDIMAD */
+#if PJMEDIA_AUDIO_DEV_HAS_BDIMAD
+	
+	if (statcode >= PJMEDIA_AUDIODEV_BDIMAD_ERROR_START &&
+	    statcode <  PJMEDIA_AUDIODEV_BDIMAD_ERROR_END)
+	{
+	    pj_status_t native_err;
+	    native_err = statcode - PJMEDIA_AUDIODEV_BDIMAD_ERROR_START;
+
+	    pj_ansi_snprintf(buf, bufsize, "BDIMAD native error %d", native_err);
+	    return pj_str(buf);
+	} else
+#endif
+
+    /* Audiodev error */
+    if (statcode >= PJMEDIA_AUDIODEV_ERRNO_START && 
+	statcode < PJMEDIA_AUDIODEV_ERRNO_END)
+    {
+	/* Find the error in the table.
+	 * Use binary search!
+	 */
+	int first = 0;
+	int n = PJ_ARRAY_SIZE(err_str);
+
+	while (n > 0) {
+	    int half = n/2;
+	    int mid = first + half;
+
+	    if (err_str[mid].code < statcode) {
+		first = mid+1;
+		n -= (half+1);
+	    } else if (err_str[mid].code > statcode) {
+		n = half;
+	    } else {
+		first = mid;
+		break;
+	    }
+	}
+
+
+	if (PJ_ARRAY_SIZE(err_str) && err_str[first].code == statcode) {
+	    pj_str_t msg;
+	    
+	    msg.ptr = (char*)err_str[first].msg;
+	    msg.slen = pj_ansi_strlen(err_str[first].msg);
+
+	    errstr.ptr = buf;
+	    pj_strncpy_with_null(&errstr, &msg, bufsize);
+	    return errstr;
+
+	} 
+    } 
+#endif	/* PJ_HAS_ERROR_STRING */
+
+    /* Error not found. */
+    errstr.ptr = buf;
+    errstr.slen = pj_ansi_snprintf(buf, bufsize, 
+				   "Unknown pjmedia-audiodev error %d",
+				   statcode);
+
+    return errstr;
+}
+
diff --git a/jni/pjproject-android/.svn/pristine/69/695b7aa536ef4aa9f87017799427d44fa4dfcd3f.svn-base b/jni/pjproject-android/.svn/pristine/69/695b7aa536ef4aa9f87017799427d44fa4dfcd3f.svn-base
new file mode 100644
index 0000000..949c389
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/69/695b7aa536ef4aa9f87017799427d44fa4dfcd3f.svn-base
@@ -0,0 +1,223 @@
+Changelog
+
+1.3.20
+
+  Lots of changes.  Thanks to Jeff Chan for catching a memory leak and
+  helping track down the endian issues with the SSRCs.
+
+1.3.8
+
+  This is an interim release.  Several little-endian bugs were identified
+  and fixed; this means that we can use intel/linux for development again.
+
+  Cleaned up sha1 and hmac code significantly, got rid of some excess
+  functions and properly documented the fuctions in the .h files.
+
+  Eliminated some vestigial files.
+
+  There is a SIGBUS error in the AES encrypt function on sparc
+  (observed on both solaris and openbsd) with gcc 2.95.  Was unable to
+  find bad pointer anywhere, so I'm wondering if it isn't a compiler
+  problem (there's a known problem whose profile it fits).  It doesn't
+  appear on any other platform, even in the cipher_driver stress
+  tests.
+
+  Planned changes
+
+  Change interface to nonces (xtd_seq_num_t) so that it uses
+  network byte ordering, and is consistent with other arguments.
+
+
+1.3.6 
+
+  Changed /dev/random (in configure.in and crypto/rng/rand_source.c) to
+  /dev/urandom; the latter is non-blocking on all known platforms (which 
+  corrects some programs that seem to hang) and is actually present on 
+  Open BSD (unlike /dev/random, which only works in the presence of 
+  hardware supported random number generation).
+
+  Added machine/types.h case in include/integers.h.
+
+1.3.5
+
+  Removing srtp_t::template and stream_clone().
+
+  Adding a new policy structure, which will reflect a complete SRTP
+  policy (including SRTCP).
+
+  This version is *incomplete* and will undergo more changes.  It is
+  provided only as a basis for discussion.
+
+1.3.4
+
+   Removed tmmh.c and tmmh.h, which implemented version one of TMMH.
+
+   Changed srtp_get_trailer_length() to act on streams rather than
+   sessions, and documented the macro SRTP_MAX_TRAILER_LEN, which should
+   usually be used rather than that function.
+
+   Removed 'salt' from cipher input. 
+
+   Changed rdbx to use err.h error codes.
+
+   Changed malloc() and free() to xalloc() and xfree; these functions
+   are defined in crypto/kernel/alloc.c and declared in 
+   include/alloc.h.
+
+   Added 'output' functions to cipher, in addition to 'encrypt'
+   functions.  It is no longer necessary to zeroize a buffer before
+   encrypting in order to get keystream.
+
+   Changed octet_string_hex_string() so that "times two" isn't needed
+   in its input.
+
+   Added crypto_kernel_init() prior to command-line parsing, so that
+   kernel can be passed command-line arguments, such as "-d
+   debug_module".  This was done to for the applications
+   test/srtp-driver, test/kernel-driver, and test/ust-driver.
+
+   Improved srtp_init_aes_128_prf - wrote key derivation function
+   (srtp_kdf_t).
+
+   Add the tag_len as an argument to the auth_compute() function, but
+   not the corresponding macro.  This change allows the tag length for
+   a given auth func to be set to different values at initialization
+   time.  Previously, the structure auth_t contained the
+   output_length, but that value was inaccessible from hmac_compute()
+   and other functions.
+
+   Re-named files from a-b.c to a_b.c. in order to help portability.
+
+   Re-named rijndael to aes (or aes_128 as appropriate).
+
+
+1.2.1 
+
+  Changes so that 1.2.0 compiles on cygwin-win2k.
+
+  Added better error reporting system.  If syslog is present on the
+  OS, then it is used.
+
+
+1.2.0 Many improvements and additions, and a fex fixes
+
+   Fixed endian issues in RTP header construction in the function
+   rtp_sendto() in srtp/rtp.c.
+
+   Implemented RIJNDAEL decryption operation, adding the functions
+   rijndael_decrypt() and rijndael_expand_decryption_key().  Also
+   re-named rijndael_expand_key() to rijndael_expand_encryption_key()
+   for consistency.
+
+   Implemented random number source using /dev/random, in the files
+   crypto/rng/rand_source.c and include/rand_source.h.
+
+   Added index check to SEAL cipher (only values less than 2^32 are
+   allowed)
+
+   Added test case for null_auth authentication function.
+
+   Added a timing test which tests the effect of CPU cache thrash on
+   cipher throughput.  The test is done by the function
+   cipher_test_throughput_array(); the function
+   cipher_array_alloc_init() creates an array of ciphers for use in
+   this test.  This test can be accessed by using the -a flag to
+   the application cipher-driver in the test subdirectory.
+ 
+   Added argument processing to ust-driver.c, and added that app to
+   the 'runtest' target in Makefile.in.
+
+   A minor auth_t API change: last argument of auth_init() eliminated.
+
+
+1.0.6 A small but important fix
+
+   Fixed srtp_init_aes_128_prf() by adding octet_string_set_to_zero()
+   after buffer allocation.
+
+   Eliminated references to no-longer-existing variables in debugging
+   code in srtp/srtp.c.  This fixes the compilation failure that
+   occured when using PRINT_DEBUG in that file.
+
+   Corrected spelling of Richard Priestley's name in credits.  Sorry
+   Richard!
+
+
+1.0.5 Many little fixes
+
+   Fixed octet_string_set_to_zero(), which was writing one
+   more zero octet than it should.  This bug caused srtp_protect()
+   and srtp_unprotect() to overwrite the byte that followed the
+   srtp packet.
+
+   Changed sizeof(uint32_t) to srtp_get_trailer_length() in
+   srtp-driver.c.  This is just defensive coding.
+
+   Added NULL check to malloc in srtp_alloc().
+
+
+1.0.4 Many minor fixes and two big ones (thanks for the bug reports!)
+
+   Removed 'ssrc' from the srtp_init_aes_128_prf() function argument
+   list.  This is so that applications which do not a priori know the
+   ssrc which they will be receiving can still use libsrtp.  Now the
+   SSRC value is gleaned from the rtp header and exored into the
+   counter mode offset in the srtp_protect() and srtp_unprotect()
+   functions, if that cipher is used.  This change cascaed through
+   many other functions, including srtp_init_from_hex(),
+   srtp_sender_init() and srtp_receiver_init() in rtp.c, and also
+   changing the CLI to test/rtpw.  In the future, another function
+   call will be added to the library that enables multiple ssrc/key
+   pairs to be installed into the same srtp session, so that libsrtp
+   works with multiple srtp senders.  For now, this functionality is
+   lacking.
+
+   Removed the GDOI interface to the rtpw demo program.  This will be
+   added again at a later date, after the SRTP and GDOI distributions
+   stabilize.  For now, I've left in the GDOI #defines and autoconf
+   definitions so that they'll be in place when needed.
+
+   Updated tmmhv2_compute() so that it didn't assume any particular
+   alginment of the output tag.
+
+   Changed bit field variables in srtp.h to unsigned char from
+   unsigned int in order to avoid a potential endianness issue.
+
+   Fixed rdbx_estimate_index() to handle all input cases.  This solves
+   the now notorious "abaft" bug in the rtpw demo app on linux/intel,
+   in which spurious replay protection failures happen after that word
+   is received.
+
+   Added ntohs(hdr->seq) to srtp_protect and srtp_unprotect, removed
+   from rijndael_icm_set_segment().
+
+   Added error checking and handling to srtp_sender_init() and
+   srtp_receiver_init().
+
+   Changed srtp_alloc() so that it does what you'd expect: allocate an
+   srtp_ctx_t structure.  This hides the library internals.
+
+
+1.0.1   Many minor fixes
+
+   Added cipher_driver_buffer_test(...) to test/cipher-driver.c.  This
+   function checks that the byte-buffering functions used by a cipher
+   are correct.
+
+   Fixed SunOS/Solaris build problems: added HAVE_SYS_INT_TYPES_H and
+   changed index_t to xtd_seq_num_t (see include/rdbx.h).
+
+   Fixed SEAL3.0 output byte buffering, added byte-buffering test to
+   cipher/cipher-driver.c.
+
+   Fixed roc-driver so that the non-sequential insertion test
+   automatically recovers from bad estimates.  This was required to
+   prevent spurious failures.
+
+   Made rdbx_estimate_index(...) function smarter, so that initial RTP
+   sequence numbers greater than 32,768 don't cause it to estimate the
+   rollover counter of 0xffffffff.
+
+
+1.0.0   Initial release
+
diff --git a/jni/pjproject-android/.svn/pristine/69/6984e1f817da0d43aa30f8489f6538c0820ae656.svn-base b/jni/pjproject-android/.svn/pristine/69/6984e1f817da0d43aa30f8489f6538c0820ae656.svn-base
new file mode 100644
index 0000000..a0397c5
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/69/6984e1f817da0d43aa30f8489f6538c0820ae656.svn-base
@@ -0,0 +1,28 @@
+# $Id$
+import inc_sip as sip
+import inc_sdp as sdp
+
+# Multiple m=audio, one of them has dynamic PT codec that we don't support
+sdp = \
+"""
+v=0
+o=- 0 0 IN IP4 127.0.0.1
+s=-
+c=IN IP4 127.0.0.1
+t=0 0
+m=audio 5000 RTP/AVP 100
+a=rtpmap:100 someunknowncodec/8000
+m=audio 4000 RTP/AVP 0
+"""
+
+pjsua_args = "--null-audio --auto-answer 200"
+extra_headers = ""
+include = ["Content-Type: application/sdp",	# response must include SDP
+	   "m=audio 0 RTP/AVP[\s\S]+m=audio [1-9]+[0-9]* RTP/AVP"
+	   ]
+exclude = []
+
+sendto_cfg = sip.SendtoCfg("Multiple audio lines", pjsua_args, sdp, 200,
+			   extra_headers=extra_headers,
+			   resp_inc=include, resp_exc=exclude) 
+
diff --git a/jni/pjproject-android/.svn/pristine/69/698e68916a362ffbf8f2b23f3b4e843fb6696439.svn-base b/jni/pjproject-android/.svn/pristine/69/698e68916a362ffbf8f2b23f3b4e843fb6696439.svn-base
new file mode 100644
index 0000000..c2685bb
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/69/698e68916a362ffbf8f2b23f3b4e843fb6696439.svn-base
@@ -0,0 +1,478 @@
+//------------------------------------------------------------------------------

+// File: RenBase.h

+//

+// Desc: DirectShow base classes - defines a generic ActiveX base renderer

+//       class.

+//

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

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

+

+

+#ifndef __RENBASE__

+#define __RENBASE__

+

+// Forward class declarations

+

+class CBaseRenderer;

+class CBaseVideoRenderer;

+class CRendererInputPin;

+

+// This is our input pin class that channels calls to the renderer

+

+class CRendererInputPin : public CBaseInputPin

+{

+protected:

+

+    CBaseRenderer *m_pRenderer;

+

+public:

+

+    CRendererInputPin(__inout CBaseRenderer *pRenderer,

+                      __inout HRESULT *phr,

+                      __in_opt LPCWSTR Name);

+

+    // Overriden from the base pin classes

+

+    HRESULT BreakConnect();

+    HRESULT CompleteConnect(IPin *pReceivePin);

+    HRESULT SetMediaType(const CMediaType *pmt);

+    HRESULT CheckMediaType(const CMediaType *pmt);

+    HRESULT Active();

+    HRESULT Inactive();

+

+    // Add rendering behaviour to interface functions

+

+    STDMETHODIMP QueryId(__deref_out LPWSTR *Id);

+    STDMETHODIMP EndOfStream();

+    STDMETHODIMP BeginFlush();

+    STDMETHODIMP EndFlush();

+    STDMETHODIMP Receive(IMediaSample *pMediaSample);

+

+    // Helper

+    IMemAllocator inline *Allocator() const

+    {

+        return m_pAllocator;

+    }

+};

+

+// Main renderer class that handles synchronisation and state changes

+

+class CBaseRenderer : public CBaseFilter

+{

+protected:

+

+    friend class CRendererInputPin;

+

+    friend void CALLBACK EndOfStreamTimer(UINT uID,      // Timer identifier

+                                          UINT uMsg,     // Not currently used

+                                          DWORD_PTR dwUser,  // User information

+                                          DWORD_PTR dw1,     // Windows reserved

+                                          DWORD_PTR dw2);    // Is also reserved

+

+    CRendererPosPassThru *m_pPosition;  // Media seeking pass by object

+    CAMEvent m_RenderEvent;             // Used to signal timer events

+    CAMEvent m_ThreadSignal;            // Signalled to release worker thread

+    CAMEvent m_evComplete;              // Signalled when state complete

+    BOOL m_bAbort;                      // Stop us from rendering more data

+    BOOL m_bStreaming;                  // Are we currently streaming

+    DWORD_PTR m_dwAdvise;                   // Timer advise cookie

+    IMediaSample *m_pMediaSample;       // Current image media sample

+    BOOL m_bEOS;                        // Any more samples in the stream

+    BOOL m_bEOSDelivered;               // Have we delivered an EC_COMPLETE

+    CRendererInputPin *m_pInputPin;     // Our renderer input pin object

+    CCritSec m_InterfaceLock;           // Critical section for interfaces

+    CCritSec m_RendererLock;            // Controls access to internals

+    IQualityControl * m_pQSink;         // QualityControl sink

+    BOOL m_bRepaintStatus;              // Can we signal an EC_REPAINT

+    //  Avoid some deadlocks by tracking filter during stop

+    volatile BOOL  m_bInReceive;        // Inside Receive between PrepareReceive

+                                        // And actually processing the sample

+    REFERENCE_TIME m_SignalTime;        // Time when we signal EC_COMPLETE

+    UINT m_EndOfStreamTimer;            // Used to signal end of stream

+    CCritSec m_ObjectCreationLock;      // This lock protects the creation and

+                                        // of m_pPosition and m_pInputPin.  It

+                                        // ensures that two threads cannot create

+                                        // either object simultaneously.

+

+public:

+

+    CBaseRenderer(REFCLSID RenderClass, // CLSID for this renderer

+                  __in_opt LPCTSTR pName,         // Debug ONLY description

+                  __inout_opt LPUNKNOWN pUnk,       // Aggregated owner object

+                  __inout HRESULT *phr);        // General OLE return code

+

+    ~CBaseRenderer();

+

+    // Overriden to say what interfaces we support and where

+

+    virtual HRESULT GetMediaPositionInterface(REFIID riid, __deref_out void **ppv);

+    STDMETHODIMP NonDelegatingQueryInterface(REFIID, __deref_out void **);

+

+    virtual HRESULT SourceThreadCanWait(BOOL bCanWait);

+

+#ifdef DEBUG

+    // Debug only dump of the renderer state

+    void DisplayRendererState();

+#endif

+    virtual HRESULT WaitForRenderTime();

+    virtual HRESULT CompleteStateChange(FILTER_STATE OldState);

+

+    // Return internal information about this filter

+

+    BOOL IsEndOfStream() { return m_bEOS; };

+    BOOL IsEndOfStreamDelivered() { return m_bEOSDelivered; };

+    BOOL IsStreaming() { return m_bStreaming; };

+    void SetAbortSignal(BOOL bAbort) { m_bAbort = bAbort; };

+    virtual void OnReceiveFirstSample(IMediaSample *pMediaSample) { };

+    CAMEvent *GetRenderEvent() { return &m_RenderEvent; };

+

+    // Permit access to the transition state

+

+    void Ready() { m_evComplete.Set(); };

+    void NotReady() { m_evComplete.Reset(); };

+    BOOL CheckReady() { return m_evComplete.Check(); };

+

+    virtual int GetPinCount();

+    virtual CBasePin *GetPin(int n);

+    FILTER_STATE GetRealState();

+    void SendRepaint();

+    void SendNotifyWindow(IPin *pPin,HWND hwnd);

+    BOOL OnDisplayChange();

+    void SetRepaintStatus(BOOL bRepaint);

+

+    // Override the filter and pin interface functions

+

+    STDMETHODIMP Stop();

+    STDMETHODIMP Pause();

+    STDMETHODIMP Run(REFERENCE_TIME StartTime);

+    STDMETHODIMP GetState(DWORD dwMSecs, __out FILTER_STATE *State);

+    STDMETHODIMP FindPin(LPCWSTR Id, __deref_out IPin **ppPin);

+

+    // These are available for a quality management implementation

+

+    virtual void OnRenderStart(IMediaSample *pMediaSample);

+    virtual void OnRenderEnd(IMediaSample *pMediaSample);

+    virtual HRESULT OnStartStreaming() { return NOERROR; };

+    virtual HRESULT OnStopStreaming() { return NOERROR; };

+    virtual void OnWaitStart() { };

+    virtual void OnWaitEnd() { };

+    virtual void PrepareRender() { };

+

+#ifdef PERF

+    REFERENCE_TIME m_trRenderStart; // Just before we started drawing

+                                    // Set in OnRenderStart, Used in OnRenderEnd

+    int m_idBaseStamp;              // MSR_id for frame time stamp

+    int m_idBaseRenderTime;         // MSR_id for true wait time

+    int m_idBaseAccuracy;           // MSR_id for time frame is late (int)

+#endif

+

+    // Quality management implementation for scheduling rendering

+

+    virtual BOOL ScheduleSample(IMediaSample *pMediaSample);

+    virtual HRESULT GetSampleTimes(IMediaSample *pMediaSample,

+                                   __out REFERENCE_TIME *pStartTime,

+                                   __out REFERENCE_TIME *pEndTime);

+

+    virtual HRESULT ShouldDrawSampleNow(IMediaSample *pMediaSample,

+                                        __out REFERENCE_TIME *ptrStart,

+                                        __out REFERENCE_TIME *ptrEnd);

+

+    // Lots of end of stream complexities

+

+    void TimerCallback();

+    void ResetEndOfStreamTimer();

+    HRESULT NotifyEndOfStream();

+    virtual HRESULT SendEndOfStream();

+    virtual HRESULT ResetEndOfStream();

+    virtual HRESULT EndOfStream();

+

+    // Rendering is based around the clock

+

+    void SignalTimerFired();

+    virtual HRESULT CancelNotification();

+    virtual HRESULT ClearPendingSample();

+

+    // Called when the filter changes state

+

+    virtual HRESULT Active();

+    virtual HRESULT Inactive();

+    virtual HRESULT StartStreaming();

+    virtual HRESULT StopStreaming();

+    virtual HRESULT BeginFlush();

+    virtual HRESULT EndFlush();

+

+    // Deal with connections and type changes

+

+    virtual HRESULT BreakConnect();

+    virtual HRESULT SetMediaType(const CMediaType *pmt);

+    virtual HRESULT CompleteConnect(IPin *pReceivePin);

+

+    // These look after the handling of data samples

+

+    virtual HRESULT PrepareReceive(IMediaSample *pMediaSample);

+    virtual HRESULT Receive(IMediaSample *pMediaSample);

+    virtual BOOL HaveCurrentSample();

+    virtual IMediaSample *GetCurrentSample();

+    virtual HRESULT Render(IMediaSample *pMediaSample);

+

+    // Derived classes MUST override these

+    virtual HRESULT DoRenderSample(IMediaSample *pMediaSample) PURE;

+    virtual HRESULT CheckMediaType(const CMediaType *) PURE;

+

+    // Helper

+    void WaitForReceiveToComplete();

+};

+

+

+// CBaseVideoRenderer is a renderer class (see its ancestor class) and

+// it handles scheduling of media samples so that they are drawn at the

+// correct time by the reference clock.  It implements a degradation

+// strategy.  Possible degradation modes are:

+//    Drop frames here (only useful if the drawing takes significant time)

+//    Signal supplier (upstream) to drop some frame(s) - i.e. one-off skip.

+//    Signal supplier to change the frame rate - i.e. ongoing skipping.

+//    Or any combination of the above.

+// In order to determine what's useful to try we need to know what's going

+// on.  This is done by timing various operations (including the supplier).

+// This timing is done by using timeGetTime as it is accurate enough and

+// usually cheaper than calling the reference clock.  It also tells the

+// truth if there is an audio break and the reference clock stops.

+// We provide a number of public entry points (named OnXxxStart, OnXxxEnd)

+// which the rest of the renderer calls at significant moments.  These do

+// the timing.

+

+// the number of frames that the sliding averages are averaged over.

+// the rule is (1024*NewObservation + (AVGPERIOD-1) * PreviousAverage)/AVGPERIOD

+#define AVGPERIOD 4

+#define DO_MOVING_AVG(avg,obs) (avg = (1024*obs + (AVGPERIOD-1)*avg)/AVGPERIOD)

+// Spot the bug in this macro - I can't. but it doesn't work!

+

+class CBaseVideoRenderer : public CBaseRenderer,    // Base renderer class

+                           public IQualProp,        // Property page guff

+                           public IQualityControl   // Allow throttling

+{

+protected:

+

+    // Hungarian:

+    //     tFoo is the time Foo in mSec (beware m_tStart from filter.h)

+    //     trBar is the time Bar by the reference clock

+

+    //******************************************************************

+    // State variables to control synchronisation

+    //******************************************************************

+

+    // Control of sending Quality messages.  We need to know whether

+    // we are in trouble (e.g. frames being dropped) and where the time

+    // is being spent.

+

+    // When we drop a frame we play the next one early.

+    // The frame after that is likely to wait before drawing and counting this

+    // wait as spare time is unfair, so we count it as a zero wait.

+    // We therefore need to know whether we are playing frames early or not.

+

+    int m_nNormal;                  // The number of consecutive frames

+                                    // drawn at their normal time (not early)

+                                    // -1 means we just dropped a frame.

+

+#ifdef PERF

+    BOOL m_bDrawLateFrames;         // Don't drop any frames (debug and I'm

+                                    // not keen on people using it!)

+#endif

+

+    BOOL m_bSupplierHandlingQuality;// The response to Quality messages says

+                                    // our supplier is handling things.

+                                    // We will allow things to go extra late

+                                    // before dropping frames.  We will play

+                                    // very early after he has dropped one.

+

+    // Control of scheduling, frame dropping etc.

+    // We need to know where the time is being spent so as to tell whether

+    // we should be taking action here, signalling supplier or what.

+    // The variables are initialised to a mode of NOT dropping frames.

+    // They will tell the truth after a few frames.

+    // We typically record a start time for an event, later we get the time

+    // again and subtract to get the elapsed time, and we average this over

+    // a few frames.  The average is used to tell what mode we are in.

+

+    // Although these are reference times (64 bit) they are all DIFFERENCES

+    // between times which are small.  An int will go up to 214 secs before

+    // overflow.  Avoiding 64 bit multiplications and divisions seems

+    // worth while.

+

+

+

+    // Audio-video throttling.  If the user has turned up audio quality

+    // very high (in principle it could be any other stream, not just audio)

+    // then we can receive cries for help via the graph manager.  In this case

+    // we put in a wait for some time after rendering each frame.

+    int m_trThrottle;

+

+    // The time taken to render (i.e. BitBlt) frames controls which component

+    // needs to degrade.  If the blt is expensive, the renderer degrades.

+    // If the blt is cheap it's done anyway and the supplier degrades.

+    int m_trRenderAvg;              // Time frames are taking to blt

+    int m_trRenderLast;             // Time for last frame blt

+    int m_tRenderStart;             // Just before we started drawing (mSec)

+                                    // derived from timeGetTime.

+

+    // When frames are dropped we will play the next frame as early as we can.

+    // If it was a false alarm and the machine is fast we slide gently back to

+    // normal timing.  To do this, we record the offset showing just how early

+    // we really are.  This will normally be negative meaning early or zero.

+    int m_trEarliness;

+

+    // Target provides slow long-term feedback to try to reduce the

+    // average sync offset to zero.  Whenever a frame is actually rendered

+    // early we add a msec or two, whenever late we take off a few.

+    // We add or take off 1/32 of the error time.

+    // Eventually we should be hovering around zero.  For a really bad case

+    // where we were (say) 300mSec off, it might take 100 odd frames to

+    // settle down.  The rate of change of this is intended to be slower

+    // than any other mechanism in Quartz, thereby avoiding hunting.

+    int m_trTarget;

+

+    // The proportion of time spent waiting for the right moment to blt

+    // controls whether we bother to drop a frame or whether we reckon that

+    // we're doing well enough that we can stand a one-frame glitch.

+    int m_trWaitAvg;                // Average of last few wait times

+                                    // (actually we just average how early

+                                    // we were).  Negative here means LATE.

+

+    // The average inter-frame time.

+    // This is used to calculate the proportion of the time used by the

+    // three operations (supplying us, waiting, rendering)

+    int m_trFrameAvg;               // Average inter-frame time

+    int m_trDuration;               // duration of last frame.

+

+#ifdef PERF

+    // Performance logging identifiers

+    int m_idTimeStamp;              // MSR_id for frame time stamp

+    int m_idEarliness;              // MSR_id for earliness fudge

+    int m_idTarget;                 // MSR_id for Target fudge

+    int m_idWaitReal;               // MSR_id for true wait time

+    int m_idWait;                   // MSR_id for wait time recorded

+    int m_idFrameAccuracy;          // MSR_id for time frame is late (int)

+    int m_idRenderAvg;              // MSR_id for Render time recorded (int)

+    int m_idSchLateTime;            // MSR_id for lateness at scheduler

+    int m_idQualityRate;            // MSR_id for Quality rate requested

+    int m_idQualityTime;            // MSR_id for Quality time requested

+    int m_idDecision;               // MSR_id for decision code

+    int m_idDuration;               // MSR_id for duration of a frame

+    int m_idThrottle;               // MSR_id for audio-video throttling

+    //int m_idDebug;                  // MSR_id for trace style debugging

+    //int m_idSendQuality;          // MSR_id for timing the notifications per se

+#endif // PERF

+    REFERENCE_TIME m_trRememberStampForPerf;  // original time stamp of frame

+                                              // with no earliness fudges etc.

+#ifdef PERF

+    REFERENCE_TIME m_trRememberFrameForPerf;  // time when previous frame rendered

+

+    // debug...

+    int m_idFrameAvg;

+    int m_idWaitAvg;

+#endif

+

+    // PROPERTY PAGE

+    // This has edit fields that show the user what's happening

+    // These member variables hold these counts.

+

+    int m_cFramesDropped;           // cumulative frames dropped IN THE RENDERER

+    int m_cFramesDrawn;             // Frames since streaming started seen BY THE

+                                    // RENDERER (some may be dropped upstream)

+

+    // Next two support average sync offset and standard deviation of sync offset.

+    LONGLONG m_iTotAcc;                  // Sum of accuracies in mSec

+    LONGLONG m_iSumSqAcc;           // Sum of squares of (accuracies in mSec)

+

+    // Next two allow jitter calculation.  Jitter is std deviation of frame time.

+    REFERENCE_TIME m_trLastDraw;    // Time of prev frame (for inter-frame times)

+    LONGLONG m_iSumSqFrameTime;     // Sum of squares of (inter-frame time in mSec)

+    LONGLONG m_iSumFrameTime;            // Sum of inter-frame times in mSec

+

+    // To get performance statistics on frame rate, jitter etc, we need

+    // to record the lateness and inter-frame time.  What we actually need are the

+    // data above (sum, sum of squares and number of entries for each) but the data

+    // is generated just ahead of time and only later do we discover whether the

+    // frame was actually drawn or not.  So we have to hang on to the data

+    int m_trLate;                   // hold onto frame lateness

+    int m_trFrame;                  // hold onto inter-frame time

+

+    int m_tStreamingStart;          // if streaming then time streaming started

+                                    // else time of last streaming session

+                                    // used for property page statistics

+#ifdef PERF

+    LONGLONG m_llTimeOffset;        // timeGetTime()*10000+m_llTimeOffset==ref time

+#endif

+

+public:

+

+

+    CBaseVideoRenderer(REFCLSID RenderClass, // CLSID for this renderer

+                       __in_opt LPCTSTR pName,         // Debug ONLY description

+                       __inout_opt LPUNKNOWN pUnk,       // Aggregated owner object

+                       __inout HRESULT *phr);        // General OLE return code

+

+    ~CBaseVideoRenderer();

+

+    // IQualityControl methods - Notify allows audio-video throttling

+

+    STDMETHODIMP SetSink( IQualityControl * piqc);

+    STDMETHODIMP Notify( IBaseFilter * pSelf, Quality q);

+

+    // These provide a full video quality management implementation

+

+    void OnRenderStart(IMediaSample *pMediaSample);

+    void OnRenderEnd(IMediaSample *pMediaSample);

+    void OnWaitStart();

+    void OnWaitEnd();

+    HRESULT OnStartStreaming();

+    HRESULT OnStopStreaming();

+    void ThrottleWait();

+

+    // Handle the statistics gathering for our quality management

+

+    void PreparePerformanceData(int trLate, int trFrame);

+    virtual void RecordFrameLateness(int trLate, int trFrame);

+    virtual void OnDirectRender(IMediaSample *pMediaSample);

+    virtual HRESULT ResetStreamingTimes();

+    BOOL ScheduleSample(IMediaSample *pMediaSample);

+    HRESULT ShouldDrawSampleNow(IMediaSample *pMediaSample,

+                                __inout REFERENCE_TIME *ptrStart,

+                                __inout REFERENCE_TIME *ptrEnd);

+

+    virtual HRESULT SendQuality(REFERENCE_TIME trLate, REFERENCE_TIME trRealStream);

+    STDMETHODIMP JoinFilterGraph(__inout_opt IFilterGraph * pGraph, __in_opt LPCWSTR pName);

+

+    //

+    //  Do estimates for standard deviations for per-frame

+    //  statistics

+    //

+    //  *piResult = (llSumSq - iTot * iTot / m_cFramesDrawn - 1) /

+    //                            (m_cFramesDrawn - 2)

+    //  or 0 if m_cFramesDrawn <= 3

+    //

+    HRESULT GetStdDev(

+        int nSamples,

+        __out int *piResult,

+        LONGLONG llSumSq,

+        LONGLONG iTot

+    );

+public:

+

+    // IQualProp property page support

+

+    STDMETHODIMP get_FramesDroppedInRenderer(__out int *cFramesDropped);

+    STDMETHODIMP get_FramesDrawn(__out int *pcFramesDrawn);

+    STDMETHODIMP get_AvgFrameRate(__out int *piAvgFrameRate);

+    STDMETHODIMP get_Jitter(__out int *piJitter);

+    STDMETHODIMP get_AvgSyncOffset(__out int *piAvg);

+    STDMETHODIMP get_DevSyncOffset(__out int *piDev);

+

+    // Implement an IUnknown interface and expose IQualProp

+

+    DECLARE_IUNKNOWN

+    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,__deref_out VOID **ppv);

+};

+

+#endif // __RENBASE__

+

diff --git a/jni/pjproject-android/.svn/pristine/69/69a788a132e0fc16210836a59f56bc2551deac2f.svn-base b/jni/pjproject-android/.svn/pristine/69/69a788a132e0fc16210836a59f56bc2551deac2f.svn-base
new file mode 100644
index 0000000..4e126a7
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/69/69a788a132e0fc16210836a59f56bc2551deac2f.svn-base
@@ -0,0 +1,46 @@
+/* $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 
+ */
+
+/*
+ * THIS FILE IS INCLUDED BY scanner.c.
+ * DO NOT COMPILE THIS FILE ALONE!
+ */
+
+
+PJ_DEF(void) pj_cis_buf_init( pj_cis_buf_t *cis_buf)
+{
+    /* Do nothing. */
+    PJ_UNUSED_ARG(cis_buf);
+}
+
+PJ_DEF(pj_status_t) pj_cis_init(pj_cis_buf_t *cis_buf, pj_cis_t *cis)
+{
+    PJ_UNUSED_ARG(cis_buf);
+    pj_bzero(cis->cis_buf, sizeof(cis->cis_buf));
+    return PJ_SUCCESS;
+}
+
+PJ_DEF(pj_status_t) pj_cis_dup( pj_cis_t *new_cis, pj_cis_t *existing)
+{
+    pj_memcpy(new_cis, existing, sizeof(pj_cis_t));
+    return PJ_SUCCESS;
+}
+
+