* #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/a3/a33129f7bf0bd22b05cd4b837636f9ae4ec62dd6.svn-base b/jni/pjproject-android/.svn/pristine/a3/a33129f7bf0bd22b05cd4b837636f9ae4ec62dd6.svn-base
new file mode 100644
index 0000000..081f36d
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/a3/a33129f7bf0bd22b05cd4b837636f9ae4ec62dd6.svn-base
@@ -0,0 +1,487 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#ifndef __PJNATH_STUN_SOCK_H__
+#define __PJNATH_STUN_SOCK_H__
+
+/**
+ * @file stun_sock.h
+ * @brief STUN aware socket transport
+ */
+#include <pjnath/stun_config.h>
+#include <pjlib-util/resolver.h>
+#include <pj/ioqueue.h>
+#include <pj/lock.h>
+#include <pj/sock.h>
+#include <pj/sock_qos.h>
+
+
+PJ_BEGIN_DECL
+
+
+/**
+ * @addtogroup PJNATH_STUN_SOCK
+ * @{
+ *
+ * The STUN transport provides asynchronous UDP like socket transport
+ * with the additional STUN capability. It has the following features:
+ *
+ *  - API to send and receive UDP packets
+ *
+ *  - multiplex STUN and non-STUN incoming packets and distinguish between
+ *    STUN responses that belong to internal requests with application data
+ *    (the application data may be STUN packets as well)
+ *
+ *  - DNS SRV resolution to the STUN server (if wanted), along with fallback
+ *    to DNS A resolution if SRV record is not found.
+ *
+ *  - STUN keep-alive maintenance, and handle changes to the mapped address
+ *    (when the NAT binding changes)
+ *
+ */
+
+/**
+ * Opaque type to represent a STUN transport.
+ */
+typedef struct pj_stun_sock pj_stun_sock;
+
+/**
+ * Types of operation being reported in \a on_status() callback of
+ * pj_stun_sock_cb. Application may retrieve the string representation
+ * of these constants with pj_stun_sock_op_name().
+ */
+typedef enum pj_stun_sock_op
+{
+    /**
+     * Asynchronous DNS resolution.
+     */
+    PJ_STUN_SOCK_DNS_OP		= 1,
+
+    /**
+     * Initial STUN Binding request.
+     */
+    PJ_STUN_SOCK_BINDING_OP,
+
+    /**
+     * Subsequent STUN Binding request for keeping the binding
+     * alive.
+     */
+    PJ_STUN_SOCK_KEEP_ALIVE_OP,
+
+    /**
+     * IP address change notification from the keep-alive operation.
+     */
+    PJ_STUN_SOCK_MAPPED_ADDR_CHANGE
+
+
+} pj_stun_sock_op;
+
+
+/**
+ * This structure contains callbacks that will be called by the STUN
+ * transport to notify application about various events.
+ */
+typedef struct pj_stun_sock_cb
+{
+    /**
+     * Notification when incoming packet has been received.
+     *
+     * @param stun_sock	The STUN transport.
+     * @param data	The packet.
+     * @param data_len	Length of the packet.
+     * @param src_addr	The source address of the packet.
+     * @param addr_len	The length of the source address.
+     *
+     * @return		Application should normally return PJ_TRUE to let
+     *			the STUN transport continue its operation. However
+     *			it must return PJ_FALSE if it has destroyed the
+     *			STUN transport in this callback.
+     */
+    pj_bool_t (*on_rx_data)(pj_stun_sock *stun_sock,
+			    void *pkt,
+			    unsigned pkt_len,
+			    const pj_sockaddr_t *src_addr,
+			    unsigned addr_len);
+
+    /**
+     * Notifification when asynchronous send operation has completed.
+     *
+     * @param stun_sock	The STUN transport.
+     * @param send_key	The send operation key that was given in
+     *			#pj_stun_sock_sendto().
+     * @param sent	If value is positive non-zero it indicates the
+     *			number of data sent. When the value is negative,
+     *			it contains the error code which can be retrieved
+     *			by negating the value (i.e. status=-sent).
+     *
+     * @return		Application should normally return PJ_TRUE to let
+     *			the STUN transport continue its operation. However
+     *			it must return PJ_FALSE if it has destroyed the
+     *			STUN transport in this callback.
+     */
+    pj_bool_t (*on_data_sent)(pj_stun_sock *stun_sock,
+			      pj_ioqueue_op_key_t *send_key,
+			      pj_ssize_t sent);
+
+    /**
+     * Notification when the status of the STUN transport has changed. This
+     * callback may be called for the following conditions:
+     *	- the first time the publicly mapped address has been resolved from
+     *	  the STUN server, this callback will be called with \a op argument
+     *    set to PJ_STUN_SOCK_BINDING_OP \a status  argument set to 
+     *    PJ_SUCCESS.
+     *	- anytime when the transport has detected that the publicly mapped
+     *    address has changed, this callback will be called with \a op
+     *    argument set to PJ_STUN_SOCK_KEEP_ALIVE_OP and \a status
+     *    argument set to PJ_SUCCESS. On this case and the case above,
+     *    application will get the resolved public address in the
+     *    #pj_stun_sock_info structure.
+     *	- for any terminal error (such as STUN time-out, DNS resolution
+     *    failure, or keep-alive failure), this callback will be called 
+     *	  with the \a status argument set to non-PJ_SUCCESS.
+     *
+     * @param stun_sock	The STUN transport.
+     * @param op	The operation that triggers the callback.
+     * @param status	The status.
+     *
+     * @return		Must return PJ_FALSE if it has destroyed the
+     *			STUN transport in this callback. Application should
+     *			normally destroy the socket and return PJ_FALSE
+     *			upon encountering terminal error, otherwise it
+     *			should return PJ_TRUE to let the STUN socket operation
+     *			continues.
+     */
+    pj_bool_t	(*on_status)(pj_stun_sock *stun_sock, 
+			     pj_stun_sock_op op,
+			     pj_status_t status);
+
+} pj_stun_sock_cb;
+
+
+/**
+ * This structure contains information about the STUN transport. Application
+ * may query this information by calling #pj_stun_sock_get_info().
+ */
+typedef struct pj_stun_sock_info
+{
+    /**
+     * The bound address of the socket.
+     */
+    pj_sockaddr	    bound_addr;
+
+    /**
+     * IP address of the STUN server.
+     */
+    pj_sockaddr	    srv_addr;
+
+    /**
+     * The publicly mapped address. It may contain zero address when the
+     * mapped address has not been resolved. Application may query whether
+     * this field contains valid address with pj_sockaddr_has_addr().
+     */
+    pj_sockaddr	    mapped_addr;
+
+    /**
+     * Number of interface address aliases. The interface address aliases
+     * are list of all interface addresses in this host.
+     */
+    unsigned	    alias_cnt;
+
+    /**
+     * Array of interface address aliases.
+     */
+    pj_sockaddr	    aliases[PJ_ICE_ST_MAX_CAND];
+
+} pj_stun_sock_info;
+
+
+/**
+ * This describe the settings to be given to the STUN transport during its
+ * creation. Application should initialize this structure by calling
+ * #pj_stun_sock_cfg_default().
+ */
+typedef struct pj_stun_sock_cfg
+{
+    /**
+     * The group lock to be used by the STUN socket. If NULL, the STUN socket
+     * will create one internally.
+     *
+     * Default: NULL
+     */
+    pj_grp_lock_t *grp_lock;
+
+    /**
+     * Packet buffer size.
+     *
+     * Default value is PJ_STUN_SOCK_PKT_LEN.
+     */
+    unsigned max_pkt_size;
+
+    /**
+     * Specify the number of simultaneous asynchronous read operations to
+     * be invoked to the ioqueue. Having more than one read operations will
+     * increase performance on multiprocessor systems since the application
+     * will be able to process more than one incoming packets simultaneously.
+     * Default value is 1.
+     */
+    unsigned async_cnt;
+
+    /**
+     * Specify the interface where the socket should be bound to. If the
+     * address is zero, socket will be bound to INADDR_ANY. If the address
+     * is non-zero, socket will be bound to this address only, and the
+     * transport will have only one address alias (the \a alias_cnt field
+     * in #pj_stun_sock_info structure. If the port is set to zero, the
+     * socket will bind at any port (chosen by the OS).
+     */
+    pj_sockaddr bound_addr;
+
+    /**
+     * Specify the port range for STUN socket binding, relative to the start
+     * port number specified in \a bound_addr. Note that this setting is only
+     * applicable when the start port number is non zero.
+     *
+     * Default value is zero.
+     */
+    pj_uint16_t	port_range;
+
+    /**
+     * Specify the STUN keep-alive duration, in seconds. The STUN transport
+     * does keep-alive by sending STUN Binding request to the STUN server. 
+     * If this value is zero, the PJ_STUN_KEEP_ALIVE_SEC value will be used.
+     * If the value is negative, it will disable STUN keep-alive.
+     */
+    int ka_interval;
+
+    /**
+     * QoS traffic type to be set on this transport. When application wants
+     * to apply QoS tagging to the transport, it's preferable to set this
+     * field rather than \a qos_param fields since this is more portable.
+     *
+     * Default value is PJ_QOS_TYPE_BEST_EFFORT.
+     */
+    pj_qos_type qos_type;
+
+    /**
+     * Set the low level QoS parameters to the transport. This is a lower
+     * level operation than setting the \a qos_type field and may not be
+     * supported on all platforms.
+     *
+     * By default all settings in this structure are disabled.
+     */
+    pj_qos_params qos_params;
+
+    /**
+     * Specify if STUN socket should ignore any errors when setting the QoS
+     * traffic type/parameters.
+     *
+     * Default: PJ_TRUE
+     */
+    pj_bool_t qos_ignore_error;
+
+    /**
+     * Specify target value for socket receive buffer size. It will be
+     * applied using setsockopt(). When it fails to set the specified size,
+     * it will try with lower value until the highest possible is
+     * successfully set.
+     *
+     * Default: 0 (OS default)
+     */
+    unsigned so_rcvbuf_size;
+
+    /**
+     * Specify target value for socket send buffer size. It will be
+     * applied using setsockopt(). When it fails to set the specified size,
+     * it will try with lower value until the highest possible is
+     * successfully set.
+     *
+     * Default: 0 (OS default)
+     */
+    unsigned so_sndbuf_size;
+
+} pj_stun_sock_cfg;
+
+
+
+/**
+ * Retrieve the name representing the specified operation.
+ */
+PJ_DECL(const char*) pj_stun_sock_op_name(pj_stun_sock_op op);
+
+
+/**
+ * Initialize the STUN transport setting with its default values.
+ *
+ * @param cfg	The STUN transport config.
+ */
+PJ_DECL(void) pj_stun_sock_cfg_default(pj_stun_sock_cfg *cfg);
+
+
+/**
+ * Create the STUN transport using the specified configuration. Once
+ * the STUN transport has been create, application should call
+ * #pj_stun_sock_start() to start the transport.
+ *
+ * @param stun_cfg	The STUN configuration which contains among other
+ *			things the ioqueue and timer heap instance for
+ *			the operation of this transport.
+ * @param af		Address family of socket. Currently pj_AF_INET()
+ *			and pj_AF_INET6() are supported. 
+ * @param name		Optional name to be given to this transport to
+ *			assist debugging.
+ * @param cb		Callback to receive events/data from the transport.
+ * @param cfg		Optional transport settings.
+ * @param user_data	Arbitrary application data to be associated with
+ *			this transport.
+ * @param p_sock	Pointer to receive the created transport instance.
+ *
+ * @return		PJ_SUCCESS if the operation has been successful,
+ *			or the appropriate error code on failure.
+ */
+PJ_DECL(pj_status_t) pj_stun_sock_create(pj_stun_config *stun_cfg,
+					 const char *name,
+					 int af,
+					 const pj_stun_sock_cb *cb,
+					 const pj_stun_sock_cfg *cfg,
+					 void *user_data,
+					 pj_stun_sock **p_sock);
+
+
+/**
+ * Start the STUN transport. This will start the DNS SRV resolution for
+ * the STUN server (if desired), and once the server is resolved, STUN
+ * Binding request will be sent to resolve the publicly mapped address.
+ * Once the initial STUN Binding response is received, the keep-alive
+ * timer will be started.
+ *
+ * @param stun_sock	The STUN transport instance.
+ * @param domain	The domain, hostname, or IP address of the TURN
+ *			server. When this parameter contains domain name,
+ *			the \a resolver parameter must be set to activate
+ *			DNS SRV resolution.
+ * @param default_port	The default STUN port number to use when DNS SRV
+ *			resolution is not used. If DNS SRV resolution is
+ *			used, the server port number will be set from the
+ *			DNS SRV records. The recommended value for this
+ *			parameter is PJ_STUN_PORT.
+ * @param resolver	If this parameter is not NULL, then the \a domain
+ *			parameter will be first resolved with DNS SRV and
+ *			then fallback to using DNS A/AAAA resolution when
+ *			DNS SRV resolution fails. If this parameter is
+ *			NULL, the \a domain parameter will be resolved as
+ *			hostname.
+ *
+ * @return		PJ_SUCCESS if the operation has been successfully
+ *			queued, or the appropriate error code on failure.
+ *			When this function returns PJ_SUCCESS, the final
+ *			result of the allocation process will be notified
+ *			to application in \a on_state() callback.
+ */
+PJ_DECL(pj_status_t) pj_stun_sock_start(pj_stun_sock *stun_sock,
+				        const pj_str_t *domain,
+				        pj_uint16_t default_port,
+				        pj_dns_resolver *resolver);
+
+/**
+ * Destroy the STUN transport.
+ *
+ * @param sock		The STUN transport socket.
+ *
+ * @return		PJ_SUCCESS if the operation has been successful,
+ *			or the appropriate error code on failure.
+ */
+PJ_DECL(pj_status_t) pj_stun_sock_destroy(pj_stun_sock *sock);
+
+
+/**
+ * Associate a user data with this STUN transport. The user data may then
+ * be retrieved later with #pj_stun_sock_get_user_data().
+ *
+ * @param stun_sock	The STUN transport instance.
+ * @param user_data	Arbitrary data.
+ *
+ * @return		PJ_SUCCESS if the operation has been successful,
+ *			or the appropriate error code on failure.
+ */
+PJ_DECL(pj_status_t) pj_stun_sock_set_user_data(pj_stun_sock *stun_sock,
+					        void *user_data);
+
+/**
+ * Retrieve the previously assigned user data associated with this STUN
+ * transport.
+ *
+ * @param stun_sock	The STUN transport instance.
+ *
+ * @return		The user/application data.
+ */
+PJ_DECL(void*) pj_stun_sock_get_user_data(pj_stun_sock *stun_sock);
+
+
+/**
+ * Get the STUN transport info. The transport info contains, among other
+ * things, the allocated relay address.
+ *
+ * @param stun_sock	The STUN transport instance.
+ * @param info		Pointer to be filled with STUN transport info.
+ *
+ * @return		PJ_SUCCESS if the operation has been successful,
+ *			or the appropriate error code on failure.
+ */
+PJ_DECL(pj_status_t) pj_stun_sock_get_info(pj_stun_sock *stun_sock,
+					   pj_stun_sock_info *info);
+
+
+/**
+ * Send a data to the specified address. This function may complete
+ * asynchronously and in this case \a on_data_sent() will be called.
+ *
+ * @param stun_sock	The STUN transport instance.
+ * @param send_key	Optional send key for sending the packet down to
+ *			the ioqueue. This value will be given back to
+ *			\a on_data_sent() callback
+ * @param pkt		The data/packet to be sent to peer.
+ * @param pkt_len	Length of the data.
+ * @param flag		pj_ioqueue_sendto() flag.
+ * @param dst_addr	The remote address.
+ * @param addr_len	Length of the address.
+ *
+ * @return		PJ_SUCCESS if data has been sent immediately, or
+ *			PJ_EPENDING if data cannot be sent immediately. In
+ *			this case the \a on_data_sent() callback will be
+ *			called when data is actually sent. Any other return
+ *			value indicates error condition.
+ */ 
+PJ_DECL(pj_status_t) pj_stun_sock_sendto(pj_stun_sock *stun_sock,
+					 pj_ioqueue_op_key_t *send_key,
+					 const void *pkt,
+					 unsigned pkt_len,
+					 unsigned flag,
+					 const pj_sockaddr_t *dst_addr,
+					 unsigned addr_len);
+
+/**
+ * @}
+ */
+
+
+PJ_END_DECL
+
+
+#endif	/* __PJNATH_STUN_SOCK_H__ */
+
diff --git a/jni/pjproject-android/.svn/pristine/a3/a3bf29473aaf4a239c1d1cd2d42cead1a190dcfc.svn-base b/jni/pjproject-android/.svn/pristine/a3/a3bf29473aaf4a239c1d1cd2d42cead1a190dcfc.svn-base
new file mode 100644
index 0000000..d1df5b2
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/a3/a3bf29473aaf4a239c1d1cd2d42cead1a190dcfc.svn-base
@@ -0,0 +1,162 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#ifndef __PJSIP_SIP_UA_LAYER_H__
+#define __PJSIP_SIP_UA_LAYER_H__
+
+/**
+ * @file sip_ua_layer.h
+ * @brief SIP User Agent Layer Module
+ */
+#include <pjsip/sip_types.h>
+
+
+PJ_BEGIN_DECL
+
+/**
+ * @defgroup PJSIP_UA Base User Agent Layer/Common Dialog Layer
+ * @brief Dialog management.
+ *
+ * This module provides basic dialog management, which is used by higher
+ * layer dialog usages such as INVITE sessions and SIP Event Subscription
+ * framework (RFC 3265). Application should link  with <b>pjsip-core</b> 
+ * library to use this base UA layer. The base UA layer module is initialized
+ * with #pjsip_ua_init_module().
+ */
+
+/**
+ * @defgroup PJSUA_UA SIP User Agent Module
+ * @ingroup PJSIP_UA
+ * @brief Provides dialog management.
+ * @{
+ *
+ * Application MUST initialize the user agent layer module by calling
+ * #pjsip_ua_init_module() before using any of the dialog API, and link
+ * the application with with <b>pjsip-core</b> library.
+ */
+
+/** User agent initialization parameter. */
+typedef struct pjsip_ua_init_param
+{
+    /** Callback to be called when the UA layer detects that outgoing
+     *  dialog has forked.
+     */
+    pjsip_dialog* (*on_dlg_forked)(pjsip_dialog *first_set, pjsip_rx_data *res);
+} pjsip_ua_init_param;
+
+/**
+ * Initialize user agent layer and register it to the specified endpoint.
+ *
+ * @param endpt		The endpoint where the user agent will be
+ *			registered.
+ * @param prm		UA initialization parameter.
+ *
+ * @return		PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_ua_init_module(pjsip_endpoint *endpt,
+					  const pjsip_ua_init_param *prm);
+
+/**
+ * Get the instance of the user agent.
+ *
+ * @return		The user agent module instance.
+ */
+PJ_DECL(pjsip_user_agent*) pjsip_ua_instance(void);
+
+
+/**
+ * Retrieve the current number of dialog-set currently registered
+ * in the hash table. Note that dialog-set is different than dialog
+ * when the request forks. In this case, all dialogs created from
+ * the original request will belong to the same dialog set. When
+ * no forking occurs, the number of dialog sets will be equal to
+ * the number of dialogs.
+ *
+ * @return	    Number of dialog sets.
+ */
+PJ_DECL(pj_uint32_t) pjsip_ua_get_dlg_set_count(void);
+
+
+/**
+ * Find a dialog with the specified Call-ID and tags properties. This
+ * function may optionally lock the matching dialog instance before
+ * returning it back to the caller.
+ *
+ * @param call_id	The call ID to be matched.
+ * @param local_tag	The local tag to be matched.
+ * @param remote_tag	The remote tag to be matched.
+ * @param lock_dialog	If non-zero, instruct the function to lock the 
+ *			matching dialog with #pjsip_dlg_inc_lock(). 
+ *			Application is responsible to release the dialog's
+ *			lock after it has finished manipulating the dialog,
+ *			by calling #pjsip_dlg_dec_lock().
+ *
+ * @return		The matching dialog instance, or NULL if no matching
+ *			dialog is found.
+ */
+PJ_DECL(pjsip_dialog*) pjsip_ua_find_dialog(const pj_str_t *call_id,
+					    const pj_str_t *local_tag,
+					    const pj_str_t *remote_tag,
+					    pj_bool_t lock_dialog);
+
+/**
+ * Destroy the user agent layer.
+ *
+ * @return		PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_ua_destroy(void);
+
+/**
+ * Dump user agent contents (e.g. all dialogs).
+ *
+ * @param detail	If non-zero, list of dialogs will be printed.
+ */
+PJ_DECL(void) pjsip_ua_dump(pj_bool_t detail);
+
+/**
+ * Get the endpoint instance of a user agent module.
+ *
+ * @param ua		The user agent instance.
+ *
+ * @return		The endpoint instance where the user agent is
+ *			registered.
+ */
+PJ_DECL(pjsip_endpoint*) pjsip_ua_get_endpt(pjsip_user_agent *ua);
+
+
+/**
+ * @}
+ */
+
+
+/*
+ * Internal (called by sip_dialog.c).
+ */
+
+PJ_DECL(pj_status_t) pjsip_ua_register_dlg( pjsip_user_agent *ua,
+					    pjsip_dialog *dlg );
+PJ_DECL(pj_status_t) pjsip_ua_unregister_dlg(pjsip_user_agent *ua,
+					     pjsip_dialog *dlg );
+
+
+PJ_END_DECL
+
+
+#endif	/* __PJSIP_SIP_UA_LAYER_H__ */
+
diff --git a/jni/pjproject-android/.svn/pristine/a3/a3d5bf2a2b910c19fa6ae93d5420fe1ed8dab942.svn-base b/jni/pjproject-android/.svn/pristine/a3/a3d5bf2a2b910c19fa6ae93d5420fe1ed8dab942.svn-base
new file mode 100644
index 0000000..60fcfd8
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/a3/a3d5bf2a2b910c19fa6ae93d5420fe1ed8dab942.svn-base
@@ -0,0 +1 @@
+#include "../../../portaudio/src/common/pa_endianness.h"
diff --git a/jni/pjproject-android/.svn/pristine/a3/a3db0d40d9893ef404a6811ee9b4f371f113afa0.svn-base b/jni/pjproject-android/.svn/pristine/a3/a3db0d40d9893ef404a6811ee9b4f371f113afa0.svn-base
new file mode 100644
index 0000000..1b5b335
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/a3/a3db0d40d9893ef404a6811ee9b4f371f113afa0.svn-base
@@ -0,0 +1,152 @@
+/* $Id$ */
+/* 
+ * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
+ */
+#ifndef __PJ_SELECT_H__
+#define __PJ_SELECT_H__
+
+/**
+ * @file sock_select.h
+ * @brief Socket select().
+ */
+
+#include <pj/types.h>
+
+PJ_BEGIN_DECL 
+
+/**
+ * @defgroup PJ_SOCK_SELECT Socket select() API.
+ * @ingroup PJ_IO
+ * @{
+ * This module provides portable abstraction for \a select() like API.
+ * The abstraction is needed so that it can utilize various event
+ * dispatching mechanisms that are available across platforms.
+ *
+ * The API is very similar to normal \a select() usage. 
+ *
+ * \section pj_sock_select_examples_sec Examples
+ *
+ * For some examples on how to use the select API, please see:
+ *
+ *  - \ref page_pjlib_select_test
+ */
+
+/**
+ * Portable structure declarations for pj_fd_set.
+ * The implementation of pj_sock_select() does not use this structure 
+ * per-se, but instead it will use the native fd_set structure. However,
+ * we must make sure that the size of pj_fd_set_t can accomodate the
+ * native fd_set structure.
+ */
+typedef struct pj_fd_set_t
+{
+    pj_sock_t data[PJ_IOQUEUE_MAX_HANDLES+ 4]; /**< Opaque buffer for fd_set */
+} pj_fd_set_t;
+
+
+/**
+ * Initialize the descriptor set pointed to by fdsetp to the null set.
+ *
+ * @param fdsetp    The descriptor set.
+ */
+PJ_DECL(void) PJ_FD_ZERO(pj_fd_set_t *fdsetp);
+
+
+/**
+ * This is an internal function, application shouldn't use this.
+ * 
+ * Get the number of descriptors in the set. This is defined in sock_select.c
+ * This function will only return the number of sockets set from PJ_FD_SET
+ * operation. When the set is modified by other means (such as by select()),
+ * the count will not be reflected here.
+ *
+ * @param fdsetp    The descriptor set.
+ *
+ * @return          Number of descriptors in the set.
+ */
+PJ_DECL(pj_size_t) PJ_FD_COUNT(const pj_fd_set_t *fdsetp);
+
+
+/**
+ * Add the file descriptor fd to the set pointed to by fdsetp. 
+ * If the file descriptor fd is already in this set, there shall be no effect
+ * on the set, nor will an error be returned.
+ *
+ * @param fd	    The socket descriptor.
+ * @param fdsetp    The descriptor set.
+ */
+PJ_DECL(void) PJ_FD_SET(pj_sock_t fd, pj_fd_set_t *fdsetp);
+
+/**
+ * Remove the file descriptor fd from the set pointed to by fdsetp. 
+ * If fd is not a member of this set, there shall be no effect on the set, 
+ * nor will an error be returned.
+ *
+ * @param fd	    The socket descriptor.
+ * @param fdsetp    The descriptor set.
+ */
+PJ_DECL(void) PJ_FD_CLR(pj_sock_t fd, pj_fd_set_t *fdsetp);
+
+
+/**
+ * Evaluate to non-zero if the file descriptor fd is a member of the set 
+ * pointed to by fdsetp, and shall evaluate to zero otherwise.
+ *
+ * @param fd	    The socket descriptor.
+ * @param fdsetp    The descriptor set.
+ *
+ * @return	    Nonzero if fd is member of the descriptor set.
+ */
+PJ_DECL(pj_bool_t) PJ_FD_ISSET(pj_sock_t fd, const pj_fd_set_t *fdsetp);
+
+
+/**
+ * This function wait for a number of file  descriptors to change status.
+ * The behaviour is the same as select() function call which appear in
+ * standard BSD socket libraries.
+ *
+ * @param n	    On Unices, this specifies the highest-numbered
+ *		    descriptor in any of the three set, plus 1. On Windows,
+ *		    the value is ignored.
+ * @param readfds   Optional pointer to a set of sockets to be checked for 
+ *		    readability.
+ * @param writefds  Optional pointer to a set of sockets to be checked for 
+ *		    writability.
+ * @param exceptfds Optional pointer to a set of sockets to be checked for 
+ *		    errors.
+ * @param timeout   Maximum time for select to wait, or null for blocking 
+ *		    operations.
+ *
+ * @return	    The total number of socket handles that are ready, or
+ *		    zero if the time limit expired, or -1 if an error occurred.
+ */
+PJ_DECL(int) pj_sock_select( int n, 
+			     pj_fd_set_t *readfds, 
+			     pj_fd_set_t *writefds,
+			     pj_fd_set_t *exceptfds, 
+			     const pj_time_val *timeout);
+
+
+/**
+ * @}
+ */
+
+
+PJ_END_DECL
+
+#endif	/* __PJ_SELECT_H__ */
diff --git a/jni/pjproject-android/.svn/pristine/a3/a3f023e00e027b69290015ea4bed238c3d04ba35.svn-base b/jni/pjproject-android/.svn/pristine/a3/a3f023e00e027b69290015ea4bed238c3d04ba35.svn-base
new file mode 100644
index 0000000..c16a7a1
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/a3/a3f023e00e027b69290015ea4bed238c3d04ba35.svn-base
Binary files differ
diff --git a/jni/pjproject-android/.svn/pristine/a3/a3f110234d57b62f378c741f85efdb4d993832ad.svn-base b/jni/pjproject-android/.svn/pristine/a3/a3f110234d57b62f378c741f85efdb4d993832ad.svn-base
new file mode 100644
index 0000000..830259d
--- /dev/null
+++ b/jni/pjproject-android/.svn/pristine/a3/a3f110234d57b62f378c741f85efdb4d993832ad.svn-base
@@ -0,0 +1,242 @@
+/* $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/config.h>
+
+
+#if defined(PJMEDIA_VIDEO_DEV_HAS_DSHOW) && PJMEDIA_VIDEO_DEV_HAS_DSHOW != 0
+
+
+#include <assert.h>
+#include <streams.h>
+
+typedef void (*input_callback)(void *user_data, IMediaSample *pMediaSample);
+
+const GUID CLSID_NullRenderer = {0xF9168C5E, 0xCEB2, 0x4FAA, {0xB6, 0xBF,
+                                 0x32, 0x9B, 0xF3, 0x9F, 0xA1, 0xE4}};
+
+const GUID CLSID_SourceFilter = {0xF9168C5E, 0xCEB2, 0x4FAA, {0xB6, 0xBF,
+                                 0x32, 0x9B, 0xF3, 0x9F, 0xA1, 0xE5}};
+
+class NullRenderer: public CBaseRenderer
+{
+public:
+    NullRenderer(HRESULT *pHr);
+    virtual ~NullRenderer();
+
+    virtual HRESULT CheckMediaType(const CMediaType *pmt);
+    virtual HRESULT DoRenderSample(IMediaSample *pMediaSample);
+
+    input_callback  input_cb;
+    void           *user_data;
+};
+
+class OutputPin: public CBaseOutputPin
+{
+public:
+    OutputPin(CBaseFilter *pFilter, CCritSec *pLock, HRESULT *pHr);
+    ~OutputPin();
+
+    HRESULT Push(void *buf, long size);
+
+    virtual HRESULT CheckMediaType(const CMediaType *pmt);
+    virtual HRESULT DecideBufferSize(IMemAllocator *pAlloc, 
+                                     ALLOCATOR_PROPERTIES *ppropInputRequest);
+
+    CMediaType mediaType;
+    long bufSize;
+};
+
+class SourceFilter: public CBaseFilter
+{
+public:
+    SourceFilter();
+    ~SourceFilter();
+
+    int GetPinCount();
+    CBasePin* GetPin(int n);
+
+protected:
+    CCritSec lock;
+    OutputPin* outPin;
+};
+
+OutputPin::OutputPin(CBaseFilter *pFilter, CCritSec *pLock, HRESULT *pHr):
+    CBaseOutputPin("OutputPin", pFilter, pLock, pHr, L"OutputPin")
+{
+}
+
+OutputPin::~OutputPin()
+{
+}
+
+HRESULT OutputPin::CheckMediaType(const CMediaType *pmt)
+{
+    return S_OK;
+}
+
+HRESULT OutputPin::DecideBufferSize(IMemAllocator *pAlloc, 
+                                    ALLOCATOR_PROPERTIES *ppropInputRequest)
+{
+    ALLOCATOR_PROPERTIES properties;
+
+    ppropInputRequest->cbBuffer = bufSize;
+    ppropInputRequest->cBuffers = 1;
+
+    /* First set the buffer descriptions we're interested in */
+    pAlloc->SetProperties(ppropInputRequest, &properties);
+
+    return S_OK;
+}
+
+HRESULT OutputPin::Push(void *buf, long size)
+{
+    HRESULT hr;
+    IMediaSample *pSample;
+    VIDEOINFOHEADER *vi;
+    AM_MEDIA_TYPE *pmt;
+    BYTE *dst_buf;
+
+    /**
+     * Hold the critical section here as the pin might get disconnected
+     * during the Deliver() method call.
+     */
+    m_pLock->Lock();
+
+    hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0);
+    if (FAILED(hr))
+        goto on_error;
+
+    pSample->GetMediaType(&pmt);
+    if (pmt) {
+        mediaType.Set(*pmt);
+        bufSize = pmt->lSampleSize;
+    }
+
+    pSample->GetPointer(&dst_buf);
+    vi = (VIDEOINFOHEADER *)mediaType.pbFormat;
+    if (vi->rcSource.right == vi->bmiHeader.biWidth) {
+        assert(pSample->GetSize() >= size);
+        memcpy(dst_buf, buf, size);
+    } else {
+        unsigned i, bpp;
+        unsigned dststride, srcstride;
+        BYTE *src_buf = (BYTE *)buf;
+
+        bpp = size / abs(vi->bmiHeader.biHeight) / vi->rcSource.right;
+        dststride = vi->bmiHeader.biWidth * bpp;
+        srcstride = vi->rcSource.right * bpp;
+        for (i = abs(vi->bmiHeader.biHeight); i > 0; i--) {
+            memcpy(dst_buf, src_buf, srcstride);
+            dst_buf += dststride;
+            src_buf += srcstride;
+        }
+    }
+    pSample->SetActualDataLength(size);
+
+    hr = Deliver(pSample);
+
+    pSample->Release();
+
+on_error:
+    m_pLock->Unlock();
+    return hr;
+}
+
+SourceFilter::SourceFilter(): CBaseFilter("SourceFilter", NULL, &lock, 
+                                          CLSID_SourceFilter)
+{
+    HRESULT hr;
+    outPin = new OutputPin(this, &lock, &hr);
+}
+
+SourceFilter::~SourceFilter()
+{
+}
+
+int SourceFilter::GetPinCount()
+{
+    return 1;
+}
+
+CBasePin* SourceFilter::GetPin(int n)
+{
+    return outPin;
+}
+
+NullRenderer::NullRenderer(HRESULT *pHr): CBaseRenderer(CLSID_NullRenderer,
+                                                        "NullRenderer",
+                                                        NULL, pHr)
+{
+    input_cb = NULL;
+}
+
+NullRenderer::~NullRenderer()
+{
+}
+
+HRESULT NullRenderer::CheckMediaType(const CMediaType *pmt)
+{
+    return S_OK;
+}
+
+HRESULT NullRenderer::DoRenderSample(IMediaSample *pMediaSample)
+{
+    if (input_cb)
+        input_cb(user_data, pMediaSample);
+
+    return S_OK;
+}
+
+extern "C" IBaseFilter* NullRenderer_Create(input_callback input_cb,
+                                             void *user_data)
+{
+    HRESULT hr;
+    NullRenderer *renderer = new NullRenderer(&hr);
+    renderer->AddRef();
+    renderer->input_cb = input_cb;
+    renderer->user_data = user_data;
+
+    return (CBaseFilter *)renderer;
+}
+
+extern "C" IBaseFilter* SourceFilter_Create(SourceFilter **pSrc)
+{
+    SourceFilter *src = new SourceFilter();
+    src->AddRef();
+    *pSrc = src;
+
+    return (CBaseFilter *)src;
+}
+
+extern "C" HRESULT SourceFilter_Deliver(SourceFilter *src,
+                                        void *buf, long size)
+{
+    return ((OutputPin *)src->GetPin(0))->Push(buf, size);
+}
+
+extern "C" void SourceFilter_SetMediaType(SourceFilter *src,
+                                          AM_MEDIA_TYPE *pmt)
+{
+    ((OutputPin *)src->GetPin(0))->mediaType.Set(*pmt);
+    ((OutputPin *)src->GetPin(0))->bufSize = pmt->lSampleSize;
+}
+
+
+#endif	/* PJMEDIA_VIDEO_DEV_HAS_DSHOW */