Switch commoncpp2 to ucommon to solve dependency conflicts.

libccrtp was depending on commoncpp2, and have been replaced by a version
depending on ucommon as well.
diff --git a/jni/libccrtp/sources/src/.cvsignore b/jni/libccrtp/sources/src/.cvsignore
new file mode 100644
index 0000000..c986ea0
--- /dev/null
+++ b/jni/libccrtp/sources/src/.cvsignore
@@ -0,0 +1,11 @@
+# ignore genorated...
+
+Makefile
+config.h
+config.h.in
+Makefile.in
+*.lo
+*.la
+.libs
+stamp-*
+*.tmp
diff --git a/jni/libccrtp/sources/src/CMakeLists.txt b/jni/libccrtp/sources/src/CMakeLists.txt
new file mode 100644
index 0000000..d52153b
--- /dev/null
+++ b/jni/libccrtp/sources/src/CMakeLists.txt
@@ -0,0 +1,69 @@
+## Copyright (C) 1999-2005 Open Source Telecom Corporation.
+## Copyright (C) 2006-2008 David Sugar, Tycho Softworks.
+## Copyright (C) 2009-2010 Werner Dittmann
+##
+## This file is free software; as a special exception the author gives
+## unlimited permission to copy and/or distribute it, with or without
+## modifications, as long as this notice is preserved.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+## implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+
+########### next target ###############
+
+set(openssl_srcs ccrtp/crypto/openssl/hmac.cpp
+         ccrtp/crypto/openssl/SrtpSymCrypto.cpp)
+
+set(gcrypt_srcs ccrtp/crypto/gcrypt/gcrypthmac.cpp
+        ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp
+        ccrtp/crypto/gcrypt/InitializeGcrypt.cpp)
+
+set(skein_srcs ccrtp/crypto/macSkein.cpp
+        ccrtp/crypto/skein.c
+        ccrtp/crypto/skein_block.c
+        ccrtp/crypto/skeinApi.c)
+
+set(twofish_srcs ccrtp/crypto/twofish.c)
+
+if (SRTP_SUPPORT)
+  if(GCRYPT_FOUND)
+    set(crypto_srcs ${gcrypt_srcs})
+  else()
+    set(crypto_srcs ${openssl_srcs})
+  endif()
+endif()
+
+set(ccrtp_srcs
+    rtppkt.cpp
+    rtcppkt.cpp
+    source.cpp
+    data.cpp
+    incqueue.cpp
+    outqueue.cpp
+    queue.cpp
+    control.cpp
+    members.cpp
+    socket.cpp
+    duplex.cpp
+    pool.cpp
+    CryptoContext.cpp
+    CryptoContextCtrl.cpp)
+
+add_subdirectory(ccrtp)
+
+if(BUILD_STATIC AND NOT BUILD_SHARED)
+    set(BUILD_LIBRARY_TYPE STATIC)
+else()
+    set(BUILD_LIBRARY_TYPE SHARED)
+endif()
+
+add_library(ccrtp ${BUILD_LIBRARY_TYPE} ${ccrtp_srcs} ${crypto_srcs} ${skein_srcs} ${twofish_srcs})
+set_target_properties(ccrtp PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION})
+target_link_libraries(ccrtp commoncpp ${LIBS})
+add_dependencies(ccrtp commoncpp)
+
+########### install files ###############
+
+install(TARGETS ccrtp DESTINATION lib${LIB64})
diff --git a/jni/libccrtp/sources/src/CryptoContext.cxx b/jni/libccrtp/sources/src/CryptoContext.cpp
similarity index 88%
rename from jni/libccrtp/sources/src/CryptoContext.cxx
rename to jni/libccrtp/sources/src/CryptoContext.cpp
index bbc1174..8e9bbc6 100644
--- a/jni/libccrtp/sources/src/CryptoContext.cxx
+++ b/jni/libccrtp/sources/src/CryptoContext.cpp
@@ -16,32 +16,32 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */
 
-/* Copyright (C) 2004-2006
+/* Copyright (C) 2004-2012
  *
  * Authors: Israel Abad <i_abad@terra.es>
  *          Erik Eliasson <eliasson@it.kth.se>
  *          Johan Bilien <jobi@via.ecp.fr>
- *      Joachim Orrblad <joachim@orrblad.com>
+ *          Joachim Orrblad <joachim@orrblad.com>
  *          Werner Dittmann <Werner.Dittmann@t-online.de>
  */
 
 #include <iostream>
 
-#include <config.h>
+#include <ccrtp-config.h>
 
 #ifdef SRTP_SUPPORT
 #include <ccrtp/crypto/hmac.h>
 #include <ccrtp/crypto/macSkein.h>
 #endif
 
+#include <commoncpp/config.h>
+#include <commoncpp/export.h>
 #include <ccrtp/CryptoContext.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 CryptoContext::CryptoContext( uint32 ssrc ):
-ssrc(ssrc),
+ssrcCtx(ssrc),
 using_mki(false),mkiLength(0),mki(NULL),
 roc(0),guessed_roc(0),s_l(0),key_deriv_rate(0),
 replay_window(0),
@@ -51,7 +51,7 @@
 n_e(0),k_e(NULL),n_a(0),k_a(NULL),n_s(0),k_s(NULL),
 ealg(SrtpEncryptionNull), aalg(SrtpAuthenticationNull),
 ekeyl(0), akeyl(0), skeyl(0),
-seqNumSet(false), cipher(NULL), f8Cipher(NULL)
+seqNumSet(false), macCtx(NULL), cipher(NULL), f8Cipher(NULL)
 {}
 
 #ifdef SRTP_SUPPORT
@@ -69,11 +69,11 @@
                                 int32 skeyl,
                                 int32 tagLength):
 
-ssrc(ssrc),using_mki(false),mkiLength(0),mki(NULL),
+ssrcCtx(ssrc),using_mki(false),mkiLength(0),mki(NULL),
 roc(roc),guessed_roc(0),s_l(0),key_deriv_rate(key_deriv_rate),
 replay_window(0),
 master_key_srtp_use_nb(0), master_key_srtcp_use_nb(0), seqNumSet(false),
-cipher(NULL), f8Cipher(NULL)
+macCtx(NULL), cipher(NULL), f8Cipher(NULL)
 {
     this->ealg = ealg;
     this->aalg = aalg;
@@ -98,25 +98,25 @@
         break;
 
         case SrtpEncryptionTWOF8:
-        f8Cipher = new AesSrtp(SrtpEncryptionTWOCM);
+        f8Cipher = new SrtpSymCrypto(SrtpEncryptionTWOF8);
 
         case SrtpEncryptionTWOCM:
         n_e = ekeyl;
         k_e = new uint8[n_e];
         n_s = skeyl;
         k_s = new uint8[n_s];
-        cipher = new AesSrtp(SrtpEncryptionTWOCM);
+        cipher = new SrtpSymCrypto(SrtpEncryptionTWOCM);
         break;
 
         case SrtpEncryptionAESF8:
-        f8Cipher = new AesSrtp(SrtpEncryptionAESCM);
+        f8Cipher = new SrtpSymCrypto(SrtpEncryptionAESF8);
 
         case SrtpEncryptionAESCM:
         n_e = ekeyl;
         k_e = new uint8[n_e];
         n_s = skeyl;
         k_s = new uint8[n_s];
-        cipher = new AesSrtp(SrtpEncryptionAESCM);
+        cipher = new SrtpSymCrypto(SrtpEncryptionAESCM);
         break;
     }
 
@@ -140,30 +140,32 @@
 
 CryptoContext::~CryptoContext(){
 
-    ealg = SrtpEncryptionNull;
-    aalg = SrtpAuthenticationNull;
-
 #ifdef SRTP_SUPPORT
     if (mki)
         delete [] mki;
 
     if (master_key_length > 0) {
+        memset(master_key, 0, master_key_length);
         master_key_length = 0;
         delete [] master_key;
     }
     if (master_salt_length > 0) {
+        memset(master_salt, 0, master_salt_length);
         master_salt_length = 0;
         delete [] master_salt;
     }
     if (n_e > 0) {
+        memset(k_e, 0, n_e);
         n_e = 0;
         delete [] k_e;
     }
     if (n_s > 0) {
+        memset(k_s, 0, n_s);
         n_s = 0;
         delete [] k_s;
     }
     if (n_a > 0) {
+        memset(k_a, 0, n_a);
         n_a = 0;
         delete [] k_a;
     }
@@ -187,15 +189,18 @@
         }
     }
 #endif
+
+    ealg = SrtpEncryptionNull;
+    aalg = SrtpAuthenticationNull;
 }
 
-void CryptoContext::srtpEncrypt( RTPPacket* rtp, uint64 index, uint32 ssrc )
+void CryptoContext::srtpEncrypt(RTPPacket* rtp, uint64 index, uint32 ssrc)
 {
     if (ealg == SrtpEncryptionNull) {
         return;
     }
 #ifdef SRTP_SUPPORT
-    if (ealg == SrtpEncryptionAESCM) {
+    if (ealg == SrtpEncryptionAESCM || ealg == SrtpEncryptionTWOCM) {
 
         /* Compute the CM IV (refer to chapter 4.1.1 in RFC 3711):
          *
@@ -211,19 +216,19 @@
 
         int i;
         for(i = 4; i < 8; i++ ){
-        iv[i] = ( 0xFF & ( ssrc >> ((7-i)*8) ) ) ^ k_s[i];
+            iv[i] = ( 0xFF & ( ssrc >> ((7-i)*8) ) ) ^ k_s[i];
         }
         for(i = 8; i < 14; i++ ){
-        iv[i] = ( 0xFF & (unsigned char)( index >> ((13-i)*8) ) ) ^ k_s[i];
+            iv[i] = ( 0xFF & (unsigned char)( index >> ((13-i)*8) ) ) ^ k_s[i];
         }
         iv[14] = iv[15] = 0;
 
         int32 pad = rtp->isPadded() ? rtp->getPaddingSize() : 0;
-        cipher->ctr_encrypt( const_cast<uint8*>(rtp->getPayload()),
-                  rtp->getPayloadSize()+pad, iv);
+        cipher->ctr_encrypt(const_cast<uint8*>(rtp->getPayload()),
+                            rtp->getPayloadSize()+pad, iv);
     }
 
-    if (ealg == SrtpEncryptionAESF8) {
+    if (ealg == SrtpEncryptionAESF8 || ealg == SrtpEncryptionTWOF8) {
 
         /* Create the F8 IV (refer to chapter 4.1.2.2 in RFC 3711):
          *
@@ -243,9 +248,7 @@
         ui32p[3] = htonl(roc);
 
         int32 pad = rtp->isPadded() ? rtp->getPaddingSize() : 0;
-        cipher->f8_encrypt(rtp->getPayload(),
-                  rtp->getPayloadSize()+pad,
-                  iv, k_e, n_e, k_s, n_s, f8Cipher);
+        cipher->f8_encrypt(rtp->getPayload(), rtp->getPayloadSize()+pad, iv, f8Cipher);
     }
 #endif
 }
@@ -338,6 +341,7 @@
 
     // prepare AES cipher to compute derived keys.
     cipher->setNewKey(master_key, master_key_length);
+    memset(master_key, 0, master_key_length);
 
     // compute the session encryption key
     uint64 label = 0;
@@ -348,6 +352,7 @@
     label = 0x01;
     computeIv(iv, label, index, key_deriv_rate, master_salt);
     cipher->get_ctr_cipher_stream(k_a, n_a, iv);
+
     // Initialize MAC context with the derived key
     switch (aalg) {
     case SrtpAuthenticationSha1Hmac:
@@ -358,13 +363,20 @@
         macCtx = createSkeinMacContext(k_a, n_a, tagLength*8, Skein512);
         break;
     }
+    memset(k_a, 0, n_a);
+
     // compute the session salt
     label = 0x02;
     computeIv(iv, label, index, key_deriv_rate, master_salt);
     cipher->get_ctr_cipher_stream(k_s, n_s, iv);
+    memset(master_salt, 0, master_salt_length);
 
-    // as last step prepare AES cipher with derived key.
+    // as last step prepare ciphers with derived key.
     cipher->setNewKey(k_e, n_e);
+    if (f8Cipher != NULL)
+        cipher->f8_deriveForIV(f8Cipher, k_e, n_e, k_s, n_s);
+    memset(k_e, 0, n_e);
+
 #endif
 }
 
@@ -493,9 +505,7 @@
 #endif
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/CryptoContextCtrl.cpp b/jni/libccrtp/sources/src/CryptoContextCtrl.cpp
new file mode 100644
index 0000000..5eb3405
--- /dev/null
+++ b/jni/libccrtp/sources/src/CryptoContextCtrl.cpp
@@ -0,0 +1,455 @@
+/*
+  Copyright (C) 2004-2006 the Minisip Team
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library 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
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+*/
+
+/* Copyright (C) 2004-2012
+ *
+ * Authors: Israel Abad <i_abad@terra.es>
+ *          Erik Eliasson <eliasson@it.kth.se>
+ *          Johan Bilien <jobi@via.ecp.fr>
+ *          Joachim Orrblad <joachim@orrblad.com>
+ *          Werner Dittmann <Werner.Dittmann@t-online.de>
+ */
+
+#include <iostream>
+
+#include <ccrtp-config.h>
+
+#ifdef SRTP_SUPPORT
+#include <ccrtp/crypto/hmac.h>
+#include <ccrtp/crypto/macSkein.h>
+#endif
+
+#include <commoncpp/config.h>
+#include <commoncpp/export.h>
+#include <ccrtp/CryptoContextCtrl.h>
+#include <ccrtp/base.h>
+
+NAMESPACE_COMMONCPP
+
+CryptoContextCtrl::CryptoContextCtrl(uint32 ssrc ):
+ssrcCtx(ssrc),
+using_mki(false),mkiLength(0),mki(NULL), s_l(0),
+replay_window(0),
+master_key(NULL), master_key_length(0),
+master_salt(NULL), master_salt_length(0),
+n_e(0),k_e(NULL),n_a(0),k_a(NULL),n_s(0),k_s(NULL),
+ealg(SrtpEncryptionNull), aalg(SrtpAuthenticationNull),
+ekeyl(0), akeyl(0), skeyl(0),
+macCtx(NULL), cipher(NULL), f8Cipher(NULL)
+{}
+
+#ifdef SRTP_SUPPORT
+CryptoContextCtrl::CryptoContextCtrl(uint32 ssrc,
+                                const int32 ealg,
+                                const int32 aalg,
+                                uint8* master_key,
+                                int32 master_key_length,
+                                uint8* master_salt,
+                                int32 master_salt_length,
+                                int32 ekeyl,
+                                int32 akeyl,
+                                int32 skeyl,
+                                int32 tagLength):
+
+ssrcCtx(ssrc),using_mki(false),mkiLength(0),mki(NULL),
+replay_window(0), macCtx(NULL), cipher(NULL), f8Cipher(NULL)
+{
+    this->ealg = ealg;
+    this->aalg = aalg;
+    this->ekeyl = ekeyl;
+    this->akeyl = akeyl;
+    this->skeyl = skeyl;
+
+    this->master_key_length = master_key_length;
+    this->master_key = new uint8[master_key_length];
+    memcpy(this->master_key, master_key, master_key_length);
+
+    this->master_salt_length = master_salt_length;
+    this->master_salt = new uint8[master_salt_length];
+    memcpy(this->master_salt, master_salt, master_salt_length);
+
+    switch( ealg ) {
+        case SrtpEncryptionNull:
+            n_e = 0;
+            k_e = NULL;
+            n_s = 0;
+            k_s = NULL;
+            break;
+
+        case SrtpEncryptionTWOF8:
+            f8Cipher = new SrtpSymCrypto(SrtpEncryptionTWOF8);
+            // fall through
+
+        case SrtpEncryptionTWOCM:
+            n_e = ekeyl;
+            k_e = new uint8[n_e];
+            n_s = skeyl;
+            k_s = new uint8[n_s];
+            cipher = new SrtpSymCrypto(SrtpEncryptionTWOCM);
+            break;
+
+        case SrtpEncryptionAESF8:
+            f8Cipher = new SrtpSymCrypto(SrtpEncryptionAESF8);
+            // fall through
+
+        case SrtpEncryptionAESCM:
+            n_e = ekeyl;
+            k_e = new uint8[n_e];
+            n_s = skeyl;
+            k_s = new uint8[n_s];
+            cipher = new SrtpSymCrypto(SrtpEncryptionAESCM);
+            break;
+    }
+
+    switch( aalg ) {
+        case SrtpAuthenticationNull:
+            n_a = 0;
+            k_a = NULL;
+            this->tagLength = 0;
+            break;
+
+        case SrtpAuthenticationSha1Hmac:
+        case SrtpAuthenticationSkeinHmac:
+            n_a = akeyl;
+            k_a = new uint8[n_a];
+            this->tagLength = tagLength;
+            break;
+    }
+}
+
+#endif
+
+CryptoContextCtrl::~CryptoContextCtrl(){
+
+#ifdef SRTP_SUPPORT
+    if (mki)
+        delete [] mki;
+
+    if (master_key_length > 0) {
+        memset(master_key, 0, master_key_length);
+        master_key_length = 0;
+        delete [] master_key;
+    }
+    if (master_salt_length > 0) {
+        memset(master_salt, 0, master_salt_length);
+        master_salt_length = 0;
+        delete [] master_salt;
+    }
+    if (n_e > 0) {
+        memset(k_e, 0, n_e);
+        n_e = 0;
+        delete [] k_e;
+    }
+    if (n_s > 0) {
+        memset(k_s, 0, n_s);
+        n_s = 0;
+        delete [] k_s;
+    }
+    if (n_a > 0) {
+        memset(k_a, 0, n_a);
+        n_a = 0;
+        delete [] k_a;
+    }
+    if (cipher != NULL) {
+        delete cipher;
+        cipher = NULL;
+    }
+    if (f8Cipher != NULL) {
+        delete f8Cipher;
+        f8Cipher = NULL;
+    }
+    if (macCtx != NULL) {
+        switch(aalg) {
+            case SrtpAuthenticationSha1Hmac:
+                freeSha1HmacContext(macCtx);
+                break;
+
+            case SrtpAuthenticationSkeinHmac:
+                freeSkeinMacContext(macCtx);
+                break;
+        }
+    }
+#endif
+
+    ealg = SrtpEncryptionNull;
+    aalg = SrtpAuthenticationNull;
+}
+
+void CryptoContextCtrl::srtcpEncrypt( uint8* rtp, size_t len, uint64 index, uint32 ssrc )
+{
+    if (ealg == SrtpEncryptionNull) {
+        return;
+    }
+#ifdef SRTP_SUPPORT
+    if (ealg == SrtpEncryptionAESCM || ealg == SrtpEncryptionTWOCM) {
+
+        /* Compute the CM IV (refer to chapter 4.1.1 in RFC 3711):
+        *
+        * k_s   XX XX XX XX XX XX XX XX XX XX XX XX XX XX
+        * SSRC              XX XX XX XX
+        * index                               XX XX XX XX
+        * ------------------------------------------------------XOR
+        * IV    XX XX XX XX XX XX XX XX XX XX XX XX XX XX 00 00
+        *        0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
+        */
+        unsigned char iv[16];
+
+        iv[0] = k_s[0];
+        iv[1] = k_s[1];
+        iv[2] = k_s[2];
+        iv[3] = k_s[3];
+
+        // The shifts transform the ssrc and index into network order
+        iv[4] = ((ssrc >> 24) & 0xff) ^ k_s[4];
+        iv[5] = ((ssrc >> 16) & 0xff) ^ k_s[5];
+        iv[6] = ((ssrc >> 8) & 0xff) ^ k_s[6];
+        iv[7] = (ssrc & 0xff) ^ k_s[7];
+
+        iv[8] = k_s[8];
+        iv[9] = k_s[9];
+
+        iv[10] = ((index >> 24) & 0xff) ^ k_s[10];
+        iv[11] = ((index >> 16) & 0xff) ^ k_s[11];
+        iv[12] = ((index >> 8) & 0xff) ^ k_s[12];
+        iv[13] = (index & 0xff) ^ k_s[13];
+
+        iv[14] = iv[15] = 0;
+
+        cipher->ctr_encrypt(rtp, len, iv);
+    }
+
+    if (ealg == SrtpEncryptionAESF8 || ealg == SrtpEncryptionTWOF8) {
+
+        unsigned char iv[16];
+
+        // 4 bytes of the iv are zero
+        // the first byte of the RTP header is not used.
+        iv[0] = 0;
+        iv[1] = 0;
+        iv[2] = 0;
+        iv[3] = 0;
+
+        // Need the encryption flag
+        index = index | 0x80000000;
+
+        // set the index and the encrypt flag in network order into IV
+        iv[4] = index >> 24;
+        iv[5] = index >> 16;
+        iv[6] = index >> 8;
+        iv[7] = index;
+
+        // The fixed header follows and fills the rest of the IV
+        memcpy(iv+8, rtp, 8);
+
+        cipher->f8_encrypt(rtp, len, iv, f8Cipher);
+    }
+#endif
+}
+
+/* Warning: tag must have been initialized */
+void CryptoContextCtrl::srtcpAuthenticate(uint8* rtp, size_t len, uint32 index, uint8* tag )
+{
+    if (aalg == SrtpAuthenticationNull) {
+        return;
+    }
+#ifdef SRTP_SUPPORT
+    int32_t macL;
+
+    unsigned char temp[20];
+    const unsigned char* chunks[3];
+    unsigned int chunkLength[3];
+    uint32_t beIndex = htonl(index);
+
+    chunks[0] = rtp;
+    chunkLength[0] = len;
+
+    chunks[1] = (unsigned char *)&beIndex;
+    chunkLength[1] = 4;
+    chunks[2] = NULL;
+
+    switch (aalg) {
+    case SrtpAuthenticationSha1Hmac:
+        hmacSha1Ctx(macCtx,
+                    chunks,           // data chunks to hash
+                    chunkLength,      // length of the data to hash
+                    temp, &macL);
+        /* truncate the result */
+        memcpy(tag, temp, getTagLength());
+        break;
+    case SrtpAuthenticationSkeinHmac:
+        macSkeinCtx(macCtx,
+                    chunks,           // data chunks to hash
+                    chunkLength,      // length of the data to hash
+                    temp);
+        /* truncate the result */
+        memcpy(tag, temp, getTagLength());
+        break;
+    }
+#endif
+}
+
+#ifdef SRTP_SUPPORT
+/* used by the key derivation method */
+static void computeIv(unsigned char* iv, uint8 label, uint8* master_salt)
+{
+    //printf( "Key_ID: %llx\n", key_id );
+
+    /* compute the IV
+       key_id:                           XX XX XX XX XX XX XX
+       master_salt: XX XX XX XX XX XX XX XX XX XX XX XX XX XX
+       ------------------------------------------------------------ XOR
+       IV:          XX XX XX XX XX XX XX XX XX XX XX XX XX XX 00 00
+    */
+
+    memcpy(iv, master_salt, 14);
+    iv[7] ^= label;
+
+    iv[14] = iv[15] = 0;
+}
+#endif
+
+/* Derives the srtp session keys from the master key */
+void CryptoContextCtrl::deriveSrtcpKeys()
+{
+#ifdef SRTP_SUPPORT
+    uint8 iv[16];
+
+    // prepare AES cipher to compute derived keys.
+    cipher->setNewKey(master_key, master_key_length);
+    memset(master_key, 0, master_key_length);
+
+    // compute the session encryption key
+    uint8 label = 3;
+    computeIv(iv, label, master_salt);
+    cipher->get_ctr_cipher_stream(k_e, n_e, iv);
+
+    // compute the session authentication key
+    label = 4;
+    computeIv(iv, label, master_salt);
+    cipher->get_ctr_cipher_stream(k_a, n_a, iv);
+
+    // Initialize MAC context with the derived key
+    switch (aalg) {
+    case SrtpAuthenticationSha1Hmac:
+        macCtx = createSha1HmacContext(k_a, n_a);
+        break;
+    case SrtpAuthenticationSkeinHmac:
+        // Skein MAC uses number of bits as MAC size, not just bytes
+        macCtx = createSkeinMacContext(k_a, n_a, tagLength*8, Skein512);
+        break;
+    }
+    memset(k_a, 0, n_a);
+
+    // compute the session salt
+    label = 5;
+    computeIv(iv, label, master_salt);
+    cipher->get_ctr_cipher_stream(k_s, n_s, iv);
+    memset(master_salt, 0, master_salt_length);
+
+    // as last step prepare ciphers with derived key.
+    cipher->setNewKey(k_e, n_e);
+    if (f8Cipher != NULL)
+        cipher->f8_deriveForIV(f8Cipher, k_e, n_e, k_s, n_s);
+    memset(k_e, 0, n_e);
+#endif
+}
+
+bool CryptoContextCtrl::checkReplay( uint32 index )
+{
+#ifdef SRTP_SUPPORT
+    if ( aalg == SrtpAuthenticationNull && ealg == SrtpEncryptionNull ) {
+        /* No security policy, don't use the replay protection */
+        return true;
+    }
+
+    int64 delta = s_l - index;
+    if (delta > 0) {
+        /* Packet not yet received*/
+        return true;
+    }
+    else {
+        if( -delta > REPLAY_WINDOW_SIZE ) {
+            /* Packet too old */
+            return false;
+        }
+        else {
+            if((replay_window >> (-delta)) & 0x1) {
+                /* Packet already received ! */
+                return false;
+        }
+        else {
+            /* Packet not yet received */
+            return true;
+        }
+    }
+}
+#else
+    return true;
+#endif
+}
+
+void CryptoContextCtrl::update(uint32 index)
+{
+#ifdef SRTP_SUPPORT
+    int64 delta = index - s_l;
+
+    /* update the replay bitmask */
+    if( delta > 0 ){
+        replay_window = replay_window << delta;
+        replay_window |= 1;
+    }
+    else {
+        replay_window |= ( 1 << delta );
+    }
+    s_l = index;
+
+#endif
+}
+
+CryptoContextCtrl* CryptoContextCtrl::newCryptoContextForSSRC(uint32 ssrc)
+{
+#ifdef SRTP_SUPPORT
+    CryptoContextCtrl* pcc = new CryptoContextCtrl(
+            ssrc,
+            this->ealg,                              // encryption algo
+            this->aalg,                              // authentication algo
+            this->master_key,                        // Master Key
+            this->master_key_length,                 // Master Key length
+            this->master_salt,                       // Master Salt
+            this->master_salt_length,                // Master Salt length
+            this->ekeyl,                             // encryption keyl
+            this->akeyl,                             // authentication key len
+            this->skeyl,                             // session salt len
+            this->tagLength);                        // authentication tag len
+
+    return pcc;
+#else
+    return NULL;
+#endif
+}
+
+END_NAMESPACE
+
+/** EMACS **
+ * Local variables:
+ * mode: c++
+ * c-default-style: ellemtel
+ * c-basic-offset: 4
+ * End:
+ */
+
diff --git a/jni/libccrtp/sources/src/Makefile b/jni/libccrtp/sources/src/Makefile
index d193330..986ca55 100644
--- a/jni/libccrtp/sources/src/Makefile
+++ b/jni/libccrtp/sources/src/Makefile
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
 # src/Makefile.  Generated from Makefile.in by configure.
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -28,6 +27,51 @@
 
 
 
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/ccrtp
 pkgincludedir = $(includedir)/ccrtp
 pkglibdir = $(libdir)/ccrtp
@@ -45,11 +89,11 @@
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = x86_64-unknown-linux-gnu
-host_triplet = arm-unknown-linux-androideabi
-target_triplet = arm-unknown-linux-androideabi
+host_triplet = x86_64-unknown-linux-gnu
+target_triplet = x86_64-unknown-linux-gnu
 subdir = src
-DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(srcdir)/config.h.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(noinst_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libgcrypt_local.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -60,7 +104,7 @@
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = config.h
+CONFIG_HEADER = $(top_builddir)/ccrtp-config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -84,68 +128,134 @@
 am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
 am__installdirs = "$(DESTDIR)$(libdir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
-libccrtp1_la_LIBADD =
-am__libccrtp1_la_SOURCES_DIST = rtppkt.cpp rtcppkt.cpp source.cpp \
+libccrtp_la_LIBADD =
+am__libccrtp_la_SOURCES_DIST = rtppkt.cpp rtcppkt.cpp source.cpp \
 	data.cpp incqueue.cpp outqueue.cpp queue.cpp control.cpp \
-	members.cpp socket.cpp duplex.cpp pool.cpp CryptoContext.cxx \
-	ccrtp/crypto/gcrypt/gcrypthmac.cxx \
-	ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx \
-	ccrtp/crypto/gcrypt/InitializeGcrypt.cxx \
-	ccrtp/crypto/openssl/hmac.cpp ccrtp/crypto/openssl/AesSrtp.cxx \
-	ccrtp/crypto/openssl/InitializeOpenSSL.cxx \
+	members.cpp socket.cpp duplex.cpp pool.cpp CryptoContext.cpp \
+	CryptoContextCtrl.cpp ccrtp/crypto/gcrypt/gcrypthmac.cpp \
+	ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp \
+	ccrtp/crypto/gcrypt/InitializeGcrypt.cpp \
+	ccrtp/crypto/twofish.c ccrtp/crypto/openssl/hmac.cpp \
+	ccrtp/crypto/openssl/SrtpSymCrypto.cpp \
 	ccrtp/crypto/macSkein.cpp ccrtp/crypto/skein.c \
 	ccrtp/crypto/skein_block.c ccrtp/crypto/skeinApi.c
-#am__objects_1 = gcrypthmac.lo gcryptAesSrtp.lo \
-#	InitializeGcrypt.lo
-#am__objects_2 = hmac.lo AesSrtp.lo \
-#	InitializeOpenSSL.lo
+am__objects_1 = gcrypthmac.lo gcryptSrtpSymCrypto.lo \
+	InitializeGcrypt.lo twofish.lo
+#am__objects_2 = hmac.lo SrtpSymCrypto.lo
 am__objects_3 = macSkein.lo skein.lo skein_block.lo skeinApi.lo
-am_libccrtp1_la_OBJECTS = rtppkt.lo rtcppkt.lo source.lo data.lo \
+am_libccrtp_la_OBJECTS = rtppkt.lo rtcppkt.lo source.lo data.lo \
 	incqueue.lo outqueue.lo queue.lo control.lo members.lo \
-	socket.lo duplex.lo pool.lo CryptoContext.lo $(am__objects_1) \
-	$(am__objects_2) $(am__objects_3)
-libccrtp1_la_OBJECTS = $(am_libccrtp1_la_OBJECTS)
-libccrtp1_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	socket.lo duplex.lo pool.lo CryptoContext.lo \
+	CryptoContextCtrl.lo $(am__objects_1) $(am__objects_2) \
+	$(am__objects_3)
+libccrtp_la_OBJECTS = $(am_libccrtp_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+libccrtp_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-	$(CXXFLAGS) $(libccrtp1_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I.
+	$(CXXFLAGS) $(libccrtp_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I. -I$(top_builddir)
 depcomp =
 am__depfiles_maybe =
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
-SOURCES = $(libccrtp1_la_SOURCES)
-DIST_SOURCES = $(am__libccrtp1_la_SOURCES_DIST)
-RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
-	html-recursive info-recursive install-data-recursive \
-	install-dvi-recursive install-exec-recursive \
-	install-html-recursive install-info-recursive \
-	install-pdf-recursive install-ps-recursive install-recursive \
-	installcheck-recursive installdirs-recursive pdf-recursive \
-	ps-recursive uninstall-recursive
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
+SOURCES = $(libccrtp_la_SOURCES)
+DIST_SOURCES = $(am__libccrtp_la_SOURCES_DIST)
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+	ctags-recursive dvi-recursive html-recursive info-recursive \
+	install-data-recursive install-dvi-recursive \
+	install-exec-recursive install-html-recursive \
+	install-info-recursive install-pdf-recursive \
+	install-ps-recursive install-recursive installcheck-recursive \
+	installdirs-recursive pdf-recursive ps-recursive \
+	tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 HEADERS = $(noinst_HEADERS)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
-AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
-	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+am__recursive_targets = \
+  $(RECURSIVE_TARGETS) \
+  $(RECURSIVE_CLEAN_TARGETS) \
+  $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
 	distdir
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
@@ -175,71 +285,71 @@
     dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
   done; \
   reldir="$$dir2"
-ACLOCAL = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run aclocal-1.11
-AMTAR = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run tar
-AR = arm-linux-androideabi-ar
-AUTOCONF = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run automake-1.11
+ACLOCAL = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing aclocal-1.13
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 1
+AR = ar
+AUTOCONF = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing autoconf
+AUTOHEADER = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing autoheader
+AUTOMAKE = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing automake-1.13
 AWK = gawk
-CC = arm-linux-androideabi-gcc
+CC = gcc
 CCDEPMODE = depmode=none
 CFLAGS = -g -O2
-COMMON_CFLAGS = -D_GNU_SOURCE  
-COMMON_LIBS = -pthread -lccgnu2 -ldl -lrt  
-CPP = arm-linux-androideabi-gcc -E
+COMMONCPP_CFLAGS = -Wno-long-long -fexceptions -DNEW_STDCPP -pthread -fno-check-new -finline -fvisibility=hidden -DUCOMMON_VISIBILITY=1 
+COMMONCPP_LIBS = -lcommoncpp -lucommon -lrt -ldl -lpthread 
+CPP = gcc -E
 CPPFLAGS = 
-CXX = arm-linux-androideabi-g++
-CXXCPP = arm-linux-androideabi-g++ -E
+CXX = g++
+CXXCPP = g++ -E
 CXXDEPMODE = depmode=none
-CXXFLAGS = -g -O2 -D_GNU_SOURCE  
+CXXFLAGS = -g -O2 -Wno-long-long -fexceptions -DNEW_STDCPP -pthread -fno-check-new -finline -fvisibility=hidden -DUCOMMON_VISIBILITY=1 
 CYGPATH_W = echo
 DEFS = -DHAVE_CONFIG_H
 DEPDIR = .deps
 DLLTOOL = false
-DOXYGEN = no
+DOXYGEN = /usr/bin/doxygen
 DSYMUTIL = 
 DUMPBIN = 
 ECHO_C = 
 ECHO_N = -n
 ECHO_T = 
-EGREP = /bin/grep -E
+EGREP = /usr/bin/grep -E
 EXEEXT = 
-FGREP = /bin/grep -F
+FGREP = /usr/bin/grep -F
 FTPDIR = 
-GNULIBS = -L/usr/lib -pthread -lccgnu2 -ldl -lrt   
-GREP = /bin/grep
+GNULIBS = -lcommoncpp -lucommon -lrt -ldl -lpthread  -lgcrypt -ldl -lgpg-error 
+GREP = /usr/bin/grep
 INSTALL = /usr/bin/install -c
 INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
 KDOC_DIR = $(top_srcdir)/doc
-LD = /home/evigier/android-14b-toolchain/arm-linux-androideabi/bin/ld
+LD = /usr/bin/ld -m elf_x86_64
 LDFLAGS = 
 LIBGCRYPT_CFLAGS = 
-LIBGCRYPT_CONFIG = 
-LIBGCRYPT_LIBS = 
+LIBGCRYPT_CONFIG = /usr/bin/libgcrypt-config
+LIBGCRYPT_LIBS = -lgcrypt -ldl -lgpg-error
 LIBOBJS = 
-LIBS = -L/usr/lib -pthread -lccgnu2 -ldl -lrt   
+LIBS = -lgcrypt -ldl -lgpg-error 
 LIBTOOL = $(SHELL) $(top_builddir)/libtool
-LIB_MAJOR = 0
-LIB_VERSION = 1_8
 LIPO = 
 LN_S = ln -s
 LTLIBOBJS = 
-LT_CCXX_VERSION = -version-info 0:0
-LT_MAJOR = 0
+LT_CCXX_VERSION = -version-info 2:2:0
+LT_MAJOR = 2
 LT_MINOR = 0
-LT_RELEASE = 1.8
-LT_SUBVER = 0.0
+LT_RELEASE = 
+LT_SUBVER = 2.0
+LT_VERSION = 2:2:0
 MAINT = #
-MAKEINFO = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing makeinfo
 MANIFEST_TOOL = :
-MKDIR_P = /bin/mkdir -p
-NM = /home/evigier/android-14b-toolchain/bin/arm-linux-androideabi-nm -B
+MKDIR_P = /usr/bin/mkdir -p
+NM = /usr/bin/nm -B
 NMEDIT = 
-OBJDUMP = arm-linux-androideabi-objdump
+OBJDUMP = objdump
 OBJEXT = o
 OTOOL = 
 OTOOL64 = 
@@ -253,27 +363,27 @@
 PATH_SEPARATOR = :
 PKG_CONFIG = /usr/bin/pkg-config
 PKG_CONFIG_LIBDIR = 
-PKG_CONFIG_PATH = /home/evigier/android-ndk-r8b/platforms/android-14/arch-arm/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
-RANLIB = arm-linux-androideabi-ranlib
-SED = /bin/sed
+PKG_CONFIG_PATH = /usr/local/lib/pkgconfig
+RANLIB = ranlib
+SED = /usr/bin/sed
 SET_MAKE = 
-SHELL = /bin/bash
-STRIP = arm-linux-androideabi-strip
-VERSION = 1.8.0
+SHELL = /bin/sh
+STRIP = strip
+VERSION = 2.0.4
 WARN_FLAGS = -fno-strict-aliasing -Wall -ansi -pedantic
-abs_builddir = /home/evigier/git/ccrtp-1.8.0-android/src
-abs_srcdir = /home/evigier/git/ccrtp-1.8.0-android/src
-abs_top_builddir = /home/evigier/git/ccrtp-1.8.0-android
-abs_top_srcdir = /home/evigier/git/ccrtp-1.8.0-android
-ac_ct_AR = 
-ac_ct_CC = 
-ac_ct_CXX = 
+abs_builddir = /home/lisional/git/sflphone-android/jni/libccrtp/sources/src
+abs_srcdir = /home/lisional/git/sflphone-android/jni/libccrtp/sources/src
+abs_top_builddir = /home/lisional/git/sflphone-android/jni/libccrtp/sources
+abs_top_srcdir = /home/lisional/git/sflphone-android/jni/libccrtp/sources
+ac_ct_AR = ar
+ac_ct_CC = gcc
+ac_ct_CXX = g++
 ac_ct_DUMPBIN = 
 am__include = include
 am__leading_dot = .
 am__quote = 
-am__tar = ${AMTAR} chof - "$$tardir"
-am__untar = ${AMTAR} xf -
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
 bindir = ${exec_prefix}/bin
 build = x86_64-unknown-linux-gnu
 build_alias = 
@@ -286,51 +396,53 @@
 docdir = ${datarootdir}/doc/${PACKAGE}
 dvidir = ${docdir}
 exec_prefix = ${prefix}
-host = arm-unknown-linux-androideabi
-host_alias = arm-linux-androideabi
-host_cpu = arm
-host_os = linux-androideabi
+host = x86_64-unknown-linux-gnu
+host_alias = 
+host_cpu = x86_64
+host_os = linux-gnu
 host_vendor = unknown
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/install-sh
+install_sh = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale
 localstatedir = ${prefix}/var
 mandir = ${datarootdir}/man
-mkdir_p = /bin/mkdir -p
+mkdir_p = $(MKDIR_P)
 oldincludedir = /usr/include
 pdfdir = ${docdir}
-prefix = /home/evigier/android-ndk-r8b/platforms/android-14/arch-arm/usr
+prefix = /usr/local
 program_transform_name = s,x,x,
 psdir = ${docdir}
 sbindir = ${exec_prefix}/sbin
 sharedstatedir = ${prefix}/com
 srcdir = .
 sysconfdir = ${prefix}/etc
-target = arm-unknown-linux-androideabi
+target = x86_64-unknown-linux-gnu
 target_alias = 
-target_cpu = arm
-target_os = linux-androideabi
+target_cpu = x86_64
+target_os = linux-gnu
 target_vendor = unknown
 top_build_prefix = ../
 top_builddir = ..
 top_srcdir = ..
 AUTOMAKE_OPTIONS = no-dependencies dist-shar
-LT_VERSION = -version-info 0:0
-AM_CXXFLAGS = -fno-strict-aliasing -Wall -ansi -pedantic
-# RELEASE = $(LT_VERSION) -release $(LT_RELEASE)
-RELEASE = $(LT_VERSION) -release $(LT_RELEASE) -L/usr/lib -pthread -lccgnu2 -ldl -lrt   
-lib_LTLIBRARIES = libccrtp1.la
-#srtp_src_o = ccrtp/crypto/openssl/hmac.cpp \
-#		ccrtp/crypto/openssl/AesSrtp.cxx \
-#		ccrtp/crypto/openssl/InitializeOpenSSL.cxx
 
-#srtp_src_g = ccrtp/crypto/gcrypt/gcrypthmac.cxx \
-#		ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx \
-#		ccrtp/crypto/gcrypt/InitializeGcrypt.cxx
+# additional include path necessary to compile the srtp crypto sources
+AM_CXXFLAGS = -fno-strict-aliasing -Wall -ansi -pedantic -I$(top_srcdir)/src/ccrtp
+AM_CPPFLAGS = -fno-strict-aliasing -Wall -ansi -pedantic -I$(top_srcdir)/src/ccrtp
+
+# RELEASE = $(LT_VERSION) -release $(LT_RELEASE)
+RELEASE = --version-info $(LT_VERSION)
+lib_LTLIBRARIES = libccrtp.la
+#srtp_src_o = ccrtp/crypto/openssl/hmac.cpp \
+#        ccrtp/crypto/openssl/SrtpSymCrypto.cpp
+
+srtp_src_g = ccrtp/crypto/gcrypt/gcrypthmac.cpp \
+        ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp \
+        ccrtp/crypto/gcrypt/InitializeGcrypt.cpp ccrtp/crypto/twofish.c
 
 skein_srcs = ccrtp/crypto/macSkein.cpp \
         ccrtp/crypto/skein.c \
@@ -338,17 +450,16 @@
         ccrtp/crypto/skeinApi.c
 
 SUBDIRS = ccrtp ccrtp/crypto
-libccrtp1_la_SOURCES = rtppkt.cpp rtcppkt.cpp source.cpp data.cpp incqueue.cpp \
-	outqueue.cpp queue.cpp control.cpp members.cpp socket.cpp duplex.cpp pool.cpp \
-	CryptoContext.cxx $(srtp_src_g) $(srtp_src_o) $(skein_srcs)
+libccrtp_la_SOURCES = rtppkt.cpp rtcppkt.cpp source.cpp data.cpp incqueue.cpp \
+    outqueue.cpp queue.cpp control.cpp members.cpp socket.cpp duplex.cpp pool.cpp \
+    CryptoContext.cpp CryptoContextCtrl.cpp $(srtp_src_g) $(srtp_src_o) $(skein_srcs)
 
-libccrtp1_la_LDFLAGS = $(RELEASE)
+libccrtp_la_LDFLAGS = $(RELEASE) -lcommoncpp -lucommon -lrt -ldl -lpthread  -lgcrypt -ldl -lgpg-error 
 noinst_HEADERS = private.h
-all: config.h
-	$(MAKE) $(AM_MAKEFLAGS) all-recursive
+all: all-recursive
 
 .SUFFIXES:
-.SUFFIXES: .c .cpp .cxx .lo .o .obj
+.SUFFIXES: .c .cpp .lo .o .obj
 $(srcdir)/Makefile.in: # $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
@@ -380,25 +491,8 @@
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
-config.h: stamp-h1
-	@if test ! -f $@; then \
-	  rm -f stamp-h1; \
-	  $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
-	else :; fi
-
-stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
-	@rm -f stamp-h1
-	cd $(top_builddir) && $(SHELL) ./config.status src/config.h
-$(srcdir)/config.h.in: # $(am__configure_deps) 
-	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
-	rm -f stamp-h1
-	touch $@
-
-distclean-hdr:
-	-rm -f config.h stamp-h1
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
-	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
 	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
 	list2=; for p in $$list; do \
 	  if test -f $$p; then \
@@ -406,6 +500,8 @@
 	  else :; fi; \
 	done; \
 	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
 	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
 	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
 	}
@@ -421,14 +517,17 @@
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-	  test "$$dir" != "$$p" || dir=.; \
-	  echo "rm -f \"$${dir}/so_locations\""; \
-	  rm -f "$${dir}/so_locations"; \
-	done
-libccrtp1.la: $(libccrtp1_la_OBJECTS) $(libccrtp1_la_DEPENDENCIES) 
-	$(libccrtp1_la_LINK) -rpath $(libdir) $(libccrtp1_la_OBJECTS) $(libccrtp1_la_LIBADD) $(LIBS)
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
+libccrtp.la: $(libccrtp_la_OBJECTS) $(libccrtp_la_DEPENDENCIES) $(EXTRA_libccrtp_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libccrtp_la_LINK) -rpath $(libdir) $(libccrtp_la_OBJECTS) $(libccrtp_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -437,61 +536,52 @@
 	-rm -f *.tab.c
 
 .c.o:
-	$(COMPILE) -c $<
+	$(AM_V_CC)$(COMPILE) -c $<
 
 .c.obj:
-	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+	$(AM_V_CC)$(COMPILE) -c `$(CYGPATH_W) '$<'`
 
 .c.lo:
-	$(LTCOMPILE) -c -o $@ $<
+	$(AM_V_CC)$(LTCOMPILE) -c -o $@ $<
+
+twofish.lo: ccrtp/crypto/twofish.c
+	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o twofish.lo `test -f 'ccrtp/crypto/twofish.c' || echo '$(srcdir)/'`ccrtp/crypto/twofish.c
 
 skein.lo: ccrtp/crypto/skein.c
-	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skein.lo `test -f 'ccrtp/crypto/skein.c' || echo '$(srcdir)/'`ccrtp/crypto/skein.c
+	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skein.lo `test -f 'ccrtp/crypto/skein.c' || echo '$(srcdir)/'`ccrtp/crypto/skein.c
 
 skein_block.lo: ccrtp/crypto/skein_block.c
-	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skein_block.lo `test -f 'ccrtp/crypto/skein_block.c' || echo '$(srcdir)/'`ccrtp/crypto/skein_block.c
+	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skein_block.lo `test -f 'ccrtp/crypto/skein_block.c' || echo '$(srcdir)/'`ccrtp/crypto/skein_block.c
 
 skeinApi.lo: ccrtp/crypto/skeinApi.c
-	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skeinApi.lo `test -f 'ccrtp/crypto/skeinApi.c' || echo '$(srcdir)/'`ccrtp/crypto/skeinApi.c
+	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skeinApi.lo `test -f 'ccrtp/crypto/skeinApi.c' || echo '$(srcdir)/'`ccrtp/crypto/skeinApi.c
 
 .cpp.o:
-	$(CXXCOMPILE) -c -o $@ $<
+	$(AM_V_CXX)$(CXXCOMPILE) -c -o $@ $<
 
 .cpp.obj:
-	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+	$(AM_V_CXX)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cpp.lo:
-	$(LTCXXCOMPILE) -c -o $@ $<
+	$(AM_V_CXX)$(LTCXXCOMPILE) -c -o $@ $<
 
-gcrypthmac.lo: ccrtp/crypto/gcrypt/gcrypthmac.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gcrypthmac.lo `test -f 'ccrtp/crypto/gcrypt/gcrypthmac.cxx' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/gcrypthmac.cxx
+gcrypthmac.lo: ccrtp/crypto/gcrypt/gcrypthmac.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gcrypthmac.lo `test -f 'ccrtp/crypto/gcrypt/gcrypthmac.cpp' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/gcrypthmac.cpp
 
-gcryptAesSrtp.lo: ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gcryptAesSrtp.lo `test -f 'ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx
+gcryptSrtpSymCrypto.lo: ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gcryptSrtpSymCrypto.lo `test -f 'ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp
 
-InitializeGcrypt.lo: ccrtp/crypto/gcrypt/InitializeGcrypt.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o InitializeGcrypt.lo `test -f 'ccrtp/crypto/gcrypt/InitializeGcrypt.cxx' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/InitializeGcrypt.cxx
+InitializeGcrypt.lo: ccrtp/crypto/gcrypt/InitializeGcrypt.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o InitializeGcrypt.lo `test -f 'ccrtp/crypto/gcrypt/InitializeGcrypt.cpp' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/InitializeGcrypt.cpp
 
 hmac.lo: ccrtp/crypto/openssl/hmac.cpp
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hmac.lo `test -f 'ccrtp/crypto/openssl/hmac.cpp' || echo '$(srcdir)/'`ccrtp/crypto/openssl/hmac.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hmac.lo `test -f 'ccrtp/crypto/openssl/hmac.cpp' || echo '$(srcdir)/'`ccrtp/crypto/openssl/hmac.cpp
 
-AesSrtp.lo: ccrtp/crypto/openssl/AesSrtp.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o AesSrtp.lo `test -f 'ccrtp/crypto/openssl/AesSrtp.cxx' || echo '$(srcdir)/'`ccrtp/crypto/openssl/AesSrtp.cxx
-
-InitializeOpenSSL.lo: ccrtp/crypto/openssl/InitializeOpenSSL.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o InitializeOpenSSL.lo `test -f 'ccrtp/crypto/openssl/InitializeOpenSSL.cxx' || echo '$(srcdir)/'`ccrtp/crypto/openssl/InitializeOpenSSL.cxx
+SrtpSymCrypto.lo: ccrtp/crypto/openssl/SrtpSymCrypto.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o SrtpSymCrypto.lo `test -f 'ccrtp/crypto/openssl/SrtpSymCrypto.cpp' || echo '$(srcdir)/'`ccrtp/crypto/openssl/SrtpSymCrypto.cpp
 
 macSkein.lo: ccrtp/crypto/macSkein.cpp
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o macSkein.lo `test -f 'ccrtp/crypto/macSkein.cpp' || echo '$(srcdir)/'`ccrtp/crypto/macSkein.cpp
-
-.cxx.o:
-	$(CXXCOMPILE) -c -o $@ $<
-
-.cxx.obj:
-	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.cxx.lo:
-	$(LTCXXCOMPILE) -c -o $@ $<
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o macSkein.lo `test -f 'ccrtp/crypto/macSkein.cpp' || echo '$(srcdir)/'`ccrtp/crypto/macSkein.cpp
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -500,22 +590,25 @@
 	-rm -rf .libs _libs
 
 # This directory's subdirectories are mostly independent; you can cd
-# into them and run `make' without going through this Makefile.
-# To change the values of `make' variables: instead of editing Makefiles,
-# (1) if the variable is set in `config.status', edit `config.status'
-#     (which will cause the Makefiles to be regenerated when you run `make');
-# (2) otherwise, pass the desired values on the `make' command line.
-$(RECURSIVE_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+#     (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+	@fail=; \
+	if $(am__make_keepgoing); then \
+	  failcom='fail=yes'; \
+	else \
+	  failcom='exit 1'; \
+	fi; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	for subdir in $$list; do \
 	  echo "Making $$target in $$subdir"; \
 	  if test "$$subdir" = "."; then \
 	    dot_seen=yes; \
@@ -530,57 +623,12 @@
 	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
 	fi; test -z "$$fail"
 
-$(RECURSIVE_CLEAN_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	dot_seen=no; \
-	case "$@" in \
-	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
-	  *) list='$(SUBDIRS)' ;; \
-	esac; \
-	rev=''; for subdir in $$list; do \
-	  if test "$$subdir" = "."; then :; else \
-	    rev="$$subdir $$rev"; \
-	  fi; \
-	done; \
-	rev="$$rev ."; \
-	target=`echo $@ | sed s/-recursive//`; \
-	for subdir in $$rev; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
-	done && test -z "$$fail"
-tags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
-	done
-ctags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
-	done
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
@@ -596,12 +644,7 @@
 	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
-	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -613,15 +656,11 @@
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -630,6 +669,21 @@
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -666,13 +720,10 @@
 	done
 	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
-	    test -d "$(distdir)/$$subdir" \
-	    || $(MKDIR_P) "$(distdir)/$$subdir" \
-	    || exit 1; \
-	  fi; \
-	done
-	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-	  if test "$$subdir" = .; then :; else \
+	    $(am__make_dryrun) \
+	      || test -d "$(distdir)/$$subdir" \
+	      || $(MKDIR_P) "$(distdir)/$$subdir" \
+	      || exit 1; \
 	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
 	    $(am__relativize); \
 	    new_distdir=$$reldir; \
@@ -694,7 +745,7 @@
 	done
 check-am: all-am
 check: check-recursive
-all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
 installdirs: installdirs-recursive
 installdirs-am:
 	for dir in "$(DESTDIR)$(libdir)"; do \
@@ -710,10 +761,15 @@
 
 installcheck: installcheck-recursive
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
@@ -733,7 +789,7 @@
 distclean: distclean-recursive
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
-	distclean-hdr distclean-tags
+	distclean-tags
 
 dvi: dvi-recursive
 
@@ -794,24 +850,22 @@
 
 uninstall-am: uninstall-libLTLIBRARIES
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
-	ctags-recursive install-am install-strip tags-recursive
+.MAKE: $(am__recursive_targets) install-am install-strip
 
-.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
-	all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool ctags ctags-recursive \
-	distclean distclean-compile distclean-generic distclean-hdr \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-libLTLIBRARIES install-man install-pdf \
-	install-pdf-am install-ps install-ps-am install-strip \
-	installcheck installcheck-am installdirs installdirs-am \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
-	uninstall-libLTLIBRARIES
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
+	check-am clean clean-generic clean-libLTLIBRARIES \
+	clean-libtool cscopelist-am ctags ctags-am distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am \
+	install-libLTLIBRARIES install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/jni/libccrtp/sources/src/Makefile.am b/jni/libccrtp/sources/src/Makefile.am
index a494fcc..58cf4c1 100644
--- a/jni/libccrtp/sources/src/Makefile.am
+++ b/jni/libccrtp/sources/src/Makefile.am
@@ -10,24 +10,25 @@
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 AUTOMAKE_OPTIONS = no-dependencies dist-shar
-LT_VERSION=@LT_CCXX_VERSION@
-AM_CXXFLAGS= @WARN_FLAGS@
-# RELEASE = $(LT_VERSION) -release $(LT_RELEASE)
-RELEASE = $(LT_VERSION) -release $(LT_RELEASE) @GNULIBS@
-LIBS = @GNULIBS@
 
-lib_LTLIBRARIES = libccrtp1.la
+# additional include path necessary to compile the srtp crypto sources
+AM_CXXFLAGS= @WARN_FLAGS@ -I$(top_srcdir)/src/ccrtp
+AM_CPPFLAGS= @WARN_FLAGS@ -I$(top_srcdir)/src/ccrtp
+
+# RELEASE = $(LT_VERSION) -release $(LT_RELEASE)
+RELEASE = --version-info $(LT_VERSION)
+
+lib_LTLIBRARIES = libccrtp.la
 
 if SRTP_OPENSSL
-srtp_src_o = 	ccrtp/crypto/openssl/hmac.cpp \
-		ccrtp/crypto/openssl/AesSrtp.cxx \
-		ccrtp/crypto/openssl/InitializeOpenSSL.cxx
+srtp_src_o =    ccrtp/crypto/openssl/hmac.cpp \
+        ccrtp/crypto/openssl/SrtpSymCrypto.cpp
 endif
 
 if SRTP_GCRYPT
-srtp_src_g =    ccrtp/crypto/gcrypt/gcrypthmac.cxx \
-		ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx \
-		ccrtp/crypto/gcrypt/InitializeGcrypt.cxx
+srtp_src_g =    ccrtp/crypto/gcrypt/gcrypthmac.cpp \
+        ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp \
+        ccrtp/crypto/gcrypt/InitializeGcrypt.cpp ccrtp/crypto/twofish.c
 endif
 
 skein_srcs= ccrtp/crypto/macSkein.cpp \
@@ -38,10 +39,10 @@
 
 SUBDIRS = ccrtp ccrtp/crypto
 
-libccrtp1_la_SOURCES = rtppkt.cpp rtcppkt.cpp source.cpp data.cpp incqueue.cpp \
-	outqueue.cpp queue.cpp control.cpp members.cpp socket.cpp duplex.cpp pool.cpp \
-	CryptoContext.cxx $(srtp_src_g) $(srtp_src_o) $(skein_srcs)
+libccrtp_la_SOURCES = rtppkt.cpp rtcppkt.cpp source.cpp data.cpp incqueue.cpp \
+    outqueue.cpp queue.cpp control.cpp members.cpp socket.cpp duplex.cpp pool.cpp \
+    CryptoContext.cpp CryptoContextCtrl.cpp $(srtp_src_g) $(srtp_src_o) $(skein_srcs)
 
-libccrtp1_la_LDFLAGS = $(RELEASE)
+libccrtp_la_LDFLAGS = $(RELEASE) @GNULIBS@
 
 noinst_HEADERS = private.h
diff --git a/jni/libccrtp/sources/src/Makefile.in b/jni/libccrtp/sources/src/Makefile.in
index f0d1b00..8c18c2d 100644
--- a/jni/libccrtp/sources/src/Makefile.in
+++ b/jni/libccrtp/sources/src/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -28,6 +27,51 @@
 
 
 VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -48,8 +92,8 @@
 host_triplet = @host@
 target_triplet = @target@
 subdir = src
-DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in $(srcdir)/config.h.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(noinst_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libgcrypt_local.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -60,7 +104,7 @@
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = config.h
+CONFIG_HEADER = $(top_builddir)/ccrtp-config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
@@ -84,68 +128,134 @@
 am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
 am__installdirs = "$(DESTDIR)$(libdir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
-libccrtp1_la_LIBADD =
-am__libccrtp1_la_SOURCES_DIST = rtppkt.cpp rtcppkt.cpp source.cpp \
+libccrtp_la_LIBADD =
+am__libccrtp_la_SOURCES_DIST = rtppkt.cpp rtcppkt.cpp source.cpp \
 	data.cpp incqueue.cpp outqueue.cpp queue.cpp control.cpp \
-	members.cpp socket.cpp duplex.cpp pool.cpp CryptoContext.cxx \
-	ccrtp/crypto/gcrypt/gcrypthmac.cxx \
-	ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx \
-	ccrtp/crypto/gcrypt/InitializeGcrypt.cxx \
-	ccrtp/crypto/openssl/hmac.cpp ccrtp/crypto/openssl/AesSrtp.cxx \
-	ccrtp/crypto/openssl/InitializeOpenSSL.cxx \
+	members.cpp socket.cpp duplex.cpp pool.cpp CryptoContext.cpp \
+	CryptoContextCtrl.cpp ccrtp/crypto/gcrypt/gcrypthmac.cpp \
+	ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp \
+	ccrtp/crypto/gcrypt/InitializeGcrypt.cpp \
+	ccrtp/crypto/twofish.c ccrtp/crypto/openssl/hmac.cpp \
+	ccrtp/crypto/openssl/SrtpSymCrypto.cpp \
 	ccrtp/crypto/macSkein.cpp ccrtp/crypto/skein.c \
 	ccrtp/crypto/skein_block.c ccrtp/crypto/skeinApi.c
-@SRTP_GCRYPT_TRUE@am__objects_1 = gcrypthmac.lo gcryptAesSrtp.lo \
-@SRTP_GCRYPT_TRUE@	InitializeGcrypt.lo
-@SRTP_OPENSSL_TRUE@am__objects_2 = hmac.lo AesSrtp.lo \
-@SRTP_OPENSSL_TRUE@	InitializeOpenSSL.lo
+@SRTP_GCRYPT_TRUE@am__objects_1 = gcrypthmac.lo gcryptSrtpSymCrypto.lo \
+@SRTP_GCRYPT_TRUE@	InitializeGcrypt.lo twofish.lo
+@SRTP_OPENSSL_TRUE@am__objects_2 = hmac.lo SrtpSymCrypto.lo
 am__objects_3 = macSkein.lo skein.lo skein_block.lo skeinApi.lo
-am_libccrtp1_la_OBJECTS = rtppkt.lo rtcppkt.lo source.lo data.lo \
+am_libccrtp_la_OBJECTS = rtppkt.lo rtcppkt.lo source.lo data.lo \
 	incqueue.lo outqueue.lo queue.lo control.lo members.lo \
-	socket.lo duplex.lo pool.lo CryptoContext.lo $(am__objects_1) \
-	$(am__objects_2) $(am__objects_3)
-libccrtp1_la_OBJECTS = $(am_libccrtp1_la_OBJECTS)
-libccrtp1_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	socket.lo duplex.lo pool.lo CryptoContext.lo \
+	CryptoContextCtrl.lo $(am__objects_1) $(am__objects_2) \
+	$(am__objects_3)
+libccrtp_la_OBJECTS = $(am_libccrtp_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+libccrtp_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
-	$(CXXFLAGS) $(libccrtp1_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I.@am__isrc@
+	$(CXXFLAGS) $(libccrtp_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp =
 am__depfiles_maybe =
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
 CCLD = $(CC)
-LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
 	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
-LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
 CXXLD = $(CXX)
-CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
-	--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
-	$(LDFLAGS) -o $@
-SOURCES = $(libccrtp1_la_SOURCES)
-DIST_SOURCES = $(am__libccrtp1_la_SOURCES_DIST)
-RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
-	html-recursive info-recursive install-data-recursive \
-	install-dvi-recursive install-exec-recursive \
-	install-html-recursive install-info-recursive \
-	install-pdf-recursive install-ps-recursive install-recursive \
-	installcheck-recursive installdirs-recursive pdf-recursive \
-	ps-recursive uninstall-recursive
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
+SOURCES = $(libccrtp_la_SOURCES)
+DIST_SOURCES = $(am__libccrtp_la_SOURCES_DIST)
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+	ctags-recursive dvi-recursive html-recursive info-recursive \
+	install-data-recursive install-dvi-recursive \
+	install-exec-recursive install-html-recursive \
+	install-info-recursive install-pdf-recursive \
+	install-ps-recursive install-recursive installcheck-recursive \
+	installdirs-recursive pdf-recursive ps-recursive \
+	tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 HEADERS = $(noinst_HEADERS)
 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
   distclean-recursive maintainer-clean-recursive
-AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
-	$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+am__recursive_targets = \
+  $(RECURSIVE_TARGETS) \
+  $(RECURSIVE_CLEAN_TARGETS) \
+  $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
 	distdir
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = $(SUBDIRS)
@@ -177,6 +287,7 @@
   reldir="$$dir2"
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -185,8 +296,8 @@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMMON_CFLAGS = @COMMON_CFLAGS@
-COMMON_LIBS = @COMMON_LIBS@
+COMMONCPP_CFLAGS = @COMMONCPP_CFLAGS@
+COMMONCPP_LIBS = @COMMONCPP_LIBS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CXX = @CXX@
@@ -221,10 +332,8 @@
 LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
 LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
 LIBOBJS = @LIBOBJS@
-LIBS = @GNULIBS@
+LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
-LIB_MAJOR = @LIB_MAJOR@
-LIB_VERSION = @LIB_VERSION@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
@@ -233,6 +342,7 @@
 LT_MINOR = @LT_MINOR@
 LT_RELEASE = @LT_RELEASE@
 LT_SUBVER = @LT_SUBVER@
+LT_VERSION = @LT_VERSION@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
@@ -319,18 +429,20 @@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = no-dependencies dist-shar
-LT_VERSION = @LT_CCXX_VERSION@
-AM_CXXFLAGS = @WARN_FLAGS@
-# RELEASE = $(LT_VERSION) -release $(LT_RELEASE)
-RELEASE = $(LT_VERSION) -release $(LT_RELEASE) @GNULIBS@
-lib_LTLIBRARIES = libccrtp1.la
-@SRTP_OPENSSL_TRUE@srtp_src_o = ccrtp/crypto/openssl/hmac.cpp \
-@SRTP_OPENSSL_TRUE@		ccrtp/crypto/openssl/AesSrtp.cxx \
-@SRTP_OPENSSL_TRUE@		ccrtp/crypto/openssl/InitializeOpenSSL.cxx
 
-@SRTP_GCRYPT_TRUE@srtp_src_g = ccrtp/crypto/gcrypt/gcrypthmac.cxx \
-@SRTP_GCRYPT_TRUE@		ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx \
-@SRTP_GCRYPT_TRUE@		ccrtp/crypto/gcrypt/InitializeGcrypt.cxx
+# additional include path necessary to compile the srtp crypto sources
+AM_CXXFLAGS = @WARN_FLAGS@ -I$(top_srcdir)/src/ccrtp
+AM_CPPFLAGS = @WARN_FLAGS@ -I$(top_srcdir)/src/ccrtp
+
+# RELEASE = $(LT_VERSION) -release $(LT_RELEASE)
+RELEASE = --version-info $(LT_VERSION)
+lib_LTLIBRARIES = libccrtp.la
+@SRTP_OPENSSL_TRUE@srtp_src_o = ccrtp/crypto/openssl/hmac.cpp \
+@SRTP_OPENSSL_TRUE@        ccrtp/crypto/openssl/SrtpSymCrypto.cpp
+
+@SRTP_GCRYPT_TRUE@srtp_src_g = ccrtp/crypto/gcrypt/gcrypthmac.cpp \
+@SRTP_GCRYPT_TRUE@        ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp \
+@SRTP_GCRYPT_TRUE@        ccrtp/crypto/gcrypt/InitializeGcrypt.cpp ccrtp/crypto/twofish.c
 
 skein_srcs = ccrtp/crypto/macSkein.cpp \
         ccrtp/crypto/skein.c \
@@ -338,17 +450,16 @@
         ccrtp/crypto/skeinApi.c
 
 SUBDIRS = ccrtp ccrtp/crypto
-libccrtp1_la_SOURCES = rtppkt.cpp rtcppkt.cpp source.cpp data.cpp incqueue.cpp \
-	outqueue.cpp queue.cpp control.cpp members.cpp socket.cpp duplex.cpp pool.cpp \
-	CryptoContext.cxx $(srtp_src_g) $(srtp_src_o) $(skein_srcs)
+libccrtp_la_SOURCES = rtppkt.cpp rtcppkt.cpp source.cpp data.cpp incqueue.cpp \
+    outqueue.cpp queue.cpp control.cpp members.cpp socket.cpp duplex.cpp pool.cpp \
+    CryptoContext.cpp CryptoContextCtrl.cpp $(srtp_src_g) $(srtp_src_o) $(skein_srcs)
 
-libccrtp1_la_LDFLAGS = $(RELEASE)
+libccrtp_la_LDFLAGS = $(RELEASE) @GNULIBS@
 noinst_HEADERS = private.h
-all: config.h
-	$(MAKE) $(AM_MAKEFLAGS) all-recursive
+all: all-recursive
 
 .SUFFIXES:
-.SUFFIXES: .c .cpp .cxx .lo .o .obj
+.SUFFIXES: .c .cpp .lo .o .obj
 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
@@ -380,25 +491,8 @@
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
 
-config.h: stamp-h1
-	@if test ! -f $@; then \
-	  rm -f stamp-h1; \
-	  $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
-	else :; fi
-
-stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
-	@rm -f stamp-h1
-	cd $(top_builddir) && $(SHELL) ./config.status src/config.h
-$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
-	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
-	rm -f stamp-h1
-	touch $@
-
-distclean-hdr:
-	-rm -f config.h stamp-h1
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
 	@$(NORMAL_INSTALL)
-	test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
 	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
 	list2=; for p in $$list; do \
 	  if test -f $$p; then \
@@ -406,6 +500,8 @@
 	  else :; fi; \
 	done; \
 	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
 	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
 	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
 	}
@@ -421,14 +517,17 @@
 
 clean-libLTLIBRARIES:
 	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-	  test "$$dir" != "$$p" || dir=.; \
-	  echo "rm -f \"$${dir}/so_locations\""; \
-	  rm -f "$${dir}/so_locations"; \
-	done
-libccrtp1.la: $(libccrtp1_la_OBJECTS) $(libccrtp1_la_DEPENDENCIES) 
-	$(libccrtp1_la_LINK) -rpath $(libdir) $(libccrtp1_la_OBJECTS) $(libccrtp1_la_LIBADD) $(LIBS)
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
+libccrtp.la: $(libccrtp_la_OBJECTS) $(libccrtp_la_DEPENDENCIES) $(EXTRA_libccrtp_la_DEPENDENCIES) 
+	$(AM_V_CXXLD)$(libccrtp_la_LINK) -rpath $(libdir) $(libccrtp_la_OBJECTS) $(libccrtp_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -437,61 +536,52 @@
 	-rm -f *.tab.c
 
 .c.o:
-	$(COMPILE) -c $<
+	$(AM_V_CC)$(COMPILE) -c $<
 
 .c.obj:
-	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+	$(AM_V_CC)$(COMPILE) -c `$(CYGPATH_W) '$<'`
 
 .c.lo:
-	$(LTCOMPILE) -c -o $@ $<
+	$(AM_V_CC)$(LTCOMPILE) -c -o $@ $<
+
+twofish.lo: ccrtp/crypto/twofish.c
+	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o twofish.lo `test -f 'ccrtp/crypto/twofish.c' || echo '$(srcdir)/'`ccrtp/crypto/twofish.c
 
 skein.lo: ccrtp/crypto/skein.c
-	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skein.lo `test -f 'ccrtp/crypto/skein.c' || echo '$(srcdir)/'`ccrtp/crypto/skein.c
+	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skein.lo `test -f 'ccrtp/crypto/skein.c' || echo '$(srcdir)/'`ccrtp/crypto/skein.c
 
 skein_block.lo: ccrtp/crypto/skein_block.c
-	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skein_block.lo `test -f 'ccrtp/crypto/skein_block.c' || echo '$(srcdir)/'`ccrtp/crypto/skein_block.c
+	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skein_block.lo `test -f 'ccrtp/crypto/skein_block.c' || echo '$(srcdir)/'`ccrtp/crypto/skein_block.c
 
 skeinApi.lo: ccrtp/crypto/skeinApi.c
-	$(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skeinApi.lo `test -f 'ccrtp/crypto/skeinApi.c' || echo '$(srcdir)/'`ccrtp/crypto/skeinApi.c
+	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o skeinApi.lo `test -f 'ccrtp/crypto/skeinApi.c' || echo '$(srcdir)/'`ccrtp/crypto/skeinApi.c
 
 .cpp.o:
-	$(CXXCOMPILE) -c -o $@ $<
+	$(AM_V_CXX)$(CXXCOMPILE) -c -o $@ $<
 
 .cpp.obj:
-	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+	$(AM_V_CXX)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .cpp.lo:
-	$(LTCXXCOMPILE) -c -o $@ $<
+	$(AM_V_CXX)$(LTCXXCOMPILE) -c -o $@ $<
 
-gcrypthmac.lo: ccrtp/crypto/gcrypt/gcrypthmac.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gcrypthmac.lo `test -f 'ccrtp/crypto/gcrypt/gcrypthmac.cxx' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/gcrypthmac.cxx
+gcrypthmac.lo: ccrtp/crypto/gcrypt/gcrypthmac.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gcrypthmac.lo `test -f 'ccrtp/crypto/gcrypt/gcrypthmac.cpp' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/gcrypthmac.cpp
 
-gcryptAesSrtp.lo: ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gcryptAesSrtp.lo `test -f 'ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx
+gcryptSrtpSymCrypto.lo: ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o gcryptSrtpSymCrypto.lo `test -f 'ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp
 
-InitializeGcrypt.lo: ccrtp/crypto/gcrypt/InitializeGcrypt.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o InitializeGcrypt.lo `test -f 'ccrtp/crypto/gcrypt/InitializeGcrypt.cxx' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/InitializeGcrypt.cxx
+InitializeGcrypt.lo: ccrtp/crypto/gcrypt/InitializeGcrypt.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o InitializeGcrypt.lo `test -f 'ccrtp/crypto/gcrypt/InitializeGcrypt.cpp' || echo '$(srcdir)/'`ccrtp/crypto/gcrypt/InitializeGcrypt.cpp
 
 hmac.lo: ccrtp/crypto/openssl/hmac.cpp
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hmac.lo `test -f 'ccrtp/crypto/openssl/hmac.cpp' || echo '$(srcdir)/'`ccrtp/crypto/openssl/hmac.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hmac.lo `test -f 'ccrtp/crypto/openssl/hmac.cpp' || echo '$(srcdir)/'`ccrtp/crypto/openssl/hmac.cpp
 
-AesSrtp.lo: ccrtp/crypto/openssl/AesSrtp.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o AesSrtp.lo `test -f 'ccrtp/crypto/openssl/AesSrtp.cxx' || echo '$(srcdir)/'`ccrtp/crypto/openssl/AesSrtp.cxx
-
-InitializeOpenSSL.lo: ccrtp/crypto/openssl/InitializeOpenSSL.cxx
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o InitializeOpenSSL.lo `test -f 'ccrtp/crypto/openssl/InitializeOpenSSL.cxx' || echo '$(srcdir)/'`ccrtp/crypto/openssl/InitializeOpenSSL.cxx
+SrtpSymCrypto.lo: ccrtp/crypto/openssl/SrtpSymCrypto.cpp
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o SrtpSymCrypto.lo `test -f 'ccrtp/crypto/openssl/SrtpSymCrypto.cpp' || echo '$(srcdir)/'`ccrtp/crypto/openssl/SrtpSymCrypto.cpp
 
 macSkein.lo: ccrtp/crypto/macSkein.cpp
-	$(LIBTOOL)  --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o macSkein.lo `test -f 'ccrtp/crypto/macSkein.cpp' || echo '$(srcdir)/'`ccrtp/crypto/macSkein.cpp
-
-.cxx.o:
-	$(CXXCOMPILE) -c -o $@ $<
-
-.cxx.obj:
-	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-.cxx.lo:
-	$(LTCXXCOMPILE) -c -o $@ $<
+	$(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o macSkein.lo `test -f 'ccrtp/crypto/macSkein.cpp' || echo '$(srcdir)/'`ccrtp/crypto/macSkein.cpp
 
 mostlyclean-libtool:
 	-rm -f *.lo
@@ -500,22 +590,25 @@
 	-rm -rf .libs _libs
 
 # This directory's subdirectories are mostly independent; you can cd
-# into them and run `make' without going through this Makefile.
-# To change the values of `make' variables: instead of editing Makefiles,
-# (1) if the variable is set in `config.status', edit `config.status'
-#     (which will cause the Makefiles to be regenerated when you run `make');
-# (2) otherwise, pass the desired values on the `make' command line.
-$(RECURSIVE_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+#     (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+	@fail=; \
+	if $(am__make_keepgoing); then \
+	  failcom='fail=yes'; \
+	else \
+	  failcom='exit 1'; \
+	fi; \
 	dot_seen=no; \
 	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	for subdir in $$list; do \
 	  echo "Making $$target in $$subdir"; \
 	  if test "$$subdir" = "."; then \
 	    dot_seen=yes; \
@@ -530,57 +623,12 @@
 	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
 	fi; test -z "$$fail"
 
-$(RECURSIVE_CLEAN_TARGETS):
-	@fail= failcom='exit 1'; \
-	for f in x $$MAKEFLAGS; do \
-	  case $$f in \
-	    *=* | --[!k]*);; \
-	    *k*) failcom='fail=yes';; \
-	  esac; \
-	done; \
-	dot_seen=no; \
-	case "$@" in \
-	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
-	  *) list='$(SUBDIRS)' ;; \
-	esac; \
-	rev=''; for subdir in $$list; do \
-	  if test "$$subdir" = "."; then :; else \
-	    rev="$$subdir $$rev"; \
-	  fi; \
-	done; \
-	rev="$$rev ."; \
-	target=`echo $@ | sed s/-recursive//`; \
-	for subdir in $$rev; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
-	done && test -z "$$fail"
-tags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
-	done
-ctags-recursive:
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
-	done
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
-
-TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
 	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
@@ -596,12 +644,7 @@
 	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
 	  fi; \
 	done; \
-	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -613,15 +656,11 @@
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -630,6 +669,21 @@
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -666,13 +720,10 @@
 	done
 	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
 	  if test "$$subdir" = .; then :; else \
-	    test -d "$(distdir)/$$subdir" \
-	    || $(MKDIR_P) "$(distdir)/$$subdir" \
-	    || exit 1; \
-	  fi; \
-	done
-	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-	  if test "$$subdir" = .; then :; else \
+	    $(am__make_dryrun) \
+	      || test -d "$(distdir)/$$subdir" \
+	      || $(MKDIR_P) "$(distdir)/$$subdir" \
+	      || exit 1; \
 	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
 	    $(am__relativize); \
 	    new_distdir=$$reldir; \
@@ -694,7 +745,7 @@
 	done
 check-am: all-am
 check: check-recursive
-all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
 installdirs: installdirs-recursive
 installdirs-am:
 	for dir in "$(DESTDIR)$(libdir)"; do \
@@ -710,10 +761,15 @@
 
 installcheck: installcheck-recursive
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
@@ -733,7 +789,7 @@
 distclean: distclean-recursive
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
-	distclean-hdr distclean-tags
+	distclean-tags
 
 dvi: dvi-recursive
 
@@ -794,24 +850,22 @@
 
 uninstall-am: uninstall-libLTLIBRARIES
 
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
-	ctags-recursive install-am install-strip tags-recursive
+.MAKE: $(am__recursive_targets) install-am install-strip
 
-.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
-	all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool ctags ctags-recursive \
-	distclean distclean-compile distclean-generic distclean-hdr \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-libLTLIBRARIES install-man install-pdf \
-	install-pdf-am install-ps install-ps-am install-strip \
-	installcheck installcheck-am installdirs installdirs-am \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
-	uninstall-libLTLIBRARIES
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
+	check-am clean clean-generic clean-libLTLIBRARIES \
+	clean-libtool cscopelist-am ctags ctags-am distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am \
+	install-libLTLIBRARIES install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES
 
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/jni/libccrtp/sources/src/ccrtp/.cvsignore b/jni/libccrtp/sources/src/ccrtp/.cvsignore
new file mode 100644
index 0000000..22a4e72
--- /dev/null
+++ b/jni/libccrtp/sources/src/ccrtp/.cvsignore
@@ -0,0 +1,3 @@
+Makefile
+Makefile.in
+
diff --git a/jni/libccrtp/sources/src/ccrtp/CMakeLists.txt b/jni/libccrtp/sources/src/ccrtp/CMakeLists.txt
new file mode 100644
index 0000000..1fc563d
--- /dev/null
+++ b/jni/libccrtp/sources/src/ccrtp/CMakeLists.txt
@@ -0,0 +1,20 @@
+set(ccrtp1_headers base.h 
+		 formats.h 
+		 rtppkt.h 
+		 rtcppkt.h 
+		 sources.h 
+		 channel.h  
+		 queuebase.h 
+		 iqueue.h 
+		 oqueue.h
+		 ioqueue.h
+		 cqueue.h
+		 ext.h
+		 rtp.h 
+		 pool.h
+		 CryptoContext.h
+         CryptoContextCtrl.h)
+
+########### install files ###############
+
+install(FILES ${ccrtp1_headers} DESTINATION include/ccrtp)
diff --git a/jni/libccrtp/sources/src/ccrtp/CryptoContext.h b/jni/libccrtp/sources/src/ccrtp/CryptoContext.h
index 7d25770..3367e81 100644
--- a/jni/libccrtp/sources/src/ccrtp/CryptoContext.h
+++ b/jni/libccrtp/sources/src/ccrtp/CryptoContext.h
@@ -21,14 +21,13 @@
 #ifndef CRYPTOCONTEXT_H
 #define CRYPTOCONTEXT_H
 
-#include <cc++/config.h>
+#include <commoncpp/config.h>
 
 #include <ccrtp/rtppkt.h>
 
 
 #define REPLAY_WINDOW_SIZE 64
 
-
 const int SrtpAuthenticationNull     =  0;
 const int SrtpAuthenticationSha1Hmac =  1;
 const int SrtpAuthenticationSkeinHmac = 2;
@@ -39,13 +38,17 @@
 const int SrtpEncryptionTWOCM = 3;
 const int SrtpEncryptionTWOF8 = 4;
 
+#ifndef CRYPTOCONTEXTCTRL_H
+
+#include <stdint.h>
+
 #ifdef SRTP_SUPPORT
-#include <ccrtp/crypto/AesSrtp.h>
+#include <ccrtp/crypto/SrtpSymCrypto.h>
 #endif
 
-#ifdef CCXX_NAMESPACES
-namespace ost {
-#endif
+class SrtpSymCrypto;
+
+NAMESPACE_COMMONCPP
 
     class RTPPacket;
 
@@ -78,330 +81,330 @@
      */
 
     class __EXPORT CryptoContext {
-	public:
-	/**
-	 * Constructor for empty SRTP cryptographic context.
-	 *
-	 * This constructor creates an empty SRTP cryptographic context were
-	 * all algorithms are set to the null algorithm, that is no SRTP processing
-	 * is performed.
-	 *
-	 * @param ssrc The RTP SSRC that this SRTP cryptographic context protects.
-	 */
-	    CryptoContext( uint32 ssrc );
+    public:
+    /**
+     * Constructor for empty SRTP cryptographic context.
+     *
+     * This constructor creates an empty SRTP cryptographic context were
+     * all algorithms are set to the null algorithm, that is no SRTP processing
+     * is performed.
+     *
+     * @param ssrc The RTP SSRC that this SRTP cryptographic context protects.
+     */
+        CryptoContext( uint32 ssrc );
 
-	/**
-	 * Constructor for an active SRTP cryptographic context.
-	 *
-	 * This constructor creates an active SRTP cryptographic context were
-	 * algorithms are enabled, keys are computed and so on. This SRTP
-	 * cryptographic context can protect a RTP SSRC stream.
-	 *
-	 * @param ssrc
-	 *    The RTP SSRC that this SRTP cryptographic context protects.
-	 *
-	 * @param roc
-	 *    The initial Roll-Over-Counter according to RFC 3711. These are the
-	 *    upper 32 bit of the overall 48 bit SRTP packet index. Refer to
-	 *    chapter 3.2.1 of the RFC.
-	 *
-	 * @param keyDerivRate
-	 *    The key derivation rate defines when to recompute the SRTP session
-	 *    keys. Refer to chapter 4.3.1 in the RFC.
-	 *
-	 * @param ealg
-	 *    The encryption algorithm to use. Possible values are <code>
-	 *    SrtpEncryptionNull, SrtpEncryptionAESCM, SrtpEncryptionAESF8
-	 *    </code>. See chapter 4.1.1 for AESCM (Counter mode) and 4.1.2
-	 *    for AES F8 mode.
-	 *
-	 * @param aalg
-	 *    The authentication algorithm to use. Possible values are <code>
-	 *    SrtpEncryptionNull, SrtpAuthenticationSha1Hmac</code>. The only
-	 *    active algorithm here is SHA1 HMAC, a SHA1 based hashed message
-	 *    authentication code as defined in RFC 2104.
-	 *
-	 * @param masterKey
-	 *    Pointer to the master key for this SRTP cryptographic context.
-	 *    Must point to <code>masterKeyLength</code> bytes. Refer to chapter
-	 *    3.2.1 of the RFC about the role of the master key.
-	 *
-	 * @param masterKeyLength
-	 *    The length in bytes of the master key in bytes. The length must
-	 *    match the selected encryption algorithm. Because SRTP uses AES
-	 *    based  encryption only, then master key length may be 16 or 32
-	 *    bytes (128 or 256 bit master key)
-	 *
-	 * @param masterSalt
-	 *    SRTP uses the master salt to computer the initialization vector
-	 *    that in turn is input to compute the session key, session
-	 *    authentication key and the session salt.
-	 *
-	 * @param masterSaltLength
-	 *    The length in bytes of the master salt data in bytes. SRTP uses
-	 *    AES as encryption algorithm. AES encrypts 16 byte blocks
-	 *    (independent of the key length). According to RFC3711 the standard
-	 *    value for the master salt length should be 112 bit (14 bytes).
-	 *
-	 * @param ekeyl
-	 *    The length in bytes of the session encryption key that SRTP shall
-	 *    compute and use. Usually the same length as for the master key
-	 *    length. But you may use a different length as well. Be carefull
-	 *    that the key management mechanisms supports different key lengths.
-	 *
-	 * @param akeyl
-	 *    The length in bytes of the session authentication key. SRTP
-	 *    computes this key and uses it as input to the authentication
-	 *    algorithm.
-	 *    The standard value is 160 bits (20 bytes).
-	 *
-	 * @param skeyl
-	 *    The length in bytes of the session salt. SRTP computes this salt
-	 *    key and uses it as input during encryption. The length usually
-	 *    is the same as the master salt length.
-	 *
-	 * @param tagLength
-	 *    The length is bytes of the authentication tag that SRTP appends
-	 *    to the RTP packet. Refer to chapter 4.2. in the RFC 3711.
-	 */
-	    CryptoContext( uint32 ssrc, int32 roc,
-			   int64  keyDerivRate,
-			   const  int32 ealg,
-			   const  int32 aalg,
-			   uint8* masterKey,
-			   int32  masterKeyLength,
-			   uint8* masterSalt,
-			   int32  masterSaltLength,
-			   int32  ekeyl,
-			   int32  akeyl,
-			   int32  skeyl,
-			   int32  tagLength );
-	/**
-	 * Destructor.
-	 *
-	 * Cleans the SRTP cryptographic context.
-	 */
-	    ~CryptoContext();
+    /**
+     * Constructor for an active SRTP cryptographic context.
+     *
+     * This constructor creates an active SRTP cryptographic context were
+     * algorithms are enabled, keys are computed and so on. This SRTP
+     * cryptographic context can protect a RTP SSRC stream.
+     *
+     * @param ssrc
+     *    The RTP SSRC that this SRTP cryptographic context protects.
+     *
+     * @param roc
+     *    The initial Roll-Over-Counter according to RFC 3711. These are the
+     *    upper 32 bit of the overall 48 bit SRTP packet index. Refer to
+     *    chapter 3.2.1 of the RFC.
+     *
+     * @param keyDerivRate
+     *    The key derivation rate defines when to recompute the SRTP session
+     *    keys. Refer to chapter 4.3.1 in the RFC.
+     *
+     * @param ealg
+     *    The encryption algorithm to use. Possible values are <code>
+     *    SrtpEncryptionNull, SrtpEncryptionAESCM, SrtpEncryptionAESF8
+     *    </code>. See chapter 4.1.1 for AESCM (Counter mode) and 4.1.2
+     *    for AES F8 mode.
+     *
+     * @param aalg
+     *    The authentication algorithm to use. Possible values are <code>
+     *    SrtpEncryptionNull, SrtpAuthenticationSha1Hmac</code>. The only
+     *    active algorithm here is SHA1 HMAC, a SHA1 based hashed message
+     *    authentication code as defined in RFC 2104.
+     *
+     * @param masterKey
+     *    Pointer to the master key for this SRTP cryptographic context.
+     *    Must point to <code>masterKeyLength</code> bytes. Refer to chapter
+     *    3.2.1 of the RFC about the role of the master key.
+     *
+     * @param masterKeyLength
+     *    The length in bytes of the master key in bytes. The length must
+     *    match the selected encryption algorithm. Because SRTP uses AES
+     *    based  encryption only, then master key length may be 16 or 32
+     *    bytes (128 or 256 bit master key)
+     *
+     * @param masterSalt
+     *    SRTP uses the master salt to computer the initialization vector
+     *    that in turn is input to compute the session key, session
+     *    authentication key and the session salt.
+     *
+     * @param masterSaltLength
+     *    The length in bytes of the master salt data in bytes. SRTP uses
+     *    AES as encryption algorithm. AES encrypts 16 byte blocks
+     *    (independent of the key length). According to RFC3711 the standard
+     *    value for the master salt length should be 112 bit (14 bytes).
+     *
+     * @param ekeyl
+     *    The length in bytes of the session encryption key that SRTP shall
+     *    compute and use. Usually the same length as for the master key
+     *    length. But you may use a different length as well. Be carefull
+     *    that the key management mechanisms supports different key lengths.
+     *
+     * @param akeyl
+     *    The length in bytes of the session authentication key. SRTP
+     *    computes this key and uses it as input to the authentication
+     *    algorithm.
+     *    The standard value is 160 bits (20 bytes).
+     *
+     * @param skeyl
+     *    The length in bytes of the session salt. SRTP computes this salt
+     *    key and uses it as input during encryption. The length usually
+     *    is the same as the master salt length.
+     *
+     * @param tagLength
+     *    The length is bytes of the authentication tag that SRTP appends
+     *    to the RTP packet. Refer to chapter 4.2. in the RFC 3711.
+     */
+        CryptoContext( uint32 ssrc, int32 roc,
+               int64  keyDerivRate,
+               const  int32 ealg,
+               const  int32 aalg,
+               uint8* masterKey,
+               int32  masterKeyLength,
+               uint8* masterSalt,
+               int32  masterSaltLength,
+               int32  ekeyl,
+               int32  akeyl,
+               int32  skeyl,
+               int32  tagLength );
+    /**
+     * Destructor.
+     *
+     * Cleans the SRTP cryptographic context.
+     */
+        ~CryptoContext();
 
-	/**
-	 * Set the Roll-Over-Counter.
-	 *
-	 * Ths method sets the upper 32 bit of the 48 bit SRTP packet index
-	 * (the roll-over-part)
-	 *
-	 * @param r
-	 *   The roll-over-counter
-	 */
-	    inline void
-	    setRoc(uint32 r)
-	    {roc = r;}
+    /**
+     * Set the Roll-Over-Counter.
+     *
+     * Ths method sets the upper 32 bit of the 48 bit SRTP packet index
+     * (the roll-over-part)
+     *
+     * @param r
+     *   The roll-over-counter
+     */
+        inline void
+        setRoc(uint32 r)
+        {roc = r;}
 
-	/**
-	 * Get the Roll-Over-Counter.
-	 *
-	 * Ths method get the upper 32 bit of the 48 bit SRTP packet index
-	 * (the roll-over-part)
-	 *
-	 * @return The roll-over-counter
-	 */
-	    inline uint32
-	    getRoc() const
-	    {return roc;}
+    /**
+     * Get the Roll-Over-Counter.
+     *
+     * Ths method get the upper 32 bit of the 48 bit SRTP packet index
+     * (the roll-over-part)
+     *
+     * @return The roll-over-counter
+     */
+        inline uint32
+        getRoc() const
+        {return roc;}
 
-	/**
-	 * Perform SRTP encryption.
-	 *
-	 * This method encrypts <em>and</em> decrypts SRTP payload data. Plain
-	 * data gets encrypted, encrypted data get decrypted.
-	 *
-	 * @param rtp
-	 *    The RTP packet that contains the data to encrypt.
-	 *
-	 * @param index
-	 *    The 48 bit SRTP packet index. See the <code>guessIndex</code>
-	 *    method.
-	 *
-	 * @param ssrc
-	 *    The RTP SSRC data in <em>host</em> order.
-	 */
-	    void srtpEncrypt( RTPPacket* rtp, uint64 index, uint32 ssrc );
+    /**
+     * Perform SRTP encryption.
+     *
+     * This method encrypts <em>and</em> decrypts SRTP payload data. Plain
+     * data gets encrypted, encrypted data get decrypted.
+     *
+     * @param rtp
+     *    The RTP packet that contains the data to encrypt.
+     *
+     * @param index
+     *    The 48 bit SRTP packet index. See the <code>guessIndex</code>
+     *    method.
+     *
+     * @param ssrc
+     *    The RTP SSRC data in <em>host</em> order.
+     */
+        void srtpEncrypt( RTPPacket* rtp, uint64 index, uint32 ssrc );
 
-	/**
-	 * Compute the authentication tag.
-	 *
-	 * Compute the authentication tag according the the paramters in the
-	 * SRTP Cryptograhic context.
-	 *
-	 * @param rtp
-	 *    The RTP packet that contains the data to authenticate.
-	 *
-	 * @param roc
-	 *    The 32 bit SRTP roll-over-counter.
-	 *
-	 * @param tag
-	 *    Points to a buffer that hold the computed tag. This buffer must
-	 *    be able to hold <code>tagLength</code> bytes.
-	 */
-	    void srtpAuthenticate(RTPPacket* rtp, uint32 roc, uint8* tag );
+    /**
+     * Compute the authentication tag.
+     *
+     * Compute the authentication tag according the the paramters in the
+     * SRTP Cryptograhic context.
+     *
+     * @param rtp
+     *    The RTP packet that contains the data to authenticate.
+     *
+     * @param roc
+     *    The 32 bit SRTP roll-over-counter.
+     *
+     * @param tag
+     *    Points to a buffer that hold the computed tag. This buffer must
+     *    be able to hold <code>tagLength</code> bytes.
+     */
+        void srtpAuthenticate(RTPPacket* rtp, uint32 roc, uint8* tag );
 
-	/**
-	 * Perform key derivation according to SRTP specification
-	 *
-	 * This method computes the session key, session authentication key and the
-	 * session salt key. This method must be called at least once after the
-	 * SRTP Cryptograhic context was set up.
-	 *
-	 * @param index
-	 *    The 48 bit SRTP packet index. See the <code>guessIndex</code>
-	 *    method.
-	 */
-	    void deriveSrtpKeys(uint64 index);
+    /**
+     * Perform key derivation according to SRTP specification
+     *
+     * This method computes the session key, session authentication key and the
+     * session salt key. This method must be called at least once after the
+     * SRTP Cryptograhic context was set up.
+     *
+     * @param index
+     *    The 48 bit SRTP packet index. See the <code>guessIndex</code>
+     *    method.
+     */
+        void deriveSrtpKeys(uint64 index);
 
-	/**
-	 * Compute (guess) the new SRTP index based on the sequence number of
-	 * a received RTP packet.
-	 *
-	 * The method uses the algorithm show in RFC3711, Appendix A, to compute
-	 * the new index.
-	 *
-	 * @param newSeqNumber
-	 *    The sequence number of the received RTP packet in host order.
-	 *
-	 * @return The new SRTP packet index
-	 */
-	    uint64 guessIndex(uint16 newSeqNumber);
+    /**
+     * Compute (guess) the new SRTP index based on the sequence number of
+     * a received RTP packet.
+     *
+     * The method uses the algorithm show in RFC3711, Appendix A, to compute
+     * the new index.
+     *
+     * @param newSeqNumber
+     *    The sequence number of the received RTP packet in host order.
+     *
+     * @return The new SRTP packet index
+     */
+        uint64 guessIndex(uint16 newSeqNumber);
 
-	/**
-	 * Check for packet replay.
-	 *
-	 * The method check if a received packet is either to old or was already
-	 * received.
-	 *
-	 * The method supports a 64 packet history relative the the given
-	 * sequence number.
-	 *
-	 * @param newSeqNumber
-	 *    The sequence number of the received RTP packet in host order.
-	 *
-	 * @return <code>true</code> if no replay, <code>false</code> if packet
-	 *    is too old ar was already received.
-	 */
-	    bool checkReplay(uint16 newSeqNumber);
+    /**
+     * Check for packet replay.
+     *
+     * The method check if a received packet is either to old or was already
+     * received.
+     *
+     * The method supports a 64 packet history relative the the given
+     * sequence number.
+     *
+     * @param newSeqNumber
+     *    The sequence number of the received RTP packet in host order.
+     *
+     * @return <code>true</code> if no replay, <code>false</code> if packet
+     *    is too old ar was already received.
+     */
+        bool checkReplay(uint16 newSeqNumber);
 
-	/**
-	 * Update the SRTP packet index.
-	 *
-	 * Call this method after all checks were successful. See chapter
-	 * 3.3.1 in the RFC when to update the ROC and ROC processing.
-	 *
-	 * @param newSeqNumber
-	 *    The sequence number of the received RTP packet in host order.
-	 */
-	    void update( uint16 newSeqNumber );
+    /**
+     * Update the SRTP packet index.
+     *
+     * Call this method after all checks were successful. See chapter
+     * 3.3.1 in the RFC when to update the ROC and ROC processing.
+     *
+     * @param newSeqNumber
+     *    The sequence number of the received RTP packet in host order.
+     */
+        void update( uint16 newSeqNumber );
 
-	/**
-	 * Get the length of the SRTP authentication tag in bytes.
-	 *
-	 * @return the length of the authentication tag.
-	 */
-	    inline int32
-	    getTagLength() const
-	    {return tagLength;}
+    /**
+     * Get the length of the SRTP authentication tag in bytes.
+     *
+     * @return the length of the authentication tag.
+     */
+        inline int32
+        getTagLength() const
+        {return tagLength;}
 
 
-	/**
-	 * Get the length of the MKI in bytes.
-	 *
-	 * @return the length of the MKI.
-	 */
-	    inline int32
-	    getMkiLength() const
-	    {return mkiLength;}
+    /**
+     * Get the length of the MKI in bytes.
+     *
+     * @return the length of the MKI.
+     */
+        inline int32
+        getMkiLength() const
+        {return mkiLength;}
 
-	/**
-	 * Get the SSRC of this SRTP Cryptograhic context.
-	 *
-	 * @return the SSRC.
-	 */
-	    inline uint32
-	    getSsrc() const
-	    {return ssrc;}
+    /**
+     * Get the SSRC of this SRTP Cryptograhic context.
+     *
+     * @return the SSRC.
+     */
+        inline uint32
+        getSsrc() const
+        {return ssrcCtx;}
 
-        /**
-         * Derive a new Crypto Context for use with a new SSRC
-         *
-         * This method returns a new Crypto Context initialized with the data
-         * of this crypto context. Replacing the SSRC, Roll-over-Counter, and
-         * the key derivation rate the application cab use this Crypto Context
-         * to encrypt / decrypt a new stream (Synchronization source) inside
-         * one RTP session.
-         *
-         * Before the application can use this crypto context it must call
-         * the <code>deriveSrtpKeys</code> method.
-         *
-         * @param ssrc
-         *     The SSRC for this context
-         * @param roc
-         *     The Roll-Over-Counter for this context
-         * @param keyDerivRate
-         *     The key derivation rate for this context
-         * @return
-         *     a new CryptoContext with all relevant data set.
-         */
+    /**
+     * Derive a new Crypto Context for use with a new SSRC
+     *
+     * This method returns a new Crypto Context initialized with the data
+     * of this crypto context. Replacing the SSRC, Roll-over-Counter, and
+     * the key derivation rate the application cab use this Crypto Context
+     * to encrypt / decrypt a new stream (Synchronization source) inside
+     * one RTP session.
+     *
+     * Before the application can use this crypto context it must call
+     * the <code>deriveSrtpKeys</code> method.
+     *
+     * @param ssrc
+     *     The SSRC for this context
+     * @param roc
+     *     The Roll-Over-Counter for this context
+     * @param keyDerivRate
+     *     The key derivation rate for this context
+     * @return
+     *     a new CryptoContext with all relevant data set.
+     */
+     CryptoContext* newCryptoContextForSSRC(uint32 ssrc, int roc, int64 keyDerivRate);
 
-            CryptoContext* newCryptoContextForSSRC(uint32 ssrc, int roc, int64 keyDerivRate);
+    private:
 
-	private:
+        uint32 ssrcCtx;
+        bool   using_mki;
+        uint32 mkiLength;
+        uint8* mki;
 
-	    uint32 ssrc;
-	    bool   using_mki;
-	    uint32 mkiLength;
-	    uint8* mki;
+        uint32 roc;
+        uint32 guessed_roc;
+        uint16 s_l;
+        int64  key_deriv_rate;
 
-	    uint32 roc;
-	    uint32 guessed_roc;
-	    uint16 s_l;
-	    int64  key_deriv_rate;
+        /* bitmask for replay check */
+        uint64 replay_window;
 
-	    /* bitmask for replay check */
-	    uint64 replay_window;
+        uint8* master_key;
+        uint32 master_key_length;
+        uint32 master_key_srtp_use_nb;
+        uint32 master_key_srtcp_use_nb;
+        uint8* master_salt;
+        uint32 master_salt_length;
 
-	    uint8* master_key;
-	    uint32 master_key_length;
-	    uint32 master_key_srtp_use_nb;
-	    uint32 master_key_srtcp_use_nb;
-	    uint8* master_salt;
-	    uint32 master_salt_length;
+        /* Session Encryption, Authentication keys, Salt */
+        int32  n_e;
+        uint8* k_e;
+        int32  n_a;
+        uint8* k_a;
+        int32  n_s;
+        uint8* k_s;
 
-	    /* Session Encryption, Authentication keys, Salt */
-	    int32  n_e;
-	    uint8* k_e;
-	    int32  n_a;
-	    uint8* k_a;
-	    int32  n_s;
-	    uint8* k_s;
-
-	    int32 ealg;
-	    int32 aalg;
-	    int32 ekeyl;
-	    int32 akeyl;
-	    int32 skeyl;
-	    int32 tagLength;
-	    bool  seqNumSet;
+        int32 ealg;
+        int32 aalg;
+        int32 ekeyl;
+        int32 akeyl;
+        int32 skeyl;
+        int32 tagLength;
+        bool  seqNumSet;
 
         void*   macCtx;
 
 #ifdef SRTP_SUPPORT
-	    AesSrtp* cipher;
-	    AesSrtp* f8Cipher;
+        SrtpSymCrypto* cipher;
+        SrtpSymCrypto* f8Cipher;
 #else
-	    void* cipher;
-	    void* f8Cipher;
+        void* cipher;
+        void* f8Cipher;
 #endif
 
     };
-#ifdef  CCXX_NAMESPACES
-}
+
+END_NAMESPACE
+
 #endif
 
 #endif
diff --git a/jni/libccrtp/sources/src/ccrtp/CryptoContextCtrl.h b/jni/libccrtp/sources/src/ccrtp/CryptoContextCtrl.h
new file mode 100644
index 0000000..10a50e7
--- /dev/null
+++ b/jni/libccrtp/sources/src/ccrtp/CryptoContextCtrl.h
@@ -0,0 +1,341 @@
+/*
+  Copyright (C) 2004-2006 the Minisip Team
+  Copyright (C) 2011 Werner Dittmann for the SRTCP support
+  
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library 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
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+*/
+
+
+
+#ifndef CRYPTOCONTEXTCTRL_H
+#define CRYPTOCONTEXTCTRL_H
+
+#include <commoncpp/config.h>
+
+#define REPLAY_WINDOW_SIZE 64
+
+#ifdef SRTP_SUPPORT
+#include <ccrtp/crypto/SrtpSymCrypto.h>
+#endif
+
+NAMESPACE_COMMONCPP
+
+    /**
+     * The implementation for a SRTCP cryptographic context.
+     *
+     * This class holds data and provides functions that implement a
+     * cryptographic context for SRTP, Refer to RFC 3711, chapter 3.2 for some
+     * more detailed information about the SRTP cryptographic context.
+     *
+     * Each SRTP cryptographic context maintains a RTP source identified by
+     * its SSRC. Thus you can independently protect each source inside a RTP
+     * session.
+     *
+     * Key management mechanisms negotiate the parameters for the SRTP
+     * cryptographic context, such as master key, key length, authentication
+     * length and so on. The key management mechanisms are not part of
+     * SRTP. Refer to MIKEY (RFC 3880) or to Phil Zimmermann's ZRTP protocol
+     * (draft-zimmermann-avt-zrtp-01). After key management negotiated the
+     * data the application can setup the SRTCP cryptographic context and
+     * enable SRTCP processing.
+     *
+     *
+     * @author Israel Abad <i_abad@terra.es>
+     * @author Erik Eliasson <eliasson@it.kth.se>
+     * @author Johan Bilien <jobi@via.ecp.fr>
+     * @author Joachim Orrblad <joachim@orrblad.com>
+     * @author Werner Dittmann <Werner.Dittmann@t-online.de>
+     */
+
+    class __EXPORT CryptoContextCtrl {
+    public:
+    /**
+     * Constructor for empty SRTP cryptographic context.
+     *
+     * This constructor creates an empty SRTP cryptographic context were
+     * all algorithms are set to the null algorithm, that is no SRTP processing
+     * is performed.
+     *
+     * @param ssrc The RTP SSRC that this SRTP cryptographic context protects.
+     */
+    CryptoContextCtrl( uint32 ssrc );
+
+    /**
+     * Constructor for an active SRTP cryptographic context.
+     *
+     * This constructor creates an active SRTP cryptographic context were
+     * algorithms are enabled, keys are computed and so on. This SRTP
+     * cryptographic context can protect a RTP SSRC stream.
+     *
+     * @param ssrc
+     *    The RTP SSRC that this SRTP cryptographic context protects.
+     *
+     * @param ealg
+     *    The encryption algorithm to use. Possible values are <code>
+     *    SrtpEncryptionNull, SrtpEncryptionAESCM, SrtpEncryptionAESF8
+     *    </code>. See chapter 4.1.1 for AESCM (Counter mode) and 4.1.2
+     *    for AES F8 mode.
+     *
+     * @param aalg
+     *    The authentication algorithm to use. Possible values are <code>
+     *    SrtpEncryptionNull, SrtpAuthenticationSha1Hmac</code>. The only
+     *    active algorithm here is SHA1 HMAC, a SHA1 based hashed message
+     *    authentication code as defined in RFC 2104.
+     *
+     * @param masterKey
+     *    Pointer to the master key for this SRTP cryptographic context.
+     *    Must point to <code>masterKeyLength</code> bytes. Refer to chapter
+     *    3.2.1 of the RFC about the role of the master key.
+     *
+     * @param masterKeyLength
+     *    The length in bytes of the master key in bytes. The length must
+     *    match the selected encryption algorithm. Because SRTP uses AES
+     *    based  encryption only, then master key length may be 16 or 32
+     *    bytes (128 or 256 bit master key)
+     *
+     * @param masterSalt
+     *    SRTP uses the master salt to computer the initialization vector
+     *    that in turn is input to compute the session key, session
+     *    authentication key and the session salt.
+     *
+     * @param masterSaltLength
+     *    The length in bytes of the master salt data in bytes. SRTP uses
+     *    AES as encryption algorithm. AES encrypts 16 byte blocks
+     *    (independent of the key length). According to RFC3711 the standard
+     *    value for the master salt length should be 112 bit (14 bytes).
+     *
+     * @param ekeyl
+     *    The length in bytes of the session encryption key that SRTP shall
+     *    compute and use. Usually the same length as for the master key
+     *    length. But you may use a different length as well. Be carefull
+     *    that the key management mechanisms supports different key lengths.
+     *
+     * @param akeyl
+     *    The length in bytes of the session authentication key. SRTP
+     *    computes this key and uses it as input to the authentication
+     *    algorithm.
+     *    The standard value is 160 bits (20 bytes).
+     *
+     * @param skeyl
+     *    The length in bytes of the session salt. SRTP computes this salt
+     *    key and uses it as input during encryption. The length usually
+     *    is the same as the master salt length.
+     *
+     * @param tagLength
+     *    The length is bytes of the authentication tag that SRTP appends
+     *    to the RTP packet. Refer to chapter 4.2. in the RFC 3711.
+     */
+    CryptoContextCtrl( uint32 ssrc,
+               const  int32 ealg,
+               const  int32 aalg,
+               uint8* masterKey,
+               int32  masterKeyLength,
+               uint8* masterSalt,
+               int32  masterSaltLength,
+               int32  ekeyl,
+               int32  akeyl,
+               int32  skeyl,
+               int32  tagLength );
+    /**
+     * Destructor.
+     *
+     * Cleans the SRTP cryptographic context.
+     */
+    ~CryptoContextCtrl();
+
+    /**
+     * Perform SRTP encryption.
+     *
+     * This method encrypts <em>and</em> decrypts SRTP payload data. Plain
+     * data gets encrypted, encrypted data get decrypted.
+     *
+     * @param rtp
+     *    The RTP packet that contains the data to encrypt.
+     *
+     * @param index
+     *    The 48 bit SRTP packet index. See the <code>guessIndex</code>
+     *    method.
+     *
+     * @param ssrc
+     *    The RTP SSRC data in <em>host</em> order.
+     */
+    void srtcpEncrypt( uint8* rtp, size_t len, uint64 index, uint32 ssrc );
+
+    /**
+     * Compute the authentication tag.
+     *
+     * Compute the authentication tag according the the paramters in the
+     * SRTP Cryptograhic context.
+     *
+     * @param rtp
+     *    The RTP packet that contains the data to authenticate.
+     *
+     * @param roc
+     *    The 32 bit SRTP roll-over-counter.
+     *
+     * @param tag
+     *    Points to a buffer that hold the computed tag. This buffer must
+     *    be able to hold <code>tagLength</code> bytes.
+     */
+    void srtcpAuthenticate(uint8* rtp, size_t len, uint32 roc, uint8* tag );
+
+    /**
+     * Perform key derivation according to SRTP specification
+     *
+     * This method computes the session key, session authentication key and the
+     * session salt key. This method must be called at least once after the
+     * SRTP Cryptograhic context was set up.
+     *
+     * @param index
+     *    The 48 bit SRTP packet index. See the <code>guessIndex</code>
+     *    method.
+     */
+     void deriveSrtcpKeys();
+
+    /**
+     * Check for packet replay.
+     *
+     * The method check if a received packet is either to old or was already
+     * received.
+     *
+     * The method supports a 64 packet history relative the the given
+     * sequence number.
+     *
+     * @param newSeqNumber
+     *    The sequence number of the received RTP packet in host order.
+     *
+     * @return <code>true</code> if no replay, <code>false</code> if packet
+     *    is too old ar was already received.
+     */
+     bool checkReplay(uint32 newSeqNumber);
+
+    /**
+     * Update the SRTP packet index.
+     *
+     * Call this method after all checks were successful. See chapter
+     * 3.3.1 in the RFC when to update the ROC and ROC processing.
+     *
+     * @param newSeqNumber
+     *    The sequence number of the received RTCP packet in host order.
+     */
+    void update( uint32 newSeqNumber );
+
+    /**
+     * Get the length of the SRTP authentication tag in bytes.
+     *
+     * @return the length of the authentication tag.
+     */
+    inline int32
+    getTagLength() const
+        {return tagLength;}
+
+
+    /**
+     * Get the length of the MKI in bytes.
+     *
+     * @return the length of the MKI.
+     */
+    inline int32
+    getMkiLength() const
+        {return mkiLength;}
+
+    /**
+     * Get the SSRC of this SRTP Cryptograhic context.
+     *
+     * @return the SSRC.
+     */
+    inline uint32
+    getSsrc() const
+        {return ssrcCtx;}
+
+    /**
+     * Derive a new Crypto Context for use with a new SSRC
+     *
+     * This method returns a new Crypto Context initialized with the data
+     * of this crypto context. Replacing the SSRC, Roll-over-Counter, and
+     * the key derivation rate the application cab use this Crypto Context
+     * to encrypt / decrypt a new stream (Synchronization source) inside
+     * one RTP session.
+     *
+     * Before the application can use this crypto context it must call
+     * the <code>deriveSrtpKeys</code> method.
+     *
+     * @param ssrc
+     *     The SSRC for this context
+     * @param roc
+     *     The Roll-Over-Counter for this context
+     * @param keyDerivRate
+     *     The key derivation rate for this context
+     * @return
+     *     a new CryptoContext with all relevant data set.
+     */
+    CryptoContextCtrl* newCryptoContextForSSRC(uint32 ssrc);
+
+    private:
+
+        uint32 ssrcCtx;
+        bool   using_mki;
+        uint32 mkiLength;
+        uint8* mki;
+
+        uint32 s_l;
+
+        /* bitmask for replay check */
+        uint64 replay_window;
+
+        uint8* master_key;
+        uint32 master_key_length;
+        uint8* master_salt;
+        uint32 master_salt_length;
+
+        /* Session Encryption, Authentication keys, Salt */
+        int32  n_e;
+        uint8* k_e;
+        int32  n_a;
+        uint8* k_a;
+        int32  n_s;
+        uint8* k_s;
+
+        int32 ealg;
+        int32 aalg;
+        int32 ekeyl;
+        int32 akeyl;
+        int32 skeyl;
+        int32 tagLength;
+
+        void*   macCtx;
+
+#ifdef SRTP_SUPPORT
+        SrtpSymCrypto* cipher;
+        SrtpSymCrypto* f8Cipher;
+#else
+        void* cipher;
+        void* f8Cipher;
+#endif
+
+    };
+
+END_NAMESPACE
+
+#endif
+
+/** EMACS **
+ * Local variables:
+ * mode: c++
+ * c-default-style: ellemtel
+ * c-basic-offset: 4
+ * End:
+ */
+
diff --git a/jni/libccrtp/sources/src/ccrtp/Makefile b/jni/libccrtp/sources/src/ccrtp/Makefile
index 4c1c3d6..a74f4d3 100644
--- a/jni/libccrtp/sources/src/ccrtp/Makefile
+++ b/jni/libccrtp/sources/src/ccrtp/Makefile
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
 # src/ccrtp/Makefile.  Generated from Makefile.in by configure.
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -27,6 +26,51 @@
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/ccrtp
 pkgincludedir = $(includedir)/ccrtp
 pkglibdir = $(libdir)/ccrtp
@@ -44,11 +88,11 @@
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = x86_64-unknown-linux-gnu
-host_triplet = arm-unknown-linux-androideabi
-target_triplet = arm-unknown-linux-androideabi
+host_triplet = x86_64-unknown-linux-gnu
+target_triplet = x86_64-unknown-linux-gnu
 subdir = src/ccrtp
-DIST_COMMON = $(ccxxinclude_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(ccxxinclude_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libgcrypt_local.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -59,13 +103,30 @@
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_HEADER = $(top_builddir)/ccrtp-config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 = 
 depcomp =
 am__depfiles_maybe =
 SOURCES =
 DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -87,76 +148,99 @@
 am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
 am__installdirs = "$(DESTDIR)$(ccxxincludedir)"
 HEADERS = $(ccxxinclude_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run aclocal-1.11
-AMTAR = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run tar
-AR = arm-linux-androideabi-ar
-AUTOCONF = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run automake-1.11
+ACLOCAL = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing aclocal-1.13
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 1
+AR = ar
+AUTOCONF = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing autoconf
+AUTOHEADER = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing autoheader
+AUTOMAKE = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing automake-1.13
 AWK = gawk
-CC = arm-linux-androideabi-gcc
+CC = gcc
 CCDEPMODE = depmode=none
 CFLAGS = -g -O2
-COMMON_CFLAGS = -D_GNU_SOURCE  
-COMMON_LIBS = -pthread -lccgnu2 -ldl -lrt  
-CPP = arm-linux-androideabi-gcc -E
+COMMONCPP_CFLAGS = -Wno-long-long -fexceptions -DNEW_STDCPP -pthread -fno-check-new -finline -fvisibility=hidden -DUCOMMON_VISIBILITY=1 
+COMMONCPP_LIBS = -lcommoncpp -lucommon -lrt -ldl -lpthread 
+CPP = gcc -E
 CPPFLAGS = 
-CXX = arm-linux-androideabi-g++
-CXXCPP = arm-linux-androideabi-g++ -E
+CXX = g++
+CXXCPP = g++ -E
 CXXDEPMODE = depmode=none
-CXXFLAGS = -g -O2 -D_GNU_SOURCE  
+CXXFLAGS = -g -O2 -Wno-long-long -fexceptions -DNEW_STDCPP -pthread -fno-check-new -finline -fvisibility=hidden -DUCOMMON_VISIBILITY=1 
 CYGPATH_W = echo
 DEFS = -DHAVE_CONFIG_H
 DEPDIR = .deps
 DLLTOOL = false
-DOXYGEN = no
+DOXYGEN = /usr/bin/doxygen
 DSYMUTIL = 
 DUMPBIN = 
 ECHO_C = 
 ECHO_N = -n
 ECHO_T = 
-EGREP = /bin/grep -E
+EGREP = /usr/bin/grep -E
 EXEEXT = 
-FGREP = /bin/grep -F
+FGREP = /usr/bin/grep -F
 FTPDIR = 
-GNULIBS = -L/usr/lib -pthread -lccgnu2 -ldl -lrt   
-GREP = /bin/grep
+GNULIBS = -lcommoncpp -lucommon -lrt -ldl -lpthread  -lgcrypt -ldl -lgpg-error 
+GREP = /usr/bin/grep
 INSTALL = /usr/bin/install -c
 INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
 KDOC_DIR = $(top_srcdir)/doc
-LD = /home/evigier/android-14b-toolchain/arm-linux-androideabi/bin/ld
+LD = /usr/bin/ld -m elf_x86_64
 LDFLAGS = 
 LIBGCRYPT_CFLAGS = 
-LIBGCRYPT_CONFIG = 
-LIBGCRYPT_LIBS = 
+LIBGCRYPT_CONFIG = /usr/bin/libgcrypt-config
+LIBGCRYPT_LIBS = -lgcrypt -ldl -lgpg-error
 LIBOBJS = 
-LIBS = 
+LIBS = -lgcrypt -ldl -lgpg-error 
 LIBTOOL = $(SHELL) $(top_builddir)/libtool
-LIB_MAJOR = 0
-LIB_VERSION = 1_8
 LIPO = 
 LN_S = ln -s
 LTLIBOBJS = 
-LT_CCXX_VERSION = -version-info 0:0
-LT_MAJOR = 0
+LT_CCXX_VERSION = -version-info 2:2:0
+LT_MAJOR = 2
 LT_MINOR = 0
-LT_RELEASE = 1.8
-LT_SUBVER = 0.0
+LT_RELEASE = 
+LT_SUBVER = 2.0
+LT_VERSION = 2:2:0
 MAINT = #
-MAKEINFO = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing makeinfo
 MANIFEST_TOOL = :
-MKDIR_P = /bin/mkdir -p
-NM = /home/evigier/android-14b-toolchain/bin/arm-linux-androideabi-nm -B
+MKDIR_P = /usr/bin/mkdir -p
+NM = /usr/bin/nm -B
 NMEDIT = 
-OBJDUMP = arm-linux-androideabi-objdump
+OBJDUMP = objdump
 OBJEXT = o
 OTOOL = 
 OTOOL64 = 
@@ -170,27 +254,27 @@
 PATH_SEPARATOR = :
 PKG_CONFIG = /usr/bin/pkg-config
 PKG_CONFIG_LIBDIR = 
-PKG_CONFIG_PATH = /home/evigier/android-ndk-r8b/platforms/android-14/arch-arm/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
-RANLIB = arm-linux-androideabi-ranlib
-SED = /bin/sed
+PKG_CONFIG_PATH = /usr/local/lib/pkgconfig
+RANLIB = ranlib
+SED = /usr/bin/sed
 SET_MAKE = 
-SHELL = /bin/bash
-STRIP = arm-linux-androideabi-strip
-VERSION = 1.8.0
+SHELL = /bin/sh
+STRIP = strip
+VERSION = 2.0.4
 WARN_FLAGS = -fno-strict-aliasing -Wall -ansi -pedantic
-abs_builddir = /home/evigier/git/ccrtp-1.8.0-android/src/ccrtp
-abs_srcdir = /home/evigier/git/ccrtp-1.8.0-android/src/ccrtp
-abs_top_builddir = /home/evigier/git/ccrtp-1.8.0-android
-abs_top_srcdir = /home/evigier/git/ccrtp-1.8.0-android
-ac_ct_AR = 
-ac_ct_CC = 
-ac_ct_CXX = 
+abs_builddir = /home/lisional/git/sflphone-android/jni/libccrtp/sources/src/ccrtp
+abs_srcdir = /home/lisional/git/sflphone-android/jni/libccrtp/sources/src/ccrtp
+abs_top_builddir = /home/lisional/git/sflphone-android/jni/libccrtp/sources
+abs_top_srcdir = /home/lisional/git/sflphone-android/jni/libccrtp/sources
+ac_ct_AR = ar
+ac_ct_CC = gcc
+ac_ct_CXX = g++
 ac_ct_DUMPBIN = 
 am__include = include
 am__leading_dot = .
 am__quote = 
-am__tar = ${AMTAR} chof - "$$tardir"
-am__untar = ${AMTAR} xf -
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
 bindir = ${exec_prefix}/bin
 build = x86_64-unknown-linux-gnu
 build_alias = 
@@ -203,34 +287,34 @@
 docdir = ${datarootdir}/doc/${PACKAGE}
 dvidir = ${docdir}
 exec_prefix = ${prefix}
-host = arm-unknown-linux-androideabi
-host_alias = arm-linux-androideabi
-host_cpu = arm
-host_os = linux-androideabi
+host = x86_64-unknown-linux-gnu
+host_alias = 
+host_cpu = x86_64
+host_os = linux-gnu
 host_vendor = unknown
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/install-sh
+install_sh = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale
 localstatedir = ${prefix}/var
 mandir = ${datarootdir}/man
-mkdir_p = /bin/mkdir -p
+mkdir_p = $(MKDIR_P)
 oldincludedir = /usr/include
 pdfdir = ${docdir}
-prefix = /home/evigier/android-ndk-r8b/platforms/android-14/arch-arm/usr
+prefix = /usr/local
 program_transform_name = s,x,x,
 psdir = ${docdir}
 sbindir = ${exec_prefix}/sbin
 sharedstatedir = ${prefix}/com
 srcdir = .
 sysconfdir = ${prefix}/etc
-target = arm-unknown-linux-androideabi
+target = x86_64-unknown-linux-gnu
 target_alias = 
-target_cpu = arm
-target_os = linux-androideabi
+target_cpu = x86_64
+target_os = linux-gnu
 target_vendor = unknown
 top_build_prefix = ../../
 top_builddir = ../..
@@ -239,10 +323,10 @@
 ccxxincludedir = $(includedir)/ccrtp
 ccxxinclude_HEADERS = base.h formats.h rtppkt.h rtcppkt.h sources.h channel.h \
 	queuebase.h iqueue.h oqueue.h ioqueue.h cqueue.h ext.h rtp.h pool.h \
-	CryptoContext.h
+	CryptoContext.h CryptoContextCtrl.h
 
 kdoc_headers = base.h formats.h rtppkt.h rtcppkt.h sources.h channel.h \
-	queuebase.h iqueue.h oqueue.h ioqueue.h cqueue.h ext.h CryptoContext.h
+	queuebase.h iqueue.h oqueue.h ioqueue.h cqueue.h ext.h CryptoContext.h CryptoContextCtrl.h
 
 all: all-am
 
@@ -285,8 +369,11 @@
 	-rm -rf .libs _libs
 install-ccxxincludeHEADERS: $(ccxxinclude_HEADERS)
 	@$(NORMAL_INSTALL)
-	test -z "$(ccxxincludedir)" || $(MKDIR_P) "$(DESTDIR)$(ccxxincludedir)"
 	@list='$(ccxxinclude_HEADERS)'; test -n "$(ccxxincludedir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(ccxxincludedir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(ccxxincludedir)" || exit 1; \
+	fi; \
 	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  echo "$$d$$p"; \
@@ -300,30 +387,17 @@
 	@$(NORMAL_UNINSTALL)
 	@list='$(ccxxinclude_HEADERS)'; test -n "$(ccxxincludedir)" || list=; \
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
-	test -n "$$files" || exit 0; \
-	echo " ( cd '$(DESTDIR)$(ccxxincludedir)' && rm -f" $$files ")"; \
-	cd "$(DESTDIR)$(ccxxincludedir)" && rm -f $$files
+	dir='$(DESTDIR)$(ccxxincludedir)'; $(am__uninstall_files_from_dir)
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -335,15 +409,11 @@
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -352,6 +422,21 @@
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -403,10 +488,15 @@
 
 installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
@@ -486,10 +576,10 @@
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libtool ctags distclean distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libtool cscopelist-am ctags ctags-am distclean \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
 	install-ccxxincludeHEADERS install-data install-data-am \
 	install-dvi install-dvi-am install-exec install-exec-am \
 	install-html install-html-am install-info install-info-am \
@@ -497,7 +587,7 @@
 	install-ps-am install-strip installcheck installcheck-am \
 	installdirs maintainer-clean maintainer-clean-generic \
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
-	ps ps-am tags uninstall uninstall-am \
+	ps ps-am tags tags-am uninstall uninstall-am \
 	uninstall-ccxxincludeHEADERS
 
 
diff --git a/jni/libccrtp/sources/src/ccrtp/Makefile.am b/jni/libccrtp/sources/src/ccrtp/Makefile.am
index bab1a4d..ca6e4a4 100644
--- a/jni/libccrtp/sources/src/ccrtp/Makefile.am
+++ b/jni/libccrtp/sources/src/ccrtp/Makefile.am
@@ -14,10 +14,10 @@
 
 ccxxinclude_HEADERS = base.h formats.h rtppkt.h rtcppkt.h sources.h channel.h \
 	queuebase.h iqueue.h oqueue.h ioqueue.h cqueue.h ext.h rtp.h pool.h \
-	CryptoContext.h
+	CryptoContext.h CryptoContextCtrl.h
 
 kdoc_headers = base.h formats.h rtppkt.h rtcppkt.h sources.h channel.h \
-	queuebase.h iqueue.h oqueue.h ioqueue.h cqueue.h ext.h CryptoContext.h
+	queuebase.h iqueue.h oqueue.h ioqueue.h cqueue.h ext.h CryptoContext.h CryptoContextCtrl.h
 
 kdoc:
 	kdoc -f html -d $(KDOC_DIR) -L$(KDOC_DIR) -n ccrtp $(kdoc_headers)
diff --git a/jni/libccrtp/sources/src/ccrtp/Makefile.in b/jni/libccrtp/sources/src/ccrtp/Makefile.in
index 1e1c4e3..f32459f 100644
--- a/jni/libccrtp/sources/src/ccrtp/Makefile.in
+++ b/jni/libccrtp/sources/src/ccrtp/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -27,6 +26,51 @@
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -47,8 +91,8 @@
 host_triplet = @host@
 target_triplet = @target@
 subdir = src/ccrtp
-DIST_COMMON = $(ccxxinclude_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(ccxxinclude_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libgcrypt_local.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -59,13 +103,30 @@
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_HEADER = $(top_builddir)/ccrtp-config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 depcomp =
 am__depfiles_maybe =
 SOURCES =
 DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -87,13 +148,37 @@
 am__base_list = \
   sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
   sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
 am__installdirs = "$(DESTDIR)$(ccxxincludedir)"
 HEADERS = $(ccxxinclude_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -102,8 +187,8 @@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMMON_CFLAGS = @COMMON_CFLAGS@
-COMMON_LIBS = @COMMON_LIBS@
+COMMONCPP_CFLAGS = @COMMONCPP_CFLAGS@
+COMMONCPP_LIBS = @COMMONCPP_LIBS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CXX = @CXX@
@@ -140,8 +225,6 @@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
-LIB_MAJOR = @LIB_MAJOR@
-LIB_VERSION = @LIB_VERSION@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
@@ -150,6 +233,7 @@
 LT_MINOR = @LT_MINOR@
 LT_RELEASE = @LT_RELEASE@
 LT_SUBVER = @LT_SUBVER@
+LT_VERSION = @LT_VERSION@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
@@ -239,10 +323,10 @@
 ccxxincludedir = $(includedir)/ccrtp
 ccxxinclude_HEADERS = base.h formats.h rtppkt.h rtcppkt.h sources.h channel.h \
 	queuebase.h iqueue.h oqueue.h ioqueue.h cqueue.h ext.h rtp.h pool.h \
-	CryptoContext.h
+	CryptoContext.h CryptoContextCtrl.h
 
 kdoc_headers = base.h formats.h rtppkt.h rtcppkt.h sources.h channel.h \
-	queuebase.h iqueue.h oqueue.h ioqueue.h cqueue.h ext.h CryptoContext.h
+	queuebase.h iqueue.h oqueue.h ioqueue.h cqueue.h ext.h CryptoContext.h CryptoContextCtrl.h
 
 all: all-am
 
@@ -285,8 +369,11 @@
 	-rm -rf .libs _libs
 install-ccxxincludeHEADERS: $(ccxxinclude_HEADERS)
 	@$(NORMAL_INSTALL)
-	test -z "$(ccxxincludedir)" || $(MKDIR_P) "$(DESTDIR)$(ccxxincludedir)"
 	@list='$(ccxxinclude_HEADERS)'; test -n "$(ccxxincludedir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(ccxxincludedir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(ccxxincludedir)" || exit 1; \
+	fi; \
 	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  echo "$$d$$p"; \
@@ -300,30 +387,17 @@
 	@$(NORMAL_UNINSTALL)
 	@list='$(ccxxinclude_HEADERS)'; test -n "$(ccxxincludedir)" || list=; \
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
-	test -n "$$files" || exit 0; \
-	echo " ( cd '$(DESTDIR)$(ccxxincludedir)' && rm -f" $$files ")"; \
-	cd "$(DESTDIR)$(ccxxincludedir)" && rm -f $$files
+	dir='$(DESTDIR)$(ccxxincludedir)'; $(am__uninstall_files_from_dir)
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -335,15 +409,11 @@
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -352,6 +422,21 @@
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -403,10 +488,15 @@
 
 installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
@@ -486,10 +576,10 @@
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libtool ctags distclean distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libtool cscopelist-am ctags ctags-am distclean \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
 	install-ccxxincludeHEADERS install-data install-data-am \
 	install-dvi install-dvi-am install-exec install-exec-am \
 	install-html install-html-am install-info install-info-am \
@@ -497,7 +587,7 @@
 	install-ps-am install-strip installcheck installcheck-am \
 	installdirs maintainer-clean maintainer-clean-generic \
 	mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
-	ps ps-am tags uninstall uninstall-am \
+	ps ps-am tags tags-am uninstall uninstall-am \
 	uninstall-ccxxincludeHEADERS
 
 
diff --git a/jni/libccrtp/sources/src/ccrtp/base.h b/jni/libccrtp/sources/src/ccrtp/base.h
index a162f46..a248f6a 100644
--- a/jni/libccrtp/sources/src/ccrtp/base.h
+++ b/jni/libccrtp/sources/src/ccrtp/base.h
@@ -1,27 +1,27 @@
 // Copyright (C) 2001-2005 Federico Montesino Pouzols <fedemp@altern.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 
+// along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// 
+//
 // As a special exception, you may use this file as part of a free software
 // library without restriction.  Specifically, if other files instantiate
 // templates or use macros or inline functions from this file, or you compile
 // this file and link it with other files to produce an executable, this
 // file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however    
+// the GNU General Public License.  This exception does not however
 // invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.    
+// the GNU General Public License.
 //
 // This exception applies only to the code released under the name GNU
 // ccRTP.  If you copy code from other releases into a copy of GNU
@@ -35,28 +35,27 @@
 // If you do not wish that, delete this exception notice.
 //
 
-#ifndef	CCXX_RTP_BASE_H_
+#ifndef CCXX_RTP_BASE_H_
 #define CCXX_RTP_BASE_H_
 
-#ifndef	CCXX_SOCKET_H_
-#include <cc++/config.h>
-#include <cc++/socket.h>
+#ifndef CCXX_SOCKET_H_
+#include <commoncpp/config.h>
+#include <commoncpp/socket.h>
+#include <commoncpp/udp.h>
 #endif
 
-#ifndef	CCXX_PACKING
+#ifndef CCXX_PACKING
 #if defined(__GNUC__)
 #define CCXX_PACKED
 #elif !defined(__hpux) && !defined(_AIX)
-#define CCXX_PACKED        
-#endif 
+#define CCXX_PACKED
+#endif
 #endif
 
-#ifdef CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
-/** 
- * @file base.h 
+/**
+ * @file base.h
  *
  * @short Base elements for RTP stacks: constants, types and global
  * functions.
@@ -78,7 +77,7 @@
  * @param to time interval, in microseconds.
  * @return the same time interval, as a timeval value.
  **/
-__EXPORT timeval 
+__EXPORT timeval
 microtimeout2Timeval(microtimeout_t to);
 
 /**
@@ -103,8 +102,8 @@
 inline microtimeout_t
 timevalDiff2microtimeout(const timeval& t1, const timeval& t2)
 {
-	return ((t1.tv_sec - t2.tv_sec) * 1000000ul) + 
-		(t1.tv_usec - t2.tv_usec);
+    return ((t1.tv_sec - t2.tv_sec) * 1000000ul) +
+        (t1.tv_usec - t2.tv_usec);
 }
 
 /// registered default RTP data transport port
@@ -113,16 +112,7 @@
 /// registered default RTCP transport port
 const tpport_t DefaultRTCPPort = 5005;
 
-#ifndef	HAVE_GETTIMEOFDAY
-#ifdef	WIN32
-__EXPORT int
-gettimeofday(struct timeval *tv_, void *tz_);
-#endif
-#endif
-
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  // ndef CCXX_RTP_BASE_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/channel.h b/jni/libccrtp/sources/src/ccrtp/channel.h
index c451d3e..7216823 100644
--- a/jni/libccrtp/sources/src/ccrtp/channel.h
+++ b/jni/libccrtp/sources/src/ccrtp/channel.h
@@ -1,27 +1,27 @@
 // Copyright (C) 2001-2005 Federico Montesino Pouzols <fedemp@altern.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 
+// along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// 
+//
 // As a special exception, you may use this file as part of a free software
 // library without restriction.  Specifically, if other files instantiate
 // templates or use macros or inline functions from this file, or you compile
 // this file and link it with other files to produce an executable, this
 // file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however    
+// the GNU General Public License.  This exception does not however
 // invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.    
+// the GNU General Public License.
 //
 // This exception applies only to the code released under the name GNU
 // ccRTP.  If you copy code from other releases into a copy of GNU
@@ -35,29 +35,28 @@
 // If you do not wish that, delete this exception notice.
 //
 
-#ifndef	CCRTP_CHANNEL_H_
+#ifndef CCRTP_CHANNEL_H_
 #define CCRTP_CHANNEL_H_
 
 #include <ccrtp/base.h>
+#include <commoncpp/socket.h>
 
-#ifndef WIN32
+#ifndef _MSWINDOWS_
 #include <sys/ioctl.h>
-inline size_t ccioctl(SOCKET so, int request, size_t& len) 
-{ return ::ioctl(so,request,&len); }
+inline size_t ccioctl(int so, int request, size_t& len)
+    { return ioctl(so,request,&len); }
 #else
 inline size_t ccioctl(SOCKET so, int request, size_t& len )
-{ 
-	unsigned long l; 
-	size_t result = 0;
-	::ioctlsocket(so,request,&l); 
-	len = l; 
-	return result;
+{
+    unsigned long l;
+    size_t result = 0;
+    ::ioctlsocket(so,request,&l);
+    len = l;
+    return result;
 }
 #endif
 
-#ifdef	CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @file channel.h
@@ -96,73 +95,73 @@
 class RTPBaseUDPIPv4Socket : private UDPSocket
 {
 public:
-	/**
-	 * Constructor for receiver.
-	 **/
-	RTPBaseUDPIPv4Socket(const InetAddress& ia, tpport_t port) :
-		UDPSocket(ia,port)
-	{ }
-	
-	inline ~RTPBaseUDPIPv4Socket()
-	{ endSocket(); }
-	
-	inline bool
-	isPendingRecv(microtimeout_t timeout)
-	{ return UDPSocket::isPending(UDPSocket::pendingInput, timeout); }
+    /**
+     * Constructor for receiver.
+     **/
+    RTPBaseUDPIPv4Socket(const InetAddress& ia, tpport_t port) :
+        UDPSocket(ia,port)
+    { }
 
-	inline InetHostAddress
-	getSender(tpport_t& port) const
-	{ return UDPSocket::getSender(&port); }
+    inline ~RTPBaseUDPIPv4Socket()
+    { endSocket(); }
 
-	inline size_t
-	recv(unsigned char* buffer, size_t len)
-	{ return UDPSocket::receive(buffer, len); }
+    inline bool
+    isPendingRecv(microtimeout_t timeout)
+    { return UDPSocket::isPending(UDPSocket::pendingInput, timeout); }
 
-	/**
-	 * Get size of next datagram waiting to be read.
-	 **/
-	inline size_t
-	getNextPacketSize() const
-	{ size_t len; ccioctl(UDPSocket::so,FIONREAD,len); return len; }
+    inline InetHostAddress
+    getSender(tpport_t& port) const
+    { return UDPSocket::getSender(&port); }
 
-	Socket::Error
-	setMulticast(bool enable)
-	{ return UDPSocket::setMulticast(enable); }
+    inline size_t
+    recv(unsigned char* buffer, size_t len)
+    { return UDPSocket::receive(buffer, len); }
 
-	inline Socket::Error
-	join(const InetMcastAddress& ia, uint32 iface)
-	{ return UDPSocket::join(ia,iface); }
+    /**
+     * Get size of next datagram waiting to be read.
+     **/
+    inline size_t
+    getNextPacketSize() const
+    { size_t len; ccioctl(UDPSocket::so,FIONREAD,len); return len; }
 
-	inline Socket::Error
-	drop(const InetMcastAddress& ia)
-	{ return UDPSocket::drop(ia); }
+    Socket::Error
+    setMulticast(bool enable)
+    { return UDPSocket::setMulticast(enable); }
 
-        inline Socket::Error 
-	setTimeToLive(unsigned char ttl)
-	{ return UDPSocket::setTimeToLive(ttl); }
- 
-	/**
-	 * Constructor for transmitter.
-	 **/
-	RTPBaseUDPIPv4Socket() :
-		UDPSocket()
-	{ }
+    inline Socket::Error
+    join(const InetMcastAddress& ia, uint32 iface)
+    { return UDPSocket::join(ia,iface); }
 
-	inline void 
-	setPeer(const InetAddress &ia, tpport_t port)
-		{UDPSocket::setPeer((InetHostAddress&)ia, port);}
+    inline Socket::Error
+    drop(const InetMcastAddress& ia)
+    { return UDPSocket::drop(ia); }
 
-	inline size_t
-	send(const unsigned char* const buffer, size_t len)
-	{ return UDPSocket::send(buffer, len); }
+        inline Socket::Error
+    setTimeToLive(unsigned char ttl)
+    { return UDPSocket::setTimeToLive(ttl); }
 
-	inline SOCKET getRecvSocket() const
-	{ return UDPSocket::so; }
+    /**
+     * Constructor for transmitter.
+     **/
+    RTPBaseUDPIPv4Socket() :
+        UDPSocket()
+    { }
 
-	// common
-	inline void
-	endSocket()
-	{ UDPSocket::endSocket(); }
+    inline void
+    setPeer(const InetAddress &ia, tpport_t port)
+        {UDPSocket::setPeer((InetHostAddress&)ia, port);}
+
+    inline size_t
+    send(const unsigned char* const buffer, size_t len)
+    { return UDPSocket::send(buffer, len); }
+
+    inline SOCKET getRecvSocket() const
+    { return UDPSocket::so; }
+
+    // common
+    inline void
+    endSocket()
+    { UDPSocket::endSocket(); }
 };
 
 /**
@@ -189,71 +188,71 @@
 class DualRTPChannel
 {
 public:
-	DualRTPChannel(const InetAddress& ia, tpport_t port)
-	{ 
-		recvSocket = new BaseSocket(ia,port);
-		sendSocket = new BaseSocket;
-	}
+    DualRTPChannel(const InetAddress& ia, tpport_t port)
+    {
+        recvSocket = new BaseSocket(ia,port);
+        sendSocket = new BaseSocket;
+    }
 
-	inline ~DualRTPChannel()
-	{ delete sendSocket; delete recvSocket; }
-	
-	inline bool
-	isPendingRecv(microtimeout_t timeout) const
-	{ return recvSocket->isPendingRecv(timeout); }
+    inline ~DualRTPChannel()
+    { delete sendSocket; delete recvSocket; }
 
-	inline InetHostAddress
-	getSender(tpport_t& port) const
-	{ return recvSocket->getSender(port); }
+    inline bool
+    isPendingRecv(microtimeout_t timeout) const
+    { return recvSocket->isPendingRecv(timeout); }
 
-	inline size_t
-	recv(unsigned char* buffer, size_t len)
-	{ return recvSocket->recv(buffer, len); }
+    inline InetHostAddress
+    getSender(tpport_t& port) const
+    { return recvSocket->getSender(port); }
 
-	inline size_t
-	getNextPacketSize() const
-	{ return recvSocket->getNextPacketSize(); }
+    inline size_t
+    recv(unsigned char* buffer, size_t len)
+    { return recvSocket->recv(buffer, len); }
 
-	inline Socket::Error
-	setMulticast(bool enable)
-	{ Socket::Error error = recvSocket->setMulticast(enable); 
-	  if (error) return error;
-	  return sendSocket->setMulticast(enable); }
+    inline size_t
+    getNextPacketSize() const
+    { return recvSocket->getNextPacketSize(); }
 
-	inline Socket::Error
-	join(const InetMcastAddress& ia, uint32 iface)
-	{ return recvSocket->join(ia,iface); }
+    inline Socket::Error
+    setMulticast(bool enable)
+    { Socket::Error error = recvSocket->setMulticast(enable);
+      if (error) return error;
+      return sendSocket->setMulticast(enable); }
 
-	inline Socket::Error
-	drop(const InetMcastAddress& ia)
-	{ return recvSocket->drop(ia); }
+    inline Socket::Error
+    join(const InetMcastAddress& ia, uint32 iface)
+    { return recvSocket->join(ia,iface); }
 
-        inline Socket::Error 
-	setTimeToLive(unsigned char ttl)
-	{ return sendSocket->setTimeToLive(ttl); }
- 
-	inline void 
-	setPeer(const InetAddress& host, tpport_t port)
-	{ sendSocket->setPeer(host,port); }
+    inline Socket::Error
+    drop(const InetMcastAddress& ia)
+    { return recvSocket->drop(ia); }
 
-	inline size_t
-	send(const unsigned char* const buffer, size_t len)		  
-	{ return sendSocket->send(buffer, len); }
+        inline Socket::Error
+    setTimeToLive(unsigned char ttl)
+    { return sendSocket->setTimeToLive(ttl); }
 
-	inline SOCKET getRecvSocket() const
-	{ return recvSocket->getRecvSocket(); }
+    inline void
+    setPeer(const InetAddress& host, tpport_t port)
+    { sendSocket->setPeer(host,port); }
 
-	// common.
-	inline void
-	endSocket()
-	{ sendSocket->endSocket(); recvSocket->endSocket(); }
+    inline size_t
+    send(const unsigned char* const buffer, size_t len)
+    { return sendSocket->send(buffer, len); }
+
+    inline SOCKET getRecvSocket() const
+    { return recvSocket->getRecvSocket(); }
+
+    // common.
+    inline void
+    endSocket()
+    { sendSocket->endSocket(); recvSocket->endSocket(); }
 
 private:
-	BaseSocket* sendSocket;
-	BaseSocket* recvSocket;
+    BaseSocket* sendSocket;
+    BaseSocket* recvSocket;
 };
 
-#ifdef	CCXX_IPV6
+#ifdef  CCXX_IPV6
 
 /**
  * @class RTPBaseUDPIPv4Socket
@@ -279,73 +278,73 @@
 class RTPBaseUDPIPv6Socket : private UDPSocket
 {
 public:
-	/**
-	 * Constructor for receiver.
-	 **/
-	RTPBaseUDPIPv6Socket(const IPV6Address& ia, tpport_t port) :
-		UDPSocket(ia,port)
-	{ }
-	
-	inline ~RTPBaseUDPIPv6Socket()
-	{ endSocket(); }
-	
-	inline bool
-	isPendingRecv(microtimeout_t timeout)
-	{ return UDPSocket::isPending(UDPSocket::pendingInput, timeout); }
+    /**
+     * Constructor for receiver.
+     **/
+    RTPBaseUDPIPv6Socket(const IPV6Address& ia, tpport_t port) :
+        UDPSocket(ia,port)
+    { }
 
-	inline IPV6Host
-	getSender(tpport_t& port) const
-	{ return UDPSocket::getIPV6Sender(&port); }
+    inline ~RTPBaseUDPIPv6Socket()
+    { endSocket(); }
 
-	inline size_t
-	recv(unsigned char* buffer, size_t len)
-	{ return UDPSocket::receive(buffer, len); }
+    inline bool
+    isPendingRecv(microtimeout_t timeout)
+    { return UDPSocket::isPending(UDPSocket::pendingInput, timeout); }
 
-	/**
-	 * Get size of next datagram waiting to be read.
-	 **/
-	inline size_t
-	getNextPacketSize() const
-	{ size_t len; ccioctl(UDPSocket::so,FIONREAD,len); return len; }
+    inline IPV6Host
+    getSender(tpport_t& port) const
+    { return UDPSocket::getIPV6Sender(&port); }
 
-	Socket::Error
-	setMulticast(bool enable)
-	{ return UDPSocket::setMulticast(enable); }
+    inline size_t
+    recv(unsigned char* buffer, size_t len)
+    { return UDPSocket::receive(buffer, len); }
 
-	inline Socket::Error
-	join(const IPV6Multicast& ia, uint32 iface)
-	{ return Socket::join(ia); }
+    /**
+     * Get size of next datagram waiting to be read.
+     **/
+    inline size_t
+    getNextPacketSize() const
+    { size_t len; ccioctl(UDPSocket::so,FIONREAD,len); return len; }
 
-	inline Socket::Error
-	drop(const IPV6Multicast& ia)
-	{ return UDPSocket::drop(ia); }
+    Socket::Error
+    setMulticast(bool enable)
+    { return UDPSocket::setMulticast(enable); }
 
-        inline Socket::Error 
-	setTimeToLive(unsigned char ttl)
-	{ return UDPSocket::setTimeToLive(ttl); }
- 
-	/**
-	 * Constructor for transmitter.
-	 **/
-	RTPBaseUDPIPv6Socket() :
-		UDPSocket()
-	{ }
+    inline Socket::Error
+    join(const IPV6Multicast& ia, uint32 iface)
+    { return Socket::join(ia); }
 
-	inline void 
-	setPeer(const IPV6Host &ia, tpport_t port)
-		{UDPSocket::setPeer(ia, port);}
+    inline Socket::Error
+    drop(const IPV6Multicast& ia)
+    { return UDPSocket::drop(ia); }
 
-	inline size_t
-	send(const unsigned char* const buffer, size_t len)
-	{ return UDPSocket::send(buffer, len); }
+        inline Socket::Error
+    setTimeToLive(unsigned char ttl)
+    { return UDPSocket::setTimeToLive(ttl); }
 
-	inline SOCKET getRecvSocket() const
-	{ return UDPSocket::so; }
+    /**
+     * Constructor for transmitter.
+     **/
+    RTPBaseUDPIPv6Socket() :
+        UDPSocket()
+    { }
 
-	// common
-	inline void
-	endSocket()
-	{ UDPSocket::endSocket(); }
+    inline void
+    setPeer(const IPV6Host &ia, tpport_t port)
+        {UDPSocket::setPeer(ia, port);}
+
+    inline size_t
+    send(const unsigned char* const buffer, size_t len)
+    { return UDPSocket::send(buffer, len); }
+
+    inline SOCKET getRecvSocket() const
+    { return UDPSocket::so; }
+
+    // common
+    inline void
+    endSocket()
+    { UDPSocket::endSocket(); }
 };
 
 /**
@@ -372,73 +371,73 @@
 class DualRTPChannelIPV6
 {
 public:
-	DualRTPChannelIPV6(const IPV6Host& ia, tpport_t port)
-	{ 
-		recvSocket = new BaseSocket(ia,port);
-		sendSocket = new BaseSocket;
-	}
+    DualRTPChannelIPV6(const IPV6Host& ia, tpport_t port)
+    {
+        recvSocket = new BaseSocket(ia,port);
+        sendSocket = new BaseSocket;
+    }
 
-	inline ~DualRTPChannelIPV6()
-	{ delete sendSocket; delete recvSocket; }
-	
-	inline bool
-	isPendingRecv(microtimeout_t timeout) const
-	{ return recvSocket->isPendingRecv(timeout); }
+    inline ~DualRTPChannelIPV6()
+    { delete sendSocket; delete recvSocket; }
 
-	inline IPV6Host
-	getSender(tpport_t& port) const
-	{ return recvSocket->getIPV6Sender(port); }
+    inline bool
+    isPendingRecv(microtimeout_t timeout) const
+    { return recvSocket->isPendingRecv(timeout); }
 
-	inline size_t
-	recv(unsigned char* buffer, size_t len)
-	{ return recvSocket->recv(buffer, len); }
+    inline IPV6Host
+    getSender(tpport_t& port) const
+    { return recvSocket->getIPV6Sender(port); }
 
-	inline size_t
-	getNextPacketSize() const
-	{ return recvSocket->getNextPacketSize(); }
+    inline size_t
+    recv(unsigned char* buffer, size_t len)
+    { return recvSocket->recv(buffer, len); }
 
-	inline Socket::Error
-	setMulticast(bool enable)
-	{ Socket::Error error = recvSocket->setMulticast(enable); 
-	  if (error) return error;
-	  return sendSocket->setMulticast(enable); }
+    inline size_t
+    getNextPacketSize() const
+    { return recvSocket->getNextPacketSize(); }
 
-	inline Socket::Error
-	join(const IPV6Multicast& ia, uint32 iface)
-	{ return recvSocket->join(ia,iface); }
+    inline Socket::Error
+    setMulticast(bool enable)
+    { Socket::Error error = recvSocket->setMulticast(enable);
+      if (error) return error;
+      return sendSocket->setMulticast(enable); }
 
-	inline Socket::Error
-	drop(const IPV6Multicast& ia)
-	{ return recvSocket->drop(ia); }
+    inline Socket::Error
+    join(const IPV6Multicast& ia, uint32 iface)
+    { return recvSocket->join(ia,iface); }
 
-        inline Socket::Error 
-	setTimeToLive(unsigned char ttl)
-	{ return sendSocket->setTimeToLive(ttl); }
- 
-	inline void 
-	setPeer(const IPV6Host& host, tpport_t port)
-	{ sendSocket->setPeer(host,port); }
+    inline Socket::Error
+    drop(const IPV6Multicast& ia)
+    { return recvSocket->drop(ia); }
 
-	inline size_t
-	send(const unsigned char* const buffer, size_t len)		  
-	{ return sendSocket->send(buffer, len); }
+        inline Socket::Error
+    setTimeToLive(unsigned char ttl)
+    { return sendSocket->setTimeToLive(ttl); }
 
-	inline SOCKET getRecvSocket() const
-	{ return recvSocket->getRecvSocket(); }
+    inline void
+    setPeer(const IPV6Host& host, tpport_t port)
+    { sendSocket->setPeer(host,port); }
 
-	// common.
-	inline void
-	endSocket()
-	{ sendSocket->endSocket(); recvSocket->endSocket(); }
+    inline size_t
+    send(const unsigned char* const buffer, size_t len)
+    { return sendSocket->send(buffer, len); }
+
+    inline SOCKET getRecvSocket() const
+    { return recvSocket->getRecvSocket(); }
+
+    // common.
+    inline void
+    endSocket()
+    { sendSocket->endSocket(); recvSocket->endSocket(); }
 
 private:
-	BaseSocket* sendSocket;
-	BaseSocket* recvSocket;
+    BaseSocket* sendSocket;
+    BaseSocket* recvSocket;
 };
 
 
-typedef DualRTPChannelIPV6<RTPBaseUDPIPv6Socket> DualRTPUDPIPv6Channel; 
-typedef	RTPBaseUDPIPv6Socket SingleRTPChannelIPV6;
+typedef DualRTPChannelIPV6<RTPBaseUDPIPv6Socket> DualRTPUDPIPv6Channel;
+typedef RTPBaseUDPIPv6Socket SingleRTPChannelIPV6;
 typedef SingleRTPChannelIPV6 SymmetricRTPChannelIPV6;
 
 #endif
@@ -458,9 +457,7 @@
 
 /** @}*/ // sockets
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  //CCRTP_CHANNEL_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/cqueue.h b/jni/libccrtp/sources/src/ccrtp/cqueue.h
index eebd21e..6187b7e 100644
--- a/jni/libccrtp/sources/src/ccrtp/cqueue.h
+++ b/jni/libccrtp/sources/src/ccrtp/cqueue.h
@@ -41,14 +41,14 @@
  * @short Generic RTCP control queues.
  **/
 
-#ifndef	CCXX_RTP_CQUEUE_H_
+#ifndef CCXX_RTP_CQUEUE_H_
 #define CCXX_RTP_CQUEUE_H_
 
 #include <ccrtp/ioqueue.h>
+#include <ccrtp/CryptoContextCtrl.h>
+#include <list>
 
-#ifdef	CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @defgroup cqueue Generic RTCP control queues.
@@ -78,545 +78,625 @@
  * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT QueueRTCPManager : public RTPDataQueue,
-	protected RTCPCompoundHandler
+    protected RTCPCompoundHandler
 {
 public:
-	/**
-	 * Get the most recent sender report received from a
-	 * synchronization source.
-	 *
-	 * @param src Synchronization source of the sender info.
-	 * @return Most recent sender info received from src.
-	 * @retval NULL when no sender report has been received from
-	 * the specified source.
-	 **/
-	RTCPSenderInfo* getMRSenderInfo(SyncSource& src);
+    /**
+     * Get the most recent sender report received from a
+     * synchronization source.
+     *
+     * @param src Synchronization source of the sender info.
+     * @return Most recent sender info received from src.
+     * @retval NULL when no sender report has been received from
+     * the specified source.
+     **/
+    RTCPSenderInfo* getMRSenderInfo(SyncSource& src);
 
-	/**
-	 * Ask for the info in the most recent receiver report about
-	 * the local source received from the source given as
-	 * parameter.
-	 *
-	 * @param srcFrom Source of the receiver info.
-	 * @return most recent receiver info received from src.
-	 * @retval NULL when no receiver report has been received from
-	 * the specified source.
-	 */
-	RTCPReceiverInfo* getMRReceiverInfo(SyncSource& srcFrom);
+    /**
+     * Ask for the info in the most recent receiver report about
+     * the local source received from the source given as
+     * parameter.
+     *
+     * @param srcFrom Source of the receiver info.
+     * @return most recent receiver info received from src.
+     * @retval NULL when no receiver report has been received from
+     * the specified source.
+     */
+    RTCPReceiverInfo* getMRReceiverInfo(SyncSource& srcFrom);
 
-	/**
-	 * Set how much time the stack will wait before deleting a
-	 * synchronization source that has sent an RTCP BYE packet.
-	 *
-	 * @param delay delay in microseconds.
-	 *
-	 * @note The default delay is 1000000 microseconds
-	 **/
-	void setLeavingDelay(microtimeout_t delay)
-	{ leavingDelay = delay; }
+    /**
+     * Set how much time the stack will wait before deleting a
+     * synchronization source that has sent an RTCP BYE packet.
+     *
+     * @param delay delay in microseconds.
+     *
+     * @note The default delay is 1000000 microseconds
+     **/
+    void setLeavingDelay(microtimeout_t delay)
+    { leavingDelay = delay; }
 
-	/**
-	 * This method sets the maximum end to end delay allowed. If
-	 * the processing delay plus the trip time for a packet is
-	 * greater than the end to end delay, the packet is discarded,
-	 * and the application cannot get it.
-	 *
-	 * This is a way of setting an upper bound to the end to end
-	 * delay, computed as the elapsed time between the packet
-	 * timestamping at the sender side, and the picking of the
-	 * packet at the receiver side.
-	 *
-	 * @param t maximum end to end delay allowed. A value of 0
-	 * implies there is no limit and is the default
-	 */
-	inline void
-	setEnd2EndDelay(microtimeout_t t)
-		{ end2EndDelay = t; }
+    /**
+     * This method sets the maximum end to end delay allowed. If
+     * the processing delay plus the trip time for a packet is
+     * greater than the end to end delay, the packet is discarded,
+     * and the application cannot get it.
+     *
+     * This is a way of setting an upper bound to the end to end
+     * delay, computed as the elapsed time between the packet
+     * timestamping at the sender side, and the picking of the
+     * packet at the receiver side.
+     *
+     * @param t maximum end to end delay allowed. A value of 0
+     * implies there is no limit and is the default
+     */
+    inline void
+    setEnd2EndDelay(microtimeout_t t)
+        { end2EndDelay = t; }
 
-	inline microtimeout_t
-	getDefaultEnd2EndDelay() const
-	{ return defaultEnd2EndDelay; }
+    inline microtimeout_t
+    getDefaultEnd2EndDelay() const
+    { return defaultEnd2EndDelay; }
 
-	inline microtimeout_t
-	getEnd2EndDelay() const
-	{ return end2EndDelay; }
+    inline microtimeout_t
+    getEnd2EndDelay() const
+    { return end2EndDelay; }
 
-	/**
-	 * Specify the fraction of the total control bandwith to be
-	 * dedicated to senders reports.
-	 *
-	 * @param fraction fraction of bandwidth, must be between 0 an 1.
-	 *
-	 * This method sets the fraction of the global control
-	 * bandwidth that will be dedicated to senders reports. Of
-	 * course, <code>1 - fraction</code> will be dedicated to
-	 * receivers reports.
-	 *
-	 * @see setControlBandwidth
-	 */
-	inline void
-	setSendersControlFraction(float fraction)
-	{ sendControlBwFract = fraction; recvControlBwFract = 1 - fraction;}
+    /**
+     * Specify the fraction of the total control bandwith to be
+     * dedicated to senders reports.
+     *
+     * @param fraction fraction of bandwidth, must be between 0 an 1.
+     *
+     * This method sets the fraction of the global control
+     * bandwidth that will be dedicated to senders reports. Of
+     * course, <code>1 - fraction</code> will be dedicated to
+     * receivers reports.
+     *
+     * @see setControlBandwidth
+     */
+    inline void
+    setSendersControlFraction(float fraction)
+    { sendControlBwFract = fraction; recvControlBwFract = 1 - fraction;}
 
-	/**
-	 * Manually set the minimum interval for sending RTP compound
-	 * packets
-	 *
-	 * @param interval minimum interval between RTCP packets, in
-	 * microseconds.
-	 *
-	 * @see computeRTCPInterval()
-	 **/
-	void
-	setMinRTCPInterval(microtimeout_t interval)
-	{ rtcpMinInterval = interval; }
+    /**
+     * Manually set the minimum interval for sending RTP compound
+     * packets
+     *
+     * @param interval minimum interval between RTCP packets, in
+     * microseconds.
+     *
+     * @see computeRTCPInterval()
+     **/
+    void
+    setMinRTCPInterval(microtimeout_t interval)
+    { rtcpMinInterval = interval; }
 
-	/**
-	 * Get the total number of RTCP packets sent until now
-	 **/
-	inline uint32
-	getSendRTCPPacketCount() const
-	{ return ctrlSendCount; }
+    /**
+     * Get the total number of RTCP packets sent until now
+     **/
+    inline uint32
+    getSendRTCPPacketCount() const
+    { return ctrlSendCount; }
+
+    /**
+     * Set ouput queue CryptoContext.
+     *
+     * The endQueue method (provided by RTPQueue) deletes all
+     * registered CryptoContexts.
+     *
+     * @param cc Pointer to initialized CryptoContext.
+     */
+    void
+    setOutQueueCryptoContextCtrl(CryptoContextCtrl* cc);
+
+    /**
+     * Remove output queue CryptoContext.
+     *
+     * The endQueue method (provided by RTPQueue) also deletes all
+     * registered CryptoContexts.
+     *
+     * @param cc Pointer to initialized CryptoContext to remove.
+     */
+    void
+    removeOutQueueCryptoContextCtrl(CryptoContextCtrl* cc);
+
+    /**
+     * Get an output queue CryptoContext identified by SSRC
+     *
+     * @param ssrc Request CryptoContext for this incoming SSRC
+     * @return Pointer to CryptoContext of the SSRC of NULL if no context
+     * available for this SSRC.
+     */
+    CryptoContextCtrl*
+    getOutQueueCryptoContextCtrl(uint32 ssrc);
+
+
+    /**
+     * Set input queue CryptoContext.
+     *
+     * The endQueue method (provided by RTPQueue) deletes all
+     * registered CryptoContexts.
+     *
+     * @param cc Pointer to initialized CryptoContext.
+     */
+    void
+    setInQueueCryptoContextCtrl(CryptoContextCtrl* cc);
+
+    /**
+     * Remove input queue CryptoContext.
+     *
+     * The endQueue method (provided by RTPQueue) also deletes all
+     * registered CryptoContexts.
+     *
+     * @param cc
+     *     Pointer to initialized CryptoContext to remove. If pointer
+     *     if <code>NULL</code> then delete the whole queue
+     */
+    void
+    removeInQueueCryptoContextCtrl(CryptoContextCtrl* cc);
+
+    /**
+     * Get an input queue CryptoContext identified by SSRC
+     *
+     * @param ssrc Request CryptoContext for this incoming SSRC
+     * @return Pointer to CryptoContext of the SSRC of NULL if no context
+     * available for this SSRC.
+     */
+    CryptoContextCtrl*
+    getInQueueCryptoContextCtrl(uint32 ssrc);
 
 protected:
-	QueueRTCPManager(uint32 size = RTPDataQueue::defaultMembersHashSize,
-			 RTPApplication& app = defaultApplication());
+    QueueRTCPManager(uint32 size = RTPDataQueue::defaultMembersHashSize,
+             RTPApplication& app = defaultApplication());
 
-	QueueRTCPManager(uint32 ssrc,
-			 uint32 size = RTPDataQueue::defaultMembersHashSize,
-			 RTPApplication& app = defaultApplication());
+    QueueRTCPManager(uint32 ssrc,
+             uint32 size = RTPDataQueue::defaultMembersHashSize,
+             RTPApplication& app = defaultApplication());
 
-	virtual
-	~QueueRTCPManager();
+    virtual
+    ~QueueRTCPManager();
 
-	const RTPApplication&
-	getApplication()
-	{ return queueApplication; }
+    const RTPApplication&
+    getApplication()
+    { return queueApplication; }
 
-	inline void
-	setControlBandwidth(float fraction)
-	{ controlBwFract = fraction; }
+    inline void
+    setControlBandwidth(float fraction)
+    { controlBwFract = fraction; }
 
-	float
-	getControlBandwidth() const
-	{ return controlBwFract; }
+    float
+    getControlBandwidth() const
+    { return controlBwFract; }
 
-	/**
-	 * Build and send RTCP packets following timing rules
-	 * (including the "timer reconsideration" algorithm).
-	 **/
-	void
-	controlTransmissionService();
+    /**
+     * Build and send RTCP packets following timing rules
+     * (including the "timer reconsideration" algorithm).
+     **/
+    void
+    controlTransmissionService();
 
-	/**
-	 * Process incoming RTCP packets pending in the control
-	 * reception socket.
-	 **/
-	void
-	controlReceptionService();
+    /**
+     * Process incoming RTCP packets pending in the control
+     * reception socket.
+     **/
+    void
+    controlReceptionService();
 
-	/**
-	 * Appy collision and loop detection and correction algorithm
-	 * when receiving RTCP packets. Follows section 8.2 in
-	 * draft-ietf-avp-rtp-new.
-	 *
-	 * @param sourceLink link to the source object.
-	 * @param is_new whether the source has been just recorded.
-	 * @param na RTCP packet network address.
-	 * @param tp RTCP packet source transport port.
-	 *
-	 * @return whether the packet must not be discarded.
-	 **/
-	bool checkSSRCInRTCPPkt(SyncSourceLink& sourceLink, bool is_new,
-				InetAddress& na, tpport_t tp);
+    /**
+     * Appy collision and loop detection and correction algorithm
+     * when receiving RTCP packets. Follows section 8.2 in
+     * draft-ietf-avp-rtp-new.
+     *
+     * @param sourceLink link to the source object.
+     * @param is_new whether the source has been just recorded.
+     * @param na RTCP packet network address.
+     * @param tp RTCP packet source transport port.
+     *
+     * @return whether the packet must not be discarded.
+     **/
+    bool checkSSRCInRTCPPkt(SyncSourceLink& sourceLink, bool is_new,
+                InetAddress& na, tpport_t tp);
 
-	void
-	endQueueRTCPManager();
+    void
+    endQueueRTCPManager();
 
-	/**
-	 * Plug-in for processing (acquire information carried in) an
-	 * incoming RTCP Sender Report. The default implementation in
-	 * this class only processes the sender information and the
-	 * receiver report blocks about the local source.
-	 *
-	 * @param source Synchronization source this report comes from.
-	 * @param SR Sender report structure.
-	 * @param blocks Number of report blocks in the packet.
-	 **/
-	virtual void
-	onGotSR(SyncSource& source, SendReport& SR, uint8 blocks);
+    /**
+     * Plug-in for processing (acquire information carried in) an
+     * incoming RTCP Sender Report. The default implementation in
+     * this class only processes the sender information and the
+     * receiver report blocks about the local source.
+     *
+     * @param source Synchronization source this report comes from.
+     * @param SR Sender report structure.
+     * @param blocks Number of report blocks in the packet.
+     **/
+    virtual void
+    onGotSR(SyncSource& source, SendReport& SR, uint8 blocks);
 
-	/**
-	 * Plug-in for processing (acquire information carried in) an
-	 * incoming RTCP Receiver Report. The default implementation
-	 * in this class only processes the receiver report blocks
-	 * about the local source.
-	 *
-	 * @param source Synchronization source this report comes from.
-	 * @param RR Receiver report structure
-	 * @param blocks Number of report blocks in the packet
-	 **/
-	virtual void
-	onGotRR(SyncSource& source, RecvReport& RR, uint8 blocks);
+    /**
+     * Plug-in for processing (acquire information carried in) an
+     * incoming RTCP Receiver Report. The default implementation
+     * in this class only processes the receiver report blocks
+     * about the local source.
+     *
+     * @param source Synchronization source this report comes from.
+     * @param RR Receiver report structure
+     * @param blocks Number of report blocks in the packet
+     **/
+    virtual void
+    onGotRR(SyncSource& source, RecvReport& RR, uint8 blocks);
 
-	/**
-	 * @param source Synchronization source of SDES RTCP packet.
-	 * @param pkt SDES RTCP packet received.
-	 **/
-	bool
-	onGotSDES(SyncSource& source, RTCPPacket& pkt);
+    /**
+     * @param source Synchronization source of SDES RTCP packet.
+     * @param pkt SDES RTCP packet received.
+     **/
+    bool
+    onGotSDES(SyncSource& source, RTCPPacket& pkt);
 
-	/**
-	 * Plug-in for handling of SDES chunks.
-	 *
-	 * @param source Synchronization source of SDES chunk.
-	 * @param chunk SDES chunk structure.
-	 * @param len Length of chunk, in octets.
-	 *
-	 * @return whether there was a CNAME.
-	 **/
-	virtual bool
-	onGotSDESChunk(SyncSource& source, SDESChunk& chunk, size_t len);
+    /**
+     * Plug-in for handling of SDES chunks.
+     *
+     * @param source Synchronization source of SDES chunk.
+     * @param chunk SDES chunk structure.
+     * @param len Length of chunk, in octets.
+     *
+     * @return whether there was a CNAME.
+     **/
+    virtual bool
+    onGotSDESChunk(SyncSource& source, SDESChunk& chunk, size_t len);
 
-	/**
-	 * Plug-in for handling of APP (application specific) RTCP
-	 * packets.
-	 *
-	 * @param - Synchronization source of this packet.
-	 * @param - RTCP APP packet struct.
-	 * @param - Length of the app data packet, including ssrc.
-	 * name and app. specific data.
-	 **/
-	inline virtual void
-	onGotAPP(SyncSource&, RTCPCompoundHandler::APPPacket&,
-		 size_t)
-	{ return; }
+    /**
+     * Plug-in for handling of APP (application specific) RTCP
+     * packets.
+     *
+     * @param - Synchronization source of this packet.
+     * @param - RTCP APP packet struct.
+     * @param - Length of the app data packet, including ssrc.
+     * name and app. specific data.
+     **/
+    inline virtual void
+    onGotAPP(SyncSource&, RTCPCompoundHandler::APPPacket&,
+         size_t)
+    { return; }
 
-	inline timeval
-	getRTCPCheckInterval()
-	{ return rtcpCheckInterval; }
+    inline timeval
+    getRTCPCheckInterval()
+    { return rtcpCheckInterval; }
 
-	/**
-	 * Get the number of data packets sent at the time the last SR
-	 * was generated.
-	 **/
-	uint32
-	getLastSendPacketCount() const
-	{ return lastSendPacketCount; }
+    /**
+     * Get the number of data packets sent at the time the last SR
+     * was generated.
+     **/
+    uint32
+    getLastSendPacketCount() const
+    { return lastSendPacketCount; }
 
-	/**
-	 * @param n Number of members.
-	 **/
-	inline void
-	setPrevMembersNum(uint32 n)
-	{ reconsInfo.rtcpPMembers = n; }
+    /**
+     * @param n Number of members.
+     **/
+    inline void
+    setPrevMembersNum(uint32 n)
+    { reconsInfo.rtcpPMembers = n; }
 
-	inline uint32
-	getPrevMembersCount() const
-	{ return reconsInfo.rtcpPMembers; }
+    inline uint32
+    getPrevMembersCount() const
+    { return reconsInfo.rtcpPMembers; }
 
-	/**
-	 * This method is used to send an RTCP BYE packet.  An RTCP
-	 * BYE packet is sent when one of the the following
-	 * circumstances occur:
-	 * - when leaving the session
-	 * - when we have detected that another synchronization source
-	 * in the same session is using the same SSRC identifier as
-	 * us.
-	 *
-	 * Try to post a BYE message. It will send a BYE packet as
-	 * long as at least one RTP or RTCP packet has been sent
-	 * before. If the number of members in the session is more
-	 * than 50, the algorithm described in section 6.3.7 of
-	 * RFC 3550 is applied in order to avoid a flood
-	 * of BYE messages.
-	 *
-	 * @param reason reason to specify in the BYE packet.
-	 **/
-	size_t
-	dispatchBYE(const std::string& reason);
+    /**
+     * This method is used to send an RTCP BYE packet.  An RTCP
+     * BYE packet is sent when one of the the following
+     * circumstances occur:
+     * - when leaving the session
+     * - when we have detected that another synchronization source
+     * in the same session is using the same SSRC identifier as
+     * us.
+     *
+     * Try to post a BYE message. It will send a BYE packet as
+     * long as at least one RTP or RTCP packet has been sent
+     * before. If the number of members in the session is more
+     * than 50, the algorithm described in section 6.3.7 of
+     * RFC 3550 is applied in order to avoid a flood
+     * of BYE messages.
+     *
+     * @param reason reason to specify in the BYE packet.
+     **/
+    size_t
+    dispatchBYE(const std::string& reason);
 
-	size_t
-	sendControlToDestinations(unsigned char* buffer, size_t len);
+    size_t
+    sendControlToDestinations(unsigned char* buffer, size_t len);
 
 private:
-	QueueRTCPManager(const QueueRTCPManager &o);
+    QueueRTCPManager(const QueueRTCPManager &o);
 
-	QueueRTCPManager&
-	operator=(const QueueRTCPManager &o);
+    QueueRTCPManager&
+    operator=(const QueueRTCPManager &o);
 
-	/**
-	 * Posting of RTCP messages.
-	 *
-	 * @return std::size_t number of octets sent
-	 */
-	size_t
-	dispatchControlPacket();
+    /**
+     * Posting of RTCP messages.
+     *
+     * @return std::size_t number of octets sent
+     */
+    size_t
+    dispatchControlPacket();
 
-	/**
-	 * For picking up incoming RTCP packets if they are waiting. A
-	 * timeout for the maximum interval since the last RTCP packet
-	 * had been received is also returned. This is checked every
-	 * rtcpCheckInterval seconds.
-	 *
-	 * This method decomposes all incoming RTCP compound packets
-	 * pending in the control socket and processes each RTCP
-	 * packet.
-	 *
-	 **/
-	void
-	takeInControlPacket();
+    /**
+     * For picking up incoming RTCP packets if they are waiting. A
+     * timeout for the maximum interval since the last RTCP packet
+     * had been received is also returned. This is checked every
+     * rtcpCheckInterval seconds.
+     *
+     * This method decomposes all incoming RTCP compound packets
+     * pending in the control socket and processes each RTCP
+     * packet.
+     *
+     **/
+    void
+    takeInControlPacket();
 
-	/**
-	 * Computes the interval for sending RTCP compound packets,
-	 * based on the average size of RTCP packets sent and
-	 * received, and the current estimated number of participants
-	 * in the session.
-	 *
-	 * @note This currently follows the rules in section 6 of
-	 *       RFC 3550
-	 * @todo make it more flexible as recommended in the draft. For now,
-	 * we have setMinRTCPInterval.
-	 *
-	 * @return interval for sending RTCP compound packets
-	 **/
-	virtual timeval
-	computeRTCPInterval();
+    /**
+     * Computes the interval for sending RTCP compound packets,
+     * based on the average size of RTCP packets sent and
+     * received, and the current estimated number of participants
+     * in the session.
+     *
+     * @note This currently follows the rules in section 6 of
+     *       RFC 3550
+     * @todo make it more flexible as recommended in the draft. For now,
+     * we have setMinRTCPInterval.
+     *
+     * @return interval for sending RTCP compound packets
+     **/
+    virtual timeval
+    computeRTCPInterval();
 
-	/**
-	 * Choose which should be the type of the next SDES item
-	 * sent. This method is called when packing SDES chunks in a
-	 * new RTCP packet.
-	 *
-	 * @return type of the next SDES item to be sent
-	 **/
-	virtual SDESItemType
-	scheduleSDESItem();
+    /**
+     * Choose which should be the type of the next SDES item
+     * sent. This method is called when packing SDES chunks in a
+     * new RTCP packet.
+     *
+     * @return type of the next SDES item to be sent
+     **/
+    virtual SDESItemType
+    scheduleSDESItem();
 
-	/**
-	 * Plug-in for SSRC collision handling.
-	 *
-	 * @param - previously identified source.
-	 **/
-	inline virtual void
-	onSSRCCollision(const SyncSource&)
-	{ }
+    /**
+     * Plug-in for SSRC collision handling.
+     *
+     * @param - previously identified source.
+     **/
+    inline virtual void
+    onSSRCCollision(const SyncSource&)
+    { }
 
-	/**
-	 * Virtual reimplemented from RTPDataQueue
-	 **/
-	virtual bool
-	end2EndDelayed(IncomingRTPPktLink& p);
+    /**
+     * Virtual reimplemented from RTPDataQueue
+     **/
+    virtual bool
+    end2EndDelayed(IncomingRTPPktLink& p);
 
-	/**
-	 * Plug-in for processing of SR/RR RTCP packet
-	 * profile-specific extensions (third part of SR reports or
-	 * second part of RR reports).
-	 *
-	 * @param - Content of the profile extension.
-	 * @param - Length of the extension, in octets.
-	 **/
-	inline virtual void
-	onGotRRSRExtension(unsigned char*, size_t)
-	{ return; }
+    /**
+     * Plug-in for processing of SR/RR RTCP packet
+     * profile-specific extensions (third part of SR reports or
+     * second part of RR reports).
+     *
+     * @param - Content of the profile extension.
+     * @param - Length of the extension, in octets.
+     **/
+    inline virtual void
+    onGotRRSRExtension(unsigned char*, size_t)
+    { return; }
 
- 	/**
- 	 * A plugin point for goodbye message.  Called when a BYE RTCP
- 	 * packet has been received from a valid synchronization
- 	 * source.
-	 *
-	 * @param - synchronization source from what a BYE RTCP
-	 * packet has been just received.
-	 * @param - reason string the source has provided.
- 	 **/
- 	inline virtual void
-	onGotGoodbye(const SyncSource&, const std::string&)
-	{ return; }
+    /**
+     * A plugin point for goodbye message.  Called when a BYE RTCP
+     * packet has been received from a valid synchronization
+     * source.
+     *
+     * @param - synchronization source from what a BYE RTCP
+     * packet has been just received.
+     * @param - reason string the source has provided.
+     **/
+    inline virtual void
+    onGotGoodbye(const SyncSource&, const std::string&)
+    { return; }
 
-	/**
-	 * Process a BYE packet just received and identified.
-	 *
-	 * @param pkt previously identified RTCP BYE packet
-	 * @param pointer octet number in the RTCP reception buffer
-	 *        where the packet is stored
-	 * @param len total length of the compount RTCP packet the BYE
-	 *        packet to process is contained
-	 *
-	 * @bug if the bye packet contains several SSRCs,
-	 *      eventSourceLeaving is only called for the last one
-	 **/
-	bool
-	getBYE(RTCPPacket &pkt, size_t &pointer, size_t len);
+    /**
+     * Process a BYE packet just received and identified.
+     *
+     * @param pkt previously identified RTCP BYE packet
+     * @param pointer octet number in the RTCP reception buffer
+     *        where the packet is stored
+     * @param len total length of the compount RTCP packet the BYE
+     *        packet to process is contained
+     *
+     * @bug if the bye packet contains several SSRCs,
+     *      eventSourceLeaving is only called for the last one
+     **/
+    bool
+    getBYE(RTCPPacket &pkt, size_t &pointer, size_t len);
 
-	/**
-	 * @return number of Report Blocks packed
-	 **/
-	uint8
-	packReportBlocks(RRBlock* blocks, uint16& len, uint16& available);
+    /**
+     * @return number of Report Blocks packed
+     **/
+    uint8
+    packReportBlocks(RRBlock* blocks, uint16& len, uint16& available);
 
-	/**
-	 * Builds an SDES RTCP packet. Each chunk is built following
-	 * appendix A.4 in draft-ietf-avt-rtp-new.
-	 *
-	 * @param len provisionary length of the RTCP compound packet
-	 *
-	 * @return
-	 **/
-	void
-	packSDES(uint16& len);
+    /**
+     * Builds an SDES RTCP packet. Each chunk is built following
+     * appendix A.4 in draft-ietf-avt-rtp-new.
+     *
+     * @param len provisionary length of the RTCP compound packet
+     *
+     * @return
+     **/
+    void
+    packSDES(uint16& len);
 
-	/**
-	 * This must be called in order to update the average RTCP compound
-	 * packet size estimation when:
-	 *
-	 * a compoung RTCP packet is received (6.3.3).
-	 *
-	 * a compound RTCP packet is transmitted (6.3.6).
-	 *
-	 * @param len length in octets of the compound RTCP packet
-	 * just received/transmitted.
-	 **/
-	void
-	updateAvgRTCPSize(size_t len);
+    /**
+     * This must be called in order to update the average RTCP compound
+     * packet size estimation when:
+     *
+     * a compoung RTCP packet is received (6.3.3).
+     *
+     * a compound RTCP packet is transmitted (6.3.6).
+     *
+     * @param len length in octets of the compound RTCP packet
+     * just received/transmitted.
+     **/
+    void
+    updateAvgRTCPSize(size_t len);
 
-	/**
-	 * Apply reverse reconsideration adjustment to timing
-	 * parameters when receiving BYE packets and not waiting to
-	 * send a BYE.
-	 **/
-	void
-	reverseReconsideration();
+    /**
+     * Apply reverse reconsideration adjustment to timing
+     * parameters when receiving BYE packets and not waiting to
+     * send a BYE.
+     **/
+    void
+    reverseReconsideration();
 
-	bool
-	timerReconsideration();
+    bool
+    timerReconsideration();
 
-	/**
-	 * Purge sources that do not seem active any more.
-	 *
-	 * @note MUST be perform at least every RTCP transmission
-	 *       interval
-	 * @todo implement it. It may be dangerous and anyway should
-	 * be optional.
-	 **/
-	void
-	expireSSRCs();
+    /**
+     * Purge sources that do not seem active any more.
+     *
+     * @note MUST be perform at least every RTCP transmission
+     *       interval
+     * @todo implement it. It may be dangerous and anyway should
+     * be optional.
+     **/
+    void
+    expireSSRCs();
 
-	/**
-	 * To be executed when whe are leaving the session.
-	 **/
-	void
-	getOnlyBye();
+    /**
+     * To be executed when whe are leaving the session.
+     **/
+    void
+    getOnlyBye();
 
-	/**
-	 * Set item value from a string without null termination (as
-	 * it is transported in RTCP packets).
-	 **/
-	void
-	setSDESItem(Participant* part, SDESItemType type,
-		    const char* const value, size_t len);
+    /**
+     * Set item value from a string without null termination (as
+     * it is transported in RTCP packets).
+     **/
+    void
+    setSDESItem(Participant* part, SDESItemType type,
+            const char* const value, size_t len);
 
-	/**
-	 * Set PRIV item previx value from a string without null
-	 * termination (as it is transported in RTCP packets).
-	 **/
-	void
-	setPRIVPrefix(Participant* part, const char* const value, size_t len);
+    /**
+     * Set PRIV item previx value from a string without null
+     * termination (as it is transported in RTCP packets).
+     **/
+    void
+    setPRIVPrefix(Participant* part, const char* const value, size_t len);
 
-	/**
-	 * For certain control calculations in RTCP, the size of the
-	 * underlying network and transport protocols is needed. This
-	 * method provides the size of the network level header for
-	 * the default case of IP (20 octets). In case other protocol
-	 * with different header size is used, this method should be
-	 * redefined in a new specialized class.
-	 *
-	 * @return size of the headers of the network level. IP (20) by
-	 *        default.
-	 **/
-	inline virtual uint16
-	networkHeaderSize()
-	{ return 20; }
+    /**
+     * For certain control calculations in RTCP, the size of the
+     * underlying network and transport protocols is needed. This
+     * method provides the size of the network level header for
+     * the default case of IP (20 octets). In case other protocol
+     * with different header size is used, this method should be
+     * redefined in a new specialized class.
+     *
+     * @return size of the headers of the network level. IP (20) by
+     *        default.
+     **/
+    inline virtual uint16
+    networkHeaderSize()
+    { return 20; }
 
-	/**
-	 * For certain control calculations in RTCP, the size of the
-	 * underlying network and transport protocols is needed. This
-	 * method provides the size of the transport level header for
-	 * the default case of UDP (8 octets). In case other protocol
-	 * with different header size is used, this method should be
-	 * redefined in a new specialized class.
-	 *
-	 * return size of the headers of the transport level. UDP (8)
-	 *        by default
-	 **/
-	inline virtual uint16
-	transportHeaderSize()
-	{ return 8; }
+    /**
+     * For certain control calculations in RTCP, the size of the
+     * underlying network and transport protocols is needed. This
+     * method provides the size of the transport level header for
+     * the default case of UDP (8 octets). In case other protocol
+     * with different header size is used, this method should be
+     * redefined in a new specialized class.
+     *
+     * return size of the headers of the transport level. UDP (8)
+     *        by default
+     **/
+    inline virtual uint16
+    transportHeaderSize()
+    { return 8; }
 
-	SDESItemType
-	nextSDESType(SDESItemType t);
 
-	virtual size_t
-	sendControl(const unsigned char* const buffer, size_t len) = 0;
+    int32 protect(uint8* pkt, size_t len, CryptoContextCtrl* cc);
+    int32 unprotect(uint8* pkt, size_t len, CryptoContextCtrl* cc);
+    
+    
+    SDESItemType
+    nextSDESType(SDESItemType t);
 
-	virtual size_t
-	recvControl(unsigned char* buffer, size_t len,
-		    InetHostAddress& na, tpport_t& tp) = 0;
+    virtual size_t
+    sendControl(const unsigned char* const buffer, size_t len) = 0;
 
-	virtual bool
-	isPendingControl(microtimeout_t timeout) = 0;
+    virtual size_t
+    recvControl(unsigned char* buffer, size_t len,
+            InetHostAddress& na, tpport_t& tp) = 0;
 
-	// whether the RTCP service is active
-	volatile bool controlServiceActive;
-	float controlBwFract, sendControlBwFract, recvControlBwFract;
-	// number of RTCP packets sent since the beginning
-	uint32 ctrlSendCount;
+    virtual bool
+    isPendingControl(microtimeout_t timeout) = 0;
 
-	// Network + transport headers size, typically size of IP +
-	// UDP headers
-	uint16 lowerHeadersSize;
+    // whether the RTCP service is active
+    volatile bool controlServiceActive;
+    float controlBwFract, sendControlBwFract, recvControlBwFract;
+    // number of RTCP packets sent since the beginning
+    uint32 ctrlSendCount;
 
-	SDESItemType nextScheduledSDESItem;
-	static const SDESItemType firstSchedulable;
-	static const SDESItemType lastSchedulable;
+    // Network + transport headers size, typically size of IP +
+    // UDP headers
+    uint16 lowerHeadersSize;
 
-	// state for rtcp timing. Its meaning is defined in
-	// draft-ietf-avt-rtp-new, 6.3.
+    SDESItemType nextScheduledSDESItem;
+    static const SDESItemType firstSchedulable;
+    static const SDESItemType lastSchedulable;
 
-	// Parameters for timer reconsideration algorithm
-	struct {
-		timeval rtcpTp, rtcpTc, rtcpTn;
-		uint32 rtcpPMembers;
-	} reconsInfo;
-	bool rtcpWeSent;
-	uint16 rtcpAvgSize;
-	bool rtcpInitial;
-	// last time we checked if there were incoming RTCP packets
-	timeval rtcpLastCheck;
-	// interval to check if there are incoming RTCP packets
-	timeval rtcpCheckInterval;
-	// next time to check if there are incoming RTCP packets
-	timeval rtcpNextCheck;
+    // state for rtcp timing. Its meaning is defined in
+    // draft-ietf-avt-rtp-new, 6.3.
 
-	// number of RTP data packets sent at the time of the last
-	// RTCP packet transmission.
-	uint32 lastSendPacketCount;
+    // Parameters for timer reconsideration algorithm
+    struct {
+        timeval rtcpTp, rtcpTc, rtcpTn;
+        uint32 rtcpPMembers;
+    } reconsInfo;
+    bool rtcpWeSent;
+    uint16 rtcpAvgSize;
+    bool rtcpInitial;
+    // last time we checked if there were incoming RTCP packets
+    timeval rtcpLastCheck;
+    // interval to check if there are incoming RTCP packets
+    timeval rtcpCheckInterval;
+    // next time to check if there are incoming RTCP packets
+    timeval rtcpNextCheck;
 
-	// minimum interval for transmission of RTCP packets. The
-	// result of computeRTCPInterval will always be >= (times a
-	// random number between 0.5 and 1.5).
-	microtimeout_t rtcpMinInterval;
+    // number of RTP data packets sent at the time of the last
+    // RTCP packet transmission.
+    uint32 lastSendPacketCount;
 
-	microtimeout_t leavingDelay;
-	static const microtimeout_t defaultEnd2EndDelay;
-	// Maximum delay allowed between packet timestamping and
-	// packet availability for the application.
-	microtimeout_t end2EndDelay;
-	// Application this queue is bound to.
-	RTPApplication& queueApplication;
+    // minimum interval for transmission of RTCP packets. The
+    // result of computeRTCPInterval will always be >= (times a
+    // random number between 0.5 and 1.5).
+    microtimeout_t rtcpMinInterval;
 
-	// an empty RTPData
-	static const uint16 TIMEOUT_MULTIPLIER;
-	static const double RECONSIDERATION_COMPENSATION;
+    microtimeout_t leavingDelay;
+    static const microtimeout_t defaultEnd2EndDelay;
+    // Maximum delay allowed between packet timestamping and
+    // packet availability for the application.
+    microtimeout_t end2EndDelay;
+    // Application this queue is bound to.
+    RTPApplication& queueApplication;
+
+    // an empty RTPData
+    static const uint16 TIMEOUT_MULTIPLIER;
+    static const double RECONSIDERATION_COMPENSATION;
+    
+    mutable Mutex outCryptoMutex;
+    std::list<CryptoContextCtrl *> outCryptoContexts;
+    uint32 srtcpIndex;
+
+    mutable Mutex inCryptoMutex;
+    std::list<CryptoContextCtrl *> inCryptoContexts;
+
 };
 
 /**
@@ -626,55 +706,53 @@
  *
  * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
-class AVPQueue : public QueueRTCPManager
+class __EXPORT AVPQueue : public QueueRTCPManager
 {
 public:
-	/**
-	 * Specify the bandwith available for control (RTCP) packets.
-	 * This method sets the global control bandwidth for both
-	 * sender and receiver reports. As recommended in RFC 1890,
-	 * 1/4 of the total control bandwidth is dedicated to senders,
-	 * whereas 3/4 are dedicated to receivers.
-	 *
-	 * @param fraction fraction of the session bandwidth, between
-	 * 0 and 1
-	 *
-	 * @note If this method is not called, it is assumed that the
-	 * control bandwidth is equal to 5% of the session
-	 * bandwidth. Note also that the RFC RECOMMENDS the 5%.
-	 *
-	 **/
-	inline void
-	setControlBandwidth(float fraction)
-	{ QueueRTCPManager::setControlBandwidth(fraction); }
+    /**
+     * Specify the bandwith available for control (RTCP) packets.
+     * This method sets the global control bandwidth for both
+     * sender and receiver reports. As recommended in RFC 1890,
+     * 1/4 of the total control bandwidth is dedicated to senders,
+     * whereas 3/4 are dedicated to receivers.
+     *
+     * @param fraction fraction of the session bandwidth, between
+     * 0 and 1
+     *
+     * @note If this method is not called, it is assumed that the
+     * control bandwidth is equal to 5% of the session
+     * bandwidth. Note also that the RFC RECOMMENDS the 5%.
+     *
+     **/
+    inline void
+    setControlBandwidth(float fraction)
+    { QueueRTCPManager::setControlBandwidth(fraction); }
 
-	float
-	getControlBandwidth() const
-	{ return QueueRTCPManager::getControlBandwidth(); }
+    float
+    getControlBandwidth() const
+    { return QueueRTCPManager::getControlBandwidth(); }
 
 protected:
-	AVPQueue(uint32 size = RTPDataQueue::defaultMembersHashSize,
-		 RTPApplication& app = defaultApplication()) :
-		QueueRTCPManager(size,app)
-	{ }
+    AVPQueue(uint32 size = RTPDataQueue::defaultMembersHashSize,
+         RTPApplication& app = defaultApplication()) :
+        QueueRTCPManager(size,app)
+    { }
 
-	/**
-	 * Local SSRC is given instead of computed by the queue.
-	 **/
-	AVPQueue(uint32 ssrc, uint32 size =
-		 RTPDataQueue::defaultMembersHashSize,
-		 RTPApplication& app = defaultApplication()) :
- 		QueueRTCPManager(ssrc,size,app)
-	{ }
-	inline virtual ~AVPQueue()
-	{ }
+    /**
+     * Local SSRC is given instead of computed by the queue.
+     **/
+    AVPQueue(uint32 ssrc, uint32 size =
+         RTPDataQueue::defaultMembersHashSize,
+         RTPApplication& app = defaultApplication()) :
+        QueueRTCPManager(ssrc,size,app)
+    { }
+    inline virtual ~AVPQueue()
+    { }
 };
 
 /** @}*/ // cqueue
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  //CCXX_RTP_CQUEUE_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/AesSrtp.h b/jni/libccrtp/sources/src/ccrtp/crypto/AesSrtp.h
deleted file mode 100644
index 5566be4..0000000
--- a/jni/libccrtp/sources/src/ccrtp/crypto/AesSrtp.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/*

-  Copyright (C) 2005, 2004 Erik Eliasson, Johan Bilien

-

-  This library is free software; you can redistribute it and/or

-  modify it under the terms of the GNU Lesser General Public

-  License as published by the Free Software Foundation; either

-  version 2.1 of the License, or (at your option) any later version.

-

-  This library 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

-  Lesser General Public License for more details.

-

-  You should have received a copy of the GNU Lesser General Public

-  License along with this library; if not, write to the Free Software

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

-

- * In addition, as a special exception, the copyright holders give

- * permission to link the code of portions of this program with the

- * OpenSSL library under certain conditions as described in each

- * individual source file, and distribute linked combinations

- * including the two.

- * You must obey the GNU General Public License in all respects

- * for all of the code used other than OpenSSL.  If you modify

- * file(s) with this exception, you may extend this exception to your

- * version of the file(s), but you are not obligated to do so.  If you

- * do not wish to do so, delete this exception statement from your

- * version.  If you delete this exception statement from all source

- * files in the program, then also delete it here.

-*/

-

-/**

- * Implments the SRTP encryption modes as defined in RFC3711

- *

- * The SRTP specification defines two encryption modes, AES-CTR

- * (AES Counter mode) and AES-F8 mode. The AES-CTR is required,

- * AES-F8 is optional.

- *

- * Both modes are desinged to encrypt/decrypt data of arbitrary length

- * (with a specified upper limit, refer to RFC 3711). These modes do

- * <em>not</em> require that the amount of data to encrypt is a multiple

- * of the AES blocksize (128byte), no padding is necessary.

- *

- * The implementation uses the openSSL library as its cryptographic

- * backend.

- *

- * @author Erik Eliasson <eliasson@it.kth.se>

- * @author Johan Bilien <jobi@via.ecp.fr>

- * @author Werner Dittmann <Werner.Dittmann@t-online.de>

- */

-

-

-#ifndef AESSRTP_H

-#define AESSRTP_H

-

-#include <cc++/config.h>

-

-#include <ccrtp/CryptoContext.h>

-

-#ifndef SRTP_BLOCK_SIZE

-#define SRTP_BLOCK_SIZE 16

-#endif

-

-typedef struct _f8_ctx {

-    unsigned char *S;

-    unsigned char *ivAccent;

-    uint32_t J;

-} F8_CIPHER_CTX;

-

-

-class __EXPORT AesSrtp {

-public:

-    AesSrtp(int algo = SrtpEncryptionAESCM);

-    AesSrtp(uint8* key, int32 key_length, int algo = SrtpEncryptionAESCM);

-    ~AesSrtp();

-

-    /**

-     * Encrypts the inpout to the output.

-     *

-     * Encrypts one input block to one output block. Each block

-     * is 16 bytes according to the AES encryption algorithm used.

-     *

-     * @param input

-     *    Pointer to input block, must be 16 bytes

-     *

-     * @param output

-     *    Pointer to output block, must be 16 bytes

-     */

-    void encrypt( const uint8* input, uint8* output );

-

-    /**

-     * Set new key

-     *

-     * @param key

-     *   Pointer to key data, must have at least a size of keyLength 

-     *

-     * @param keyLength

-     *   Length of the key in bytes, must be 16, 24, or 32

-     *

-     * @return

-     *   false if key could not set.

-     */

-    bool setNewKey(const uint8* key, int32 keyLength);

-

-    /**

-     * Computes the cipher stream for AES CM mode.

-     *

-     * @param output

-     *    Pointer to a buffer that receives the cipher stream. Must be

-     *    at least <code>length</code> bytes long.

-     *

-     * @param length

-     *    Number of cipher stream bytes to produce. Usually the same

-     *    length as the data to be encrypted.

-     *

-     * @param iv

-     *    The initialization vector as input to create the cipher stream.

-     *    Refer to chapter 4.1.1 in RFC 3711.

-     */

-    void get_ctr_cipher_stream(uint8* output, uint32 length, uint8* iv);

-

-    /**

-     * Counter-mode encryption.

-     *

-     * This method performs the AES CM encryption.

-     *

-     * @param input

-     *    Pointer to input buffer, must be <code>inputLen</code> bytes.

-     *

-     * @param inputLen

-     *    Number of bytes to process.

-     *

-     * @param output

-     *    Pointer to output buffer, must be <code>inputLen</code> bytes.

-     *

-     * @param iv

-     *    The initialization vector as input to create the cipher stream.

-     *    Refer to chapter 4.1.1 in RFC 3711.

-     */

-    void ctr_encrypt( const uint8* input,

-		      uint32 inputLen,

-		      uint8* output, uint8* iv );

-

-    /**

-     * Counter-mode encryption, in place.

-     *

-     * This method performs the AES CM encryption.

-     *

-     * @param data

-     *    Pointer to input and output block, must be <code>dataLen</code>

-     *    bytes.

-     *

-     * @param dataLen

-     *    Number of bytes to process.

-     *

-     * @param iv

-     *    The initialization vector as input to create the cipher stream.

-     *    Refer to chapter 4.1.1 in RFC 3711.

-     */

-    void ctr_encrypt( uint8* data,

-		      uint32 data_length,

-		      uint8* iv );

-

-    /**

-     * AES F8 mode encryption, in place.

-     *

-     * This method performs the AES F8 encryption, see chapter 4.1.2

-     * in RFC 3711.

-     *

-     * @param data

-     *    Pointer to input and output block, must be <code>dataLen</code>

-     *    bytes.

-     *

-     * @param dataLen

-     *    Number of bytes to process.

-     *

-     * @param iv

-     *    The initialization vector as input to create the cipher stream.

-     *    Refer to chapter 4.1.1 in RFC 3711.

-     *

-     * @param key

-     *    Pointer to the computed SRTP session key.

-     *

-     * @param keyLen

-     *    The length in bytes of the computed SRTP session key.

-     *

-     * @param salt

-     *    pointer to the computed session salt.

-     *

-     * @param saltLen

-     *    The length in bytes of the computed SRTP session salt.

-     *

-     * @param f8Cipher

-     *   An AES cipher context used for intermediate f8 AES encryption.

-     */

-    void f8_encrypt( const uint8* data,

-		     uint32 dataLen,

-		     uint8* iv,

-		     uint8* key,

-		     int32  keyLen,

-		     uint8* salt,

-		     int32  saltLen,

-	AesSrtp* f8Cipher);

-

-    /**

-     * AES F8 mode encryption.

-     *

-     * This method performs the AES F8 encryption, see chapter 4.1.2

-     * in RFC 3711.

-     *

-     * @param data

-     *    Pointer to input and output block, must be <code>dataLen</code>

-     *    bytes.

-     *

-     * @param dataLen

-     *    Number of bytes to process.

-     *

-     * @param out

-     *    Pointer to output buffer, must be <code>dataLen</code> bytes.

-     *

-     * @param iv

-     *    The initialization vector as input to create the cipher stream.

-     *    Refer to chapter 4.1.1 in RFC 3711.

-     *

-     * @param key

-     *    Pointer to the computed SRTP session key.

-     *

-     * @param keyLen

-     *    The length in bytes of the computed SRTP session key.

-     *

-     * @param salt

-     *    pointer to the computed session salt.

-     *

-     * @param saltLen

-     *    The length in bytes of the computed SRTP session salt.

-     */

-    void f8_encrypt(const uint8* data,

-		    uint32 dataLen,

-		    uint8* out,

-		    uint8* iv,

-		    uint8* key,

-		    int32  keyLen,

-		    uint8* salt,

-		    int32  saltLen,

-	AesSrtp* f8Cipher);

-

-

-private:

-    int processBlock(F8_CIPHER_CTX *f8ctx,

-		     const uint8* in,

-		     int32 length,

-		     uint8* out);

-    void* key;

-    int32_t algorithm;

-};

-

-#endif

-

-/** EMACS **

- * Local variables:

- * mode: c++

- * c-default-style: ellemtel

- * c-basic-offset: 4

- * End:

- */

-

diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/Makefile b/jni/libccrtp/sources/src/ccrtp/crypto/Makefile
index 3134e9e..d5364bc 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/Makefile
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/Makefile
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
 # src/ccrtp/crypto/Makefile.  Generated from Makefile.in by configure.
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -26,6 +25,51 @@
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/ccrtp
 pkgincludedir = $(includedir)/ccrtp
 pkglibdir = $(libdir)/ccrtp
@@ -43,11 +87,11 @@
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = x86_64-unknown-linux-gnu
-host_triplet = arm-unknown-linux-androideabi
-target_triplet = arm-unknown-linux-androideabi
+host_triplet = x86_64-unknown-linux-gnu
+target_triplet = x86_64-unknown-linux-gnu
 subdir = src/ccrtp/crypto
-DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(noinst_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libgcrypt_local.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -58,82 +102,116 @@
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_HEADER = $(top_builddir)/ccrtp-config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 = 
 depcomp =
 am__depfiles_maybe =
 SOURCES =
 DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 HEADERS = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run aclocal-1.11
-AMTAR = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run tar
-AR = arm-linux-androideabi-ar
-AUTOCONF = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run automake-1.11
+ACLOCAL = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing aclocal-1.13
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 1
+AR = ar
+AUTOCONF = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing autoconf
+AUTOHEADER = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing autoheader
+AUTOMAKE = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing automake-1.13
 AWK = gawk
-CC = arm-linux-androideabi-gcc
+CC = gcc
 CCDEPMODE = depmode=none
 CFLAGS = -g -O2
-COMMON_CFLAGS = -D_GNU_SOURCE  
-COMMON_LIBS = -pthread -lccgnu2 -ldl -lrt  
-CPP = arm-linux-androideabi-gcc -E
+COMMONCPP_CFLAGS = -Wno-long-long -fexceptions -DNEW_STDCPP -pthread -fno-check-new -finline -fvisibility=hidden -DUCOMMON_VISIBILITY=1 
+COMMONCPP_LIBS = -lcommoncpp -lucommon -lrt -ldl -lpthread 
+CPP = gcc -E
 CPPFLAGS = 
-CXX = arm-linux-androideabi-g++
-CXXCPP = arm-linux-androideabi-g++ -E
+CXX = g++
+CXXCPP = g++ -E
 CXXDEPMODE = depmode=none
-CXXFLAGS = -g -O2 -D_GNU_SOURCE  
+CXXFLAGS = -g -O2 -Wno-long-long -fexceptions -DNEW_STDCPP -pthread -fno-check-new -finline -fvisibility=hidden -DUCOMMON_VISIBILITY=1 
 CYGPATH_W = echo
 DEFS = -DHAVE_CONFIG_H
 DEPDIR = .deps
 DLLTOOL = false
-DOXYGEN = no
+DOXYGEN = /usr/bin/doxygen
 DSYMUTIL = 
 DUMPBIN = 
 ECHO_C = 
 ECHO_N = -n
 ECHO_T = 
-EGREP = /bin/grep -E
+EGREP = /usr/bin/grep -E
 EXEEXT = 
-FGREP = /bin/grep -F
+FGREP = /usr/bin/grep -F
 FTPDIR = 
-GNULIBS = -L/usr/lib -pthread -lccgnu2 -ldl -lrt   
-GREP = /bin/grep
+GNULIBS = -lcommoncpp -lucommon -lrt -ldl -lpthread  -lgcrypt -ldl -lgpg-error 
+GREP = /usr/bin/grep
 INSTALL = /usr/bin/install -c
 INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
 KDOC_DIR = $(top_srcdir)/doc
-LD = /home/evigier/android-14b-toolchain/arm-linux-androideabi/bin/ld
+LD = /usr/bin/ld -m elf_x86_64
 LDFLAGS = 
 LIBGCRYPT_CFLAGS = 
-LIBGCRYPT_CONFIG = 
-LIBGCRYPT_LIBS = 
+LIBGCRYPT_CONFIG = /usr/bin/libgcrypt-config
+LIBGCRYPT_LIBS = -lgcrypt -ldl -lgpg-error
 LIBOBJS = 
-LIBS = 
+LIBS = -lgcrypt -ldl -lgpg-error 
 LIBTOOL = $(SHELL) $(top_builddir)/libtool
-LIB_MAJOR = 0
-LIB_VERSION = 1_8
 LIPO = 
 LN_S = ln -s
 LTLIBOBJS = 
-LT_CCXX_VERSION = -version-info 0:0
-LT_MAJOR = 0
+LT_CCXX_VERSION = -version-info 2:2:0
+LT_MAJOR = 2
 LT_MINOR = 0
-LT_RELEASE = 1.8
-LT_SUBVER = 0.0
+LT_RELEASE = 
+LT_SUBVER = 2.0
+LT_VERSION = 2:2:0
 MAINT = #
-MAKEINFO = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/missing --run makeinfo
+MAKEINFO = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/missing makeinfo
 MANIFEST_TOOL = :
-MKDIR_P = /bin/mkdir -p
-NM = /home/evigier/android-14b-toolchain/bin/arm-linux-androideabi-nm -B
+MKDIR_P = /usr/bin/mkdir -p
+NM = /usr/bin/nm -B
 NMEDIT = 
-OBJDUMP = arm-linux-androideabi-objdump
+OBJDUMP = objdump
 OBJEXT = o
 OTOOL = 
 OTOOL64 = 
@@ -147,27 +225,27 @@
 PATH_SEPARATOR = :
 PKG_CONFIG = /usr/bin/pkg-config
 PKG_CONFIG_LIBDIR = 
-PKG_CONFIG_PATH = /home/evigier/android-ndk-r8b/platforms/android-14/arch-arm/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
-RANLIB = arm-linux-androideabi-ranlib
-SED = /bin/sed
+PKG_CONFIG_PATH = /usr/local/lib/pkgconfig
+RANLIB = ranlib
+SED = /usr/bin/sed
 SET_MAKE = 
-SHELL = /bin/bash
-STRIP = arm-linux-androideabi-strip
-VERSION = 1.8.0
+SHELL = /bin/sh
+STRIP = strip
+VERSION = 2.0.4
 WARN_FLAGS = -fno-strict-aliasing -Wall -ansi -pedantic
-abs_builddir = /home/evigier/git/ccrtp-1.8.0-android/src/ccrtp/crypto
-abs_srcdir = /home/evigier/git/ccrtp-1.8.0-android/src/ccrtp/crypto
-abs_top_builddir = /home/evigier/git/ccrtp-1.8.0-android
-abs_top_srcdir = /home/evigier/git/ccrtp-1.8.0-android
-ac_ct_AR = 
-ac_ct_CC = 
-ac_ct_CXX = 
+abs_builddir = /home/lisional/git/sflphone-android/jni/libccrtp/sources/src/ccrtp/crypto
+abs_srcdir = /home/lisional/git/sflphone-android/jni/libccrtp/sources/src/ccrtp/crypto
+abs_top_builddir = /home/lisional/git/sflphone-android/jni/libccrtp/sources
+abs_top_srcdir = /home/lisional/git/sflphone-android/jni/libccrtp/sources
+ac_ct_AR = ar
+ac_ct_CC = gcc
+ac_ct_CXX = g++
 ac_ct_DUMPBIN = 
 am__include = include
 am__leading_dot = .
 am__quote = 
-am__tar = ${AMTAR} chof - "$$tardir"
-am__untar = ${AMTAR} xf -
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
 bindir = ${exec_prefix}/bin
 build = x86_64-unknown-linux-gnu
 build_alias = 
@@ -180,44 +258,44 @@
 docdir = ${datarootdir}/doc/${PACKAGE}
 dvidir = ${docdir}
 exec_prefix = ${prefix}
-host = arm-unknown-linux-androideabi
-host_alias = arm-linux-androideabi
-host_cpu = arm
-host_os = linux-androideabi
+host = x86_64-unknown-linux-gnu
+host_alias = 
+host_cpu = x86_64
+host_os = linux-gnu
 host_vendor = unknown
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/evigier/git/ccrtp-1.8.0-android/autoconf/install-sh
+install_sh = ${SHELL} /home/lisional/git/sflphone-android/jni/libccrtp/sources/autoconf/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localedir = ${datarootdir}/locale
 localstatedir = ${prefix}/var
 mandir = ${datarootdir}/man
-mkdir_p = /bin/mkdir -p
+mkdir_p = $(MKDIR_P)
 oldincludedir = /usr/include
 pdfdir = ${docdir}
-prefix = /home/evigier/android-ndk-r8b/platforms/android-14/arch-arm/usr
+prefix = /usr/local
 program_transform_name = s,x,x,
 psdir = ${docdir}
 sbindir = ${exec_prefix}/sbin
 sharedstatedir = ${prefix}/com
 srcdir = .
 sysconfdir = ${prefix}/etc
-target = arm-unknown-linux-androideabi
+target = x86_64-unknown-linux-gnu
 target_alias = 
-target_cpu = arm
-target_os = linux-androideabi
+target_cpu = x86_64
+target_os = linux-gnu
 target_vendor = unknown
 top_build_prefix = ../../../
 top_builddir = ../../..
 top_srcdir = ../../..
 AUTOMAKE_OPTIONS = no-dependencies dist-shar
 ccxxincludedir = $(includedir)/ccrtp/crypto
-noinst_HEADERS = AesSrtp.h hmac.h macSkein.h skein.h skein_iv.h skein_port.h skeinApi.h \
-		brg_endian.h brg_types.h
+noinst_HEADERS = SrtpSymCrypto.h hmac.h macSkein.h skein.h skein_iv.h skein_port.h skeinApi.h \
+		brg_endian.h brg_types.h twofish.h
 
-kdoc_headers = AesSrtp.h hmac.h
+kdoc_headers = SrtpSymCrypto.h hmac.h
 all: all-am
 
 .SUFFIXES:
@@ -258,26 +336,15 @@
 clean-libtool:
 	-rm -rf .libs _libs
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -289,15 +356,11 @@
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -306,6 +369,21 @@
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -354,10 +432,15 @@
 
 installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
@@ -437,17 +520,17 @@
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libtool ctags distclean distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libtool cscopelist-am ctags ctags-am distclean \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
 	uninstall-am
 
 
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/Makefile.am b/jni/libccrtp/sources/src/ccrtp/crypto/Makefile.am
index f42591e..b101cf8 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/Makefile.am
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/Makefile.am
@@ -11,10 +11,10 @@
 AUTOMAKE_OPTIONS = no-dependencies dist-shar
 ccxxincludedir=$(includedir)/ccrtp/crypto
 
-noinst_HEADERS = AesSrtp.h hmac.h macSkein.h skein.h skein_iv.h skein_port.h skeinApi.h \
-		brg_endian.h brg_types.h
+noinst_HEADERS = SrtpSymCrypto.h hmac.h macSkein.h skein.h skein_iv.h skein_port.h skeinApi.h \
+		brg_endian.h brg_types.h twofish.h
 
-kdoc_headers = AesSrtp.h hmac.h
+kdoc_headers = SrtpSymCrypto.h hmac.h
 
 kdoc:
 	kdoc -f html -d $(KDOC_DIR) -L$(KDOC_DIR) -n ccrtp $(kdoc_headers)
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/Makefile.in b/jni/libccrtp/sources/src/ccrtp/crypto/Makefile.in
index fdce98e..de39e2f 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/Makefile.in
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
-# Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -26,6 +25,51 @@
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -46,8 +90,8 @@
 host_triplet = @host@
 target_triplet = @target@
 subdir = src/ccrtp/crypto
-DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(noinst_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libgcrypt_local.m4 \
 	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -58,19 +102,54 @@
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_HEADER = $(top_builddir)/ccrtp-config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 depcomp =
 am__depfiles_maybe =
 SOURCES =
 DIST_SOURCES =
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
 HEADERS = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
@@ -79,8 +158,8 @@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
-COMMON_CFLAGS = @COMMON_CFLAGS@
-COMMON_LIBS = @COMMON_LIBS@
+COMMONCPP_CFLAGS = @COMMONCPP_CFLAGS@
+COMMONCPP_LIBS = @COMMONCPP_LIBS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CXX = @CXX@
@@ -117,8 +196,6 @@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
-LIB_MAJOR = @LIB_MAJOR@
-LIB_VERSION = @LIB_VERSION@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
@@ -127,6 +204,7 @@
 LT_MINOR = @LT_MINOR@
 LT_RELEASE = @LT_RELEASE@
 LT_SUBVER = @LT_SUBVER@
+LT_VERSION = @LT_VERSION@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
@@ -214,10 +292,10 @@
 top_srcdir = @top_srcdir@
 AUTOMAKE_OPTIONS = no-dependencies dist-shar
 ccxxincludedir = $(includedir)/ccrtp/crypto
-noinst_HEADERS = AesSrtp.h hmac.h macSkein.h skein.h skein_iv.h skein_port.h skeinApi.h \
-		brg_endian.h brg_types.h
+noinst_HEADERS = SrtpSymCrypto.h hmac.h macSkein.h skein.h skein_iv.h skein_port.h skeinApi.h \
+		brg_endian.h brg_types.h twofish.h
 
-kdoc_headers = AesSrtp.h hmac.h
+kdoc_headers = SrtpSymCrypto.h hmac.h
 all: all-am
 
 .SUFFIXES:
@@ -258,26 +336,15 @@
 clean-libtool:
 	-rm -rf .libs _libs
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
-	mkid -fID $$unique
-tags: TAGS
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
 
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
 	set x; \
 	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+	$(am__define_uniq_tagged_files); \
 	shift; \
 	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
 	  test -n "$$unique" || unique=$$empty_fix; \
@@ -289,15 +356,11 @@
 	      $$unique; \
 	  fi; \
 	fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-		$(TAGS_FILES) $(LISP)
-	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-	unique=`for i in $$list; do \
-	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-	  done | \
-	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-	      END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
 	test -z "$(CTAGS_ARGS)$$unique" \
 	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
 	     $$unique
@@ -306,6 +369,21 @@
 	here=`$(am__cd) $(top_builddir) && pwd` \
 	  && $(am__cd) $(top_srcdir) \
 	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
 
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -354,10 +432,15 @@
 
 installcheck: installcheck-am
 install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	  `test -z '$(STRIP)' || \
-	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
 mostlyclean-generic:
 
 clean-generic:
@@ -437,17 +520,17 @@
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-	clean-libtool ctags distclean distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+	clean-libtool cscopelist-am ctags ctags-am distclean \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
 	uninstall-am
 
 
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/SrtpSymCrypto.h b/jni/libccrtp/sources/src/ccrtp/crypto/SrtpSymCrypto.h
new file mode 100644
index 0000000..b14d46e
--- /dev/null
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/SrtpSymCrypto.h
@@ -0,0 +1,398 @@
+/*

+  Copyright (C) 2005, 2004, 2010, 2012 Erik Eliasson, Johan Bilien, Werner Dittmann

+

+  This library is free software; you can redistribute it and/or

+  modify it under the terms of the GNU Lesser General Public

+  License as published by the Free Software Foundation; either

+  version 2.1 of the License, or (at your option) any later version.

+

+  This library 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

+  Lesser General Public License for more details.

+

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

+  License along with this library; if not, write to the Free Software

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

+

+ * In addition, as a special exception, the copyright holders give

+ * permission to link the code of portions of this program with the

+ * OpenSSL library under certain conditions as described in each

+ * individual source file, and distribute linked combinations

+ * including the two.

+ * You must obey the GNU General Public License in all respects

+ * for all of the code used other than OpenSSL.  If you modify

+ * file(s) with this exception, you may extend this exception to your

+ * version of the file(s), but you are not obligated to do so.  If you

+ * do not wish to do so, delete this exception statement from your

+ * version.  If you delete this exception statement from all source

+ * files in the program, then also delete it here.

+*/

+

+

+

+#ifndef SRTPSYMCRYPTO_H

+#define SRTPSYMCRYPTO_H

+

+/**

+ * @file SrtpSymCrypto.h

+ * @brief Class which implements SRTP AES cryptographic functions

+ *

+ * @ingroup GNU_ZRTP

+ * @{

+ */

+

+#include <stdint.h>

+#include <CryptoContext.h>

+

+#ifndef SRTP_BLOCK_SIZE

+#define SRTP_BLOCK_SIZE 16

+#endif

+

+typedef struct _f8_ctx {

+    unsigned char *S;           ///< Intermetiade buffer

+    unsigned char *ivAccent;    ///< second IV

+    uint32_t J;                 ///< Counter

+} F8_CIPHER_CTX;

+

+/**

+ * Implments the SRTP encryption modes as defined in RFC3711

+ *

+ * The SRTP specification defines two encryption modes, AES-CTR

+ * (AES Counter mode) and AES-F8 mode. The AES-CTR is required,

+ * AES-F8 is optional.

+ *

+ * Both modes are desinged to encrypt/decrypt data of arbitrary length

+ * (with a specified upper limit, refer to RFC 3711). These modes do

+ * <em>not</em> require that the amount of data to encrypt is a multiple

+ * of the AES blocksize (16 bytes), no padding is necessary.

+ *

+ * The implementation uses the openSSL library as its cryptographic

+ * backend.

+ *

+ * @author Erik Eliasson <eliasson@it.kth.se>

+ * @author Johan Bilien <jobi@via.ecp.fr>

+ * @author Werner Dittmann <Werner.Dittmann@t-online.de>

+ */

+class SrtpSymCrypto {

+public:

+    SrtpSymCrypto(int algo = SrtpEncryptionAESCM);

+

+    /**

+     * Constructor that initializes key data

+     *

+     * @param key

+     *     Pointer to key bytes.

+     * @param key_length

+     *     Number of key bytes.

+     */

+    SrtpSymCrypto(uint8_t* key, int32_t key_length, int algo = SrtpEncryptionAESCM);

+

+    ~SrtpSymCrypto();

+

+    /**

+     * Encrypts the inpout to the output.

+     *

+     * Encrypts one input block to one output block. Each block

+     * is 16 bytes according to the AES encryption algorithm used.

+     *

+     * @param input

+     *    Pointer to input block, must be 16 bytes

+     *

+     * @param output

+     *    Pointer to output block, must be 16 bytes

+     */

+    void encrypt( const uint8_t* input, uint8_t* output );

+

+    /**

+     * Set new key

+     *

+     * @param key

+     *   Pointer to key data, must have at least a size of keyLength

+     *

+     * @param keyLength

+     *   Length of the key in bytes, must be 16, 24, or 32

+     *

+     * @return

+     *   false if key could not set.

+     */

+    bool setNewKey(const uint8_t* key, int32_t keyLength);

+

+    /**

+     * Computes the cipher stream for AES CM mode.

+     *

+     * @param output

+     *    Pointer to a buffer that receives the cipher stream. Must be

+     *    at least <code>length</code> bytes long.

+     *

+     * @param length

+     *    Number of cipher stream bytes to produce. Usually the same

+     *    length as the data to be encrypted.

+     *

+     * @param iv

+     *    The initialization vector as input to create the cipher stream.

+     *    Refer to chapter 4.1.1 in RFC 3711.

+     */

+    void get_ctr_cipher_stream(uint8_t* output, uint32_t length, uint8_t* iv);

+

+    /**

+     * Counter-mode encryption.

+     *

+     * This method performs the AES CM encryption.

+     *

+     * @param input

+     *    Pointer to input buffer, must be <code>inputLen</code> bytes.

+     *

+     * @param inputLen

+     *    Number of bytes to process.

+     *

+     * @param output

+     *    Pointer to output buffer, must be <code>inputLen</code> bytes.

+     *

+     * @param iv

+     *    The initialization vector as input to create the cipher stream.

+     *    Refer to chapter 4.1.1 in RFC 3711.

+     */

+    void ctr_encrypt(const uint8_t* input, uint32_t inputLen, uint8_t* output, uint8_t* iv );

+

+    /**

+     * Counter-mode encryption, in place.

+     *

+     * This method performs the AES CM encryption.

+     *

+     * @param data

+     *    Pointer to input and output block, must be <code>dataLen</code>

+     *    bytes.

+     *

+     * @param data_length

+     *    Number of bytes to process.

+     *

+     * @param iv

+     *    The initialization vector as input to create the cipher stream.

+     *    Refer to chapter 4.1.1 in RFC 3711.

+     */

+    void ctr_encrypt(uint8_t* data, uint32_t data_length, uint8_t* iv );

+

+    /**

+     * Derive a AES context to compute the IV'.

+     *

+     * See chapter 4.1.2.1 in RFC 3711.

+     *

+     * @param f8Cipher

+     *    Pointer to the AES context that will be used to encrypt IV to IV'

+     *

+     * @param key

+     *    The master key

+     *

+     * @param keyLen

+     *    Length of the master key.

+     *

+     * @param salt

+     *   Master salt.

+     *

+     * @param saltLen

+     *   length of master salt.

+     */

+    void f8_deriveForIV(SrtpSymCrypto* f8Cipher, uint8_t* key, int32_t keyLen, uint8_t* salt, int32_t saltLen);

+

+    /**

+     * AES F8 mode encryption, in place.

+     *

+     * This method performs the AES F8 encryption, see chapter 4.1.2

+     * in RFC 3711.

+     *

+     * @param data

+     *    Pointer to input and output block, must be <code>dataLen</code>

+     *    bytes.

+     *

+     * @param dataLen

+     *    Number of bytes to process.

+     *

+     * @param iv

+     *    The initialization vector as input to create the cipher stream.

+     *    Refer to chapter 4.1.1 in RFC 3711.

+     *

+     * @param f8Cipher

+     *   An AES cipher context used to encrypt IV to IV'.

+     */

+    void f8_encrypt(const uint8_t* data, uint32_t dataLen, uint8_t* iv, SrtpSymCrypto* f8Cipher);

+

+    /**

+     * AES F8 mode encryption.

+     *

+     * This method performs the AES F8 encryption, see chapter 4.1.2

+     * in RFC 3711.

+     *

+     * @param data

+     *    Pointer to input and output block, must be <code>dataLen</code>

+     *    bytes.

+     *

+     * @param dataLen

+     *    Number of bytes to process.

+     *

+     * @param out

+     *    Pointer to output buffer, must be <code>dataLen</code> bytes.

+     *

+     * @param iv

+     *    The initialization vector as input to create the cipher stream.

+     *    Refer to chapter 4.1.1 in RFC 3711.

+     *

+     * @param f8Cipher

+     *   An AES cipher context used to encrypt IV to IV'.

+     */

+    void f8_encrypt(const uint8_t* data, uint32_t dataLen, uint8_t* out, uint8_t* iv, SrtpSymCrypto* f8Cipher);

+

+private:

+    int processBlock(F8_CIPHER_CTX* f8ctx, const uint8_t* in, int32_t length, uint8_t* out);

+    void* key;

+    int32_t algorithm;

+};

+

+#pragma GCC visibility push(default)

+int testF8();

+#pragma GCC visibility pop

+

+/* Only SrtpSymCrypto functions define the MAKE_F8_TEST */

+#ifdef MAKE_F8_TEST

+

+#include <cstring>

+#include <iostream>

+#include <cstdio>

+

+#if defined(_MSC_VER) || defined(WIN32) || defined(_WIN32)

+#include <windows.h>

+#else

+#include <arpa/inet.h>

+#endif

+

+using namespace std;

+

+static void hexdump(const char* title, const unsigned char *s, int l)

+{

+    int n=0;

+

+    if (s == NULL) return;

+

+    fprintf(stderr, "%s",title);

+    for( ; n < l ; ++n) {

+        if((n%16) == 0)

+            fprintf(stderr, "\n%04x",n);

+        fprintf(stderr, " %02x",s[n]);

+    }

+    fprintf(stderr, "\n");

+}

+

+/*

+ * The F8 test vectors according to RFC3711

+ */

+static unsigned char salt[] = {0x32, 0xf2, 0x87, 0x0d};

+

+static unsigned char iv[] = {  0x00, 0x6e, 0x5c, 0xba, 0x50, 0x68, 0x1d, 0xe5,

+                        0x5c, 0x62, 0x15, 0x99, 0xd4, 0x62, 0x56, 0x4a};

+

+static unsigned char key[]= {  0x23, 0x48, 0x29, 0x00, 0x84, 0x67, 0xbe, 0x18,

+                        0x6c, 0x3d, 0xe1, 0x4a, 0xae, 0x72, 0xd6, 0x2c};

+

+static unsigned char payload[] = {

+                        0x70, 0x73, 0x65, 0x75, 0x64, 0x6f, 0x72, 0x61,

+                        0x6e, 0x64, 0x6f, 0x6d, 0x6e, 0x65, 0x73, 0x73,

+                        0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20,

+                        0x6e, 0x65, 0x78, 0x74, 0x20, 0x62, 0x65, 0x73,

+                        0x74, 0x20, 0x74, 0x68, 0x69, 0x6e, 0x67};  // 39 bytes

+

+static unsigned char cipherText[] = {

+                        0x01, 0x9c, 0xe7, 0xa2, 0x6e, 0x78, 0x54, 0x01,

+                        0x4a, 0x63, 0x66, 0xaa, 0x95, 0xd4, 0xee, 0xfd,

+                        0x1a, 0xd4, 0x17, 0x2a, 0x14, 0xf9, 0xfa, 0xf4,

+                        0x55, 0xb7, 0xf1, 0xd4, 0xb6, 0x2b, 0xd0, 0x8f,

+                        0x56, 0x2c, 0x0e, 0xef, 0x7c, 0x48, 0x02}; // 39 bytes

+

+// static unsigned char rtpPacketHeader[] = {

+//                         0x80, 0x6e, 0x5c, 0xba, 0x50, 0x68, 0x1d, 0xe5,

+//                         0x5c, 0x62, 0x15, 0x99};

+

+static unsigned char rtpPacket[] = {

+                    0x80, 0x6e, 0x5c, 0xba, 0x50, 0x68, 0x1d, 0xe5,

+                    0x5c, 0x62, 0x15, 0x99,                        // header

+                    0x70, 0x73, 0x65, 0x75, 0x64, 0x6f, 0x72, 0x61, // payload

+                    0x6e, 0x64, 0x6f, 0x6d, 0x6e, 0x65, 0x73, 0x73,

+                    0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20,

+                    0x6e, 0x65, 0x78, 0x74, 0x20, 0x62, 0x65, 0x73,

+                    0x74, 0x20, 0x74, 0x68, 0x69, 0x6e, 0x67};

+static uint32_t ROC = 0xd462564a;

+

+int testF8()

+{

+    SrtpSymCrypto* aesCipher = new SrtpSymCrypto(SrtpEncryptionAESF8);

+    SrtpSymCrypto* f8AesCipher = new SrtpSymCrypto(SrtpEncryptionAESF8);

+

+    aesCipher->setNewKey(key, sizeof(key));

+

+    /* Create the F8 IV (refer to chapter 4.1.2.2 in RFC 3711):

+     *

+     * IV = 0x00 || M || PT || SEQ  ||      TS    ||    SSRC   ||    ROC

+     *      8Bit  1bit  7bit  16bit       32bit        32bit        32bit

+     * ------------\     /--------------------------------------------------

+     *       XX       XX      XX XX   XX XX XX XX   XX XX XX XX  XX XX XX XX

+     */

+

+    unsigned char derivedIv[16];

+    uint32_t* ui32p = (uint32_t*)derivedIv;

+

+    memcpy(derivedIv, rtpPacket, 12);

+    derivedIv[0] = 0;

+

+    // set ROC in network order into IV

+    ui32p[3] = htonl(ROC);

+

+    int32_t pad = 0;

+

+    if (memcmp(iv, derivedIv, 16) != 0) {

+        cerr << "Wrong IV constructed" << endl;

+        hexdump("derivedIv", derivedIv, 16);

+        hexdump("test vector Iv", iv, 16);

+        return -1;

+    }

+

+    aesCipher->f8_deriveForIV(f8AesCipher, key, sizeof(key), salt, sizeof(salt));

+

+    // now encrypt the RTP payload data

+    aesCipher->f8_encrypt(rtpPacket + 12, sizeof(rtpPacket)-12+pad,

+        derivedIv, f8AesCipher);

+

+    // compare with test vector cipher data

+    if (memcmp(rtpPacket+12, cipherText, sizeof(rtpPacket)-12+pad) != 0) {

+        cerr << "cipher data mismatch" << endl;

+        hexdump("computed cipher data", rtpPacket+12, sizeof(rtpPacket)-12+pad);

+        hexdump("Test vcetor cipher data", cipherText, sizeof(cipherText));

+        return -1;

+    }

+

+    // Now decrypt the data to get the payload data again

+    aesCipher->f8_encrypt(rtpPacket+12, sizeof(rtpPacket)-12+pad, derivedIv, f8AesCipher);

+

+    // compare decrypted data with test vector payload data

+    if (memcmp(rtpPacket+12, payload, sizeof(rtpPacket)-12+pad) != 0) {

+        cerr << "payload data mismatch" << endl;

+        hexdump("computed payload data", rtpPacket+12, sizeof(rtpPacket)-12+pad);

+        hexdump("Test vector payload data", payload, sizeof(payload));

+        return -1;

+    }

+    return 0;

+}

+#endif

+

+/**

+ * @}

+ */

+

+#endif

+

+/** EMACS **

+ * Local variables:

+ * mode: c++

+ * c-default-style: ellemtel

+ * c-basic-offset: 4

+ * End:

+ */

+

diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/InitializeGcrypt.cxx b/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/InitializeGcrypt.cpp
similarity index 90%
rename from jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/InitializeGcrypt.cxx
rename to jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/InitializeGcrypt.cpp
index 6d23d08..78fad51 100755
--- a/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/InitializeGcrypt.cxx
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/InitializeGcrypt.cpp
@@ -1,10 +1,10 @@
 /*
-  Copyright (C) 2006 Werner Dittmann
+  Copyright (C) 2006-2007 Werner Dittmann
 
-  This program is free software; you can redistribute it and/or modify
+  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, or (at your option)
-  any later version.
+  the Free Software Foundation, either version 3 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
@@ -12,13 +12,12 @@
   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, Boston, MA 02111.
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include <stdio.h>
 
-#include <stdlib.h>
+#include <malloc.h>
 #include <pthread.h>
 #include <errno.h>
 #include <gcrypt.h>
@@ -75,7 +74,7 @@
 {
 
     if (initialized) {
-        return 1;
+	return 1;
     }
     gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
     gcry_check_version(NULL);
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx b/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx
deleted file mode 100644
index 1188633..0000000
--- a/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcryptAesSrtp.cxx
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
-  Copyright (C) 2005, 2004 Erik Eliasson, Johan Bilien
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
- * In addition, as a special exception, the copyright holders give
- * permission to link the code of portions of this program with the
- * OpenSSL library under certain conditions as described in each
- * individual source file, and distribute linked combinations
- * including the two.
- * You must obey the GNU General Public License in all respects
- * for all of the code used other than OpenSSL.  If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so.  If you
- * do not wish to do so, delete this exception statement from your
- * version.  If you delete this exception statement from all source
- * files in the program, then also delete it here.
-*/
-
-/**
- * @author Erik Eliasson <eliasson@it.kth.se>
- * @author Johan Bilien <jobi@via.ecp.fr>
- * @author Werner Dittmann <Werner.Dittmann@t-online.de>
- */
-
-extern void initializeGcrypt();
-
-#include <gcrypt.h>            // the include of gcrypt
-#include <stdlib.h>
-#include <ccrtp/crypto/AesSrtp.h>
-
-#include <stdio.h>
-
-AesSrtp::AesSrtp(int algo) : key(NULL), algorithm(algo) {
-    initializeGcrypt();
-}
-
-AesSrtp::AesSrtp( uint8* k, int32 keyLength, int algo) : 
-    key(NULL),  algorithm(algo) {
-
-    initializeGcrypt();
-    setNewKey(k, keyLength);
-}
-
-AesSrtp::~AesSrtp() {
-    if (key) {
-        gcry_cipher_close(static_cast<gcry_cipher_hd_t>(key));
-        key = NULL;
-    }
-}
-
-bool AesSrtp::setNewKey(const uint8* k, int32 keyLength) {
-
-    // release an existing key before setting a new one
-    if (key != NULL) {
-        gcry_cipher_close(static_cast<gcry_cipher_hd_t>(key));
-        key = NULL;
-    }
-
-    int algo = 0;
-    if (keyLength == 16) {
-        algo = GCRY_CIPHER_AES;
-    }
-    else if (keyLength == 32) {
-        algo = GCRY_CIPHER_AES256;
-    }
-    else {
-	return false;
-    }
-    gcry_cipher_hd_t tmp;
-    int err = gcry_cipher_open(&tmp, algo, GCRY_CIPHER_MODE_ECB, 0);
-    key = tmp;
-    err = gcry_cipher_setkey(static_cast<gcry_cipher_hd_t>(key), k, keyLength);
-    return true;
-}
-
-
-void AesSrtp::encrypt( const uint8* input, uint8* output ) {
-    if (key != NULL) {
-        gcry_cipher_encrypt (static_cast<gcry_cipher_hd_t>(key),
-                             output, SRTP_BLOCK_SIZE, input, SRTP_BLOCK_SIZE);
-    }
-}
-
-void AesSrtp::get_ctr_cipher_stream( uint8* output, uint32 length,
-				     uint8* iv ) {
-    uint16 ctr;
-    uint16 input;
-
-    unsigned char aes_input[SRTP_BLOCK_SIZE];
-    unsigned char temp[SRTP_BLOCK_SIZE];
-
-    memcpy(aes_input, iv, 14 );
-    iv += 14;
-
-    for( ctr = 0; ctr < length/SRTP_BLOCK_SIZE; ctr++ ){
-	input = ctr;
-	//compute the cipher stream
-	aes_input[14] = (uint8)((input & 0xFF00) >>  8);
-	aes_input[15] = (uint8)((input & 0x00FF));
-
-        gcry_cipher_encrypt(static_cast<gcry_cipher_hd_t>(key), &output[ctr*SRTP_BLOCK_SIZE], SRTP_BLOCK_SIZE,
-                            aes_input, SRTP_BLOCK_SIZE);
-    }
-    if ((length % SRTP_BLOCK_SIZE) > 0) {
-        // Treat the last bytes:
-        input = ctr;
-        aes_input[14] = (uint8)((input & 0xFF00) >>  8);
-        aes_input[15] = (uint8)((input & 0x00FF));
-
-        gcry_cipher_encrypt(static_cast<gcry_cipher_hd_t>(key), temp, SRTP_BLOCK_SIZE, aes_input, SRTP_BLOCK_SIZE);
-        memcpy(&output[ctr*SRTP_BLOCK_SIZE], temp, length % SRTP_BLOCK_SIZE);
-    }
-}
-
-
-void AesSrtp::ctr_encrypt( const uint8* input, uint32 input_length,
-			   uint8* output, uint8* iv ) {
-
-    if (key == NULL)
-	return;
-
-    uint8* cipher_stream = new uint8[input_length];
-
-    get_ctr_cipher_stream( cipher_stream, input_length, iv );
-
-    for( unsigned int i = 0; i < input_length; i++ ){
-	output[i] = cipher_stream[i] ^ input[i];
-    }
-    delete []cipher_stream;
-}
-
-void AesSrtp::ctr_encrypt( uint8* data, uint32 data_length, uint8* iv ) {
-
-    if (key == NULL)
-	return;
-
-    //unsigned char cipher_stream[data_length];
-    uint8* cipher_stream = new uint8[data_length];
-
-    get_ctr_cipher_stream( cipher_stream, data_length, iv );
-
-    for( uint32 i = 0; i < data_length; i++ ){
-	data[i] ^= cipher_stream[i];
-    }
-    delete[] cipher_stream;
-}
-
-void AesSrtp::f8_encrypt(const uint8* data, uint32 data_length,
-			 uint8* iv, uint8* origKey, int32 keyLen,
-			 uint8* salt, int32 saltLen, AesSrtp* f8Cipher ) {
-
-    f8_encrypt(data, data_length, const_cast<uint8*>(data), iv, origKey, keyLen, salt, saltLen, f8Cipher);
-}
-
-#define MAX_KEYLEN 32
-
-void AesSrtp::f8_encrypt(const uint8* in, uint32 in_length, uint8* out,
-			 uint8* iv, uint8* origKey, int32 keyLen,
-			 uint8* salt, int32 saltLen, AesSrtp* f8Cipher ) {
-
-
-    unsigned char *cp_in, *cp_in1, *cp_out;
-    int i;
-    int offset = 0;
-
-    unsigned char ivAccent[SRTP_BLOCK_SIZE];
-    unsigned char maskedKey[MAX_KEYLEN];
-    unsigned char saltMask[MAX_KEYLEN];
-    unsigned char S[SRTP_BLOCK_SIZE];
-
-    F8_CIPHER_CTX f8ctx;
-
-    if (key == NULL)
-	return;
-
-    if (keyLen > MAX_KEYLEN)
-	return;
-
-    if (saltLen > keyLen)
-	return;
-
-    /*
-     * Get memory for the derived IV (IV')
-     */
-    f8ctx.ivAccent = ivAccent;
-
-    /*
-     * First copy the salt into the mask field, then fill with 0x55 to
-     * get a full key.
-     */
-    memcpy(saltMask, salt, saltLen);
-    memset(saltMask+saltLen, 0x55, keyLen-saltLen);
-
-    /*
-     * XOR the original key with the above created mask to
-     * get the special key.
-     */
-    cp_out = maskedKey;
-    cp_in = origKey;
-    cp_in1 = saltMask;
-    for (i = 0; i < keyLen; i++) {
-        *cp_out++ = *cp_in++ ^ *cp_in1++;
-    }
-    /*
-     * Prepare the a new AES cipher with the special key to compute IV'
-     */
-    f8Cipher->setNewKey(maskedKey, keyLen);
-
-    /*
-     * Use the masked key to encrypt the original IV to produce IV'.
-     *
-     * After computing the IV' we don't need this cipher context anymore, free it.
-     */
-    f8Cipher->encrypt(iv, f8ctx.ivAccent);
-
-    f8ctx.J = 0;                       // initialize the counter
-    f8ctx.S = S;		       // get the key stream buffer
-
-    memset(f8ctx.S, 0, SRTP_BLOCK_SIZE); // initial value for key stream
-
-    while (in_length >= SRTP_BLOCK_SIZE) {
-        processBlock(&f8ctx, in+offset, SRTP_BLOCK_SIZE, out+offset);
-        in_length -= SRTP_BLOCK_SIZE;
-        offset += SRTP_BLOCK_SIZE;
-    }
-    if (in_length > 0) {
-        processBlock(&f8ctx, in+offset, in_length, out+offset);
-    }
-}
-
-int AesSrtp::processBlock(F8_CIPHER_CTX *f8ctx, const uint8* in, int32 length, uint8* out) {
-
-    int i;
-    const uint8 *cp_in;
-    uint8* cp_in1, *cp_out;
-    uint32_t *ui32p;
-
-    /*
-     * XOR the previous key stream with IV'
-     * ( S(-1) xor IV' )
-     */
-    cp_in = f8ctx->ivAccent;
-    cp_out = f8ctx->S;
-    for (i = 0; i < SRTP_BLOCK_SIZE; i++) {
-        *cp_out++ ^= *cp_in++;
-    }
-    /*
-     * Now XOR (S(n-1) xor IV') with the current counter, then increment the counter
-     */
-    ui32p = (uint32_t *)f8ctx->S;
-    ui32p[3] ^= htonl(f8ctx->J);
-    f8ctx->J++;
-    /*
-     * Now compute the new key stream using AES encrypt
-     */
-    gcry_cipher_encrypt(static_cast<gcry_cipher_hd_t>(key), f8ctx->S, SRTP_BLOCK_SIZE, NULL, 0);
-    /*
-     * as the last step XOR the plain text with the key stream to produce
-     * the ciphertext.
-     */
-    cp_out = out;
-    cp_in = in;
-    cp_in1 = f8ctx->S;
-    for (i = 0; i < length; i++) {
-        *cp_out++ = *cp_in++ ^ *cp_in1++;
-    }
-    return length;
-}
-
-
-/** EMACS **
- * Local variables:
- * mode: c++
- * c-default-style: ellemtel
- * c-basic-offset: 4
- * End:
- */
-
-
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp b/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp
new file mode 100644
index 0000000..766deac
--- /dev/null
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcryptSrtpSymCrypto.cpp
@@ -0,0 +1,344 @@
+/*
+  Copyright (C) 2005, 2004, 2012 Erik Eliasson, Johan Bilien, Werner Dittmann
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library 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
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+ * In addition, as a special exception, the copyright holders give
+ * permission to link the code of portions of this program with the
+ * OpenSSL library under certain conditions as described in each
+ * individual source file, and distribute linked combinations
+ * including the two.
+ * You must obey the GNU General Public License in all respects
+ * for all of the code used other than OpenSSL.  If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so.  If you
+ * do not wish to do so, delete this exception statement from your
+ * version.  If you delete this exception statement from all source
+ * files in the program, then also delete it here.
+*/
+
+/**
+ * @author Erik Eliasson <eliasson@it.kth.se>
+ * @author Johan Bilien <jobi@via.ecp.fr>
+ * @author Werner Dittmann <Werner.Dittmann@t-online.de>
+ */
+
+extern void initializeGcrypt();
+
+#define MAKE_F8_TEST
+
+#include <gcrypt.h>            // the include of gcrypt
+#include <stdlib.h>
+#include <crypto/SrtpSymCrypto.h>
+#include <crypto/twofish.h>
+
+#include <stdio.h>
+
+SrtpSymCrypto::SrtpSymCrypto(int algo) : key(NULL), algorithm(algo) {
+    initializeGcrypt();
+}
+
+SrtpSymCrypto::SrtpSymCrypto( uint8_t* k, int32_t keyLength, int algo) :
+    key(NULL),  algorithm(algo) {
+
+    initializeGcrypt();
+    setNewKey(k, keyLength);
+}
+
+SrtpSymCrypto::~SrtpSymCrypto() {
+    if (key) {
+        if (algorithm == SrtpEncryptionAESCM || algorithm == SrtpEncryptionAESF8)
+            gcry_cipher_close(static_cast<gcry_cipher_hd_t>(key));
+        else if (algorithm == SrtpEncryptionTWOCM || algorithm == SrtpEncryptionTWOF8) {
+            memset(key, 0, sizeof(Twofish_key));
+            delete[] (uint8_t*)key;
+        }
+        key = NULL;
+    }
+}
+
+static int twoFishInit = 0;
+
+bool SrtpSymCrypto::setNewKey(const uint8_t* k, int32_t keyLength) {
+
+    // release an existing key before setting a new one
+    if (algorithm == SrtpEncryptionAESCM || algorithm == SrtpEncryptionAESF8) {
+        if (key != NULL) {
+            gcry_cipher_close(static_cast<gcry_cipher_hd_t>(key));
+            key = NULL;
+        }
+
+        int algo = 0;
+        if (keyLength == 16) {
+            algo = GCRY_CIPHER_AES;
+        }
+        else if (keyLength == 32) {
+            algo = GCRY_CIPHER_AES256;
+        }
+        else {
+            return false;
+        }
+        gcry_cipher_hd_t tmp;
+        gcry_cipher_open(&tmp, algo, GCRY_CIPHER_MODE_ECB, 0);
+        key = tmp;
+        gcry_cipher_setkey(static_cast<gcry_cipher_hd_t>(key), k, keyLength);
+    }
+    else if (algorithm == SrtpEncryptionTWOCM || algorithm == SrtpEncryptionTWOF8) {
+        if (!twoFishInit) {
+            Twofish_initialise();
+            twoFishInit = 1;
+        }
+        if (key != NULL)
+            delete[] (uint8_t*)key;
+
+        key = new uint8_t[sizeof(Twofish_key)];
+        memset(key, 0, sizeof(Twofish_key));
+        Twofish_prepare_key((Twofish_Byte*)k, keyLength,  (Twofish_key*)key);
+    }
+    else
+        return false;
+
+    return true;
+}
+
+
+void SrtpSymCrypto::encrypt(const uint8_t* input, uint8_t* output) {
+    if (key != NULL) {
+        if (algorithm == SrtpEncryptionAESCM || algorithm == SrtpEncryptionAESF8)
+            gcry_cipher_encrypt (static_cast<gcry_cipher_hd_t>(key),
+                                 output, SRTP_BLOCK_SIZE, input, SRTP_BLOCK_SIZE);
+        else if (algorithm == SrtpEncryptionTWOCM || algorithm == SrtpEncryptionTWOF8)
+            Twofish_encrypt((Twofish_key*)key, (Twofish_Byte*)input,
+                            (Twofish_Byte*)output);
+        }
+}
+
+void SrtpSymCrypto::get_ctr_cipher_stream( uint8_t* output, uint32_t length,
+                                     uint8_t* iv ) {
+    uint16_t ctr = 0;
+
+    unsigned char temp[SRTP_BLOCK_SIZE];
+
+    for(ctr = 0; ctr < length/SRTP_BLOCK_SIZE; ctr++ ){
+        //compute the cipher stream
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, &output[ctr*SRTP_BLOCK_SIZE]);
+    }
+    if ((length % SRTP_BLOCK_SIZE) > 0) {
+        // Treat the last bytes:
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        memcpy(&output[ctr*SRTP_BLOCK_SIZE], temp, length % SRTP_BLOCK_SIZE);
+    }
+}
+
+void SrtpSymCrypto::ctr_encrypt( const uint8_t* input, uint32_t input_length,
+			   uint8_t* output, uint8_t* iv ) {
+
+    if (key == NULL)
+        return;
+
+    uint16_t ctr = 0;
+    unsigned char temp[SRTP_BLOCK_SIZE];
+
+    int l = input_length/SRTP_BLOCK_SIZE;
+    for ( ctr = 0; ctr < l; ctr++ ) {
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        for (int i = 0; i < SRTP_BLOCK_SIZE; i++ ) {
+            *output++ = temp[i] ^ *input++;
+        }
+
+    }
+    l = input_length % SRTP_BLOCK_SIZE;
+    if (l > 0) {
+        // Treat the last bytes:
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        for (int i = 0; i < l; i++ ) {
+            *output++ = temp[i] ^ *input++;
+        }
+    }
+}
+
+void SrtpSymCrypto::ctr_encrypt( uint8_t* data, uint32_t data_length, uint8_t* iv ) {
+
+    if (key == NULL)
+        return;
+    
+    uint16_t ctr = 0;
+    unsigned char temp[SRTP_BLOCK_SIZE];
+
+    int l = data_length/SRTP_BLOCK_SIZE;
+    for (ctr = 0; ctr < l; ctr++ ) {
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        for (int i = 0; i < SRTP_BLOCK_SIZE; i++ ) {
+            *data++ ^= temp[i];
+        }
+
+    }
+    l = data_length % SRTP_BLOCK_SIZE;
+    if (l > 0) {
+        // Treat the last bytes:
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        for (int i = 0; i < l; i++ ) {
+            *data++ ^= temp[i];
+        }
+    }
+
+}
+
+void SrtpSymCrypto::f8_encrypt(const uint8_t* data, uint32_t data_length, uint8_t* iv, SrtpSymCrypto* f8Cipher ) {
+
+    f8_encrypt(data, data_length, const_cast<uint8_t*>(data), iv, f8Cipher);
+}
+
+#define MAX_KEYLEN 32
+
+void SrtpSymCrypto::f8_deriveForIV(SrtpSymCrypto* f8Cipher, uint8_t* key, int32_t keyLen,
+             uint8_t* salt, int32_t saltLen) {
+
+    unsigned char *cp_in, *cp_in1, *cp_out;
+
+    unsigned char maskedKey[MAX_KEYLEN];
+    unsigned char saltMask[MAX_KEYLEN];
+
+    if (keyLen > MAX_KEYLEN)
+        return;
+
+    if (saltLen > keyLen)
+        return;
+    /*
+     * First copy the salt into the mask field, then fill with 0x55 to
+     * get a full key.
+     */
+    memcpy(saltMask, salt, saltLen);
+    memset(saltMask+saltLen, 0x55, keyLen-saltLen);
+
+    /*
+     * XOR the original key with the above created mask to
+     * get the special key.
+     */
+    cp_out = maskedKey;
+    cp_in = key;
+    cp_in1 = saltMask;
+    for (int i = 0; i < keyLen; i++) {
+        *cp_out++ = *cp_in++ ^ *cp_in1++;
+    }
+    /*
+     * Prepare the a new AES cipher with the special key to compute IV'
+     */
+    f8Cipher->setNewKey(maskedKey, keyLen);
+}
+
+void SrtpSymCrypto::f8_encrypt(const uint8_t* in, uint32_t in_length, uint8_t* out,
+                         uint8_t* iv, SrtpSymCrypto* f8Cipher ) {
+
+    int offset = 0;
+
+    unsigned char ivAccent[SRTP_BLOCK_SIZE];
+    unsigned char S[SRTP_BLOCK_SIZE];
+
+    F8_CIPHER_CTX f8ctx;
+
+    if (key == NULL)
+        return;
+
+    /*
+     * Get memory for the derived IV (IV')
+     */
+    f8ctx.ivAccent = ivAccent;
+    /*
+     * Use the derived IV encryption setup to encrypt the original IV to produce IV'.
+     */
+    f8Cipher->encrypt(iv, f8ctx.ivAccent);
+
+    f8ctx.J = 0;                        // initialize the counter
+    f8ctx.S = S;                        // get the key stream buffer
+
+    memset(f8ctx.S, 0, SRTP_BLOCK_SIZE); // initial value for key stream
+
+    while (in_length >= SRTP_BLOCK_SIZE) {
+        processBlock(&f8ctx, in+offset, SRTP_BLOCK_SIZE, out+offset);
+        in_length -= SRTP_BLOCK_SIZE;
+        offset += SRTP_BLOCK_SIZE;
+    }
+    if (in_length > 0) {
+        processBlock(&f8ctx, in+offset, in_length, out+offset);
+    }
+}
+
+int SrtpSymCrypto::processBlock(F8_CIPHER_CTX *f8ctx, const uint8_t* in, int32_t length, uint8_t* out) {
+
+    int i;
+    const uint8_t *cp_in;
+    uint8_t* cp_in1, *cp_out;
+    uint32_t *ui32p;
+
+    /*
+     * XOR the previous key stream with IV'
+     * ( S(-1) xor IV' )
+     */
+    cp_in = f8ctx->ivAccent;
+    cp_out = f8ctx->S;
+    for (i = 0; i < SRTP_BLOCK_SIZE; i++) {
+        *cp_out++ ^= *cp_in++;
+    }
+    /*
+     * Now XOR (S(n-1) xor IV') with the current counter, then increment the counter
+     */
+    ui32p = (uint32_t *)f8ctx->S;
+    ui32p[3] ^= htonl(f8ctx->J);
+    f8ctx->J++;
+    /*
+     * Now compute the new key stream using encrypt
+     */
+    encrypt(f8ctx->S, f8ctx->S);
+    /*
+     * as the last step XOR the plain text with the key stream to produce
+     * the ciphertext.
+     */
+    cp_out = out;
+    cp_in = in;
+    cp_in1 = f8ctx->S;
+    for (i = 0; i < length; i++) {
+        *cp_out++ = *cp_in++ ^ *cp_in1++;
+    }
+    return length;
+}
+
+/** EMACS **
+ * Local variables:
+ * mode: c++
+ * c-default-style: ellemtel
+ * c-basic-offset: 4
+ * End:
+ */
+
+
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcrypthmac.cxx b/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcrypthmac.cpp
similarity index 77%
rename from jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcrypthmac.cxx
rename to jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcrypthmac.cpp
index c13f657..208c3ec 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcrypthmac.cxx
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/gcrypt/gcrypthmac.cpp
@@ -22,17 +22,16 @@
  */
 #include <gcrypt.h>
 
-#include <ccrtp/crypto/hmac.h>
+#include <crypto/hmac.h>
 #include <stdio.h>
 
-void hmac_sha1(uint8* key, int32 keyLength,
-                 const uint8* data, int32 dataLength,
-                 uint8* mac, int32* macLength)
+void hmac_sha1(uint8_t* key, int32_t keyLength,
+                 const uint8_t* data, int32_t dataLength,
+                 uint8_t* mac, int32_t* macLength)
 {
     gcry_md_hd_t hd;
-    gcry_error_t err = 0;
 
-    err = gcry_md_open(&hd, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
+     gcry_md_open(&hd, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
     gcry_md_setkey(hd, key, keyLength);
 
     gcry_md_write (hd, data, dataLength);
@@ -45,19 +44,18 @@
     gcry_md_close (hd);
 }
 
-void hmac_sha1( uint8* key, int32 keyLength,
-                  const uint8* dataChunks[],
-                  uint32 dataChunkLength[],
-                  uint8* mac, int32* macLength )
+void hmac_sha1( uint8_t* key, int32_t keyLength,
+                  const uint8_t* dataChunks[],
+                  uint32_t dataChunkLength[],
+                  uint8_t* mac, int32_t* macLength )
 {
     gcry_md_hd_t hd;
-    gcry_error_t err = 0;
 
-    err = gcry_md_open(&hd, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
+    gcry_md_open(&hd, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
     gcry_md_setkey(hd, key, keyLength);
 
     while (*dataChunks) {
-        gcry_md_write (hd, *dataChunks, (uint32)(*dataChunkLength));
+        gcry_md_write (hd, *dataChunks, (uint32_t)(*dataChunkLength));
         dataChunks++;
         dataChunkLength++;
     }
@@ -72,9 +70,8 @@
 void* createSha1HmacContext(uint8_t* key, int32_t key_length)
 {
     gcry_md_hd_t ctx;
-    gcry_error_t err = 0;
-    
-    err = gcry_md_open(&ctx, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
+
+    gcry_md_open(&ctx, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
     gcry_md_setkey(ctx, key, key_length);
     return ctx;
 }
@@ -83,11 +80,11 @@
                 uint8_t* mac, int32_t* mac_length)
 {
     gcry_md_hd_t pctx = (gcry_md_hd_t)ctx;
-    
+
     gcry_md_reset(pctx);
 
     gcry_md_write (pctx, data, data_length);
-    
+
     uint8_t* p = gcry_md_read (pctx, GCRY_MD_SHA1);
     memcpy(mac, p, SHA1_DIGEST_LENGTH);
     if (mac_length != NULL) {
@@ -99,10 +96,10 @@
                 uint8_t* mac, int32_t* mac_length )
 {
     gcry_md_hd_t pctx = (gcry_md_hd_t)ctx;
-    
+
     gcry_md_reset (pctx);
     while (*data) {
-        gcry_md_write (pctx, *data, (uint32)(*data_length));
+        gcry_md_write (pctx, *data, (uint32_t)(*data_length));
         data++;
         data_length++;
     }
@@ -117,4 +114,4 @@
 {
     gcry_md_hd_t pctx = (gcry_md_hd_t)ctx;
     gcry_md_close (pctx);
-}
\ No newline at end of file
+}
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/hmac.h b/jni/libccrtp/sources/src/ccrtp/crypto/hmac.h
index 02a5b8c..4abfa8f 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/hmac.h
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/hmac.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2005, 2004 Erik Eliasson, Johan Bilien
+  Copyright (C) 2005, 2004, 2010 Erik Eliasson, Johan Bilien, Werner Dittmann
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -34,12 +34,21 @@
  *
  * @author Erik Eliasson <eliasson@it.kth.se>
  * @author Johan Bilien <jobi@via.ecp.fr>
+ * @author Werner Dittmann
  */
 
 #ifndef HMAC_H
 #define HMAC_H
 
-#include <cc++/config.h>
+/**
+ * @file hmac.h
+ * @brief Functions that provide SHA1 HMAC support
+ * 
+ * @ingroup GNU_ZRTP
+ * @{
+ */
+
+#include <stdint.h>
 
 #ifndef SHA1_DIGEST_LENGTH
 #define SHA1_DIGEST_LENGTH 20
@@ -65,15 +74,14 @@
  *    Point to an integer that receives the length of the computed HMAC.
  */
 
-__EXPORT void hmac_sha1( uint8* key, int32 key_length,
-                const uint8* data, uint32 data_length,
-                uint8* mac, int32* mac_length );
+void hmac_sha1( uint8_t* key, int32_t key_length,
+                const uint8_t* data, uint32_t data_length,
+                uint8_t* mac, int32_t* mac_length );
 
 /**
  * Compute SHA1 HMAC over several data cunks.
  *
- * This functions takes several data chunk and computes the SHA1 HAMAC. It
- * uses the openSSL HAMAC SHA1 implementation.
+ * This functions takes several data chunk and computes the SHA1 HAMAC.
  *
  * @param key
  *    The MAC key.
@@ -90,15 +98,14 @@
  * @param mac_length
  *    Point to an integer that receives the length of the computed HMAC.
  */
-__EXPORT void hmac_sha1( uint8* key, int32 key_length,
-                const uint8* data[], uint32 data_length[],
-                uint8* mac, int32* mac_length );
+void hmac_sha1( uint8_t* key, int32_t key_length,
+                const uint8_t* data[], uint32_t data_length[],
+                uint8_t* mac, int32_t* mac_length );
 
 /**
  * Create and initialize a SHA1 HMAC context.
  *
- * An application uses this context to hash several data into one SHA1
- * digest. 
+ * An application uses this context to create several HMAC with the same key.
  *
  * @param key
  *    The MAC key.
@@ -106,12 +113,13 @@
  *    Lenght of the MAC key in bytes
  * @return Returns a pointer to the initialized context
  */
-__EXPORT void* createSha1HmacContext(uint8_t* key, int32_t key_length);
+void* createSha1HmacContext(uint8_t* key, int32_t key_length);
 
 /**
  * Compute SHA1 HMAC.
  *
- * This functions takes one data chunk and computes its SHA1 HMAC.
+ * This functions takes one data chunk and computes its SHA1 HMAC. On return
+ * the SHA1 MAC context is ready to compute a HMAC for another data chunk.
  *
  * @param ctx
  *     Pointer to initialized SHA1 HMAC context
@@ -125,14 +133,14 @@
  * @param mac_length
  *    Point to an integer that receives the length of the computed HMAC.
  */
-
-__EXPORT void hmacSha1Ctx(void* ctx, const uint8_t* data, uint32_t data_length,
+void hmacSha1Ctx(void* ctx, const uint8_t* data, uint32_t data_length,
                 uint8_t* mac, int32_t* mac_length );
 
 /**
  * Compute SHA1 HMAC over several data cunks.
  *
- * This functions takes several data chunk and computes the SHA1 HAMAC.
+ * This functions takes several data chunks and computes the SHA1 HAMAC. On return
+ * the SHA1 MAC context is ready to compute a HMAC for another data chunk.
  *
  * @param ctx 
  *     Pointer to initialized SHA1 HMAC context
@@ -147,7 +155,7 @@
  * @param mac_length
  *    Point to an integer that receives the length of the computed HMAC.
  */
-__EXPORT void hmacSha1Ctx(void* ctx, const uint8_t* data[], uint32_t data_length[],
+void hmacSha1Ctx(void* ctx, const uint8_t* data[], uint32_t data_length[],
                 uint8_t* mac, int32_t* mac_length );
 
 /**
@@ -157,4 +165,8 @@
  */
 void freeSha1HmacContext(void* ctx);
 
+
+/**
+ * @}
+ */
 #endif
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/macSkein.cpp b/jni/libccrtp/sources/src/ccrtp/crypto/macSkein.cpp
index 1f74739..ba4c260 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/macSkein.cpp
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/macSkein.cpp
@@ -15,7 +15,7 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <ccrtp/crypto/macSkein.h>
+#include <crypto/macSkein.h>
 #include <stdlib.h>
 
 void macSkein(uint8_t* key, int32_t key_length,
@@ -23,9 +23,9 @@
                uint8_t* mac, int32_t mac_length, SkeinSize_t skeinSize)
 {
     SkeinCtx_t ctx;
-    
+
     skeinCtxPrepare(&ctx, skeinSize);
-    
+
     skeinMacInit(&ctx, key, key_length, mac_length);
     skeinUpdate(&ctx, data, data_length);
     skeinFinal(&ctx, mac);
@@ -36,7 +36,7 @@
                uint8_t* mac, int32_t mac_length, SkeinSize_t skeinSize)
 {
     SkeinCtx_t ctx;
-    
+
     skeinCtxPrepare(&ctx, skeinSize);
 
     skeinMacInit(&ctx, key, key_length, mac_length);
@@ -62,7 +62,7 @@
                 uint8_t* mac)
 {
     SkeinCtx_t* pctx = (SkeinCtx_t*)ctx;
-    
+
     skeinUpdate(pctx, data, data_length);
     skeinFinal(pctx, mac);
     skeinReset(pctx);
@@ -72,7 +72,7 @@
                 uint8_t* mac)
 {
     SkeinCtx_t* pctx = (SkeinCtx_t*)ctx;
-    
+
     while (*data) {
         skeinUpdate(pctx, *data, *data_length);
         data++;
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/macSkein.h b/jni/libccrtp/sources/src/ccrtp/crypto/macSkein.h
index 013d8fc..71c2ad9 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/macSkein.h
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/macSkein.h
@@ -19,7 +19,7 @@
 #ifndef MAC_SKEIN_H
 #define MAC_SKEIN_H
 
-#include <ccrtp/crypto/skeinApi.h>
+#include <crypto/skeinApi.h>
 /**
  * @file macSkein.h
  * @brief Function that provide Skein MAC support
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/openssl/AesSrtp.cxx b/jni/libccrtp/sources/src/ccrtp/crypto/openssl/AesSrtp.cxx
deleted file mode 100644
index eb669f8..0000000
--- a/jni/libccrtp/sources/src/ccrtp/crypto/openssl/AesSrtp.cxx
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
-  Copyright (C) 2005, 2004 Erik Eliasson, Johan Bilien
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Lesser General Public
-  License as published by the Free Software Foundation; either
-  version 2.1 of the License, or (at your option) any later version.
-
-  This library 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
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public
-  License along with this library; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-  * In addition, as a special exception, the copyright holders give
-  * permission to link the code of portions of this program with the
-  * OpenSSL library under certain conditions as described in each
-  * individual source file, and distribute linked combinations
-  * including the two.
-  * You must obey the GNU General Public License in all respects
-  * for all of the code used other than OpenSSL.  If you modify
-  * file(s) with this exception, you may extend this exception to your
-  * version of the file(s), but you are not obligated to do so.  If you
-  * do not wish to do so, delete this exception statement from your
-  * version.  If you delete this exception statement from all source
-  * files in the program, then also delete it here.
-  */
-
-/**
- * @author Erik Eliasson <eliasson@it.kth.se>
- * @author Johan Bilien <jobi@via.ecp.fr>
- * @author Werner Dittmann <Werner.Dittmann@t-online.de>
- */
-
-extern void initializeOpenSSL();
-
-#include <stdlib.h>
-#include <openssl/aes.h>                // the include of openSSL
-#include <ccrtp/crypto/AesSrtp.h>
-#include <string.h>
-#include <stdio.h>
-
-AesSrtp::AesSrtp(int algo):key(NULL), algorithm(algo) {
-    void initializeOpenSSL();
-}
-
-AesSrtp::AesSrtp( uint8* k, int32 keyLength, int algo ):
-    key(NULL), algorithm(algo) {
-
-    void initializeOpenSSL();
-    setNewKey(k, keyLength);
-}
-
-AesSrtp::~AesSrtp() {
-    if (key != NULL)
-	delete[] (uint8*)key;
-}
-
-bool AesSrtp::setNewKey(const uint8* k, int32 keyLength) {
-    // release an existing key before setting a new one
-    if (key != NULL)
-	delete[] (uint8*)key;
-
-    if (!(keyLength == 16 || keyLength == 32)) {
-	return false;
-    }
-    key = new uint8[sizeof( AES_KEY )];
-    memset(key, 0, sizeof(AES_KEY) );
-    AES_set_encrypt_key(k, keyLength*8, (AES_KEY *)key );
-    return true;
-}
-
-
-void AesSrtp::encrypt( const uint8* input, uint8* output ){
-    AES_encrypt(input, output, (AES_KEY *)key);
-}
-
-void AesSrtp::get_ctr_cipher_stream( uint8* output, uint32 length,
-				     uint8* iv ){
-    uint16 ctr;
-    uint16 input;
-
-    unsigned char aes_input[SRTP_BLOCK_SIZE];
-    unsigned char temp[SRTP_BLOCK_SIZE];
-
-    memcpy(aes_input, iv, 14 );
-    iv += 14;
-
-    for( ctr = 0; ctr < length/SRTP_BLOCK_SIZE; ctr++ ){
-	input = ctr;
-	//compute the cipher stream
-	aes_input[14] = (uint8)((input & 0xFF00) >>  8);
-	aes_input[15] = (uint8)((input & 0x00FF));
-
-	AES_encrypt(aes_input, &output[ctr*SRTP_BLOCK_SIZE], (AES_KEY *)key );
-    }
-    if ((length % SRTP_BLOCK_SIZE) > 0) {
-        // Treat the last bytes:
-        input = ctr;
-        aes_input[14] = (uint8)((input & 0xFF00) >>  8);
-        aes_input[15] = (uint8)((input & 0x00FF));
-
-        AES_encrypt(aes_input, temp, (AES_KEY *)key );
-        memcpy( &output[ctr*SRTP_BLOCK_SIZE], temp, length % SRTP_BLOCK_SIZE );
-    }
-}
-
-
-void AesSrtp::ctr_encrypt( const uint8* input, uint32 input_length,
-			   uint8* output, uint8* iv ) {
-
-    if (key == NULL)
-	return;
-
-    uint8* cipher_stream = new uint8[input_length];
-
-    get_ctr_cipher_stream( cipher_stream, input_length, iv );
-
-    for( unsigned int i = 0; i < input_length; i++ ){
-	output[i] = cipher_stream[i] ^ input[i];
-    }
-    delete []cipher_stream;
-}
-
-void AesSrtp::ctr_encrypt( uint8* data, uint32 data_length, uint8* iv ) {
-
-    if (key == NULL)
-	return;
-
-    //unsigned char cipher_stream[data_length];
-    uint8* cipher_stream = new uint8[data_length];
-
-    get_ctr_cipher_stream( cipher_stream, data_length, iv );
-
-    for( uint32 i = 0; i < data_length; i++ ){
-	data[i] ^= cipher_stream[i];
-    }
-    delete[] cipher_stream;
-}
-
-void AesSrtp::f8_encrypt(const uint8* data, uint32 data_length,
-			 uint8* iv, uint8* origKey, int32 keyLen,
-			 uint8* salt, int32 saltLen, AesSrtp* f8Cipher ) {
-
-    f8_encrypt(data, data_length, const_cast<uint8*>(data), iv, origKey, keyLen, salt, saltLen, f8Cipher);
-}
-
-#define MAX_KEYLEN 32
-
-void AesSrtp::f8_encrypt(const uint8* in, uint32 in_length, uint8* out,
-			 uint8* iv, uint8* origKey, int32 keyLen,
-			 uint8* salt, int32 saltLen, AesSrtp* f8Cipher ) {
-
-
-    unsigned char *cp_in, *cp_in1, *cp_out;
-    int i;
-    int offset = 0;
-
-    unsigned char ivAccent[SRTP_BLOCK_SIZE];
-    unsigned char maskedKey[MAX_KEYLEN];
-    unsigned char saltMask[MAX_KEYLEN];
-    unsigned char S[SRTP_BLOCK_SIZE];
-
-    F8_CIPHER_CTX f8ctx;
-
-    if (key == NULL)
-	return;
-
-    if (keyLen > MAX_KEYLEN)
-	return;
-
-    if (saltLen > keyLen)
-	return;
-
-    /*
-     * Get memory for the derived IV (IV')
-     */
-    f8ctx.ivAccent = ivAccent;
-
-    /*
-     * First copy the salt into the mask field, then fill with 0x55 to
-     * get a full key.
-     */
-    memcpy(saltMask, salt, saltLen);
-    memset(saltMask+saltLen, 0x55, keyLen-saltLen);
-
-    /*
-     * XOR the original key with the above created mask to
-     * get the special key.
-     */
-    cp_out = maskedKey;
-    cp_in = origKey;
-    cp_in1 = saltMask;
-    for (i = 0; i < keyLen; i++) {
-        *cp_out++ = *cp_in++ ^ *cp_in1++;
-    }
-    /*
-     * Prepare the a new AES cipher with the special key to compute IV'
-     */
-    f8Cipher->setNewKey(maskedKey, keyLen);
-
-    /*
-     * Use the masked key to encrypt the original IV to produce IV'.
-     *
-     * After computing the IV' we don't need this cipher context anymore, free it.
-     */
-    f8Cipher->encrypt(iv, f8ctx.ivAccent);
-
-    f8ctx.J = 0;                       // initialize the counter
-    f8ctx.S = S;		       // get the key stream buffer
-
-    memset(f8ctx.S, 0, SRTP_BLOCK_SIZE); // initial value for key stream
-
-    while (in_length >= SRTP_BLOCK_SIZE) {
-        processBlock(&f8ctx, in+offset, SRTP_BLOCK_SIZE, out+offset);
-        in_length -= SRTP_BLOCK_SIZE;
-        offset += SRTP_BLOCK_SIZE;
-    }
-    if (in_length > 0) {
-        processBlock(&f8ctx, in+offset, in_length, out+offset);
-    }
-}
-
-int AesSrtp::processBlock(F8_CIPHER_CTX *f8ctx, const uint8* in, int32 length, uint8* out) {
-
-    int i;
-    const uint8 *cp_in;
-    uint8* cp_in1, *cp_out;
-    uint32_t *ui32p;
-
-    /*
-     * XOR the previous key stream with IV'
-     * ( S(-1) xor IV' )
-     */
-    cp_in = f8ctx->ivAccent;
-    cp_out = f8ctx->S;
-    for (i = 0; i < SRTP_BLOCK_SIZE; i++) {
-        *cp_out++ ^= *cp_in++;
-    }
-    /*
-     * Now XOR (S(n-1) xor IV') with the current counter, then increment the counter
-     */
-    ui32p = (uint32_t *)f8ctx->S;
-    ui32p[3] ^= htonl(f8ctx->J);
-    f8ctx->J++;
-    /*
-     * Now compute the new key stream using AES encrypt
-     */
-    AES_encrypt(f8ctx->S, f8ctx->S, (AES_KEY *)key);
-    /*
-     * as the last step XOR the plain text with the key stream to produce
-     * the ciphertext.
-     */
-    cp_out = out;
-    cp_in = in;
-    cp_in1 = f8ctx->S;
-    for (i = 0; i < length; i++) {
-        *cp_out++ = *cp_in++ ^ *cp_in1++;
-    }
-    return length;
-}
-
-
-/** EMACS **
- * Local variables:
- * mode: c++
- * c-default-style: ellemtel
- * c-basic-offset: 4
- * End:
- */
-
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/openssl/InitializeOpenSSL.cxx b/jni/libccrtp/sources/src/ccrtp/crypto/openssl/InitializeOpenSSL.cxx
deleted file mode 100755
index f0b3258..0000000
--- a/jni/libccrtp/sources/src/ccrtp/crypto/openssl/InitializeOpenSSL.cxx
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
-  Copyright (C) 2006 Werner Dittmann
-
-  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, 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, Boston, MA 02111.
-*/
-
-#include <stdio.h>
-#include <openssl/evp.h>
-
-#include <private.h>
-
-#ifdef OPENSSL_SYS_WIN32
-#include <windows.h>
-#endif
-#if defined SOLARIS && !defined HAVE_PTHREAD_H
-#include <synch.h>
-#include <thread.h>
-#endif
-#if defined HAVE_PTHREAD_H && !defined SOLARIS
-#include <pthread.h>
-#endif
-
-static void threadLockSetup(void);
-static void threadLockCleanup(void);
-static void myLockingCallback(int, int, const char *, int);
-
-/**
- * Implement the locking callback functions for openSSL.
- *
- * Unfortunatly we can't use the Commonc++ Mutex here because the
- * Mutex may use (for some cases) the Commonc++ Thread class. OpenSSL
- * does not use this Thread class.
- */
-
-static int initialized = 0;
-
-int initializeOpenSSL ()
-{
-
-    if (initialized) {
-	return 1;
-    }
-    initialized = 1;
-    threadLockSetup();
-    return 1;
-}
-
-int finalizeOpenSSL ()
-{
-	if(!initialized)
-		return 1;
-
-	initialized = 0;
-	threadLockCleanup();
-	return 1;
-}
-
-#ifdef OPENSSL_SYS_WIN32
-
-static HANDLE *lock_cs;
-
-static void threadLockSetup(void) {
-    int i;
-
-    lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE));
-    for (i = 0; i < CRYPTO_num_locks(); i++) {
-	lock_cs[i] = CreateMutex(NULL,FALSE,NULL);
-    }
-
-    CRYPTO_set_locking_callback((void (*)(int,int,const char *,int))myLockingCallback);
-    /* id callback defined */
-}
-
-static void threadLockCleanup(void) {
-    int i;
-
-    CRYPTO_set_locking_callback(NULL);
-    for (i = 0; i < CRYPTO_num_locks(); i++) {
-	CloseHandle(lock_cs[i]);
-    }
-    OPENSSL_free(lock_cs);
-}
-
-static void myLockingCallback(int mode, int type, const char *file, int line) {
-    if (mode & CRYPTO_LOCK) {
-	WaitForSingleObject(lock_cs[type], INFINITE);
-    }
-    else {
-	ReleaseMutex(lock_cs[type]);
-    }
-}
-
-#endif /* OPENSSL_SYS_WIN32 */
-
-
-#if defined SOLARIS && !defined HAVE_PTHREAD_H
-
-static mutex_t *lock_cs;
-static long *lock_count;
-
-static void threadLockSetup(void) {
-    int i;
-
-    lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(mutex_t));
-    lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
-    for (i = 0; i < CRYPTO_num_locks(); i++) {
-	lock_count[i] = 0;
-	/* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */
-	mutex_init(&(lock_cs[i]), USYNC_THREAD, NULL);
-    }
-    CRYPTO_set_locking_callback((void (*)(int, int ,const char *, int))myLockingCallback);
-}
-
-static void threadLockCleanup(void) {
-    int i;
-
-    CRYPTO_set_locking_callback(NULL);
-
-    fprintf(stderr,"cleanup\n");
-
-    for (i = 0; i < CRYPTO_num_locks(); i++) {
-	/* rwlock_destroy(&(lock_cs[i])); */
-	mutex_destroy(&(lock_cs[i]));
-	fprintf(stderr,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i));
-    }
-    OPENSSL_free(lock_cs);
-    OPENSSL_free(lock_count);
-}
-
-static void myLockingCallback(int mode, int type, const char *file, int line)
-{
-#ifdef undef
-    fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
-	    CRYPTO_thread_id(),
-	    (mode&CRYPTO_LOCK)?"l":"u",
-	    (type&CRYPTO_READ)?"r":"w",file,line);
-#endif
-
-    /*
-      if (CRYPTO_LOCK_SSL_CERT == type)
-      fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
-      CRYPTO_thread_id(),
-      mode,file,line);
-    */
-    if (mode & CRYPTO_LOCK) {
-	mutex_lock(&(lock_cs[type]));
-	lock_count[type]++;
-    }
-    else {
-	mutex_unlock(&(lock_cs[type]));
-    }
-}
-
-static unsigned long solaris_thread_id(void) {
-    unsigned long ret;
-
-    ret=(unsigned long)thr_self();
-    return(ret);
-}
-#endif /* SOLARIS */
-
-
-#if defined HAVE_PTHREAD_H && !defined SOLARIS
-
-static pthread_mutex_t* lock_cs;
-static long* lock_count;
-
-static void threadLockSetup(void) {
-    int i;
-
-    lock_cs = (pthread_mutex_t*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
-    lock_count = (long*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
-    for (i = 0; i < CRYPTO_num_locks(); i++) {
-	lock_count[i] = 0;
-	pthread_mutex_init(&(lock_cs[i]),NULL);
-    }
-
-    // CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id);
-    CRYPTO_set_locking_callback((void (*)(int, int ,const char *, int))myLockingCallback);
-}
-
-static void threadLockCleanup(void)
-{
-    int i;
-
-    CRYPTO_set_locking_callback(NULL);
-    fprintf(stderr,"cleanup\n");
-    for (i = 0; i < CRYPTO_num_locks(); i++) {
-	pthread_mutex_destroy(&(lock_cs[i]));
-	fprintf(stderr,"%8ld:%s\n",lock_count[i],
-		CRYPTO_get_lock_name(i));
-    }
-    OPENSSL_free(lock_cs);
-    OPENSSL_free(lock_count);
-}
-
-static void myLockingCallback(int mode, int type, const char *file,
-			      int line) {
-#ifdef undef
-    fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
-	    CRYPTO_thread_id(),
-	    (mode&CRYPTO_LOCK)?"l":"u",
-	    (type&CRYPTO_READ)?"r":"w",file,line);
-#endif
-    if (mode & CRYPTO_LOCK) {
-	pthread_mutex_lock(&(lock_cs[type]));
-	lock_count[type]++;
-    }
-    else {
-	pthread_mutex_unlock(&(lock_cs[type]));
-    }
-}
-
-/*
-static unsigned long pthreads_thread_id(void)
-{
-    unsigned long ret;
-
-    ret = (unsigned long)pthread_self();
-    return(ret);
-}
-*/
-
-#endif /* LIBPTHREAD && !SOLARIS */
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/openssl/SrtpSymCrypto.cpp b/jni/libccrtp/sources/src/ccrtp/crypto/openssl/SrtpSymCrypto.cpp
new file mode 100644
index 0000000..569e540
--- /dev/null
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/openssl/SrtpSymCrypto.cpp
@@ -0,0 +1,331 @@
+/*
+  Copyright (C) 2005, 2004, 2012 Erik Eliasson, Johan Bilien, Werner Dittmann
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library 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
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+  * In addition, as a special exception, the copyright holders give
+  * permission to link the code of portions of this program with the
+  * OpenSSL library under certain conditions as described in each
+  * individual source file, and distribute linked combinations
+  * including the two.
+  * You must obey the GNU General Public License in all respects
+  * for all of the code used other than OpenSSL.  If you modify
+  * file(s) with this exception, you may extend this exception to your
+  * version of the file(s), but you are not obligated to do so.  If you
+  * do not wish to do so, delete this exception statement from your
+  * version.  If you delete this exception statement from all source
+  * files in the program, then also delete it here.
+  */
+
+/**
+ * @author Erik Eliasson <eliasson@it.kth.se>
+ * @author Johan Bilien <jobi@via.ecp.fr>
+ * @author Werner Dittmann <Werner.Dittmann@t-online.de>
+ */
+
+#define MAKE_F8_TEST
+
+#include <stdlib.h>
+#include <openssl/aes.h>                // the include of openSSL
+#include <crypto/SrtpSymCrypto.h>
+#include <crypto/twofish.h>
+#include <string.h>
+#include <stdio.h>
+
+#if defined(_MSC_VER) || defined(WIN32) || defined(_WIN32)
+#include <windows.h>
+#else
+#include <arpa/inet.h>
+#endif
+
+SrtpSymCrypto::SrtpSymCrypto(int algo):key(NULL), algorithm(algo) {
+}
+
+SrtpSymCrypto::SrtpSymCrypto( uint8_t* k, int32_t keyLength, int algo ):
+    key(NULL), algorithm(algo) {
+
+    setNewKey(k, keyLength);
+}
+
+SrtpSymCrypto::~SrtpSymCrypto() {
+    if (key != NULL) {
+        if (algorithm == SrtpEncryptionAESCM || algorithm == SrtpEncryptionAESF8) {
+            memset(key, 0, sizeof(AES_KEY) );
+        }
+        else if (algorithm == SrtpEncryptionTWOCM || algorithm == SrtpEncryptionTWOF8) {
+            memset(key, 0, sizeof(Twofish_key));
+        }
+        delete[] (uint8_t*)key;
+        key = NULL;
+    }
+}
+
+static int twoFishInit = 0;
+
+bool SrtpSymCrypto::setNewKey(const uint8_t* k, int32_t keyLength) {
+    // release an existing key before setting a new one
+    if (key != NULL)
+        delete[] (uint8_t*)key;
+
+    if (!(keyLength == 16 || keyLength == 32)) {
+        return false;
+    }
+    if (algorithm == SrtpEncryptionAESCM || algorithm == SrtpEncryptionAESF8) {
+        key = new uint8_t[sizeof(AES_KEY)];
+        memset(key, 0, sizeof(AES_KEY) );
+        AES_set_encrypt_key(k, keyLength*8, (AES_KEY *)key);
+    }
+    else if (algorithm == SrtpEncryptionTWOCM || algorithm == SrtpEncryptionTWOF8) {
+        if (!twoFishInit) {
+            Twofish_initialise();
+            twoFishInit = 1;
+        }
+        key = new uint8_t[sizeof(Twofish_key)];
+        memset(key, 0, sizeof(Twofish_key));
+        Twofish_prepare_key((Twofish_Byte*)k, keyLength,  (Twofish_key*)key);
+    }
+    else
+        return false;
+
+    return true;
+}
+
+
+void SrtpSymCrypto::encrypt(const uint8_t* input, uint8_t* output ) {
+    if (algorithm == SrtpEncryptionAESCM || algorithm == SrtpEncryptionAESF8) {
+        AES_encrypt(input, output, (AES_KEY *)key);
+    }
+    else if (algorithm == SrtpEncryptionTWOCM || algorithm == SrtpEncryptionTWOF8) {
+        Twofish_encrypt((Twofish_key*)key, (Twofish_Byte*)input,
+                        (Twofish_Byte*)output);
+    }
+}
+
+void SrtpSymCrypto::get_ctr_cipher_stream(uint8_t* output, uint32_t length,
+                                    uint8_t* iv ) {
+    uint16_t ctr = 0;
+    unsigned char temp[SRTP_BLOCK_SIZE];
+
+    for(ctr = 0; ctr < length/SRTP_BLOCK_SIZE; ctr++) {
+        //compute the cipher stream
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, &output[ctr*SRTP_BLOCK_SIZE]);
+    }
+    if ((length % SRTP_BLOCK_SIZE) > 0) {
+        // Treat the last bytes:
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        memcpy(&output[ctr*SRTP_BLOCK_SIZE], temp, length % SRTP_BLOCK_SIZE );
+    }
+}
+
+void SrtpSymCrypto::ctr_encrypt(const uint8_t* input, uint32_t input_length,
+                           uint8_t* output, uint8_t* iv ) {
+
+    if (key == NULL)
+        return;
+
+    uint16_t ctr = 0;
+    unsigned char temp[SRTP_BLOCK_SIZE];
+
+    int l = input_length/SRTP_BLOCK_SIZE;
+    for (ctr = 0; ctr < l; ctr++ ) {
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        for (int i = 0; i < SRTP_BLOCK_SIZE; i++ ) {
+            *output++ = temp[i] ^ *input++;
+        }
+
+    }
+    l = input_length % SRTP_BLOCK_SIZE;
+    if (l > 0) {
+        // Treat the last bytes:
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        for (int i = 0; i < l; i++ ) {
+            *output++ = temp[i] ^ *input++;
+        }
+    }
+}
+
+void SrtpSymCrypto::ctr_encrypt( uint8_t* data, uint32_t data_length, uint8_t* iv ) {
+
+    if (key == NULL)
+        return;
+
+    uint16_t ctr = 0;
+    unsigned char temp[SRTP_BLOCK_SIZE];
+
+    int l = data_length/SRTP_BLOCK_SIZE;
+    for (ctr = 0; ctr < l; ctr++ ) {
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        for (int i = 0; i < SRTP_BLOCK_SIZE; i++ ) {
+            *data++ ^= temp[i];
+        }
+
+    }
+    l = data_length % SRTP_BLOCK_SIZE;
+    if (l > 0) {
+        // Treat the last bytes:
+        iv[14] = (uint8_t)((ctr & 0xFF00) >>  8);
+        iv[15] = (uint8_t)((ctr & 0x00FF));
+
+        encrypt(iv, temp);
+        for (int i = 0; i < l; i++ ) {
+            *data++ ^= temp[i];
+        }
+    }
+}
+
+void SrtpSymCrypto::f8_encrypt(const uint8_t* data, uint32_t data_length,
+                         uint8_t* iv, SrtpSymCrypto* f8Cipher ) {
+
+    f8_encrypt(data, data_length, const_cast<uint8_t*>(data), iv, f8Cipher);
+}
+
+#define MAX_KEYLEN 32
+
+void SrtpSymCrypto::f8_deriveForIV(SrtpSymCrypto* f8Cipher, uint8_t* key, int32_t keyLen,
+             uint8_t* salt, int32_t saltLen) {
+
+    unsigned char *cp_in, *cp_in1, *cp_out;
+
+    unsigned char maskedKey[MAX_KEYLEN];
+    unsigned char saltMask[MAX_KEYLEN];
+
+    if (keyLen > MAX_KEYLEN)
+        return;
+
+    if (saltLen > keyLen)
+        return;
+    /*
+     * First copy the salt into the mask field, then fill with 0x55 to
+     * get a full key.
+     */
+    memcpy(saltMask, salt, saltLen);
+    memset(saltMask+saltLen, 0x55, keyLen-saltLen);
+
+    /*
+     * XOR the original key with the above created mask to
+     * get the special key.
+     */
+    cp_out = maskedKey;
+    cp_in = key;
+    cp_in1 = saltMask;
+    for (int i = 0; i < keyLen; i++) {
+        *cp_out++ = *cp_in++ ^ *cp_in1++;
+    }
+    /*
+     * Prepare the a new AES cipher with the special key to compute IV'
+     */
+    f8Cipher->setNewKey(maskedKey, keyLen);
+}
+
+void SrtpSymCrypto::f8_encrypt(const uint8_t* in, uint32_t in_length, uint8_t* out,
+                         uint8_t* iv, SrtpSymCrypto* f8Cipher ) {
+
+
+    int offset = 0;
+
+    unsigned char ivAccent[SRTP_BLOCK_SIZE];
+    unsigned char S[SRTP_BLOCK_SIZE];
+
+    F8_CIPHER_CTX f8ctx;
+
+    if (key == NULL)
+        return;
+    /*
+     * Get memory for the derived IV (IV')
+     */
+    f8ctx.ivAccent = ivAccent;
+    /*
+     * Use the derived IV encryption setup to encrypt the original IV to produce IV'.
+     */
+    f8Cipher->encrypt(iv, f8ctx.ivAccent);
+
+    f8ctx.J = 0;                       // initialize the counter
+    f8ctx.S = S;               // get the key stream buffer
+
+    memset(f8ctx.S, 0, SRTP_BLOCK_SIZE); // initial value for key stream
+
+    while (in_length >= SRTP_BLOCK_SIZE) {
+        processBlock(&f8ctx, in+offset, SRTP_BLOCK_SIZE, out+offset);
+        in_length -= SRTP_BLOCK_SIZE;
+        offset += SRTP_BLOCK_SIZE;
+    }
+    if (in_length > 0) {
+        processBlock(&f8ctx, in+offset, in_length, out+offset);
+    }
+}
+
+int SrtpSymCrypto::processBlock(F8_CIPHER_CTX *f8ctx, const uint8_t* in, int32_t length, uint8_t* out) {
+
+    int i;
+    const uint8_t *cp_in;
+    uint8_t* cp_in1, *cp_out;
+    uint32_t *ui32p;
+
+    /*
+     * XOR the previous key stream with IV'
+     * ( S(-1) xor IV' )
+     */
+    cp_in = f8ctx->ivAccent;
+    cp_out = f8ctx->S;
+    for (i = 0; i < SRTP_BLOCK_SIZE; i++) {
+        *cp_out++ ^= *cp_in++;
+    }
+    /*
+     * Now XOR (S(n-1) xor IV') with the current counter, then increment the counter
+     */
+    ui32p = (uint32_t *)f8ctx->S;
+    ui32p[3] ^= htonl(f8ctx->J);
+    f8ctx->J++;
+    /*
+     * Now compute the new key stream using AES encrypt
+     */
+    encrypt(f8ctx->S, f8ctx->S);
+    /*
+     * as the last step XOR the plain text with the key stream to produce
+     * the ciphertext.
+     */
+    cp_out = out;
+    cp_in = in;
+    cp_in1 = f8ctx->S;
+    for (i = 0; i < length; i++) {
+        *cp_out++ = *cp_in++ ^ *cp_in1++;
+    }
+    return length;
+}
+
+
+/** EMACS **
+ * Local variables:
+ * mode: c++
+ * c-default-style: ellemtel
+ * c-basic-offset: 4
+ * End:
+ */
+
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/openssl/hmac.cpp b/jni/libccrtp/sources/src/ccrtp/crypto/openssl/hmac.cpp
index 4edf375..88d33a1 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/openssl/hmac.cpp
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/openssl/hmac.cpp
@@ -37,7 +37,7 @@
 
 #include <stdint.h>
 #include <openssl/hmac.h>
-#include <ccrtp/crypto/hmac.h>
+#include <crypto/hmac.h>
 
 void hmac_sha1(uint8_t * key, int32_t key_length,
                const uint8_t* data, uint32_t data_length,
@@ -53,15 +53,15 @@
                 uint32_t data_chunck_length[],
                 uint8_t* mac, int32_t* mac_length ) {
     HMAC_CTX ctx;
-    HMAC_CTX_init( &ctx );
-    HMAC_Init_ex( &ctx, key, key_length, EVP_sha1(), NULL );
-    while ( *data_chunks ) {
-        HMAC_Update( &ctx, *data_chunks, *data_chunck_length );
+    HMAC_CTX_init(&ctx);
+    HMAC_Init_ex(&ctx, key, key_length, EVP_sha1(), NULL);
+    while (*data_chunks) {
+        HMAC_Update(&ctx, *data_chunks, *data_chunck_length);
         data_chunks ++;
         data_chunck_length ++;
     }
-    HMAC_Final( &ctx, mac, reinterpret_cast<uint32_t*>(mac_length) );
-    HMAC_CTX_cleanup( &ctx );
+    HMAC_Final(&ctx, mac, reinterpret_cast<uint32_t*>(mac_length));
+    HMAC_CTX_cleanup(&ctx);
 }
 
 void* createSha1HmacContext(uint8_t* key, int32_t key_length)
@@ -77,7 +77,7 @@
                 uint8_t* mac, int32_t* mac_length)
 {
     HMAC_CTX* pctx = (HMAC_CTX*)ctx;
-    
+
     HMAC_Init_ex(pctx, NULL, 0, NULL, NULL );
     HMAC_Update(pctx, data, data_length );
     HMAC_Final(pctx, mac, reinterpret_cast<uint32_t*>(mac_length) );
@@ -87,7 +87,7 @@
                 uint8_t* mac, int32_t* mac_length )
 {
     HMAC_CTX* pctx = (HMAC_CTX*)ctx;
-    
+
     HMAC_Init_ex(pctx, NULL, 0, NULL, NULL );
     while (*data) {
         HMAC_Update(pctx, *data, *data_length);
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/skein.c b/jni/libccrtp/sources/src/ccrtp/crypto/skein.c
index 60efdcc..5935a2a 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/skein.c
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/skein.c
@@ -11,8 +11,8 @@
 #define  SKEIN_PORT_CODE /* instantiate any code in skein_port.h */

 

 #include <string.h>       /* get the memcpy/memset functions */

-#include <ccrtp/crypto/skein.h> /* get the Skein API definitions   */

-#include <ccrtp/crypto/skein_iv.h>    /* get precomputed IVs */

+#include <crypto/skein.h> /* get the Skein API definitions   */

+#include <crypto/skein_iv.h>    /* get precomputed IVs */

 

 /*****************************************************************/

 /* External function to process blkCnt (nonzero) full block(s) of data. */

diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/skein.h b/jni/libccrtp/sources/src/ccrtp/crypto/skein.h
index 5634cb0..345a112 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/skein.h
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/skein.h
@@ -33,7 +33,7 @@
 #endif

 

 #include <stddef.h>                          /* get size_t definition */

-#include <ccrtp/crypto/skein_port.h>               /* get platform-specific definitions */

+#include <crypto/skein_port.h>               /* get platform-specific definitions */

 

 enum

     {

diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/skeinApi.c b/jni/libccrtp/sources/src/ccrtp/crypto/skeinApi.c
index b669146..84f0120 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/skeinApi.c
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/skeinApi.c
@@ -25,7 +25,7 @@
 */
 
 #define SKEIN_ERR_CHECK 1
-#include <ccrtp/crypto/skeinApi.h>
+#include <crypto/skeinApi.h>
 #include <string.h>
 #include <stdio.h>
 
@@ -53,7 +53,7 @@
      * The beauty of C :-) .
      */
     X = ctx->m.s256.X;
-    Xlen = ctx->skeinSize/8;
+    Xlen = (size_t)(ctx->skeinSize/8);
     /*
      * If size is the same and hash bit length is zero then reuse
      * the save chaining variables.
@@ -91,7 +91,7 @@
     Skein_Assert(ctx, SKEIN_FAIL);
 
     X = ctx->m.s256.X;
-    Xlen = ctx->skeinSize/8;
+    Xlen = (size_t)(ctx->skeinSize/8);
 
     Skein_Assert(hashBitLen, SKEIN_BAD_HASHLEN);
 
@@ -132,7 +132,7 @@
      * The beautiy of C :-) .
      */
     X = ctx->m.s256.X;
-    Xlen = ctx->skeinSize/8;
+    Xlen = (size_t)(ctx->skeinSize/8);
     /*
      * If size is the same and hash bit length is zero then reuse
      * the save chaining variables.
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/skeinApi.h b/jni/libccrtp/sources/src/ccrtp/crypto/skeinApi.h
index cd07632..2f25073 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/skeinApi.h
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/skeinApi.h
@@ -78,8 +78,20 @@
  * 
  */
 
-#include <ccrtp/crypto/skein.h>
+#include <crypto/skein.h>
+
+#ifdef _MSC_VER
+typedef signed __int8 int8_t;
+typedef unsigned __int8 uint8_t;
+typedef signed __int16 int16_t;
+typedef unsigned __int16 uint16_t;
+typedef signed __int32 int32_t;
+typedef unsigned __int32 uint32_t;
+typedef signed __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#else
 #include <stdint.h>
+#endif
 
 #ifdef __cplusplus
 extern "C"
diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/skein_block.c b/jni/libccrtp/sources/src/ccrtp/crypto/skein_block.c
index 759d000..fbf37e7 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/skein_block.c
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/skein_block.c
@@ -15,7 +15,7 @@
 ************************************************************************/

 

 #include <string.h>

-#include <ccrtp/crypto/skein.h>

+#include <crypto/skein.h>

 

 #ifndef SKEIN_USE_ASM

 #define SKEIN_USE_ASM   (0)                     /* default is all C code (no ASM) */

diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/skein_iv.h b/jni/libccrtp/sources/src/ccrtp/crypto/skein_iv.h
index 4a02b39..0c62fac 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/skein_iv.h
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/skein_iv.h
@@ -1,7 +1,7 @@
 #ifndef _SKEIN_IV_H_

 #define _SKEIN_IV_H_

 

-#include <ccrtp/crypto/skein.h>    /* get Skein macros and types */

+#include <crypto/skein.h>    /* get Skein macros and types */

 

 /*

 ***************** Pre-computed Skein IVs *******************

diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/skein_port.h b/jni/libccrtp/sources/src/ccrtp/crypto/skein_port.h
index e62069e..256e9d5 100644
--- a/jni/libccrtp/sources/src/ccrtp/crypto/skein_port.h
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/skein_port.h
@@ -15,9 +15,12 @@
 ** 

 ********************************************************************/

 

-#include <ccrtp/crypto/brg_types.h>                      /* get integer type definitions */

+#include <crypto/brg_types.h>                      /* get integer type definitions */

 

+/*r3gis3r : android already has that defined in types */

+#ifndef ANDROID

 typedef unsigned int    uint_t;             /* native unsigned integer */

+#endif

 typedef uint_8t         u08b_t;             /*  8-bit unsigned integer */

 typedef uint_64t        u64b_t;             /* 64-bit unsigned integer */

 

@@ -46,7 +49,7 @@
  */

 #ifndef SKEIN_NEED_SWAP /* compile-time "override" for endianness? */

 

-#include <ccrtp/crypto/brg_endian.h>              /* get endianness selection */

+#include <crypto/brg_endian.h>              /* get endianness selection */

 #if   PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN

     /* here for big-endian CPUs */

 #define SKEIN_NEED_SWAP   (1)

diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/twofish.c b/jni/libccrtp/sources/src/ccrtp/crypto/twofish.c
new file mode 100644
index 0000000..3d390ea
--- /dev/null
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/twofish.c
@@ -0,0 +1,1733 @@
+/* 

+ * Fast, portable, and easy-to-use Twofish implementation,  

+ * Version 0.3. 

+ * Copyright (c) 2002 by Niels Ferguson.  

+ * (See further down for the almost-unrestricted licensing terms.) 

+ * 

+ * -------------------------------------------------------------------------- 

+ * There are two files for this implementation: 

+ * - twofish.h, the header file. 

+ * - twofish.c, the code file. 

+ * 

+ * To incorporate this code into your program you should: 

+ * - Check the licensing terms further down in this comment. 

+ * - Fix the two type definitions in twofish.h to suit your platform. 

+ * - Fix a few definitions in twofish.c in the section marked  

+ *   PLATFORM FIXES. There is one important ones that affects  

+ *   functionality, and then a few definitions that you can optimise  

+ *   for efficiency but those have no effect on the functionality.  

+ *   Don't change anything else. 

+ * - Put the code in your project and compile it. 

+ * 

+ * To use this library you should: 

+ * - Call Twofish_initialise() in your program before any other function in 

+ *   this library. 

+ * - Use Twofish_prepare_key(...) to convert a key to internal form. 

+ * - Use Twofish_encrypt(...) and Twofish_decrypt(...) to encrypt and decrypt 

+ *   data. 

+ * See the comments in the header file for details on these functions. 

+ * -------------------------------------------------------------------------- 

+ *  

+ * There are many Twofish implementation available for free on the web. 

+ * Most of them are hard to integrate into your own program. 

+ * As we like people to use our cipher, I thought I would make it easier.  

+ * Here is a free and easy-to-integrate Twofish implementation in C. 

+ * The latest version is always available from my personal home page at 

+ *    http://niels.ferguson.net/ 

+ * 

+ * Integrating library code into a project is difficult because the library 

+ * header files interfere with the project's header files and code.  

+ * And of course the project's header files interfere with the library code. 

+ * I've tried to resolve these problems here.  

+ * The header file of this implementation is very light-weight.  

+ * It contains two typedefs, a structure, and a few function declarations. 

+ * All names it defines start with "Twofish_".  

+ * The header file is therefore unlikely to cause problems in your project. 

+ * The code file of this implementation doesn't need to include the header 

+ * files of the project. There is thus no danger of the project interfering 

+ * with all the definitions and macros of the Twofish code. 

+ * In most situations, all you need to do is fill in a few platform-specific 

+ * definitions in the header file and code file,  

+ * and you should be able to run the Twofish code in your project. 

+ * I estimate it should take you less than an hour to integrate this code 

+ * into your project, most of it spent reading the comments telling you what 

+ * to do. 

+ * 

+ * For people using C++: it is very easy to wrap this library into a 

+ * TwofishKey class. One of the big advantages is that you can automate the 

+ * wiping of the key material in the destructor. I have not provided a C++ 

+ * class because the interface depends too much on the abstract base class  

+ * you use for block ciphers in your program, which I don't know about. 

+ * 

+ * This implementation is designed for use on PC-class machines. It uses the  

+ * Twofish 'full' keying option which uses large tables. Total table size is  

+ * around 5-6 kB for static tables plus 4.5 kB for each pre-processed key. 

+ * If you need an implementation that uses less memory, 

+ * take a look at Brian Gladman's code on his web site: 

+ *     http://fp.gladman.plus.com/cryptography_technology/aes/ 

+ * He has code for all AES candidates. 

+ * His Twofish code has lots of options trading off table size vs. speed. 

+ * You can also take a look at the optimised code by Doug Whiting on the 

+ * Twofish web site 

+ *      http://www.counterpane.com/twofish.html 

+ * which has loads of options. 

+ * I believe these existing implementations are harder to re-use because they 

+ * are not clean libraries and they impose requirements on the environment.  

+ * This implementation is very careful to minimise those,  

+ * and should be easier to integrate into any larger program. 

+ * 

+ * The default mode of this implementation is fully portable as it uses no 

+ * behaviour not defined in the C standard. (This is harder than you think.) 

+ * If you have any problems porting the default mode, please let me know 

+ * so that I can fix the problem. (But only if this code is at fault, I  

+ * don't fix compilers.) 

+ * Most of the platform fixes are related to non-portable but faster ways  

+ * of implementing certain functions. 

+ * 

+ * In general I've tried to make the code as fast as possible, at the expense 

+ * of memory and code size. However, C does impose limits, and this  

+ * implementation will be slower than an optimised assembler implementation. 

+ * But beware of assembler implementations: a good Pentium implementation 

+ * uses completely different code than a good Pentium II implementation. 

+ * You basically have to re-write the assembly code for every generation of 

+ * processor. Unless you are severely pressed for speed, stick with C. 

+ * 

+ * The initialisation routine of this implementation contains a self-test. 

+ * If initialisation succeeds without calling the fatal routine, then 

+ * the implementation works. I don't think you can break the implementation 

+ * in such a way that it still passes the tests, unless you are malicious. 

+ * In other words: if the initialisation routine returns,  

+ * you have successfully ported the implementation.  

+ * (Or not implemented the fatal routine properly, but that is your problem.) 

+ * 

+ * I'm indebted to many people who helped me in one way or another to write 

+ * this code. During the design of Twofish and the AES process I had very  

+ * extensive discussions of all implementation issues with various people. 

+ * Doug Whiting in particular provided a wealth of information. The Twofish  

+ * team spent untold hours discussion various cipher features, and their  

+ * implementation. Brian Gladman implemented all AES candidates in C,  

+ * and we had some fruitful discussions on how to implement Twofish in C. 

+ * Jan Nieuwenhuizen tested this code on Linux using GCC. 

+ * 

+ * Now for the license: 

+ * The author hereby grants a perpetual license to everybody to 

+ * use this code for any purpose as long as the copyright message is included 

+ * in the source code of this or any derived work. 

+ *  

+ * Yes, this means that you, your company, your club, and anyone else 

+ * can use this code anywhere you want. You can change it and distribute it 

+ * under the GPL, include it in your commercial product without releasing 

+ * the source code, put it on the web, etc.  

+ * The only thing you cannot do is remove my copyright message,  

+ * or distribute any source code based on this implementation that does not  

+ * include my copyright message.  

+ *  

+ * I appreciate a mention in the documentation or credits,  

+ * but I understand if that is difficult to do. 

+ * I also appreciate it if you tell me where and why you used my code. 

+ * 

+ * Please send any questions or comments to niels@ferguson.net 

+ * 

+ * Have Fun! 

+ * 

+ * Niels 

+ */ 

+ 

+/* 

+ * DISCLAIMER: As I'm giving away my work for free, I'm of course not going 

+ * to accept any liability of any form. This code, or the Twofish cipher, 

+ * might very well be flawed; you have been warned. 

+ * This software is provided as-is, without any kind of warrenty or 

+ * guarantee. And that is really all you can expect when you download  

+ * code for free from the Internet.  

+ * 

+ * I think it is really sad that disclaimers like this seem to be necessary. 

+ * If people only had a little bit more common sense, and didn't come 

+ * whining like little children every time something happens.... 

+ */ 

+  

+/* 

+ * Version history: 

+ * Version 0.0, 2002-08-30 

+ *      First written. 

+ * Version 0.1, 2002-09-03 

+ *      Added disclaimer. Improved self-tests. 

+ * Version 0.2, 2002-09-09 

+ *      Removed last non-portabilities. Default now works completely within 

+ *      the C standard. UInt32 can be larger than 32 bits without problems. 

+ * Version 0.3, 2002-09-28 

+ *      Bugfix: use  instead of  to adhere to ANSI/ISO. 

+ *      Rename BIG_ENDIAN macro to CPU_IS_BIG_ENDIAN. The gcc library  

+ *      header  already defines BIG_ENDIAN, even though it is not  

+ *      supposed to. 

+ */ 

+ 

+ 

+/*  

+ * Minimum set of include files. 

+ * You should not need any application-specific include files for this code.  

+ * In fact, adding you own header files could break one of the many macros or 

+ * functions in this file. Be very careful. 

+ * Standard include files will probably be ok. 

+ */ 

+#include <stdio.h>

+#include <string.h>

+#include <stdlib.h>

+/* #include      * for memset(), memcpy(), and memcmp() */ 

+#include "twofish.h" 

+ 

+ 

+/* 

+ * PLATFORM FIXES 

+ * ============== 

+ * 

+ * Fix the type definitions in twofish.h first! 

+ *  

+ * The following definitions have to be fixed for each particular platform  

+ * you work on. If you have a multi-platform program, you no doubt have  

+ * portable definitions that you can substitute here without changing the  

+ * rest of the code. 

+ */ 

+ 

+ 

+/*  

+ * Function called if something is fatally wrong with the implementation.  

+ * This fatal function is called when a coding error is detected in the 

+ * Twofish implementation, or when somebody passes an obviously erroneous 

+ * parameter to this implementation. There is not much you can do when 

+ * the code contains bugs, so we just stop. 

+ *  

+ * The argument is a string. Ideally the fatal function prints this string 

+ * as an error message. Whatever else this function does, it should never 

+ * return. A typical implementation would stop the program completely after 

+ * printing the error message. 

+ * 

+ * This default implementation is not very useful,  

+ * but does not assume anything about your environment.  

+ * It will at least let you know something is wrong.... 

+ * I didn't want to include any libraries to print and error or so, 

+ * as this makes the code much harder to integrate in a project. 

+ * 

+ * Note that the Twofish_fatal function may not return to the caller. 

+ * Unfortunately this is not something the self-test can test for, 

+ * so you have to make sure of this yourself. 

+ * 

+ * If you want to call an external function, be careful about including 

+ * your own header files here. This code uses a lot of macros, and your 

+ * header file could easily break it. Maybe the best solution is to use 

+ * a separate extern statement for your fatal function. 

+ */ 

+/* #define Twofish_fatal(pmsgx) { fprintf(stderr, pmsgx); exit(1); } */

+#define Twofish_fatal(pmsgx, code) { return(code); } 

+ 

+ 

+/* 

+ * The rest of the settings are not important for the functionality 

+ * of this Twofish implementation. That is, their default settings 

+ * work on all platforms. You can change them to improve the  

+ * speed of the implementation on your platform. Erroneous settings 

+ * will result in erroneous implementations, but the self-test should 

+ * catch those. 

+ */ 

+ 

+ 

+/*  

+ * Macros to rotate a Twofish_UInt32 value left or right by the  

+ * specified number of bits. This should be a 32-bit rotation,  

+ * and not rotation of, say, 64-bit values. 

+ * 

+ * Every encryption or decryption operation uses 32 of these rotations, 

+ * so it is a good idea to make these macros efficient. 

+ * 

+ * This fully portable definition has one piece of tricky stuff. 

+ * The UInt32 might be larger than 32 bits, so we have to mask 

+ * any higher bits off. The simplest way to do this is to 'and' the 

+ * value first with 0xffffffff and then shift it right. An optimising 

+ * compiler that has a 32-bit type can optimise this 'and' away. 

+ *  

+ * Unfortunately there is no portable way of writing the constant 

+ * 0xffffffff. You don't know which suffix to use (U, or UL?) 

+ * The UINT32_MASK definition uses a bit of trickery. Shift-left 

+ * is only defined if the shift amount is strictly less than the size 

+ * of the UInt32, so we can't use (1<<32). The answer it to take the value 

+ * 2, cast it to a UInt32, shift it left 31 positions, and subtract one. 

+ * Another example of how to make something very simple extremely difficult. 

+ * I hate C. 

+ *  

+ * The rotation macros are straightforward. 

+ * They are only applied to UInt32 values, which are _unsigned_ 

+ * so the >> operator must do a logical shift that brings in zeroes. 

+ * On most platforms you will only need to optimise the ROL32 macro; the 

+ * ROR32 macro is not inefficient on an optimising compiler as all rotation 

+ * amounts in this code are known at compile time. 

+ * 

+ * On many platforms there is a faster solution. 

+ * For example, MS compilers have the __rotl and __rotr functions 

+ * that generate x86 rotation instructions. 

+ */ 

+#define UINT32_MASK    ( (((Twofish_UInt32)2)<<31) - 1 ) 

+ 

+#ifndef _MSC_VER 

+#define ROL32(x,n) ( (x)<<(n) | ((x) & UINT32_MASK) >> (32-(n)) ) 

+#define ROR32(x,n) ( (x)>>(n) | ((x) & UINT32_MASK) << (32-(n)) ) 

+#else 

+#define ROL32(x,n) (_lrotl((x), (n))) 

+#define ROR32(x,n) (_lrotr((x), (n))) 

+#endif 

+ 

+/* 

+ * Select data type for q-table entries.  

+ * 

+ * Larger entry types cost more memory (1.5 kB), and might be faster  

+ * or slower depending on the CPU and compiler details. 

+ * 

+ * This choice only affects the static data size and the key setup speed. 

+ * Functionality, expanded key size, or encryption speed are not affected. 

+ * Define to 1 to get large q-table entries. 

+ */ 

+#define LARGE_Q_TABLE   0    /* default = 0 */ 

+ 

+ 

+/* 

+ * Method to select a single byte from a UInt32. 

+ * WARNING: non-portable code if set; might not work on all platforms. 

+ * 

+ * Inside the inner loop of Twofish it is necessary to access the 4  

+ * individual bytes of a UInt32. This can be done using either shifts 

+ * and masks, or memory accesses. 

+ * 

+ * Set to 0 to use shift and mask operations for the byte selection. 

+ * This is more ALU intensive. It is also fully portable.  

+ *  

+ * Set to 1 to use memory accesses. The UInt32 is stored in memory and 

+ * the individual bytes are read from memory one at a time. 

+ * This solution is more memory-intensive, and not fully portable. 

+ * It might be faster on your platform, or not. If you use this option, 

+ * make sure you set the CPU_IS_BIG_ENDIAN flag appropriately. 

+ *  

+ * This macro does not affect the conversion of the inputs and outputs 

+ * of the cipher. See the CONVERT_USING_CASTS macro for that. 

+ */ 

+#define SELECT_BYTE_FROM_UINT32_IN_MEMORY    0    /* default = 0 */ 

+ 

+ 

+/* 

+ * Method used to read the input and write the output. 

+ * WARNING: non-portable code if set; might not work on all platforms. 

+ * 

+ * Twofish operates on 32-bit words. The input to the cipher is 

+ * a byte array, as is the output. The portable method of doing the 

+ * conversion is a bunch of rotate and mask operations, but on many  

+ * platforms it can be done faster using a cast. 

+ * This only works if your CPU allows UInt32 accesses to arbitrary Byte 

+ * addresses. 

+ *  

+ * Set to 0 to use the shift and mask operations. This is fully 

+ * portable. . 

+ * 

+ * Set to 1 to use a cast. The Byte * is cast to a UInt32 *, and a 

+ * UInt32 is read. If necessary (as indicated by the CPU_IS_BIG_ENDIAN  

+ * macro) the byte order in the UInt32 is swapped. The reverse is done 

+ * to write the output of the encryption/decryption. Make sure you set 

+ * the CPU_IS_BIG_ENDIAN flag appropriately. 

+ * This option does not work unless a UInt32 is exactly 32 bits. 

+ * 

+ * This macro only changes the reading/writing of the plaintext/ciphertext. 

+ * See the SELECT_BYTE_FROM_UINT32_IN_MEMORY to affect the way in which 

+ * a UInt32 is split into 4 bytes for the S-box selection. 

+ */ 

+#define CONVERT_USING_CASTS    0    /* default = 0 */ 

+ 

+ 

+/*  

+ * Endianness switch. 

+ * Only relevant if SELECT_BYTE_FROM_UINT32_IN_MEMORY or 

+ * CONVERT_USING_CASTS is set. 

+ * 

+ * Set to 1 on a big-endian machine, and to 0 on a little-endian machine.  

+ * Twofish uses the little-endian convention (least significant byte first) 

+ * and big-endian machines (using most significant byte first)  

+ * have to do a few conversions.  

+ * 

+ * CAUTION: This code has never been tested on a big-endian machine,  

+ * because I don't have access to one. Feedback appreciated. 

+ */ 

+#define CPU_IS_BIG_ENDIAN    0 

+ 

+ 

+/*  

+ * Macro to reverse the order of the bytes in a UInt32. 

+ * Used to convert to little-endian on big-endian machines. 

+ * This macro is always tested, but only used in the encryption and 

+ * decryption if CONVERT_USING_CASTS, and CPU_IS_BIG_ENDIAN 

+ * are both set. In other words: this macro is only speed-critical if 

+ * both these flags have been set. 

+ * 

+ * This default definition of SWAP works, but on many platforms there is a  

+ * more efficient implementation.  

+ */ 

+#define BSWAP(x) ((ROL32((x),8)&0x00ff00ff) | (ROR32((x),8) & 0xff00ff00)) 

+ 

+ 

+/* 

+ * END OF PLATFORM FIXES 

+ * ===================== 

+ *  

+ * You should not have to touch the rest of this file. 

+ */ 

+ 

+ 

+/* 

+ * Convert the external type names to some that are easier to use inside 

+ * this file. I didn't want to use the names Byte and UInt32 in the 

+ * header file, because many programs already define them and using two 

+ * conventions at once can be very difficult. 

+ * Don't change these definitions! Change the originals  

+ * in twofish.h instead.  

+ */ 

+/* A Byte must be an unsigned integer, 8 bits long. */ 

+/* typedef Twofish_Byte    Byte; */

+/* A UInt32 must be an unsigned integer at least 32 bits long. */ 

+/* typedef Twofish_UInt32  UInt32; */

+ 

+ 

+/*  

+ * Define a macro ENDIAN_CONVERT. 

+ * 

+ * We define a macro ENDIAN_CONVERT that performs a BSWAP on big-endian 

+ * machines, and is the identity function on little-endian machines. 

+ * The code then uses this macro without considering the endianness. 

+ */ 

+ 

+#if CPU_IS_BIG_ENDIAN 

+#define ENDIAN_CONVERT(x)    BSWAP(x) 

+#else 

+#define ENDIAN_CONVERT(x)    (x) 

+#endif 

+ 

+ 

+/*  

+ * Compute byte offset within a UInt32 stored in memory. 

+ * 

+ * This is only used when SELECT_BYTE_FROM_UINT32_IN_MEMORY is set. 

+ *  

+ * The input is the byte number 0..3, 0 for least significant. 

+ * Note the use of sizeof() to support UInt32 types that are larger 

+ * than 4 bytes. 

+ */ 

+#if CPU_IS_BIG_ENDIAN 

+#define BYTE_OFFSET( n )  (sizeof(Twofish_UInt32) - 1 - (n) ) 

+#else 

+#define BYTE_OFFSET( n )  (n) 

+#endif 

+ 

+ 

+/* 

+ * Macro to get Byte no. b from UInt32 value X. 

+ * We use two different definition, depending on the settings. 

+ */ 

+#if SELECT_BYTE_FROM_UINT32_IN_MEMORY 

+    /* Pick the byte from the memory in which X is stored. */ 

+#define SELECT_BYTE( X, b ) (((Twofish_Byte *)(&(X)))[BYTE_OFFSET(b)]) 

+#else 

+    /* Portable solution: Pick the byte directly from the X value. */ 

+#define SELECT_BYTE( X, b ) (((X) >> (8*(b))) & 0xff) 

+#endif 

+ 

+ 

+/* Some shorthands because we use byte selection in large formulae. */ 

+#define b0(X)   SELECT_BYTE((X),0) 

+#define b1(X)   SELECT_BYTE((X),1) 

+#define b2(X)   SELECT_BYTE((X),2) 

+#define b3(X)   SELECT_BYTE((X),3) 

+ 

+ 

+/* 

+ * We need macros to load and store UInt32 from/to byte arrays 

+ * using the least-significant-byte-first convention. 

+ * 

+ * GET32( p ) gets a UInt32 in lsb-first form from four bytes pointed to 

+ * by p. 

+ * PUT32( v, p ) writes the UInt32 value v at address p in lsb-first form. 

+ */ 

+#if CONVERT_USING_CASTS 

+ 

+    /* Get UInt32 from four bytes pointed to by p. */ 

+#define GET32( p )    ENDIAN_CONVERT( *((Twofish_UInt32 *)(p)) ) 

+    /* Put UInt32 into four bytes pointed to by p */ 

+#define PUT32( v, p ) *((Twofish_UInt32 *)(p)) = ENDIAN_CONVERT(v) 

+ 

+#else 

+ 

+    /* Get UInt32 from four bytes pointed to by p. */ 

+#define GET32( p ) \

+    ( \

+      (Twofish_UInt32)((p)[0])     \

+    | (Twofish_UInt32)((p)[1])<< 8 \

+    | (Twofish_UInt32)((p)[2])<<16 \

+    | (Twofish_UInt32)((p)[3])<<24 \

+    ) 

+    /* Put UInt32 into four bytes pointed to by p */ 

+#define PUT32( v, p ) \

+    (p)[0] = (Twofish_Byte)(((v)      ) & 0xff); \

+    (p)[1] = (Twofish_Byte)(((v) >>  8) & 0xff); \

+    (p)[2] = (Twofish_Byte)(((v) >> 16) & 0xff); \

+    (p)[3] = (Twofish_Byte)(((v) >> 24) & 0xff)

+ 

+#endif 

+ 

+ 

+/* 

+ * Test the platform-specific macros. 

+ * This function tests the macros defined so far to make sure the  

+ * definitions are appropriate for this platform. 

+ * If you make any mistake in the platform configuration, this should detect 

+ * that and inform you what went wrong. 

+ * Somewhere, someday, this is going to save somebody a lot of time, 

+ * because misbehaving macros are hard to debug. 

+ */ 

+static int test_platform() 

+    { 

+    /* Buffer with test values. */ 

+    Twofish_Byte buf[] = {0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0}; 

+    Twofish_UInt32 C; 

+    Twofish_UInt32 x,y; 

+    int i; 

+ 

+    /*  

+     * Some sanity checks on the types that can't be done in compile time.  

+     * A smart compiler will just optimise these tests away. 

+     * The pre-processor doesn't understand different types, so we cannot 

+     * do these checks in compile-time. 

+     * 

+     * I hate C. 

+     * 

+     * The first check in each case is to make sure the size is correct. 

+     * The second check is to ensure that it is an unsigned type. 

+     */ 

+    if( ((Twofish_UInt32)((Twofish_UInt32)1 << 31) == 0) || ((Twofish_UInt32)-1 < 0 ))  

+        { 

+	  Twofish_fatal( "Twofish code: Twofish_UInt32 type not suitable", ERR_UINT32 ); 

+        } 

+    if( (sizeof( Twofish_Byte ) != 1) || (((Twofish_Byte)-1) < 0) )  

+        { 

+	  Twofish_fatal( "Twofish code: Twofish_Byte type not suitable", ERR_BYTE ); 

+        } 

+ 

+    /*  

+     * Sanity-check the endianness conversions.  

+     * This is just an aid to find problems. If you do the endianness 

+     * conversion macros wrong you will fail the full cipher test, 

+     * but that does not help you find the error. 

+     * Always make it easy to find the bugs!  

+     * 

+     * Detail: There is no fully portable way of writing UInt32 constants, 

+     * as you don't know whether to use the U or UL suffix. Using only U you 

+     * might only be allowed 16-bit constants. Using UL you might get 64-bit 

+     * constants which cannot be stored in a UInt32 without warnings, and 

+     * which generally behave subtly different from a true UInt32. 

+     * As long as we're just comparing with the constant,  

+     * we can always use the UL suffix and at worst lose some efficiency.  

+     * I use a separate '32-bit constant' macro in most of my other code. 

+     * 

+     * I hate C. 

+     * 

+     * Start with testing GET32. We test it on all positions modulo 4  

+     * to make sure we can handly any position of inputs. (Some CPUs 

+     * do not allow non-aligned accesses which we would do if you used 

+     * the CONVERT_USING_CASTS option. 

+     */ 

+    if( (GET32( buf ) != 0x78563412UL) || (GET32(buf+1) != 0x9a785634UL)  

+        || (GET32( buf+2 ) != 0xbc9a7856UL) || (GET32(buf+3) != 0xdebc9a78UL) ) 

+        { 

+	  Twofish_fatal( "Twofish code: GET32 not implemented properly", ERR_GET32 ); 

+        } 

+ 

+    /*  

+     * We can now use GET32 to test PUT32. 

+     * We don't test the shifted versions. If GET32 can do that then 

+     * so should PUT32. 

+     */ 

+    C = GET32( buf ); 

+    PUT32( 3*C, buf ); 

+    if( GET32( buf ) != 0x69029c36UL ) 

+        { 

+	  Twofish_fatal( "Twofish code: PUT32 not implemented properly", ERR_PUT32 ); 

+        } 

+ 

+ 

+    /* Test ROL and ROR */ 

+    for( i=1; i<32; i++ )  

+        { 

+        /* Just a simple test. */ 

+        x = ROR32( C, i ); 

+        y = ROL32( C, i ); 

+        x ^= (C>>i) ^ (C<<(32-i)); 

+        /*y ^= (C<>(32-i));  */

+        y ^= (C<<i) ^ (C>>(32-i));

+        x |= y; 

+        /*  

+         * Now all we check is that x is zero in the least significant 

+         * 32 bits. Using the UL suffix is safe here, as it doesn't matter 

+         * if we get a larger type. 

+         */ 

+	if( (x & 0xffffffffUL) != 0 ) 

+            { 

+	      Twofish_fatal( "Twofish ROL or ROR not properly defined.", ERR_ROLR ); 

+            } 

+        } 

+ 

+    /* Test the BSWAP macro */ 

+    if( BSWAP(C) != 0x12345678UL ) 

+        { 

+        /* 

+         * The BSWAP macro should always work, even if you are not using it. 

+         * A smart optimising compiler will just remove this entire test. 

+         */ 

+	  Twofish_fatal( "BSWAP not properly defined.", ERR_BSWAP ); 

+        } 

+ 

+    /* And we can test the b macros which use SELECT_BYTE. */ 

+    if( (b0(C)!=0x12) || (b1(C) != 0x34) || (b2(C) != 0x56) || (b3(C) != 0x78) ) 

+        { 

+        /* 

+         * There are many reasons why this could fail. 

+         * Most likely is that CPU_IS_BIG_ENDIAN has the wrong value.  

+         */ 

+	  Twofish_fatal( "Twofish code: SELECT_BYTE not implemented properly", ERR_SELECTB ); 

+        }

+    return SUCCESS;

+    } 

+ 

+ 

+/* 

+ * Finally, we can start on the Twofish-related code. 

+ * You really need the Twofish specifications to understand this code. The 

+ * best source is the Twofish book: 

+ *     "The Twofish Encryption Algorithm", by Bruce Schneier, John Kelsey, 

+ *     Doug Whiting, David Wagner, Chris Hall, and Niels Ferguson. 

+ * you can also use the AES submission document of Twofish, which is  

+ * available from my list of publications on my personal web site at  

+ *    http://niels.ferguson.net/. 

+ * 

+ * The first thing we do is write the testing routines. This is what the  

+ * implementation has to satisfy in the end. We only test the external 

+ * behaviour of the implementation of course. 

+ */ 

+ 

+ 

+/* 

+ * Perform a single self test on a (plaintext,ciphertext,key) triple. 

+ * Arguments: 

+ *  key     array of key bytes 

+ *  key_len length of key in bytes 

+ *  p       plaintext 

+ *  c       ciphertext 

+ */ 

+static int test_vector( Twofish_Byte key[], int key_len, Twofish_Byte p[16], Twofish_Byte c[16] ) 

+    { 

+    Twofish_Byte tmp[16];               /* scratch pad. */ 

+    Twofish_key xkey;           /* The expanded key */ 

+    int i; 

+ 

+ 

+    /* Prepare the key */ 

+    if ((i = Twofish_prepare_key( key, key_len, &xkey)) < 0)

+	return i; 

+ 

+    /*  

+     * We run the test twice to ensure that the xkey structure 

+     * is not damaged by the first encryption.  

+     * Those are hideous bugs to find if you get them in an application. 

+     */ 

+    for( i=0; i<2; i++ )  

+        { 

+        /* Encrypt and test */ 

+        Twofish_encrypt( &xkey, p, tmp ); 

+        if( memcmp( c, tmp, 16 ) != 0 )  

+            { 

+	      Twofish_fatal( "Twofish encryption failure", ERR_TEST_ENC ); 

+            } 

+ 

+        /* Decrypt and test */ 

+        Twofish_decrypt( &xkey, c, tmp ); 

+        if( memcmp( p, tmp, 16 ) != 0 )  

+            { 

+	      Twofish_fatal( "Twofish decryption failure", ERR_TEST_DEC ); 

+            } 

+        } 

+ 

+    /* The test keys are not secret, so we don't need to wipe xkey. */

+    return SUCCESS;

+    }

+ 

+ 

+/* 

+ * Check implementation using three (key,plaintext,ciphertext) 

+ * test vectors, one for each major key length. 

+ *  

+ * This is an absolutely minimal self-test.  

+ * This routine does not test odd-sized keys. 

+ */ 

+static int test_vectors() 

+    { 

+    /* 

+     * We run three tests, one for each major key length. 

+     * These test vectors come from the Twofish specification. 

+     * One encryption and one decryption using randomish data and key 

+     * will detect almost any error, especially since we generate the 

+     * tables ourselves, so we don't have the problem of a single 

+     * damaged table entry in the source. 

+     */ 

+ 

+    /* 128-bit test is the I=3 case of section B.2 of the Twofish book. */ 

+    static Twofish_Byte k128[] = { 

+        0x9F, 0x58, 0x9F, 0x5C, 0xF6, 0x12, 0x2C, 0x32,  

+        0xB6, 0xBF, 0xEC, 0x2F, 0x2A, 0xE8, 0xC3, 0x5A, 

+        }; 

+    static Twofish_Byte p128[] = { 

+        0xD4, 0x91, 0xDB, 0x16, 0xE7, 0xB1, 0xC3, 0x9E,  

+        0x86, 0xCB, 0x08, 0x6B, 0x78, 0x9F, 0x54, 0x19 

+        }; 

+    static Twofish_Byte c128[] = { 

+        0x01, 0x9F, 0x98, 0x09, 0xDE, 0x17, 0x11, 0x85,  

+        0x8F, 0xAA, 0xC3, 0xA3, 0xBA, 0x20, 0xFB, 0xC3 

+        }; 

+ 

+    /* 192-bit test is the I=4 case of section B.2 of the Twofish book. */ 

+    static Twofish_Byte k192[] = { 

+        0x88, 0xB2, 0xB2, 0x70, 0x6B, 0x10, 0x5E, 0x36,  

+        0xB4, 0x46, 0xBB, 0x6D, 0x73, 0x1A, 0x1E, 0x88,  

+        0xEF, 0xA7, 0x1F, 0x78, 0x89, 0x65, 0xBD, 0x44 

+        }; 

+    static Twofish_Byte p192[] = { 

+        0x39, 0xDA, 0x69, 0xD6, 0xBA, 0x49, 0x97, 0xD5, 

+        0x85, 0xB6, 0xDC, 0x07, 0x3C, 0xA3, 0x41, 0xB2 

+        }; 

+    static Twofish_Byte c192[] = { 

+        0x18, 0x2B, 0x02, 0xD8, 0x14, 0x97, 0xEA, 0x45, 

+        0xF9, 0xDA, 0xAC, 0xDC, 0x29, 0x19, 0x3A, 0x65 

+        }; 

+ 

+    /* 256-bit test is the I=4 case of section B.2 of the Twofish book. */ 

+    static Twofish_Byte k256[] = { 

+        0xD4, 0x3B, 0xB7, 0x55, 0x6E, 0xA3, 0x2E, 0x46,  

+        0xF2, 0xA2, 0x82, 0xB7, 0xD4, 0x5B, 0x4E, 0x0D, 

+        0x57, 0xFF, 0x73, 0x9D, 0x4D, 0xC9, 0x2C, 0x1B, 

+        0xD7, 0xFC, 0x01, 0x70, 0x0C, 0xC8, 0x21, 0x6F 

+        }; 

+    static Twofish_Byte p256[] = { 

+        0x90, 0xAF, 0xE9, 0x1B, 0xB2, 0x88, 0x54, 0x4F, 

+        0x2C, 0x32, 0xDC, 0x23, 0x9B, 0x26, 0x35, 0xE6 

+        }; 

+    static Twofish_Byte c256[] = { 

+        0x6C, 0xB4, 0x56, 0x1C, 0x40, 0xBF, 0x0A, 0x97, 

+        0x05, 0x93, 0x1C, 0xB6, 0xD4, 0x08, 0xE7, 0xFA 

+        }; 

+

+    int ret;

+

+    /* Run the actual tests. */ 

+    if ((ret = test_vector( k128, 16, p128, c128 )) < 0)

+      return ret; 

+    if ((ret = test_vector( k192, 24, p192, c192 )) < 0)

+      return ret; 

+    if ((ret = test_vector( k256, 32, p256, c256 )) < 0)

+      return ret;

+    return SUCCESS;

+    }    

+ 

+ 

+/* 

+ * Perform extensive test for a single key size. 

+ *  

+ * Test a single key size against the test vectors from section 

+ * B.2 in the Twofish book. This is a sequence of 49 encryptions 

+ * and decryptions. Each plaintext is equal to the ciphertext of 

+ * the previous encryption. The key is made up from the ciphertext 

+ * two and three encryptions ago. Both plaintext and key start 

+ * at the zero value.  

+ * We should have designed a cleaner recurrence relation for 

+ * these tests, but it is too late for that now. At least we learned 

+ * how to do it better next time. 

+ * For details see appendix B of the book. 

+ * 

+ * Arguments: 

+ * key_len      Number of bytes of key 

+ * final_value  Final plaintext value after 49 iterations 

+ */ 

+static int test_sequence( int key_len, Twofish_Byte final_value[] ) 

+    { 

+    Twofish_Byte buf[ (50+3)*16 ];      /* Buffer to hold our computation values. */ 

+    Twofish_Byte tmp[16];               /* Temp for testing the decryption. */ 

+    Twofish_key xkey;           /* The expanded key */ 

+    int i, ret;

+    Twofish_Byte * p; 

+ 

+    /* Wipe the buffer */ 

+    memset( buf, 0, sizeof( buf ) ); 

+ 

+    /* 

+     * Because the recurrence relation is done in an inconvenient manner 

+     * we end up looping backwards over the buffer. 

+     */ 

+ 

+    /* Pointer in buffer points to current plaintext. */ 

+    p = &buf[50*16]; 

+    for( i=1; i<50; i++ ) 

+        { 

+        /*  

+         * Prepare a key. 

+         * This automatically checks that key_len is valid. 

+         */ 

+	  if ((ret = Twofish_prepare_key( p+16, key_len, &xkey)) < 0)

+	    return ret; 

+ 

+        /* Compute the next 16 bytes in the buffer */ 

+        Twofish_encrypt( &xkey, p, p-16 ); 

+ 

+        /* Check that the decryption is correct. */ 

+        Twofish_decrypt( &xkey, p-16, tmp ); 

+        if( memcmp( tmp, p, 16 ) != 0 ) 

+            { 

+	      Twofish_fatal( "Twofish decryption failure in sequence", ERR_SEQ_DEC ); 

+            } 

+        /* Move on to next 16 bytes in the buffer. */ 

+        p -= 16; 

+        } 

+ 

+    /* And check the final value. */ 

+    if( memcmp( p, final_value, 16 ) != 0 )  

+        { 

+	  Twofish_fatal( "Twofish encryption failure in sequence", ERR_SEQ_ENC ); 

+        } 

+ 

+    /* None of the data was secret, so there is no need to wipe anything. */

+    return SUCCESS;

+    } 

+ 

+ 

+/*  

+ * Run all three sequence tests from the Twofish test vectors.  

+ * 

+ * This checks the most extensive test vectors currently available  

+ * for Twofish. The data is from the Twofish book, appendix B.2. 

+ */ 

+static int test_sequences() 

+    { 

+    static Twofish_Byte r128[] = { 

+        0x5D, 0x9D, 0x4E, 0xEF, 0xFA, 0x91, 0x51, 0x57, 

+        0x55, 0x24, 0xF1, 0x15, 0x81, 0x5A, 0x12, 0xE0 

+        }; 

+    static Twofish_Byte r192[] = { 

+        0xE7, 0x54, 0x49, 0x21, 0x2B, 0xEE, 0xF9, 0xF4, 

+        0xA3, 0x90, 0xBD, 0x86, 0x0A, 0x64, 0x09, 0x41 

+        }; 

+    static Twofish_Byte r256[] = { 

+        0x37, 0xFE, 0x26, 0xFF, 0x1C, 0xF6, 0x61, 0x75, 

+        0xF5, 0xDD, 0xF4, 0xC3, 0x3B, 0x97, 0xA2, 0x05 

+        }; 

+ 

+    /* Run the three sequence test vectors */

+    int ret;

+    if ((ret = test_sequence( 16, r128)) < 0)

+      return ret; 

+    if ((ret = test_sequence( 24, r192)) < 0)

+      return ret; 

+    if ((ret = test_sequence( 32, r256)) < 0)

+      return ret;

+    return SUCCESS;

+    } 

+ 

+ 

+/* 

+ * Test the odd-sized keys. 

+ * 

+ * Every odd-sized key is equivalent to a one of 128, 192, or 256 bits. 

+ * The equivalent key is found by padding at the end with zero bytes 

+ * until a regular key size is reached. 

+ * 

+ * We just test that the key expansion routine behaves properly. 

+ * If the expanded keys are identical, then the encryptions and decryptions 

+ * will behave the same. 

+ */ 

+static int test_odd_sized_keys() 

+    { 

+    Twofish_Byte buf[32]; 

+    Twofish_key xkey; 

+    Twofish_key xkey_two; 

+    int i, ret;

+ 

+    /*  

+     * We first create an all-zero key to use as PRNG key.  

+     * Normally we would not have to fill the buffer with zeroes, as we could 

+     * just pass a zero key length to the Twofish_prepare_key function. 

+     * However, this relies on using odd-sized keys, and those are just the 

+     * ones we are testing here. We can't use an untested function to test  

+     * itself.  

+     */ 

+    memset( buf, 0, sizeof( buf ) ); 

+    if ((ret = Twofish_prepare_key( buf, 16, &xkey)) < 0)

+      return ret; 

+ 

+    /* Fill buffer with pseudo-random data derived from two encryptions */ 

+    Twofish_encrypt( &xkey, buf, buf ); 

+    Twofish_encrypt( &xkey, buf, buf+16 ); 

+ 

+    /* Create all possible shorter keys that are prefixes of the buffer. */ 

+    for( i=31; i>=0; i-- ) 

+        { 

+        /* Set a byte to zero. This is the new padding byte */ 

+        buf[i] = 0; 

+ 

+        /* Expand the key with only i bytes of length */ 

+        if ((ret = Twofish_prepare_key( buf, i, &xkey)) < 0)

+	  return ret; 

+ 

+        /* Expand the corresponding padded key of regular length */ 

+        if ((ret = Twofish_prepare_key( buf, i<=16 ? 16 : (i<= 24 ? 24 : 32), &xkey_two )) < 0)

+	  return ret; 

+ 

+        /* Compare the two */ 

+        if( memcmp( &xkey, &xkey_two, sizeof( xkey ) ) != 0 ) 

+            { 

+	      Twofish_fatal( "Odd sized keys do not expand properly", ERR_ODD_KEY ); 

+            } 

+        } 

+ 

+    /* None of the key values are secret, so we don't need to wipe them. */

+    return SUCCESS;

+    } 

+ 

+ 

+/* 

+ * Test the Twofish implementation. 

+ * 

+ * This routine runs all the self tests, in order of importance. 

+ * It is called by the Twofish_initialise routine. 

+ *  

+ * In almost all applications the cost of running the self tests during 

+ * initialisation is insignificant, especially 

+ * compared to the time it takes to load the application from disk.  

+ * If you are very pressed for initialisation performance,  

+ * you could remove some of the tests. Make sure you did run them 

+ * once in the software and hardware configuration you are using. 

+ */ 

+static int self_test() 

+    {

+      int ret;

+    /* The three test vectors form an absolute minimal test set. */ 

+      if ((ret = test_vectors()) < 0)

+	return ret;

+ 

+    /*  

+     * If at all possible you should run these tests too. They take 

+     * more time, but provide a more thorough coverage. 

+     */ 

+      if ((ret = test_sequences()) < 0)

+	return ret;

+ 

+    /* Test the odd-sized keys. */ 

+      if ((ret = test_odd_sized_keys()) < 0)

+	return ret;

+      return SUCCESS;

+    } 

+ 

+ 

+/* 

+ * And now, the actual Twofish implementation. 

+ * 

+ * This implementation generates all the tables during initialisation.  

+ * I don't like large tables in the code, especially since they are easily  

+ * damaged in the source without anyone noticing it. You need code to  

+ * generate them anyway, and this way all the code is close together. 

+ * Generating them in the application leads to a smaller executable  

+ * (the code is smaller than the tables it generates) and a  

+ * larger static memory footprint. 

+ * 

+ * Twofish can be implemented in many ways. I have chosen to  

+ * use large tables with a relatively long key setup time. 

+ * If you encrypt more than a few blocks of data it pays to pre-compute  

+ * as much as possible. This implementation is relatively inefficient for  

+ * applications that need to re-key every block or so. 

+ */ 

+ 

+/*  

+ * We start with the t-tables, directly from the Twofish definition.  

+ * These are nibble-tables, but merging them and putting them two nibbles  

+ * in one byte is more work than it is worth. 

+ */ 

+static Twofish_Byte t_table[2][4][16] = { 

+    { 

+        {0x8,0x1,0x7,0xD,0x6,0xF,0x3,0x2,0x0,0xB,0x5,0x9,0xE,0xC,0xA,0x4}, 

+        {0xE,0xC,0xB,0x8,0x1,0x2,0x3,0x5,0xF,0x4,0xA,0x6,0x7,0x0,0x9,0xD}, 

+        {0xB,0xA,0x5,0xE,0x6,0xD,0x9,0x0,0xC,0x8,0xF,0x3,0x2,0x4,0x7,0x1}, 

+        {0xD,0x7,0xF,0x4,0x1,0x2,0x6,0xE,0x9,0xB,0x3,0x0,0x8,0x5,0xC,0xA} 

+    }, 

+    { 

+        {0x2,0x8,0xB,0xD,0xF,0x7,0x6,0xE,0x3,0x1,0x9,0x4,0x0,0xA,0xC,0x5}, 

+        {0x1,0xE,0x2,0xB,0x4,0xC,0x3,0x7,0x6,0xD,0xA,0x5,0xF,0x9,0x0,0x8}, 

+        {0x4,0xC,0x7,0x5,0x1,0x6,0x9,0xA,0x0,0xE,0xD,0x8,0x2,0xB,0x3,0xF}, 

+        {0xB,0x9,0x5,0x1,0xC,0x3,0xD,0xE,0x6,0x4,0x7,0xF,0x2,0x0,0x8,0xA} 

+    } 

+}; 

+ 

+ 

+/* A 1-bit rotation of 4-bit values. Input must be in range 0..15 */ 

+#define ROR4BY1( x ) (((x)>>1) | (((x)<<3) & 0x8) ) 

+ 

+/* 

+ * The q-boxes are only used during the key schedule computations.  

+ * These are 8->8 bit lookup tables. Some CPUs prefer to have 8->32 bit  

+ * lookup tables as it is faster to load a 32-bit value than to load an  

+ * 8-bit value and zero the rest of the register. 

+ * The LARGE_Q_TABLE switch allows you to choose 32-bit entries in  

+ * the q-tables. Here we just define the Qtype which is used to store  

+ * the entries of the q-tables. 

+ */ 

+#if LARGE_Q_TABLE 

+typedef Twofish_UInt32      Qtype; 

+#else 

+typedef Twofish_Byte        Qtype; 

+#endif 

+ 

+/*  

+ * The actual q-box tables.  

+ * There are two q-boxes, each having 256 entries. 

+ */ 

+static Qtype q_table[2][256]; 

+ 

+ 

+/* 

+ * Now the function that converts a single t-table into a q-table. 

+ * 

+ * Arguments: 

+ * t[4][16] : four 4->4bit lookup tables that define the q-box 

+ * q[256]   : output parameter: the resulting q-box as a lookup table. 

+ */ 

+static void make_q_table( Twofish_Byte t[4][16], Qtype q[256] ) 

+    { 

+    int ae,be,ao,bo;        /* Some temporaries. */ 

+    int i; 

+    /* Loop over all input values and compute the q-box result. */ 

+    for( i=0; i<256; i++ ) { 

+        /*  

+         * This is straight from the Twofish specifications.  

+         *  

+         * The ae variable is used for the a_i values from the specs 

+         * with even i, and ao for the odd i's. Similarly for the b's. 

+         */ 

+        ae = i>>4; be = i&0xf; 

+        ao = ae ^ be; bo = ae ^ ROR4BY1(be) ^ ((ae<<3)&8); 

+        ae = t[0][ao]; be = t[1][bo]; 

+        ao = ae ^ be; bo = ae ^ ROR4BY1(be) ^ ((ae<<3)&8); 

+        ae = t[2][ao]; be = t[3][bo]; 

+ 

+        /* Store the result in the q-box table, the cast avoids a warning. */ 

+        q[i] = (Qtype) ((be<<4) | ae); 

+        } 

+    } 

+ 

+ 

+/*  

+ * Initialise both q-box tables.  

+ */ 

+static void initialise_q_boxes() { 

+    /* Initialise each of the q-boxes using the t-tables */ 

+    make_q_table( t_table[0], q_table[0] ); 

+    make_q_table( t_table[1], q_table[1] ); 

+    } 

+ 

+ 

+/* 

+ * Next up is the MDS matrix multiplication. 

+ * The MDS matrix multiplication operates in the field 

+ * GF(2)[x]/p(x) with p(x)=x^8+x^6+x^5+x^3+1. 

+ * If you don't understand this, read a book on finite fields. You cannot 

+ * follow the finite-field computations without some background. 

+ *  

+ * In this field, multiplication by x is easy: shift left one bit  

+ * and if bit 8 is set then xor the result with 0x169.  

+ * 

+ * The MDS coefficients use a multiplication by 1/x, 

+ * or rather a division by x. This is easy too: first make the 

+ * value 'even' (i.e. bit 0 is zero) by xorring with 0x169 if necessary,  

+ * and then shift right one position.  

+ * Even easier: shift right and xor with 0xb4 if the lsbit was set. 

+ * 

+ * The MDS coefficients are 1, EF, and 5B, and we use the fact that 

+ *   EF = 1 + 1/x + 1/x^2 

+ *   5B = 1       + 1/x^2 

+ * in this field. This makes multiplication by EF and 5B relatively easy. 

+ * 

+ * This property is no accident, the MDS matrix was designed to allow 

+ * this implementation technique to be used. 

+ * 

+ * We have four MDS tables, each mapping 8 bits to 32 bits. 

+ * Each table performs one column of the matrix multiplication.  

+ * As the MDS is always preceded by q-boxes, each of these tables 

+ * also implements the q-box just previous to that column. 

+ */ 

+ 

+/* The actual MDS tables. */ 

+static Twofish_UInt32 MDS_table[4][256]; 

+ 

+/* A small table to get easy conditional access to the 0xb4 constant. */ 

+static Twofish_UInt32 mds_poly_divx_const[] = {0,0xb4}; 

+ 

+/* Function to initialise the MDS tables. */ 

+static void initialise_mds_tables() 

+    { 

+    int i; 

+    Twofish_UInt32 q,qef,q5b;       /* Temporary variables. */ 

+ 

+    /* Loop over all 8-bit input values */ 

+    for( i=0; i<256; i++ )  

+        { 

+        /*  

+         * To save some work during the key expansion we include the last 

+         * of the q-box layers from the h() function in these MDS tables. 

+         */ 

+ 

+        /* We first do the inputs that are mapped through the q0 table. */ 

+        q = q_table[0][i]; 

+        /* 

+         * Here we divide by x, note the table to get 0xb4 only if the  

+         * lsbit is set.  

+         * This sets qef = (1/x)*q in the finite field 

+         */ 

+        qef = (q >> 1) ^ mds_poly_divx_const[ q & 1 ]; 

+        /* 

+         * Divide by x again, and add q to get (1+1/x^2)*q.  

+         * Note that (1+1/x^2) =  5B in the field, and addition in the field 

+         * is exclusive or on the bits. 

+         */ 

+        q5b = (qef >> 1) ^ mds_poly_divx_const[ qef & 1 ] ^ q; 

+        /*  

+         * Add q5b to qef to set qef = (1+1/x+1/x^2)*q. 

+         * Again, (1+1/x+1/x^2) = EF in the field. 

+         */ 

+        qef ^= q5b; 

+ 

+        /*  

+         * Now that we have q5b = 5B * q and qef = EF * q  

+         * we can fill two of the entries in the MDS matrix table.  

+         * See the Twofish specifications for the order of the constants. 

+         */ 

+        MDS_table[1][i] = (q  <<24) | (q5b<<16) | (qef<<8) | qef; 

+        MDS_table[3][i] = (q5b<<24) | (qef<<16) | (q  <<8) | q5b; 

+ 

+        /* Now we do it all again for the two columns that have a q1 box. */ 

+        q = q_table[1][i]; 

+        qef = (q >> 1) ^ mds_poly_divx_const[ q & 1 ]; 

+        q5b = (qef >> 1) ^ mds_poly_divx_const[ qef & 1 ] ^ q; 

+        qef ^= q5b; 

+ 

+        /* The other two columns use the coefficient in a different order. */ 

+        MDS_table[0][i] = (qef<<24) | (qef<<16) | (q5b<<8) | q  ; 

+        MDS_table[2][i] = (qef<<24) | (q  <<16) | (qef<<8) | q5b; 

+        } 

+    } 

+ 

+ 

+/* 

+ * The h() function is the heart of the Twofish cipher.  

+ * It is a complicated sequence of q-box lookups, key material xors,  

+ * and finally the MDS matrix. 

+ * We use lots of macros to make this reasonably fast. 

+ */ 

+ 

+/* First a shorthand for the two q-tables */ 

+#define q0  q_table[0] 

+#define q1  q_table[1] 

+ 

+/* 

+ * Each macro computes one column of the h for either 2, 3, or 4 stages. 

+ * As there are 4 columns, we have 12 macros in all. 

+ *  

+ * The key bytes are stored in the Byte array L at offset  

+ * 0,1,2,3,  8,9,10,11,  [16,17,18,19,   [24,25,26,27]] as this is the 

+ * order we get the bytes from the user. If you look at the Twofish  

+ * specs, you'll see that h() is applied to the even key words or the 

+ * odd key words. The bytes of the even words appear in this spacing, 

+ * and those of the odd key words too. 

+ * 

+ * These macros are the only place where the q-boxes and the MDS table 

+ * are used. 

+ */ 

+#define H02( y, L )  MDS_table[0][q0[q0[y]^L[ 8]]^L[0]] 

+#define H12( y, L )  MDS_table[1][q0[q1[y]^L[ 9]]^L[1]] 

+#define H22( y, L )  MDS_table[2][q1[q0[y]^L[10]]^L[2]] 

+#define H32( y, L )  MDS_table[3][q1[q1[y]^L[11]]^L[3]] 

+#define H03( y, L )  H02( q1[y]^L[16], L ) 

+#define H13( y, L )  H12( q1[y]^L[17], L ) 

+#define H23( y, L )  H22( q0[y]^L[18], L ) 

+#define H33( y, L )  H32( q0[y]^L[19], L ) 

+#define H04( y, L )  H03( q1[y]^L[24], L ) 

+#define H14( y, L )  H13( q0[y]^L[25], L ) 

+#define H24( y, L )  H23( q0[y]^L[26], L ) 

+#define H34( y, L )  H33( q1[y]^L[27], L ) 

+ 

+/* 

+ * Now we can define the h() function given an array of key bytes.  

+ * This function is only used in the key schedule, and not to pre-compute 

+ * the keyed S-boxes. 

+ * 

+ * In the key schedule, the input is always of the form k*(1+2^8+2^16+2^24) 

+ * so we only provide k as an argument. 

+ * 

+ * Arguments: 

+ * k        input to the h() function. 

+ * L        pointer to array of key bytes at  

+ *          offsets 0,1,2,3, ... 8,9,10,11, [16,17,18,19, [24,25,26,27]] 

+ * kCycles  # key cycles, 2, 3, or 4. 

+ */ 

+static Twofish_UInt32 h( int k, Twofish_Byte L[], int kCycles ) 

+    { 

+    switch( kCycles ) { 

+        /* We code all 3 cases separately for speed reasons. */ 

+    case 2: 

+        return H02(k,L) ^ H12(k,L) ^ H22(k,L) ^ H32(k,L); 

+    case 3: 

+        return H03(k,L) ^ H13(k,L) ^ H23(k,L) ^ H33(k,L); 

+    case 4: 

+        return H04(k,L) ^ H14(k,L) ^ H24(k,L) ^ H34(k,L); 

+    default:  

+        /* This is always a coding error, which is fatal. */ 

+      Twofish_fatal( "Twofish h(): Illegal argument", ERR_ILL_ARG ); 

+      return ERR_ILL_ARG;

+        } 

+    } 

+ 

+ 

+/* 

+ * Pre-compute the keyed S-boxes. 

+ * Fill the pre-computed S-box array in the expanded key structure. 

+ * Each pre-computed S-box maps 8 bits to 32 bits. 

+ * 

+ * The S argument contains half the number of bytes of the full key, but is 

+ * derived from the full key. (See Twofish specifications for details.) 

+ * S has the weird byte input order used by the Hxx macros. 

+ * 

+ * This function takes most of the time of a key expansion. 

+ * 

+ * Arguments: 

+ * S        pointer to array of 8*kCycles Bytes containing the S vector. 

+ * kCycles  number of key words, must be in the set {2,3,4} 

+ * xkey     pointer to Twofish_key structure that will contain the S-boxes. 

+ */ 

+static int fill_keyed_sboxes( Twofish_Byte S[], int kCycles, Twofish_key * xkey ) 

+    { 

+    int i; 

+    switch( kCycles ) { 

+        /* We code all 3 cases separately for speed reasons. */ 

+    case 2: 

+        for( i=0; i<256; i++ ) 

+            { 

+            xkey->s[0][i]= H02( i, S ); 

+            xkey->s[1][i]= H12( i, S ); 

+            xkey->s[2][i]= H22( i, S ); 

+            xkey->s[3][i]= H32( i, S ); 

+            } 

+        break; 

+    case 3: 

+        for( i=0; i<256; i++ ) 

+            { 

+            xkey->s[0][i]= H03( i, S ); 

+            xkey->s[1][i]= H13( i, S ); 

+            xkey->s[2][i]= H23( i, S ); 

+            xkey->s[3][i]= H33( i, S ); 

+            } 

+        break; 

+    case 4: 

+        for( i=0; i<256; i++ ) 

+            { 

+            xkey->s[0][i]= H04( i, S ); 

+            xkey->s[1][i]= H14( i, S ); 

+            xkey->s[2][i]= H24( i, S ); 

+            xkey->s[3][i]= H34( i, S ); 

+            } 

+        break; 

+    default:  

+        /* This is always a coding error, which is fatal. */ 

+      Twofish_fatal( "Twofish fill_keyed_sboxes(): Illegal argument", ERR_ILL_ARG ); 

+        }

+    return SUCCESS;

+    }

+ 

+ 

+/* A flag to keep track of whether we have been initialised or not. */ 

+static int Twofish_initialised = 0; 

+ 

+/* 

+ * Initialise the Twofish implementation. 

+ * This function must be called before any other function in the 

+ * Twofish implementation is called. 

+ * This routine also does some sanity checks, to make sure that 

+ * all the macros behave, and it tests the whole cipher. 

+ */ 

+int Twofish_initialise() 

+    {

+      int ret;

+    /* First test the various platform-specific definitions. */ 

+      if ((ret = test_platform()) < 0)

+	return ret;

+ 

+    /* We can now generate our tables, in the right order of course. */ 

+    initialise_q_boxes(); 

+    initialise_mds_tables(); 

+ 

+    /* We're finished with the initialisation itself. */ 

+    Twofish_initialised = 1; 

+ 

+    /*  

+     * And run some tests on the whole cipher.  

+     * Yes, you need to do this every time you start your program.  

+     * It is called assurance; you have to be certain that your program 

+     * still works properly.  

+     */ 

+    return self_test(); 

+    } 

+ 

+ 

+/* 

+ * The Twofish key schedule uses an Reed-Solomon code matrix multiply. 

+ * Just like the MDS matrix, the RS-matrix is designed to be easy 

+ * to implement. Details are below in the code.  

+ * 

+ * These constants make it easy to compute in the finite field used  

+ * for the RS code. 

+ * 

+ * We use Bytes for the RS computation, but these are automatically 

+ * widened to unsigned integers in the expressions. Having unsigned 

+ * ints in these tables therefore provides the fastest access. 

+ */ 

+static unsigned int rs_poly_const[] = {0, 0x14d}; 

+static unsigned int rs_poly_div_const[] = {0, 0xa6 }; 

+ 

+ 

+/* 

+ * Prepare a key for use in encryption and decryption. 

+ * Like most block ciphers, Twofish allows the key schedule  

+ * to be pre-computed given only the key.  

+ * Twofish has a fairly 'heavy' key schedule that takes a lot of time  

+ * to compute. The main work is pre-computing the S-boxes used in the  

+ * encryption and decryption. We feel that this makes the cipher much  

+ * harder to attack. The attacker doesn't even know what the S-boxes  

+ * contain without including the entire key schedule in the analysis.  

+ * 

+ * Unlike most Twofish implementations, this one allows any key size from 

+ * 0 to 32 bytes. Odd key sizes are defined for Twofish (see the  

+ * specifications); the key is simply padded with zeroes to the next real  

+ * key size of 16, 24, or 32 bytes. 

+ * Each odd-sized key is thus equivalent to a single normal-sized key. 

+ * 

+ * Arguments: 

+ * key      array of key bytes 

+ * key_len  number of bytes in the key, must be in the range 0,...,32. 

+ * xkey     Pointer to an Twofish_key structure that will be filled  

+ *             with the internal form of the cipher key. 

+ */ 

+int Twofish_prepare_key( Twofish_Byte key[], int key_len, Twofish_key * xkey ) 

+    { 

+    /* We use a single array to store all key material in,  

+     * to simplify the wiping of the key material at the end. 

+     * The first 32 bytes contain the actual (padded) cipher key. 

+     * The next 32 bytes contain the S-vector in its weird format, 

+     * and we have 4 bytes of overrun necessary for the RS-reduction. 

+     */ 

+    Twofish_Byte K[32+32+4];  

+ 

+    int kCycles;        /* # key cycles, 2,3, or 4. */ 

+ 

+    int i; 

+    Twofish_UInt32 A, B;        /* Used to compute the round keys. */ 

+ 

+    Twofish_Byte * kptr;        /* Three pointers for the RS computation. */ 

+    Twofish_Byte * sptr; 

+    Twofish_Byte * t; 

+ 

+    Twofish_Byte b,bx,bxx;      /* Some more temporaries for the RS computation. */ 

+ 

+    /* Check that the Twofish implementation was initialised. */ 

+    if( Twofish_initialised == 0 ) 

+        { 

+        /*  

+         * You didn't call Twofish_initialise before calling this routine. 

+         * This is a programming error, and therefore we call the fatal 

+         * routine.  

+         * 

+         * I could of course call the initialisation routine here, 

+         * but there are a few reasons why I don't. First of all, the  

+         * self-tests have to be done at startup. It is no good to inform 

+         * the user that the cipher implementation fails when he wants to 

+         * write his data to disk in encrypted form. You have to warn him 

+         * before he spends time typing his data. Second, the initialisation 

+         * and self test are much slower than a single key expansion. 

+         * Calling the initialisation here makes the performance of the 

+         * cipher unpredictable. This can lead to really weird problems  

+         * if you use the cipher for a real-time task. Suddenly it fails  

+         * once in a while the first time you try to use it. Things like  

+         * that are almost impossible to debug. 

+         */ 

+	  /* Twofish_fatal( "Twofish implementation was not initialised.", ERR_INIT ); */

+         

+        /* 

+         * There is always a danger that the Twofish_fatal routine returns, 

+         * in spite of the specifications that it should not.  

+         * (A good programming rule: don't trust the rest of the code.) 

+         * This would be disasterous. If the q-tables and MDS-tables have 

+         * not been initialised, they are probably still filled with zeroes. 

+         * Suppose the MDS-tables are all zero. The key expansion would then 

+         * generate all-zero round keys, and all-zero s-boxes. The danger 

+         * is that nobody would notice as the encry

+         * mangles the input, and the decryption still 'decrypts' it, 

+         * but now in a completely key-independent manner.  

+         * To stop such security disasters, we use blunt force. 

+         * If your program hangs here: fix the fatal routine! 

+         */ 

+        for(;;);        /* Infinite loop, which beats being insecure. */ 

+        } 

+ 

+    /* Check for valid key length. */ 

+    if( key_len < 0 || key_len > 32 ) 

+        { 

+        /*  

+         * This can only happen if a programmer didn't read the limitations 

+         * on the key size.  

+         */ 

+	  Twofish_fatal( "Twofish_prepare_key: illegal key length", ERR_KEY_LEN ); 

+        /*  

+         * A return statement just in case the fatal macro returns. 

+         * The rest of the code assumes that key_len is in range, and would 

+         * buffer-overflow if it wasn't.  

+         * 

+         * Why do we still use a programming language that has problems like 

+         * buffer overflows, when these problems were solved in 1960 with 

+         * the development of Algol? Have we not leared anything? 

+         */ 

+        return ERR_KEY_LEN; 

+        } 

+ 

+    /* Pad the key with zeroes to the next suitable key length. */ 

+    memcpy( K, key, key_len ); 

+    memset( K+key_len, 0, sizeof(K)-key_len ); 

+ 

+    /*  

+     * Compute kCycles: the number of key cycles used in the cipher.  

+     * 2 for 128-bit keys, 3 for 192-bit keys, and 4 for 256-bit keys. 

+     */ 

+    kCycles = (key_len + 7) >> 3; 

+    /* Handle the special case of very short keys: minimum 2 cycles. */ 

+    if( kCycles < 2 ) 

+        { 

+        kCycles = 2; 

+        } 

+ 

+    /*  

+     * From now on we just pretend to have 8*kCycles bytes of  

+     * key material in K. This handles all the key size cases.  

+     */ 

+ 

+    /*  

+     * We first compute the 40 expanded key words,  

+     * formulas straight from the Twofish specifications. 

+     */ 

+    for( i=0; i<40; i+=2 ) 

+        { 

+        /*  

+         * Due to the byte spacing expected by the h() function  

+         * we can pick the bytes directly from the key K. 

+         * As we use bytes, we never have the little/big endian 

+         * problem. 

+         * 

+         * Note that we apply the rotation function only to simple 

+         * variables, as the rotation macro might evaluate its argument 

+         * more than once. 

+         */ 

+        A = h( i  , K  , kCycles ); 

+        B = h( i+1, K+4, kCycles ); 

+        B = ROL32( B, 8 ); 

+ 

+        /* Compute and store the round keys. */ 

+        A += B; 

+        B += A; 

+        xkey->K[i]   = A; 

+        xkey->K[i+1] = ROL32( B, 9 ); 

+        } 

+ 

+    /* Wipe variables that contained key material. */ 

+    A=B=0; 

+ 

+    /*  

+     * And now the dreaded RS multiplication that few seem to understand. 

+     * The RS matrix is not random, and is specially designed to compute the 

+     * RS matrix multiplication in a simple way. 

+     * 

+     * We work in the field GF(2)[x]/x^8+x^6+x^3+x^2+1. Note that this is a 

+     * different field than used for the MDS matrix.  

+     * (At least, it is a different representation because all GF(2^8)  

+     * representations are equivalent in some form.) 

+     *  

+     * We take 8 consecutive bytes of the key and interpret them as  

+     * a polynomial k_0 + k_1 y + k_2 y^2 + ... + k_7 y^7 where  

+     * the k_i bytes are the key bytes and are elements of the finite field. 

+     * We multiply this polynomial by y^4 and reduce it modulo 

+     *     y^4 + (x + 1/x)y^3 + (x)y^2 + (x + 1/x)y + 1.  

+     * using straightforward polynomial modulo reduction. 

+     * The coefficients of the result are the result of the RS 

+     * matrix multiplication. When we wrote the Twofish specification,  

+     * the original RS definition used the polynomials,  

+     * but that requires much more mathematical knowledge.  

+     * We were already using matrix multiplication in a finite field for  

+     * the MDS matrix, so I re-wrote the RS operation as a matrix  

+     * multiplication to reduce the difficulty of understanding it.  

+     * Some implementors have not picked up on this simpler method of 

+     * computing the RS operation, even though it is mentioned in the 

+     * specifications. 

+     * 

+     * It is possible to perform these computations faster by using 32-bit  

+     * word operations, but that is not portable and this is not a speed- 

+     * critical area. 

+     * 

+     * We explained the 1/x computation when we did the MDS matrix.  

+     * 

+     * The S vector is stored in K[32..64]. 

+     * The S vector has to be reversed, so we loop cross-wise. 

+     * 

+     * Note the weird byte spacing of the S-vector, to match the even  

+     * or odd key words arrays. See the discussion at the Hxx macros for 

+     * details. 

+     */ 

+    kptr = K + 8*kCycles;           /* Start at end of key */ 

+    sptr = K + 32;                  /* Start at start of S */ 

+ 

+    /* Loop over all key material */ 

+    while( kptr > K )  

+        { 

+        kptr -= 8; 

+        /*  

+         * Initialise the polynimial in sptr[0..12] 

+         * The first four coefficients are 0 as we have to multiply by y^4. 

+         * The next 8 coefficients are from the key material. 

+         */ 

+        memset( sptr, 0, 4 ); 

+        memcpy( sptr+4, kptr, 8 ); 

+ 

+        /*  

+         * The 12 bytes starting at sptr are now the coefficients of 

+         * the polynomial we need to reduce. 

+         */ 

+ 

+        /* Loop over the polynomial coefficients from high to low */ 

+        t = sptr+11; 

+        /* Keep looping until polynomial is degree 3; */ 

+        while( t > sptr+3 ) 

+            { 

+            /* Pick up the highest coefficient of the poly. */ 

+            b = *t; 

+ 

+            /*  

+             * Compute x and (x+1/x) times this coefficient.  

+             * See the MDS matrix implementation for a discussion of  

+             * multiplication by x and 1/x. We just use different  

+             * constants here as we are in a  

+             * different finite field representation. 

+             * 

+             * These two statements set  

+             * bx = (x) * b  

+             * bxx= (x + 1/x) * b 

+             */ 

+            bx = (Twofish_Byte)((b<<1) ^ rs_poly_const[ b>>7 ]); 

+            bxx= (Twofish_Byte)((b>>1) ^ rs_poly_div_const[ b&1 ] ^ bx); 

+ 

+            /* 

+             * Subtract suitable multiple of  

+             * y^4 + (x + 1/x)y^3 + (x)y^2 + (x + 1/x)y + 1  

+             * from the polynomial, except that we don't bother 

+             * updating t[0] as it will become zero anyway. 

+             */ 

+            t[-1] ^= bxx; 

+            t[-2] ^= bx; 

+            t[-3] ^= bxx; 

+            t[-4] ^= b; 

+             

+            /* Go to the next coefficient. */ 

+            t--; 

+            } 

+ 

+        /* Go to next S-vector word, obeying the weird spacing rules. */ 

+        sptr += 8; 

+        } 

+ 

+    /* Wipe variables that contained key material. */ 

+    b = bx = bxx = 0; 

+ 

+    /* And finally, we can compute the key-dependent S-boxes. */ 

+    fill_keyed_sboxes( &K[32], kCycles, xkey ); 

+ 

+    /* Wipe array that contained key material. */ 

+    memset( K, 0, sizeof( K ) );

+    return SUCCESS;

+    } 

+ 

+ 

+/* 

+ * We can now start on the actual encryption and decryption code. 

+ * As these are often speed-critical we will use a lot of macros. 

+ */ 

+ 

+/* 

+ * The g() function is the heart of the round function. 

+ * We have two versions of the g() function, one without an input 

+ * rotation and one with. 

+ * The pre-computed S-boxes make this pretty simple. 

+ */ 

+#define g0(X,xkey) \

+ (xkey->s[0][b0(X)]^xkey->s[1][b1(X)]^xkey->s[2][b2(X)]^xkey->s[3][b3(X)]) 

+ 

+#define g1(X,xkey) \

+ (xkey->s[0][b3(X)]^xkey->s[1][b0(X)]^xkey->s[2][b1(X)]^xkey->s[3][b2(X)]) 

+ 

+/* 

+ * A single round of Twofish. The A,B,C,D are the four state variables, 

+ * T0 and T1 are temporaries, xkey is the expanded key, and r the  

+ * round number. 

+ * 

+ * Note that this macro does not implement the swap at the end of the round. 

+ */ 

+#define ENCRYPT_RND( A,B,C,D, T0, T1, xkey, r ) \

+    T0 = g0(A,xkey); T1 = g1(B,xkey);\

+    C ^= T0+T1+xkey->K[8+2*(r)]; C = ROR32(C,1);\

+    D = ROL32(D,1); D ^= T0+2*T1+xkey->K[8+2*(r)+1] 

+ 

+/* 

+ * Encrypt a single cycle, consisting of two rounds. 

+ * This avoids the swapping of the two halves.  

+ * Parameter r is now the cycle number. 

+ */ 

+#define ENCRYPT_CYCLE( A, B, C, D, T0, T1, xkey, r ) \

+    ENCRYPT_RND( A,B,C,D,T0,T1,xkey,2*(r)   );\

+    ENCRYPT_RND( C,D,A,B,T0,T1,xkey,2*(r)+1 )

+ 

+/* Full 16-round encryption */ 

+#define ENCRYPT( A,B,C,D,T0,T1,xkey ) \

+    ENCRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 0 );\

+    ENCRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 1 );\

+    ENCRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 2 );\

+    ENCRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 3 );\

+    ENCRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 4 );\

+    ENCRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 5 );\

+    ENCRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 6 );\

+    ENCRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 7 )

+ 

+/* 

+ * A single round of Twofish for decryption. It differs from 

+ * ENCRYTP_RND only because of the 1-bit rotations. 

+ */ 

+#define DECRYPT_RND( A,B,C,D, T0, T1, xkey, r ) \

+    T0 = g0(A,xkey); T1 = g1(B,xkey);\

+    C = ROL32(C,1); C ^= T0+T1+xkey->K[8+2*(r)];\

+    D ^= T0+2*T1+xkey->K[8+2*(r)+1]; D = ROR32(D,1)

+ 

+/* 

+ * Decrypt a single cycle, consisting of two rounds.  

+ * This avoids the swapping of the two halves.  

+ * Parameter r is now the cycle number. 

+ */ 

+#define DECRYPT_CYCLE( A, B, C, D, T0, T1, xkey, r ) \

+    DECRYPT_RND( A,B,C,D,T0,T1,xkey,2*(r)+1 );\

+    DECRYPT_RND( C,D,A,B,T0,T1,xkey,2*(r)   )

+ 

+/* Full 16-round decryption. */ 

+#define DECRYPT( A,B,C,D,T0,T1, xkey ) \

+    DECRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 7 );\

+    DECRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 6 );\

+    DECRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 5 );\

+    DECRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 4 );\

+    DECRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 3 );\

+    DECRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 2 );\

+    DECRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 1 );\

+    DECRYPT_CYCLE( A,B,C,D,T0,T1,xkey, 0 ) 

+

+/* 

+ * A macro to read the state from the plaintext and do the initial key xors. 

+ * The koff argument allows us to use the same macro  

+ * for the decryption which uses different key words at the start. 

+ */ 

+#define GET_INPUT( src, A,B,C,D, xkey, koff ) \

+    A = GET32(src   )^xkey->K[  koff]; B = GET32(src+ 4)^xkey->K[1+koff]; \

+    C = GET32(src+ 8)^xkey->K[2+koff]; D = GET32(src+12)^xkey->K[3+koff]

+ 

+/* 

+ * Similar macro to put the ciphertext in the output buffer. 

+ * We xor the keys into the state variables before we use the PUT32  

+ * macro as the macro might use its argument multiple times. 

+ */ 

+#define PUT_OUTPUT( A,B,C,D, dst, xkey, koff ) \

+    A ^= xkey->K[  koff]; B ^= xkey->K[1+koff]; \

+    C ^= xkey->K[2+koff]; D ^= xkey->K[3+koff]; \

+    PUT32( A, dst   ); PUT32( B, dst+ 4 ); \

+    PUT32( C, dst+8 ); PUT32( D, dst+12 )

+ 

+ 

+/* 

+ * Twofish block encryption 

+ * 

+ * Arguments: 

+ * xkey         expanded key array 

+ * p            16 bytes of plaintext 

+ * c            16 bytes in which to store the ciphertext 

+ */ 

+void Twofish_encrypt( Twofish_key * xkey, Twofish_Byte p[16], Twofish_Byte c[16]) 

+    { 

+    Twofish_UInt32 A,B,C,D,T0,T1;       /* Working variables */ 

+ 

+    /* Get the four plaintext words xorred with the key */ 

+    GET_INPUT( p, A,B,C,D, xkey, 0 ); 

+ 

+    /* Do 8 cycles (= 16 rounds) */ 

+    ENCRYPT( A,B,C,D,T0,T1,xkey ); 

+ 

+    /* Store them with the final swap and the output whitening. */ 

+    PUT_OUTPUT( C,D,A,B, c, xkey, 4 ); 

+    } 

+ 

+ 

+/* 

+ * Twofish block decryption. 

+ * 

+ * Arguments: 

+ * xkey         expanded key array 

+ * p            16 bytes of plaintext 

+ * c            16 bytes in which to store the ciphertext 

+ */ 

+void Twofish_decrypt( Twofish_key * xkey, Twofish_Byte c[16], Twofish_Byte p[16]) 

+    { 

+    Twofish_UInt32 A,B,C,D,T0,T1;       /* Working variables */ 

+ 

+    /* Get the four plaintext words xorred with the key */ 

+    GET_INPUT( c, A,B,C,D, xkey, 4 ); 

+ 

+    /* Do 8 cycles (= 16 rounds) */ 

+    DECRYPT( A,B,C,D,T0,T1,xkey ); 

+ 

+    /* Store them with the final swap and the output whitening. */ 

+    PUT_OUTPUT( C,D,A,B, p, xkey, 0 ); 

+    } 

+ 

+/* 

+ * Using the macros it is easy to make special routines for 

+ * CBC mode, CTR mode etc. The only thing you might want to 

+ * add is a XOR_PUT_OUTPUT which xors the outputs into the 

+ * destinationa instead of overwriting the data. This requires 

+ * a XOR_PUT32 macro as well, but that should all be trivial. 

+ * 

+ * I thought about including routines for the separate cipher 

+ * modes here, but it is unclear which modes should be included, 

+ * and each encryption or decryption routine takes up a lot of code space. 

+ * Also, I don't have any test vectors for any cipher modes 

+ * with Twofish. 

+ */ 

+

+

diff --git a/jni/libccrtp/sources/src/ccrtp/crypto/twofish.h b/jni/libccrtp/sources/src/ccrtp/crypto/twofish.h
new file mode 100644
index 0000000..cf444fa
--- /dev/null
+++ b/jni/libccrtp/sources/src/ccrtp/crypto/twofish.h
@@ -0,0 +1,214 @@
+/* 

+ * Fast, portable, and easy-to-use Twofish implementation,  

+ * Version 0.3. 

+ * Copyright (c) 2002 by Niels Ferguson. 

+ * 

+ * See the twofish.c file for the details of the how and why of this code. 

+ * 

+ * The author hereby grants a perpetual license to everybody to 

+ * use this code for any purpose as long as the copyright message is included 

+ * in the source code of this or any derived work. 

+ */ 

+ 

+ 

+/* 

+ * PLATFORM FIXES 

+ * ============== 

+ * 

+ * The following definitions have to be fixed for each particular platform  

+ * you work on. If you have a multi-platform program, you no doubt have  

+ * portable definitions that you can substitute here without changing  

+ * the rest of the code. 

+ * 

+ * The defaults provided here should work on most PC compilers. 

+ */ 

+#ifndef _TWOFISH_H

+#define _TWOFISH_H

+

+#ifdef __cplusplus

+extern "C"

+{

+#endif

+

+ 

+/**

+ * A Twofish_Byte must be an unsigned 8-bit integer.

+ *

+ * It must also be the elementary data size of your C platform, 

+ * i.e. sizeof( Twofish_Byte ) == 1. 

+ */ 

+typedef unsigned char   Twofish_Byte; 

+ 

+/**

+ * A Twofish_UInt32 must be an unsigned integer of at least 32 bits.  

+ *  

+ * This type is used only internally in the implementation, so ideally it 

+ * would not appear in the header file, but it is used inside the 

+ * Twofish_key structure which means it has to be included here. 

+ */ 

+typedef unsigned int    Twofish_UInt32; 

+ 

+ 

+/* 

+ * END OF PLATFORM FIXES 

+ * ===================== 

+ *  

+ * You should not have to touch the rest of this file, but the code 

+ * in twofish.c has a few things you need to fix too. 

+ */ 

+

+/**

+ * Return  codes

+ */

+

+#define SUCCESS          1

+#define ERR_UINT32      -2

+#define ERR_BYTE        -3

+#define ERR_GET32       -4

+#define ERR_PUT32       -5

+#define ERR_ROLR        -6

+#define ERR_BSWAP       -7

+#define ERR_SELECTB     -8

+#define ERR_TEST_ENC    -9

+#define ERR_TEST_DEC   -10

+#define ERR_SEQ_ENC    -11

+#define ERR_SEQ_DEC    -12

+#define ERR_ODD_KEY    -13

+#define ERR_INIT       -14

+#define ERR_KEY_LEN    -15

+#define ERR_ILL_ARG    -16

+

+

+/**

+ * Structure that contains a prepared Twofish key.

+ *

+ * A cipher key is used in two stages. In the first stage it is converted 

+ * form the original form to an internal representation.  

+ * This internal form is then used to encrypt and decrypt data.  

+ * This structure contains the internal form. It is rather large: 4256 bytes 

+ * on a platform with 32-bit unsigned values. 

+ * 

+ * Treat this as an opague structure, and don't try to manipulate the 

+ * elements in it. I wish I could hide the inside of the structure, 

+ * but C doesn't allow that. 

+ */ 

+typedef  

+    struct  

+        { 

+        Twofish_UInt32 s[4][256];   /* pre-computed S-boxes */ 

+        Twofish_UInt32 K[40];       /* Round key words */ 

+        } 

+    Twofish_key; 

+ 

+ 

+/**

+ * Initialise and test the Twofish implementation.  

+ *  

+ * This function MUST be called before any other function in the  

+ * Twofish implementation is called. 

+ * It only needs to be called once. 

+ *  

+ * Apart from initialising the implementation it performs a self test. 

+ * If the Twofish_fatal function is not called, the code passed the test. 

+ * (See the twofish.c file for details on the Twofish_fatal function.)

+ *

+ * @returns a negative number if an error happend, +1 otherwise

+ */ 

+extern int Twofish_initialise(); 

+ 

+ 

+/**

+ * Convert a cipher key to the internal form used for  

+ * encryption and decryption. 

+ *  

+ * The cipher key is an array of bytes; the Twofish_Byte type is  

+ * defined above to a type suitable on your platform.  

+ * 

+ * Any key must be converted to an internal form in the Twofisk_key structure 

+ * before it can be used. 

+ * The encryption and decryption functions only work with the internal form. 

+ * The conversion to internal form need only be done once for each key value. 

+ * 

+ * Be sure to wipe all key storage, including the Twofish_key structure,  

+ * once you are done with the key data.  

+ * A simple memset( TwofishKey, 0, sizeof( TwofishKey ) ) will do just fine. 

+ * 

+ * Unlike most implementations, this one allows any key size from 0 bytes  

+ * to 32 bytes. According to the Twofish specifications,  

+ * irregular key sizes are handled by padding the key with zeroes at the end  

+ * until the key size is 16, 24, or 32 bytes, whichever 

+ * comes first. Note that each key of irregular size is equivalent to exactly 

+ * one key of 16, 24, or 32 bytes. 

+ * 

+ * WARNING: Short keys have low entropy, and result in low security. 

+ * Anything less than 8 bytes is utterly insecure. For good security 

+ * use at least 16 bytes. I prefer to use 32-byte keys to prevent 

+ * any collision attacks on the key. 

+ * 

+ * The key length argument key_len must be in the proper range. 

+ * If key_len is not in the range 0,...,32 this routine attempts to generate  

+ * a fatal error (depending on the code environment),  

+ * and at best (or worst) returns without having done anything. 

+ * 

+ * @param key      Array of key bytes 

+ * @param key_len  Number of key bytes, must be in the range 0,1,...,32.  

+ * @para xkey     Pointer to an Twofish_key structure that will be filled  

+ *             with the internal form of the cipher key.

+ * @returns a negative number if an error happend, +1 otherwise

+ */ 

+extern int Twofish_prepare_key(  

+                                Twofish_Byte key[], 

+                                int key_len,  

+                                Twofish_key * xkey   

+                                ); 

+ 

+ 

+/**

+ * Encrypt a single block of data. 

+ * 

+ * This function encrypts a single block of 16 bytes of data. 

+ * If you want to encrypt a larger or variable-length message,  

+ * you will have to use a cipher mode, such as CBC or CTR.  

+ * These are outside the scope of this implementation. 

+ * 

+ * The xkey structure is not modified by this routine, and can be 

+ * used for further encryption and decryption operations. 

+ * 

+ * @param xkey     pointer to Twofish_key, internal form of the key 

+ *                 produces by Twofish_prepare_key() 

+ * @param p        Plaintext to be encrypted 

+ * @param c        Place to store the ciphertext 

+ */ 

+extern void Twofish_encrypt(  

+                            Twofish_key * xkey, 

+                            Twofish_Byte p[16],  

+                            Twofish_Byte c[16] 

+                            ); 

+ 

+ 

+/**

+ * Decrypt a single block of data. 

+ * 

+ * This function decrypts a single block of 16 bytes of data. 

+ * If you want to decrypt a larger or variable-length message,  

+ * you will have to use a cipher mode, such as CBC or CTR.  

+ * These are outside the scope of this implementation. 

+ * 

+ * The xkey structure is not modified by this routine, and can be 

+ * used for further encryption and decryption operations. 

+ * 

+ * @param xkey     pointer to Twofish_key, internal form of the key 

+ *                 produces by Twofish_prepare_key() 

+ * @param c        Ciphertext to be decrypted 

+ * @param p        Place to store the plaintext 

+ */ 

+extern void Twofish_decrypt(  

+                            Twofish_key * xkey, 

+                            Twofish_Byte c[16],  

+                            Twofish_Byte p[16] 

+                            ); 

+

+#ifdef __cplusplus

+}

+#endif

+#endif

diff --git a/jni/libccrtp/sources/src/ccrtp/ext.h b/jni/libccrtp/sources/src/ccrtp/ext.h
index e398609..615562d 100644
--- a/jni/libccrtp/sources/src/ccrtp/ext.h
+++ b/jni/libccrtp/sources/src/ccrtp/ext.h
@@ -1,27 +1,27 @@
 // Copyright (C) 1999-2003 Open Source Telecom Corporation.
-//  
+//
 // 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 
+// along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// 
+//
 // As a special exception, you may use this file as part of a free software
 // library without restriction.  Specifically, if other files instantiate
 // templates or use macros or inline functions from this file, or you compile
 // this file and link it with other files to produce an executable, this
 // file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however    
+// the GNU General Public License.  This exception does not however
 // invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.    
+// the GNU General Public License.
 //
 // This exception applies only to the code released under the name GNU
 // ccRTP.  If you copy code from other releases into a copy of GNU
@@ -35,24 +35,23 @@
 // If you do not wish that, delete this exception notice.
 //
 
-/** 
- * @file ext.h 
+/**
+ * @file ext.h
  * @short ccRTP Stack extensions.
  **/
 
 #ifndef CCXX_RTP_EXT_H
 #define CCXX_RTP_EXT_H
 
-#ifndef	CCXX_SOCKET_H_
-#include <cc++/socket.h>
+#ifndef COMMONCPP_SOCKET_H_
+#include <commoncpp/socket.h>
+#include <commoncpp/udp.h>
 #endif
 
 #include <ccrtp/ioqueue.h>
 #include <ccrtp/channel.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @defgroup rtpext ccRTP Extension classes
@@ -69,101 +68,99 @@
  * @author David Sugar
  * @short RTP peer host over UDP.
  */
-class __EXPORT RTPDuplex : public RTPDataQueue, 
-				    protected UDPReceive, public UDPTransmit
+class __EXPORT RTPDuplex : public RTPDataQueue,
+                    protected UDPReceive, public UDPTransmit
 {
 public:
-	/**
-	 * @param bind network address this socket is to be bound
-	 * @param local transport port this socket is to be bound
-	 * @param remote peer transpor port
-	 */
-	RTPDuplex(const InetAddress &bind, tpport_t local, tpport_t remote);
+    /**
+     * @param bind network address this socket is to be bound
+     * @param local transport port this socket is to be bound
+     * @param remote peer transpor port
+     */
+    RTPDuplex(const InetAddress &bind, tpport_t local, tpport_t remote);
 
-	/**
-	 *
-	 */
-	virtual
-	~RTPDuplex();
+    /**
+     *
+     */
+    virtual
+    ~RTPDuplex();
 
-	/**
-	 * @param host peer address
-	 * @param port peer port. If not specified, the same as the
-	 *        local is used
-	 * @return socket status
-	 */
-	UDPTransmit::Error 
-	connect(const InetHostAddress &host, tpport_t port = 0);
+    /**
+     * @param host peer address
+     * @param port peer port. If not specified, the same as the
+     *        local is used
+     * @return socket status
+     */
+    UDPTransmit::Error
+    connect(const InetHostAddress &host, tpport_t port = 0);
 
 protected:
 
-	/**
-	 * @param timeout how much time to wait for new data
-	 * @return if there is some new data
-	 */
-	bool 
-	isPendingData(microtimeout_t timeout)
-	{ return isPendingReceive(timeout); }
+    /**
+     * @param timeout how much time to wait for new data
+     * @return if there is some new data
+     */
+    bool
+    isPendingData(microtimeout_t timeout)
+    { return isPendingReceive(timeout); }
 
-	/**
-	 * @param buffer pointer to data to be written
-	 * @param len how many octets to write
-	 * @return number of octets written
-	 */
-	size_t 
-	sendData(const unsigned char *const buffer, size_t len)
-	{ return UDPTransmit::transmit((const char *)buffer, len); }
+    /**
+     * @param buffer pointer to data to be written
+     * @param len how many octets to write
+     * @return number of octets written
+     */
+    size_t
+    sendData(const unsigned char *const buffer, size_t len)
+    { return UDPTransmit::transmit((const char *)buffer, len); }
 
-	/**
-	 * @param buffer where to store the retrieved data
-	 * @param len how many octets to read
-	 * @param na Source network address.
-	 * @param tp Source transport port.
-	 * @return number of octets read
-	 */
-	size_t
-	recvData(unsigned char *buffer, size_t len, 
-		 InetHostAddress& na, tpport_t& tp)
-	{ /* na = UDPReceive::getPeer(&tp);  FIX name ambiguity */
-	return UDPReceive::receive(buffer, len); }
-	
-	/**
-	 * @param - peer host network address.
-	 * @param - peer host RTP data transport port.
-	 **/
+    /**
+     * @param buffer where to store the retrieved data
+     * @param len how many octets to read
+     * @param na Source network address.
+     * @param tp Source transport port.
+     * @return number of octets read
+     */
+    size_t
+    recvData(unsigned char *buffer, size_t len,
+         InetHostAddress& na, tpport_t& tp)
+    { /* na = UDPReceive::getPeer(&tp);  FIX name ambiguity */
+    return UDPReceive::receive(buffer, len); }
+
+    /**
+     * @param - peer host network address.
+     * @param - peer host RTP data transport port.
+     **/
         inline void
         setDataPeer(const InetAddress&, tpport_t)
-	{ }
+    { }
 
-	/**
-	 * @param - peer host network address.
-	 * @param - peer host RTCP transport port.
-	 **/
+    /**
+     * @param - peer host network address.
+     * @param - peer host RTCP transport port.
+     **/
         inline void
         setControlPeer(const InetAddress&, tpport_t)
-	{ }
+    { }
 
-	inline size_t
-	getNextDataPacketSize() const
-	{
-		// the const cast is a trick only needed for cc++2 <= 1.0.10
-		size_t len; ccioctl(const_cast<RTPDuplex*>(this)->UDPReceive::getReceiver(),FIONREAD,len); return len; 
-	}
+    inline size_t
+    getNextDataPacketSize() const
+    {
+        // the const cast is a trick only needed for cc++2 <= 1.0.10
+        size_t len; ccioctl(const_cast<RTPDuplex*>(this)->UDPReceive::getReceiver(),FIONREAD,len); return len;
+    }
 
-	/**
-	 * @return the associated peer information
-	 */
-	SyncSource &getPeer();
+    /**
+     * @return the associated peer information
+     */
+    SyncSource &getPeer();
 
 private:
-	tpport_t dataBasePort;
+    tpport_t dataBasePort;
 };
 
 /*@}*/ // rtpext
 
-#ifdef	CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif //CCXX_RTP_EXT_H
 
diff --git a/jni/libccrtp/sources/src/ccrtp/formats.h b/jni/libccrtp/sources/src/ccrtp/formats.h
index d5896f1..7efc7ac 100644
--- a/jni/libccrtp/sources/src/ccrtp/formats.h
+++ b/jni/libccrtp/sources/src/ccrtp/formats.h
@@ -1,27 +1,27 @@
 // Copyright (C) 2002 Federico Montesino Pouzols <fedemp@altern.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 
+// along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// 
+//
 // As a special exception, you may use this file as part of a free software
 // library without restriction.  Specifically, if other files instantiate
 // templates or use macros or inline functions from this file, or you compile
 // this file and link it with other files to produce an executable, this
 // file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however    
+// the GNU General Public License.  This exception does not however
 // invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.    
+// the GNU General Public License.
 //
 // This exception applies only to the code released under the name GNU
 // ccRTP.  If you copy code from other releases into a copy of GNU
@@ -35,15 +35,13 @@
 // If you do not wish that, delete this exception notice.
 //
 
-#ifndef	CCXX_RTP_FORMATS_H_
+#ifndef CCXX_RTP_FORMATS_H_
 #define CCXX_RTP_FORMATS_H_
 
-#ifdef CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
-/** 
- * @file formats.h 
+/**
+ * @file formats.h
  *
  * @short Payload types and formats.
  **/
@@ -74,47 +72,47 @@
  * AVP profile.
  **/
 typedef enum {
-	// Types for audio formats:
-	sptPCMU = 0,        ///< ITU-T G.711. mu-law audio 8 Khz (RFC 1890)
-	firstStaticPayloadType = sptPCMU,
-	// 1016 static payload type is now deprecated. Type 1 is reserved.
-	// spt1016,         ///< CELP audio (FED-STD 1016) (RFC 1890)
-	sptG726_32 = 2,     ///< ITU-T G.726. ADPCM audio (RFC 1890)
-	sptGSM,             ///< GSM audio (RFC 1890)
-	sptG723,            ///< ITU-T G.723. MP-MLQ ACELP audio (RFC 1890)
-	sptDVI4_8000,       ///< Modified IMA ADPCM audio 8Khz (RFC 1890)
-	sptDVI4_16000,      ///< Modified IMA ADPCM audio 16Khz (RFC 1890)
-	sptLPC,             ///< LPC audio (RFC 1890)
-	sptPCMA,            ///< ITU-T G.711 A-law audio 8 Khz (RFC 1890) 
-	sptG722,            ///< Audio (RFCs 1890, 3047)
-	sptL16_DUAL,        ///< Linear uncompressed dual audio (RFC 1890)
-	sptL16_MONO,        ///< Linear uncompressed mono audio (RFC 1890)
-	sptQCELP,           ///< Audio at 8000 hz.
-	// Type 13 is reserved.
-	sptMPA = 14,	    ///< MPEG Audio elem. stream (RFCs 1890, 2250)
-	sptG728,            ///< ITU-T G.728. LD-CELP audio
-	sptDVI4_11025,      ///< DVI audio at 11025 hz (by Joseph Di Pol)
-	sptDVI4_22050,      ///< DVI audio at 22050 hz (by Joseph Di Pol)
-	sptG729,            ///< ITU-T G.729. CS-ACELP audio
-	// Type 19 is reserved. Types 20 - 23 are unassigned.
-	lastStaticAudioPayloadType = sptG729,
+    // Types for audio formats:
+    sptPCMU = 0,        ///< ITU-T G.711. mu-law audio 8 Khz (RFC 1890)
+    firstStaticPayloadType = sptPCMU,
+    // 1016 static payload type is now deprecated. Type 1 is reserved.
+    // spt1016,         ///< CELP audio (FED-STD 1016) (RFC 1890)
+    sptG726_32 = 2,     ///< ITU-T G.726. ADPCM audio (RFC 1890)
+    sptGSM,             ///< GSM audio (RFC 1890)
+    sptG723,            ///< ITU-T G.723. MP-MLQ ACELP audio (RFC 1890)
+    sptDVI4_8000,       ///< Modified IMA ADPCM audio 8Khz (RFC 1890)
+    sptDVI4_16000,      ///< Modified IMA ADPCM audio 16Khz (RFC 1890)
+    sptLPC,             ///< LPC audio (RFC 1890)
+    sptPCMA,            ///< ITU-T G.711 A-law audio 8 Khz (RFC 1890)
+    sptG722,            ///< Audio (RFCs 1890, 3047)
+    sptL16_DUAL,        ///< Linear uncompressed dual audio (RFC 1890)
+    sptL16_MONO,        ///< Linear uncompressed mono audio (RFC 1890)
+    sptQCELP,           ///< Audio at 8000 hz.
+    // Type 13 is reserved.
+    sptMPA = 14,        ///< MPEG Audio elem. stream (RFCs 1890, 2250)
+    sptG728,            ///< ITU-T G.728. LD-CELP audio
+    sptDVI4_11025,      ///< DVI audio at 11025 hz (by Joseph Di Pol)
+    sptDVI4_22050,      ///< DVI audio at 22050 hz (by Joseph Di Pol)
+    sptG729,            ///< ITU-T G.729. CS-ACELP audio
+    // Type 19 is reserved. Types 20 - 23 are unassigned.
+    lastStaticAudioPayloadType = sptG729,
 
-	// Types for video formats:
-	// Type 24 is unassigned.
-	sptCELB = 25,       ///< Sun's propietary video (RFCs 1890, 2029)
-	sptJPEG,            ///< JPEG (ISO 10918) video (RFCs 1890, 2435)
-	// Type 27 is unassigned.
-	sptNV = 28,         ///< Ron Frederick's nv audio (RFC 1890)
-	// Types 29 and 30 are unassigned.
-	sptH261 = 31,       ///< ITU-T H.261 video (RFCs 1890, 2032) 
-	sptMPV,             ///< MPEG Video elem. stream (RFCs 1890, 2250)
-	sptMP2T,            ///< MPEG 2 Transport stream (RFCs 1890, 2250)
-	sptH263,            ///< ITU-T H.263 video (RFCs 2190, 2429)
-	// Types 35 - 71 are unassigned.
-	// Types 72 - 76 are reserved.
-	// Types 96 - 127 are dynamic.
-	lastStaticPayloadType = sptH263
-}	StaticPayloadType;
+    // Types for video formats:
+    // Type 24 is unassigned.
+    sptCELB = 25,       ///< Sun's propietary video (RFCs 1890, 2029)
+    sptJPEG,            ///< JPEG (ISO 10918) video (RFCs 1890, 2435)
+    // Type 27 is unassigned.
+    sptNV = 28,         ///< Ron Frederick's nv audio (RFC 1890)
+    // Types 29 and 30 are unassigned.
+    sptH261 = 31,       ///< ITU-T H.261 video (RFCs 1890, 2032)
+    sptMPV,             ///< MPEG Video elem. stream (RFCs 1890, 2250)
+    sptMP2T,            ///< MPEG 2 Transport stream (RFCs 1890, 2250)
+    sptH263,            ///< ITU-T H.263 video (RFCs 2190, 2429)
+    // Types 35 - 71 are unassigned.
+    // Types 72 - 76 are reserved.
+    // Types 96 - 127 are dynamic.
+    lastStaticPayloadType = sptH263
+}   StaticPayloadType;
 
 /**
  * @class PayloadFormat
@@ -127,65 +125,65 @@
  * This is a base class for both StaticPayloadFormat and
  * DynamicPayloadFormat.
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT PayloadFormat
 {
 public:
-	/**
-	 * Get payload type numeric identifier carried in RTP packets.
-	 *
-	 * @return payload type numeric identifier.
-	 **/
-	inline PayloadType getPayloadType() const
-	{ return payloadType; }
+    /**
+     * Get payload type numeric identifier carried in RTP packets.
+     *
+     * @return payload type numeric identifier.
+     **/
+    inline PayloadType getPayloadType() const
+    { return payloadType; }
 
-	/**
-	 * Get RTP clock rate for this payload format. Note this
-	 * method provides the RTP clock rate (for the timestamp in
-	 * RTP data packets headers), which is not necessarily the
-	 * same as the codec clock rate.
-	 *
-	 * @return RTP clock rate in Hz.
-	 **/
-	inline uint32 getRTPClockRate() const
-	{ return RTPClockRate; }
-	
+    /**
+     * Get RTP clock rate for this payload format. Note this
+     * method provides the RTP clock rate (for the timestamp in
+     * RTP data packets headers), which is not necessarily the
+     * same as the codec clock rate.
+     *
+     * @return RTP clock rate in Hz.
+     **/
+    inline uint32 getRTPClockRate() const
+    { return RTPClockRate; }
+
 protected:
-	/**
-	 * PayloadFormat must not be used but as base class.
-	 **/
-	PayloadFormat()
-	{ }
-	
-	/**
-	 * PayloadFormat must not be used but as base class.
-	 **/
-	inline virtual ~PayloadFormat()	
-	{ }
+    /**
+     * PayloadFormat must not be used but as base class.
+     **/
+    PayloadFormat()
+    { }
 
-	/**
-	 * Set payload type numeric identifier carried in RTP packets.
-	 *
-	 * @param pt payload type number.
-	 **/
-	inline void setPayloadType(PayloadType pt)
-	{ payloadType = pt; }
+    /**
+     * PayloadFormat must not be used but as base class.
+     **/
+    inline virtual ~PayloadFormat()
+    { }
 
-	/**
-	 * Set RTP clock rate.
-	 *
-	 * @param rate RTP clock rate in Hz.
-	 **/
-	inline void setRTPClockRate(uint32 rate)
-	{ RTPClockRate = rate; }
+    /**
+     * Set payload type numeric identifier carried in RTP packets.
+     *
+     * @param pt payload type number.
+     **/
+    inline void setPayloadType(PayloadType pt)
+    { payloadType = pt; }
 
-	// default clock rate
-	static const uint32 defaultRTPClockRate;
+    /**
+     * Set RTP clock rate.
+     *
+     * @param rate RTP clock rate in Hz.
+     **/
+    inline void setRTPClockRate(uint32 rate)
+    { RTPClockRate = rate; }
+
+    // default clock rate
+    static const uint32 defaultRTPClockRate;
 
 private:
-	PayloadType payloadType;    ///< Numeric identifier.
-	uint32 RTPClockRate;        ///< Rate in Hz.
+    PayloadType payloadType;    ///< Numeric identifier.
+    uint32 RTPClockRate;        ///< Rate in Hz.
 };
 
 /**
@@ -198,29 +196,29 @@
  * StaticPayloadFormat(sptPCMU) will set the proper clock rate and any
  * other parameters for that static payload type.
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
- **/	
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
+ **/
 class __EXPORT StaticPayloadFormat : public PayloadFormat
 {
 public:
-	/**
-	 * Constructor. Builds a payload format from a static payload
-	 * binding identifier, assigning the numeric identifier and
-	 * RTP clock rate statically bounded.
-	 *
-	 * @param type Numeric identifier in the range 0-96.
-	 * @note some identifiers are reserved.
-	 **/
-	StaticPayloadFormat(StaticPayloadType type);
-	
+    /**
+     * Constructor. Builds a payload format from a static payload
+     * binding identifier, assigning the numeric identifier and
+     * RTP clock rate statically bounded.
+     *
+     * @param type Numeric identifier in the range 0-96.
+     * @note some identifiers are reserved.
+     **/
+    StaticPayloadFormat(StaticPayloadType type);
+
 private:
-	/** 
-	 * RTP clock rate for static payload types. There is no need
-	 * for a table like this for video types, since they all have
-	 * 90000 Khz rate.
-	 **/
-	static uint32 staticAudioTypesRates[lastStaticAudioPayloadType - 
-					    firstStaticPayloadType + 1];
+    /**
+     * RTP clock rate for static payload types. There is no need
+     * for a table like this for video types, since they all have
+     * 90000 Khz rate.
+     **/
+    static uint32 staticAudioTypesRates[lastStaticAudioPayloadType -
+                        firstStaticPayloadType + 1];
 };
 
 /**
@@ -232,26 +230,24 @@
  * assigned, it must be specified to the constructor. This class will
  * be used by applications that support dynamic payload negotiation.
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
- **/	
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
+ **/
 class __EXPORT DynamicPayloadFormat : public PayloadFormat
 {
 public:
-	/**
-	 * Constructor. Builds a dynamic payload format from payload
-	 * numeric identifier and the corresponding RTP clock rate.
-	 *
-	 * @param type payload type numeric identifier.
-	 * @param rate RTP clock rate.
-	 **/
-	DynamicPayloadFormat(PayloadType type, uint32 rate);
+    /**
+     * Constructor. Builds a dynamic payload format from payload
+     * numeric identifier and the corresponding RTP clock rate.
+     *
+     * @param type payload type numeric identifier.
+     * @param rate RTP clock rate.
+     **/
+    DynamicPayloadFormat(PayloadType type, uint32 rate);
 };
 
-/** @}*/ // payload 
+/** @}*/ // payload
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  // ndef CCXX_RTP_FORMATS_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/ioqueue.h b/jni/libccrtp/sources/src/ccrtp/ioqueue.h
index d8aa239..c33c3c3 100644
--- a/jni/libccrtp/sources/src/ccrtp/ioqueue.h
+++ b/jni/libccrtp/sources/src/ccrtp/ioqueue.h
@@ -41,15 +41,13 @@
  * @short Generic RTP input/output queues.
  **/
 
-#ifndef	CCXX_RTP_IOQUEUE_H_
+#ifndef CCXX_RTP_IOQUEUE_H_
 #define CCXX_RTP_IOQUEUE_H_
 
 #include <ccrtp/iqueue.h>
 #include <ccrtp/oqueue.h>
 
-#ifdef	CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @defgroup ioqueue Generic RTP input/output queues.
@@ -75,56 +73,56 @@
  * @short RTP data queue handler.
  */
 class __EXPORT RTPDataQueue :
-	public IncomingDataQueue,
-	public OutgoingDataQueue
+    public IncomingDataQueue,
+    public OutgoingDataQueue
 {
 public:
-	/**
-	 * @enum Tos rtp.h cc++/rtp.h
-	 * @short Type of network service the application uses.
-	 *
-	 * If the application uses enhanced network service, for
-	 * instance Integrated Services or Differentiated Services, it
-	 * <em>has not</em> to ensure fair competition with TCP,
-	 * provided that the requested service is actually being
-	 * delivered.  Whenever the application uses best-effort
-	 * service or the requested enhanced service is not actually
-	 * being delivered, it <em>has</em> to ensure fair competition
-	 * with TCP. By default, best-effot is assumed.
-	 *
-	 * @note Although not required, RTP packets are always sent on
-	 * top of UDP segments. No other underlying transport protocol
-	 * is supported at present.
-	 *
-	 * @todo implement fair competition with tcp
-	 **/
-	typedef enum {
-		tosBestEffort,      ///< Best-effort network service
-		tosEnhanced         ///< Enhanced network service
-	}       Tos;
+    /**
+     * @enum Tos rtp.h cc++/rtp.h
+     * @short Type of network service the application uses.
+     *
+     * If the application uses enhanced network service, for
+     * instance Integrated Services or Differentiated Services, it
+     * <em>has not</em> to ensure fair competition with TCP,
+     * provided that the requested service is actually being
+     * delivered.  Whenever the application uses best-effort
+     * service or the requested enhanced service is not actually
+     * being delivered, it <em>has</em> to ensure fair competition
+     * with TCP. By default, best-effot is assumed.
+     *
+     * @note Although not required, RTP packets are always sent on
+     * top of UDP segments. No other underlying transport protocol
+     * is supported at present.
+     *
+     * @todo implement fair competition with tcp
+     **/
+    typedef enum {
+        tosBestEffort,      ///< Best-effort network service
+        tosEnhanced         ///< Enhanced network service
+    }       Tos;
 
-	/**
-	 * Specify the kind of service the application expects to use.
-	 *
-	 * @param tos type of service the application expects to use
-	 *
-	 * @note If enhanced service is specified but packet loss is
-	 * high (the requested service does not appear to actually be
-	 * delivered) ccRTP defaults to best-effort suitable
-	 * behaviour: guarantee fair competition with TCP.
-	 *
-	 * @todo Implement fair competition with tcp
-	 **/
-	inline void
-	setTypeOfService(Tos tos)
-	{ typeOfService = tos; }
+    /**
+     * Specify the kind of service the application expects to use.
+     *
+     * @param tos type of service the application expects to use
+     *
+     * @note If enhanced service is specified but packet loss is
+     * high (the requested service does not appear to actually be
+     * delivered) ccRTP defaults to best-effort suitable
+     * behaviour: guarantee fair competition with TCP.
+     *
+     * @todo Implement fair competition with tcp
+     **/
+    inline void
+    setTypeOfService(Tos tos)
+    { typeOfService = tos; }
 
-	/**
-	 * Enable packet queue processing in the stack. This method
-	 * will not any thread of execution.
-	 **/
-	inline void enableStack()
-	{ dataServiceActive = true; }
+    /**
+     * Enable packet queue processing in the stack. This method
+     * will not any thread of execution.
+     **/
+    inline void enableStack()
+    { dataServiceActive = true; }
 
         /**
          * Disable packet queue processing in the stack.
@@ -132,206 +130,204 @@
         inline void disableStack()
         { dataServiceActive = false; }
 
-	/**
-	 * Get active connection state flag.
-	 *
-	 * @return true if connection "active".
-	 */
-	inline bool
-	isActive() const
-	{ return dataServiceActive; }
+    /**
+     * Get active connection state flag.
+     *
+     * @return true if connection "active".
+     */
+    inline bool
+    isActive() const
+    { return dataServiceActive; }
 
-	/**
-	 * Get the timestamp that should be given for a packet whose
-	 * payload sampling instant corresponds to the current system
-	 * time.
-	 *
-	 * The timestamp applications should provide for each packet
-	 * represents the sampling instant of its payload and should
-	 * not be a reading of the system clock. Nevertheless, the
-	 * internal operation of the RTP stack relies on the accuracy
-	 * of the provided timestamp, since several computations
-	 * assume that there is a certain degree of correspondence
-	 * between the timestamp and the system clock.
-	 *
-	 * It is recommended that applications use this method in
-	 * order to <em>periodically adjust the RTP timestamp</em>.
-	 *
-	 * In particular, it is advisable getting the timestamp
-	 * corresponding to the first sampling instant or any instant
-	 * after a period of inactivity through a call to this method.
-	 *
-	 * Applications should use the nominal sampling or
-	 * any other value provided by the coder in order to compute
-	 * the next timestamps with minimum computational requirement.
-	 *
-	 * For instance, an application using an RTP profile that
-	 * specifies a fixed sampling rate of 8 Khz with eight bits
-	 * per sample, continuously transmitting audio blocks 80
-	 * octets long, would transmit 100 packets every
-	 * second. Every packet would carry a timestamp 80 units
-	 * greater than the previous one. So, the first timestamp
-	 * would be obtained from this method, whereas the following
-	 * ones would be computed adding 80 every time. Also the
-	 * timestamp should be increased for every block whether
-	 * it is put in the queue or dropped.
-	 *
-	 * The aforementioned increment can be obtained from the
-	 * RTPDataQueue::getTimestampIncrement() method rather than
-	 * computing it by hand in the application.
-	 *
-	 * @note Frame based applications must follow a specific
-	 * timestamping method, probably specified in a profile.
-	 *
-	 * @note You should take into account that by default ccRTP
-	 * assumes that the application begins sampling at the queue
-	 * creation time.  Moreover, the first sampling instant is
-	 * assigned a "user visible" timestamp of 0, although the RTP
-	 * stack will then add internally a ramdom offset unknown to
-	 * the application.  That is to say, the application may count
-	 * samples from 0 in order to get the timestamp for the next
-	 * packet, provided that the first sampling instant is the
-	 * same as the queue creation time.  Nevertheless, this
-	 * simpler way of starting will not be as accurate as it would
-	 * be if the application got at least the first timestamp
-	 * through getCurrentTimestamp.  <em>We provide this option
-	 * since ccRTP interface is evolving, but we admit that it is
-	 * ugly, we could remove this option or even replace uint32
-	 * timestamps with a restrictively regulated object;
-	 * suggestions are gladly welcomed</em>
-	 **/
-	uint32
-	getCurrentTimestamp() const;
+    /**
+     * Get the timestamp that should be given for a packet whose
+     * payload sampling instant corresponds to the current system
+     * time.
+     *
+     * The timestamp applications should provide for each packet
+     * represents the sampling instant of its payload and should
+     * not be a reading of the system clock. Nevertheless, the
+     * internal operation of the RTP stack relies on the accuracy
+     * of the provided timestamp, since several computations
+     * assume that there is a certain degree of correspondence
+     * between the timestamp and the system clock.
+     *
+     * It is recommended that applications use this method in
+     * order to <em>periodically adjust the RTP timestamp</em>.
+     *
+     * In particular, it is advisable getting the timestamp
+     * corresponding to the first sampling instant or any instant
+     * after a period of inactivity through a call to this method.
+     *
+     * Applications should use the nominal sampling or
+     * any other value provided by the coder in order to compute
+     * the next timestamps with minimum computational requirement.
+     *
+     * For instance, an application using an RTP profile that
+     * specifies a fixed sampling rate of 8 Khz with eight bits
+     * per sample, continuously transmitting audio blocks 80
+     * octets long, would transmit 100 packets every
+     * second. Every packet would carry a timestamp 80 units
+     * greater than the previous one. So, the first timestamp
+     * would be obtained from this method, whereas the following
+     * ones would be computed adding 80 every time. Also the
+     * timestamp should be increased for every block whether
+     * it is put in the queue or dropped.
+     *
+     * The aforementioned increment can be obtained from the
+     * RTPDataQueue::getTimestampIncrement() method rather than
+     * computing it by hand in the application.
+     *
+     * @note Frame based applications must follow a specific
+     * timestamping method, probably specified in a profile.
+     *
+     * @note You should take into account that by default ccRTP
+     * assumes that the application begins sampling at the queue
+     * creation time.  Moreover, the first sampling instant is
+     * assigned a "user visible" timestamp of 0, although the RTP
+     * stack will then add internally a ramdom offset unknown to
+     * the application.  That is to say, the application may count
+     * samples from 0 in order to get the timestamp for the next
+     * packet, provided that the first sampling instant is the
+     * same as the queue creation time.  Nevertheless, this
+     * simpler way of starting will not be as accurate as it would
+     * be if the application got at least the first timestamp
+     * through getCurrentTimestamp.  <em>We provide this option
+     * since ccRTP interface is evolving, but we admit that it is
+     * ugly, we could remove this option or even replace uint32
+     * timestamps with a restrictively regulated object;
+     * suggestions are gladly welcomed</em>
+     **/
+    uint32
+    getCurrentTimestamp() const;
 
-	/**
-	 * Specify the bandwidth of the current session.
-	 *
-	 * @param bw bandwidth of the current session, in bits/s.
-	 *
-	 * @see AVPQueue::setControlBandwidth()
-	 */
-	void
-	setSessionBandwidth(uint32 bw)
-	{ sessionBw = bw; }
+    /**
+     * Specify the bandwidth of the current session.
+     *
+     * @param bw bandwidth of the current session, in bits/s.
+     *
+     * @see AVPQueue::setControlBandwidth()
+     */
+    void
+    setSessionBandwidth(uint32 bw)
+    { sessionBw = bw; }
 
-	uint32
-	getDefaultSessionBandwidth() const
-	{ return defaultSessionBw; }
+    uint32
+    getDefaultSessionBandwidth() const
+    { return defaultSessionBw; }
 
-	uint32
-	getSessionBandwidth() const
-	{ return sessionBw; }
+    uint32
+    getSessionBandwidth() const
+    { return sessionBw; }
 
- 	/**
- 	 * Set the packet timeclock for synchronizing timestamps.
- 	 **/
- 	inline void
-	setTimeclock()
-	{ timeclock.setTimer(); }
+    /**
+     * Set the packet timeclock for synchronizing timestamps.
+     **/
+    inline void
+    setTimeclock()
+    { timeclock.setTimer(); }
 
- 	/**
- 	 * Get the packet timeclock for synchronizing timestamps.
- 	 *
- 	 * @return runtime in milliseconds since last set.
- 	 */
- 	inline timeout_t
-	getTimeclock() const
-	{ return timeclock.getElapsed(); }
+    /**
+     * Get the packet timeclock for synchronizing timestamps.
+     *
+     * @return runtime in milliseconds since last set.
+     */
+    inline timeout_t
+    getTimeclock() const
+    { return timeclock.getElapsed(); }
 
 protected:
 
-	/**
-	 * Constructor. This will generate a random application SSRC
-	 * identifier.
-	 *
-	 * @param size an estimation of the number of participants in
-	 * the session
-	 **/
-	RTPDataQueue(uint32 size = defaultMembersHashSize);
+    /**
+     * Constructor. This will generate a random application SSRC
+     * identifier.
+     *
+     * @param size an estimation of the number of participants in
+     * the session
+     **/
+    RTPDataQueue(uint32 size = defaultMembersHashSize);
 
-	/**
-	 * Using this constructor you can start a session with the
-	 * given ssrc, instead of the usual randomly generated
-	 * one. This is necessary when you need to initiate several
-	 * sessions having the same SSRC identifier, for instance, to
-	 * implement layered encoding, in which case each layer is
-	 * managed through a different session but all sessions share
-	 * the same SSRC identifier.
-	 *
-	 * @warning This doesn't seem to be a good solution
-	 *
-	 * @param ssrc Synchronization SouRCe identifier for this session
-	 * @param size an estimation of the number of participants in the
-	 *        session
-	 */
-	RTPDataQueue(uint32* ssrc, uint32 size = defaultMembersHashSize);
+    /**
+     * Using this constructor you can start a session with the
+     * given ssrc, instead of the usual randomly generated
+     * one. This is necessary when you need to initiate several
+     * sessions having the same SSRC identifier, for instance, to
+     * implement layered encoding, in which case each layer is
+     * managed through a different session but all sessions share
+     * the same SSRC identifier.
+     *
+     * @warning This doesn't seem to be a good solution
+     *
+     * @param ssrc Synchronization SouRCe identifier for this session
+     * @param size an estimation of the number of participants in the
+     *        session
+     */
+    RTPDataQueue(uint32* ssrc, uint32 size = defaultMembersHashSize);
 
-	/**
-	 * The queue destructor flushes the queue and stops all
-	 * services.
-	 */
-	inline virtual
-	~RTPDataQueue()
-	{ endQueue(); }
+    /**
+     * The queue destructor flushes the queue and stops all
+     * services.
+     */
+    inline virtual
+    ~RTPDataQueue()
+    { endQueue(); }
 
         /**
          * A plugin point for timer tick driven events.
          */
         inline virtual void
-	timerTick()
-	{ return; }
+    timerTick()
+    { return; }
 
-	void renewLocalSSRC()
-		{IncomingDataQueue::renewLocalSSRC();}
+    void renewLocalSSRC()
+        {IncomingDataQueue::renewLocalSSRC();}
 
 private:
-	RTPDataQueue(const RTPDataQueue &o);
+    RTPDataQueue(const RTPDataQueue &o);
 
-	RTPDataQueue&
-	operator=(const RTPDataQueue &o);
+    RTPDataQueue&
+    operator=(const RTPDataQueue &o);
 
-	/**
-	 * Global queue initialization.
-	 *
-	 * @param localSSRC local 32-bit SSRC identifier
-	 **/
-	void
-	initQueue();
+    /**
+     * Global queue initialization.
+     *
+     * @param localSSRC local 32-bit SSRC identifier
+     **/
+    void
+    initQueue();
 
 protected:
-	/**
-	 * This method ends the queue.
-	 */
-	void
-	endQueue();
+    /**
+     * This method ends the queue.
+     */
+    void
+    endQueue();
 
-	/**
-	 * This function is used to check for and schedule against
-	 * arriving packets based on the derived connection type.
-	 *
-	 * @return true if packet waiting for processing.
-	 * @param number of microseconds to wait.
-	 */
-	virtual bool
-	isPendingData(microtimeout_t timeout) = 0;
+    /**
+     * This function is used to check for and schedule against
+     * arriving packets based on the derived connection type.
+     *
+     * @return true if packet waiting for processing.
+     * @param number of microseconds to wait.
+     */
+    virtual bool
+    isPendingData(microtimeout_t timeout) = 0;
 
 private:
-	// true if connection "active"
-	volatile bool dataServiceActive;
-	Tos typeOfService;
-	TimerPort timeclock;
-	/* RTP session bandwidth control */
-	static const uint32 defaultSessionBw;
-	uint32 sessionBw;
+    // true if connection "active"
+    volatile bool dataServiceActive;
+    Tos typeOfService;
+    TimerPort timeclock;
+    /* RTP session bandwidth control */
+    static const uint32 defaultSessionBw;
+    uint32 sessionBw;
 
 
 };
 
 /** @}*/ // ioqueue
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  //CCXX_RTP_IOQUEUE_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/iqueue.h b/jni/libccrtp/sources/src/ccrtp/iqueue.h
index 0fbd14d..36350d4 100644
--- a/jni/libccrtp/sources/src/ccrtp/iqueue.h
+++ b/jni/libccrtp/sources/src/ccrtp/iqueue.h
@@ -41,7 +41,7 @@
  * @short Generic RTP input queues.
  **/
 
-#ifndef	CCXX_RTP_IQUEUE_H_
+#ifndef CCXX_RTP_IQUEUE_H_
 #define CCXX_RTP_IQUEUE_H_
 
 #include <ccrtp/queuebase.h>
@@ -49,9 +49,7 @@
 
 #include <list>
 
-#ifdef	CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @defgroup iqueue Generic RTP input queues.
@@ -70,52 +68,52 @@
 class __EXPORT Members
 {
 public:
-	inline void
-	setMembersCount(uint32 n)
-	{ members = n; }
+    inline void
+    setMembersCount(uint32 n)
+    { members = n; }
 
-	inline void
-	increaseMembersCount()
-	{ members++; }
+    inline void
+    increaseMembersCount()
+    { members++; }
 
-	inline void
-	decreaseMembersCount()
-	{ members--; }
+    inline void
+    decreaseMembersCount()
+    { members--; }
 
-	inline uint32
-	getMembersCount() const
-	{ return members; }
+    inline uint32
+    getMembersCount() const
+    { return members; }
 
-	inline void
-	setSendersCount(uint32 n)
-	{ activeSenders = n; }
+    inline void
+    setSendersCount(uint32 n)
+    { activeSenders = n; }
 
-	inline void
-	increaseSendersCount()
-	{ activeSenders++; }
+    inline void
+    increaseSendersCount()
+    { activeSenders++; }
 
-	inline void
-	decreaseSendersCount()
-	{ activeSenders--; }
+    inline void
+    decreaseSendersCount()
+    { activeSenders--; }
 
-	inline uint32
-	getSendersCount() const
-	{ return activeSenders; }
+    inline uint32
+    getSendersCount() const
+    { return activeSenders; }
 
 protected:
-	Members() :
-		members(0),
-		activeSenders(0)
-	{ }
+    Members() :
+        members(0),
+        activeSenders(0)
+    { }
 
-	inline virtual ~Members()
-	{ }
+    inline virtual ~Members()
+    { }
 
 private:
-	/// number of identified members
-	uint32 members;
-	/// number of identified members that currently are active senders
-	uint32 activeSenders;
+    /// number of identified members
+    uint32 members;
+    /// number of identified members that currently are active senders
+    uint32 activeSenders;
 };
 
 /**
@@ -127,50 +125,50 @@
 class __EXPORT SyncSourceHandler
 {
 public:
-	/**
-	 * This requires SyncSource - SyncSourceHandler friendship.
-	 *
-	 * Get the SyncSourceLink corresponding to a SyncSource
-	 * object.
-	 **/
-	inline void*
-	getLink(const SyncSource& source) const
-	{ return source.getLink(); }
+    /**
+     * This requires SyncSource - SyncSourceHandler friendship.
+     *
+     * Get the SyncSourceLink corresponding to a SyncSource
+     * object.
+     **/
+    inline void*
+    getLink(const SyncSource& source) const
+    { return source.getLink(); }
 
-	inline void
-	setLink(SyncSource& source, void* link)
-	{ source.setLink(link); }
+    inline void
+    setLink(SyncSource& source, void* link)
+    { source.setLink(link); }
 
-	inline void
-	setParticipant(SyncSource& source, Participant& p)
-	{ source.setParticipant(p); }
+    inline void
+    setParticipant(SyncSource& source, Participant& p)
+    { source.setParticipant(p); }
 
-	inline void
-	setState(SyncSource& source, SyncSource::State ns)
-	{ source.setState(ns); }
+    inline void
+    setState(SyncSource& source, SyncSource::State ns)
+    { source.setState(ns); }
 
-	inline void
-	setSender(SyncSource& source, bool active)
-	{ source.setSender(active); }
+    inline void
+    setSender(SyncSource& source, bool active)
+    { source.setSender(active); }
 
-	inline void
-	setDataTransportPort(SyncSource& source, tpport_t p)
-	{ source.setDataTransportPort(p); }
+    inline void
+    setDataTransportPort(SyncSource& source, tpport_t p)
+    { source.setDataTransportPort(p); }
 
-	inline void
-	setControlTransportPort(SyncSource& source, tpport_t p)
-	{ source.setControlTransportPort(p); }
+    inline void
+    setControlTransportPort(SyncSource& source, tpport_t p)
+    { source.setControlTransportPort(p); }
 
-	inline void
-	setNetworkAddress(SyncSource& source, InetAddress addr)
-	{ source.setNetworkAddress(addr); }
+    inline void
+    setNetworkAddress(SyncSource& source, InetAddress addr)
+    { source.setNetworkAddress(addr); }
 
 protected:
-	SyncSourceHandler()
-	{ }
+    SyncSourceHandler()
+    { }
 
-	inline virtual ~SyncSourceHandler()
-	{ }
+    inline virtual ~SyncSourceHandler()
+    { }
 };
 
 /**
@@ -182,21 +180,21 @@
 class __EXPORT ParticipantHandler
 {
 public:
-	inline void
-	setSDESItem(Participant* part, SDESItemType item,
-		    const std::string& val)
-	{ part->setSDESItem(item,val); }
+    inline void
+    setSDESItem(Participant* part, SDESItemType item,
+            const std::string& val)
+    { part->setSDESItem(item,val); }
 
-	inline void
-	setPRIVPrefix(Participant* part, const std::string val)
-	{ part->setPRIVPrefix(val); }
+    inline void
+    setPRIVPrefix(Participant* part, const std::string val)
+    { part->setPRIVPrefix(val); }
 
 protected:
-	ParticipantHandler()
-	{ }
+    ParticipantHandler()
+    { }
 
-	inline virtual ~ParticipantHandler()
-	{ }
+    inline virtual ~ParticipantHandler()
+    { }
 };
 
 /**
@@ -208,21 +206,21 @@
 class __EXPORT ApplicationHandler
 {
 public:
-	inline void
-	addParticipant(RTPApplication& app, Participant& part)
-	{ app.addParticipant(part); }
+    inline void
+    addParticipant(RTPApplication& app, Participant& part)
+    { app.addParticipant(part); }
 
-	inline void
-	removeParticipant(RTPApplication& app,
-			  RTPApplication::ParticipantLink* pl)
-	{ app.removeParticipant(pl); }
+    inline void
+    removeParticipant(RTPApplication& app,
+              RTPApplication::ParticipantLink* pl)
+    { app.removeParticipant(pl); }
 
 protected:
-	ApplicationHandler()
-	{ }
+    ApplicationHandler()
+    { }
 
-	inline virtual ~ApplicationHandler()
-	{ }
+    inline virtual ~ApplicationHandler()
+    { }
 };
 
 /**
@@ -235,57 +233,57 @@
 class __EXPORT ConflictHandler
 {
 public:
-	struct ConflictingTransportAddress
-	{
-		ConflictingTransportAddress(InetAddress na,
-					    tpport_t dtp, tpport_t ctp);
+    struct ConflictingTransportAddress
+    {
+        ConflictingTransportAddress(InetAddress na,
+                        tpport_t dtp, tpport_t ctp);
 
-		void setNext(ConflictingTransportAddress* nc)
-		{ next = nc; }
+        void setNext(ConflictingTransportAddress* nc)
+        { next = nc; }
 
-		inline const InetAddress& getNetworkAddress( ) const
-		{ return networkAddress; }
+        inline const InetAddress& getNetworkAddress( ) const
+        { return networkAddress; }
 
-		inline tpport_t getDataTransportPort() const
-		{ return dataTransportPort; }
+        inline tpport_t getDataTransportPort() const
+        { return dataTransportPort; }
 
-		inline tpport_t getControlTransportPort() const
-		{ return controlTransportPort; }
+        inline tpport_t getControlTransportPort() const
+        { return controlTransportPort; }
 
-		InetAddress networkAddress;
-		tpport_t dataTransportPort;
-		tpport_t controlTransportPort;
-		ConflictingTransportAddress* next;
-		// arrival time of last data or control packet.
-		timeval lastPacketTime;
-	};
+        InetAddress networkAddress;
+        tpport_t dataTransportPort;
+        tpport_t controlTransportPort;
+        ConflictingTransportAddress* next;
+        // arrival time of last data or control packet.
+        timeval lastPacketTime;
+    };
 
-	/**
-	 * @param na Inet network address.
-	 * @param dtp Data transport port.
-	 **/
-	ConflictingTransportAddress* searchDataConflict(InetAddress na,
-							tpport_t dtp);
-	/**
-	 * @param na Inet network address.
-	 * @param ctp Data transport port.
-	 **/
-	ConflictingTransportAddress* searchControlConflict(InetAddress na,
-							   tpport_t ctp);
+    /**
+     * @param na Inet network address.
+     * @param dtp Data transport port.
+     **/
+    ConflictingTransportAddress* searchDataConflict(InetAddress na,
+                            tpport_t dtp);
+    /**
+     * @param na Inet network address.
+     * @param ctp Data transport port.
+     **/
+    ConflictingTransportAddress* searchControlConflict(InetAddress na,
+                               tpport_t ctp);
 
-	void updateConflict(ConflictingTransportAddress& ca)
-	{ gettimeofday(&(ca.lastPacketTime),NULL); }
+    void updateConflict(ConflictingTransportAddress& ca)
+    { SysTime::gettimeofday(&(ca.lastPacketTime),NULL); }
 
-	void addConflict(const InetAddress& na, tpport_t dtp, tpport_t ctp);
+    void addConflict(const InetAddress& na, tpport_t dtp, tpport_t ctp);
 
 protected:
-	ConflictHandler()
-	{ firstConflict = lastConflict = NULL; }
+    ConflictHandler()
+    { firstConflict = lastConflict = NULL; }
 
-	inline virtual ~ConflictHandler()
-	{ }
+    inline virtual ~ConflictHandler()
+    { }
 
-	ConflictingTransportAddress* firstConflict, * lastConflict;
+    ConflictingTransportAddress* firstConflict, * lastConflict;
 };
 
 /**
@@ -299,579 +297,579 @@
  * @author Federico Montesino Pouzols <fedemp@altern.org>
  */
 class __EXPORT MembershipBookkeeping :
-	public SyncSourceHandler,
-	public ParticipantHandler,
-	public ApplicationHandler,
-	public ConflictHandler,
-	private Members
+    public SyncSourceHandler,
+    public ParticipantHandler,
+    public ApplicationHandler,
+    public ConflictHandler,
+    private Members
 {
 public:
-	inline size_t getDefaultMembersHashSize()
-	{ return defaultMembersHashSize; }
+    inline size_t getDefaultMembersHashSize()
+    { return defaultMembersHashSize; }
 
 protected:
 
-	/**
-	 * @short The initial size is a hint to allocate the resources
-	 * needed in order to keep the members' identifiers and
-	 * associated information.
-	 *
-	 * Although ccRTP will reallocate resources when it becomes
-	 * necessary, a good hint may save a lot of unpredictable time
-	 * penalties.
-	 *
-	 * @param initialSize an estimation of how many participants
-	 * the session will consist of.
-	 *
-	 */
-	MembershipBookkeeping(uint32 initialSize = defaultMembersHashSize);
+    /**
+     * @short The initial size is a hint to allocate the resources
+     * needed in order to keep the members' identifiers and
+     * associated information.
+     *
+     * Although ccRTP will reallocate resources when it becomes
+     * necessary, a good hint may save a lot of unpredictable time
+     * penalties.
+     *
+     * @param initialSize an estimation of how many participants
+     * the session will consist of.
+     *
+     */
+    MembershipBookkeeping(uint32 initialSize = defaultMembersHashSize);
 
-	/**
-	 * Purges all RTPSource structures created during the session,
-	 * as well as the hash table and the list of sources.
-	 **/
-	inline virtual
-	~MembershipBookkeeping()
-	{ endMembers(); }
+    /**
+     * Purges all RTPSource structures created during the session,
+     * as well as the hash table and the list of sources.
+     **/
+    inline virtual
+    ~MembershipBookkeeping()
+    { endMembers(); }
 
-	struct SyncSourceLink;
+    struct SyncSourceLink;
 
-	inline SyncSourceLink* getLink(const SyncSource& source) const
-	{ return static_cast<SyncSourceLink*>(SyncSourceHandler::getLink(source)); }
-	/**
-	 * Get whether a synchronization source is recorded in this
-	 * membership controller.
-	 **/
-	inline bool isMine(const SyncSource& source) const
-	{ return getLink(source)->getMembership() == this; }
+    inline SyncSourceLink* getLink(const SyncSource& source) const
+    { return static_cast<SyncSourceLink*>(SyncSourceHandler::getLink(source)); }
+    /**
+     * Get whether a synchronization source is recorded in this
+     * membership controller.
+     **/
+    inline bool isMine(const SyncSource& source) const
+    { return getLink(source)->getMembership() == this; }
 
-	/**
-	 * @struct IncomingRTPPktLink
-	 *
-	 * @short Incoming RTP data packets control structure within
-	 * the incoming packet queue class.
-	 **/
-	struct IncomingRTPPktLink
-	{
-		IncomingRTPPktLink(IncomingRTPPkt* pkt, SyncSourceLink* sLink,
-				   struct timeval& recv_ts,
-				   uint32 shifted_ts,
-				   IncomingRTPPktLink* sp,
-				   IncomingRTPPktLink* sn,
-				   IncomingRTPPktLink* p,
-				   IncomingRTPPktLink* n) :
-			packet(pkt),
-			sourceLink(sLink),
-			prev(p), next(n),
-			srcPrev(sp), srcNext(sn),
-			receptionTime(recv_ts),
-			shiftedTimestamp(shifted_ts)
-		{ }
+    /**
+     * @struct IncomingRTPPktLink
+     *
+     * @short Incoming RTP data packets control structure within
+     * the incoming packet queue class.
+     **/
+    struct IncomingRTPPktLink
+    {
+        IncomingRTPPktLink(IncomingRTPPkt* pkt, SyncSourceLink* sLink,
+                   struct timeval& recv_ts,
+                   uint32 shifted_ts,
+                   IncomingRTPPktLink* sp,
+                   IncomingRTPPktLink* sn,
+                   IncomingRTPPktLink* p,
+                   IncomingRTPPktLink* n) :
+            packet(pkt),
+            sourceLink(sLink),
+            prev(p), next(n),
+            srcPrev(sp), srcNext(sn),
+            receptionTime(recv_ts),
+            shiftedTimestamp(shifted_ts)
+        { }
 
-		~IncomingRTPPktLink()
-		{ }
+        ~IncomingRTPPktLink()
+        { }
 
-		inline SyncSourceLink* getSourceLink() const
-		{ return sourceLink; }
+        inline SyncSourceLink* getSourceLink() const
+        { return sourceLink; }
 
-		inline void setSourceLink(SyncSourceLink* src)
-		{ sourceLink = src; }
+        inline void setSourceLink(SyncSourceLink* src)
+        { sourceLink = src; }
 
-		inline IncomingRTPPktLink* getNext() const
-		{ return next; }
+        inline IncomingRTPPktLink* getNext() const
+        { return next; }
 
-		inline void setNext(IncomingRTPPktLink* nl)
-		{ next = nl; }
+        inline void setNext(IncomingRTPPktLink* nl)
+        { next = nl; }
 
-		inline IncomingRTPPktLink* getPrev() const
-		{ return prev; }
+        inline IncomingRTPPktLink* getPrev() const
+        { return prev; }
 
-		inline void setPrev(IncomingRTPPktLink* pl)
-		{ prev = pl; }
+        inline void setPrev(IncomingRTPPktLink* pl)
+        { prev = pl; }
 
-		inline IncomingRTPPktLink* getSrcNext() const
-		{ return srcNext; }
+        inline IncomingRTPPktLink* getSrcNext() const
+        { return srcNext; }
 
-		inline void setSrcNext(IncomingRTPPktLink* sn)
-		{ srcNext = sn; }
+        inline void setSrcNext(IncomingRTPPktLink* sn)
+        { srcNext = sn; }
 
-		inline IncomingRTPPktLink* getSrcPrev() const
-		{ return srcPrev; }
+        inline IncomingRTPPktLink* getSrcPrev() const
+        { return srcPrev; }
 
-		inline void setSrcPrev(IncomingRTPPktLink* sp)
-		{ srcPrev = sp; }
+        inline void setSrcPrev(IncomingRTPPktLink* sp)
+        { srcPrev = sp; }
 
-		inline IncomingRTPPkt* getPacket() const
-		{ return packet; }
+        inline IncomingRTPPkt* getPacket() const
+        { return packet; }
 
-		inline void setPacket(IncomingRTPPkt* pkt)
-		{ packet = pkt; }
+        inline void setPacket(IncomingRTPPkt* pkt)
+        { packet = pkt; }
 
-		/**
-		 * Set the time this packet was received at.
-		 *
-		 * @param t time of reception.
-		 * @note this has almost nothing to do with the 32-bit
-		 * timestamp contained in the packet header.
-		 **/
-		inline void setRecvTime(const timeval &t)
-		{ receptionTime = t; }
+        /**
+         * Set the time this packet was received at.
+         *
+         * @param t time of reception.
+         * @note this has almost nothing to do with the 32-bit
+         * timestamp contained in the packet header.
+         **/
+        inline void setRecvTime(const timeval &t)
+        { receptionTime = t; }
 
-		/**
-		 * Get the time this packet was received at.
-		 **/
-		inline timeval getRecvTime() const
-		{ return receptionTime; }
+        /**
+         * Get the time this packet was received at.
+         **/
+        inline timeval getRecvTime() const
+        { return receptionTime; }
 
-		/**
-		 * Get timestamp of this packet. The timestamp of
-		 * incoming packets is filtered so that the timestamp
-		 * this method provides for the first packet received
-		 * from every source starts from 0.
-		 *
-		 * @return 32 bit timestamp starting from 0 for each source.
-		 */
-		inline uint32 getTimestamp() const
-		{ return shiftedTimestamp; }
+        /**
+         * Get timestamp of this packet. The timestamp of
+         * incoming packets is filtered so that the timestamp
+         * this method provides for the first packet received
+         * from every source starts from 0.
+         *
+         * @return 32 bit timestamp starting from 0 for each source.
+         */
+        inline uint32 getTimestamp() const
+        { return shiftedTimestamp; }
 
-		inline void setTimestamp(uint32 ts)
-		{ shiftedTimestamp = ts;}
+        inline void setTimestamp(uint32 ts)
+        { shiftedTimestamp = ts;}
 
-		// the packet this link refers to.
-		IncomingRTPPkt* packet;
-		// the synchronization source this packet comes from.
-		SyncSourceLink* sourceLink;
-		// global incoming packet queue links.
-		IncomingRTPPktLink* prev, * next;
-		// source specific incoming packet queue links.
-		IncomingRTPPktLink* srcPrev, * srcNext;
-		// time this packet was received at
-		struct timeval receptionTime;
-		// timestamp of the packet in host order and after
-		// substracting the initial timestamp for its source
-		// (it is an increment from the initial timestamp).
-		uint32 shiftedTimestamp;
-	};
+        // the packet this link refers to.
+        IncomingRTPPkt* packet;
+        // the synchronization source this packet comes from.
+        SyncSourceLink* sourceLink;
+        // global incoming packet queue links.
+        IncomingRTPPktLink* prev, * next;
+        // source specific incoming packet queue links.
+        IncomingRTPPktLink* srcPrev, * srcNext;
+        // time this packet was received at
+        struct timeval receptionTime;
+        // timestamp of the packet in host order and after
+        // substracting the initial timestamp for its source
+        // (it is an increment from the initial timestamp).
+        uint32 shiftedTimestamp;
+    };
 
-	/**
-	 * @struct SyncSourceLink
-	 *
-	 * @short Synchronization Source internal handler within the
-	 * incoming packets queue.
-	 *
-	 * Incoming packets queue objects hold a hash table and a
-	 * linked list of synchronization sources. For each of these
-	 * sources, there is also a linked list of incoming rtp
-	 * packets, which are linked in an "all incoming packets" list
-	 * as well. SyncSourceLink objects hold the necessary data to
-	 * maintain these data estructures, as well as source specific
-	 * information and statistics for RTCP,
-	 *
-	 * @author Federico Montesino Pouzols <fedemp@altern.org>
-	 **/
-	struct SyncSourceLink
-	{
-		// 2^16
-		static const uint32 SEQNUMMOD;
+    /**
+     * @struct SyncSourceLink
+     *
+     * @short Synchronization Source internal handler within the
+     * incoming packets queue.
+     *
+     * Incoming packets queue objects hold a hash table and a
+     * linked list of synchronization sources. For each of these
+     * sources, there is also a linked list of incoming rtp
+     * packets, which are linked in an "all incoming packets" list
+     * as well. SyncSourceLink objects hold the necessary data to
+     * maintain these data estructures, as well as source specific
+     * information and statistics for RTCP,
+     *
+     * @author Federico Montesino Pouzols <fedemp@altern.org>
+     **/
+    struct SyncSourceLink
+    {
+        // 2^16
+        static const uint32 SEQNUMMOD;
 
-		SyncSourceLink(MembershipBookkeeping* m,
-			       SyncSource* s,
-			       IncomingRTPPktLink* fp = NULL,
-			       IncomingRTPPktLink* lp = NULL,
-			       SyncSourceLink* ps = NULL,
-			       SyncSourceLink* ns = NULL,
-			       SyncSourceLink* ncollis = NULL) :
-			membership(m), source(s), first(fp), last(lp),
-			prev(ps), next(ns), nextCollis(ncollis),
-			prevConflict(NULL)
-		{ m->setLink(*s,this); // record that the source is associated
-		  initStats();         // to this link.
-		}
+        SyncSourceLink(MembershipBookkeeping* m,
+                   SyncSource* s,
+                   IncomingRTPPktLink* fp = NULL,
+                   IncomingRTPPktLink* lp = NULL,
+                   SyncSourceLink* ps = NULL,
+                   SyncSourceLink* ns = NULL,
+                   SyncSourceLink* ncollis = NULL) :
+            membership(m), source(s), first(fp), last(lp),
+            prev(ps), next(ns), nextCollis(ncollis),
+            prevConflict(NULL)
+        { m->setLink(*s,this); // record that the source is associated
+          initStats();         // to this link.
+        }
 
-		/**
-		 * Note it deletes the source.
-		 **/
-		~SyncSourceLink();
+        /**
+         * Note it deletes the source.
+         **/
+        ~SyncSourceLink();
 
-		inline MembershipBookkeeping* getMembership()
-		{ return membership; }
+        inline MembershipBookkeeping* getMembership()
+        { return membership; }
 
-		/**
-		 * Get the synchronization source object this link
-		 * objet holds information for.
-		 **/
-		inline SyncSource* getSource() { return source; }
+        /**
+         * Get the synchronization source object this link
+         * objet holds information for.
+         **/
+        inline SyncSource* getSource() { return source; }
 
-		/**
-		 * Get first RTP (data) packet in the queue of packets
-		 * received from this socket.
-		 **/
-		inline IncomingRTPPktLink* getFirst()
-		{ return first; }
+        /**
+         * Get first RTP (data) packet in the queue of packets
+         * received from this socket.
+         **/
+        inline IncomingRTPPktLink* getFirst()
+        { return first; }
 
-		inline void setFirst(IncomingRTPPktLink* fp)
-		{ first = fp; }
+        inline void setFirst(IncomingRTPPktLink* fp)
+        { first = fp; }
 
-		/**
-		 * Get last RTP (data) packet in the queue of packets
-		 * received from this socket.
-		 **/
-		inline IncomingRTPPktLink* getLast()
-		{ return last; }
+        /**
+         * Get last RTP (data) packet in the queue of packets
+         * received from this socket.
+         **/
+        inline IncomingRTPPktLink* getLast()
+        { return last; }
 
-		inline void setLast(IncomingRTPPktLink* lp)
-		{ last = lp; }
+        inline void setLast(IncomingRTPPktLink* lp)
+        { last = lp; }
 
-		/**
-		 * Get the link object for the previous RTP source.
-		 **/
-		inline SyncSourceLink* getPrev()
-		{ return prev; }
+        /**
+         * Get the link object for the previous RTP source.
+         **/
+        inline SyncSourceLink* getPrev()
+        { return prev; }
 
-		inline void setPrev(SyncSourceLink* ps)
-		{ prev = ps; }
+        inline void setPrev(SyncSourceLink* ps)
+        { prev = ps; }
 
-		/**
-		 * Get the link object for the next RTP source.
-		 **/
-		inline SyncSourceLink* getNext()
-		{ return next; }
+        /**
+         * Get the link object for the next RTP source.
+         **/
+        inline SyncSourceLink* getNext()
+        { return next; }
 
-		inline void setNext(SyncSourceLink *ns)
-		{ next = ns; }
+        inline void setNext(SyncSourceLink *ns)
+        { next = ns; }
 
-		/**
-		 * Get the link object for the next RTP source in the
-		 * hash table entry collision list.  Note that
-		 * collision does not refer to SSRC collision, but
-		 * hash table collision.
-		 **/
-		inline SyncSourceLink* getNextCollis()
-		{ return nextCollis; }
+        /**
+         * Get the link object for the next RTP source in the
+         * hash table entry collision list.  Note that
+         * collision does not refer to SSRC collision, but
+         * hash table collision.
+         **/
+        inline SyncSourceLink* getNextCollis()
+        { return nextCollis; }
 
-		inline void setNextCollis(SyncSourceLink* ns)
-		{ nextCollis = ns; }
+        inline void setNextCollis(SyncSourceLink* ns)
+        { nextCollis = ns; }
 
-		inline ConflictingTransportAddress* getPrevConflict() const
-		{ return prevConflict; }
+        inline ConflictingTransportAddress* getPrevConflict() const
+        { return prevConflict; }
 
-		/**
-		 * Get conflicting address.
-		 **/
-		void setPrevConflict(InetAddress& addr, tpport_t dataPort,
-				     tpport_t controlPort);
+        /**
+         * Get conflicting address.
+         **/
+        void setPrevConflict(InetAddress& addr, tpport_t dataPort,
+                     tpport_t controlPort);
 
-		unsigned char* getSenderInfo()
-		{ return senderInfo; }
+        unsigned char* getSenderInfo()
+        { return senderInfo; }
 
-		void setSenderInfo(unsigned char* si);
+        void setSenderInfo(unsigned char* si);
 
-		unsigned char* getReceiverInfo()
-		{ return receiverInfo; }
+        unsigned char* getReceiverInfo()
+        { return receiverInfo; }
 
-		void setReceiverInfo(unsigned char* ri);
+        void setReceiverInfo(unsigned char* ri);
 
-		inline timeval getLastPacketTime() const
-		{ return lastPacketTime; }
+        inline timeval getLastPacketTime() const
+        { return lastPacketTime; }
 
-		inline timeval getLastRTCPPacketTime() const
-		{ return lastRTCPPacketTime; }
+        inline timeval getLastRTCPPacketTime() const
+        { return lastRTCPPacketTime; }
 
-		inline timeval getLastRTCPSRTime() const
-		{ return lastRTCPSRTime; }
+        inline timeval getLastRTCPSRTime() const
+        { return lastRTCPSRTime; }
 
-		/**
-		 * Get the total number of RTP packets received from this
-		 * source.
-		 */
-		inline uint32 getObservedPacketCount() const
-		{ return obsPacketCount; }
+        /**
+         * Get the total number of RTP packets received from this
+         * source.
+         */
+        inline uint32 getObservedPacketCount() const
+        { return obsPacketCount; }
 
-		inline void incObservedPacketCount()
-		{ obsPacketCount++; }
+        inline void incObservedPacketCount()
+        { obsPacketCount++; }
 
-		/**
-		 * Get the total number of payload octets received from this
-		 * source.
-		 **/
-		inline uint32 getObservedOctetCount() const
-		{ return obsOctetCount; }
+        /**
+         * Get the total number of payload octets received from this
+         * source.
+         **/
+        inline uint32 getObservedOctetCount() const
+        { return obsOctetCount; }
 
-		inline void incObservedOctetCount(uint32 n)
-		{ obsOctetCount += n; }
+        inline void incObservedOctetCount(uint32 n)
+        { obsOctetCount += n; }
 
-		/**
-		 * Get the highest valid sequence number received.
-		 **/
-		uint16
-		getMaxSeqNum() const
-		{ return maxSeqNum; }
+        /**
+         * Get the highest valid sequence number received.
+         **/
+        uint16
+        getMaxSeqNum() const
+        { return maxSeqNum; }
 
-		/**
-		 * Set the highest valid sequence number recived.
-		 * @param max Sequence number.
-		 **/
-		void
-		setMaxSeqNum(uint16 max)
-		{ maxSeqNum = max; }
+        /**
+         * Set the highest valid sequence number recived.
+         * @param max Sequence number.
+         **/
+        void
+        setMaxSeqNum(uint16 max)
+        { maxSeqNum = max; }
 
-		inline uint32
-		getExtendedMaxSeqNum() const
-		{ return extendedMaxSeqNum; }
+        inline uint32
+        getExtendedMaxSeqNum() const
+        { return extendedMaxSeqNum; }
 
-		inline void
-		setExtendedMaxSeqNum(uint32 seq)
-		{ extendedMaxSeqNum = seq; }
+        inline void
+        setExtendedMaxSeqNum(uint32 seq)
+        { extendedMaxSeqNum = seq; }
 
-		inline uint32 getCumulativePacketLost() const
-		{ return cumulativePacketLost; }
+        inline uint32 getCumulativePacketLost() const
+        { return cumulativePacketLost; }
 
-		inline void setCumulativePacketLost(uint32 pl)
-		{ cumulativePacketLost = pl; }
+        inline void setCumulativePacketLost(uint32 pl)
+        { cumulativePacketLost = pl; }
 
-		inline uint8 getFractionLost() const
-		{ return fractionLost; }
+        inline uint8 getFractionLost() const
+        { return fractionLost; }
 
-		inline void setFractionLost(uint8 fl)
-		{ fractionLost = fl; }
+        inline void setFractionLost(uint8 fl)
+        { fractionLost = fl; }
 
-		inline uint32 getLastPacketTransitTime()
-		{ return lastPacketTransitTime; }
+        inline uint32 getLastPacketTransitTime()
+        { return lastPacketTransitTime; }
 
-		inline void setLastPacketTransitTime(uint32 time)
-		{ lastPacketTransitTime = time; }
+        inline void setLastPacketTransitTime(uint32 time)
+        { lastPacketTransitTime = time; }
 
-		inline float getJitter() const
-		{ return jitter; }
+        inline float getJitter() const
+        { return jitter; }
 
-		inline void setJitter(float j)
-		{ jitter = j; }
+        inline void setJitter(float j)
+        { jitter = j; }
 
-		inline uint32 getInitialDataTimestamp() const
-		{ return initialDataTimestamp; }
+        inline uint32 getInitialDataTimestamp() const
+        { return initialDataTimestamp; }
 
-		inline void setInitialDataTimestamp(uint32 ts)
-		{ initialDataTimestamp = ts; }
+        inline void setInitialDataTimestamp(uint32 ts)
+        { initialDataTimestamp = ts; }
 
-		inline timeval getInitialDataTime() const
-		{ return initialDataTime; }
+        inline timeval getInitialDataTime() const
+        { return initialDataTime; }
 
-		inline void setInitialDataTime(timeval it)
-		{ initialDataTime = it; }
+        inline void setInitialDataTime(timeval it)
+        { initialDataTime = it; }
 
-		/**
-		 * Mark this source as having sent a BYE control packet.
-		 *
-		 * @return whether some packet from this source had
-		 * been received before (getHello() has been called at
-		 * least once)
-		 **/
-		bool getGoodbye()
-		{
-			if(!flag)
-				return false;
-			flag = false;
-			return true;
-		}
+        /**
+         * Mark this source as having sent a BYE control packet.
+         *
+         * @return whether some packet from this source had
+         * been received before (getHello() has been called at
+         * least once)
+         **/
+        bool getGoodbye()
+        {
+            if(!flag)
+                return false;
+            flag = false;
+            return true;
+        }
 
-		/**
-		 * Mark this source as having sent some packet.
-		 *
-		 * @return whether no packet from this source had been
-		 * received before
-		 **/
-		bool getHello() {
-			if(flag)
-				return false;
-			flag = true;
-			return true;
-		}
+        /**
+         * Mark this source as having sent some packet.
+         *
+         * @return whether no packet from this source had been
+         * received before
+         **/
+        bool getHello() {
+            if(flag)
+                return false;
+            flag = true;
+            return true;
+        }
 
-		inline uint32 getBadSeqNum() const
-		{ return badSeqNum; }
+        inline uint32 getBadSeqNum() const
+        { return badSeqNum; }
 
-		inline void setBadSeqNum(uint32 seq)
-		{ badSeqNum = seq; }
+        inline void setBadSeqNum(uint32 seq)
+        { badSeqNum = seq; }
 
-		uint8 getProbation() const
-		{ return probation; }
+        uint8 getProbation() const
+        { return probation; }
 
-		inline void setProbation(uint8 p)
-		{ probation = p; }
+        inline void setProbation(uint8 p)
+        { probation = p; }
 
-		inline void decProbation()
-		{ --probation; }
+        inline void decProbation()
+        { --probation; }
 
-		bool isValid() const
-		{ return 0 == probation; }
+        bool isValid() const
+        { return 0 == probation; }
 
-		inline uint16 getBaseSeqNum() const
-		{ return baseSeqNum; }
+        inline uint16 getBaseSeqNum() const
+        { return baseSeqNum; }
 
-		inline uint32 getSeqNumAccum() const
-		{ return seqNumAccum; }
+        inline uint32 getSeqNumAccum() const
+        { return seqNumAccum; }
 
-		inline void incSeqNumAccum()
-		{ seqNumAccum += SEQNUMMOD; }
+        inline void incSeqNumAccum()
+        { seqNumAccum += SEQNUMMOD; }
 
-		/**
-		 * Start a new sequence of received packets.
-		 **/
-		inline void initSequence(uint16 seqnum)
-		{ maxSeqNum = seqNumAccum = seqnum; }
+        /**
+         * Start a new sequence of received packets.
+         **/
+        inline void initSequence(uint16 seqnum)
+        { maxSeqNum = seqNumAccum = seqnum; }
 
-		/**
-		 * Record the insertion of an RTP packet from this
-		 * source into the scheduled reception queue. All
-		 * received packets should be registered with
-		 * recordReception(), but only those actually inserted
-		 * into the queue should be registered via this
-		 * method.
-		 *
-		 * @param pl Link structure for packet inserted into the queue.
-		 **/
-		void recordInsertion(const IncomingRTPPktLink& pl);
+        /**
+         * Record the insertion of an RTP packet from this
+         * source into the scheduled reception queue. All
+         * received packets should be registered with
+         * recordReception(), but only those actually inserted
+         * into the queue should be registered via this
+         * method.
+         *
+         * @param pl Link structure for packet inserted into the queue.
+         **/
+        void recordInsertion(const IncomingRTPPktLink& pl);
 
-		void initStats();
+        void initStats();
 
-		/**
-		 * Compute cumulative packet lost and fraction of
-		 * packets lost during the last reporting interval.
-		 **/
-		void computeStats();
+        /**
+         * Compute cumulative packet lost and fraction of
+         * packets lost during the last reporting interval.
+         **/
+        void computeStats();
 
-		MembershipBookkeeping* membership;
-		// The source this link object refers to.
-		SyncSource* source;
-		// first/last packets from this source in the queue.
-		IncomingRTPPktLink* first, * last;
-		// Links for synchronization sources located before
-		// and after this one in the list of sources.
-		SyncSourceLink* prev, * next;
-		// Prev and next inside the hash table collision list.
-		SyncSourceLink* nextCollis;
-		ConflictingTransportAddress* prevConflict;
-		unsigned char* senderInfo;
-		unsigned char* receiverInfo;
-		// time the last RTP packet from this source was
-		// received at.
-		timeval lastPacketTime;
-		// time the last RTCP packet was received.
-		timeval lastRTCPPacketTime;
-		// time the lasrt RTCP SR was received. Required for
-		// DLSR computation.
-		timeval lastRTCPSRTime;
+        MembershipBookkeeping* membership;
+        // The source this link object refers to.
+        SyncSource* source;
+        // first/last packets from this source in the queue.
+        IncomingRTPPktLink* first, * last;
+        // Links for synchronization sources located before
+        // and after this one in the list of sources.
+        SyncSourceLink* prev, * next;
+        // Prev and next inside the hash table collision list.
+        SyncSourceLink* nextCollis;
+        ConflictingTransportAddress* prevConflict;
+        unsigned char* senderInfo;
+        unsigned char* receiverInfo;
+        // time the last RTP packet from this source was
+        // received at.
+        timeval lastPacketTime;
+        // time the last RTCP packet was received.
+        timeval lastRTCPPacketTime;
+        // time the lasrt RTCP SR was received. Required for
+        // DLSR computation.
+        timeval lastRTCPSRTime;
 
-		// for outgoing RR reports.
-		// number of packets received from this source.
-		uint32 obsPacketCount;
-		// number of octets received from this source.
-		uint32 obsOctetCount;
-		// the higher sequence number seen from this source
-		uint16 maxSeqNum;
-		uint32 extendedMaxSeqNum;
-		uint32 cumulativePacketLost;
-		uint8 fractionLost;
-		// for interarrivel jitter computation
-		uint32 lastPacketTransitTime;
-		// interarrival jitter of packets from this source.
-		float jitter;
-		uint32 initialDataTimestamp;
-		timeval initialDataTime;
+        // for outgoing RR reports.
+        // number of packets received from this source.
+        uint32 obsPacketCount;
+        // number of octets received from this source.
+        uint32 obsOctetCount;
+        // the higher sequence number seen from this source
+        uint16 maxSeqNum;
+        uint32 extendedMaxSeqNum;
+        uint32 cumulativePacketLost;
+        uint8 fractionLost;
+        // for interarrivel jitter computation
+        uint32 lastPacketTransitTime;
+        // interarrival jitter of packets from this source.
+        float jitter;
+        uint32 initialDataTimestamp;
+        timeval initialDataTime;
 
-		// this flag assures we only call one gotHello and one
-		// gotGoodbye for this src.
-		bool flag;
+        // this flag assures we only call one gotHello and one
+        // gotGoodbye for this src.
+        bool flag;
 
-		// for source validation:
-		uint32 badSeqNum;
-		uint8 probation;  // packets in sequence before valid.
-		uint16 baseSeqNum;
-		uint32 expectedPrior;
-		uint32 receivedPrior;
-		uint32 seqNumAccum;
-	};
+        // for source validation:
+        uint32 badSeqNum;
+        uint8 probation;  // packets in sequence before valid.
+        uint16 baseSeqNum;
+        uint32 expectedPrior;
+        uint32 receivedPrior;
+        uint32 seqNumAccum;
+    };
 
-	/**
-	 * Returns whether there is already a synchronizacion source
-	 * with "ssrc" SSRC identifier.
-	 **/
-	bool
-	isRegistered(uint32 ssrc);
+    /**
+     * Returns whether there is already a synchronizacion source
+     * with "ssrc" SSRC identifier.
+     **/
+    bool
+    isRegistered(uint32 ssrc);
 
-	/**
-	 * Get the description of a source by its <code>ssrc</code> identifier.
-	 *
-	 * @param ssrc SSRC identifier, in host order.
-	 * @param created whether a new source has been created.
-	 * @return Pointer to the SyncSource object identified by
-	 * <code>ssrc</code>.
-	 */
-	SyncSourceLink*
-	getSourceBySSRC(uint32 ssrc, bool& created);
+    /**
+     * Get the description of a source by its <code>ssrc</code> identifier.
+     *
+     * @param ssrc SSRC identifier, in host order.
+     * @param created whether a new source has been created.
+     * @return Pointer to the SyncSource object identified by
+     * <code>ssrc</code>.
+     */
+    SyncSourceLink*
+    getSourceBySSRC(uint32 ssrc, bool& created);
 
-	/**
-	 * Mark the source identified by <code>ssrc</code> as having
-	 * sent a BYE packet. It is not deleted until a timeout
-	 * expires, so that in case some packets from this source
-	 * arrive a bit later the source is not inserted again in the
-	 * table of known sources.
-	 *
-	 * @return true if the source had been previously identified.
-	 * false if it was not in the table of known sources.
-	 **/
-	bool
-	BYESource(uint32 ssrc);
+    /**
+     * Mark the source identified by <code>ssrc</code> as having
+     * sent a BYE packet. It is not deleted until a timeout
+     * expires, so that in case some packets from this source
+     * arrive a bit later the source is not inserted again in the
+     * table of known sources.
+     *
+     * @return true if the source had been previously identified.
+     * false if it was not in the table of known sources.
+     **/
+    bool
+    BYESource(uint32 ssrc);
 
-	/**
-	 * Remove the description of the source identified by
-	 * <code>ssrc</code>
-	 *
-	 * @return whether the source has been actually removed or it
-	 * did not exist.
-	 */
-	bool
-	removeSource(uint32 ssrc);
+    /**
+     * Remove the description of the source identified by
+     * <code>ssrc</code>
+     *
+     * @return whether the source has been actually removed or it
+     * did not exist.
+     */
+    bool
+    removeSource(uint32 ssrc);
 
-	inline SyncSourceLink* getFirst()
-	{ return first; }
+    inline SyncSourceLink* getFirst()
+    { return first; }
 
-	inline SyncSourceLink* getLast()
-	{ return last; }
+    inline SyncSourceLink* getLast()
+    { return last; }
 
-	inline uint32
-	getMembersCount()
-	{ return Members::getMembersCount(); }
+    inline uint32
+    getMembersCount()
+    { return Members::getMembersCount(); }
 
-	inline void
-	setMembersCount(uint32 n)
-	{ Members::setMembersCount(n); }
+    inline void
+    setMembersCount(uint32 n)
+    { Members::setMembersCount(n); }
 
-	inline uint32
-	getSendersCount()
-	{ return Members::getSendersCount(); }
+    inline uint32
+    getSendersCount()
+    { return Members::getSendersCount(); }
 
-	static const size_t defaultMembersHashSize;
-	static const uint32 SEQNUMMOD;
+    static const size_t defaultMembersHashSize;
+    static const uint32 SEQNUMMOD;
 
 private:
-	MembershipBookkeeping(const MembershipBookkeeping &o);
+    MembershipBookkeeping(const MembershipBookkeeping &o);
 
-	MembershipBookkeeping&
-	operator=(const MembershipBookkeeping &o);
+    MembershipBookkeeping&
+    operator=(const MembershipBookkeeping &o);
 
-	/**
-	 * Purge all RTPSource structures, the hash table and the list
-	 * of sources.
-	 **/
-	void
-	endMembers();
+    /**
+     * Purge all RTPSource structures, the hash table and the list
+     * of sources.
+     **/
+    void
+    endMembers();
 
-	// Hash table with sources of RTP and RTCP packets
-	uint32 sourceBucketsNum;
-	SyncSourceLink** sourceLinks;
-	// List of sources, ordered from older to newer
-	SyncSourceLink* first, * last;
+    // Hash table with sources of RTP and RTCP packets
+    uint32 sourceBucketsNum;
+    SyncSourceLink** sourceLinks;
+    // List of sources, ordered from older to newer
+    SyncSourceLink* first, * last;
 };
 
 /**
@@ -881,166 +879,166 @@
  * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT IncomingDataQueue: public IncomingDataQueueBase,
-	protected MembershipBookkeeping
+    protected MembershipBookkeeping
 {
 public:
-	/**
-	 * @class SyncSourcesIterator
-	 * @short iterator through the list of synchronizations
-	 * sources in this session
-	 **/
-	class SyncSourcesIterator
-	{
-	public:
-		typedef std::forward_iterator_tag iterator_category;
-		typedef SyncSource value_type;
-		typedef ptrdiff_t difference_type;
-		typedef const SyncSource* pointer;
-		typedef const SyncSource& reference;
+    /**
+     * @class SyncSourcesIterator
+     * @short iterator through the list of synchronizations
+     * sources in this session
+     **/
+    class SyncSourcesIterator
+    {
+    public:
+        typedef std::forward_iterator_tag iterator_category;
+        typedef SyncSource value_type;
+        typedef std::ptrdiff_t difference_type;
+        typedef const SyncSource* pointer;
+        typedef const SyncSource& reference;
 
-		SyncSourcesIterator(SyncSourceLink* l = NULL) :
-			link(l)
-		{ }
+        SyncSourcesIterator(SyncSourceLink* l = NULL) :
+            link(l)
+        { }
 
-		SyncSourcesIterator(const SyncSourcesIterator& si) :
-			link(si.link)
-		{ }
+        SyncSourcesIterator(const SyncSourcesIterator& si) :
+            link(si.link)
+        { }
 
-		reference operator*() const
-		{ return *(link->getSource()); }
+        reference operator*() const
+        { return *(link->getSource()); }
 
-		pointer operator->() const
-		{ return link->getSource(); }
+        pointer operator->() const
+        { return link->getSource(); }
 
-		SyncSourcesIterator& operator++() {
-			link = link->getNext();
-			return *this;
-		}
+        SyncSourcesIterator& operator++() {
+            link = link->getNext();
+            return *this;
+        }
 
-		SyncSourcesIterator operator++(int) {
-			SyncSourcesIterator result(*this);
-			++(*this);
-			return result;
-		}
+        SyncSourcesIterator operator++(int) {
+            SyncSourcesIterator result(*this);
+            ++(*this);
+            return result;
+        }
 
-		friend bool operator==(const SyncSourcesIterator& l,
-				       const SyncSourcesIterator& r)
-		{ return l.link == r.link; }
+        friend bool operator==(const SyncSourcesIterator& l,
+                       const SyncSourcesIterator& r)
+        { return l.link == r.link; }
 
-		friend bool operator!=(const SyncSourcesIterator& l,
-				       const SyncSourcesIterator& r)
-		{ return l.link != r.link; }
+        friend bool operator!=(const SyncSourcesIterator& l,
+                       const SyncSourcesIterator& r)
+        { return l.link != r.link; }
 
-	private:
-		SyncSourceLink *link;
-	};
+    private:
+        SyncSourceLink *link;
+    };
 
-	SyncSourcesIterator begin()
-	{ return SyncSourcesIterator(MembershipBookkeeping::getFirst()); }
+    SyncSourcesIterator begin()
+    { return SyncSourcesIterator(MembershipBookkeeping::getFirst()); }
 
-	SyncSourcesIterator end()
-	{ return SyncSourcesIterator(NULL); }
+    SyncSourcesIterator end()
+    { return SyncSourcesIterator(NULL); }
 
- 	/**
-	 * Retreive data from a specific timestamped packet if such a
-	 * packet is currently available in the receive buffer. 
-	 *
-	 * @param stamp Data unit timestamp.
-	 * @param src Optional synchronization source selector.
-	 * @return data retrieved from the reception buffer.
-	 * @retval null pointer if no packet with such timestamp is available.
-	 **/
-	const AppDataUnit*
-	getData(uint32 stamp, const SyncSource* src = NULL);
+    /**
+     * Retreive data from a specific timestamped packet if such a
+     * packet is currently available in the receive buffer.
+     *
+     * @param stamp Data unit timestamp.
+     * @param src Optional synchronization source selector.
+     * @return data retrieved from the reception buffer.
+     * @retval null pointer if no packet with such timestamp is available.
+     **/
+    const AppDataUnit*
+    getData(uint32 stamp, const SyncSource* src = NULL);
 
 
- 	/**
- 	 * Determine if packets are waiting in the reception queue.
- 	 *
-	 * @param src Optional synchronization source selector.
- 	 * @return True if packets are waiting.
- 	 */
- 	bool
-	isWaiting(const SyncSource* src = NULL) const;
+    /**
+     * Determine if packets are waiting in the reception queue.
+     *
+     * @param src Optional synchronization source selector.
+     * @return True if packets are waiting.
+     */
+    bool
+    isWaiting(const SyncSource* src = NULL) const;
 
- 	/**
- 	 * Get timestamp of first packet waiting in the queue.
- 	 *
-	 * @param src optional source selector.
- 	 * @return timestamp of first arrival packet.
- 	 **/
- 	uint32
-	getFirstTimestamp(const SyncSource* src = NULL) const;
+    /**
+     * Get timestamp of first packet waiting in the queue.
+     *
+     * @param src optional source selector.
+     * @return timestamp of first arrival packet.
+     **/
+    uint32
+    getFirstTimestamp(const SyncSource* src = NULL) const;
 
-	/**
-	 * When receiving packets from a new source, it may be
-	 * convenient to reject a first few packets before we are
-	 * really sure the source is valid. This method sets how many
-	 * data packets must be received in sequence before the source
-	 * is considered valid and the stack starts to accept its
-	 * packets.
-	 *
-	 * @note the default (see defaultMinValidPacketSequence())
-	 * value for this parameter is 0, so that no packets are
-	 * rejected (data packets are accepted from the first one).
-	 *
-	 * @note this validation is performed after the generic header
-	 * validation and the additional validation done in
-	 * onRTPPacketRecv().
-	 *
-	 * @note if any valid RTCP packet is received from this
-	 * source, it will be immediatly considered valid regardless
-	 * of the number of sequential data packets received.
-	 *
-	 * @param packets number of sequential packet required
-	 **/
-	void
-	setMinValidPacketSequence(uint8 packets)
-	{ minValidPacketSequence = packets; }
+    /**
+     * When receiving packets from a new source, it may be
+     * convenient to reject a first few packets before we are
+     * really sure the source is valid. This method sets how many
+     * data packets must be received in sequence before the source
+     * is considered valid and the stack starts to accept its
+     * packets.
+     *
+     * @note the default (see defaultMinValidPacketSequence())
+     * value for this parameter is 0, so that no packets are
+     * rejected (data packets are accepted from the first one).
+     *
+     * @note this validation is performed after the generic header
+     * validation and the additional validation done in
+     * onRTPPacketRecv().
+     *
+     * @note if any valid RTCP packet is received from this
+     * source, it will be immediatly considered valid regardless
+     * of the number of sequential data packets received.
+     *
+     * @param packets number of sequential packet required
+     **/
+    void
+    setMinValidPacketSequence(uint8 packets)
+    { minValidPacketSequence = packets; }
 
-	uint8
-	getDefaultMinValidPacketSequence() const
-	{ return defaultMinValidPacketSequence; }
+    uint8
+    getDefaultMinValidPacketSequence() const
+    { return defaultMinValidPacketSequence; }
 
-	/**
-	 * Get the minimun number of consecutive packets that must be
-	 * received from a source before accepting its data packets.
-	 **/
-	uint8
-	getMinValidPacketSequence() const
-	{ return minValidPacketSequence; }
+    /**
+     * Get the minimun number of consecutive packets that must be
+     * received from a source before accepting its data packets.
+     **/
+    uint8
+    getMinValidPacketSequence() const
+    { return minValidPacketSequence; }
 
-	void
-	setMaxPacketMisorder(uint16 packets)
-	{ maxPacketMisorder = packets; }
+    void
+    setMaxPacketMisorder(uint16 packets)
+    { maxPacketMisorder = packets; }
 
-	uint16
-	getDefaultMaxPacketMisorder() const
-	{ return defaultMaxPacketMisorder; }
+    uint16
+    getDefaultMaxPacketMisorder() const
+    { return defaultMaxPacketMisorder; }
 
-	uint16
-	getMaxPacketMisorder() const
-	{ return maxPacketMisorder; }
+    uint16
+    getMaxPacketMisorder() const
+    { return maxPacketMisorder; }
 
-	/**
-	 *
-	 * It also prevents packets sent after a restart of the source
-	 * being immediately accepted.
-	 **/
-	void
-	setMaxPacketDropout(uint16 packets) // default: 3000.
-	{ maxPacketDropout = packets; }
+    /**
+     *
+     * It also prevents packets sent after a restart of the source
+     * being immediately accepted.
+     **/
+    void
+    setMaxPacketDropout(uint16 packets) // default: 3000.
+    { maxPacketDropout = packets; }
 
-	uint16
-	getDefaultMaxPacketDropout() const
-	{ return defaultMaxPacketDropout; }
+    uint16
+    getDefaultMaxPacketDropout() const
+    { return defaultMaxPacketDropout; }
 
-	uint16
-	getMaxPacketDropout() const
-	{ return maxPacketDropout; }
+    uint16
+    getMaxPacketDropout() const
+    { return maxPacketDropout; }
 
-	// default value for constructors that allow to specify
-	// members table s\ize
+    // default value for constructors that allow to specify
+    // members table s\ize
         inline static size_t
         getDefaultMembersSize()
         { return defaultMembersSize; }
@@ -1080,142 +1078,142 @@
         getInQueueCryptoContext(uint32 ssrc);
 
 protected:
-	/**
-	 * @param size initial size of the membership table.
-	 **/
-	IncomingDataQueue(uint32 size);
+    /**
+     * @param size initial size of the membership table.
+     **/
+    IncomingDataQueue(uint32 size);
 
-	virtual ~IncomingDataQueue()
-	{ }
+    virtual ~IncomingDataQueue()
+    { }
 
-	/**
-	 * Apply collision and loop detection and correction algorithm
-	 * when receiving RTP data packets. Follows section 8.2 in
-	 * draft-ietf-avt-rtp-new.
-	 *
-	 * @param sourceLink link to the source object.
-	 * @param is_new whether the source has been just recorded.
-	 * @param na data packet network address.
-	 * @param tp data packet source transport port.
-	 *
-	 * @return whether the packet must not be discarded.
-	 **/
-	bool checkSSRCInIncomingRTPPkt(SyncSourceLink& sourceLink,
-				       bool is_new, InetAddress& na,
-				       tpport_t tp);
+    /**
+     * Apply collision and loop detection and correction algorithm
+     * when receiving RTP data packets. Follows section 8.2 in
+     * draft-ietf-avt-rtp-new.
+     *
+     * @param sourceLink link to the source object.
+     * @param is_new whether the source has been just recorded.
+     * @param na data packet network address.
+     * @param tp data packet source transport port.
+     *
+     * @return whether the packet must not be discarded.
+     **/
+    bool checkSSRCInIncomingRTPPkt(SyncSourceLink& sourceLink,
+                       bool is_new, InetAddress& na,
+                       tpport_t tp);
 
-	/**
-	 * Set the number of RTCP intervals that the stack will wait
-	 * to change the state of a source from stateActive to
-	 * stateInactive, or to delete the source after being in
-	 * stateInactive.
-	 *
-	 * Note that this value should be uniform accross all
-	 * participants and SHOULD be fixed for a particular profile.
-	 *
-	 * @param intervals number of RTCP report intervals
-	 *
-	 * @note If RTCP is not being used, the RTCP interval is
-	 * assumed to be the default: 5 seconds.
-	 * @note The default for this value is, as RECOMMENDED, 5.
-	 **/
-	void setSourceExpirationPeriod(uint8 intervals)
-	{ sourceExpirationPeriod = intervals; }
+    /**
+     * Set the number of RTCP intervals that the stack will wait
+     * to change the state of a source from stateActive to
+     * stateInactive, or to delete the source after being in
+     * stateInactive.
+     *
+     * Note that this value should be uniform accross all
+     * participants and SHOULD be fixed for a particular profile.
+     *
+     * @param intervals number of RTCP report intervals
+     *
+     * @note If RTCP is not being used, the RTCP interval is
+     * assumed to be the default: 5 seconds.
+     * @note The default for this value is, as RECOMMENDED, 5.
+     **/
+    void setSourceExpirationPeriod(uint8 intervals)
+    { sourceExpirationPeriod = intervals; }
 
-	/**
-	 * This function is used by the service thread to process
-	 * the next incoming packet and place it in the receive list.
-	 *
-	 * @return number of payload bytes received.  <0 if error.
-	 */
-	virtual size_t
-	takeInDataPacket();
+    /**
+     * This function is used by the service thread to process
+     * the next incoming packet and place it in the receive list.
+     *
+     * @return number of payload bytes received.  <0 if error.
+     */
+    virtual size_t
+    takeInDataPacket();
 
-	void renewLocalSSRC();
+    void renewLocalSSRC();
 
-	/**
-	 * This is used to fetch a packet in the receive queue and to
-	 * expire packets older than the current timestamp.
-	 *
-	 * @return packet buffer object for current timestamp if found.
-	 * @param timestamp timestamp requested.
-	 * @param src optional source selector
-	 * @note if found, the packet is removed from the reception queue
-	 **/
-	IncomingDataQueue::IncomingRTPPktLink*
-	getWaiting(uint32 timestamp, const SyncSource *src = NULL);
+    /**
+     * This is used to fetch a packet in the receive queue and to
+     * expire packets older than the current timestamp.
+     *
+     * @return packet buffer object for current timestamp if found.
+     * @param timestamp timestamp requested.
+     * @param src optional source selector
+     * @note if found, the packet is removed from the reception queue
+     **/
+    IncomingDataQueue::IncomingRTPPktLink*
+    getWaiting(uint32 timestamp, const SyncSource *src = NULL);
 
-	/**
-	 * Log reception of a new RTP packet from this source. Usually
-	 * updates data such as the packet counter, the expected
-	 * sequence number for the next packet and the time the last
-	 * packet was received at.
-	 *
-	 * @param srcLink Link structure for the synchronization
-	 * source of this packet.
-	 * @param pkt Packet just created and to be logged.
-	 * @param recvtime Reception time.
-	 *
-	 * @return whether, according to the source state and
-	 * statistics, the packet is considered valid and must be
-	 * inserted in the incoming packets queue.
-	 **/
-	bool
-	recordReception(SyncSourceLink& srcLink, const IncomingRTPPkt& pkt,
-			const timeval recvtime);
+    /**
+     * Log reception of a new RTP packet from this source. Usually
+     * updates data such as the packet counter, the expected
+     * sequence number for the next packet and the time the last
+     * packet was received at.
+     *
+     * @param srcLink Link structure for the synchronization
+     * source of this packet.
+     * @param pkt Packet just created and to be logged.
+     * @param recvtime Reception time.
+     *
+     * @return whether, according to the source state and
+     * statistics, the packet is considered valid and must be
+     * inserted in the incoming packets queue.
+     **/
+    bool
+    recordReception(SyncSourceLink& srcLink, const IncomingRTPPkt& pkt,
+            const timeval recvtime);
 
-	/**
-	 * Log extraction of a packet from this source from the
-	 * scheduled reception queue.
-	 *
-	 * @param pkt Packet extracted from the queue.
-	 **/
-	void
-	recordExtraction(const IncomingRTPPkt& pkt);
+    /**
+     * Log extraction of a packet from this source from the
+     * scheduled reception queue.
+     *
+     * @param pkt Packet extracted from the queue.
+     **/
+    void
+    recordExtraction(const IncomingRTPPkt& pkt);
 
-	void purgeIncomingQueue();
+    void purgeIncomingQueue();
 
-	/**
-	 * Virtual called when a new synchronization source has joined
-	 * the session.
-	 *
-	 * @param - new synchronization source
-	 **/
-	inline virtual void
-	onNewSyncSource(const SyncSource&)
-	{ }
+    /**
+     * Virtual called when a new synchronization source has joined
+     * the session.
+     *
+     * @param - new synchronization source
+     **/
+    inline virtual void
+    onNewSyncSource(const SyncSource&)
+    { }
 
 protected:
-	/**
-	 * A virtual function to support parsing of arriving packets
-	 * to determine if they should be kept in the queue and to
-	 * dispatch events.
-	 *
-	 * A generic header validity check (as specified in RFC 1889)
-	 * is performed on every incoming packet. If the generic check
-	 * completes succesfully, this method is called before the
-	 * packet is actually inserted into the reception queue.
-	 *
-	 * May be used to perform additional validity checks or to do
-	 * some application specific processing.
-	 *
-	 * @param - packet just received.
-	 * @return true if packet is kept in the incoming packets queue.
-	 **/
-	inline virtual bool
-	onRTPPacketRecv(IncomingRTPPkt&)
-	{ return true; }
+    /**
+     * A virtual function to support parsing of arriving packets
+     * to determine if they should be kept in the queue and to
+     * dispatch events.
+     *
+     * A generic header validity check (as specified in RFC 1889)
+     * is performed on every incoming packet. If the generic check
+     * completes succesfully, this method is called before the
+     * packet is actually inserted into the reception queue.
+     *
+     * May be used to perform additional validity checks or to do
+     * some application specific processing.
+     *
+     * @param - packet just received.
+     * @return true if packet is kept in the incoming packets queue.
+     **/
+    inline virtual bool
+    onRTPPacketRecv(IncomingRTPPkt&)
+    { return true; }
 
-	/**
-	 * A hook to filter packets in the receive queue that are being
-	 * expired. This hook may be used to do some application
-	 * specific processing on expired packets before they are
-	 * deleted.
-	 *
-	 * @param - packet expired from the recv queue.
-	 **/
-	inline virtual void onExpireRecv(IncomingRTPPkt&)
-	{ return; }
+    /**
+     * A hook to filter packets in the receive queue that are being
+     * expired. This hook may be used to do some application
+     * specific processing on expired packets before they are
+     * deleted.
+     *
+     * @param - packet expired from the recv queue.
+     **/
+    inline virtual void onExpireRecv(IncomingRTPPkt&)
+    { return; }
 
         /**
          * A hook that gets called if the decoding of an incoming SRTP was erroneous
@@ -1235,66 +1233,64 @@
         { return false; }
 
         inline virtual bool
-	end2EndDelayed(IncomingRTPPktLink&)
-	{ return false; }
+    end2EndDelayed(IncomingRTPPktLink&)
+    { return false; }
 
-       	/**
-	 * Insert a just received packet in the queue (both general
-	 * and source specific queues). If the packet was already in
-	 * the queue (same SSRC and sequence number), it is not
-	 * inserted but deleted.
-	 *
-	 * @param packetLink link to a packet just received and
-	 * generally validated and processed by onRTPPacketRecv.
-	 *
-	 * @return whether the packet was successfully inserted.
-	 * @retval false when the packet is duplicated (there is
-	 * already a packet from the same source with the same
-	 * timestamp).
-	 * @retval true when the packet is not duplicated.
-	 **/
-	bool
-	insertRecvPacket(IncomingRTPPktLink* packetLink);
+        /**
+     * Insert a just received packet in the queue (both general
+     * and source specific queues). If the packet was already in
+     * the queue (same SSRC and sequence number), it is not
+     * inserted but deleted.
+     *
+     * @param packetLink link to a packet just received and
+     * generally validated and processed by onRTPPacketRecv.
+     *
+     * @return whether the packet was successfully inserted.
+     * @retval false when the packet is duplicated (there is
+     * already a packet from the same source with the same
+     * timestamp).
+     * @retval true when the packet is not duplicated.
+     **/
+    bool
+    insertRecvPacket(IncomingRTPPktLink* packetLink);
 
-	/**
-	 * This function performs the physical I/O for reading a
-	 * packet from the source.  It is a virtual that is
-	 * overriden in the derived class.
-	 *
-	 * @return number of bytes read.
-	 * @param buffer of read packet.
-	 * @param length of data to read.
-	 * @param host address of source.
-	 * @param port number of source.
-	 **/
-	virtual size_t
-	recvData(unsigned char* buffer, size_t length,
-		 InetHostAddress& host, tpport_t& port) = 0;
+    /**
+     * This function performs the physical I/O for reading a
+     * packet from the source.  It is a virtual that is
+     * overriden in the derived class.
+     *
+     * @return number of bytes read.
+     * @param buffer of read packet.
+     * @param length of data to read.
+     * @param host address of source.
+     * @param port number of source.
+     **/
+    virtual size_t
+    recvData(unsigned char* buffer, size_t length,
+         InetHostAddress& host, tpport_t& port) = 0;
 
-	virtual size_t
-	getNextDataPacketSize() const = 0;
+    virtual size_t
+    getNextDataPacketSize() const = 0;
 
-	mutable ThreadLock recvLock;
-	// reception queue
-	IncomingRTPPktLink* recvFirst, * recvLast;
-	// values for packet validation.
-	static const uint8 defaultMinValidPacketSequence;
-	static const uint16 defaultMaxPacketMisorder;
-	static const uint16 defaultMaxPacketDropout;
-	uint8 minValidPacketSequence;
-	uint16 maxPacketMisorder;
-	uint16 maxPacketDropout;
-	static const size_t defaultMembersSize;
-	uint8 sourceExpirationPeriod;
-	mutable Mutex cryptoMutex;
+    mutable ThreadLock recvLock;
+    // reception queue
+    IncomingRTPPktLink* recvFirst, * recvLast;
+    // values for packet validation.
+    static const uint8 defaultMinValidPacketSequence;
+    static const uint16 defaultMaxPacketMisorder;
+    static const uint16 defaultMaxPacketDropout;
+    uint8 minValidPacketSequence;
+    uint16 maxPacketMisorder;
+    uint16 maxPacketDropout;
+    static const size_t defaultMembersSize;
+    uint8 sourceExpirationPeriod;
+    mutable Mutex cryptoMutex;
         std::list<CryptoContext *> cryptoContexts;
 };
 
 /** @}*/ // iqueue
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  //CCXX_RTP_IQUEUE_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/oqueue.h b/jni/libccrtp/sources/src/ccrtp/oqueue.h
index 3d9bbbc..8048dba 100644
--- a/jni/libccrtp/sources/src/ccrtp/oqueue.h
+++ b/jni/libccrtp/sources/src/ccrtp/oqueue.h
@@ -41,16 +41,14 @@
  * @short Generic RTP output queues.
  **/
 
-#ifndef	CCXX_RTP_OQUEUE_H_
+#ifndef CCXX_RTP_OQUEUE_H_
 #define CCXX_RTP_OQUEUE_H_
 
 #include <ccrtp/queuebase.h>
 #include <ccrtp/CryptoContext.h>
 #include <list>
 
-#ifdef	CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @defgroup oqueue Generic RTP output queues.
@@ -68,72 +66,72 @@
 class __EXPORT DestinationListHandler
 {
 protected:
-	struct TransportAddress;
-	std::list<TransportAddress*> destList;
+    struct TransportAddress;
+    std::list<TransportAddress*> destList;
 
 public:
-	DestinationListHandler();
+    DestinationListHandler();
 
-	~DestinationListHandler();
+    ~DestinationListHandler();
 
-	/**
-	 * Get whether there is only a destination in the list.
-	 **/
-	inline bool isSingleDestination() const
-	{ return (1 == destList.size()); }
+    /**
+     * Get whether there is only a destination in the list.
+     **/
+    inline bool isSingleDestination() const
+    { return (1 == destList.size()); }
 
-	inline TransportAddress* getFirstDestination() const
-	{ return destList.front(); }
+    inline TransportAddress* getFirstDestination() const
+    { return destList.front(); }
 
-	inline void lockDestinationList() const
-	{ destinationLock.readLock(); }
+    inline void lockDestinationList() const
+    { destinationLock.readLock(); }
 
-	inline void unlockDestinationList() const
-	{ destinationLock.unlock(); }
+    inline void unlockDestinationList() const
+    { destinationLock.unlock(); }
 
 protected:
-	inline void writeLockDestinationList() const
-	{ destinationLock.writeLock(); }
+    inline void writeLockDestinationList() const
+    { destinationLock.writeLock(); }
 
-	/**
-	 * Locks the object before modifying it.
-	 **/
-	bool
-	addDestinationToList(const InetAddress& ia, tpport_t data,
-			     tpport_t control);
+    /**
+     * Locks the object before modifying it.
+     **/
+    bool
+    addDestinationToList(const InetAddress& ia, tpport_t data,
+                 tpport_t control);
 
-	/**
-	 * Locks the object before modifying it.
-	 **/
-	bool removeDestinationFromList(const InetAddress& ia,
-				       tpport_t dataPort,
-				       tpport_t controlPort);
+    /**
+     * Locks the object before modifying it.
+     **/
+    bool removeDestinationFromList(const InetAddress& ia,
+                       tpport_t dataPort,
+                       tpport_t controlPort);
 
-	struct TransportAddress
-	{
-		TransportAddress(InetAddress na, tpport_t dtp, tpport_t ctp) :
-			networkAddress(na), dataTransportPort(dtp),
-			controlTransportPort(ctp)
-		{  }
+    struct TransportAddress
+    {
+        TransportAddress(InetAddress na, tpport_t dtp, tpport_t ctp) :
+            networkAddress(na), dataTransportPort(dtp),
+            controlTransportPort(ctp)
+        {  }
 
-		inline const InetAddress& getNetworkAddress() const
-		{ return networkAddress; }
+        inline const InetAddress& getNetworkAddress() const
+        { return networkAddress; }
 
-		inline tpport_t getDataTransportPort() const
-		{ return dataTransportPort; }
+        inline tpport_t getDataTransportPort() const
+        { return dataTransportPort; }
 
-		inline tpport_t getControlTransportPort() const
-		{ return controlTransportPort; }
+        inline tpport_t getControlTransportPort() const
+        { return controlTransportPort; }
 
-		InetAddress networkAddress;
-		tpport_t dataTransportPort, controlTransportPort;
-	};
+        InetAddress networkAddress;
+        tpport_t dataTransportPort, controlTransportPort;
+    };
 
 private:
-	mutable ThreadLock destinationLock;
+    mutable ThreadLock destinationLock;
 };
 
-#ifdef	CCXX_IPV6
+#ifdef  CCXX_IPV6
 /**
  * @class DestinationListHandler
  *
@@ -145,69 +143,69 @@
 class __EXPORT DestinationListHandlerIPV6
 {
 protected:
-	struct TransportAddressIPV6;
-	std::list<TransportAddressIPV6*> destListIPV6;
+    struct TransportAddressIPV6;
+    std::list<TransportAddressIPV6*> destListIPV6;
 
 public:
-	DestinationListHandlerIPV6();
+    DestinationListHandlerIPV6();
 
-	~DestinationListHandlerIPV6();
+    ~DestinationListHandlerIPV6();
 
-	/**
-	 * Get whether there is only a destination in the list.
-	 **/
-	inline bool isSingleDestinationIPV6() const
-	{ return (1 == destListIPV6.size()); }
+    /**
+     * Get whether there is only a destination in the list.
+     **/
+    inline bool isSingleDestinationIPV6() const
+    { return (1 == destListIPV6.size()); }
 
-	inline TransportAddressIPV6* getFirstDestinationIPV6() const
-	{ return destListIPV6.front(); }
+    inline TransportAddressIPV6* getFirstDestinationIPV6() const
+    { return destListIPV6.front(); }
 
-	inline void lockDestinationListIPV6() const
-	{ destinationLock.readLock(); }
+    inline void lockDestinationListIPV6() const
+    { destinationLock.readLock(); }
 
-	inline void unlockDestinationListIPV6() const
-	{ destinationLock.unlock(); }
+    inline void unlockDestinationListIPV6() const
+    { destinationLock.unlock(); }
 
 protected:
-	inline void writeLockDestinationListIPV6() const
-	{ destinationLock.writeLock(); }
+    inline void writeLockDestinationListIPV6() const
+    { destinationLock.writeLock(); }
 
-	/**
-	 * Locks the object before modifying it.
-	 **/
-	bool
-	addDestinationToListIPV6(const IPV6Address& ia, tpport_t data,
-			     tpport_t control);
+    /**
+     * Locks the object before modifying it.
+     **/
+    bool
+    addDestinationToListIPV6(const IPV6Address& ia, tpport_t data,
+                 tpport_t control);
 
-	/**
-	 * Locks the object before modifying it.
-	 **/
-	bool removeDestinationFromListIPV6(const IPV6Address& ia,
-				       tpport_t dataPort,
-				       tpport_t controlPort);
+    /**
+     * Locks the object before modifying it.
+     **/
+    bool removeDestinationFromListIPV6(const IPV6Address& ia,
+                       tpport_t dataPort,
+                       tpport_t controlPort);
 
-	struct TransportAddressIPV6
-	{
-		TransportAddressIPV6(IPV6Address na, tpport_t dtp, tpport_t ctp) :
-			networkAddress(na), dataTransportPort(dtp),
-			controlTransportPort(ctp)
-		{  }
+    struct TransportAddressIPV6
+    {
+        TransportAddressIPV6(IPV6Address na, tpport_t dtp, tpport_t ctp) :
+            networkAddress(na), dataTransportPort(dtp),
+            controlTransportPort(ctp)
+        {  }
 
-		inline const IPV6Address& getNetworkAddress() const
-		{ return networkAddress; }
+        inline const IPV6Address& getNetworkAddress() const
+        { return networkAddress; }
 
-		inline tpport_t getDataTransportPort() const
-		{ return dataTransportPort; }
+        inline tpport_t getDataTransportPort() const
+        { return dataTransportPort; }
 
-		inline tpport_t getControlTransportPort() const
-		{ return controlTransportPort; }
+        inline tpport_t getControlTransportPort() const
+        { return controlTransportPort; }
 
-		IPV6Address networkAddress;
-		tpport_t dataTransportPort, controlTransportPort;
-	};
+        IPV6Address networkAddress;
+        tpport_t dataTransportPort, controlTransportPort;
+    };
 
 private:
-	mutable ThreadLock destinationLock;
+    mutable ThreadLock destinationLock;
 };
 
 #endif
@@ -220,83 +218,83 @@
  * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT OutgoingDataQueue:
-	public OutgoingDataQueueBase,
-#ifdef	CCXX_IPV6
-	protected DestinationListHandlerIPV6,
+    public OutgoingDataQueueBase,
+#ifdef  CCXX_IPV6
+    protected DestinationListHandlerIPV6,
 #endif
-	protected DestinationListHandler
+    protected DestinationListHandler
 {
 public:
-#ifdef	CCXX_IPV6
-	bool
-	addDestination(const IPV6Address& ia,
-		       tpport_t dataPort = DefaultRTPDataPort,
-		       tpport_t controlPort = 0);
+#ifdef  CCXX_IPV6
+    bool
+    addDestination(const IPV6Address& ia,
+               tpport_t dataPort = DefaultRTPDataPort,
+               tpport_t controlPort = 0);
 
-	bool
-	forgetDestination(const IPV6Address& ia,
-			  tpport_t dataPort = DefaultRTPDataPort,
-			  tpport_t controlPort = 0);
+    bool
+    forgetDestination(const IPV6Address& ia,
+              tpport_t dataPort = DefaultRTPDataPort,
+              tpport_t controlPort = 0);
 
 #endif
 
-	bool
-	addDestination(const InetHostAddress& ia,
-		       tpport_t dataPort = DefaultRTPDataPort,
-		       tpport_t controlPort = 0);
+    bool
+    addDestination(const InetHostAddress& ia,
+               tpport_t dataPort = DefaultRTPDataPort,
+               tpport_t controlPort = 0);
 
-	bool
-	addDestination(const InetMcastAddress& ia,
-		       tpport_t dataPort = DefaultRTPDataPort,
-		       tpport_t controlPort = 0);
+    bool
+    addDestination(const InetMcastAddress& ia,
+               tpport_t dataPort = DefaultRTPDataPort,
+               tpport_t controlPort = 0);
 
-	bool
-	forgetDestination(const InetHostAddress& ia,
-			  tpport_t dataPort = DefaultRTPDataPort,
-			  tpport_t controlPort = 0);
+    bool
+    forgetDestination(const InetHostAddress& ia,
+              tpport_t dataPort = DefaultRTPDataPort,
+              tpport_t controlPort = 0);
 
-	bool
-	forgetDestination(const InetMcastAddress& ia,
-			  tpport_t dataPort = DefaultRTPDataPort,
-			  tpport_t controlPort = 0);
+    bool
+    forgetDestination(const InetMcastAddress& ia,
+              tpport_t dataPort = DefaultRTPDataPort,
+              tpport_t controlPort = 0);
 
-	/**
-	 * Add csrc as the CSRC identifier of a new contributor. This
-	 * method adds the CSRC identifier to a list of contributors
-	 * that will be inserted in every packet enqueued from now on.
-	 **/
-	void
-	addContributor(uint32 csrc);
+    /**
+     * Add csrc as the CSRC identifier of a new contributor. This
+     * method adds the CSRC identifier to a list of contributors
+     * that will be inserted in every packet enqueued from now on.
+     **/
+    void
+    addContributor(uint32 csrc);
 
-	/**
-	 * Remove CSRC from the list of contributors.
-	 **/
-	bool
-	removeContributor(uint32 csrc);
+    /**
+     * Remove CSRC from the list of contributors.
+     **/
+    bool
+    removeContributor(uint32 csrc);
 
- 	/**
- 	 * Determine if outgoing packets are waiting to send.
- 	 *
- 	 * @return true if there are packets waiting to be send.
- 	 */
- 	bool
-	isSending() const;
+    /**
+     * Determine if outgoing packets are waiting to send.
+     *
+     * @return true if there are packets waiting to be send.
+     */
+    bool
+    isSending() const;
 
 
-	/**
-	 * This is used to create a data packet in the send queue.
-	 * Sometimes a "NULL" or empty packet will be used instead, and
-	 * these are known as "silent" packets.  "Silent" packets are
-	 * used simply to "push" the scheduler along more accurately
-	 * by giving the appearence that a next packet is waiting to
-	 * be sent and to provide a valid timestamp for that packet.
-	 *
-	 * @param stamp Timestamp for expected send time of packet.
-	 * @param data Value or NULL if special "silent" packet.
-	 * @param len May be 0 to indicate a default by payload type.
-	 **/
-	void
-	putData(uint32 stamp, const unsigned char* data = NULL, size_t len = 0);
+    /**
+     * This is used to create a data packet in the send queue.
+     * Sometimes a "NULL" or empty packet will be used instead, and
+     * these are known as "silent" packets.  "Silent" packets are
+     * used simply to "push" the scheduler along more accurately
+     * by giving the appearence that a next packet is waiting to
+     * be sent and to provide a valid timestamp for that packet.
+     *
+     * @param stamp Timestamp for expected send time of packet.
+     * @param data Value or NULL if special "silent" packet.
+     * @param len May be 0 to indicate a default by payload type.
+     **/
+    void
+    putData(uint32 stamp, const unsigned char* data = NULL, size_t len = 0);
 
         /**
          * This is used to create a data packet and send it immediately.
@@ -314,94 +312,94 @@
         sendImmediate(uint32 stamp, const unsigned char* data = NULL, size_t len = 0);
 
 
-	/**
-	 * Set padding. All outgoing packets will be transparently
-	 * padded to a multiple of paddinglen.
-	 *
-	 * @param paddinglen pad packets to a length multiple of paddinglen.
-	 **/
-	void setPadding(uint8 paddinglen)
-	{ sendInfo.paddinglen = paddinglen; }
+    /**
+     * Set padding. All outgoing packets will be transparently
+     * padded to a multiple of paddinglen.
+     *
+     * @param paddinglen pad packets to a length multiple of paddinglen.
+     **/
+    void setPadding(uint8 paddinglen)
+    { sendInfo.paddinglen = paddinglen; }
 
-	/**
-	 * Set marker bit for the packet in which the next data
-	 * provided will be send. When transmitting audio, should be
-	 * set for the first packet of a talk spurt. When transmitting
-	 * video, should be set for the last packet for a video frame.
-	 *
-	 * @param mark Marker bit value for next packet.
-	 **/
-	void setMark(bool mark)
-	{ sendInfo.marked = mark; }
+    /**
+     * Set marker bit for the packet in which the next data
+     * provided will be send. When transmitting audio, should be
+     * set for the first packet of a talk spurt. When transmitting
+     * video, should be set for the last packet for a video frame.
+     *
+     * @param mark Marker bit value for next packet.
+     **/
+    void setMark(bool mark)
+    { sendInfo.marked = mark; }
 
-	/**
-	 * Get wheter the mark bit will be set in the next packet.
-	 **/
-	inline bool getMark() const
-	{ return sendInfo.marked; }
+    /**
+     * Get wheter the mark bit will be set in the next packet.
+     **/
+    inline bool getMark() const
+    { return sendInfo.marked; }
 
-	/**
-	 * Set partial data for an already queued packet.  This is often
-	 * used for multichannel data.
-	 *
-	 * @param timestamp Timestamp of packet.
-	 * @param data Buffer to copy from.
-	 * @param offset Offset to copy from.
-	 * @param max Maximum data size.
-	 * @return Number of packet data bytes set.
-	 **/
-	size_t
-	setPartial(uint32 timestamp, unsigned char* data, size_t offset, size_t max);
+    /**
+     * Set partial data for an already queued packet.  This is often
+     * used for multichannel data.
+     *
+     * @param timestamp Timestamp of packet.
+     * @param data Buffer to copy from.
+     * @param offset Offset to copy from.
+     * @param max Maximum data size.
+     * @return Number of packet data bytes set.
+     **/
+    size_t
+    setPartial(uint32 timestamp, unsigned char* data, size_t offset, size_t max);
 
-	inline microtimeout_t
-	getDefaultSchedulingTimeout() const
-	{ return defaultSchedulingTimeout; }
+    inline microtimeout_t
+    getDefaultSchedulingTimeout() const
+    { return defaultSchedulingTimeout; }
 
-	/**
-	 * Set the default scheduling timeout to use when no data
-	 * packets are waiting to be sent.
-	 *
-	 * @param to timeout in milliseconds.
-	 **/
-	inline void
-	setSchedulingTimeout(microtimeout_t to)
-	{ schedulingTimeout = to; }
+    /**
+     * Set the default scheduling timeout to use when no data
+     * packets are waiting to be sent.
+     *
+     * @param to timeout in milliseconds.
+     **/
+    inline void
+    setSchedulingTimeout(microtimeout_t to)
+    { schedulingTimeout = to; }
 
-	inline microtimeout_t
-	getDefaultExpireTimeout() const
-	{ return defaultExpireTimeout; }
+    inline microtimeout_t
+    getDefaultExpireTimeout() const
+    { return defaultExpireTimeout; }
 
-	/**
-	 * Set the "expired" timer for expiring packets pending in
-	 * the send queue which have gone unsent and are already
-	 * "too late" to be sent now.
-	 *
-	 * @param to timeout to expire unsent packets in milliseconds.
-	 **/
-	inline void
-	setExpireTimeout(microtimeout_t to)
-	{ expireTimeout = to; }
+    /**
+     * Set the "expired" timer for expiring packets pending in
+     * the send queue which have gone unsent and are already
+     * "too late" to be sent now.
+     *
+     * @param to timeout to expire unsent packets in milliseconds.
+     **/
+    inline void
+    setExpireTimeout(microtimeout_t to)
+    { expireTimeout = to; }
 
-	inline microtimeout_t getExpireTimeout() const
-	{ return expireTimeout; }
+    inline microtimeout_t getExpireTimeout() const
+    { return expireTimeout; }
 
-	/**
-	 * Get the total number of packets sent so far
-	 *
-	 * @return total number of packets sent
-	 */
-	inline uint32
-	getSendPacketCount() const
-	{ return sendInfo.packetCount; }
+    /**
+     * Get the total number of packets sent so far
+     *
+     * @return total number of packets sent
+     */
+    inline uint32
+    getSendPacketCount() const
+    { return sendInfo.packetCount; }
 
-	/**
-	 * Get the total number of octets (payload only) sent so far.
-	 *
-	 * @return total number of payload octets sent in RTP packets.
-	 **/
-	inline uint32
-	getSendOctetCount() const
-	{ return sendInfo.octetCount; }
+    /**
+     * Get the total number of octets (payload only) sent so far.
+     *
+     * @return total number of payload octets sent in RTP packets.
+     **/
+    inline uint32
+    getSendOctetCount() const
+    { return sendInfo.octetCount; }
 
         /**
          * Get the sequence number of the next outgoing packet.
@@ -446,189 +444,187 @@
 
 
 protected:
-	OutgoingDataQueue();
+    OutgoingDataQueue();
 
-	virtual ~OutgoingDataQueue()
-	{ }
+    virtual ~OutgoingDataQueue()
+    { }
 
-	struct OutgoingRTPPktLink
-	{
-		OutgoingRTPPktLink(OutgoingRTPPkt* pkt,
-				   OutgoingRTPPktLink* p,
-				   OutgoingRTPPktLink* n) :
-			packet(pkt), prev(p), next(n) { }
+    struct OutgoingRTPPktLink
+    {
+        OutgoingRTPPktLink(OutgoingRTPPkt* pkt,
+                   OutgoingRTPPktLink* p,
+                   OutgoingRTPPktLink* n) :
+            packet(pkt), prev(p), next(n) { }
 
-		~OutgoingRTPPktLink() { delete packet; }
+        ~OutgoingRTPPktLink() { delete packet; }
 
-		inline OutgoingRTPPkt* getPacket() { return packet; }
+        inline OutgoingRTPPkt* getPacket() { return packet; }
 
-		inline void setPacket(OutgoingRTPPkt* pkt) { packet = pkt; }
+        inline void setPacket(OutgoingRTPPkt* pkt) { packet = pkt; }
 
-		inline OutgoingRTPPktLink* getPrev() { return prev; }
+        inline OutgoingRTPPktLink* getPrev() { return prev; }
 
-		inline void setPrev(OutgoingRTPPktLink* p) { prev = p; }
+        inline void setPrev(OutgoingRTPPktLink* p) { prev = p; }
 
-		inline OutgoingRTPPktLink* getNext() { return next; }
+        inline OutgoingRTPPktLink* getNext() { return next; }
 
-		inline void setNext(OutgoingRTPPktLink* n) { next = n; }
+        inline void setNext(OutgoingRTPPktLink* n) { next = n; }
 
-		// the packet this link refers to.
-		OutgoingRTPPkt* packet;
-		// global outgoing packets queue.
-		OutgoingRTPPktLink * prev, * next;
-	};
+        // the packet this link refers to.
+        OutgoingRTPPkt* packet;
+        // global outgoing packets queue.
+        OutgoingRTPPktLink * prev, * next;
+    };
 
-	/**
-	 * This is used to write the RTP data packet to one or more
-	 * destinations.  It is used by both sendImmediate and by
-	 * dispatchDataPacket.
-	 *
-	 * @param RTP packet to send.
-	 */
-	void
-	dispatchImmediate(OutgoingRTPPkt *packet);
+    /**
+     * This is used to write the RTP data packet to one or more
+     * destinations.  It is used by both sendImmediate and by
+     * dispatchDataPacket.
+     *
+     * @param RTP packet to send.
+     */
+    void
+    dispatchImmediate(OutgoingRTPPkt *packet);
 
-	/**
-	 * This computes the timeout period for scheduling transmission
-	 * of the next packet at the "head" of the send buffer.  If no
-	 * packets are waiting, a default timeout is used.  This actually
-	 * forms the "isPending()" timeout of the rtp receiver in the
-	 * service thread.
-	 *
-	 * @return timeout until next packet is scheduled to send.
-	 **/
-	microtimeout_t
-	getSchedulingTimeout();
+    /**
+     * This computes the timeout period for scheduling transmission
+     * of the next packet at the "head" of the send buffer.  If no
+     * packets are waiting, a default timeout is used.  This actually
+     * forms the "isPending()" timeout of the rtp receiver in the
+     * service thread.
+     *
+     * @return timeout until next packet is scheduled to send.
+     **/
+    microtimeout_t
+    getSchedulingTimeout();
 
-	/**
-	 * This function is used by the service thread to process
-	 * the next outgoing packet pending in the sending queue.
-	 *
-	 * @return number of bytes sent.  0 if silent, <0 if error.
-	 **/
-	size_t
-	dispatchDataPacket();
+    /**
+     * This function is used by the service thread to process
+     * the next outgoing packet pending in the sending queue.
+     *
+     * @return number of bytes sent.  0 if silent, <0 if error.
+     **/
+    size_t
+    dispatchDataPacket();
 
-	/**
-	 * For thoses cases in which the application requires a method
-	 * to set the sequence number for the outgoing stream (such as
-	 * for implementing the RTSP PLAY command).
-	 *
-	 * @param seqNum next sequence number to be used for outgoing packets.
-	 *
-	 **/
-	inline void
-	setNextSeqNum(uint32 seqNum)
-	{ sendInfo.sendSeq = seqNum; }
+    /**
+     * For thoses cases in which the application requires a method
+     * to set the sequence number for the outgoing stream (such as
+     * for implementing the RTSP PLAY command).
+     *
+     * @param seqNum next sequence number to be used for outgoing packets.
+     *
+     **/
+    inline void
+    setNextSeqNum(uint32 seqNum)
+    { sendInfo.sendSeq = seqNum; }
 
-	inline uint32
-	getCurrentSeqNum(void)
-	{ return sendInfo.sendSeq; }
+    inline uint32
+    getCurrentSeqNum(void)
+    { return sendInfo.sendSeq; }
 
-	/**
-	 */
-	inline void
-	setInitialTimestamp(uint32 ts)
-	{ initialTimestamp = ts; }
+    /**
+     */
+    inline void
+    setInitialTimestamp(uint32 ts)
+    { initialTimestamp = ts; }
 
-	/**
-	 */
-	inline uint32
-	getInitialTimestamp()
-	{ return initialTimestamp; }
+    /**
+     */
+    inline uint32
+    getInitialTimestamp()
+    { return initialTimestamp; }
 
-	void purgeOutgoingQueue();
+    void purgeOutgoingQueue();
 
         virtual void
         setControlPeer(const InetAddress &host, tpport_t port) {}
 
-#ifdef	CCXX_IPV6
-	virtual void
-	setControlPeerIPV6(const IPV6Address &host, tpport_t port) {}
+#ifdef  CCXX_IPV6
+    virtual void
+    setControlPeerIPV6(const IPV6Address &host, tpport_t port) {}
 #endif
 
         // The crypto contexts for outgoing SRTP sessions.
-	mutable Mutex cryptoMutex;
+    mutable Mutex cryptoMutex;
         std::list<CryptoContext *> cryptoContexts;
 
 private:
         /**
-	 * A hook to filter packets being sent that have been expired.
-	 *
-	 * @param - expired packet from the send queue.
-	 **/
-	inline virtual void onExpireSend(OutgoingRTPPkt&)
-	{ }
+     * A hook to filter packets being sent that have been expired.
+     *
+     * @param - expired packet from the send queue.
+     **/
+    inline virtual void onExpireSend(OutgoingRTPPkt&)
+    { }
 
-	virtual void
+    virtual void
         setDataPeer(const InetAddress &host, tpport_t port) {}
 
-#ifdef	CCXX_IPV6
-	virtual void
-	setDataPeerIPV6(const IPV6Address &host, tpport_t port) {}
+#ifdef  CCXX_IPV6
+    virtual void
+    setDataPeerIPV6(const IPV6Address &host, tpport_t port) {}
 #endif
 
-	/**
-	 * This function performs the physical I/O for writing a
-	 * packet to the destination.  It is a virtual that is
-	 * overriden in the derived class.
-	 *
-	 * @param buffer Pointer to data to write.
-	 * @param len Length of data to write.
-	 * @return number of bytes sent.
-	 **/
-	virtual size_t
-	sendData(const unsigned char* const buffer, size_t len) {return 0;}
+    /**
+     * This function performs the physical I/O for writing a
+     * packet to the destination.  It is a virtual that is
+     * overriden in the derived class.
+     *
+     * @param buffer Pointer to data to write.
+     * @param len Length of data to write.
+     * @return number of bytes sent.
+     **/
+    virtual size_t
+    sendData(const unsigned char* const buffer, size_t len) {return 0;}
 
-#ifdef	CCXX_IPV6
-	virtual size_t
-	sendDataIPV6(const unsigned char* const buffer, size_t len) {return 0;}
+#ifdef  CCXX_IPV6
+    virtual size_t
+    sendDataIPV6(const unsigned char* const buffer, size_t len) {return 0;}
 #endif
 
-	static const microtimeout_t defaultSchedulingTimeout;
-	static const microtimeout_t defaultExpireTimeout;
-	mutable ThreadLock sendLock;
-	// outgoing data packets queue
-	OutgoingRTPPktLink* sendFirst, * sendLast;
-	uint32 initialTimestamp;
-	// transmission scheduling timeout for the service thread
-	microtimeout_t schedulingTimeout;
-	// how old a packet can reach in the sending queue before deletetion
-	microtimeout_t expireTimeout;
+    static const microtimeout_t defaultSchedulingTimeout;
+    static const microtimeout_t defaultExpireTimeout;
+    mutable ThreadLock sendLock;
+    // outgoing data packets queue
+    OutgoingRTPPktLink* sendFirst, * sendLast;
+    uint32 initialTimestamp;
+    // transmission scheduling timeout for the service thread
+    microtimeout_t schedulingTimeout;
+    // how old a packet can reach in the sending queue before deletetion
+    microtimeout_t expireTimeout;
 
 
-	struct {
-		// number of packets sent from the beginning
-		uint32 packetCount;
-		// number of payload octets sent from the beginning
-		uint32 octetCount;
-		// the sequence number of the next packet to sent
-		uint16 sendSeq;
-		// contributing sources
-		uint32 sendSources[16];
-		// how many CSRCs to send.
-		uint16 sendCC;
-		// pad packets to a paddinglen multiple
-		uint8 paddinglen;
-		// This flags tells whether to set the bit M in the
-		// RTP fixed header of the packet in which the next
-		// provided data will be sent.
-		bool marked;
-		// whether there was not loss.
-		bool complete;
-		// ramdonly generated offset for the timestamp of sent packets
-		uint32 initialTimestamp;
-		// elapsed time accumulated through successive overflows of
-		// the local timestamp field
-		timeval overflowTime;
-	} sendInfo;
+    struct {
+        // number of packets sent from the beginning
+        uint32 packetCount;
+        // number of payload octets sent from the beginning
+        uint32 octetCount;
+        // the sequence number of the next packet to sent
+        uint16 sendSeq;
+        // contributing sources
+        uint32 sendSources[16];
+        // how many CSRCs to send.
+        uint16 sendCC;
+        // pad packets to a paddinglen multiple
+        uint8 paddinglen;
+        // This flags tells whether to set the bit M in the
+        // RTP fixed header of the packet in which the next
+        // provided data will be sent.
+        bool marked;
+        // whether there was not loss.
+        bool complete;
+        // ramdonly generated offset for the timestamp of sent packets
+        uint32 initialTimestamp;
+        // elapsed time accumulated through successive overflows of
+        // the local timestamp field
+        timeval overflowTime;
+    } sendInfo;
 };
 
 /** @}*/ // oqueue
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  //CCXX_RTP_OQUEUE_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/pool.h b/jni/libccrtp/sources/src/ccrtp/pool.h
index 54b6bc3..9f241ad 100644
--- a/jni/libccrtp/sources/src/ccrtp/pool.h
+++ b/jni/libccrtp/sources/src/ccrtp/pool.h
@@ -1,27 +1,27 @@
 // Copyright (C) 2001,2002,2006 Federico Montesino Pouzols <fedemp@altern.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 
+// along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// 
+//
 // As a special exception, you may use this file as part of a free software
 // library without restriction.  Specifically, if other files instantiate
 // templates or use macros or inline functions from this file, or you compile
 // this file and link it with other files to produce an executable, this
 // file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however    
+// the GNU General Public License.  This exception does not however
 // invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.    
+// the GNU General Public License.
 //
 // This exception applies only to the code released under the name GNU
 // ccRTP.  If you copy code from other releases into a copy of GNU
@@ -46,43 +46,41 @@
 #include <list>
 #include <ccrtp/rtp.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
+NAMESPACE_COMMONCPP
 using std::list;
-#endif
 
 typedef TRTPSessionBase<> RTPSessionBase;
 
 class RTPSessionBaseHandler
 {
 public:
-	inline microtimeout_t getSchedulingTimeout(RTPSessionBase& s)
-	{ return s.getSchedulingTimeout(); }
+    inline microtimeout_t getSchedulingTimeout(RTPSessionBase& s)
+    { return s.getSchedulingTimeout(); }
 
-	inline timeval getRTCPCheckInterval(RTPSessionBase& s)
-	{ return s.getRTCPCheckInterval(); }
+    inline timeval getRTCPCheckInterval(RTPSessionBase& s)
+    { return s.getRTCPCheckInterval(); }
 
-	size_t
-	takeInDataPacket(RTPSessionBase& s)
-	{ return s.takeInDataPacket(); }
-	
-	size_t
-	dispatchDataPacket(RTPSessionBase& s)
-	{ return s.dispatchDataPacket(); }
-	
-	void
-	controlReceptionService(RTPSessionBase& s)
-	{ s.controlReceptionService(); }
-	
-	void
-	controlTransmissionService(RTPSessionBase& s)
-	{ s.controlTransmissionService(); }
-	
-	inline SOCKET getDataRecvSocket(RTPSessionBase& s) const
-	{ return s.getDataRecvSocket(); }
-	
-	inline SOCKET getControlRecvSocket(RTPSessionBase& s) const
-	{ return s.getControlRecvSocket(); }
+    size_t
+    takeInDataPacket(RTPSessionBase& s)
+    { return s.takeInDataPacket(); }
+
+    size_t
+    dispatchDataPacket(RTPSessionBase& s)
+    { return s.dispatchDataPacket(); }
+
+    void
+    controlReceptionService(RTPSessionBase& s)
+    { s.controlReceptionService(); }
+
+    void
+    controlTransmissionService(RTPSessionBase& s)
+    { s.controlTransmissionService(); }
+
+    inline SOCKET getDataRecvSocket(RTPSessionBase& s) const
+    { return s.getDataRecvSocket(); }
+
+    inline SOCKET getControlRecvSocket(RTPSessionBase& s) const
+    { return s.getControlRecvSocket(); }
 };
 
 /**
@@ -94,33 +92,33 @@
 
 class SessionListElement {
 private:
-	RTPSessionBase* elem;
-	bool cleared;
+    RTPSessionBase* elem;
+    bool cleared;
 
 public:
-	SessionListElement(RTPSessionBase* e);
-	void clear();
-	bool isCleared();
-	RTPSessionBase* get();
+    SessionListElement(RTPSessionBase* e);
+    void clear();
+    bool isCleared();
+    RTPSessionBase* get();
 };
 
 
-inline SessionListElement::SessionListElement(RTPSessionBase* e) 
-	: elem(e), cleared(false) { 
+inline SessionListElement::SessionListElement(RTPSessionBase* e)
+    : elem(e), cleared(false) {
 }
 
 inline void SessionListElement::clear() {
-	cleared = true;
-	delete elem;
-	elem = 0;
+    cleared = true;
+    delete elem;
+    elem = 0;
 }
 
 inline bool SessionListElement::isCleared() {
-	return cleared;
+    return cleared;
 }
 
 inline RTPSessionBase* SessionListElement::get() {
-	return elem;
+    return elem;
 }
 
 /**
@@ -137,7 +135,7 @@
 
     bool operator() (SessionListElement* e)
     {
-	    return e->get() == elem;
+        return e->get() == elem;
     }
 };
 
@@ -157,84 +155,82 @@
 class __EXPORT RTPSessionPool: public RTPSessionBaseHandler
 {
 public:
-	RTPSessionPool();
+    RTPSessionPool();
 
-	inline virtual ~RTPSessionPool()
-	{ }
+    inline virtual ~RTPSessionPool()
+    { }
 
-	bool
-	addSession(RTPSessionBase& session);
+    bool
+    addSession(RTPSessionBase& session);
 
-	bool 
-	removeSession(RTPSessionBase& session);
+    bool
+    removeSession(RTPSessionBase& session);
 
-	size_t
-	getPoolLength() const;
+    size_t
+    getPoolLength() const;
 
-	virtual void startRunning() = 0;
+    virtual void startRunning() = 0;
 
-	inline bool isActive()
-	{ return poolActive; }
+    inline bool isActive()
+    { return poolActive; }
 
 protected:
-	inline void setActive()
-	{ poolActive = true; }
-	
-	inline timeval getPoolTimeout()
-	{ return poolTimeout; }
+    inline void setActive()
+    { poolActive = true; }
 
-	inline void setPoolTimeout(int sec, int usec)
-	{ poolTimeout.tv_sec = sec; poolTimeout.tv_usec = usec; }
+    inline timeval getPoolTimeout()
+    { return poolTimeout; }
 
-	inline void setPoolTimeout(struct timeval to)
-	{ poolTimeout = to; }
+    inline void setPoolTimeout(int sec, int usec)
+    { poolTimeout.tv_sec = sec; poolTimeout.tv_usec = usec; }
 
-	std::list<SessionListElement*> sessionList;
-	typedef std::list<SessionListElement*>::iterator PoolIterator;
+    inline void setPoolTimeout(struct timeval to)
+    { poolTimeout = to; }
 
-	mutable ThreadLock poolLock;
+    std::list<SessionListElement*> sessionList;
+    typedef std::list<SessionListElement*>::iterator PoolIterator;
 
-#ifndef WIN32
-	fd_set recvSocketSet;
-	SOCKET highestSocket;  // highest socket number + 1
+    mutable ThreadLock poolLock;
+
+#ifndef _MSWINDOWS_
+    fd_set recvSocketSet;
+    SOCKET highestSocket;  // highest socket number + 1
 #endif
 
 private:
-	timeval poolTimeout;
-	mutable bool poolActive;
+    timeval poolTimeout;
+    mutable bool poolActive;
 };
 
 
-class __EXPORT SingleRTPSessionPool : 
-		public RTPSessionPool,
-		public Thread
+class __EXPORT SingleRTPSessionPool :
+        public RTPSessionPool,
+        public Thread
 {
 public:
-	/**
-	 * @param pri optional thread priority value.
-	 **/
-	SingleRTPSessionPool(int pri = 0) : 
-		RTPSessionPool(),
-		Thread(pri)
-	{ }
-	
-	~SingleRTPSessionPool()
-	{ }
+    /**
+     * @param pri optional thread priority value.
+     **/
+    SingleRTPSessionPool(int pri = 0) :
+        RTPSessionPool(),
+        Thread(pri)
+    { }
 
-	void startRunning()
-	{ setActive(); Thread::start(); }
+    ~SingleRTPSessionPool()
+    { }
+
+    void startRunning()
+    { setActive(); Thread::start(); }
 
 protected:
-	/**
-	 * Runnable method for the thread. This thread serves all the
-	 * RTP sessions.added to this pool.
-	 */
-	void run();
+    /**
+     * Runnable method for the thread. This thread serves all the
+     * RTP sessions.added to this pool.
+     */
+    void run();
 };
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif //CCXX_RTP_POOL_H
 
diff --git a/jni/libccrtp/sources/src/ccrtp/queuebase.h b/jni/libccrtp/sources/src/ccrtp/queuebase.h
index 9c2611b..a80482b 100644
--- a/jni/libccrtp/sources/src/ccrtp/queuebase.h
+++ b/jni/libccrtp/sources/src/ccrtp/queuebase.h
@@ -1,27 +1,27 @@
 // Copyright (C) 2001,2002,2004 Federico Montesino Pouzols <fedemp@altern.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 
+// along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// 
+//
 // As a special exception, you may use this file as part of a free software
 // library without restriction.  Specifically, if other files instantiate
 // templates or use macros or inline functions from this file, or you compile
 // this file and link it with other files to produce an executable, this
 // file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however    
+// the GNU General Public License.  This exception does not however
 // invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.    
+// the GNU General Public License.
 //
 // This exception applies only to the code released under the name GNU
 // ccRTP.  If you copy code from other releases into a copy of GNU
@@ -35,128 +35,126 @@
 // If you do not wish that, delete this exception notice.
 //
 
-/** 
- * @file queuebase.h 
+/**
+ * @file queuebase.h
  *
  * @short Base classes for RTP queues.
  **/
 
-#ifndef	CCXX_RTP_QUEUEBASE_H_
+#ifndef CCXX_RTP_QUEUEBASE_H_
 #define CCXX_RTP_QUEUEBASE_H_
 
-#include <cc++/pointer.h>
+#include <commoncpp/pointer.h>
 #include <ccrtp/rtppkt.h>
 #include <ccrtp/sources.h>
 
-#ifdef	CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @defgroup queuebase Base classes for RTP queues.
  * @{
  **/
 
-/** 
+/**
  * @class AppDataUnit
- * @short Interface (envelope) to data received over RTP packets.  
+ * @short Interface (envelope) to data received over RTP packets.
  *
  * A class of objects representing data transmitted over RTP packets.
  * Tipically, this object will apply to received data. Data blocks
  * received via RTP connections as well as its related objects
  * (source, etc), are accessed through the methods of this class.
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT AppDataUnit
-{		
+{
 public:
-	AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src);
-		
-	inline ~AppDataUnit()
-	{ }
-		
-	/**
-	 * @param src the AppDataUnit object being copied
-	 */
-	AppDataUnit(const AppDataUnit& src);
-		
-	/**
-	 * Assignment operator
-	 * 
-	 * @param source the AppDataUnit object being assigned @return
-	 * the result of the assignment
-	 */
-	AppDataUnit&
-	operator=(const AppDataUnit& source);
-		
-	/**
-	 * @return type of this data
-	 */
-	inline PayloadType
-	getType() const
-	{ return datablock->getPayloadType(); }
+    AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src);
 
-	/**
-	 *  Get data as it is received in RTP packets (i.e. for
-	 *  multi-octet encodings, octets are in network
-	 *  order.
-	 *
-	 * @return Raw pointer to data block.
-	 **/
-	inline const uint8* const
-	getData() const
-	{ return datablock->getPayload(); }
-		
-	/**
-	 * @return length of data in octets
-	 **/
-	size_t
-	getSize() const
-	{ return datablock->getPayloadSize(); }
+    inline ~AppDataUnit()
+    { }
 
-	/**
-	 * @return Source that sent this data
-	 */
-	inline const SyncSource&
-	getSource() const
-	{ return *source; }
+    /**
+     * @param src the AppDataUnit object being copied
+     */
+    AppDataUnit(const AppDataUnit& src);
 
-	/**
-	 * Is this data unit marked?.
-	 *
-	 * @return true if marked.
-	 **/
-	inline bool 
-	isMarked() const
-	{ return datablock->isMarked(); }
+    /**
+     * Assignment operator
+     *
+     * @param source the AppDataUnit object being assigned @return
+     * the result of the assignment
+     */
+    AppDataUnit&
+    operator=(const AppDataUnit& source);
 
-	/**
-	 * Get data unit sequence number.
-	 **/
-	inline uint16
-	getSeqNum() const
-	{ return datablock->getSeqNum(); }
+    /**
+     * @return type of this data
+     */
+    inline PayloadType
+    getType() const
+    { return datablock->getPayloadType(); }
 
-	/**
-	 * Get the number of contributing sources in the CSRC list.
-	 **/
-	inline uint8
-	getContributorsCount() const
-	{ return (uint8)datablock->getCSRCsCount(); }
+    /**
+     *  Get data as it is received in RTP packets (i.e. for
+     *  multi-octet encodings, octets are in network
+     *  order.
+     *
+     * @return Raw pointer to data block.
+     **/
+    inline const uint8* const
+    getData() const
+    { return datablock->getPayload(); }
 
-	/**
-	 * Get the array of 32-bit CSRC identifiers.
-	 *
-	 * @return NULL if (getContributorsCount() == 0)
-	 **/
-	inline const uint32*
-	getContributorsID() const
-	{ return datablock->getCSRCs(); }
+    /**
+     * @return length of data in octets
+     **/
+    size_t
+    getSize() const
+    { return datablock->getPayloadSize(); }
+
+    /**
+     * @return Source that sent this data
+     */
+    inline const SyncSource&
+    getSource() const
+    { return *source; }
+
+    /**
+     * Is this data unit marked?.
+     *
+     * @return true if marked.
+     **/
+    inline bool
+    isMarked() const
+    { return datablock->isMarked(); }
+
+    /**
+     * Get data unit sequence number.
+     **/
+    inline uint16
+    getSeqNum() const
+    { return datablock->getSeqNum(); }
+
+    /**
+     * Get the number of contributing sources in the CSRC list.
+     **/
+    inline uint8
+    getContributorsCount() const
+    { return (uint8)datablock->getCSRCsCount(); }
+
+    /**
+     * Get the array of 32-bit CSRC identifiers.
+     *
+     * @return NULL if (getContributorsCount() == 0)
+     **/
+    inline const uint32*
+    getContributorsID() const
+    { return datablock->getCSRCs(); }
 
 private:
-	Pointer<const IncomingRTPPkt> datablock;
-	const SyncSource* source;
+    Pointer<const IncomingRTPPkt> datablock;
+    const SyncSource* source;
 };
 
 /**
@@ -164,180 +162,178 @@
  *
  * A virtual base class for RTP queue hierarchies.
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT RTPQueueBase
 {
 public:
-	/**
-	 * Set the payload format in use, for timing and payload type
-	 * identification purposes.
-	 *
-	 * @param pf payload format to use from now on.
-	 * @return whether the payload format has been successfully set.
-	 **/
-	inline bool
-	setPayloadFormat(const PayloadFormat& pf)
-	{ 
-		currentPayloadType = pf.getPayloadType();
-		currentRTPClockRate = pf.getRTPClockRate();
-		return true;
-	}
+    /**
+     * Set the payload format in use, for timing and payload type
+     * identification purposes.
+     *
+     * @param pf payload format to use from now on.
+     * @return whether the payload format has been successfully set.
+     **/
+    inline bool
+    setPayloadFormat(const PayloadFormat& pf)
+    {
+        currentPayloadType = pf.getPayloadType();
+        currentRTPClockRate = pf.getRTPClockRate();
+        return true;
+    }
 
-	inline uint32 getLocalSSRC() const
-	{ return localSSRC; }
+    inline uint32 getLocalSSRC() const
+    { return localSSRC; }
 
-	/**
-	 * Get the clock rate in RTP clock units (for instance, 8000
-	 * units per second for PCMU, or 90000 units per second for
-	 * MP2T). This value depends on what payload format has been
-	 * selected using setPayloadFormat().
-	 *
-	 * @return clock rate in RTP clock units.
-	 **/
-	inline uint32 getCurrentRTPClockRate() const
-	{ return currentRTPClockRate; }
+    /**
+     * Get the clock rate in RTP clock units (for instance, 8000
+     * units per second for PCMU, or 90000 units per second for
+     * MP2T). This value depends on what payload format has been
+     * selected using setPayloadFormat().
+     *
+     * @return clock rate in RTP clock units.
+     **/
+    inline uint32 getCurrentRTPClockRate() const
+    { return currentRTPClockRate; }
 
-	inline PayloadType getCurrentPayloadType() const
-	{ return currentPayloadType; }
+    inline PayloadType getCurrentPayloadType() const
+    { return currentPayloadType; }
 
-	inline timeval getInitialTime() const
-	{ return initialTime; }
+    inline timeval getInitialTime() const
+    { return initialTime; }
 
 protected:
-	/**
-	 * @param ssrc If not null, the local SSRC identifier for this
-	 * session.
-	 **/
-	RTPQueueBase(uint32 *ssrc = NULL);
+    /**
+     * @param ssrc If not null, the local SSRC identifier for this
+     * session.
+     **/
+    RTPQueueBase(uint32 *ssrc = NULL);
 
-	inline void setLocalSSRC(uint32 ssrc)
-	{ localSSRC = ssrc; localSSRCNetwork = htonl(ssrc); }
+    inline void setLocalSSRC(uint32 ssrc)
+    { localSSRC = ssrc; localSSRCNetwork = htonl(ssrc); }
 
-	inline uint32 getLocalSSRCNetwork() const
-	{ return localSSRCNetwork; }
+    inline uint32 getLocalSSRCNetwork() const
+    { return localSSRCNetwork; }
 
-	virtual 
-	~RTPQueueBase()
-	{ }
+    virtual
+    ~RTPQueueBase()
+    { }
 
-	/**
-	 * A plugin point for posting of BYE messages.
-	 *
-	 * @param - reason to leave the RTP session.
-	 * @return number of octets sent.
-	 **/
-	inline virtual size_t
-	dispatchBYE(const std::string&)
-	{ return 0; }
+    /**
+     * A plugin point for posting of BYE messages.
+     *
+     * @param - reason to leave the RTP session.
+     * @return number of octets sent.
+     **/
+    inline virtual size_t
+    dispatchBYE(const std::string&)
+    { return 0; }
 
-	inline virtual void
-	renewLocalSSRC()
-	{ }
+    inline virtual void
+    renewLocalSSRC()
+    { }
 
 private:
-	// local SSRC 32-bit identifier
-	uint32 localSSRC;
-	// SSRC in network byte order
-	uint32 localSSRCNetwork;
-	// RTP clock rate for the current payload type.
-	uint32 currentRTPClockRate;
-	// Current payload type set for outgoing packets and expected
-	// from incoming packets.
-	PayloadType currentPayloadType;
-	// when the queue is created
-	timeval initialTime;
+    // local SSRC 32-bit identifier
+    uint32 localSSRC;
+    // SSRC in network byte order
+    uint32 localSSRCNetwork;
+    // RTP clock rate for the current payload type.
+    uint32 currentRTPClockRate;
+    // Current payload type set for outgoing packets and expected
+    // from incoming packets.
+    PayloadType currentPayloadType;
+    // when the queue is created
+    timeval initialTime;
 };
 
 /**
  * @class OutgoingDataQueueBase
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT OutgoingDataQueueBase:
-	public virtual RTPQueueBase
+    public virtual RTPQueueBase
 {
 public:
-	inline size_t
-	getDefaultMaxSendSegmentSize()
-	{ return defaultMaxSendSegmentSize;}
+    inline size_t
+    getDefaultMaxSendSegmentSize()
+    { return defaultMaxSendSegmentSize;}
 
-	/**
-	 * Set maximum payload segment size before fragmenting sends.
-	 *
-	 * @param size Maximum payload size.
-	 * @return Whether segment size was successfully set.
-	 **/
-	inline void
-	setMaxSendSegmentSize(size_t size)
-	{ maxSendSegmentSize = size; }
+    /**
+     * Set maximum payload segment size before fragmenting sends.
+     *
+     * @param size Maximum payload size.
+     * @return Whether segment size was successfully set.
+     **/
+    inline void
+    setMaxSendSegmentSize(size_t size)
+    { maxSendSegmentSize = size; }
 
-	inline size_t
-	getMaxSendSegmentSize()
-	{ return maxSendSegmentSize; }
+    inline size_t
+    getMaxSendSegmentSize()
+    { return maxSendSegmentSize; }
 
 protected:
-	OutgoingDataQueueBase();
+    OutgoingDataQueueBase();
 
-	inline virtual
-	~OutgoingDataQueueBase()
-	{ }
+    inline virtual
+    ~OutgoingDataQueueBase()
+    { }
 
 private:
-	static const size_t defaultMaxSendSegmentSize;
-	// maximum packet size before fragmenting sends.
-	size_t maxSendSegmentSize;
+    static const size_t defaultMaxSendSegmentSize;
+    // maximum packet size before fragmenting sends.
+    size_t maxSendSegmentSize;
 };
 
 /**
  * @class IncomingDataQueueBase
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT IncomingDataQueueBase:
-	public virtual RTPQueueBase
+    public virtual RTPQueueBase
 {
 public:
-	inline size_t getDefaultMaxRecvPacketSize() const
-	{ return defaultMaxRecvPacketSize; }
+    inline size_t getDefaultMaxRecvPacketSize() const
+    { return defaultMaxRecvPacketSize; }
 
-	inline size_t
-	getMaxRecvPacketSize() const
-	{ return maxRecvPacketSize; }
+    inline size_t
+    getMaxRecvPacketSize() const
+    { return maxRecvPacketSize; }
 
-	/**
-	 * @param maxsize maximum length of received RTP data packets,
-	 * in octets. Defaults to the value returned by
-	 * getDefaultMaxRecvPacketSize().
-	 *
-	 * @note This method sets a filter for incoming
-	 * packets. Setting higher values does not necessarily imply
-	 * higher memory usage (this method does not set any buffer
-	 * size).
-	 **/
-	inline void
-	setMaxRecvPacketSize(size_t maxsize)
-	{ maxRecvPacketSize = maxsize; }
+    /**
+     * @param maxsize maximum length of received RTP data packets,
+     * in octets. Defaults to the value returned by
+     * getDefaultMaxRecvPacketSize().
+     *
+     * @note This method sets a filter for incoming
+     * packets. Setting higher values does not necessarily imply
+     * higher memory usage (this method does not set any buffer
+     * size).
+     **/
+    inline void
+    setMaxRecvPacketSize(size_t maxsize)
+    { maxRecvPacketSize = maxsize; }
 
 protected:
-	IncomingDataQueueBase()
-	{ setMaxRecvPacketSize(getDefaultMaxRecvPacketSize()); }
+    IncomingDataQueueBase()
+    { setMaxRecvPacketSize(getDefaultMaxRecvPacketSize()); }
 
-	inline virtual 
-	~IncomingDataQueueBase()
-	{ }
+    inline virtual
+    ~IncomingDataQueueBase()
+    { }
 
 private:
-	static const size_t defaultMaxRecvPacketSize;
-	// filter value for received packets length.
-	size_t maxRecvPacketSize;
+    static const size_t defaultMaxRecvPacketSize;
+    // filter value for received packets length.
+    size_t maxRecvPacketSize;
 };
 
 /** @}*/ // queuebase
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  //CCXX_RTP_QUEUEBASE_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/rtcppkt.h b/jni/libccrtp/sources/src/ccrtp/rtcppkt.h
index 7213ab6..20e4b96 100644
--- a/jni/libccrtp/sources/src/ccrtp/rtcppkt.h
+++ b/jni/libccrtp/sources/src/ccrtp/rtcppkt.h
@@ -1,27 +1,27 @@
 // Copyright (C) 2001,2002,2004,2007 Federico Montesino Pouzols <fedemp@altern.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 
+// along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// 
+//
 // As a special exception, you may use this file as part of a free software
 // library without restriction.  Specifically, if other files instantiate
 // templates or use macros or inline functions from this file, or you compile
 // this file and link it with other files to produce an executable, this
 // file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however    
+// the GNU General Public License.  This exception does not however
 // invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.    
+// the GNU General Public License.
 //
 // This exception applies only to the code released under the name GNU
 // ccRTP.  If you copy code from other releases into a copy of GNU
@@ -35,17 +35,15 @@
 // If you do not wish that, delete this exception notice.
 //
 
-#ifndef	CCXX_RTP_RTCPPKT_H_
+#ifndef CCXX_RTP_RTCPPKT_H_
 #define CCXX_RTP_RTCPPKT_H_
 
 #include <ccrtp/base.h>
 
-#ifdef CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
-/** 
- * @file rtcppkt.h 
+/**
+ * @file rtcppkt.h
  *
  * @short RTCP packets handling.
  **/
@@ -55,7 +53,7 @@
  * @{
  **/
 
-/** 
+/**
  * @enum SDESItemType
  * @short SDES items that may be carried in a Source DEScription RTCP packet.
  *
@@ -66,17 +64,17 @@
  **/
 typedef enum
 {
-	SDESItemTypeEND = 0,         ///< END of SDES item list.
-	SDESItemTypeCNAME,           ///< Canonical end-point identifier.
-	SDESItemTypeNAME,            ///< Personal NAME of the user.
-	SDESItemTypeEMAIL,           ///< EMAIL address of the user.
-	SDESItemTypePHONE,           ///< Phone number of the user.
-	SDESItemTypeLOC,             ///< Location where the user is.
-	SDESItemTypeTOOL,            ///< Application or tool.
-	SDESItemTypeNOTE,            ///< Comment usually reporting state.
-	SDESItemTypePRIV,            ///< Private extension.
-	SDESItemTypeH323CADDR,       ///< H323 callable address.
-	SDESItemTypeLast = SDESItemTypeH323CADDR ///< Last defined code.
+    SDESItemTypeEND = 0,         ///< END of SDES item list.
+    SDESItemTypeCNAME,           ///< Canonical end-point identifier.
+    SDESItemTypeNAME,            ///< Personal NAME of the user.
+    SDESItemTypeEMAIL,           ///< EMAIL address of the user.
+    SDESItemTypePHONE,           ///< Phone number of the user.
+    SDESItemTypeLOC,             ///< Location where the user is.
+    SDESItemTypeTOOL,            ///< Application or tool.
+    SDESItemTypeNOTE,            ///< Comment usually reporting state.
+    SDESItemTypePRIV,            ///< Private extension.
+    SDESItemTypeH323CADDR,       ///< H323 callable address.
+    SDESItemTypeLast = SDESItemTypeH323CADDR ///< Last defined code.
 }       SDESItemType;
 
 /**
@@ -87,420 +85,420 @@
  * Intended to be used, through inheritance, in RTCP management
  * classes, such as QueueRTCPManager.
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
-class __EXPORT RTCPCompoundHandler 
+class __EXPORT RTCPCompoundHandler
 {
 public:
-	inline void setPathMTU(uint16 mtu)
-	{ pathMTU = mtu; }
+    inline void setPathMTU(uint16 mtu)
+    { pathMTU = mtu; }
 
-	inline uint16 getPathMTU()
-	{ return pathMTU; }
+    inline uint16 getPathMTU()
+    { return pathMTU; }
 
-#ifdef	CCXX_PACKED
-#pragma pack(1)	
+#ifdef  CCXX_PACKED
+#pragma pack(1)
 #endif
-	/**
-	 * @struct ReceiverInfo
-	 *
-	 * Struct for the data contained in a receiver info
-	 * block. Receiver info blocks can be found in SR (sender
-	 * report) or RR (receiver report) RTCP packets.
-	 **/
-	struct ReceiverInfo
-	{
-		uint8 fractionLost;      ///< packet fraction lost.
-		uint8 lostMSB;           ///< cumulative lost MSB of 3 octets.
-		uint16 lostLSW;          ///< cumulative lost two LSB.
-		uint32 highestSeqNum;    ///< highest sequence number.
-		uint32 jitter;           ///< arrival jitter.
-		uint32 lsr;              ///< last sender report timestamp.
-		uint32 dlsr;             ///< delay since last sender report.
-	};
-	
-	/**
-	 * @struct RRBlock
-	 *
-	 * Struct for a receiver info block in a SR (sender report) or an RR
-	 * (receiver report) RTCP packet.
-	 **/
-	struct RRBlock
-	{
-		uint32 ssrc;                   ///< source identifier.
-		ReceiverInfo rinfo;            ///< info about the source.
-	};
-	
-	/**
-	 * @struct RecvReport
-	 *
-	 * @short raw structure of the source and every receiver report in an
-	 * SR or RR RTCP packet.  
-	 **/
-	struct RecvReport
-	{
-		uint32 ssrc;                 ///< source identifier.
-		RRBlock blocks[1];           ///< receiver report blocks.
-	};
-	
-	/**
-	 * @struct SenderInfo
-	 *
-	 * Struct for the sender info block in a SR (sender report)
-	 * RTCP packet.
-	 **/
-	struct SenderInfo
-	{
-		uint32 NTPMSW;              ///< NTP timestamp higher octets.
-		uint32 NTPLSW;              ///< NTP timestamp lower octets.
-		uint32 RTPTimestamp;        ///< RTP timestamp.
-		uint32 packetCount;         ///< cumulative packet counter.
-		uint32 octetCount;          ///< cumulative octet counter.
-	};
-	
-	/**
-	 * @struct SendReport
-	 *
-	 * Struct for SR (sender report) RTCP packets. 
-	 **/
-	struct SendReport
-	{
-		uint32 ssrc;       ///< source identifier.
-		SenderInfo sinfo;  ///< actual sender info.
-		RRBlock blocks[1]; ///< possibly several receiver info blocks.
-	};
-	
-	/**
-	 * @struct SDESItem
-	 *
-	 * Struct for an item description of a SDES packet.
-	 **/
-	struct SDESItem 
-	{
-		uint8 type;       ///< item identifier.
-		uint8 len;        ///< item len in octets.
-		char data[1];     ///< item content.
-	};
+    /**
+     * @struct ReceiverInfo
+     *
+     * Struct for the data contained in a receiver info
+     * block. Receiver info blocks can be found in SR (sender
+     * report) or RR (receiver report) RTCP packets.
+     **/
+    struct ReceiverInfo
+    {
+        uint8 fractionLost;      ///< packet fraction lost.
+        uint8 lostMSB;           ///< cumulative lost MSB of 3 octets.
+        uint16 lostLSW;          ///< cumulative lost two LSB.
+        uint32 highestSeqNum;    ///< highest sequence number.
+        uint32 jitter;           ///< arrival jitter.
+        uint32 lsr;              ///< last sender report timestamp.
+        uint32 dlsr;             ///< delay since last sender report.
+    };
 
-	/**
-	 * @struct SDESChunk
-	 *
-	 * Struct for a chunk of items in a SDES RTCP packet.
-	 **/
-	struct SDESChunk 
-	{
-		uint32 getSSRC() const
-		{ return (ntohl(ssrc)); }
+    /**
+     * @struct RRBlock
+     *
+     * Struct for a receiver info block in a SR (sender report) or an RR
+     * (receiver report) RTCP packet.
+     **/
+    struct RRBlock
+    {
+        uint32 ssrc;                   ///< source identifier.
+        ReceiverInfo rinfo;            ///< info about the source.
+    };
 
-		uint32 ssrc;      ///< SSRC identifer from sender.
-		SDESItem item;    ///< SDES item from sender.		
-	};
+    /**
+     * @struct RecvReport
+     *
+     * @short raw structure of the source and every receiver report in an
+     * SR or RR RTCP packet.
+     **/
+    struct RecvReport
+    {
+        uint32 ssrc;                 ///< source identifier.
+        RRBlock blocks[1];           ///< receiver report blocks.
+    };
 
-	/**
-	 * @struct BYEPacket
-	 *
-	 * @short Struct for BYE (leaving session) RTCP packets.
-	 **/
-	struct BYEPacket 
-	{
-		uint32 ssrc;          ///< ssrc identifier of source leaving.
-		uint8 length;         ///< [optional] length of reason.
-	};
-	
-	/**
-	 * @struct APPPacket
-	 *
-	 * @short Struct for APP (application specific) RTCP packets.
-	 **/
-	struct APPPacket
-	{
-		uint32 ssrc;           ///< ssrc identifier of source.
-		char name [4];         ///< Name of the APP packet,
-				       ///interpreted as a sequence of
-				       ///four characters.
-		unsigned char data[1]; ///< application dependent data.
-	};
+    /**
+     * @struct SenderInfo
+     *
+     * Struct for the sender info block in a SR (sender report)
+     * RTCP packet.
+     **/
+    struct SenderInfo
+    {
+        uint32 NTPMSW;              ///< NTP timestamp higher octets.
+        uint32 NTPLSW;              ///< NTP timestamp lower octets.
+        uint32 RTPTimestamp;        ///< RTP timestamp.
+        uint32 packetCount;         ///< cumulative packet counter.
+        uint32 octetCount;          ///< cumulative octet counter.
+    };
 
-	/**
-	 * @struct FIRPacket
-	 *
-	 * @short Struct for Full Intra-frame Request (FIR) RTCP
-	 * packet. Specific for H.261 sessions (see RFC 2032).
-	 **/
-	struct FIRPacket
-	{
-		uint32 ssrc;           ///< ssrc identifier of source.
-	};
+    /**
+     * @struct SendReport
+     *
+     * Struct for SR (sender report) RTCP packets.
+     **/
+    struct SendReport
+    {
+        uint32 ssrc;       ///< source identifier.
+        SenderInfo sinfo;  ///< actual sender info.
+        RRBlock blocks[1]; ///< possibly several receiver info blocks.
+    };
 
-	/**
-	 * @struct NACKPacket
-	 *
-	 * @short Struct for Negative ACKnowledgements (NACK) RTCP
-	 * packet. Specific for H.261 sessions (see RFC 2032).
-	 **/
-	struct NACKPacket
-	{
-		uint32 ssrc;           ///< ssrc identifier of source.
-		uint16 fsn;            ///< First Sequence Number lost.
-		uint16 blp;            ///< Bitmask of following Lost Packets.
-	};
+    /**
+     * @struct SDESItem
+     *
+     * Struct for an item description of a SDES packet.
+     **/
+    struct SDESItem
+    {
+        uint8 type;       ///< item identifier.
+        uint8 len;        ///< item len in octets.
+        char data[1];     ///< item content.
+    };
 
-	/**
-	 * @struct RTCPFixedHeader
-	 * Fixed RTCP packet header. First 32-bit word in any RTCP
-	 * packet.
-	 */
-	struct RTCPFixedHeader
-	{
-#if	__BYTE_ORDER == __BIG_ENDIAN
-		///< For big endian boxes
-		unsigned char version:2;      ///< Version, currently 2.
-		unsigned char padding:1;      ///< Padding bit.
-		unsigned char block_count:5;  ///< Number of RR, SR, or SDES chunks.
+    /**
+     * @struct SDESChunk
+     *
+     * Struct for a chunk of items in a SDES RTCP packet.
+     **/
+    struct SDESChunk
+    {
+        uint32 getSSRC() const
+        { return (ntohl(ssrc)); }
+
+        uint32 ssrc;      ///< SSRC identifer from sender.
+        SDESItem item;    ///< SDES item from sender.
+    };
+
+    /**
+     * @struct BYEPacket
+     *
+     * @short Struct for BYE (leaving session) RTCP packets.
+     **/
+    struct BYEPacket
+    {
+        uint32 ssrc;          ///< ssrc identifier of source leaving.
+        uint8 length;         ///< [optional] length of reason.
+    };
+
+    /**
+     * @struct APPPacket
+     *
+     * @short Struct for APP (application specific) RTCP packets.
+     **/
+    struct APPPacket
+    {
+        uint32 ssrc;           ///< ssrc identifier of source.
+        char name [4];         ///< Name of the APP packet,
+                       ///interpreted as a sequence of
+                       ///four characters.
+        unsigned char data[1]; ///< application dependent data.
+    };
+
+    /**
+     * @struct FIRPacket
+     *
+     * @short Struct for Full Intra-frame Request (FIR) RTCP
+     * packet. Specific for H.261 sessions (see RFC 2032).
+     **/
+    struct FIRPacket
+    {
+        uint32 ssrc;           ///< ssrc identifier of source.
+    };
+
+    /**
+     * @struct NACKPacket
+     *
+     * @short Struct for Negative ACKnowledgements (NACK) RTCP
+     * packet. Specific for H.261 sessions (see RFC 2032).
+     **/
+    struct NACKPacket
+    {
+        uint32 ssrc;           ///< ssrc identifier of source.
+        uint16 fsn;            ///< First Sequence Number lost.
+        uint16 blp;            ///< Bitmask of following Lost Packets.
+    };
+
+    /**
+     * @struct RTCPFixedHeader
+     * Fixed RTCP packet header. First 32-bit word in any RTCP
+     * packet.
+     */
+    struct RTCPFixedHeader
+    {
+#if __BYTE_ORDER == __BIG_ENDIAN
+        ///< For big endian boxes
+        unsigned char version:2;      ///< Version, currently 2.
+        unsigned char padding:1;      ///< Padding bit.
+        unsigned char block_count:5;  ///< Number of RR, SR, or SDES chunks.
 #else
-		///< For little endian boxes
-		unsigned char block_count:5;  ///< Number of RR, SR, or SDES chunks. 
-		unsigned char padding:1;      ///< Padding bit.
-		unsigned char version:2;      ///< Version, currently 2.
+        ///< For little endian boxes
+        unsigned char block_count:5;  ///< Number of RR, SR, or SDES chunks.
+        unsigned char padding:1;      ///< Padding bit.
+        unsigned char version:2;      ///< Version, currently 2.
 #endif
-		uint8 type;    ///< type of RTCP packet.
-		uint16 length; ///< number of 32-bit words in the packet (*minus one*).
-	};
+        uint8 type;    ///< type of RTCP packet.
+        uint16 length; ///< number of 32-bit words in the packet (*minus one*).
+    };
 
-	/**
-	 * @struct RTCPPacket 
-	 *
-	 * @short Struct representing general RTCP packet headers as they are
-	 * sent through the network.
-	 * 
-	 * This struct consists of a fixed header, always at the
-	 * beginning of any RTCP packet, and a union for all the RTCP
-	 * packet types supported.
-	 **/
-	struct RTCPPacket
-	{
-		/**
-		 * @enum Type rtp.h cc++/rtp.h
-		 * 
-		 * RTCP packet types. They are registered with IANA.
-		 */
-		typedef enum {
-			tSR = 200,      ///< Sender Report.
-			tRR,            ///< Receiver Report.
-			tSDES,          ///< Source DEScription.
-			tBYE,           ///< End of participation.
-			tAPP,           ///< APPlication specific.
-			tFIR   = 192,   ///< Full Intra-frame request.
-			tNACK  = 193,   ///< Negative ACK.
-			tXR             ///< Extended Report.
-		}       Type;
-		
-		/**
-		 * Get the packet length specified in its header, in
-		 * octets and in host order.
-		 **/
-		uint32 getLength() const
-		{ return ((ntohs(fh.length) + 1) << 2); }
+    /**
+     * @struct RTCPPacket
+     *
+     * @short Struct representing general RTCP packet headers as they are
+     * sent through the network.
+     *
+     * This struct consists of a fixed header, always at the
+     * beginning of any RTCP packet, and a union for all the RTCP
+     * packet types supported.
+     **/
+    struct RTCPPacket
+    {
+        /**
+         * @enum Type rtp.h cc++/rtp.h
+         *
+         * RTCP packet types. They are registered with IANA.
+         */
+        typedef enum {
+            tSR = 200,      ///< Sender Report.
+            tRR,            ///< Receiver Report.
+            tSDES,          ///< Source DEScription.
+            tBYE,           ///< End of participation.
+            tAPP,           ///< APPlication specific.
+            tFIR   = 192,   ///< Full Intra-frame request.
+            tNACK  = 193,   ///< Negative ACK.
+            tXR             ///< Extended Report.
+        }       Type;
 
-		/**
-		 * Get the SSRC identifier specified in the packet
-		 * header, in host order.
-		 **/
-		uint32 getSSRC()  const			
-		{ return (ntohl(info.RR.ssrc)); } // SSRC is always the first
-						  // word after fh.
+        /**
+         * Get the packet length specified in its header, in
+         * octets and in host order.
+         **/
+        uint32 getLength() const
+        { return ((ntohs(fh.length) + 1) << 2); }
 
-		RTCPFixedHeader fh;           ///< Fixed RTCP header.
+        /**
+         * Get the SSRC identifier specified in the packet
+         * header, in host order.
+         **/
+        uint32 getSSRC()  const
+        { return (ntohl(info.RR.ssrc)); } // SSRC is always the first
+                          // word after fh.
 
-		// An RTCP packet may be of any of the types defined
-		// above, including APP specific ones.
-		union
-		{
-			SendReport SR;
-			RecvReport RR;
-			SDESChunk SDES; 
-			BYEPacket BYE;
-			APPPacket APP;
-			NACKPacket NACK;
-			FIRPacket FIR;
-		}       info;        ///< Union for SR, RR, SDES, BYE and APP
-	};
-#ifdef	CCXX_PACKED
+        RTCPFixedHeader fh;           ///< Fixed RTCP header.
+
+        // An RTCP packet may be of any of the types defined
+        // above, including APP specific ones.
+        union
+        {
+            SendReport SR;
+            RecvReport RR;
+            SDESChunk SDES;
+            BYEPacket BYE;
+            APPPacket APP;
+            NACKPacket NACK;
+            FIRPacket FIR;
+        }       info;        ///< Union for SR, RR, SDES, BYE and APP
+    };
+#ifdef  CCXX_PACKED
 #pragma pack()
 #endif
 
 protected:
-	enum { defaultPathMTU = 1500 };
+    enum { defaultPathMTU = 1500 };
 
-	RTCPCompoundHandler(uint16 mtu = defaultPathMTU);
+    RTCPCompoundHandler(uint16 mtu = defaultPathMTU);
 
-	~RTCPCompoundHandler();
+    ~RTCPCompoundHandler();
 
-	/**
-	 * Perform RTCP compound packet header validity check as
-	 * specified in draft-ietv-avt-rtp-new. This method follows
-	 * appendix A.2. Correct version, payload type, padding bit
-	 * and length of every RTCP packet in the compound are
-	 * verified.
-	 *
-	 * @param len length of the RTCP compound packet in 
-	 *        the reception buffer
-	 * @return whether the header is valid.
-	 */
-	bool
-	checkCompoundRTCPHeader(size_t len);
+    /**
+     * Perform RTCP compound packet header validity check as
+     * specified in draft-ietv-avt-rtp-new. This method follows
+     * appendix A.2. Correct version, payload type, padding bit
+     * and length of every RTCP packet in the compound are
+     * verified.
+     *
+     * @param len length of the RTCP compound packet in
+     *        the reception buffer
+     * @return whether the header is valid.
+     */
+    bool
+    checkCompoundRTCPHeader(size_t len);
 
-	// buffer to hold RTCP compound packets being sent. Allocated
-	// in construction time
-	unsigned char* rtcpSendBuffer;
-	// buffer to hold RTCP compound packets being
-	// received. Allocated at construction time
-	unsigned char* rtcpRecvBuffer;
+    // buffer to hold RTCP compound packets being sent. Allocated
+    // in construction time
+    unsigned char* rtcpSendBuffer;
+    // buffer to hold RTCP compound packets being
+    // received. Allocated at construction time
+    unsigned char* rtcpRecvBuffer;
 
-	friend class RTCPSenderInfo;
-	friend class RTCPReceiverInfo;
+    friend class RTCPSenderInfo;
+    friend class RTCPReceiverInfo;
 private:
-	// path MTU. RTCP packets should not be greater than this
-	uint16 pathMTU;
-	// masks for RTCP header validation;
-	static const uint16 RTCP_VALID_MASK;
-	static const uint16 RTCP_VALID_VALUE;
+    // path MTU. RTCP packets should not be greater than this
+    uint16 pathMTU;
+    // masks for RTCP header validation;
+    static const uint16 RTCP_VALID_MASK;
+    static const uint16 RTCP_VALID_VALUE;
 };
 
 /**
  * @class RTCPReceiverInfo
  * @short Report block information of SR/RR RTCP reports.
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT RTCPReceiverInfo
 {
 public:
-	RTCPReceiverInfo(void* ri)
-	{ memcpy(&receiverInfo,&ri,
-		 sizeof(RTCPCompoundHandler::ReceiverInfo));}
+    RTCPReceiverInfo(void* ri)
+    { memcpy(&receiverInfo,&ri,
+         sizeof(RTCPCompoundHandler::ReceiverInfo));}
 
         RTCPReceiverInfo(RTCPCompoundHandler::ReceiverInfo& si)
-		: receiverInfo( si )
+        : receiverInfo( si )
         {
         }
 
-	~RTCPReceiverInfo()
-	{ }
+    ~RTCPReceiverInfo()
+    { }
 
-	/**
-	 * Get fraction of lost packets, as a number between 0 and
-	 * 255.
-	 **/
-	inline uint8
-	getFractionLost() const
-	{ return receiverInfo.fractionLost; }
+    /**
+     * Get fraction of lost packets, as a number between 0 and
+     * 255.
+     **/
+    inline uint8
+    getFractionLost() const
+    { return receiverInfo.fractionLost; }
 
-	inline uint32
-	getCumulativePacketLost() const
-	{ return ( ((uint32)ntohs(receiverInfo.lostLSW)) + 
-		   (((uint32)receiverInfo.lostMSB) << 16) ); }
-	
-	inline uint32
-	getExtendedSeqNum() const
-	{ return ntohl(receiverInfo.highestSeqNum); }
+    inline uint32
+    getCumulativePacketLost() const
+    { return ( ((uint32)ntohs(receiverInfo.lostLSW)) +
+           (((uint32)receiverInfo.lostMSB) << 16) ); }
 
-	/**
-	* Get the statistical variance of the RTP data packets
-	* interarrival time.
-	*
-	* @return Interarrival jitter, in timestamp units.
-	**/
-	uint32
-	getJitter() const
-	{ return ntohl(receiverInfo.jitter); }
+    inline uint32
+    getExtendedSeqNum() const
+    { return ntohl(receiverInfo.highestSeqNum); }
 
-	/**
-	 * Get the integer part of the NTP timestamp of the last SR
-	 * RTCP packet received from the source this receiver report
-	 * refers to.
-	 **/
-	uint16
-	getLastSRNTPTimestampInt() const
-	{ return (uint16)((ntohl(receiverInfo.lsr) & 0xFFFF0000) >> 16); }
+    /**
+    * Get the statistical variance of the RTP data packets
+    * interarrival time.
+    *
+    * @return Interarrival jitter, in timestamp units.
+    **/
+    uint32
+    getJitter() const
+    { return ntohl(receiverInfo.jitter); }
 
-	/**
-	 * Get the fractional part of the NTP timestamp of the last SR
-	 * RTCP packet received from the source this receiver report
-	 * refers to.
-	 **/
-	uint16
-	getLastSRNTPTimestampFrac() const
-	{ return (uint16)(ntohl(receiverInfo.lsr) & 0xFFFF); }
+    /**
+     * Get the integer part of the NTP timestamp of the last SR
+     * RTCP packet received from the source this receiver report
+     * refers to.
+     **/
+    uint16
+    getLastSRNTPTimestampInt() const
+    { return (uint16)((ntohl(receiverInfo.lsr) & 0xFFFF0000) >> 16); }
 
-	/**
-	 * Get the delay between the last SR packet received and the
-	 * transmission of this report.
-	 *
-	 * @return Delay, in units of 1/65536 seconds
-	 **/
-	uint32
-	getDelayLastSR() const
-	{ return ntohl(receiverInfo.dlsr); }	
+    /**
+     * Get the fractional part of the NTP timestamp of the last SR
+     * RTCP packet received from the source this receiver report
+     * refers to.
+     **/
+    uint16
+    getLastSRNTPTimestampFrac() const
+    { return (uint16)(ntohl(receiverInfo.lsr) & 0xFFFF); }
+
+    /**
+     * Get the delay between the last SR packet received and the
+     * transmission of this report.
+     *
+     * @return Delay, in units of 1/65536 seconds
+     **/
+    uint32
+    getDelayLastSR() const
+    { return ntohl(receiverInfo.dlsr); }
 
 private:
-	RTCPCompoundHandler::ReceiverInfo receiverInfo;
+    RTCPCompoundHandler::ReceiverInfo receiverInfo;
 };
 
 /**
  * @class RTCPSenderInfo
  * @short Sender block information of SR RTCP reports.
  *
- * @author Federico Montesino Pouzols <fedemp@altern.org> 
+ * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
 class __EXPORT RTCPSenderInfo
 {
 public:
-	RTCPSenderInfo(void* si)
-	{ memcpy(&senderInfo,&si,
-		 sizeof(RTCPCompoundHandler::SenderInfo));}
+    RTCPSenderInfo(void* si)
+    { memcpy(&senderInfo,&si,
+         sizeof(RTCPCompoundHandler::SenderInfo));}
 
         RTCPSenderInfo(RTCPCompoundHandler::SenderInfo& si)
-		: senderInfo( si )
+        : senderInfo( si )
         {
         }
 
-	~RTCPSenderInfo()
-	{ }
+    ~RTCPSenderInfo()
+    { }
 
-	/**
-	 * Get integer part of the NTP timestamp of this packet.
-	 * @see NTP2Timeval
-	 **/
-	uint32
-	getNTPTimestampInt() const
-	{ return ntohl(senderInfo.NTPMSW); }
+    /**
+     * Get integer part of the NTP timestamp of this packet.
+     * @see NTP2Timeval
+     **/
+    uint32
+    getNTPTimestampInt() const
+    { return ntohl(senderInfo.NTPMSW); }
 
-	/**
-	 * Get fractional part of the NTP timestamp of this packet.
-	 * @see NTP2Timeval
-	 **/
-	uint32
-	getNTPTimestampFrac() const
-	{ return ntohl(senderInfo.NTPLSW); }
+    /**
+     * Get fractional part of the NTP timestamp of this packet.
+     * @see NTP2Timeval
+     **/
+    uint32
+    getNTPTimestampFrac() const
+    { return ntohl(senderInfo.NTPLSW); }
 
-	inline uint32
-	getRTPTimestamp() const
-	{ return ntohl(senderInfo.RTPTimestamp); }
+    inline uint32
+    getRTPTimestamp() const
+    { return ntohl(senderInfo.RTPTimestamp); }
 
-	/**
-	 * Get count of sent data packets.
-	 **/
-	inline uint32
-	getPacketCount() const
-	{ return ntohl(senderInfo.packetCount); }
-	
-	inline uint32
-	getOctetCount() const
-	{ return ntohl(senderInfo.octetCount); }
+    /**
+     * Get count of sent data packets.
+     **/
+    inline uint32
+    getPacketCount() const
+    { return ntohl(senderInfo.packetCount); }
+
+    inline uint32
+    getOctetCount() const
+    { return ntohl(senderInfo.octetCount); }
 
 private:
-	RTCPCompoundHandler::SenderInfo senderInfo;
+    RTCPCompoundHandler::SenderInfo senderInfo;
 };
 
 /**
@@ -526,9 +524,7 @@
 
 /** @}*/ // rtcppacket
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  // ndef CCXX_RTP_RTCPPKT_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/rtp.h b/jni/libccrtp/sources/src/ccrtp/rtp.h
old mode 100755
new mode 100644
index a3e2861..b08e762
--- a/jni/libccrtp/sources/src/ccrtp/rtp.h
+++ b/jni/libccrtp/sources/src/ccrtp/rtp.h
@@ -46,15 +46,13 @@
  * profile specific functionality (following RFC 3551).
  **/
 
-#ifndef	CCXX_RTP_RTP_H_
+#ifndef CCXX_RTP_RTP_H_
 #define CCXX_RTP_RTP_H_
 
 #include <ccrtp/cqueue.h>
 #include <ccrtp/channel.h>
 
-#ifdef	CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @defgroup sessions RTP sessions.
@@ -82,325 +80,325 @@
  * @author David Sugar <dyfet@ostel.com>
  * @short RTP protocol stack based on Common C++.
  **/
-	template <class RTPDataChannel = DualRTPUDPIPv4Channel,
-		  class RTCPChannel = DualRTPUDPIPv4Channel,
-		  class ServiceQueue = AVPQueue>
-	class __EXPORT TRTPSessionBase : public ServiceQueue
-	{
-	public:
-		/**
-		 * Builds a session waiting for packets in a host address.
-		 *
-		 * @param ia Network address this socket is to be bound.
-		 * @param dataPort Transport port the data socket is to be bound.
-		 * @param controlPort Transport port the control socket is to be bound.
-		 * @param membersSize Initial size of the membership table.
-		 * @param app Application this session is associated to.
-		 * */
-		TRTPSessionBase(const InetHostAddress& ia, tpport_t dataPort,
-				tpport_t controlPort, uint32 membersSize,
-				RTPApplication& app) :
-			ServiceQueue(membersSize,app)
-			{ build(ia,dataPort,controlPort); }
+    template <class RTPDataChannel = DualRTPUDPIPv4Channel,
+          class RTCPChannel = DualRTPUDPIPv4Channel,
+          class ServiceQueue = AVPQueue>
+    class __EXPORT TRTPSessionBase : public ServiceQueue
+    {
+    public:
+        /**
+         * Builds a session waiting for packets in a host address.
+         *
+         * @param ia Network address this socket is to be bound.
+         * @param dataPort Transport port the data socket is to be bound.
+         * @param controlPort Transport port the control socket is to be bound.
+         * @param membersSize Initial size of the membership table.
+         * @param app Application this session is associated to.
+         * */
+        TRTPSessionBase(const InetHostAddress& ia, tpport_t dataPort,
+                tpport_t controlPort, uint32 membersSize,
+                RTPApplication& app) :
+            ServiceQueue(membersSize,app)
+            { build(ia,dataPort,controlPort); }
 
-		/**
-		 * Builds a session with the specified ssrc identifier for the
-		 * local source.
-		 *
-		 * @param ssrc SSRC identifier for the local source.
-		 * @param ia Network address this socket is to be bound.
-		 * @param dataPort Transport port the data socket is to be bound.
-		 * @param controlPort Transport port the control socket is to be bound.
-		 * @param membersSize Initial size of the membership table.
-		 * @param app Application this session is associated to.
-		 **/
-		TRTPSessionBase(uint32 ssrc,
-				const InetHostAddress& ia,
-				tpport_t dataPort, tpport_t controlPort,
-				uint32 membersSize, RTPApplication& app):
-			ServiceQueue(ssrc,membersSize,app)
-			{ build(ia,dataPort,controlPort); }
+        /**
+         * Builds a session with the specified ssrc identifier for the
+         * local source.
+         *
+         * @param ssrc SSRC identifier for the local source.
+         * @param ia Network address this socket is to be bound.
+         * @param dataPort Transport port the data socket is to be bound.
+         * @param controlPort Transport port the control socket is to be bound.
+         * @param membersSize Initial size of the membership table.
+         * @param app Application this session is associated to.
+         **/
+        TRTPSessionBase(uint32 ssrc,
+                const InetHostAddress& ia,
+                tpport_t dataPort, tpport_t controlPort,
+                uint32 membersSize, RTPApplication& app):
+            ServiceQueue(ssrc,membersSize,app)
+            { build(ia,dataPort,controlPort); }
 
-		/**
-		 * Builds a session waiting for packets in a multicast address.
-		 * TODO: ssrc constructor for multicast!
-		 *
-		 * @param ia Multicast address this socket is to be bound.
-		 * @param dataPort Transport port the data socket is to be bound.
-		 * @param controlPort Transport port the control socket is to be bound.
-		 * @param membersSize Initial size of the membership table.
-		 * @param app Application this session is associated to.
-		 * @param iface Index (from 0 to n) of network interface to join to
-		 * multicast group.
-		 **/
-		TRTPSessionBase(const InetMcastAddress& ia, tpport_t dataPort,
-				tpport_t controlPort, uint32 membersSize,
-				RTPApplication& app, uint32 iface) :
-			ServiceQueue(membersSize,app)
-			{ build(ia,dataPort,controlPort,iface); }
+        /**
+         * Builds a session waiting for packets in a multicast address.
+         * TODO: ssrc constructor for multicast!
+         *
+         * @param ia Multicast address this socket is to be bound.
+         * @param dataPort Transport port the data socket is to be bound.
+         * @param controlPort Transport port the control socket is to be bound.
+         * @param membersSize Initial size of the membership table.
+         * @param app Application this session is associated to.
+         * @param iface Index (from 0 to n) of network interface to join to
+         * multicast group.
+         **/
+        TRTPSessionBase(const InetMcastAddress& ia, tpport_t dataPort,
+                tpport_t controlPort, uint32 membersSize,
+                RTPApplication& app, uint32 iface) :
+            ServiceQueue(membersSize,app)
+            { build(ia,dataPort,controlPort,iface); }
 
-		/**
-		 * Builds a session waiting for packets in a multicast
-		 * address, with the specified ssrc identifier for the local
-		 * source.
-		 *
-		 * @param ssrc SSRC identifier for the local source.
-		 * @param ia Multicast address this socket is to be bound.
-		 * @param dataPort Transport port the data socket is to be bound.
-		 * @param controlPort Transport port the control socket is to be bound.
-		 * @param membersSize Initial size of the membership table.
-		 * @param app Application this session is associated to.
-		 * @param iface Index (from 0 to n) of network interface to join to
-		 * multicast group.
-		 **/
-		TRTPSessionBase(uint32 ssrc,
-				const InetMcastAddress& ia, tpport_t dataPort,
-				tpport_t controlPort, uint32 membersSize,
-				RTPApplication& app, uint32 iface) :
-			ServiceQueue(ssrc,membersSize,app)
-			{ build(ia,dataPort,controlPort,iface); }
+        /**
+         * Builds a session waiting for packets in a multicast
+         * address, with the specified ssrc identifier for the local
+         * source.
+         *
+         * @param ssrc SSRC identifier for the local source.
+         * @param ia Multicast address this socket is to be bound.
+         * @param dataPort Transport port the data socket is to be bound.
+         * @param controlPort Transport port the control socket is to be bound.
+         * @param membersSize Initial size of the membership table.
+         * @param app Application this session is associated to.
+         * @param iface Index (from 0 to n) of network interface to join to
+         * multicast group.
+         **/
+        TRTPSessionBase(uint32 ssrc,
+                const InetMcastAddress& ia, tpport_t dataPort,
+                tpport_t controlPort, uint32 membersSize,
+                RTPApplication& app, uint32 iface) :
+            ServiceQueue(ssrc,membersSize,app)
+            { build(ia,dataPort,controlPort,iface); }
 
-		virtual size_t dispatchBYE(const std::string &str)
-			{
-				return QueueRTCPManager::dispatchBYE(str);
-			}
+        virtual size_t dispatchBYE(const std::string &str)
+            {
+                return QueueRTCPManager::dispatchBYE(str);
+            }
 
-		/**
-		 * Set the value of the TTL field in the sent packets.
-		 *
-		 * @param ttl Time To Live
-		 * @return error code from the socket operation
-		 */
-		inline Socket::Error
-		setMcastTTL(uint8 ttl)
-			{
-				Socket::Error error = dso->setMulticast(true);
-				if ( error ) return error;
-				error = dso->setTimeToLive(ttl);
-				if ( error ) return error;
-				error = cso->setMulticast(true);
-				if ( error ) return error;
-				return cso->setTimeToLive(ttl);
-			}
+        /**
+         * Set the value of the TTL field in the sent packets.
+         *
+         * @param ttl Time To Live
+         * @return error code from the socket operation
+         */
+        inline Socket::Error
+        setMcastTTL(uint8 ttl)
+            {
+                Socket::Error error = dso->setMulticast(true);
+                if ( error ) return error;
+                error = dso->setTimeToLive(ttl);
+                if ( error ) return error;
+                error = cso->setMulticast(true);
+                if ( error ) return error;
+                return cso->setTimeToLive(ttl);
+            }
 
-		inline virtual
-		~TRTPSessionBase()
-			{
-				endSocket();
-			}
+        inline virtual
+        ~TRTPSessionBase()
+            {
+                endSocket();
+            }
 
-		inline RTPDataChannel *getDSO(void)
-			{return dso;}
+        inline RTPDataChannel *getDSO(void)
+            {return dso;}
 
-	protected:
-		/**
-		 * @param timeout maximum timeout to wait, in microseconds
-		 */
-		inline bool
-		isPendingData(microtimeout_t timeout)
-			{ return dso->isPendingRecv(timeout); }
+    protected:
+        /**
+         * @param timeout maximum timeout to wait, in microseconds
+         */
+        inline bool
+        isPendingData(microtimeout_t timeout)
+            { return dso->isPendingRecv(timeout); }
 
-		InetHostAddress
-		getDataSender(tpport_t *port = NULL) const
-			{ return dso->getSender(port); }
+        InetHostAddress
+        getDataSender(tpport_t *port = NULL) const
+            { return dso->getSender(port); }
 
-		inline size_t
-		getNextDataPacketSize() const
-			{ return dso->getNextPacketSize(); }
+        inline size_t
+        getNextDataPacketSize() const
+            { return dso->getNextPacketSize(); }
 
-		/**
-		 * Receive data from the data channel/socket.
-		 *
-		 * @param buffer Memory region to read to.
-		 * @param len Maximum number of octets to get.
-		 * @param na Source network address.
-		 * @param tp Source transport port.
-		 * @return Number of octets actually read.
-		 */
-		inline size_t
-		recvData(unsigned char* buffer, size_t len,
-			 InetHostAddress& na, tpport_t& tp)
-			{ na = dso->getSender(tp); return dso->recv(buffer, len); }
+        /**
+         * Receive data from the data channel/socket.
+         *
+         * @param buffer Memory region to read to.
+         * @param len Maximum number of octets to get.
+         * @param na Source network address.
+         * @param tp Source transport port.
+         * @return Number of octets actually read.
+         */
+        inline size_t
+        recvData(unsigned char* buffer, size_t len,
+             InetHostAddress& na, tpport_t& tp)
+            { na = dso->getSender(tp); return dso->recv(buffer, len); }
 
-		inline void
-		setDataPeer(const InetAddress &host, tpport_t port)
-			{ dso->setPeer(host,port); }
+        inline void
+        setDataPeer(const InetAddress &host, tpport_t port)
+            { dso->setPeer(host,port); }
 
 
-		/**
-		 * @param buffer memory region to write from
-		 * @param len number of octets to write
-		 */
-		inline size_t
-		sendData(const unsigned char* const buffer, size_t len)
-			{ return dso->send(buffer, len); }
+        /**
+         * @param buffer memory region to write from
+         * @param len number of octets to write
+         */
+        inline size_t
+        sendData(const unsigned char* const buffer, size_t len)
+            { return dso->send(buffer, len); }
 
-		inline SOCKET getDataRecvSocket() const
-			{ return dso->getRecvSocket(); }
+        inline SOCKET getDataRecvSocket() const
+            { return dso->getRecvSocket(); }
 
-		/**
-		 * @param timeout maximum timeout to wait, in microseconds
-		 * @return whether there are packets waiting to be picked
-		 */
-		inline bool
-		isPendingControl(microtimeout_t timeout)
-			{ return cso->isPendingRecv(timeout); }
+        /**
+         * @param timeout maximum timeout to wait, in microseconds
+         * @return whether there are packets waiting to be picked
+         */
+        inline bool
+        isPendingControl(microtimeout_t timeout)
+            { return cso->isPendingRecv(timeout); }
 
-		InetHostAddress
-		getControlSender(tpport_t *port = NULL) const
-			{ return cso->getSender(port); }
+        InetHostAddress
+        getControlSender(tpport_t *port = NULL) const
+            { return cso->getSender(port); }
 
-		/**
-		 * Receive data from the control channel/socket.
-		 *
-		 * @param buffer Buffer where to get data.
-		 * @param len Maximum number of octets to get.
-		 * @param na Source network address.
-		 * @param tp Source transport port.
-		 * @return Number of octets actually read.
-		 **/
-		inline size_t
-		recvControl(unsigned char *buffer, size_t len,
-			    InetHostAddress& na, tpport_t& tp)
-			{ na = cso->getSender(tp); return cso->recv(buffer,len); }
+        /**
+         * Receive data from the control channel/socket.
+         *
+         * @param buffer Buffer where to get data.
+         * @param len Maximum number of octets to get.
+         * @param na Source network address.
+         * @param tp Source transport port.
+         * @return Number of octets actually read.
+         **/
+        inline size_t
+        recvControl(unsigned char *buffer, size_t len,
+                InetHostAddress& na, tpport_t& tp)
+            { na = cso->getSender(tp); return cso->recv(buffer,len); }
 
-		inline void
-		setControlPeer(const InetAddress &host, tpport_t port)
-			{ cso->setPeer(host,port); }
+        inline void
+        setControlPeer(const InetAddress &host, tpport_t port)
+            { cso->setPeer(host,port); }
 
-		/**
-		 * @return number of octets actually written
-		 * @param buffer
-		 * @param len
-		 */
-		inline size_t
-		sendControl(const unsigned char* const buffer, size_t len)
-			{ return cso->send(buffer,len); }
+        /**
+         * @return number of octets actually written
+         * @param buffer
+         * @param len
+         */
+        inline size_t
+        sendControl(const unsigned char* const buffer, size_t len)
+            { return cso->send(buffer,len); }
 
-		inline SOCKET getControlRecvSocket() const
-			{ return cso->getRecvSocket(); }
+        inline SOCKET getControlRecvSocket() const
+            { return cso->getRecvSocket(); }
 
-		/**
-		 * Join a multicast group.
-		 *
-		 * @param ia address of the multicast group
-		 * @return error code from the socket operation
-		 */
-		inline Socket::Error
-		joinGroup(const InetMcastAddress& ia, uint32 iface)
-			{
-				Socket::Error error  = dso->setMulticast(true);
-				if ( error ) return error;
-				error = dso->join(ia,iface);
-				if ( error ) return error;
-				error = cso->setMulticast(true);
-				if ( error ) {
-					dso->drop(ia);
-					return error;
-				}
-				error = cso->join(ia,iface);
-				if ( error ) {
-					dso->drop(ia);
-					return error;
-				}
-				return Socket::errSuccess;
-			}
+        /**
+         * Join a multicast group.
+         *
+         * @param ia address of the multicast group
+         * @return error code from the socket operation
+         */
+        inline Socket::Error
+        joinGroup(const InetMcastAddress& ia, uint32 iface)
+            {
+                Socket::Error error  = dso->setMulticast(true);
+                if ( error ) return error;
+                error = dso->join(ia,iface);
+                if ( error ) return error;
+                error = cso->setMulticast(true);
+                if ( error ) {
+                    dso->drop(ia);
+                    return error;
+                }
+                error = cso->join(ia,iface);
+                if ( error ) {
+                    dso->drop(ia);
+                    return error;
+                }
+                return Socket::errSuccess;
+            }
 
-		/**
-		 * Leave a multicast group.
-		 *
-		 * @param ia address of the multicast group
-		 * @return error code from the socket operation
-		 */
-		inline Socket::Error
-		leaveGroup(const InetMcastAddress& ia)
-			{
-				Socket::Error error = dso->setMulticast(false);
-				if ( error ) return error;
-				error = dso->leaveGroup(ia);
-				if ( error ) return error;
-				error = cso->setMulticast(false);
-				if ( error ) return error;
-				return cso->leaveGroup(ia);
-			}
+        /**
+         * Leave a multicast group.
+         *
+         * @param ia address of the multicast group
+         * @return error code from the socket operation
+         */
+        inline Socket::Error
+        leaveGroup(const InetMcastAddress& ia)
+            {
+                Socket::Error error = dso->setMulticast(false);
+                if ( error ) return error;
+                error = dso->leaveGroup(ia);
+                if ( error ) return error;
+                error = cso->setMulticast(false);
+                if ( error ) return error;
+                return cso->leaveGroup(ia);
+            }
 
-		inline void
-		endSocket()
-			{
-				if (dso) {
-					dso->endSocket();
-					delete dso;
-				}
-				dso = NULL;
-				if (cso) {
-					cso->endSocket();
-					delete cso;
-				}
-				cso = NULL;
-			}
+        inline void
+        endSocket()
+            {
+                if (dso) {
+                    dso->endSocket();
+                    delete dso;
+                }
+                dso = NULL;
+                if (cso) {
+                    cso->endSocket();
+                    delete cso;
+                }
+                cso = NULL;
+            }
 
-	private:
-		void
-		build(const InetHostAddress& ia, tpport_t dataPort,
-		      tpport_t controlPort)
-			{
-				if ( 0 == controlPort ) {
-					dataBasePort = even_port(dataPort);
-					controlBasePort = dataBasePort + 1;
-				} else {
-					dataBasePort = dataPort;
-					controlBasePort = controlPort;
-				}
-				dso = new RTPDataChannel(ia,dataBasePort);
-				cso = new RTCPChannel(ia,controlBasePort);
-			}
+    private:
+        void
+        build(const InetHostAddress& ia, tpport_t dataPort,
+              tpport_t controlPort)
+            {
+                if ( 0 == controlPort ) {
+                    dataBasePort = even_port(dataPort);
+                    controlBasePort = dataBasePort + 1;
+                } else {
+                    dataBasePort = dataPort;
+                    controlBasePort = controlPort;
+                }
+                dso = new RTPDataChannel(ia,dataBasePort);
+                cso = new RTCPChannel(ia,controlBasePort);
+            }
 
-		void
-		build(const InetMcastAddress& ia, tpport_t dataPort,
-		      tpport_t controlPort, uint32 iface)
-			{
-				if ( 0 == controlPort ) {
-					dataBasePort = even_port(dataPort);
-					controlBasePort = dataBasePort + 1;
-				} else {
-					dataBasePort = dataPort;
-					controlBasePort = controlPort;
-				}
-				dso = new RTPDataChannel(InetHostAddress("0.0.0.0"),dataBasePort);
-				cso = new RTCPChannel(InetHostAddress("0.0.0.0"),controlBasePort);
-				joinGroup(ia,iface);
-			}
+        void
+        build(const InetMcastAddress& ia, tpport_t dataPort,
+              tpport_t controlPort, uint32 iface)
+            {
+                if ( 0 == controlPort ) {
+                    dataBasePort = even_port(dataPort);
+                    controlBasePort = dataBasePort + 1;
+                } else {
+                    dataBasePort = dataPort;
+                    controlBasePort = controlPort;
+                }
+                dso = new RTPDataChannel(InetHostAddress("0.0.0.0"),dataBasePort);
+                cso = new RTCPChannel(InetHostAddress("0.0.0.0"),controlBasePort);
+                joinGroup(ia,iface);
+            }
 
-		/**
-		 * Ensure a port number is odd. If it is an even number, return
-		 * the next lower (odd) port number.
-		 *
-		 * @param port number to filter
-		 * @return filtered (odd) port number
-		 */
-		inline tpport_t
-		odd_port(tpport_t port)
-			{ return (port & 0x01)? (port) : (port - 1); }
+        /**
+         * Ensure a port number is odd. If it is an even number, return
+         * the next lower (odd) port number.
+         *
+         * @param port number to filter
+         * @return filtered (odd) port number
+         */
+        inline tpport_t
+        odd_port(tpport_t port)
+            { return (port & 0x01)? (port) : (port - 1); }
 
-		/**
-		 * Ensure a port number is even. If it is an odd number, return
-		 * the next lower (even) port number.
-		 *
-		 * @param port number to filter
-		 * @return filtered (even) port number
-		 */
-		inline tpport_t
-		even_port(tpport_t port)
-			{ return (port & 0x01)? (port - 1) : (port); }
+        /**
+         * Ensure a port number is even. If it is an odd number, return
+         * the next lower (even) port number.
+         *
+         * @param port number to filter
+         * @return filtered (even) port number
+         */
+        inline tpport_t
+        even_port(tpport_t port)
+            { return (port & 0x01)? (port - 1) : (port); }
 
-		tpport_t dataBasePort;
-		tpport_t controlBasePort;
+        tpport_t dataBasePort;
+        tpport_t controlBasePort;
 
-	protected:
-		RTPDataChannel* dso;
-		RTCPChannel* cso;
-		friend class RTPSessionBaseHandler;
-	};
+    protected:
+        RTPDataChannel* dso;
+        RTCPChannel* cso;
+        friend class RTPSessionBaseHandler;
+    };
 
 /**
  * @class SingleThreadRTPSession
@@ -412,30 +410,30 @@
  *
  * @author Federico Montesino Pouzols <fedemp@altern.org>
  **/
-	template
-	<class RTPDataChannel = DualRTPUDPIPv4Channel,
-	 class RTCPChannel = DualRTPUDPIPv4Channel,
-	 class ServiceQueue = AVPQueue>
-	class __EXPORT SingleThreadRTPSession :
-		protected Thread,
-		public TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>
-	{
-	public:
-		SingleThreadRTPSession(const InetHostAddress& ia,
-				       tpport_t dataPort = DefaultRTPDataPort,
-				       tpport_t controlPort = 0,
-				       int pri = 0,
-				       uint32 memberssize =
-				       MembershipBookkeeping::defaultMembersHashSize,
-				       RTPApplication& app = defaultApplication()
+    template
+    <class RTPDataChannel = DualRTPUDPIPv4Channel,
+     class RTCPChannel = DualRTPUDPIPv4Channel,
+     class ServiceQueue = AVPQueue>
+    class __EXPORT SingleThreadRTPSession :
+        protected Thread,
+        public TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>
+    {
+    public:
+        SingleThreadRTPSession(const InetHostAddress& ia,
+                       tpport_t dataPort = DefaultRTPDataPort,
+                       tpport_t controlPort = 0,
+                       int pri = 0,
+                       uint32 memberssize =
+                       MembershipBookkeeping::defaultMembersHashSize,
+                       RTPApplication& app = defaultApplication()
 #if defined(_MSC_VER) && _MSC_VER >= 1300
-			);
+            );
 #else
-		):
-		Thread(pri),
-		TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>
-		(ia,dataPort,controlPort,memberssize,app)
-		{ }
+        ):
+        Thread(pri),
+        TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>
+        (ia,dataPort,controlPort,memberssize,app)
+        { }
 #endif
 
         SingleThreadRTPSession(uint32 ssrc, const InetHostAddress& ia,
@@ -446,25 +444,25 @@
                                MembershipBookkeeping::defaultMembersHashSize,
                                RTPApplication& app = defaultApplication()
 #if defined(_MSC_VER) && _MSC_VER >= 1300
-		);
+        );
 #else
-	):
-	Thread(pri),
-	TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>
-	(ssrc, ia,dataPort,controlPort,memberssize,app)
+    ):
+    Thread(pri),
+    TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>
+    (ssrc, ia,dataPort,controlPort,memberssize,app)
 { }
 #endif
 
 SingleThreadRTPSession(const InetMcastAddress& ia,
-		       tpport_t dataPort = DefaultRTPDataPort,
-		       tpport_t controlPort = 0,
-		       int pri = 0,
-		       uint32 memberssize =
-		       MembershipBookkeeping::defaultMembersHashSize,
-		       RTPApplication& app = defaultApplication(),
-		       uint32 iface = 0
+               tpport_t dataPort = DefaultRTPDataPort,
+               tpport_t controlPort = 0,
+               int pri = 0,
+               uint32 memberssize =
+               MembershipBookkeeping::defaultMembersHashSize,
+               RTPApplication& app = defaultApplication(),
+               uint32 iface = 0
 #if defined(_MSC_VER) && _MSC_VER >= 1300
-	       );
+           );
 #else
         ):
         Thread(pri),
@@ -474,13 +472,13 @@
 #endif
 
 SingleThreadRTPSession(uint32 ssrc, const InetMcastAddress& ia,
-		       tpport_t dataPort = DefaultRTPDataPort,
-		       tpport_t controlPort = 0,
-		       int pri = 0,
-		       uint32 memberssize =
-		       MembershipBookkeeping::defaultMembersHashSize,
-		       RTPApplication& app = defaultApplication(),
-		       uint32 iface = 0
+               tpport_t dataPort = DefaultRTPDataPort,
+               tpport_t controlPort = 0,
+               int pri = 0,
+               uint32 memberssize =
+               MembershipBookkeeping::defaultMembersHashSize,
+               RTPApplication& app = defaultApplication(),
+               uint32 iface = 0
 #if defined(_MSC_VER) && _MSC_VER >= 1300
                       );
 #else
@@ -553,38 +551,32 @@
  **/
 virtual void run(void)
 {
-	microtimeout_t timeout = 0;
-	while ( ServiceQueue::isActive() ) {
-		if ( timeout < 1000 ){ // !(timeout/1000)
-			timeout = getSchedulingTimeout();
-		}
-		setCancel(cancelDeferred);
-		controlReceptionService();
-		controlTransmissionService();
-		setCancel(cancelImmediate);
-		microtimeout_t maxWait =
-			timeval2microtimeout(getRTCPCheckInterval());
-		// make sure the scheduling timeout is
-		// <= the check interval for RTCP
-		// packets
-		timeout = (timeout > maxWait)? maxWait : timeout;
-		if ( timeout < 1000 ) { // !(timeout/1000)
-			setCancel(cancelDeferred);
-			dispatchDataPacket();
-			setCancel(cancelImmediate);
-			timerTick();
-		} else {
-			if ( isPendingData(timeout/1000) ) {
-				setCancel(cancelDeferred);
+    microtimeout_t timeout = 0;
+    while ( ServiceQueue::isActive() ) {
+        if ( timeout < 1000 ){ // !(timeout/1000)
+            timeout = getSchedulingTimeout();
+        }
+        controlReceptionService();
+        controlTransmissionService();
+        microtimeout_t maxWait =
+            timeval2microtimeout(getRTCPCheckInterval());
+        // make sure the scheduling timeout is
+        // <= the check interval for RTCP
+        // packets
+        timeout = (timeout > maxWait)? maxWait : timeout;
+        if ( timeout < 1000 ) { // !(timeout/1000)
+            dispatchDataPacket();
+            timerTick();
+        } else {
+            if ( isPendingData(timeout/1000) ) {
                                 if (ServiceQueue::isActive()) { // take in only if active
                                     takeInDataPacket();
                                 }
-				setCancel(cancelImmediate);
-			}
-			timeout = 0;
-		}
-	}
-	dispatchBYE("GNU ccRTP stack finishing.");
+            }
+            timeout = 0;
+        }
+    }
+    dispatchBYE("GNU ccRTP stack finishing.");
 //        Thread::exit();
 }
 
@@ -623,9 +615,9 @@
  * @short Symmetric UDP/IPv4 RTP session scheduled by one thread of execution.
  **/
 typedef SingleThreadRTPSession<SymmetricRTPChannel,
-			       SymmetricRTPChannel> SymmetricRTPSession;
+                   SymmetricRTPChannel> SymmetricRTPSession;
 
-#ifdef	CCXX_IPV6
+#ifdef  CCXX_IPV6
 
 /**
  * @class RTPSessionBaseIPV6
@@ -649,8 +641,8 @@
  * @short RTP protocol stack based on Common C++.
  **/
 template <class RTPDataChannel = DualRTPUDPIPv6Channel,
-	  class RTCPChannel = DualRTPUDPIPv6Channel,
-	  class ServiceQueue = AVPQueue>
+      class RTCPChannel = DualRTPUDPIPv6Channel,
+      class ServiceQueue = AVPQueue>
 class __EXPORT TRTPSessionBaseIPV6 : public ServiceQueue
 {
 public:
@@ -664,303 +656,303 @@
  * @param app Application this session is associated to.
  * */
 TRTPSessionBaseIPV6(const IPV6Host& ia, tpport_t dataPort,
-	tpport_t controlPort, uint32 membersSize,
-	RTPApplication& app) :
-	ServiceQueue(membersSize,app)
+    tpport_t controlPort, uint32 membersSize,
+    RTPApplication& app) :
+    ServiceQueue(membersSize,app)
 { build(ia,dataPort,controlPort); }
 
-	/**
-	 * Builds a session with the specified ssrc identifier for the
-	 * local source.
-	 *
-	 * @param ssrc SSRC identifier for the local source.
-	 * @param ia Network address this socket is to be bound.
-	 * @param dataPort Transport port the data socket is to be bound.
-	 * @param controlPort Transport port the control socket is to be bound.
-	 * @param membersSize Initial size of the membership table.
-	 * @param app Application this session is associated to.
-	 **/
-	TRTPSessionBaseIPV6(uint32 ssrc,
-			    const IPV6Host& ia,
-			    tpport_t dataPort, tpport_t controlPort,
-			    uint32 membersSize, RTPApplication& app):
-		ServiceQueue(ssrc,membersSize,app)
-		{ build(ia,dataPort,controlPort); }
+    /**
+     * Builds a session with the specified ssrc identifier for the
+     * local source.
+     *
+     * @param ssrc SSRC identifier for the local source.
+     * @param ia Network address this socket is to be bound.
+     * @param dataPort Transport port the data socket is to be bound.
+     * @param controlPort Transport port the control socket is to be bound.
+     * @param membersSize Initial size of the membership table.
+     * @param app Application this session is associated to.
+     **/
+    TRTPSessionBaseIPV6(uint32 ssrc,
+                const IPV6Host& ia,
+                tpport_t dataPort, tpport_t controlPort,
+                uint32 membersSize, RTPApplication& app):
+        ServiceQueue(ssrc,membersSize,app)
+        { build(ia,dataPort,controlPort); }
 
-	/**
-	 * Builds a session waiting for packets in a multicast address.
-	 * TODO: ssrc constructor for multicast!
-	 *
-	 * @param ia Multicast address this socket is to be bound.
-	 * @param dataPort Transport port the data socket is to be bound.
-	 * @param controlPort Transport port the control socket is to be bound.
-	 * @param membersSize Initial size of the membership table.
-	 * @param app Application this session is associated to.
-	 * @param iface Index (from 0 to n) of network interface to join to
-	 * multicast group.
-	 **/
-	TRTPSessionBaseIPV6(const IPV6Multicast& ia, tpport_t dataPort,
-			    tpport_t controlPort, uint32 membersSize,
-			    RTPApplication& app, uint32 iface) :
-		ServiceQueue(membersSize,app)
-		{ build(ia,dataPort,controlPort,iface); }
+    /**
+     * Builds a session waiting for packets in a multicast address.
+     * TODO: ssrc constructor for multicast!
+     *
+     * @param ia Multicast address this socket is to be bound.
+     * @param dataPort Transport port the data socket is to be bound.
+     * @param controlPort Transport port the control socket is to be bound.
+     * @param membersSize Initial size of the membership table.
+     * @param app Application this session is associated to.
+     * @param iface Index (from 0 to n) of network interface to join to
+     * multicast group.
+     **/
+    TRTPSessionBaseIPV6(const IPV6Multicast& ia, tpport_t dataPort,
+                tpport_t controlPort, uint32 membersSize,
+                RTPApplication& app, uint32 iface) :
+        ServiceQueue(membersSize,app)
+        { build(ia,dataPort,controlPort,iface); }
 
-	/**
-	 * Builds a session waiting for packets in a multicast
-	 * address, with the specified ssrc identifier for the local
-	 * source.
-	 *
-	 * @param ssrc SSRC identifier for the local source.
-	 * @param ia Multicast address this socket is to be bound.
-	 * @param dataPort Transport port the data socket is to be bound.
-	 * @param controlPort Transport port the control socket is to be bound.
-	 * @param membersSize Initial size of the membership table.
-	 * @param app Application this session is associated to.
-	 * @param iface Index (from 0 to n) of network interface to join to
-	 * multicast group.
-	 **/
-	TRTPSessionBaseIPV6(uint32 ssrc,
-			    const IPV6Multicast& ia, tpport_t dataPort,
-			    tpport_t controlPort, uint32 membersSize,
-			    RTPApplication& app, uint32 iface) :
-		ServiceQueue(ssrc,membersSize,app)
-		{ build(ia,dataPort,controlPort,iface); }
+    /**
+     * Builds a session waiting for packets in a multicast
+     * address, with the specified ssrc identifier for the local
+     * source.
+     *
+     * @param ssrc SSRC identifier for the local source.
+     * @param ia Multicast address this socket is to be bound.
+     * @param dataPort Transport port the data socket is to be bound.
+     * @param controlPort Transport port the control socket is to be bound.
+     * @param membersSize Initial size of the membership table.
+     * @param app Application this session is associated to.
+     * @param iface Index (from 0 to n) of network interface to join to
+     * multicast group.
+     **/
+    TRTPSessionBaseIPV6(uint32 ssrc,
+                const IPV6Multicast& ia, tpport_t dataPort,
+                tpport_t controlPort, uint32 membersSize,
+                RTPApplication& app, uint32 iface) :
+        ServiceQueue(ssrc,membersSize,app)
+        { build(ia,dataPort,controlPort,iface); }
 
-	virtual size_t dispatchBYE(const std::string &str)
-		{
-			return QueueRTCPManager::dispatchBYE(str);
-		}
+    virtual size_t dispatchBYE(const std::string &str)
+        {
+            return QueueRTCPManager::dispatchBYE(str);
+        }
 
-	inline virtual
-	~TRTPSessionBaseIPV6()
-		{
-			endSocket();
-		}
+    inline virtual
+    ~TRTPSessionBaseIPV6()
+        {
+            endSocket();
+        }
 
-	inline RTPDataChannel *getDSO(void)
-		{return dso;}
+    inline RTPDataChannel *getDSO(void)
+        {return dso;}
 
 protected:
-	/**
-	 * @param timeout maximum timeout to wait, in microseconds
-	 */
-	inline bool
-	isPendingData(microtimeout_t timeout)
-		{ return dso->isPendingRecv(timeout); }
+    /**
+     * @param timeout maximum timeout to wait, in microseconds
+     */
+    inline bool
+    isPendingData(microtimeout_t timeout)
+        { return dso->isPendingRecv(timeout); }
 
-	inline IPV6Host
-	getDataSender(tpport_t *port = NULL) const
-		{ return dso->getSender(port); }
+    inline IPV6Host
+    getDataSender(tpport_t *port = NULL) const
+        { return dso->getSender(port); }
 
-	inline size_t
-	getNextDataPacketSize() const
-		{ return dso->getNextPacketSize(); }
+    inline size_t
+    getNextDataPacketSize() const
+        { return dso->getNextPacketSize(); }
 
-	/**
-	 * Receive data from the data channel/socket.
-	 *
-	 * @param buffer Memory region to read to.
-	 * @param len Maximum number of octets to get.
-	 * @param na Source network address.
-	 * @param tp Source transport port.
-	 * @return Number of octets actually read.
-	 */
-	inline size_t
-	recvData(unsigned char* buffer, size_t len,
-		 IPV6Host& na, tpport_t& tp)
-		{ na = dso->getSender(tp); return dso->recv(buffer, len); }
+    /**
+     * Receive data from the data channel/socket.
+     *
+     * @param buffer Memory region to read to.
+     * @param len Maximum number of octets to get.
+     * @param na Source network address.
+     * @param tp Source transport port.
+     * @return Number of octets actually read.
+     */
+    inline size_t
+    recvData(unsigned char* buffer, size_t len,
+         IPV6Host& na, tpport_t& tp)
+        { na = dso->getSender(tp); return dso->recv(buffer, len); }
 
         inline void
         setDataPeerIPV6(const IPV6Host &host, tpport_t port)
-		{ dso->setPeer(host,port); }
+        { dso->setPeer(host,port); }
 
-	/**
-	 * @param buffer memory region to write from
-	 * @param len number of octets to write
-	 */
-	inline size_t
-	sendDataIPV6(const unsigned char* const buffer, size_t len)
-		{ return dso->send(buffer, len); }
+    /**
+     * @param buffer memory region to write from
+     * @param len number of octets to write
+     */
+    inline size_t
+    sendDataIPV6(const unsigned char* const buffer, size_t len)
+        { return dso->send(buffer, len); }
 
-	inline SOCKET getDataRecvSocket() const
-		{ return dso->getRecvSocket(); }
+    inline SOCKET getDataRecvSocket() const
+        { return dso->getRecvSocket(); }
 
-	/**
-	 * @param timeout maximum timeout to wait, in microseconds
-	 * @return whether there are packets waiting to be picked
-	 */
+    /**
+     * @param timeout maximum timeout to wait, in microseconds
+     * @return whether there are packets waiting to be picked
+     */
         inline bool
-	isPendingControl(microtimeout_t timeout)
-		{ return cso->isPendingRecv(timeout); }
+    isPendingControl(microtimeout_t timeout)
+        { return cso->isPendingRecv(timeout); }
 
-	inline IPV6Host
-	getControlSender(tpport_t *port = NULL) const
-		{ return cso->getSender(port); }
+    inline IPV6Host
+    getControlSender(tpport_t *port = NULL) const
+        { return cso->getSender(port); }
 
-	/**
-	 * Receive data from the control channel/socket.
-	 *
-	 * @param buffer Buffer where to get data.
-	 * @param len Maximum number of octets to get.
-	 * @param na Source network address.
-	 * @param tp Source transport port.
-	 * @return Number of octets actually read.
-	 **/
+    /**
+     * Receive data from the control channel/socket.
+     *
+     * @param buffer Buffer where to get data.
+     * @param len Maximum number of octets to get.
+     * @param na Source network address.
+     * @param tp Source transport port.
+     * @return Number of octets actually read.
+     **/
         inline size_t
-	recvControl(unsigned char *buffer, size_t len,
-		    IPV6Host& na, tpport_t& tp)
-		{ na = cso->getSender(tp); return cso->recv(buffer,len); }
+    recvControl(unsigned char *buffer, size_t len,
+            IPV6Host& na, tpport_t& tp)
+        { na = cso->getSender(tp); return cso->recv(buffer,len); }
 
         inline void
         setControlPeerIPV6(const IPV6Host &host, tpport_t port)
-		{ cso->setPeer(host,port); }
+        { cso->setPeer(host,port); }
 
-	/**
-	 * @return number of octets actually written
-	 * @param buffer
-	 * @param len
-	 */
+    /**
+     * @return number of octets actually written
+     * @param buffer
+     * @param len
+     */
         inline size_t
-	sendControl(const unsigned char* const buffer, size_t len)
-		{ return cso->send(buffer,len); }
+    sendControl(const unsigned char* const buffer, size_t len)
+        { return cso->send(buffer,len); }
 
-	inline SOCKET getControlRecvSocket() const
-		{ return cso->getRecvSocket(); }
+    inline SOCKET getControlRecvSocket() const
+        { return cso->getRecvSocket(); }
 
-	inline void
-	endSocket()
-		{
-			dso->endSocket();
-			cso->endSocket();
-			if (dso) delete dso;
-			dso = NULL;
-			if (cso) delete cso;
-			cso = NULL;
-		}
+    inline void
+    endSocket()
+        {
+            dso->endSocket();
+            cso->endSocket();
+            if (dso) delete dso;
+            dso = NULL;
+            if (cso) delete cso;
+            cso = NULL;
+        }
 
 private:
-	void
-	build(const IPV6Host& ia, tpport_t dataPort,
-	      tpport_t controlPort)
-		{
-			if ( 0 == controlPort ) {
-				dataBasePort = even_port(dataPort);
-				controlBasePort = dataBasePort + 1;
-			} else {
-				dataBasePort = dataPort;
-				controlBasePort = controlPort;
-			}
-			dso = new RTPDataChannel(ia,dataBasePort);
-			cso = new RTCPChannel(ia,controlBasePort);
-		}
+    void
+    build(const IPV6Host& ia, tpport_t dataPort,
+          tpport_t controlPort)
+        {
+            if ( 0 == controlPort ) {
+                dataBasePort = even_port(dataPort);
+                controlBasePort = dataBasePort + 1;
+            } else {
+                dataBasePort = dataPort;
+                controlBasePort = controlPort;
+            }
+            dso = new RTPDataChannel(ia,dataBasePort);
+            cso = new RTCPChannel(ia,controlBasePort);
+        }
 
-	void
-	build(const IPV6Multicast& ia, tpport_t dataPort,
-	      tpport_t controlPort, uint32 iface)
-		{
-			if ( 0 == controlPort ) {
-				dataBasePort = even_port(dataPort);
-				controlBasePort = dataBasePort + 1;
-			} else {
-				dataBasePort = dataPort;
-				controlBasePort = controlPort;
-			}
-			dso = new RTPDataChannel(IPV6Host("0.0.0.0"),dataBasePort);
-			cso = new RTCPChannel(IPV6Host("0.0.0.0"),controlBasePort);
-			joinGroup(ia,iface);
-		}
+    void
+    build(const IPV6Multicast& ia, tpport_t dataPort,
+          tpport_t controlPort, uint32 iface)
+        {
+            if ( 0 == controlPort ) {
+                dataBasePort = even_port(dataPort);
+                controlBasePort = dataBasePort + 1;
+            } else {
+                dataBasePort = dataPort;
+                controlBasePort = controlPort;
+            }
+            dso = new RTPDataChannel(IPV6Host("0.0.0.0"),dataBasePort);
+            cso = new RTCPChannel(IPV6Host("0.0.0.0"),controlBasePort);
+            joinGroup(ia,iface);
+        }
 
-	/**
-	 * Join a multicast group.
-	 *
-	 * @param ia address of the multicast group
-	 * @return error code from the socket operation
-	 */
-	inline Socket::Error
-	joinGroup(const IPV6Multicast& ia, uint32 iface)
-		{
-			Socket::Error error  = dso->setMulticast(true);
-			if ( error ) return error;
-			error = dso->join(ia,iface);
-			if ( error ) return error;
-			error = cso->setMulticast(true);
-			if ( error ) {
-				dso->drop(ia);
-				return error;
-			}
-			error = cso->join(ia,iface);
-			if ( error ) {
-				dso->drop(ia);
-				return error;
-			}
-			return Socket::errSuccess;
-		}
+    /**
+     * Join a multicast group.
+     *
+     * @param ia address of the multicast group
+     * @return error code from the socket operation
+     */
+    inline Socket::Error
+    joinGroup(const IPV6Multicast& ia, uint32 iface)
+        {
+            Socket::Error error  = dso->setMulticast(true);
+            if ( error ) return error;
+            error = dso->join(ia,iface);
+            if ( error ) return error;
+            error = cso->setMulticast(true);
+            if ( error ) {
+                dso->drop(ia);
+                return error;
+            }
+            error = cso->join(ia,iface);
+            if ( error ) {
+                dso->drop(ia);
+                return error;
+            }
+            return Socket::errSuccess;
+        }
 
-	/**
-	 * Leave a multicast group.
-	 *
-	 * @param ia address of the multicast group
-	 * @return error code from the socket operation
-	 */
-	inline Socket::Error
-	leaveGroup(const IPV6Multicast& ia)
-		{
-			Socket::Error error = dso->setMulticast(false);
-			if ( error ) return error;
-			error = dso->leaveGroup(ia);
-			if ( error ) return error;
-			error = cso->setMulticast(false);
-			if ( error ) return error;
-			return cso->leaveGroup(ia);
-		}
+    /**
+     * Leave a multicast group.
+     *
+     * @param ia address of the multicast group
+     * @return error code from the socket operation
+     */
+    inline Socket::Error
+    leaveGroup(const IPV6Multicast& ia)
+        {
+            Socket::Error error = dso->setMulticast(false);
+            if ( error ) return error;
+            error = dso->leaveGroup(ia);
+            if ( error ) return error;
+            error = cso->setMulticast(false);
+            if ( error ) return error;
+            return cso->leaveGroup(ia);
+        }
 
-	/**
-	 * Set the value of the TTL field in the sent packets.
-	 *
-	 * @param ttl Time To Live
-	 * @return error code from the socket operation
-	 */
-	inline Socket::Error
-	setMcastTTL(uint8 ttl)
-		{
-			Socket::Error error = dso->setMulticast(true);
-			if ( error ) return error;
-			error = dso->setTimeToLive(ttl);
-			if ( error ) return error;
-			error = cso->setMulticast(true);
-			if ( error ) return error;
-			return cso->setTimeToLive(ttl);
-		}
+    /**
+     * Set the value of the TTL field in the sent packets.
+     *
+     * @param ttl Time To Live
+     * @return error code from the socket operation
+     */
+    inline Socket::Error
+    setMcastTTL(uint8 ttl)
+        {
+            Socket::Error error = dso->setMulticast(true);
+            if ( error ) return error;
+            error = dso->setTimeToLive(ttl);
+            if ( error ) return error;
+            error = cso->setMulticast(true);
+            if ( error ) return error;
+            return cso->setTimeToLive(ttl);
+        }
 
-	/**
-	 * Ensure a port number is odd. If it is an even number, return
-	 * the next lower (odd) port number.
-	 *
-	 * @param port number to filter
-	 * @return filtered (odd) port number
-	 */
-	inline tpport_t
-	odd_port(tpport_t port)
-		{ return (port & 0x01)? (port) : (port - 1); }
+    /**
+     * Ensure a port number is odd. If it is an even number, return
+     * the next lower (odd) port number.
+     *
+     * @param port number to filter
+     * @return filtered (odd) port number
+     */
+    inline tpport_t
+    odd_port(tpport_t port)
+        { return (port & 0x01)? (port) : (port - 1); }
 
-	/**
-	 * Ensure a port number is even. If it is an odd number, return
-	 * the next lower (even) port number.
-	 *
-	 * @param port number to filter
-	 * @return filtered (even) port number
-	 */
-	inline tpport_t
-	even_port(tpport_t port)
-		{ return (port & 0x01)? (port - 1) : (port); }
+    /**
+     * Ensure a port number is even. If it is an odd number, return
+     * the next lower (even) port number.
+     *
+     * @param port number to filter
+     * @return filtered (even) port number
+     */
+    inline tpport_t
+    even_port(tpport_t port)
+        { return (port & 0x01)? (port - 1) : (port); }
 
-	tpport_t dataBasePort;
-	tpport_t controlBasePort;
+    tpport_t dataBasePort;
+    tpport_t controlBasePort;
 
 protected:
-	RTPDataChannel* dso;
-	RTCPChannel* cso;
-	friend class RTPSessionBaseHandler;
+    RTPDataChannel* dso;
+    RTCPChannel* cso;
+    friend class RTPSessionBaseHandler;
 };
 
 /**
@@ -978,37 +970,37 @@
  class RTCPChannel = DualRTPUDPIPv6Channel,
  class ServiceQueue = AVPQueue>
 class __EXPORT SingleThreadRTPSessionIPV6 :
-	protected Thread,
-	public TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
+    protected Thread,
+    public TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
 {
 public:
-	SingleThreadRTPSessionIPV6(const IPV6Host& ia,
-				   tpport_t dataPort = DefaultRTPDataPort,
-				   tpport_t controlPort = 0,
-				   int pri = 0,
-				   uint32 memberssize =
-				   MembershipBookkeeping::defaultMembersHashSize,
-				   RTPApplication& app = defaultApplication()
+    SingleThreadRTPSessionIPV6(const IPV6Host& ia,
+                   tpport_t dataPort = DefaultRTPDataPort,
+                   tpport_t controlPort = 0,
+                   int pri = 0,
+                   uint32 memberssize =
+                   MembershipBookkeeping::defaultMembersHashSize,
+                   RTPApplication& app = defaultApplication()
 #if defined(_MSC_VER) && _MSC_VER >= 1300
-		);
+        );
 #else
-	):
-	Thread(pri),
-	TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
-	(ia,dataPort,controlPort,memberssize,app)
+    ):
+    Thread(pri),
+    TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
+    (ia,dataPort,controlPort,memberssize,app)
 { }
 #endif
 
 SingleThreadRTPSessionIPV6(const IPV6Multicast& ia,
-			   tpport_t dataPort = DefaultRTPDataPort,
-			   tpport_t controlPort = 0,
-			   int pri = 0,
-			   uint32 memberssize =
-			   MembershipBookkeeping::defaultMembersHashSize,
-			   RTPApplication& app = defaultApplication(),
-			   uint32 iface = 0
+               tpport_t dataPort = DefaultRTPDataPort,
+               tpport_t controlPort = 0,
+               int pri = 0,
+               uint32 memberssize =
+               MembershipBookkeeping::defaultMembersHashSize,
+               RTPApplication& app = defaultApplication(),
+               uint32 iface = 0
 #if defined(_MSC_VER) && _MSC_VER >= 1300
-	);
+    );
 #else
         ):
         Thread(pri),
@@ -1038,25 +1030,25 @@
 
 protected:
 inline void enableStack(void)
-{TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::enableStack();}
+{TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::enableStack();}
 
 inline void disableStack(void)
-{TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::disableStack();}
+{TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::disableStack();}
 
 inline microtimeout_t getSchedulingTimeout(void)
-{return TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::getSchedulingTimeout();}
+{return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::getSchedulingTimeout();}
 
 inline void controlReceptionService(void)
-{TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::controlReceptionService();}
+{TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::controlReceptionService();}
 
 inline void controlTransmissionService(void)
-{TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::controlTransmissionService();}
+{TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::controlTransmissionService();}
 
 inline timeval getRTCPCheckInterval(void)
-{return TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::getRTCPCheckInterval();}
+{return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::getRTCPCheckInterval();}
 
 inline size_t dispatchDataPacket(void)
-{return TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::dispatchDataPacket();}
+{return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::dispatchDataPacket();}
 
 #if defined(_MSC_VER) && _MSC_VER >= 1300
 virtual void run(void);
@@ -1070,7 +1062,7 @@
 {return;}
 
 virtual bool isPendingData(microtimeout_t timeout)
-{return TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::isPendingData(timeout);}
+{return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::isPendingData(timeout);}
 
 /**
  * Single runnable method for this RTP stacks, schedules
@@ -1078,46 +1070,40 @@
  **/
 virtual void run(void)
 {
-	microtimeout_t timeout = 0;
-	while ( ServiceQueue::isActive() ) {
-		if ( timeout < 1000 ){ // !(timeout/1000)
-			timeout = getSchedulingTimeout();
-		}
-		setCancel(cancelDeferred);
-		controlReceptionService();
-		controlTransmissionService();
-		setCancel(cancelImmediate);
-		microtimeout_t maxWait =
-			timeval2microtimeout(getRTCPCheckInterval());
-		// make sure the scheduling timeout is
-		// <= the check interval for RTCP
-		// packets
-		timeout = (timeout > maxWait)? maxWait : timeout;
-		if ( timeout < 1000 ) { // !(timeout/1000)
-			setCancel(cancelDeferred);
-			dispatchDataPacket();
-			setCancel(cancelImmediate);
-			timerTick();
-		} else {
-			if ( isPendingData(timeout/1000) ) {
-				setCancel(cancelDeferred);
-				takeInDataPacket();
-				setCancel(cancelImmediate);
-			}
-			timeout = 0;
-		}
-	}
-	dispatchBYE("GNU ccRTP stack finishing.");
+    microtimeout_t timeout = 0;
+    while ( ServiceQueue::isActive() ) {
+        if ( timeout < 1000 ){ // !(timeout/1000)
+            timeout = getSchedulingTimeout();
+        }
+        controlReceptionService();
+        controlTransmissionService();
+        microtimeout_t maxWait =
+            timeval2microtimeout(getRTCPCheckInterval());
+        // make sure the scheduling timeout is
+        // <= the check interval for RTCP
+        // packets
+        timeout = (timeout > maxWait)? maxWait : timeout;
+        if ( timeout < 1000 ) { // !(timeout/1000)
+            dispatchDataPacket();
+            timerTick();
+        } else {
+            if ( isPendingData(timeout/1000) ) {
+                takeInDataPacket();
+            }
+            timeout = 0;
+        }
+    }
+    dispatchBYE("GNU ccRTP stack finishing.");
         Thread::exit();
 }
 
 #endif
 
 inline size_t takeInDataPacket(void)
-{return TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::takeInDataPacket();}
+{return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::takeInDataPacket();}
 
 inline size_t dispatchBYE(const std::string &str)
-{return TRTPSessionBase<RTPDataChannel,RTCPChannel,ServiceQueue>::dispatchBYE(str);}
+{return TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>::dispatchBYE(str);}
 };
 
 /**
@@ -1146,16 +1132,14 @@
  * @short Symmetric UDP/IPv6 RTP session scheduled by one thread of execution.
  **/
  typedef SingleThreadRTPSessionIPV6<SymmetricRTPChannelIPV6,
-				    SymmetricRTPChannelIPV6> SymmetricRTPSessionIPV6;
+                    SymmetricRTPChannelIPV6> SymmetricRTPSessionIPV6;
 
 
 #endif
 
 /** @}*/ // sessions
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  //CCXX_RTP_RTP_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/rtppkt.h b/jni/libccrtp/sources/src/ccrtp/rtppkt.h
index 8a6ae6e..20809f0 100644
--- a/jni/libccrtp/sources/src/ccrtp/rtppkt.h
+++ b/jni/libccrtp/sources/src/ccrtp/rtppkt.h
@@ -35,16 +35,14 @@
 // If you do not wish that, delete this exception notice.
 //
 
-#ifndef	CCXX_RTP_RTPPKT_H_
+#ifndef CCXX_RTP_RTPPKT_H_
 #define CCXX_RTP_RTPPKT_H_
 
 #include <ccrtp/base.h>
 #include <ccrtp/formats.h>
 #include <ccrtp/CryptoContext.h>
 
-#ifdef CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @file rtppkt.h
@@ -75,221 +73,221 @@
 class  __EXPORT RTPPacket
 {
 private:
-	struct RTPFixedHeader;
-	struct RTPHeaderExt;
+    struct RTPFixedHeader;
+    struct RTPHeaderExt;
 
 public:
-	/**
-	 * Constructor, construct a packet object given the memory
-	 * zone its content (header and payload) is stored. Commonly
-	 * used to build RTPPacket objects from incoming data.
-	 *
-	 * @param block whole packet
-	 * @param len total length (header + payload + padding) of the
-	 *        packet
-	 * @param duplicate whether to memcopy the packet. At present,
-	 *        this feature is not used.
-	 * @note used in IncomingRTPPkt.
-	 **/
-	RTPPacket(const unsigned char* const block, size_t len,
-		  bool duplicate = false);
+    /**
+     * Constructor, construct a packet object given the memory
+     * zone its content (header and payload) is stored. Commonly
+     * used to build RTPPacket objects from incoming data.
+     *
+     * @param block whole packet
+     * @param len total length (header + payload + padding) of the
+     *        packet
+     * @param duplicate whether to memcopy the packet. At present,
+     *        this feature is not used.
+     * @note used in IncomingRTPPkt.
+     **/
+    RTPPacket(const unsigned char* const block, size_t len,
+          bool duplicate = false);
 
-	/**
-	 * Construct a packet object without specifying its real
-	 * content yet. Commonly used for outgoing packets. Header
-	 * fields and payload must be filled in by another methods or
-	 * by a derived constructor.
-	 *
-	 * @param hdrlen length of the header (including CSRC and extension).
-	 * @param plen payload length.
-	 * @param paddinglen pad packet to a multiple of paddinglen
-	 * @note used in OutgoingRTPPkt.
-	 */
+    /**
+     * Construct a packet object without specifying its real
+     * content yet. Commonly used for outgoing packets. Header
+     * fields and payload must be filled in by another methods or
+     * by a derived constructor.
+     *
+     * @param hdrlen length of the header (including CSRC and extension).
+     * @param plen payload length.
+     * @param paddinglen pad packet to a multiple of paddinglen
+     * @note used in OutgoingRTPPkt.
+     */
         RTPPacket(size_t hdrlen, size_t plen, uint8 paddinglen, CryptoContext* pcc= NULL);
 
-	/**
-	 * Get the length of the header, including contributing
-	 * sources identifiers and header extension, if present.
-	 *
-	 * @return number of octets.
-	 **/
-	inline uint32
-	getHeaderSize() const
-	{ return hdrSize; }
+    /**
+     * Get the length of the header, including contributing
+     * sources identifiers and header extension, if present.
+     *
+     * @return number of octets.
+     **/
+    inline uint32
+    getHeaderSize() const
+    { return hdrSize; }
 
-	/**
-	 * @return pointer to the payload section of the packet.
-	 **/
-	inline const uint8* const
-	getPayload() const
-	{ return (uint8*)(buffer + getHeaderSize()); }
+    /**
+     * @return pointer to the payload section of the packet.
+     **/
+    inline const uint8* const
+    getPayload() const
+    { return (uint8*)(buffer + getHeaderSize()); }
 
-	/**
-	 * @return length of the payload section, in octets.
-	 **/
-	inline uint32
-	getPayloadSize() const
-	{ return payloadSize; }
+    /**
+     * @return length of the payload section, in octets.
+     **/
+    inline uint32
+    getPayloadSize() const
+    { return payloadSize; }
 
-	/**
-	 * @return value of the PT header field.
-	 **/
-	inline PayloadType
-	getPayloadType() const
-	{ return static_cast<PayloadType>(getHeader()->payload); }
+    /**
+     * @return value of the PT header field.
+     **/
+    inline PayloadType
+    getPayloadType() const
+    { return static_cast<PayloadType>(getHeader()->payload); }
 
-	/**
-	 * @return value of the sequence number header field, in host order.
-	 **/
-	inline uint16
-	getSeqNum() const
-	{ return cachedSeqNum; }
+    /**
+     * @return value of the sequence number header field, in host order.
+     **/
+    inline uint16
+    getSeqNum() const
+    { return cachedSeqNum; }
 
-	/**
-	 * @return packet timestamp in host order.
-	 **/
-	inline uint32
-	getTimestamp() const
-	{ return cachedTimestamp; }
+    /**
+     * @return packet timestamp in host order.
+     **/
+    inline uint32
+    getTimestamp() const
+    { return cachedTimestamp; }
 
-	/**
-	 * @return RTP protocol version of packet.
-	 **/
-	inline uint8
-	getProtocolVersion() const
-	{ return getHeader()->version; }
+    /**
+     * @return RTP protocol version of packet.
+     **/
+    inline uint8
+    getProtocolVersion() const
+    { return getHeader()->version; }
 
-	/**
-	 * Ask whether the packet contains padding bytes at the end
-	 * @return true if the header padding bit is 1.
-	 **/
-	inline bool
-	isPadded() const
-	{ return getHeader()->padding; }
+    /**
+     * Ask whether the packet contains padding bytes at the end
+     * @return true if the header padding bit is 1.
+     **/
+    inline bool
+    isPadded() const
+    { return getHeader()->padding; }
 
-	/**
-	 * Get the number of octets padding the end of the payload
-	 * section.
-	 *
-	 * @return Padding length in octets.
-	 **/
-	inline uint8
-	getPaddingSize() const
-	{ return buffer[total - 1]; }
+    /**
+     * Get the number of octets padding the end of the payload
+     * section.
+     *
+     * @return Padding length in octets.
+     **/
+    inline uint8
+    getPaddingSize() const
+    { return buffer[total - 1]; }
 
-	/**
-	 * Ask whether the packet is marked (for isntance, is a new
-	 * talk spurt in some audio profiles).
-	 *
-	 * @return true is the header marker bit is 1.
-	 **/
-	inline bool
-	isMarked() const
-	{ return getHeader()->marker; }
+    /**
+     * Ask whether the packet is marked (for isntance, is a new
+     * talk spurt in some audio profiles).
+     *
+     * @return true is the header marker bit is 1.
+     **/
+    inline bool
+    isMarked() const
+    { return getHeader()->marker; }
 
-	/**
-	 * Ask whether the packet contains header extensions.
-	 *
-	 * @return true if the header extension bit is 1.
-	 **/
-	inline bool
-	isExtended() const
-	{ return getHeader()->extension; }
+    /**
+     * Ask whether the packet contains header extensions.
+     *
+     * @return true if the header extension bit is 1.
+     **/
+    inline bool
+    isExtended() const
+    { return getHeader()->extension; }
 
-	/**
-	 * Get the number of contributing sources specified in the
-	 * packet header.
-	 **/
-	inline uint16
-	getCSRCsCount() const
-	{ return getHeader()->cc; }
+    /**
+     * Get the number of contributing sources specified in the
+     * packet header.
+     **/
+    inline uint16
+    getCSRCsCount() const
+    { return getHeader()->cc; }
 
-	/**
-	 * Get the 32-bit identifiers of the contributing sources for
-	 * the packet as an array, of length getCSRCsCount().
-	 *
-	 * @return An array of CSRC identifiers as they are in the
-	 * packet (in network order).
-	 **/
-	inline const uint32*
-	getCSRCs() const
-	{ return static_cast<const uint32*>(&(getHeader()->sources[1])); }
+    /**
+     * Get the 32-bit identifiers of the contributing sources for
+     * the packet as an array, of length getCSRCsCount().
+     *
+     * @return An array of CSRC identifiers as they are in the
+     * packet (in network order).
+     **/
+    inline const uint32*
+    getCSRCs() const
+    { return static_cast<const uint32*>(&(getHeader()->sources[1])); }
 
-	/**
-	 * Get the first 16 bits (in network order) of the header of
-	 * the RTP header extension. Its meaning is undefined at this
-	 * level.
-	 *
-	 * @return 0 if the packet has no header extension, otherwise
-	 *         the first 16 bits of the header extension, in
-	 *         network order.
-	 *
-	 * @note 0 could be a valid value for the first 16 bits, in
-	 *         that case RTPPacket::isExtended() should be use.
-	 **/
-	inline uint16
-	getHdrExtUndefined() const
-	{ return (isExtended()? getHeaderExt()->undefined : 0); }
+    /**
+     * Get the first 16 bits (in network order) of the header of
+     * the RTP header extension. Its meaning is undefined at this
+     * level.
+     *
+     * @return 0 if the packet has no header extension, otherwise
+     *         the first 16 bits of the header extension, in
+     *         network order.
+     *
+     * @note 0 could be a valid value for the first 16 bits, in
+     *         that case RTPPacket::isExtended() should be use.
+     **/
+    inline uint16
+    getHdrExtUndefined() const
+    { return (isExtended()? getHeaderExt()->undefined : 0); }
 
-	/**
-	 * Get the length (in octets) of the data contained in the
-	 * header extension. Note that this length does not include
-	 * the four octets at the beginning of the header extension.
-	 *
-	 * @return 0 if the packet has no header extension, otherwise
-	 *         the length.
-	 *
-	 * @note 0 is a valid value for this field, so
-	 *       RTPPacket::isExtended() should be used.
-	 **/
-	inline uint32
-	getHdrExtSize() const
-	{ return (isExtended()?
-		  (static_cast<uint32>(ntohs(getHeaderExt()->length)) << 2) :
-		  0); }
+    /**
+     * Get the length (in octets) of the data contained in the
+     * header extension. Note that this length does not include
+     * the four octets at the beginning of the header extension.
+     *
+     * @return 0 if the packet has no header extension, otherwise
+     *         the length.
+     *
+     * @note 0 is a valid value for this field, so
+     *       RTPPacket::isExtended() should be used.
+     **/
+    inline uint32
+    getHdrExtSize() const
+    { return (isExtended()?
+          (static_cast<uint32>(ntohs(getHeaderExt()->length)) << 2) :
+          0); }
 
-	/**
-	 * Get the content of the header extension.
-	 *
-	 * @return NULL if the packet has no header extension, otherwise
-	 *         a pointer to the packet header extension content.
-	 **/
-	inline const unsigned char*
-	getHdrExtContent() const
-	{ return (isExtended() ?
-		  (reinterpret_cast<const unsigned char*>(getHeaderExt()) +
-		   sizeof(RTPHeaderExt)) :
-		  NULL); }
+    /**
+     * Get the content of the header extension.
+     *
+     * @return NULL if the packet has no header extension, otherwise
+     *         a pointer to the packet header extension content.
+     **/
+    inline const unsigned char*
+    getHdrExtContent() const
+    { return (isExtended() ?
+          (reinterpret_cast<const unsigned char*>(getHeaderExt()) +
+           sizeof(RTPHeaderExt)) :
+          NULL); }
 
-	/**
-	 * Get the raw packet as it will be sent through the network.
-	 *
-	 * @return memory zone where the raw packet structure is
-	 *         stored in.
-	 **/
-	inline const unsigned char* const
-	getRawPacket() const
-	{ return buffer; }
+    /**
+     * Get the raw packet as it will be sent through the network.
+     *
+     * @return memory zone where the raw packet structure is
+     *         stored in.
+     **/
+    inline const unsigned char* const
+    getRawPacket() const
+    { return buffer; }
 
-	/**
-	 * Get the raw packet length, including header, extension,
-	 * payload and padding.
-	 *
-	 * @return size of the raw packet structure.
-	 **/
-	inline uint32
-	getRawPacketSize() const
-	{ return total; }
+    /**
+     * Get the raw packet length, including header, extension,
+     * payload and padding.
+     *
+     * @return size of the raw packet structure.
+     **/
+    inline uint32
+    getRawPacketSize() const
+    { return total; }
 
         inline uint32
         getRawPacketSizeSrtp() const
         { return total + srtpLength; }
 
         inline size_t
-	getSizeOfFixedHeader() const
-	{ return sizeof(RTPFixedHeader); }
-	
-	/**
+    getSizeOfFixedHeader() const
+    { return sizeof(RTPFixedHeader); }
+
+    /**
      * Re-compute payload length.
      *
      * This recomputation may be necessary in case of SRTP. We need to decrypt
@@ -297,68 +295,68 @@
      * @c incqueue.cpp
      *
      * @param padding
-     *     If true then set padding flag in RTP header and re-compute 
+     *     If true then set padding flag in RTP header and re-compute
      *     payloadSize.
      */
     void reComputePayLength(bool padding);
-    
+
 protected:
-	/**
-	 * Destructor, free the buffer provided in the constructor.
-	 **/
-	inline virtual ~RTPPacket()
-	{ endPacket(); }
+    /**
+     * Destructor, free the buffer provided in the constructor.
+     **/
+    inline virtual ~RTPPacket()
+    { endPacket(); }
 
-	/**
-	 * Free memory allocated for the packet.
-	 **/
-	void
-	endPacket();
+    /**
+     * Free memory allocated for the packet.
+     **/
+    void
+    endPacket();
 
-	/**
-	 * Return low level structure for the header of the packet.
-	 *
-	 * @return RTPFixedHeader pointer to the header of the packet.
-	 **/
-	inline RTPFixedHeader*
-	getHeader() const
-	{ return reinterpret_cast<RTPFixedHeader*>(buffer); }
+    /**
+     * Return low level structure for the header of the packet.
+     *
+     * @return RTPFixedHeader pointer to the header of the packet.
+     **/
+    inline RTPFixedHeader*
+    getHeader() const
+    { return reinterpret_cast<RTPFixedHeader*>(buffer); }
 
-	inline void
-	setExtension(bool e)
-	{ getHeader()->extension = e; }
+    inline void
+    setExtension(bool e)
+    { getHeader()->extension = e; }
 
-	/**
-	 * Get a pointer to RTPHeaderExt pointing after the RTP header
-	 * (fixed part plus contributing sources). No check for
-	 * for the X bit is done.
-	 *
-	 * @return header extension if present, garbage if not.
-	 **/
-	inline const RTPHeaderExt*
-	getHeaderExt() const
-	{
+    /**
+     * Get a pointer to RTPHeaderExt pointing after the RTP header
+     * (fixed part plus contributing sources). No check for
+     * for the X bit is done.
+     *
+     * @return header extension if present, garbage if not.
+     **/
+    inline const RTPHeaderExt*
+    getHeaderExt() const
+    {
          uint32 fixsize = sizeof(RTPFixedHeader) + (getHeader()->cc << 2);
-	 return (reinterpret_cast<RTPHeaderExt*>(buffer + fixsize));
-	}
+     return (reinterpret_cast<RTPHeaderExt*>(buffer + fixsize));
+    }
 
-	/**
-	 * Obtain the absolute timestamp carried in the packet header.
-	 *
-	 * @return 32-bit timestamp in host order.
-	 **/
-	inline uint32
-	getRawTimestamp() const
-	{ return ntohl(getHeader()->timestamp); }
+    /**
+     * Obtain the absolute timestamp carried in the packet header.
+     *
+     * @return 32-bit timestamp in host order.
+     **/
+    inline uint32
+    getRawTimestamp() const
+    { return ntohl(getHeader()->timestamp); }
 
-	inline void
-	setbuffer(const void* src, size_t len, size_t pos)
-	{ memcpy(buffer + pos,src,len); }
+    inline void
+    setbuffer(const void* src, size_t len, size_t pos)
+    { memcpy(buffer + pos,src,len); }
 
-	/// Packet sequence number in host order.
-	uint16 cachedSeqNum;
-	/// Packet timestamp in host order (includes initial shift).
-	uint32 cachedTimestamp;
+    /// Packet sequence number in host order.
+    uint16 cachedSeqNum;
+    /// Packet timestamp in host order (includes initial shift).
+    uint32 cachedTimestamp;
 
         /**
          * Offset into packet memory pointing to area for SRTP data.
@@ -382,119 +380,119 @@
         uint32 payloadSize;
 
 private:
-	/// packet in memory
-	unsigned char* buffer;
-	/// size of the header, including contributing sources and extensions
-	uint32 hdrSize;
-	/// whether the object was contructed with duplicated = true
-	bool duplicated;
+    /// packet in memory
+    unsigned char* buffer;
+    /// size of the header, including contributing sources and extensions
+    uint32 hdrSize;
+    /// whether the object was contructed with duplicated = true
+    bool duplicated;
 
-#ifdef	CCXX_PACKED
+#ifdef  CCXX_PACKED
 #pragma pack(1)
 #endif
-	/**
-	 * @struct RTPFixedHeader
-	 * @short RTP fixed header as it is send through the network.
-	 *
-	 * A low-level representation for generic RTP packet header as
-	 * defined in RFC 1889. A packet consists of the fixed RTP
-	 * header, a possibly empty list of contributing sources and
-	 * the payload. Header contents are kept in network (big
-	 * endian) order.
-	 **/
-	struct RTPFixedHeader
-	{
-#if	__BYTE_ORDER == __BIG_ENDIAN
-		/// For big endian boxes
-		unsigned char version:2;       ///< Version, currently 2
-		unsigned char padding:1;       ///< Padding bit
-		unsigned char extension:1;     ///< Extension bit
-		unsigned char cc:4;            ///< CSRC count
-		unsigned char marker:1;        ///< Marker bit
-		unsigned char payload:7;       ///< Payload type
+    /**
+     * @struct RTPFixedHeader
+     * @short RTP fixed header as it is send through the network.
+     *
+     * A low-level representation for generic RTP packet header as
+     * defined in RFC 1889. A packet consists of the fixed RTP
+     * header, a possibly empty list of contributing sources and
+     * the payload. Header contents are kept in network (big
+     * endian) order.
+     **/
+    struct RTPFixedHeader
+    {
+#if __BYTE_ORDER == __BIG_ENDIAN
+        /// For big endian boxes
+        unsigned char version:2;       ///< Version, currently 2
+        unsigned char padding:1;       ///< Padding bit
+        unsigned char extension:1;     ///< Extension bit
+        unsigned char cc:4;            ///< CSRC count
+        unsigned char marker:1;        ///< Marker bit
+        unsigned char payload:7;       ///< Payload type
 #else
-		/// For little endian boxes
-		unsigned char cc:4;            ///< CSRC count
-		unsigned char extension:1;     ///< Extension bit
-		unsigned char padding:1;       ///< Padding bit
-		unsigned char version:2;       ///< Version, currently 2
-		unsigned char payload:7;       ///< Payload type
-		unsigned char marker:1;        ///< Marker bit
+        /// For little endian boxes
+        unsigned char cc:4;            ///< CSRC count
+        unsigned char extension:1;     ///< Extension bit
+        unsigned char padding:1;       ///< Padding bit
+        unsigned char version:2;       ///< Version, currently 2
+        unsigned char payload:7;       ///< Payload type
+        unsigned char marker:1;        ///< Marker bit
 #endif
-		uint16 sequence;        ///< sequence number
-		uint32 timestamp;       ///< timestamp
-		uint32 sources[1];      ///< contributing sources
-	};
+        uint16 sequence;        ///< sequence number
+        uint32 timestamp;       ///< timestamp
+        uint32 sources[1];      ///< contributing sources
+    };
 
-	/**
- 	 * @struct RFC2833Payload
-	 * @short a structure defining RFC2833 Telephony events.
-	 *
-	 * structure to define RFC2833 telephony events in RTP.  You can
-	 * use this by recasing the pointer returned by getPayload().
-	 */
+    /**
+     * @struct RFC2833Payload
+     * @short a structure defining RFC2833 Telephony events.
+     *
+     * structure to define RFC2833 telephony events in RTP.  You can
+     * use this by recasing the pointer returned by getPayload().
+     */
 
 public:
-	struct RFC2833Payload
-	{
+    struct RFC2833Payload
+    {
 #if __BYTE_ORDER == __BIG_ENDIAN
-        	uint8 event : 8;
-        	bool ebit : 1;
-        	bool rbit : 1;
-        	uint8 vol : 6;
-        	uint16 duration : 16;
+            uint8 event : 8;
+            bool ebit : 1;
+            bool rbit : 1;
+            uint8 vol : 6;
+            uint16 duration : 16;
 #else
-        	uint8 event : 8;
-        	uint8 vol : 6;
-        	bool rbit : 1;
-        	bool ebit : 1;
-        	uint16 duration : 16;
+            uint8 event : 8;
+            uint8 vol : 6;
+            bool rbit : 1;
+            bool ebit : 1;
+            uint16 duration : 16;
 #endif
-	};
+    };
 
 private:
-	/**
-	 * @struct RTPHeaderExt
-	 *
-	 * Fixed component of the variable-length header extension,
-	 * appended to the fixed header, after the CSRC list, when X
-	 * == 1.
-	 **/
-	struct RTPHeaderExt
-	{
-		uint16 undefined; ///< to be defined
-		uint16 length;    ///< number of 32-bit words in the extension
-	};
-#ifdef	CCXX_PACKED
+    /**
+     * @struct RTPHeaderExt
+     *
+     * Fixed component of the variable-length header extension,
+     * appended to the fixed header, after the CSRC list, when X
+     * == 1.
+     **/
+    struct RTPHeaderExt
+    {
+        uint16 undefined; ///< to be defined
+        uint16 length;    ///< number of 32-bit words in the extension
+    };
+#ifdef  CCXX_PACKED
 #pragma pack()
 #endif
 
-	/* definitions for access to most common 2833 fields... */
+    /* definitions for access to most common 2833 fields... */
 
 public:
-	/**
-	 * Fetch a raw 2833 packet.
-	 *
-	 * @return low level 2833 data structure.
-	 */
-	inline struct RFC2833Payload *getRaw2833Payload(void)
-		{return (struct RFC2833Payload *)getPayload();}
+    /**
+     * Fetch a raw 2833 packet.
+     *
+     * @return low level 2833 data structure.
+     */
+    inline struct RFC2833Payload *getRaw2833Payload(void)
+        {return (struct RFC2833Payload *)getPayload();}
 
-	/**
-	 * Fetch 2833 duration field.
-	 *
-	 * @return 2833 duration in native host machine byte order.
-	 */
-	inline uint16 get2833Duration(void)
-		{return ntohs(getRaw2833Payload()->duration);}
+    /**
+     * Fetch 2833 duration field.
+     *
+     * @return 2833 duration in native host machine byte order.
+     */
+    inline uint16 get2833Duration(void)
+        {return ntohs(getRaw2833Payload()->duration);}
 
-	/**
-	 * Set 2833 duration field.
-	 *
-	 * @param timestamp to use, native host machine byte order.
-	 */
-	inline void set2833Duration(uint16 timestamp)
-		{getRaw2833Payload()->duration = htons(timestamp);}
+    /**
+     * Set 2833 duration field.
+     *
+     * @param timestamp to use, native host machine byte order.
+     */
+    inline void set2833Duration(uint16 timestamp)
+        {getRaw2833Payload()->duration = htons(timestamp);}
 };
 
 /**
@@ -510,143 +508,143 @@
 class __EXPORT OutgoingRTPPkt : public RTPPacket
 {
 public:
-	/**
-	 * Construct a new packet to be sent, containing several
-	 * contributing source identifiers, header extensions and
-	 * payload.
+    /**
+     * Construct a new packet to be sent, containing several
+     * contributing source identifiers, header extensions and
+     * payload.
          *
          * A new copy in memory (holding all this components
-	 * along with the fixed header) is created. If the pointer
+     * along with the fixed header) is created. If the pointer
          * to the SRTP CryptoContext is not NULL and holds a CryptoContext
          * for the SSRC take the SSRC data into account when computing
          * the required memory buffer.
-	 *
-	 * @param csrcs array of countributing source 32-bit
-	 *        identifiers, in host order.
-	 * @param numcsrc number of CSRC identifiers in the array.
-	 * @param hdrext whole header extension.
-	 * @param hdrextlen size of whole header extension, in octets.
-	 * @param data payload.
-	 * @param datalen payload length, in octets.
-	 * @param paddinglen pad packet to a multiple of paddinglen.
+     *
+     * @param csrcs array of countributing source 32-bit
+     *        identifiers, in host order.
+     * @param numcsrc number of CSRC identifiers in the array.
+     * @param hdrext whole header extension.
+     * @param hdrextlen size of whole header extension, in octets.
+     * @param data payload.
+     * @param datalen payload length, in octets.
+     * @param paddinglen pad packet to a multiple of paddinglen.
          * @param pcc Pointer to the SRTP CryptoContext, defaults to NULL
          * if not specified.
-	 *
-	 * @note For efficiency purposes, since this constructor is
-	 * valid for all packets but is too complex for the common
-	 * case, two simpler others are provided.
-	 **/
-	OutgoingRTPPkt(const uint32* const csrcs, uint16 numcsrc,
-		       const unsigned char* const hdrext, uint32 hdrextlen,
-		       const unsigned char* const data, size_t datalen,
+     *
+     * @note For efficiency purposes, since this constructor is
+     * valid for all packets but is too complex for the common
+     * case, two simpler others are provided.
+     **/
+    OutgoingRTPPkt(const uint32* const csrcs, uint16 numcsrc,
+               const unsigned char* const hdrext, uint32 hdrextlen,
+               const unsigned char* const data, size_t datalen,
                        uint8 paddinglen= 0, CryptoContext* pcc= NULL);
 
-	/**
-	 * Construct a new packet to be sent, containing several
-	 * contributing source identifiers and payload.
+    /**
+     * Construct a new packet to be sent, containing several
+     * contributing source identifiers and payload.
          *
          * A new copy in
-	 * memory (holding all this components along with the fixed
+     * memory (holding all this components along with the fixed
          * header) is created. If the pointer
          * to the SRTP CryptoContext is not NULL and holds a CryptoContext
          * for the SSRC take the SSRC data into account when computing
          * the required memory buffer.
-	 *
-	 * @param csrcs array of countributing source 32-bit
-	 * identifiers, in host order.
-	 * @param numcsrc number of CSRC identifiers in the array.
-	 * @param data payload.
-	 * @param datalen payload length, in octets.
-	 * @param paddinglen pad packet to a multiple of paddinglen.
+     *
+     * @param csrcs array of countributing source 32-bit
+     * identifiers, in host order.
+     * @param numcsrc number of CSRC identifiers in the array.
+     * @param data payload.
+     * @param datalen payload length, in octets.
+     * @param paddinglen pad packet to a multiple of paddinglen.
          * @param pcc Pointer to the SRTP CryptoContext, defaults to NULL
          * if not specified.
          **/
-	OutgoingRTPPkt(const uint32* const csrcs, uint16 numcsrc,
-		       const unsigned char* const data, size_t datalen,
+    OutgoingRTPPkt(const uint32* const csrcs, uint16 numcsrc,
+               const unsigned char* const data, size_t datalen,
                        uint8 paddinglen= 0, CryptoContext* pcc= NULL);
 
-	/**
-	 * Construct a new packet (fast variant, with no contributing
-	 * sources and no header extension) to be sent.
+    /**
+     * Construct a new packet (fast variant, with no contributing
+     * sources and no header extension) to be sent.
          *
          * A new copy in
          * memory (holding the whole packet) is created. If the pointer
          * to the SRTP CryptoContext is not NULL and holds a CryptoContext
          * for the SSRC take the SSRC data into account when computing
          * the required memory buffer.
-	 *
-	 * @param data payload.
-	 * @param datalen payload length, in octets.
-	 * @param paddinglen pad packet to a multiple of paddinglen.
+     *
+     * @param data payload.
+     * @param datalen payload length, in octets.
+     * @param paddinglen pad packet to a multiple of paddinglen.
          * @param pcc Pointer to the SRTP CryptoContext, defaults to NULL
          * if not specified.
          **/
-	OutgoingRTPPkt(const unsigned char* const data, size_t datalen,
+    OutgoingRTPPkt(const unsigned char* const data, size_t datalen,
                        uint8 paddinglen= 0, CryptoContext* pcc= NULL);
 
-	~OutgoingRTPPkt()
-	{ }
+    ~OutgoingRTPPkt()
+    { }
 
-	/**
-	 * @param pt Packet payload type.
-	 **/
-	inline void
-	setPayloadType(PayloadType pt)
-	{ getHeader()->payload = pt; }
+    /**
+     * @param pt Packet payload type.
+     **/
+    inline void
+    setPayloadType(PayloadType pt)
+    { getHeader()->payload = pt; }
 
-	/**
+    /**
          * Sets the sequence number in the header.
          *
-	 * @param seq Packet sequence number, in host order.
-	 **/
-	inline void
-	setSeqNum(uint16 seq)
-	{
-		cachedSeqNum = seq;
-		getHeader()->sequence = htons(seq);
-	}
+     * @param seq Packet sequence number, in host order.
+     **/
+    inline void
+    setSeqNum(uint16 seq)
+    {
+        cachedSeqNum = seq;
+        getHeader()->sequence = htons(seq);
+    }
 
-	/**
-	 * @param pts Packet timestamp, in host order.
-	 **/
-	inline void
-	setTimestamp(uint32 pts)
-	{
-		cachedTimestamp = pts;
-		getHeader()->timestamp = htonl(pts);
-	}
+    /**
+     * @param pts Packet timestamp, in host order.
+     **/
+    inline void
+    setTimestamp(uint32 pts)
+    {
+        cachedTimestamp = pts;
+        getHeader()->timestamp = htonl(pts);
+    }
 
-	/**
-	 * Set synchronization source numeric identifier.
-	 *
-	 * @param ssrc 32-bit Synchronization SouRCe numeric
-	 * identifier, in host order.
-	 **/
-	inline void
-	setSSRC(uint32 ssrc) const
-	{ getHeader()->sources[0] = htonl(ssrc); }
+    /**
+     * Set synchronization source numeric identifier.
+     *
+     * @param ssrc 32-bit Synchronization SouRCe numeric
+     * identifier, in host order.
+     **/
+    inline void
+    setSSRC(uint32 ssrc) const
+    { getHeader()->sources[0] = htonl(ssrc); }
 
-	/**
-	 * Set synchronization source numeric identifier. Special
-	 * version to save endianness conversion.
-	 *
-	 * @param ssrc 32-bit Synchronization SouRCe numeric
-	 * identifier, in network order.
-	 **/
-	inline void
-	setSSRCNetwork(uint32 ssrc) const
-	{ getHeader()->sources[0] = ssrc; }
+    /**
+     * Set synchronization source numeric identifier. Special
+     * version to save endianness conversion.
+     *
+     * @param ssrc 32-bit Synchronization SouRCe numeric
+     * identifier, in network order.
+     **/
+    inline void
+    setSSRCNetwork(uint32 ssrc) const
+    { getHeader()->sources[0] = ssrc; }
 
-	/**
-	 * Specify the value of the marker bit. By default, the marker
-	 * bit of outgoing packets is false/0. This method allows to
-	 * explicity specify and change that value.
-	 *
-	 * @param mark value for the market bit.
-	 */
-	inline void
-	setMarker(bool mark)
-	{ getHeader()->marker = mark; }
+    /**
+     * Specify the value of the marker bit. By default, the marker
+     * bit of outgoing packets is false/0. This method allows to
+     * explicity specify and change that value.
+     *
+     * @param mark value for the market bit.
+     */
+    inline void
+    setMarker(bool mark)
+    { getHeader()->marker = mark; }
 
         /**
          * Called packet is setup.
@@ -656,39 +654,39 @@
          */
         void protect(uint32 ssrc, CryptoContext* pcc);
 
-	/**
-	 * Outgoing packets are equal if their sequence numbers match.
-	 **/
-	inline bool
-	operator==(const OutgoingRTPPkt &p) const
-	{ return ( this->getSeqNum() == p.getSeqNum() ); }
+    /**
+     * Outgoing packets are equal if their sequence numbers match.
+     **/
+    inline bool
+    operator==(const OutgoingRTPPkt &p) const
+    { return ( this->getSeqNum() == p.getSeqNum() ); }
 
-	/**
-	 * Outgoing packets are not equal if their sequence numbers differ.
-	 **/
-	inline bool
-	operator!=(const OutgoingRTPPkt &p) const
-	{ return ( this->getSeqNum() != p.getSeqNum() ); }
+    /**
+     * Outgoing packets are not equal if their sequence numbers differ.
+     **/
+    inline bool
+    operator!=(const OutgoingRTPPkt &p) const
+    { return ( this->getSeqNum() != p.getSeqNum() ); }
 
 private:
-	/**
-	 * Copy constructor from objects of its same kind, declared
-	 * private to avoid its use.
-	 **/
-	OutgoingRTPPkt(const OutgoingRTPPkt &o);
+    /**
+     * Copy constructor from objects of its same kind, declared
+     * private to avoid its use.
+     **/
+    OutgoingRTPPkt(const OutgoingRTPPkt &o);
 
-	/**
-	 * Assignment operator from objects of its same kind, declared
-	 * private to avoid its use.
-	 **/
-	OutgoingRTPPkt&
-	operator=(const OutgoingRTPPkt &o);
+    /**
+     * Assignment operator from objects of its same kind, declared
+     * private to avoid its use.
+     **/
+    OutgoingRTPPkt&
+    operator=(const OutgoingRTPPkt &o);
 
-	/**
-	 * Set the list of CSRC identifiers in an RTP packet,
-	 * switching host to network order.
-	 */
-	void setCSRCArray(const uint32* const csrcs, uint16 numcsrc);
+    /**
+     * Set the list of CSRC identifiers in an RTP packet,
+     * switching host to network order.
+     */
+    void setCSRCArray(const uint32* const csrcs, uint16 numcsrc);
 
 };
 
@@ -707,41 +705,41 @@
 class __EXPORT IncomingRTPPkt : public RTPPacket
 {
 public:
-	/**
-	 * Build an RTP packet object from a data buffer. This
-	 * constructor first performs a generic RTP data packet header
-	 * check, whose result can be checked via isHeaderValid().
-	 *
-	 * @param block pointer to the buffer the whole packet is stored in.
-	 * @param len length of the whole packet, expressed in octets.
-	 *
-	 * @note If check fails, the packet object is
-	 * incomplete. checking isHeaderValid() is recommended before
-	 * using a new RTPPacket object.
-	 **/
-	IncomingRTPPkt(const unsigned char* block, size_t len);
+    /**
+     * Build an RTP packet object from a data buffer. This
+     * constructor first performs a generic RTP data packet header
+     * check, whose result can be checked via isHeaderValid().
+     *
+     * @param block pointer to the buffer the whole packet is stored in.
+     * @param len length of the whole packet, expressed in octets.
+     *
+     * @note If check fails, the packet object is
+     * incomplete. checking isHeaderValid() is recommended before
+     * using a new RTPPacket object.
+     **/
+    IncomingRTPPkt(const unsigned char* block, size_t len);
 
-	~IncomingRTPPkt()
-	{ }
+    ~IncomingRTPPkt()
+    { }
 
-	/**
-	 * Get validity of this packet
-	 * @return whether the header check performed at construction
-	 *         time ended successfully.
-	 **/
-	inline bool
-	isHeaderValid()
-	{ return headerValid; }
+    /**
+     * Get validity of this packet
+     * @return whether the header check performed at construction
+     *         time ended successfully.
+     **/
+    inline bool
+    isHeaderValid()
+    { return headerValid; }
 
-	/**
-	 * Get synchronization source numeric identifier.
-	 *
-	 * @return 32-bits Synchronization SouRCe numeric identifier,
-	 * in host order.
-	 **/
-	inline uint32
-	getSSRC() const
-	{ return cachedSSRC; }
+    /**
+     * Get synchronization source numeric identifier.
+     *
+     * @return 32-bits Synchronization SouRCe numeric identifier,
+     * in host order.
+     **/
+    inline uint32
+    getSSRC() const
+    { return cachedSSRC; }
 
         /**
          * Unprotect a received packet.
@@ -756,53 +754,51 @@
         int32
         unprotect(CryptoContext* pcc);
 
-	/**
-	 * Two incoming packets are equal if they come from sources
-	 * with the same SSRC and have the same sequence number.
-	 **/
-	inline bool
-	operator==(const IncomingRTPPkt &p) const
-	{ return ( (this->getSeqNum() == p.getSeqNum()) &&
-		   (this->getSSRC() == p.getSSRC()) ); }
+    /**
+     * Two incoming packets are equal if they come from sources
+     * with the same SSRC and have the same sequence number.
+     **/
+    inline bool
+    operator==(const IncomingRTPPkt &p) const
+    { return ( (this->getSeqNum() == p.getSeqNum()) &&
+           (this->getSSRC() == p.getSSRC()) ); }
 
-	/**
-	 * Two incoming packets are not equal if they come from
-	 * different sources or have different sequence numbers.
-	 **/
-	inline bool
-	operator!=(const IncomingRTPPkt &p) const
-	{ return !( *this == p ); }
+    /**
+     * Two incoming packets are not equal if they come from
+     * different sources or have different sequence numbers.
+     **/
+    inline bool
+    operator!=(const IncomingRTPPkt &p) const
+    { return !( *this == p ); }
 
 private:
-	/**
-	 * Copy constructor from objects of its same kind, declared
-	 * private to avoid its use.
-	 **/
-	IncomingRTPPkt(const IncomingRTPPkt &ip);
+    /**
+     * Copy constructor from objects of its same kind, declared
+     * private to avoid its use.
+     **/
+    IncomingRTPPkt(const IncomingRTPPkt &ip);
 
-	/**
-	 * Assignment operator from objects of its same kind, declared
-	 * private to avoid its use.
-	 */
-	IncomingRTPPkt&
-	operator=(const IncomingRTPPkt &ip);
+    /**
+     * Assignment operator from objects of its same kind, declared
+     * private to avoid its use.
+     */
+    IncomingRTPPkt&
+    operator=(const IncomingRTPPkt &ip);
 
-	/// Header validity, checked at construction time.
-	bool headerValid;
-	/// SSRC 32-bit identifier in host order.
-	uint32 cachedSSRC;
-	// Masks for RTP header validation: types matching RTCP SR or
-	// RR must be rejected to avoid accepting misaddressed RTCP
-	// packets.
-	static const uint16 RTP_INVALID_PT_MASK;
-	static const uint16 RTP_INVALID_PT_VALUE;
+    /// Header validity, checked at construction time.
+    bool headerValid;
+    /// SSRC 32-bit identifier in host order.
+    uint32 cachedSSRC;
+    // Masks for RTP header validation: types matching RTCP SR or
+    // RR must be rejected to avoid accepting misaddressed RTCP
+    // packets.
+    static const uint16 RTP_INVALID_PT_MASK;
+    static const uint16 RTP_INVALID_PT_VALUE;
 };
 
 /** @}*/ // rtppacket
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif  // ndef CCXX_RTP_RTPPKT_H_
 
diff --git a/jni/libccrtp/sources/src/ccrtp/sources.h b/jni/libccrtp/sources/src/ccrtp/sources.h
index 86852e1..eb12988 100644
--- a/jni/libccrtp/sources/src/ccrtp/sources.h
+++ b/jni/libccrtp/sources/src/ccrtp/sources.h
@@ -1,27 +1,27 @@
 // Copyright (C) 2001,2002,2003,2004 Federico Montesino Pouzols <fedemp@altern.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 
+// along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// 
+//
 // As a special exception, you may use this file as part of a free software
 // library without restriction.  Specifically, if other files instantiate
 // templates or use macros or inline functions from this file, or you compile
 // this file and link it with other files to produce an executable, this
 // file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however    
+// the GNU General Public License.  This exception does not however
 // invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.    
+// the GNU General Public License.
 //
 // This exception applies only to the code released under the name GNU
 // ccRTP.  If you copy code from other releases into a copy of GNU
@@ -35,21 +35,19 @@
 // If you do not wish that, delete this exception notice.
 //
 
-/** 
- * @file sources.h 
+/**
+ * @file sources.h
  *
  * @short Sources of synchronization and participants related clases.
  **/
 
-#ifndef	CCXX_RTP_SOURCES_H_
+#ifndef CCXX_RTP_SOURCES_H_
 #define CCXX_RTP_SOURCES_H_
 
 #include <string>
 #include <ccrtp/rtcppkt.h>
 
-#ifdef	CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 /**
  * @defgroup sources Participants and synchronization sources.
@@ -67,40 +65,40 @@
 class __EXPORT SDESItemsHolder
 {
 public:
-	const std::string&
-	getItem(SDESItemType type) const;
+    const std::string&
+    getItem(SDESItemType type) const;
 
-	inline const std::string& 
-	getPRIVPrefix() const
-	{ return sdesItems[SDESItemTypeEND]; }
+    inline const std::string&
+    getPRIVPrefix() const
+    { return sdesItems[SDESItemTypeEND]; }
 
-	void
-	setItem(SDESItemType item, const std::string& val);
-	
-	inline void
-	setPRIVPrefix(const std::string& val)
-	{ sdesItems[SDESItemTypeEND] = val; }
+    void
+    setItem(SDESItemType item, const std::string& val);
+
+    inline void
+    setPRIVPrefix(const std::string& val)
+    { sdesItems[SDESItemTypeEND] = val; }
 
 protected:
-	SDESItemsHolder()
-	{ }
-	
-	inline virtual ~SDESItemsHolder()
-	{ }
-	
+    SDESItemsHolder()
+    { }
+
+    inline virtual ~SDESItemsHolder()
+    { }
+
 private:
-	// SDES items for a participant.
-	// sdesItems[0] (== sdesItems[SDESItemTypeEND]) holds the prefix
-	// value for the PRIV item. The rest of entries hold the
-	// correponding SDES item value.
-	std::string sdesItems[SDESItemTypeLast + 1];
+    // SDES items for a participant.
+    // sdesItems[0] (== sdesItems[SDESItemTypeEND]) holds the prefix
+    // value for the PRIV item. The rest of entries hold the
+    // correponding SDES item value.
+    std::string sdesItems[SDESItemTypeLast + 1];
 };
 
-/** 
+/**
  * @class Participant
  * @short A class of objects representing remote participants (RTP
  * applications) in a multimedia session.
- * 
+ *
  * Any RTP socket/queue class that directly or indirectly inherits
  * from QueueRTCPManager (and hence has RTCP support) will represent
  * participants from which any RTP or RTCP packet has been received
@@ -117,7 +115,7 @@
  * (for instance, it is included in the destination list), there will
  * be a Participant object that corresponds to the "local participant"
  * (RTPApplication) object.
- * 
+ *
  * @author Federico Montesino Pouzols <fedemp@altern.org>
  *
  * @todo implement reference counting from sources, so that when a
@@ -127,58 +125,58 @@
 class __EXPORT Participant : private SDESItemsHolder
 {
 public:
-	/**
-	 * Get the value of an SDES item. For instance,
-	 * getSDESItem(SDESItemTypeCNAME), return the CNAME of this
-	 * Participant.
-	 *
-	 * @param type type of SDES item to get value of.
-	 *
-	 * @return value of the SDES item as a string. 
-	 * @retval empty string when the value is not known (no RTCP
-	 * packet with the requested SDES item has been received from this
-	 * source).
-	 **/
-	const std::string&
-	getSDESItem(SDESItemType type) const
-	{ return SDESItemsHolder::getItem(type); }
+    /**
+     * Get the value of an SDES item. For instance,
+     * getSDESItem(SDESItemTypeCNAME), return the CNAME of this
+     * Participant.
+     *
+     * @param type type of SDES item to get value of.
+     *
+     * @return value of the SDES item as a string.
+     * @retval empty string when the value is not known (no RTCP
+     * packet with the requested SDES item has been received from this
+     * source).
+     **/
+    const std::string&
+    getSDESItem(SDESItemType type) const
+    { return SDESItemsHolder::getItem(type); }
 
-	/**
-	 * Get the prefix value for the PRIV SDES item.
-	 *
-	 * @return PRIV SDES item prefix as a string.
-	 * @retval empty string when no PRIV SDES item has been
-	 * received from this source.
-	 **/
-	inline const std::string& 
-	getPRIVPrefix() const
-	{ return SDESItemsHolder::getPRIVPrefix(); }
+    /**
+     * Get the prefix value for the PRIV SDES item.
+     *
+     * @return PRIV SDES item prefix as a string.
+     * @retval empty string when no PRIV SDES item has been
+     * received from this source.
+     **/
+    inline const std::string&
+    getPRIVPrefix() const
+    { return SDESItemsHolder::getPRIVPrefix(); }
 
-	/** 
-	 * Construct a new participant.
-	 *
-	 * @param cname Unique CNAME identifier.
-	 **/
-	Participant(const std::string& cname);
+    /**
+     * Construct a new participant.
+     *
+     * @param cname Unique CNAME identifier.
+     **/
+    Participant(const std::string& cname);
 
-	~Participant();
+    ~Participant();
 
 private:
-	friend class ParticipantHandler;
+    friend class ParticipantHandler;
 
-	/**
-	 * Set the value of a SDES item.
-	 **/
-	inline void
-	setSDESItem(SDESItemType item, const std::string& val)
-	{ SDESItemsHolder::setItem(item,val); }
+    /**
+     * Set the value of a SDES item.
+     **/
+    inline void
+    setSDESItem(SDESItemType item, const std::string& val)
+    { SDESItemsHolder::setItem(item,val); }
 
-	/**
-	 * Set prefix value for the PRIV SDES item.
-	 **/
-	inline void
-	setPRIVPrefix(const std::string val)
-	{ SDESItemsHolder::setPRIVPrefix(val); }
+    /**
+     * Set prefix value for the PRIV SDES item.
+     **/
+    inline void
+    setPRIVPrefix(const std::string val)
+    { SDESItemsHolder::setPRIVPrefix(val); }
 };
 
 /**
@@ -195,153 +193,153 @@
 class __EXPORT SyncSource
 {
 public:
-	/**
-	 * @enum State
-	 *
-	 * @short Synchronization source states during an RTP session.
-	 *
-	 * In general, new synchronization sources are not considered
-	 * valid until multiple valid data packets or a valid RTCP
-	 * compound packet has been received from the new source (@see
-	 * IncomingDataQueue::setMinValidPacketSequence()). Thus, the
-	 * source will probably be in statePrevalid before reaching
-	 * one of the two states that indicate a valid source:
-	 * stateActive and stateInactive.
-	 *
-	 * A valid participant is in stateActive state if RTP and/or
-	 * RTCP packets are currently being received from it. If,
-	 * after a small number of RTCP report intervals (see
-	 * IncomingDataQueue::setSourceExpirationPeriod() ), no
-	 * packets are received, it will reach the stateInactive
-	 * state. If, after a small number of RTCP report intervals,
-	 * no packet is received from an inactive source, it will be
-	 * deleted.
-	 *
-	 * If RTCP is being used, after receiving a BYE RTCP packet
-	 * from a synchronization source, it will reach the
-	 * stateLeaving state and will be deleted after a delay (see
-	 * QueueRTCPManager::setLeavingDelay()).
-	 *
-	 * Sources in statePrevalid and stateLeaving are not counted
-	 * for the number of session members estimation.
-	 **/
-	typedef enum {
-		stateUnknown,     ///< No valid packet has been received.
-		statePrevalid,    ///< Some packets have been
-				  ///received, but source validity not
-				  ///yet guaranteed.
-		stateActive,      ///< We currently receive packets
-				  ///(data or control) from this source.
-		stateInactive,    ///< Was active in the near past but
-				  ///no packet from this source has
-				  ///been received lately.
-		stateLeaving      ///< An RTCP BYE has been received
-				  ///from the source.
-	}       State;
+    /**
+     * @enum State
+     *
+     * @short Synchronization source states during an RTP session.
+     *
+     * In general, new synchronization sources are not considered
+     * valid until multiple valid data packets or a valid RTCP
+     * compound packet has been received from the new source (@see
+     * IncomingDataQueue::setMinValidPacketSequence()). Thus, the
+     * source will probably be in statePrevalid before reaching
+     * one of the two states that indicate a valid source:
+     * stateActive and stateInactive.
+     *
+     * A valid participant is in stateActive state if RTP and/or
+     * RTCP packets are currently being received from it. If,
+     * after a small number of RTCP report intervals (see
+     * IncomingDataQueue::setSourceExpirationPeriod() ), no
+     * packets are received, it will reach the stateInactive
+     * state. If, after a small number of RTCP report intervals,
+     * no packet is received from an inactive source, it will be
+     * deleted.
+     *
+     * If RTCP is being used, after receiving a BYE RTCP packet
+     * from a synchronization source, it will reach the
+     * stateLeaving state and will be deleted after a delay (see
+     * QueueRTCPManager::setLeavingDelay()).
+     *
+     * Sources in statePrevalid and stateLeaving are not counted
+     * for the number of session members estimation.
+     **/
+    typedef enum {
+        stateUnknown,     ///< No valid packet has been received.
+        statePrevalid,    ///< Some packets have been
+                  ///received, but source validity not
+                  ///yet guaranteed.
+        stateActive,      ///< We currently receive packets
+                  ///(data or control) from this source.
+        stateInactive,    ///< Was active in the near past but
+                  ///no packet from this source has
+                  ///been received lately.
+        stateLeaving      ///< An RTCP BYE has been received
+                  ///from the source.
+    }       State;
 
-	/**
-	 * @param ssrc SSRC identifier of the source, unique in each
-	 * session.
-	 */
-	SyncSource(uint32 ssrc); 
+    /**
+     * @param ssrc SSRC identifier of the source, unique in each
+     * session.
+     */
+    SyncSource(uint32 ssrc);
 
-	~SyncSource();
+    ~SyncSource();
 
-	State
-	getState() const
-	{ return state; }
+    State
+    getState() const
+    { return state; }
 
-	/**
-	 * Whether this source sends RTP data packets.
-	 **/
-	bool isSender() const
-	{ return activeSender; }
+    /**
+     * Whether this source sends RTP data packets.
+     **/
+    bool isSender() const
+    { return activeSender; }
 
-	uint32 getID() const
-	{ return SSRC; }
+    uint32 getID() const
+    { return SSRC; }
 
-	/**
-	 * Get the participant this synchronization source is
-	 * asociated to.
-	 *
-	 * @retval NULL if the stack has not been yet able to identify
-	 * the participant this source is associated to.
-	 **/
-	inline Participant*
-	getParticipant() const
-	{ return participant; }
+    /**
+     * Get the participant this synchronization source is
+     * asociated to.
+     *
+     * @retval NULL if the stack has not been yet able to identify
+     * the participant this source is associated to.
+     **/
+    inline Participant*
+    getParticipant() const
+    { return participant; }
 
-	tpport_t getDataTransportPort() const
-	{ return dataTransportPort; }
+    tpport_t getDataTransportPort() const
+    { return dataTransportPort; }
 
-	tpport_t getControlTransportPort() const
-	{ return controlTransportPort; }
-	
-	const InetAddress& getNetworkAddress() const
-	{ return networkAddress; }
+    tpport_t getControlTransportPort() const
+    { return controlTransportPort; }
+
+    const InetAddress& getNetworkAddress() const
+    { return networkAddress; }
 
 protected:
-	/**
-	 * @param source The RTPSource object being copied
-	 */
-	SyncSource(const SyncSource& source);
+    /**
+     * @param source The RTPSource object being copied
+     */
+    SyncSource(const SyncSource& source);
 
-	SyncSource&
-	operator=(const SyncSource& source);
+    SyncSource&
+    operator=(const SyncSource& source);
 
 private:
-	friend class SyncSourceHandler;
+    friend class SyncSourceHandler;
 
-	inline void
-	setState(State st)
-	{ state = st; }
+    inline void
+    setState(State st)
+    { state = st; }
 
-	/**
-	 * Mark this source as an active sender.
-	 **/
-	inline void
-	setSender(bool active)
-	{ activeSender = active; }
+    /**
+     * Mark this source as an active sender.
+     **/
+    inline void
+    setSender(bool active)
+    { activeSender = active; }
 
-	inline void
-	setParticipant(Participant& p)
-	{ participant = &p; }
-	
-	void setDataTransportPort(tpport_t p)
-	{ dataTransportPort = p; }
+    inline void
+    setParticipant(Participant& p)
+    { participant = &p; }
 
-	void setControlTransportPort(tpport_t p)
-	{ controlTransportPort = p; }
+    void setDataTransportPort(tpport_t p)
+    { dataTransportPort = p; }
 
-	void setNetworkAddress(InetAddress addr)
-	{ networkAddress = addr; }
+    void setControlTransportPort(tpport_t p)
+    { controlTransportPort = p; }
 
-	inline void
-	setLink(void *l)
-	{ link = l; }
+    void setNetworkAddress(InetAddress addr)
+    { networkAddress = addr; }
 
-	void *getLink() const
-	{ return link; }
+    inline void
+    setLink(void *l)
+    { link = l; }
 
-	// validity state of this source
-	State state;
-	// 32-bit SSRC identifier.
-	uint32 SSRC;
-	// A valid source not always is active
+    void *getLink() const
+    { return link; }
+
+    // validity state of this source
+    State state;
+    // 32-bit SSRC identifier.
+    uint32 SSRC;
+    // A valid source not always is active
         bool activeSender;
-	// The corresponding participant.
-	Participant* participant;
+    // The corresponding participant.
+    Participant* participant;
 
-	// Network protocol address for data and control connection
-	// (both are assumed to be the same).
-	InetAddress networkAddress;
-	tpport_t dataTransportPort;
-	tpport_t controlTransportPort;
+    // Network protocol address for data and control connection
+    // (both are assumed to be the same).
+    InetAddress networkAddress;
+    tpport_t dataTransportPort;
+    tpport_t controlTransportPort;
 
-	// Pointer to the SyncSourceLink or similar object in the
-	// service queue. Saves a lot of searches in the membership
-	// table.
-	void* link;
+    // Pointer to the SyncSourceLink or similar object in the
+    // service queue. Saves a lot of searches in the membership
+    // table.
+    void* link;
 };
 
 /**
@@ -367,129 +365,129 @@
 class __EXPORT RTPApplication : private SDESItemsHolder
 {
 private:
-	struct ParticipantLink;
+    struct ParticipantLink;
 
 public:
-	/**
-	 * Create a new RTP application. If the CNAME string provided
-	 * has zero length, it is guessed from the user and machine
-	 * name.
-	 *
-	 * @param cname Local participant canonical name.
-	 **/
-	RTPApplication(const std::string& cname);
+    /**
+     * Create a new RTP application. If the CNAME string provided
+     * has zero length, it is guessed from the user and machine
+     * name.
+     *
+     * @param cname Local participant canonical name.
+     **/
+    RTPApplication(const std::string& cname);
 
-	~RTPApplication();
+    ~RTPApplication();
 
-	inline void
-	setSDESItem(SDESItemType item, const std::string& val)
-	{ SDESItemsHolder::setItem(item,val); }
+    inline void
+    setSDESItem(SDESItemType item, const std::string& val)
+    { SDESItemsHolder::setItem(item,val); }
 
-	inline void
-	setPRIVPrefix(const std::string& val)
-	{ SDESItemsHolder::setPRIVPrefix(val); }
+    inline void
+    setPRIVPrefix(const std::string& val)
+    { SDESItemsHolder::setPRIVPrefix(val); }
 
-	const std::string&
-	getSDESItem(SDESItemType item) const
-	{ return SDESItemsHolder::getItem(item); }
+    const std::string&
+    getSDESItem(SDESItemType item) const
+    { return SDESItemsHolder::getItem(item); }
 
-	inline const std::string&
-	getPRIVPrefix() const
-	{ return SDESItemsHolder::getPRIVPrefix(); }
+    inline const std::string&
+    getPRIVPrefix() const
+    { return SDESItemsHolder::getPRIVPrefix(); }
 
-	/**
-	 * Iterator through the list of participants in this
-	 * session. Somehow resembles and standard const_iterator
-	 **/
-	class ParticipantsIterator
-	{
-	public:
-		typedef std::forward_iterator_tag iterator_category;
-		typedef Participant value_type;
-		typedef ptrdiff_t difference_type;
-		typedef const Participant* pointer;
-		typedef const Participant& reference;
+    /**
+     * Iterator through the list of participants in this
+     * session. Somehow resembles and standard const_iterator
+     **/
+    class ParticipantsIterator
+    {
+    public:
+        typedef std::forward_iterator_tag iterator_category;
+        typedef Participant value_type;
+        typedef std::ptrdiff_t difference_type;
+        typedef const Participant* pointer;
+        typedef const Participant& reference;
 
-		ParticipantsIterator(ParticipantLink* p = NULL) : 
-			link(p) 
-		{ }
+        ParticipantsIterator(ParticipantLink* p = NULL) :
+            link(p)
+        { }
 
-		ParticipantsIterator(const ParticipantsIterator& pi) : 
-			link(pi.link)
-		{ }
+        ParticipantsIterator(const ParticipantsIterator& pi) :
+            link(pi.link)
+        { }
 
-		reference operator*() const
-		{ return *(link->getParticipant()); }
+        reference operator*() const
+        { return *(link->getParticipant()); }
 
-		pointer operator->() const
-		{ return link->getParticipant(); }
+        pointer operator->() const
+        { return link->getParticipant(); }
 
-		ParticipantsIterator& operator++() {
-			link = link->getNext();
-			return *this;
-		}
+        ParticipantsIterator& operator++() {
+            link = link->getNext();
+            return *this;
+        }
 
-		ParticipantsIterator operator++(int) {
-			ParticipantsIterator result(*this);
-			++(*this);
-			return result;
-		}
-		friend bool operator==(const ParticipantsIterator& l,
-				       const ParticipantsIterator& r)
-		{ return l.link == r.link; }
+        ParticipantsIterator operator++(int) {
+            ParticipantsIterator result(*this);
+            ++(*this);
+            return result;
+        }
+        friend bool operator==(const ParticipantsIterator& l,
+                       const ParticipantsIterator& r)
+        { return l.link == r.link; }
 
-		friend bool operator!=(const ParticipantsIterator& l,
-				       const ParticipantsIterator& r)
-		{ return l.link != r.link; }
-	private:
-		ParticipantLink *link;
-	};
+        friend bool operator!=(const ParticipantsIterator& l,
+                       const ParticipantsIterator& r)
+        { return l.link != r.link; }
+    private:
+        ParticipantLink *link;
+    };
 
-	ParticipantsIterator begin()
-	{ return ParticipantsIterator(firstPart); }
-	
-	ParticipantsIterator end()
-	{ return ParticipantsIterator(NULL); }
+    ParticipantsIterator begin()
+    { return ParticipantsIterator(firstPart); }
 
-	const Participant*
-	getParticipant(const std::string& cname) const;
-	
+    ParticipantsIterator end()
+    { return ParticipantsIterator(NULL); }
+
+    const Participant*
+    getParticipant(const std::string& cname) const;
+
 private:
-	friend class ApplicationHandler;
+    friend class ApplicationHandler;
 
-	struct ParticipantLink {
-		ParticipantLink(Participant& p, 
-				ParticipantLink* l) :
-			participant(&p), next(l) 
-		{ }
-		inline ~ParticipantLink() { delete participant; }
-		inline Participant* getParticipant() { return participant; }
-		inline ParticipantLink* getPrev() { return prev; }
-		inline ParticipantLink* getNext() { return next; }
-		inline void setPrev(ParticipantLink* l) { prev = l; }
-		inline void setNext(ParticipantLink* l) { next = l; }
-		Participant* participant;
-		ParticipantLink* next, *prev;
-	};
+    struct ParticipantLink {
+        ParticipantLink(Participant& p,
+                ParticipantLink* l) :
+            participant(&p), next(l)
+        { }
+        inline ~ParticipantLink() { delete participant; }
+        inline Participant* getParticipant() { return participant; }
+        inline ParticipantLink* getPrev() { return prev; }
+        inline ParticipantLink* getNext() { return next; }
+        inline void setPrev(ParticipantLink* l) { prev = l; }
+        inline void setNext(ParticipantLink* l) { next = l; }
+        Participant* participant;
+        ParticipantLink* next, *prev;
+    };
 
-	void
-	addParticipant(Participant& part);
+    void
+    addParticipant(Participant& part);
 
-	void
-	removeParticipant(ParticipantLink* part);
+    void
+    removeParticipant(ParticipantLink* part);
 
-	/**
-	 * Find out the local CNAME as user\@host and store it as part
-	 * of the internal state of this class.  
-	 */
-	void
-	findCNAME();
+    /**
+     * Find out the local CNAME as user\@host and store it as part
+     * of the internal state of this class.
+     */
+    void
+    findCNAME();
 
-	/// Hash table with sources of RTP and RTCP packets.
-	static const size_t defaultParticipantsNum;
-	Participant** participants;
-	/// List of participants, ordered from older to newer.
-	ParticipantLink* firstPart, * lastPart;
+    /// Hash table with sources of RTP and RTCP packets.
+    static const size_t defaultParticipantsNum;
+    Participant** participants;
+    /// List of participants, ordered from older to newer.
+    ParticipantLink* firstPart, * lastPart;
 };
 
 /**
@@ -505,9 +503,7 @@
 
 /** @}*/ // sources
 
-#ifdef CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif //CCXX_RTP_SOURCES_H_
 
diff --git a/jni/libccrtp/sources/src/config.h b/jni/libccrtp/sources/src/config.h
deleted file mode 100644
index 2056952..0000000
--- a/jni/libccrtp/sources/src/config.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* src/config.h.  Generated from config.h.in by configure.  */
-/* src/config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if you have the <DL.h> header file. */
-/* #undef HAVE_DL_H */
-
-/* Define to 1 if you have the <gcrypt.h> header file. */
-/* #undef HAVE_GCRYPT_H */
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `nana' library (-lnana). */
-/* #undef HAVE_LIBNANA */
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the <openssl/aes.h> header file. */
-#define HAVE_OPENSSL_AES_H 1
-
-/* Define to 1 if you have the <openssl/bn.h> header file. */
-#define HAVE_OPENSSL_BN_H 1
-
-/* Define to 1 if you have the <openssl/sha.h> header file. */
-#define HAVE_OPENSSL_SHA_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#define LT_OBJDIR ".libs/"
-
-/* Name of package */
-#define PACKAGE "ccrtp"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME ""
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING ""
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME ""
-
-/* Define to the home page for this package. */
-#define PACKAGE_URL ""
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION ""
-
-/* SRTP support */
-#define SRTP_SUPPORT 1
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "1.8.0"
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
-   calls it, or to nothing if 'inline' is not supported under any name.  */
-#ifndef __cplusplus
-/* #undef inline */
-#endif
-
-/* Define to the equivalent of the C99 'restrict' keyword, or to
-   nothing if this is not supported.  Do not define if restrict is
-   supported directly.  */
-#define restrict __restrict
-/* Work around a bug in Sun C++: it does not support _Restrict or
-   __restrict__, even though the corresponding Sun C compiler ends up with
-   "#define restrict _Restrict" or "#define restrict __restrict__" in the
-   previous line.  Perhaps some future version of Sun C++ will work with
-   restrict; if so, hopefully it defines __RESTRICT like Sun C does.  */
-#if defined __SUNPRO_CC && !defined __RESTRICT
-# define _Restrict
-# define __restrict__
-#endif
-
-/* Define to empty if the keyword `volatile' does not work. Warning: valid
-   code using `volatile' can become incorrect without. Disable with care. */
-/* #undef volatile */
diff --git a/jni/libccrtp/sources/src/config.h.in b/jni/libccrtp/sources/src/config.h.in
deleted file mode 100644
index f89d1b6..0000000
--- a/jni/libccrtp/sources/src/config.h.in
+++ /dev/null
@@ -1,107 +0,0 @@
-/* src/config.h.in.  Generated from configure.ac by autoheader.  */
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the <DL.h> header file. */
-#undef HAVE_DL_H
-
-/* Define to 1 if you have the <gcrypt.h> header file. */
-#undef HAVE_GCRYPT_H
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `nana' library (-lnana). */
-#undef HAVE_LIBNANA
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <openssl/aes.h> header file. */
-#undef HAVE_OPENSSL_AES_H
-
-/* Define to 1 if you have the <openssl/bn.h> header file. */
-#undef HAVE_OPENSSL_BN_H
-
-/* Define to 1 if you have the <openssl/sha.h> header file. */
-#undef HAVE_OPENSSL_SHA_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#undef LT_OBJDIR
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* SRTP support */
-#undef SRTP_SUPPORT
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
-   calls it, or to nothing if 'inline' is not supported under any name.  */
-#ifndef __cplusplus
-#undef inline
-#endif
-
-/* Define to the equivalent of the C99 'restrict' keyword, or to
-   nothing if this is not supported.  Do not define if restrict is
-   supported directly.  */
-#undef restrict
-/* Work around a bug in Sun C++: it does not support _Restrict or
-   __restrict__, even though the corresponding Sun C compiler ends up with
-   "#define restrict _Restrict" or "#define restrict __restrict__" in the
-   previous line.  Perhaps some future version of Sun C++ will work with
-   restrict; if so, hopefully it defines __RESTRICT like Sun C does.  */
-#if defined __SUNPRO_CC && !defined __RESTRICT
-# define _Restrict
-# define __restrict__
-#endif
-
-/* Define to empty if the keyword `volatile' does not work. Warning: valid
-   code using `volatile' can become incorrect without. Disable with care. */
-#undef volatile
diff --git a/jni/libccrtp/sources/src/control.cpp b/jni/libccrtp/sources/src/control.cpp
index 4be6a45..2ae816a 100644
--- a/jni/libccrtp/sources/src/control.cpp
+++ b/jni/libccrtp/sources/src/control.cpp
@@ -48,9 +48,7 @@
 #include <cstdlib>
 #include <climits>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 const uint16 QueueRTCPManager::TIMEOUT_MULTIPLIER = 5;
 const double QueueRTCPManager::RECONSIDERATION_COMPENSATION = 2.718281828 - 1.5;
@@ -61,7 +59,7 @@
 
 QueueRTCPManager::QueueRTCPManager(uint32 size, RTPApplication& app):
 RTPDataQueue(size), RTCPCompoundHandler(RTCPCompoundHandler::defaultPathMTU),
-queueApplication(app)
+queueApplication(app), srtcpIndex(0)
 {
     controlServiceActive = false;
     controlBwFract = 0.05f;
@@ -85,7 +83,7 @@
         sizeof(SenderInfo);
     rtcpInitial = true;
     // force an initial check for incoming RTCP packets
-    gettimeofday(&rtcpNextCheck,NULL);
+    SysTime::gettimeofday(&rtcpNextCheck,NULL);
     // check for incoming RTCP packets every 1/4 seconds.
     rtcpCheckInterval.tv_sec = 0;
     rtcpCheckInterval.tv_usec = 250000;
@@ -112,7 +110,7 @@
 QueueRTCPManager::QueueRTCPManager(uint32 ssrc, uint32 size, RTPApplication& app):
 RTPDataQueue(&ssrc, size),
 RTCPCompoundHandler(RTCPCompoundHandler::defaultPathMTU),
-queueApplication(app)
+queueApplication(app), srtcpIndex(0)
 {
     controlServiceActive = false;
     controlBwFract = 0.05f;
@@ -137,7 +135,7 @@
     rtcpAvgSize = sizeof(RTCPFixedHeader) + sizeof(uint32) + sizeof(SenderInfo);
     rtcpInitial = true;
     // force an initial check for incoming RTCP packets
-    gettimeofday(&rtcpNextCheck,NULL);
+    SysTime::gettimeofday(&rtcpNextCheck,NULL);
     // check for incoming RTCP packets every 1/4 seconds.
     rtcpCheckInterval.tv_sec = 0;
     rtcpCheckInterval.tv_usec = 250000;
@@ -169,6 +167,9 @@
 {
     controlServiceActive = false;
     controlBwFract = sendControlBwFract = 0;
+    removeOutQueueCryptoContextCtrl(NULL);   // remove the outgoing crypto context
+    removeInQueueCryptoContextCtrl(NULL);    // Remove any incoming crypto contexts
+
 }
 
 bool QueueRTCPManager::checkSSRCInRTCPPkt(SyncSourceLink& sourceLink,
@@ -243,7 +244,7 @@
         return;
 
     // A) see if there are incoming RTCP packets
-    gettimeofday(&(reconsInfo.rtcpTc),NULL);
+    SysTime::gettimeofday(&(reconsInfo.rtcpTc),NULL);
     if ( timercmp(&(reconsInfo.rtcpTc),&rtcpNextCheck,>=) ) {
         while ( isPendingControl(0) )
             takeInControlPacket();
@@ -265,7 +266,7 @@
         return;
 
     // B) send RTCP packets
-    gettimeofday(&(reconsInfo.rtcpTc),NULL);
+    SysTime::gettimeofday(&(reconsInfo.rtcpTc),NULL);
     if ( timercmp(&(reconsInfo.rtcpTc),&(reconsInfo.rtcpTn),>=) ) {
         if ( timerReconsideration() ) {
             // this would update to last received RTCP packets
@@ -296,7 +297,7 @@
     // circumstances
     timeval T = computeRTCPInterval();
     timeradd(&(reconsInfo.rtcpTp),&T,&(reconsInfo.rtcpTn));
-    gettimeofday(&(reconsInfo.rtcpTc),NULL);
+    SysTime::gettimeofday(&(reconsInfo.rtcpTc),NULL);
     if ( timercmp(&(reconsInfo.rtcpTc),&(reconsInfo.rtcpTn),>=) ) {
         reconsInfo.rtcpTp = reconsInfo.rtcpTc;
         result = true;
@@ -318,15 +319,38 @@
 
     // get time of arrival
     struct timeval recvtime;
-    gettimeofday(&recvtime,NULL);
+    SysTime::gettimeofday(&recvtime,NULL);
 
     // process a 'len' octets long RTCP compound packet
 
+    RTCPPacket *pkt = reinterpret_cast<RTCPPacket *>(rtcpRecvBuffer);
+
+    CryptoContextCtrl* pcc = getInQueueCryptoContextCtrl(pkt->getSSRC());
+    if (pcc == NULL) {
+        pcc = getInQueueCryptoContextCtrl(0);
+        if (pcc != NULL) {
+            pcc = pcc->newCryptoContextForSSRC(pkt->getSSRC());
+            if (pcc != NULL) {
+                pcc->deriveSrtcpKeys();
+                setInQueueCryptoContextCtrl(pcc);
+            }
+        }
+    }
+    // If no crypto context: then SRTP/SRTCP is off
+    // If crypto context is available then unprotect data here. If an error
+    // occurs report the error and discard the packet.
+    if (pcc != NULL) {
+        int32 ret;
+        if ((ret = unprotect(rtcpRecvBuffer, len, pcc)) < 0) {
+            // TODO: do more error handling?
+            return;
+        }
+        len = ret;      // adjust length after unprotecting the packet
+    }
     // Check validity of the header fields of the compound packet
     if ( !RTCPCompoundHandler::checkCompoundRTCPHeader(len) )
         return;
 
-    RTCPPacket *pkt = reinterpret_cast<RTCPPacket *>(rtcpRecvBuffer);
 
     // TODO: for now, we do nothing with the padding bit
     // in the header.
@@ -464,7 +488,7 @@
             timeval packetTime;
             timeradd(&tNTP,&timevalInc,&packetTime);
             timeval now, diff;
-            gettimeofday(&now,NULL);
+            SysTime::gettimeofday(&now,NULL);
             timersub(&now,&packetTime,&diff);
 
             if ( timeval2microtimeout(diff) > getEnd2EndDelay() )
@@ -575,7 +599,7 @@
     // 8-bit long, so no ntoh[s|l] is required
     bool cname_found = false;
 
-    ptrdiff_t pointer = reinterpret_cast<unsigned char*>(&pkt) - rtcpRecvBuffer;
+    std::ptrdiff_t pointer = reinterpret_cast<unsigned char*>(&pkt) - rtcpRecvBuffer;
     uint16 i = 0;
     do {
         size_t len = pkt.getLength();
@@ -649,7 +673,7 @@
             pointer++;
             pointer += (pointer & 0x03); // padding
         } else if ( item->type == SDESItemTypePRIV ) {
-            ptrdiff_t prevpointer = pointer;
+            std::ptrdiff_t prevpointer = pointer;
             uint8 plength = *( &(item->len) + 1 );
             pointer += sizeof(item->type) + sizeof(item->len)  + 1;
 
@@ -715,6 +739,8 @@
     return result;
 }
 
+#define BYE_BUFFER_LENGTH 500
+
 size_t QueueRTCPManager::dispatchBYE(const std::string& reason)
 {
     // for this method, see section 6.3.7 in RFC 3550
@@ -726,7 +752,7 @@
     if ( getMembersCount() > 50) {
         // Usurp the scheduler role and apply a back-off
         // algorithm to avoid BYE floods.
-        gettimeofday(&(reconsInfo.rtcpTc),NULL);
+        SysTime::gettimeofday(&(reconsInfo.rtcpTc),NULL);
         reconsInfo.rtcpTp = reconsInfo.rtcpTc;
         setMembersCount(1);
         setPrevMembersNum(1);
@@ -735,19 +761,19 @@
         rtcpAvgSize = (uint16)(sizeof(RTCPFixedHeader) + sizeof(uint32) +
             strlen(reason.c_str()) +
             (4 - (strlen(reason.c_str()) & 0x03)));
-        gettimeofday(&(reconsInfo.rtcpTc),NULL);
+        SysTime::gettimeofday(&(reconsInfo.rtcpTc),NULL);
         timeval T = computeRTCPInterval();
         timeradd(&(reconsInfo.rtcpTp),&T,&(reconsInfo.rtcpTn));
         while ( timercmp(&(reconsInfo.rtcpTc),&(reconsInfo.rtcpTn),<) ) {
             getOnlyBye();
             if ( timerReconsideration() )
                 break;
-            gettimeofday(&(reconsInfo.rtcpTc),NULL);
+            SysTime::gettimeofday(&(reconsInfo.rtcpTc),NULL);
         }
     }
 
 
-    unsigned char buffer[500];
+    unsigned char buffer[BYE_BUFFER_LENGTH];
     // Build an empty RR as first packet in the compound.
         // TODO: provide more information if available. Not really
     // important, since this is the last packet being sent.
@@ -858,7 +884,7 @@
         // Fill in sender info block. It would be more
         // accurate if this were done as late as possible.
         timeval now;
-        gettimeofday(&now,NULL);
+        SysTime::gettimeofday(&now,NULL);
         // NTP MSB and MSB: dependent on current payload type.
         pkt->info.SR.sinfo.NTPMSW = htonl(now.tv_sec + NTP_EPOCH_OFFSET);
         pkt->info.SR.sinfo.NTPLSW = htonl((uint32)(((double)(now.tv_usec)*(uint32)(~0))/1000000.0));
@@ -1034,7 +1060,7 @@
                        ((ntohl(si->NTPLSW) & 0xFFFF0000) >> 16)
                        );
             timeval now, diff;
-            gettimeofday(&now,NULL);
+            SysTime::gettimeofday(&now,NULL);
             timeval last = srcLink.getLastRTCPSRTime();
             timersub(&now,&last,&diff);
             blocks[j].rinfo.dlsr =
@@ -1098,6 +1124,28 @@
 {
     size_t count = 0;
     lockDestinationList();
+
+    // Cast to have easy access to ssrc et al
+    RTCPPacket *pkt = reinterpret_cast<RTCPPacket *>(buffer);
+
+    CryptoContextCtrl* pcc = getOutQueueCryptoContextCtrl(pkt->getSSRC());
+    if (pcc == NULL) {
+        pcc = getOutQueueCryptoContextCtrl(0);
+        if (pcc != NULL) {
+            pcc = pcc->newCryptoContextForSSRC(pkt->getSSRC());
+            if (pcc != NULL) {
+                pcc->deriveSrtcpKeys();
+                setOutQueueCryptoContextCtrl(pcc);
+            }
+        }
+    }
+    // If no crypto context: then SRTP/SRTCP is off
+    // If crypto context is available then unprotect data here. If an error
+    // occurs report the error and discard the packet.
+    if (pcc != NULL) {
+        len = protect(buffer, len, pcc);
+    }
+
     if ( isSingleDestination() ) {
         count = sendControl(buffer,len);
     } else {
@@ -1115,9 +1163,192 @@
     return count;
 }
 
-#ifdef  CCXX_NAMESPACES
+int32
+QueueRTCPManager::protect(uint8* pkt, size_t len, CryptoContextCtrl* pcc) {
+    /* Encrypt the packet */
+
+    uint32 ssrc = *(reinterpret_cast<uint32*>(pkt + 4)); // always SSRC of sender
+    ssrc =ntohl(ssrc);
+
+    pcc->srtcpEncrypt(pkt + 8, len - 8, srtcpIndex, ssrc);
+
+    uint32 encIndex = srtcpIndex | 0x80000000;  // set the E flag
+
+    uint32* ip = reinterpret_cast<uint32*>(pkt+len);
+    *ip = htonl(encIndex);
+
+    // NO MKI support yet - here we assume MKI is zero. To build in MKI
+    // take MKI length into account when storing the authentication tag.
+
+    // Compute MAC and store in packet after the SRTCP index field
+    pcc->srtcpAuthenticate(pkt, len, encIndex, pkt + len + sizeof(uint32));
+
+    srtcpIndex++;
+    srtcpIndex &= ~0x80000000;       // clear possible overflow
+
+    return len + pcc->getTagLength() + sizeof(uint32);
 }
-#endif
+
+int32
+QueueRTCPManager::unprotect(uint8* pkt, size_t len, CryptoContextCtrl* pcc) {
+    if (pcc == NULL) {
+        return true;
+    }
+
+    // Compute the total length of the payload
+    uint32 payloadLen = len - (pcc->getTagLength() + pcc->getMkiLength() + 4);
+
+    // point to the SRTCP index field just after the real payload
+    const uint32* index = reinterpret_cast<uint32*>(pkt + payloadLen);
+    uint32 ssrc = *(reinterpret_cast<uint32*>(pkt + 4)); // always SSRC of sender
+    ssrc =ntohl(ssrc);
+
+    uint32 encIndex = ntohl(*index);
+    uint32 remoteIndex = encIndex & ~0x80000000;    // index without Encryption flag
+
+    if (!pcc->checkReplay(remoteIndex)) {
+       return -2;
+    }
+
+    uint8 mac[20];
+
+    // Now get a pointer to the authentication tag field
+    const uint8* tag = pkt + (len - pcc->getTagLength());
+
+    // Authenticate includes the index, but not MKI and not (obviously) the tag itself
+    pcc->srtcpAuthenticate(pkt, payloadLen, encIndex, mac);
+    if (memcmp(tag, mac, pcc->getTagLength()) != 0) {
+        return -1;
+    }
+
+    // Decrypt the content, exclude the very first SRTCP header (fixed, 8 bytes)
+    if (encIndex & 0x80000000)
+        pcc->srtcpEncrypt(pkt + 8, payloadLen - 8, remoteIndex, ssrc);
+
+    // Update the Crypto-context
+    pcc->update(remoteIndex);
+
+    return payloadLen;
+}
+
+
+void
+QueueRTCPManager::setOutQueueCryptoContextCtrl(CryptoContextCtrl* cc)
+{
+    std::list<CryptoContextCtrl *>::iterator i;
+
+    MutexLock lock(outCryptoMutex);
+        // check if a CryptoContext for a SSRC already exists. If yes
+        // remove it from list before inserting the new one.
+    for( i = outCryptoContexts.begin(); i!= outCryptoContexts.end(); i++ ) {
+        if( (*i)->getSsrc() == cc->getSsrc() ) {
+            CryptoContextCtrl* tmp = *i;
+            outCryptoContexts.erase(i);
+            delete tmp;
+            break;
+        }
+    }
+    outCryptoContexts.push_back(cc);
+}
+
+void
+QueueRTCPManager::removeOutQueueCryptoContextCtrl(CryptoContextCtrl* cc)
+{
+    std::list<CryptoContextCtrl *>::iterator i;
+
+    MutexLock lock(outCryptoMutex);
+    if (cc == NULL) {     // Remove any incoming crypto contexts
+        for (i = outCryptoContexts.begin(); i != outCryptoContexts.end(); ) {
+            CryptoContextCtrl* tmp = *i;
+            i = outCryptoContexts.erase(i);
+            delete tmp;
+        }
+    }
+    else {
+        for( i = outCryptoContexts.begin(); i != outCryptoContexts.end(); i++ ) {
+            if( (*i)->getSsrc() == cc->getSsrc() ) {
+                CryptoContextCtrl* tmp = *i;
+                outCryptoContexts.erase(i);
+                delete tmp;
+                return;
+            }
+        }
+    }
+}
+
+CryptoContextCtrl*
+QueueRTCPManager::getOutQueueCryptoContextCtrl(uint32 ssrc)
+{
+    std::list<CryptoContextCtrl *>::iterator i;
+
+    MutexLock lock(outCryptoMutex);
+    for( i = outCryptoContexts.begin(); i != outCryptoContexts.end(); i++ ){
+        if( (*i)->getSsrc() == ssrc) {
+            return (*i);
+        }
+    }
+    return NULL;
+}
+
+void
+QueueRTCPManager::setInQueueCryptoContextCtrl(CryptoContextCtrl* cc)
+{
+    std::list<CryptoContextCtrl *>::iterator i;
+
+    MutexLock lock(inCryptoMutex);
+    // check if a CryptoContext for a SSRC already exists. If yes
+    // remove it from list before inserting the new one.
+    for( i = inCryptoContexts.begin(); i!= inCryptoContexts.end(); i++ ) {
+        if( (*i)->getSsrc() == cc->getSsrc() ) {
+            CryptoContextCtrl* tmp = *i;
+            inCryptoContexts.erase(i);
+            delete tmp;
+            break;
+        }
+    }
+    inCryptoContexts.push_back(cc);
+}
+
+void
+QueueRTCPManager::removeInQueueCryptoContextCtrl(CryptoContextCtrl* cc)
+{
+    std::list<CryptoContextCtrl *>::iterator i;
+
+    MutexLock lock(inCryptoMutex);
+    if (cc == NULL) {     // Remove any incoming crypto contexts
+        for (i = inCryptoContexts.begin(); i != inCryptoContexts.end(); ) {
+            CryptoContextCtrl* tmp = *i;
+            i = inCryptoContexts.erase(i);
+            delete tmp;
+        }
+    }
+    else {
+        for( i = inCryptoContexts.begin(); i!= inCryptoContexts.end(); i++ ){
+            if( (*i)->getSsrc() == cc->getSsrc() ) {
+                CryptoContextCtrl* tmp = *i;
+                inCryptoContexts.erase(i);
+                delete tmp;
+                return;
+            }
+        }
+    }
+}
+
+CryptoContextCtrl*
+QueueRTCPManager::getInQueueCryptoContextCtrl(uint32 ssrc)
+{
+    std::list<CryptoContextCtrl *>::iterator i;
+
+    MutexLock lock(inCryptoMutex);
+    for( i = inCryptoContexts.begin(); i!= inCryptoContexts.end(); i++ ){
+        if( (*i)->getSsrc() == ssrc) {
+            return (*i);
+        }
+    }
+    return NULL;
+}
+
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/data.cpp b/jni/libccrtp/sources/src/data.cpp
index 837ad1c..a029bbc 100644
--- a/jni/libccrtp/sources/src/data.cpp
+++ b/jni/libccrtp/sources/src/data.cpp
@@ -43,9 +43,7 @@
 #include "private.h"
 #include <ccrtp/queuebase.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 AppDataUnit::AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src):
 datablock(&packet), source(&src)
@@ -66,9 +64,7 @@
     return *this;
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/duplex.cpp b/jni/libccrtp/sources/src/duplex.cpp
index b344df2..c50c676 100644
--- a/jni/libccrtp/sources/src/duplex.cpp
+++ b/jni/libccrtp/sources/src/duplex.cpp
@@ -41,9 +41,7 @@
 #include "private.h"
 #include <ccrtp/ext.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 RTPDuplex::RTPDuplex(const InetAddress &ia, tpport_t local, tpport_t remote) :
 RTPDataQueue(), UDPReceive(ia, local), UDPTransmit(ia, remote)
@@ -77,9 +75,7 @@
     return UDPTransmit::errSuccess;
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/incqueue.cpp b/jni/libccrtp/sources/src/incqueue.cpp
index c00e197..cd82194 100644
--- a/jni/libccrtp/sources/src/incqueue.cpp
+++ b/jni/libccrtp/sources/src/incqueue.cpp
@@ -38,9 +38,7 @@
 #include "private.h"
 #include <ccrtp/iqueue.h>
 
-#ifdef CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 const size_t IncomingDataQueueBase::defaultMaxRecvPacketSize = 65534;
 
@@ -49,7 +47,7 @@
 networkAddress(na), dataTransportPort(dtp),
 controlTransportPort(ctp), next(NULL)
 {
-    gettimeofday(&lastPacketTime,NULL);
+    SysTime::gettimeofday(&lastPacketTime,NULL);
 }
 
 ConflictHandler::ConflictingTransportAddress*
@@ -195,7 +193,7 @@
 
     // get time of arrival
     struct timeval recvtime;
-    gettimeofday(&recvtime,NULL);
+    SysTime::gettimeofday(&recvtime,NULL);
 
     // Special handling of padding to take care of encrypted content.
     // In case of SRTP the padding length field is also encrypted, thus
@@ -205,7 +203,7 @@
     uint8 padSet = (*buffer & 0x20);
     if (padSet) {
         *buffer = *buffer & ~0x20;          // clear padding bit
-    }    
+    }
     //  build a packet. It will link itself to its source
     IncomingRTPPkt* packet =
         new IncomingRTPPkt(buffer,rtn);
@@ -782,9 +780,7 @@
     return NULL;
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/members.cpp b/jni/libccrtp/sources/src/members.cpp
index 0b4082b..287dad2 100644
--- a/jni/libccrtp/sources/src/members.cpp
+++ b/jni/libccrtp/sources/src/members.cpp
@@ -50,9 +50,7 @@
 #include "private.h"
 #include <ccrtp/cqueue.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 const uint32 MembershipBookkeeping::SyncSourceLink::SEQNUMMOD = (1<<16);
 
@@ -326,9 +324,7 @@
     return found;
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/outqueue.cpp b/jni/libccrtp/sources/src/outqueue.cpp
index 4edb34d..df37ee7 100644
--- a/jni/libccrtp/sources/src/outqueue.cpp
+++ b/jni/libccrtp/sources/src/outqueue.cpp
@@ -38,9 +38,7 @@
 #include "private.h"
 #include <ccrtp/oqueue.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 const size_t OutgoingDataQueueBase::defaultMaxSendSegmentSize = 65536;
 
@@ -330,7 +328,7 @@
         // plus the time accumulated through successive
         // overflows of timestamp. See below.
         timeradd(&send,&(sendInfo.overflowTime),&send);
-        gettimeofday(&now, NULL);
+        SysTime::gettimeofday(&now, NULL);
 
         // Problem: when timestamp overflows, time goes back.
         // We MUST ensure that _send_ is not too lower than
@@ -671,9 +669,7 @@
     return NULL;
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/pool.cpp b/jni/libccrtp/sources/src/pool.cpp
index 11247bd..5b6511b 100644
--- a/jni/libccrtp/sources/src/pool.cpp
+++ b/jni/libccrtp/sources/src/pool.cpp
@@ -40,14 +40,12 @@
 
 #include <algorithm>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
+NAMESPACE_COMMONCPP
 using std::list;
-#endif
 
 RTPSessionPool::RTPSessionPool()
 {
-#ifndef WIN32
+#ifndef _MSWINDOWS_
     highestSocket = 0;
     setPoolTimeout(0,3000);
     FD_ZERO(&recvSocketSet);
@@ -57,7 +55,7 @@
 bool
 RTPSessionPool::addSession(RTPSessionBase& session)
 {
-#ifndef WIN32
+#ifndef _MSWINDOWS_
     bool result = false;
     poolLock.writeLock();
     // insert in list.
@@ -78,7 +76,7 @@
 bool
 RTPSessionPool::removeSession(RTPSessionBase& session)
 {
-#ifndef WIN32
+#ifndef _MSWINDOWS_
     bool result = false;
     poolLock.writeLock();
     // remove from list.
@@ -100,7 +98,7 @@
 size_t
 RTPSessionPool::getPoolLength() const
 {
-#ifndef WIN32
+#ifndef _MSWINDOWS_
     size_t result;
     poolLock.readLock();
     result = sessionList.size();
@@ -114,7 +112,7 @@
 void
 SingleRTPSessionPool::run()
 {
-#ifndef WIN32
+#ifndef _MSWINDOWS_
     SOCKET so;
     microtimeout_t packetTimeout(0);
     while ( isActive() ) {
@@ -179,9 +177,7 @@
                 // packets
                 packetTimeout = (packetTimeout > maxWait)? maxWait : packetTimeout;
                 if ( packetTimeout < 1000 ) { // !(packetTimeout/1000)
-                    setCancel(cancelDeferred);
                     dispatchDataPacket(*session);
-                    setCancel(cancelImmediate);
                     //timerTick();
                 } else {
                     packetTimeout = 0;
@@ -253,10 +249,8 @@
         if ( timeout < 1000 ){ // !(timeout/1000)
             timeout = getSchedulingTimeout();
         }
-        setCancel(cancelDeferred);
         controlReceptionService();
         controlTransmissionService();
-        setCancel(cancelImmediate);
         microtimeout_t maxWait =
             timeval2microtimeout(getRTCPCheckInterval());
         // make sure the scheduling timeout is
@@ -264,15 +258,11 @@
         // packets
         timeout = (timeout > maxWait)? maxWait : timeout;
         if ( timeout < 1000 ) { // !(timeout/1000)
-            setCancel(cancelDeferred);
             dispatchDataPacket();
-            setCancel(cancelImmediate);
             timerTick();
         } else {
             if ( isPendingData(timeout/1000) ) {
-                setCancel(cancelDeferred);
                 takeInDataPacket();
-                setCancel(cancelImmediate);
             }
             timeout = 0;
         }
@@ -284,14 +274,14 @@
 
 #ifdef  CCXX_IPV6
 
-SingleThreadRTPSessionIPV6<DualRTPUDPIPv6Channel,DualRTPUDPIPv6Channel,AVPQueue>::SingleThreadRTPSession<DualRTPUDPIPv4Channel,DualRTPUDPIPv4Channel,AVPQueue>(
+SingleThreadRTPSessionIPV6<DualRTPUDPIPv6Channel,DualRTPUDPIPv6Channel,AVPQueue>::SingleThreadRTPSessionIPV6<DualRTPUDPIPv6Channel,DualRTPUDPIPv6Channel,AVPQueue>(
 const IPV6Host& ia, tpport_t dataPort, tpport_t controlPort, int pri,
 uint32 memberssize, RTPApplication& app) :
 Thread(pri), TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
 (ia,dataPort,controlPort,memberssize,app)
 {}
 
-SingleThreadRTPSessionIPV6<DualRTPUDPIPv6Channel,DualRTPUDPIPv6Channel,AVPQueue>::SingleThreadRTPSession<DualRTPUDPIPv4Channel,DualRTPUDPIPv4Channel,AVPQueue>(
+SingleThreadRTPSessionIPV6<DualRTPUDPIPv6Channel,DualRTPUDPIPv6Channel,AVPQueue>::SingleThreadRTPSessionIPV6<DualRTPUDPIPv6Channel,DualRTPUDPIPv6Channel,AVPQueue>(
 const IPV6Multicast& ia, tpport_t dataPort, tpport_t controlPort, int pri,
 uint32 memberssize, RTPApplication& app, uint32 iface) :
 Thread(pri), TRTPSessionBaseIPV6<RTPDataChannel,RTCPChannel,ServiceQueue>
@@ -319,10 +309,8 @@
         if ( timeout < 1000 ){ // !(timeout/1000)
             timeout = getSchedulingTimeout();
         }
-        setCancel(cancelDeferred);
         controlReceptionService();
         controlTransmissionService();
-        setCancel(cancelImmediate);
         microtimeout_t maxWait =
             timeval2microtimeout(getRTCPCheckInterval());
         // make sure the scheduling timeout is
@@ -330,15 +318,11 @@
         // packets
         timeout = (timeout > maxWait)? maxWait : timeout;
         if ( timeout < 1000 ) { // !(timeout/1000)
-            setCancel(cancelDeferred);
             dispatchDataPacket();
-            setCancel(cancelImmediate);
             timerTick();
         } else {
             if ( isPendingData(timeout/1000) ) {
-                setCancel(cancelDeferred);
                 takeInDataPacket();
-                setCancel(cancelImmediate);
             }
             timeout = 0;
         }
@@ -353,9 +337,7 @@
 
 #endif
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/private.h b/jni/libccrtp/sources/src/private.h
index 9444aeb..c094fa1 100644
--- a/jni/libccrtp/sources/src/private.h
+++ b/jni/libccrtp/sources/src/private.h
@@ -86,15 +86,14 @@
 #ifndef CCXX_RTP_PRIVATE_H_
 #define CCXX_RTP_PRIVATE_H_
 
-#include <cc++/config.h>
-#include <cc++/thread.h>
-#include <cc++/socket.h>
-#include <cc++/process.h>
-#include <cc++/export.h>
+#include <commoncpp/config.h>
+#include <commoncpp/thread.h>
+#include <commoncpp/socket.h>
+#include <commoncpp/udp.h>
+#include <commoncpp/process.h>
+#include <commoncpp/export.h>
 
-#ifndef CCRTP_CAPE
-#include "config.h"
-#endif
+#include <ccrtp-config.h>
 
 #undef  PACKAGE
 #undef  VERSION
@@ -110,11 +109,9 @@
 #   define VDL(e)  /* empty */
 #endif
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
-#ifdef WIN32
+#ifdef _MSWINDOWS_
 
 #ifndef timeradd
 #define timeradd(a, b, result)                              \
@@ -146,9 +143,7 @@
 uint32 random32();
 uint16 random16();
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 #endif // ifndef CCXX_RTP_PRIVATE_H_
 
diff --git a/jni/libccrtp/sources/src/queue.cpp b/jni/libccrtp/sources/src/queue.cpp
index 6c93efd..7a1b62a 100644
--- a/jni/libccrtp/sources/src/queue.cpp
+++ b/jni/libccrtp/sources/src/queue.cpp
@@ -42,20 +42,18 @@
 #include <cstdio>
 #include <cstring>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
+#ifndef _MSWINDOWS_
+#include <fcntl.h>
 #endif
 
+NAMESPACE_COMMONCPP
+using namespace std;
+
 // The first part of this file includes a copy of the MD5Digest class
 // of Common C++. This may seem weird, but it would be the only
 // dependency on libccext, so we prefer to reduce the library
 // footprint.
 
-#ifdef CCXX_NAMESPACES
-namespace ccMD5 {
-using namespace std;
-#endif
-
 /**
  * The digest base class is used for implementing and deriving one way
  * hashing functions.
@@ -159,7 +157,7 @@
     void putDigest(const unsigned char *buffer, unsigned len);
 };
 
-#ifdef  WIN32
+#ifdef  _MSWINDOWS_
 #include <io.h>
 #endif
 
@@ -438,7 +436,7 @@
     commit();
 
     for(i = 0; i < 16; ++i)
-#ifdef  WIN32
+#ifdef  _MSWINDOWS_
         sprintf(dbuf + 2 * i, "%02x", md5[i]);
 #else
         std::sprintf(dbuf + 2 * i, "%02x", md5[i]);
@@ -447,17 +445,16 @@
     return os;
 }
 
-#ifdef  CCXX_NAMESPACES
-} // end namespace ccMD5 (and copy of MD5 Common C++ classes)
-#endif
-
 static uint32 MD5BasedRandom32()
 {
+    // for bizzare gcc wierdness with type visibility
+    typedef timeval md5time_t;
+
     // This is the input to the MD5 algorithm.
     union {
         uint8 array[1];
         struct {
-            timeval time;
+            md5time_t time;
             void *address;
             uint8 cname[10];
         } data;
@@ -469,7 +466,7 @@
         uint8 buf8[16];
     } digest;
 
-    gettimeofday(&(message.data.time),NULL);
+    SysTime::gettimeofday(&(message.data.time),NULL);
     message.array[0] =
         static_cast<uint8>(message.data.time.tv_sec *
                    message.data.time.tv_usec);
@@ -479,7 +476,7 @@
            defaultApplication().getSDESItem(SDESItemTypeCNAME).c_str(),10);
 
     // compute MD5.
-    ccMD5::MD5Digest md5;
+    MD5Digest md5;
     md5.putDigest(reinterpret_cast<unsigned char*>(message.array),
               sizeof(message));
     md5.getDigest(reinterpret_cast<unsigned char*>(digest.buf8));
@@ -496,7 +493,7 @@
     // If /dev/urandom fails, default to the MD5 based algorithm
     // given in the RTP specification.
     uint32 number;
-#ifndef WIN32
+#ifndef _MSWINDOWS_
     bool success = true;
     int fd = open("/dev/urandom",O_RDONLY);
     if (fd == -1) {
@@ -530,7 +527,7 @@
     // assume a default rate and payload type.
     setPayloadFormat(StaticPayloadFormat(sptPCMU));
     // queue/session creation time
-    gettimeofday(&initialTime,NULL);
+    SysTime::gettimeofday(&initialTime,NULL);
 }
 
 const uint32 RTPDataQueue::defaultSessionBw = 64000;
@@ -579,7 +576,7 @@
 {
     // translate from current time to timestamp
     timeval now;
-    gettimeofday(&now,NULL);
+    SysTime::gettimeofday(&now,NULL);
 
     int32 result = now.tv_usec - getInitialTime().tv_usec;
     result *= (getCurrentRTPClockRate()/1000);
@@ -590,9 +587,7 @@
     return result;
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/rtcppkt.cpp b/jni/libccrtp/sources/src/rtcppkt.cpp
index 0e0e878..dbd7727 100644
--- a/jni/libccrtp/sources/src/rtcppkt.cpp
+++ b/jni/libccrtp/sources/src/rtcppkt.cpp
@@ -44,9 +44,7 @@
 #include "private.h"
 #include <ccrtp/rtcppkt.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 #if __BYTE_ORDER == __BIG_ENDIAN
 const uint16 RTCPCompoundHandler::RTCP_VALID_MASK = (0xc000 | 0x2000  | 0xfe);
@@ -136,9 +134,7 @@
     return true;
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/rtppkt.cpp b/jni/libccrtp/sources/src/rtppkt.cpp
index 1ab27f9..3d29100 100644
--- a/jni/libccrtp/sources/src/rtppkt.cpp
+++ b/jni/libccrtp/sources/src/rtppkt.cpp
@@ -46,9 +46,7 @@
 #include <ccrtp/rtppkt.h>
 #include <ccrtp/CryptoContext.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
 // Default to 8Khz when no value is specified.
 const uint32 PayloadFormat::defaultRTPClockRate = 8000;
@@ -332,7 +330,7 @@
     /* Guess the index */
     uint64 guessedIndex = pcc->guessIndex(cachedSeqNum);
 
-    uint32 guessedRoc = guessedIndex >> 16;
+    uint32 guessedRoc = (uint32)(guessedIndex >> 16);
     uint8* mac = new uint8[pcc->getTagLength()];
 
     pcc->srtpAuthenticate(this, guessedRoc, mac);
@@ -351,9 +349,7 @@
     return 1;
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/socket.cpp b/jni/libccrtp/sources/src/socket.cpp
index 0377dd8..5a5189f 100644
--- a/jni/libccrtp/sources/src/socket.cpp
+++ b/jni/libccrtp/sources/src/socket.cpp
@@ -41,13 +41,9 @@
 #include "private.h"
 #include <ccrtp/channel.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
+NAMESPACE_COMMONCPP
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/source.cpp b/jni/libccrtp/sources/src/source.cpp
index ca153be..3254311 100644
--- a/jni/libccrtp/sources/src/source.cpp
+++ b/jni/libccrtp/sources/src/source.cpp
@@ -44,29 +44,12 @@
 #include "private.h"
 #include <ccrtp/sources.h>
 
-#ifdef  CCXX_NAMESPACES
-namespace ost {
-#endif
-
-#ifndef HAVE_GETTIMEOFDAY
-#ifdef WIN32
-int gettimeofday(struct timeval *tv_,  void *tz_)
-{
-    // We could use _ftime(), but it is not available on WinCE.
-    // (WinCE also lacks time.h)
-    // Note also that the average error of _ftime is around 20 ms :)
-    DWORD ms = GetTickCount();
-    tv_->tv_sec = ms / 1000;
-    tv_->tv_usec = ms * 1000;
-    return 0;
-}
-#endif //WIN32
-#endif
+NAMESPACE_COMMONCPP
 
 static void
 findusername(std::string &username);
 
-#ifndef WIN32
+#ifndef _MSWINDOWS_
 static void
 findusername(std::string &username)
 {
@@ -244,9 +227,7 @@
             username + "@" + hname);
 }
 
-#ifdef  CCXX_NAMESPACES
-}
-#endif
+END_NAMESPACE
 
 /** EMACS **
  * Local variables:
diff --git a/jni/libccrtp/sources/src/stamp-h1 b/jni/libccrtp/sources/src/stamp-h1
deleted file mode 100644
index 57ea58e..0000000
--- a/jni/libccrtp/sources/src/stamp-h1
+++ /dev/null
@@ -1 +0,0 @@
-timestamp for src/config.h