[Pkg-voip-commits] [ortp] 01/06: New upstream version 0.27.0

daniel at gnoutcheff.name daniel at gnoutcheff.name
Thu Jan 12 05:06:18 UTC 2017


This is an automated email from the git hooks/post-receive script.

gnoutchd-guest pushed a commit to branch master
in repository ortp.

commit 1224eba2e3a845a7399f088a241adb06567edcdf
Author: Daniel Gnoutcheff <daniel at gnoutcheff.name>
Date:   Tue Jan 10 21:27:48 2017 -0500

    New upstream version 0.27.0
---
 .clang-format                 |   64 ++
 .git-pre-commit               |   51 +
 .gitignore                    |    1 +
 CMakeLists.txt                |  104 +-
 Makefile.am                   |    4 +-
 NEWS                          |   14 +
 ORTPConfig.cmake.in           |   16 +-
 autogen.sh                    |    9 +-
 configure.ac                  |   37 +-
 debian/changelog              |   20 -
 debian/compat                 |    1 -
 debian/control                |   53 -
 debian/copyright              |   81 --
 debian/libortp-dev.docs       |    1 -
 debian/libortp-dev.install    |    4 -
 debian/libortp9.docs          |    3 -
 debian/libortp9.install       |    1 -
 debian/rules                  |   17 -
 debian/source/format          |    1 -
 debian/source/options         |    2 -
 debian/watch                  |    3 -
 include/CMakeLists.txt        |   27 +-
 include/ortp/b64.h            |    2 +-
 include/ortp/event.h          |   80 +-
 include/ortp/logging.h        |   45 +-
 include/ortp/payloadtype.h    |   12 +-
 include/ortp/port.h           |   33 +-
 include/ortp/rtcp.h           |   26 +-
 include/ortp/rtp.h            |    3 +
 include/ortp/rtpprofile.h     |   11 +-
 include/ortp/rtpsession.h     |  114 +-
 include/ortp/rtpsignaltable.h |    6 +-
 include/ortp/sessionset.h     |   12 +-
 include/ortp/str_utils.h      |    5 +-
 ortp.doxygen.in               | 2350 +++++++++++++++++++++++++++++++++++++++--
 ortp.spec.in                  |    2 +-
 src/CMakeLists.txt            |   73 +-
 src/Makefile.am               |    5 +-
 src/avprofile.c               |   41 +-
 src/dll_entry.c               |   10 +-
 src/event.c                   |   96 ++
 src/jitterctl.c               |    9 +-
 src/logging.c                 |  323 ++++--
 src/netsim.c                  |  104 +-
 src/ortp.c                    |   16 +-
 src/payloadtype.c             |    2 +-
 src/port.c                    |  109 +-
 src/posixtimer.c              |   12 +-
 src/rtcp.c                    |   58 +-
 src/rtcp_fb.c                 |   78 +-
 src/rtcp_xr.c                 |    2 +-
 src/rtcpparse.c               |   53 +-
 src/rtpparse.c                |   28 +-
 src/rtpprofile.c              |   37 +-
 src/rtpsession.c              |  417 +++++---
 src/rtpsession_inet.c         |  570 +++++-----
 src/rtpsession_priv.h         |   25 +-
 src/rtpsignaltable.c          |   10 +-
 src/rtptimer.h                |    4 +-
 src/scheduler.c               |    2 +
 src/sessionset.c              |   18 +-
 src/str_utils.c               |   47 +-
 src/telephonyevents.c         |   57 +-
 src/tests/CMakeLists.txt      |   13 +
 src/tests/Makefile.am         |    2 +-
 src/tests/rtprecv.c           |    2 +-
 src/tests/rtpsend.c           |    9 +-
 src/tests/rtpsend_stupid.c    |    4 +-
 src/tests/tevrtprecv.c        |   17 +-
 src/utils.c                   |   24 +
 src/utils.h                   |   14 +-
 src/winrttimer.cpp            |   10 +-
 72 files changed, 4269 insertions(+), 1247 deletions(-)

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..769b266
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,64 @@
+---
+# BasedOnStyle:  LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: true
+AlignEscapedNewlinesLeft: false
+AlignOperands:   true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: false
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: false
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Attach
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+ColumnLimit:     120
+CommentPragmas:  '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+DisableFormat:   false
+ExperimentalAutoDetectBinPacking: false
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IndentCaseLabels: false
+IndentFunctionDeclarationAfterType: false
+IndentWidth:     4
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: true
+Language:        Cpp
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Cpp11
+TabWidth:        4
+UseTab:          Always
+...
diff --git a/.git-pre-commit b/.git-pre-commit
new file mode 100755
index 0000000..69a71be
--- /dev/null
+++ b/.git-pre-commit
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+# This hook purpose is to keep coding style consistent between all developers
+# It is automatically installed in .git/hooks folder by cmake on first run.
+
+# From https://github.com/tatsuhiro-t/nghttp2/blob/master/pre-commit
+
+function invalid-format-detected {
+        cat git-clang-format.diff
+        echo "*****************"
+        echo "$0: Invalid coding style detected (see git-clang-format.diff for issues). Please correct it using one of the following:"
+        echo "1) Apply patch located at git-clang-format.diff using:"
+        echo "  cd $(git rev-parse --show-toplevel) && $1"
+        echo "2) Use clang-format to correctly format source code using:"
+        echo "  $2"
+        echo "3) Reformat these lines manually."
+        echo "*** Aborting commit.***"
+        exit 1
+}
+function git-clang-format-diffing {
+    format_diff=$(which git-clang-format)
+    format_diff_options="--style=file"
+
+    #only diffing commited files, ignored staged one
+    $format_diff $format_diff_options --diff $(git --no-pager diff --cached --name-status | grep -v '^D' | cut -f2) > git-clang-format.diff
+
+    if ! grep -q -E '(no modified files to format|clang-format did not modify any files)' git-clang-format.diff; then
+        invalid-format-detected "git apply git-clang-format.diff" "clang-format $format_diff_options -i <some_file.c>"
+    fi
+}
+
+function clang-format-diff-diffing {
+    format_diff=$(find /usr/bin/ -name 'clang-format-diff*' -type f | tail -n1)
+    format_diff_options="-style file"
+
+    git diff-index --cached --diff-filter=ACMR -p HEAD -- | $format_diff $format_diff_options -p1 > git-clang-format.diff
+    if [ -s git-clang-format.diff ]; then
+        invalid-format-detected "patch -p0 < git-clang-format.diff" "${format_diff/-diff/} $format_diff_options -i <some_file.cpp>"
+    fi
+}
+
+set -e
+if which git-clang-format &>/dev/null; then
+    git-clang-format-diffing $@
+elif [ ! -z "$(find /usr/bin/ /usr/local/bin/ /opt/bin/ -name 'clang-format-diff*' -type f 2>/dev/null)" ]; then
+    # Warning! We need at least version 1.6...
+    clang-format-diff-diffing $@
+else
+    echo "$0: Please install clang-format (coding style checker) - could not find git-clang-format nor clang-format-diff in PATH. Skipping code verification..."
+    exit 0
+fi
diff --git a/.gitignore b/.gitignore
index b745861..6a0ce76 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@ INSTALL
 stamp-h1
 *.vcxproj.*
 compile
+git-clang-format.diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cf01127..5026f81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,29 +21,51 @@
 ############################################################################
 
 cmake_minimum_required(VERSION 3.0)
-project(ORTP)
+project(oRTP VERSION 0.27.0)
 
 
-set(ORTP_MAJOR_VERSION "0")
-set(ORTP_MINOR_VERSION "24")
-set(ORTP_MICRO_VERSION "2")
-set(ORTP_VERSION "${ORTP_MAJOR_VERSION}.${ORTP_MINOR_VERSION}.${ORTP_MICRO_VERSION}")
-set(ORTP_SO_VERSION "9")
+set(ORTP_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
+set(ORTP_MINOR_VERSION ${PROJECT_VERSION_MINOR})
+set(ORTP_MICRO_VERSION ${PROJECT_VERSION_PATCH})
+set(ORTP_VERSION ${PROJECT_VERSION})
+set(ORTP_SO_VERSION "12") # incremented on June, the 1st 2016. DO NOT INCREMENT BEFORE ORTP 0.28
 
 
-option(ENABLE_STATIC "Build static library (default is shared library)." NO)
+option(ENABLE_SHARED "Build shared library." YES)
+option(ENABLE_STATIC "Build static library." YES)
 option(ENABLE_DOC "Enable documentation generation with Doxygen." YES)
 option(ENABLE_NTP_TIMESTAMP "Turn on NTP timestamping on packet reception." NO)
 option(ENABLE_PERF "Disable costly features to reduce cpu consumtion and increase performance." NO)
+option(ENABLE_STRICT "Build with strict compile options." YES)
 option(ENABLE_TESTS "Enable compilation of test programs." NO)
-set(CACHE WITH_THREAD_STACK_SIZE "0" CACHE STRING "Set thread stack size (0 is the OS default).")
-
-
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH}/share/cmake/Modules)
+option(ENABLE_DEBUG_LOGS "Turn on or off debug level logs." NO)
+set(WITH_THREAD_STACK_SIZE "0" CACHE STRING "Set thread stack size (0 is the OS default).")
+
+
+macro(apply_compile_flags SOURCE_FILES)
+	if(${SOURCE_FILES})
+		set(options "")
+		foreach(a ${ARGV})
+			if(STRICT_OPTIONS_${a})
+				string(REPLACE ";" " " options_${a} "${STRICT_OPTIONS_${a}}")
+				set(options "${options} ${options_${a}}")
+			endif()
+		endforeach()
+		if(options)
+			set_source_files_properties(${${SOURCE_FILES}} PROPERTIES COMPILE_FLAGS "${options}")
+		endif()
+	endif()
+endmacro()
 
 
 include(CheckIncludeFile)
 include(CheckFunctionExists)
+include(GNUInstallDirs)
+
+if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
+	set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
+	message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
+endif()
 
 set(MSVC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/MSVC")
 if(MSVC)
@@ -51,6 +73,13 @@ if(MSVC)
 endif()
 
 find_package(Threads)
+find_library(LIBM NAMES m)
+
+if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
+	include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
+else()
+	find_package(BcToolbox 0.0.3 REQUIRED)
+endif()
 
 check_include_file(sys/uio.h HAVE_SYS_UIO_H)
 check_include_file(sys/audio.h HAVE_SYS_AUDIO_H)
@@ -68,6 +97,7 @@ include_directories(
 	include/
 	src/
 	${CMAKE_CURRENT_BINARY_DIR}
+	${BCTOOLBOX_CORE_INCLUDE_DIRS}
 )
 if(MSVC)
 	include_directories(${MSVC_INCLUDE_DIR})
@@ -85,7 +115,7 @@ endif()
 if(ENABLE_NTP_TIMESTAMP)
 	set(ORTP_TIMESTAMP 1)
 endif()
-if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+if(ENABLE_DEBUG_LOGS)
 	set(ORTP_DEBUG_MODE 1)
 endif()
 if(CMAKE_USE_PTHREADS_INIT)
@@ -98,15 +128,37 @@ set(POSIXTIMER_INTERVAL 10000)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ortp-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/ortp-config.h)
 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/ortp-config.h PROPERTIES GENERATED ON)
 add_definitions(-DHAVE_CONFIG_H)
+
+set(STRICT_OPTIONS_CPP )
+set(STRICT_OPTIONS_C )
 if(NOT MSVC)
-	add_definitions(-Wall -Wno-error=unknown-pragmas)
-	if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
-		add_definitions(-Werror -Wno-error=unknown-warning-option -Qunused-arguments -Wno-tautological-compare)
-	elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
-		add_definitions(-Werror -Wno-error=pragmas)
+	list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized")
+	list(APPEND STRICT_OPTIONS_C "-Wdeclaration-after-statement" "-Wstrict-prototypes" "-Wno-error=strict-prototypes")
+	if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+		list(APPEND STRICT_OPTIONS_CPP "-Qunused-arguments" "-Wno-array-bounds")
 	endif()
+	if(APPLE)
+		list(APPEND STRICT_OPTIONS_CPP "-Wno-error=unknown-warning-option" "-Qunused-arguments" "-Wno-tautological-compare" "-Wno-unused-function" "-Wno-array-bounds")
+	endif()
+	if(ENABLE_STRICT)
+		list(APPEND STRICT_OPTIONS_CPP "-Werror" "-fno-strict-aliasing")
+	endif()
+endif()
+if(STRICT_OPTIONS_CPP)
+	list(REMOVE_DUPLICATES STRICT_OPTIONS_CPP)
+endif()
+if(STRICT_OPTIONS_C)
+	list(REMOVE_DUPLICATES STRICT_OPTIONS_C)
 endif()
 
+
+if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
+	set(EXPORT_TARGETS_NAME "LinphoneBuilder")
+else()
+	set(EXPORT_TARGETS_NAME "ORTP")
+endif()
+
+
 add_subdirectory(include)
 add_subdirectory(src)
 
@@ -125,9 +177,9 @@ if(ENABLE_DOC)
 			COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/ortp.doxygen
 			DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ortp.doxygen ${DOC_INPUT_FILES}
 		)
-		add_custom_target(html-doc ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html")
+		add_custom_target(ortp-html-doc ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/doc/html/index.html")
 		install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doc/html"
-			DESTINATION "share/doc/oRTP-${ORTP_VERSION}")
+			DESTINATION "${CMAKE_INSTALL_DATADIR}/doc/oRTP-${ORTP_VERSION}")
 	endif()
 endif()
 
@@ -142,7 +194,7 @@ set(ORTP_PKGCONFIG_VERSION "${ORTP_VERSION}")
 set(ORTPDEPS_LIBS )
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ortp.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ortp.pc)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ortp.pc DESTINATION lib/pkgconfig)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ortp.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
 
 
 include(CMakePackageConfigHelpers)
@@ -151,23 +203,21 @@ write_basic_package_version_file(
 	VERSION ${ORTP_VERSION}
 	COMPATIBILITY AnyNewerVersion
 )
-export(EXPORT ORTPTargets
+export(EXPORT ${EXPORT_TARGETS_NAME}Targets
 	FILE "${CMAKE_CURRENT_BINARY_DIR}/ORTPTargets.cmake"
-	NAMESPACE BelledonneCommunications::
 )
 configure_file(ORTPConfig.cmake.in
 	"${CMAKE_CURRENT_BINARY_DIR}/ORTPConfig.cmake"
 	@ONLY
 )
 
-set(ConfigPackageLocation lib/cmake/oRTP)
-install(EXPORT ORTPTargets
+set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
+install(EXPORT ${EXPORT_TARGETS_NAME}Targets
 	FILE ORTPTargets.cmake
-	NAMESPACE BelledonneCommunications::
-	DESTINATION ${ConfigPackageLocation}
+	DESTINATION ${CONFIG_PACKAGE_LOCATION}
 )
 install(FILES
 	"${CMAKE_CURRENT_BINARY_DIR}/ORTPConfig.cmake"
 	"${CMAKE_CURRENT_BINARY_DIR}/ORTPConfigVersion.cmake"
-	DESTINATION ${ConfigPackageLocation}
+	DESTINATION ${CONFIG_PACKAGE_LOCATION}
 )
diff --git a/Makefile.am b/Makefile.am
index 7ba951f..cf3c36f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@
 
 ACLOCAL_AMFLAGS = -I m4 $(ACLOCAL_MACOS_FLAGS)
 
-EXTRA_DIST = oRTP.prj ortp-config.h.in TODO pkg.list autogen.sh ortp.pc.in ortp.spec.in ortp.spec ortp.doxygen oRTP.pws
+EXTRA_DIST = oRTP.prj ortp-config.h.in TODO pkg.list autogen.sh ortp.pc.in ortp.spec.in ortp.spec ortp.doxygen oRTP.pws CMakeLists.txt include/CMakeLists.txt src/CMakeLists.txt src/tests/CMakeLists.txt ORTPConfig.cmake.in ortp-config.h.cmake
 
 
 SUBDIRS=src build m4 include
@@ -90,7 +90,7 @@ endif WITH_EPM
 
 distclean-local:
 	-rm -f ortp.defs
-	-rm -rf doc/html
+	-rm -rf doc
 
 all-local: ortp.spec
 
diff --git a/NEWS b/NEWS
index 9710d3b..238da5d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,17 @@
+June 1st 2016: ortp-0.27.0
+
+May XX, 2016: 
+	- Fix DSCP on Windows.
+	- bctoolbox added as dependency
+	- fixes around IPv6 support for windows and android
+
+January 22, 2016: ortp-0.26.0
+
+November 2, 2015: ortp-0.25.0
+	- Support AVPF generic NACK
+	- Add payload types for RTT (Real-Time Text) and Codec2
+	- Bug fixes
+
 May 6, 2015: ortp-0.24.2
 	- Bug fixes
 
diff --git a/ORTPConfig.cmake.in b/ORTPConfig.cmake.in
index 42843c4..bd6a236 100644
--- a/ORTPConfig.cmake.in
+++ b/ORTPConfig.cmake.in
@@ -28,10 +28,20 @@
 #  ORTP_LIBRARIES - The libraries needed to use oRTP
 #  ORTP_CPPFLAGS - The cflags needed to use oRTP
 
-include("${CMAKE_CURRENT_LIST_DIR}/ORTPTargets.cmake")
+if(NOT LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
+	include("${CMAKE_CURRENT_LIST_DIR}/ORTPTargets.cmake")
+endif()
 
 get_filename_component(ORTP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
-set(ORTP_INCLUDE_DIRS "${ORTP_CMAKE_DIR}/../../../include")
-set(ORTP_LIBRARIES BelledonneCommunications::ortp)
+if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
+	set(ORTP_INCLUDE_DIRS "${EP_ortp_INCLUDE_DIR}")
+else()
+	set(ORTP_INCLUDE_DIRS "${ORTP_CMAKE_DIR}/../../../include")
+endif()
+if(@ENABLE_SHARED@)
+	set(ORTP_LIBRARIES ortp)
+else()
+	set(ORTP_LIBRARIES ortp-static)
+endif()
 set(ORTP_CPPFLAGS @ORTP_CPPFLAGS@)
 set(ORTP_FOUND 1)
diff --git a/autogen.sh b/autogen.sh
index ad828da..7b389a8 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -37,13 +37,18 @@ if test -d /share/aclocal ; then
         ACLOCAL_ARGS="$ACLOCAL_ARGS -I /share/aclocal"
 fi
 
-
 set -x
 rm -rf config.cache autom4te.cache
 $libtoolize --copy --force
 $ACLOCAL -I m4 $ACLOCAL_ARGS
 autoheader
-$AUTOMAKE --force-missing --add-missing --copy  
+$AUTOMAKE --force-missing --add-missing --copy
 autoconf
 
+#install git pre-commit hooks if possible
+if [ -d .git/hooks ] && [ ! -f .git/hooks/pre-commit ]; then
+        cp .git-pre-commit .git/hooks/pre-commit
+        chmod +x .git/hooks/pre-commit
+fi
+
 cd $THEDIR
diff --git a/configure.ac b/configure.ac
index 3b47246..42d64d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT([ortp],[0.24.2])
+AC_INIT([ortp],[0.27.0])
 AC_CANONICAL_SYSTEM
 
 case $INSTALL in
@@ -14,7 +14,7 @@ ORTP_MINOR_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f2)
 ORTP_MICRO_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f3)
 ORTP_EXTRA_VERSION=$(echo $PACKAGE_VERSION | cut -d. -f4)
 
-LIBORTP_SO_CURRENT=9 dnl increment this number when you add/change/remove an interface
+LIBORTP_SO_CURRENT=11 dnl increment this number when you add/change/remove an interface
 LIBORTP_SO_REVISION=0 dnl increment this number when you change source code, without changing interfaces; set to 0 when incrementing CURRENT
 LIBORTP_SO_AGE=0 dnl increment this number when you add an interface, set to 0 if you remove an interface
 
@@ -60,7 +60,7 @@ AC_ARG_ENABLE(strict,
 )
 
 STRICT_OPTIONS="-Wall -Wuninitialized"
-STRICT_OPTIONS_CC="-Wdeclaration-after-statement "
+STRICT_OPTIONS_CC="-Wdeclaration-after-statement -Wstrict-prototypes"
 STRICT_OPTIONS_CXX=""
 
 #for clang
@@ -82,7 +82,7 @@ case "$target_os" in
 esac
 
 if test "$strictness" = "yes" ; then
-	STRICT_OPTIONS="$STRICT_OPTIONS -Werror"
+	STRICT_OPTIONS="$STRICT_OPTIONS -Werror -Wno-error=strict-prototypes"
 	CFLAGS="$CFLAGS -fno-strict-aliasing"
 fi
 
@@ -274,28 +274,15 @@ if test "$perf" = "yes" ; then
 	CFLAGS="$CFLAGS -DPERF"
 fi
 
-AC_ARG_ENABLE(ssl-hmac,
-	[AS_HELP_STRING([--enable-ssl-hmac], [Enable use of ssl/hmac for stun (default=no)])],
-	[case "${enableval}" in
-		yes)	ssl_hmac_enabled=yes;;
-		no)	ssl_hmac_enabled=no;;
-		*)	AC_MSG_ERROR("Bad value for --enable-ssl-hmac");;
-	esac],
-	[ssl_hmac_enabled=no]
-)
 
-if test "$ssl_hmac_enabled" = "yes" ; then
-	AC_CHECK_HEADERS(openssl/hmac.h openssl/md5.h)
-	AC_CHECK_LIB(ssl,SSL_CTX_new,[SSL_LIBS="-lssl"])
-	AC_CHECK_LIB(crypto,MD5,[SSL_LIBS="$SSL_LIBS -lcrypto"])
+PKG_CHECK_MODULES(BCTOOLBOX, bctoolbox, [found_bctoolbox=yes],[found_bctoolbox=no])
+if test "x$found_bctoolbox" != "xyes" ; then
+	AC_MSG_ERROR(["Could not find bctoolbox (required dependency)"])
 fi
 
 
-
-AC_SUBST(SSL_LIBS)
-
-ORTPDEPS_LIBS="$ORTPDEPS_LIBS $PTHREAD_LIBS $PTHREAD_LDFLAGS $RT_LIBS $SSL_LIBS"
-ORTPDEPS_CFLAGS="$ORTPDEPS_CFLAGS $PTHREAD_CFLAGS $ORTP_DEFS"
+ORTPDEPS_LIBS="$ORTPDEPS_LIBS $PTHREAD_LIBS $PTHREAD_LDFLAGS $RT_LIBS $BCTOOLBOX_LIBS"
+ORTPDEPS_CFLAGS="$ORTPDEPS_CFLAGS $PTHREAD_CFLAGS $ORTP_DEFS $BCTOOLBOX_CFLAGS"
 CFLAGS="$CFLAGS $ORTP_DEFS"
 echo "$ORTPDEPS_CFLAGS" > ortp.defs
 
@@ -321,12 +308,12 @@ esac
 dnl ##################################################
 dnl # Check for doxygen
 dnl ##################################################
-AC_ARG_ENABLE(doxygen,
-	[AS_HELP_STRING([--disable-documentation], [Disable documentation generation using doxygen (default=no)])],
+AC_ARG_ENABLE(documentation,
+	[AS_HELP_STRING([--enable-documentation], [Documentation generation using doxygen (default=yes)])],
 	[case "${enableval}" in
 		yes)	documentation_enabled=yes;;
 		no)		documentation_enabled=no;;
-		*)		AC_MSG_ERROR("Bad value for --disable-documentation");;
+		*)		AC_MSG_ERROR("Bad value for --enable-documentation");;
 	esac],
 	[documentation_enabled=yes]
 )
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index 33a33c9..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,20 +0,0 @@
-ortp (0.23.0) unstable; urgency=low
-
-  * Network simulator improvements
-  * Security bugfixes
-  * Updated to use ZRTPCPP>=4.0
-
- -- Sylvain Berfini <sylvain.berfini at linphone.org>  Mon, 31 March 2013 15:10:01 +0200
-
-ortp (0.22.0) unstable; urgency=low
-
-  * New version + migrate to ABI9.
-  * 
-
- -- Guillaume Beraudo <guillaume.beraudo at linphone.org>  Thu, 30 May 2013 15:32:14 +0200
-
-ortp (0.21.0) unstable; urgency=low
-
-  * Initial Release.
-
- -- Guillaume Beraudo <guillaume.beraudo at linphone.org>  Fri, 3 May 2012 13:58:16 +0200
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 45a4fb7..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-8
diff --git a/debian/control b/debian/control
deleted file mode 100644
index daafbbf..0000000
--- a/debian/control
+++ /dev/null
@@ -1,53 +0,0 @@
-Source: ortp
-Section: sound
-Priority: optional
-Maintainer: Debian VoIP Team <pkg-voip-maintainers at lists.alioth.debian.org>
-Uploaders: Samuel Mimram <smimram at debian.org>, Kilian Krause <kilian at debian.org>, Faidon Liambotis <paravoid at debian.org>, Mark Purcell <msp at debian.org>, Lionel Elie Mamane <lmamane at debian.org>, Tzafrir Cohen <tzafrir at debian.org>
-Build-Depends: debhelper (>= 8),
- autoconf, automake, autotools-dev, libtool, pkg-config, intltool,
- libglib2.0-dev, 
- doxygen
-Standards-Version: 3.9.1
-Homepage: http://www.linphone.org/
-Vcs-Svn: svn://svn.debian.org/pkg-voip/linphone/trunk/
-Vcs-Browser: http://anonscm.debian.org/viewvc/pkg-voip/linphone/trunk/
-
-
-Package: libortp9
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Real-time Transport Protocol stack
- This library implements the RFC1889 (RTP) with a easy to use API with high
- and low level access.
- .
- Its main features are:
-   - support for multiple profiles, AV profile (RFC 1890) being the default one;
-   - an optional packet scheduler for synchronizing RTP recv and send;
-   - implements blocking and non blocking IO for RTP sessions;
-   - supports multiplexing IO;
-   - supports part of RFC2833 for telephone events over RTP.
-
-Package: libortp-dev
-Section: libdevel
-Architecture: any
-Depends: ${misc:Depends}, libortp9 (= ${binary:Version})
-Conflicts: libortp7-dev
-Description: Real-time Transport Protocol stack
- This library implements the RFC1889 (RTP) with a easy to use API with high
- and low level access.
- .
- Its main features are:
-   - support for multiple profiles, AV profile (RFC 1890) being the default one;
-   - an optional packet scheduler for synchronizing RTP recv and send;
-   - implements blocking and non blocking IO for RTP sessions;
-   - supports multiplexing IO;
-   - supports part of RFC2833 for telephone events over RTP.
-
-Package: libortp9-dbg
-Architecture: any
-Depends: libortp9 (= ${binary:Version}), ${misc:Depends}
-Section: debug
-Priority: extra
-Description: Debugging symbols for ortp
- .
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 858da74..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,81 +0,0 @@
-This package was debianized by Samuel Mimram <samuel.mimram at ens-lyon.org> on
-Wed, 30 Jun 2004 13:58:16 +0200.
-
-It was downloaded from http://www.linphone.org/
-
-Upstream Authors: Simon Morlat, Florian Wintertein, Aymeric Moizard, Sharath Udupa.
-
-Copyright (C) 2001-2005 Simon Morlat
-
- 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.
-
-On Debian systems you can find a copy of this license in
-/usr/share/common-licenses/GPL.
-
-
-Some libraries are under other copyrights / licenses:
-
-* FFmpeg: Copyright (C) 2000, 2001 Gerard Lantau.
-  Released under the GNU General Public License
-  (see /usr/share/common-licenses/GPL)
-
-* gsmlib: Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann,
-  Technische Universitaet Berlin
-
-  Released under the following license:
-
-  Any use of this software is permitted provided that this notice is not
-  removed and that neither the authors nor the Technische Universitaet Berlin
-  are deemed to have made any representations as to the suitability of this
-  software for any purpose nor are held responsible for any defects of
-  this software.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
-
-  As a matter of courtesy, the authors request to be informed about uses
-  this software has found, about bugs in this software, and about any
-  improvements that may be of general interest.
-
-  Berlin, 28.11.1994
-  Jutta Degener
-  Carsten Bormann
-
-* oRTP: Copyright (C) Simon Morlat
-  Released under the GNU Lesser General Public License
-  (see /usr/share/common-licenses/LGPL).
-
-* osipua: Copyright (C) 2001 Simon Morlat and Aymeric Moizard
-  Released under the GNU Lesser General Public License
-  (see /usr/share/common-licenses/LGPL).
-
-* speex: Copyright (C) 2002-2003 Jean-Marc Valin
-
-  Released under the following license:
-
-  Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions
-  are met:
-
-  - Redistributions of source code must retain the above copyright
-  notice, this list of conditions and the following disclaimer.
-
-  - Redistributions in binary form must reproduce the above copyright
-  notice, this list of conditions and the following disclaimer in the
-  documentation and/or other materials provided with the distribution.
-
-  - Neither the name of the Xiph.org Foundation nor the names of its
-  contributors may be used to endorse or promote products derived from
-  this software without specific prior written permission.
-
-  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-  A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
-  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/debian/libortp-dev.docs b/debian/libortp-dev.docs
deleted file mode 100644
index 1879fe9..0000000
--- a/debian/libortp-dev.docs
+++ /dev/null
@@ -1 +0,0 @@
-usr/share/doc/ortp-*/html/
diff --git a/debian/libortp-dev.install b/debian/libortp-dev.install
deleted file mode 100644
index 6c8310d..0000000
--- a/debian/libortp-dev.install
+++ /dev/null
@@ -1,4 +0,0 @@
-usr/include/ortp/*.h
-usr/lib/libortp.so
-usr/lib/pkgconfig/ortp.pc
-usr/share/doc/ortp-*/html usr/share/doc/libortp9-dev
diff --git a/debian/libortp9.docs b/debian/libortp9.docs
deleted file mode 100644
index ca0272a..0000000
--- a/debian/libortp9.docs
+++ /dev/null
@@ -1,3 +0,0 @@
-AUTHORS
-README
-TODO
diff --git a/debian/libortp9.install b/debian/libortp9.install
deleted file mode 100644
index 8fc0ef9..0000000
--- a/debian/libortp9.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/libortp.so.*
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 41bb54a..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/make -f
-
-%:
-	dh $@ --parallel --with autotools_dev
-
-override_dh_auto_configure:
-	./configure --prefix=/usr --with-srtp=none
-# As of today, neither flexisip or linphone need the broken srtp
-
-override_dh_makeshlibs:
-	dh_makeshlibs -V
-
-override_dh_installchangelogs:
-	dh_installchangelogs NEWS
-
-override_dh_strip:
-	dh_strip --dbg-package=libortp9-dbg
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 89ae9db..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (native)
diff --git a/debian/source/options b/debian/source/options
deleted file mode 100644
index 0d4d1a4..0000000
--- a/debian/source/options
+++ /dev/null
@@ -1,2 +0,0 @@
-# Don't store changes on autogenerated files
-extend-diff-ignore = "(^|/)(config\.sub|config\.guess|Makefile|m4/.*)$"
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index 3b9155f..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,3 +0,0 @@
-version=3
-
-http://download.savannah.gnu.org/releases-noredirect/linphone/stable/sources/ linphone-([\d\.]+).tar.gz debian svn-upgrade
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 3511033..2cca4c4 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -20,8 +20,29 @@
 #
 ############################################################################
 
-file(GLOB HEADER_FILES "ortp/*.h")
+set(HEADER_FILES
+	b64.h
+	event.h
+	logging.h
+	ortp.h
+	payloadtype.h
+	port.h
+	rtcp.h
+	rtp.h
+	rtpprofile.h
+	rtpsession.h
+	rtpsignaltable.h
+	sessionset.h
+	str_utils.h
+	telephonyevents.h
+)
 
-install(FILES ${HEADER_FILES}
-        DESTINATION include/ortp
+set(ORTP_HEADER_FILES )
+foreach(HEADER_FILE ${HEADER_FILES})
+	list(APPEND ORTP_HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/ortp/${HEADER_FILE}")
+endforeach()
+set(ORTP_HEADER_FILES ${ORTP_HEADER_FILES} PARENT_SCOPE)
+
+install(FILES ${ORTP_HEADER_FILES}
+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ortp
         PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
diff --git a/include/ortp/b64.h b/include/ortp/b64.h
index b39ddfe..c275a26 100644
--- a/include/ortp/b64.h
+++ b/include/ortp/b64.h
@@ -41,7 +41,7 @@
  * ////////////////////////////////////////////////////////////////////////// */
 
 
-/** \file b64/b64.h
+/** \file ortp/b64.h
  *
  * \brief [C/C++] Header file for the b64 library.
  */
diff --git a/include/ortp/event.h b/include/ortp/event.h
index 1c90c64..058a3d2 100644
--- a/include/ortp/event.h
+++ b/include/ortp/event.h
@@ -21,6 +21,7 @@
 #define ortp_events_h
 
 #include <ortp/str_utils.h>
+#include <ortp/rtcp.h>
 
 typedef mblk_t OrtpEvent;
 
@@ -41,13 +42,15 @@ struct _OrtpEventData{
 		int payload_type;
 		bool_t dtls_stream_encrypted;
 		bool_t zrtp_stream_encrypted;
+		bool_t ice_processing_successful;
 		struct _ZrtpSas{
 			char sas[32]; // up to 31 + null characters
 			bool_t verified;
+			bool_t pad[3];
 		} zrtp_sas;
 		OrtpSocketType socket_type;
-		bool_t ice_processing_successful;
 		uint64_t tmmbr_mxtbr;
+		uint32_t received_rtt_character;
 	} info;
 };
 
@@ -91,6 +94,81 @@ ORTP_PUBLIC void ortp_ev_queue_destroy(OrtpEvQueue *q);
 ORTP_PUBLIC OrtpEvent * ortp_ev_queue_get(OrtpEvQueue *q);
 ORTP_PUBLIC void ortp_ev_queue_flush(OrtpEvQueue * qp);
 
+struct _RtpSession;
+
+/**
+ * Callback function when a RTCP packet of the interested type is found.
+ *
+ * @param evd the packet. Read-only, must NOT be changed.
+ * @param user_data user data provided when registered the callback
+ *
+ */
+typedef void (*OrtpEvDispatcherCb)(const OrtpEventData *evd, void *user_data);
+typedef struct OrtpEvDispatcherData{
+	OrtpEventType type;
+	rtcp_type_t subtype;
+	OrtpEvDispatcherCb on_found;
+	void* user_data;
+} OrtpEvDispatcherData;
+
+typedef struct OrtpEvDispatcher{
+	OrtpEvQueue *q;
+	struct _RtpSession* session;
+	OList *cbs;
+} OrtpEvDispatcher;
+
+/**
+ * Constructs an OrtpEvDispatcher object. This object can be used to be notified
+ * when any RTCP type packet is received or emitted on the rtp session,
+ * given a callback registered with \a ortp_ev_dispatcher_connect
+ *
+ * @param session RTP session to listen on. Cannot be NULL.
+ *
+ * @return OrtpEvDispatcher object newly created.
+ */
+ORTP_PUBLIC OrtpEvDispatcher * ortp_ev_dispatcher_new(struct _RtpSession* session);
+/**
+ * Frees the memory for the given dispatcher. Note that user_data must be freed
+ * by caller, and so does the OrtpEvQueue.
+ *
+ * @param d OrtpEvDispatcher object
+ */
+ORTP_PUBLIC void ortp_ev_dispatcher_destroy(OrtpEvDispatcher *d);
+/**
+ * Iterate method to be called periodically. If a RTCP packet is found and
+ * its type matches one of the callback connected with \a ortp_ev_dispatcher_connect,
+ * this callback will be invoked in the current thread.
+ *
+ * @param d OrtpEvDispatcher object
+ */
+ORTP_PUBLIC void ortp_ev_dispatcher_iterate(OrtpEvDispatcher *d);
+/**
+ * Connects a callback to the given type of event packet and, in case of RTCP event,
+ * for the given RTCP subtype.
+ * When any event is found, the callback is invoked. Multiple
+ * callbacks can be connected to the same type of event, and the same callback
+ * can be connected to multiple type of event.
+ *
+ * @param d OrtpEvDispatcher object
+ * @param type type of event to be notified of.
+ * @param subtype when type is set to ORTP_EVENT_RTCP_PACKET_RECEIVED or ORTP_EVENT_RTCP_PACKET_EMITTED, subtype of RTCP packet to be notified of. Otherwise this parameter is not used.
+ * @param on_receive function to call when a RTCP packet of the given type is found.
+ * @param user_data user data given as last argument of the callback. Can be NULL. MUST be freed by user.
+ */
+ORTP_PUBLIC void ortp_ev_dispatcher_connect(OrtpEvDispatcher *d
+											, OrtpEventType type
+											, rtcp_type_t subtype
+											, OrtpEvDispatcherCb on_receive
+											, void *user_data);
+
+/**
+ * Disconnects the given callback for the given type and subtype on the given dispatcher.
+*/
+void ortp_ev_dispatcher_disconnect(OrtpEvDispatcher *d
+								, OrtpEventType type
+								, rtcp_type_t subtype
+								, OrtpEvDispatcherCb cb);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/ortp/logging.h b/include/ortp/logging.h
index 2381e6f..45249f1 100644
--- a/include/ortp/logging.h
+++ b/include/ortp/logging.h
@@ -28,6 +28,10 @@
 
 #include <ortp/port.h>
 
+#ifndef ORTP_LOG_DOMAIN
+#define ORTP_LOG_DOMAIN NULL
+#endif
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -35,26 +39,26 @@ extern "C"
 
 typedef enum {
 	ORTP_DEBUG=1,
-	ORTP_MESSAGE=1<<1,
-	ORTP_WARNING=1<<2,
-	ORTP_ERROR=1<<3,
-	ORTP_FATAL=1<<4,
-	ORTP_TRACE=1<<5,
+	ORTP_TRACE=1<<1,
+	ORTP_MESSAGE=1<<2,
+	ORTP_WARNING=1<<3,
+	ORTP_ERROR=1<<4,
+	ORTP_FATAL=1<<5,
 	ORTP_LOGLEV_END=1<<6
 } OrtpLogLevel;
 
 
-typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args);
+typedef void (*OrtpLogFunc)(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args);
 
 ORTP_PUBLIC void ortp_set_log_file(FILE *file);
 ORTP_PUBLIC void ortp_set_log_handler(OrtpLogFunc func);
-ORTP_PUBLIC OrtpLogFunc ortp_get_log_handler();
+ORTP_PUBLIC OrtpLogFunc ortp_get_log_handler(void);
 
-ORTP_VAR_PUBLIC OrtpLogFunc ortp_logv_out;
+ORTP_PUBLIC void ortp_logv_out(const char *domain, OrtpLogLevel level, const char *fmt, va_list args);
 
-#define ortp_log_level_enabled(level)	(ortp_get_log_level_mask() & (level))
+#define ortp_log_level_enabled(domain, level)	(ortp_get_log_level_mask(domain) & (level))
 
-ORTP_PUBLIC void ortp_logv(int level, const char *fmt, va_list args);
+ORTP_PUBLIC void ortp_logv(const char *domain, OrtpLogLevel level, const char *fmt, va_list args);
 
 /**
  * Flushes the log output queue.
@@ -62,8 +66,13 @@ ORTP_PUBLIC void ortp_logv(int level, const char *fmt, va_list args);
  */
 ORTP_PUBLIC void ortp_logv_flush(void);
 
-ORTP_PUBLIC void ortp_set_log_level_mask(int levelmask);
-ORTP_PUBLIC int ortp_get_log_level_mask(void);
+/**
+ * Activate all log level greater or equal than specified level argument.
+**/
+ORTP_PUBLIC void ortp_set_log_level(const char *domain, OrtpLogLevel level);
+
+ORTP_PUBLIC void ortp_set_log_level_mask(const char *domain, int levelmask);
+ORTP_PUBLIC unsigned int ortp_get_log_level_mask(const char *domain);
 
 /**
  * Tell oRTP the id of the thread used to output the logs.
@@ -86,7 +95,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_debug(const char *fmt,...)
 {
   va_list args;
   va_start (args, fmt);
-  ortp_logv(ORTP_DEBUG, fmt, args);
+  ortp_logv(ORTP_LOG_DOMAIN, ORTP_DEBUG, fmt, args);
   va_end (args);
 }
 #else
@@ -106,7 +115,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_debug(const char *fmt,...)
 static ORTP_INLINE void CHECK_FORMAT_ARGS(2,3) ortp_log(OrtpLogLevel lev, const char *fmt,...) {
 	va_list args;
 	va_start (args, fmt);
-	ortp_logv(lev, fmt, args);
+	ortp_logv(ORTP_LOG_DOMAIN, lev, fmt, args);
 	va_end (args);
 }
 
@@ -114,7 +123,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_message(const char *fmt,...)
 {
 	va_list args;
 	va_start (args, fmt);
-	ortp_logv(ORTP_MESSAGE, fmt, args);
+	ortp_logv(ORTP_LOG_DOMAIN, ORTP_MESSAGE, fmt, args);
 	va_end (args);
 }
 
@@ -122,7 +131,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_warning(const char *fmt,...)
 {
 	va_list args;
 	va_start (args, fmt);
-	ortp_logv(ORTP_WARNING, fmt, args);
+	ortp_logv(ORTP_LOG_DOMAIN, ORTP_WARNING, fmt, args);
 	va_end (args);
 }
 
@@ -132,7 +141,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_error(const char *fmt,...)
 {
 	va_list args;
 	va_start (args, fmt);
-	ortp_logv(ORTP_ERROR, fmt, args);
+	ortp_logv(ORTP_LOG_DOMAIN, ORTP_ERROR, fmt, args);
 	va_end (args);
 }
 
@@ -140,7 +149,7 @@ static ORTP_INLINE void CHECK_FORMAT_ARGS(1,2) ortp_fatal(const char *fmt,...)
 {
 	va_list args;
 	va_start (args, fmt);
-	ortp_logv(ORTP_FATAL, fmt, args);
+	ortp_logv(ORTP_LOG_DOMAIN, ORTP_FATAL, fmt, args);
 	va_end (args);
 }
 
diff --git a/include/ortp/payloadtype.h b/include/ortp/payloadtype.h
index 682b9e6..9c2c04a 100644
--- a/include/ortp/payloadtype.h
+++ b/include/ortp/payloadtype.h
@@ -47,11 +47,14 @@ extern "C"{
 #define	PAYLOAD_TYPE_USER_FLAG_4 (1<<8)
 /* ask for more if you need*/
 
+#define PAYLOAD_TYPE_FLAG_CAN_RECV PAYLOAD_TYPE_USER_FLAG_1
+#define PAYLOAD_TYPE_FLAG_CAN_SEND PAYLOAD_TYPE_USER_FLAG_2
+
 #define PAYLOAD_AUDIO_CONTINUOUS 0
 #define PAYLOAD_AUDIO_PACKETIZED 1
 #define PAYLOAD_VIDEO 2
-#define PAYLOAD_TEXT 4
-#define PAYLOAD_OTHER 3  /* ?? */
+#define PAYLOAD_TEXT 3
+#define PAYLOAD_OTHER 4  /* ?? */
 
 #define PAYLOAD_TYPE_AVPF_NONE 0
 #define PAYLOAD_TYPE_AVPF_FIR (1 << 0)
@@ -61,6 +64,9 @@ extern "C"{
 
 struct _PayloadTypeAvpfParams {
 	unsigned char features; /**< A bitmask of PAYLOAD_TYPE_AVPF_* macros. */
+	bool_t rpsi_compatibility; /*< Linphone uses positive feeback for RPSI. However first versions handling
+		AVPF wrongly declared RPSI as negative feedback, so this is kept for compatibility
+		with these versions but will probably be removed at some point in time. */
 	uint16_t trr_interval; /**< The interval in milliseconds between regular RTCP packets. */
 };
 
@@ -158,6 +164,8 @@ ORTP_VAR_PUBLIC PayloadType payload_type_aaceld_48k;
 ORTP_VAR_PUBLIC PayloadType payload_type_opus;
 ORTP_VAR_PUBLIC PayloadType payload_type_isac;
 ORTP_VAR_PUBLIC PayloadType payload_type_gsm_efr;
+ORTP_VAR_PUBLIC PayloadType payload_type_codec2;
+ORTP_VAR_PUBLIC PayloadType payload_type_bv16;
 
 /* video */
 ORTP_VAR_PUBLIC PayloadType payload_type_mpv;
diff --git a/include/ortp/port.h b/include/ortp/port.h
index 592245a..53d71be 100644
--- a/include/ortp/port.h
+++ b/include/ortp/port.h
@@ -22,7 +22,7 @@
 #define ORTP_PORT_H
 
 
-#if !defined(WIN32) && !defined(_WIN32_WCE)
+#if !defined(_WIN32) && !defined(_WIN32_WCE)
 /********************************/
 /* definitions for UNIX flavour */
 /********************************/
@@ -76,8 +76,6 @@ typedef pthread_cond_t ortp_cond_t;
 #define ORTP_PUBLIC
 #define ORTP_INLINE			inline
 
-#define WINAPI_FAMILY_PARTITION(x) 1
-
 #ifdef __cplusplus
 extern "C"
 {
@@ -125,10 +123,20 @@ unsigned long __ortp_thread_self(void);
 #include <stdarg.h>
 #include <winsock2.h>
 #include <ws2tcpip.h>
+#ifdef _MSC_VER
+#include <io.h>
+#endif
 
-#if !defined(WINAPI_FAMILY_PARTITION)
-// Only use with x being WINAPI_PARTITION_DESKTOP to test if building on desktop
-#define WINAPI_FAMILY_PARTITION(x) 1
+#if defined(__MINGW32__) || !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
+#define ORTP_WINDOWS_DESKTOP 1
+#elif defined(WINAPI_FAMILY_PARTITION)
+#if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#define ORTP_WINDOWS_DESKTOP 1
+#elif defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
+#define ORTP_WINDOWS_PHONE 1
+#elif defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+#define ORTP_WINDOWS_UNIVERSAL 1
+#endif
 #endif
 
 #ifdef _MSC_VER
@@ -165,7 +173,7 @@ ORTP_PUBLIC char* strtok_r(char *str, const char *delim, char **nextp);
 #define vsnprintf	_vsnprintf
 
 typedef SOCKET ortp_socket_t;
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 typedef HANDLE ortp_cond_t;
 typedef HANDLE ortp_mutex_t;
 #else
@@ -266,7 +274,10 @@ char * WSAAPI gai_strerror(int errnum);
 
 #endif
 
+#ifndef _BOOL_T_
+#define _BOOL_T_
 typedef unsigned char bool_t;
+#endif /* _BOOL_T_ */
 #undef TRUE
 #undef FALSE
 #define TRUE 1
@@ -317,11 +328,12 @@ void _ortp_get_cur_time(ortpTimeSpec *ret, bool_t realtime);
 ORTP_PUBLIC uint64_t ortp_get_cur_time_ms(void);
 ORTP_PUBLIC void ortp_sleep_ms(int ms);
 ORTP_PUBLIC void ortp_sleep_until(const ortpTimeSpec *ts);
+ORTP_PUBLIC int ortp_timespec_compare(const ortpTimeSpec *s1, const ortpTimeSpec *s2);
 ORTP_PUBLIC unsigned int ortp_random(void);
 
 /* portable named pipes  and shared memory*/
 #if !defined(_WIN32_WCE)
-#ifdef WIN32
+#ifdef _WIN32
 typedef HANDLE ortp_pipe_t;
 #define ORTP_PIPE_INVALID INVALID_HANDLE_VALUE
 #else
@@ -348,6 +360,9 @@ ORTP_PUBLIC int ortp_pipe_write(ortp_pipe_t p, const uint8_t *buf, int len);
 ORTP_PUBLIC void *ortp_shm_open(unsigned int keyid, int size, int create);
 ORTP_PUBLIC void ortp_shm_close(void *memory);
 
+ORTP_PUBLIC	bool_t ortp_is_multicast_addr(const struct sockaddr *addr);
+	
+	
 #endif
 
 #ifdef __cplusplus
@@ -356,7 +371,7 @@ ORTP_PUBLIC void ortp_shm_close(void *memory);
 #endif
 
 
-#if (defined(WIN32) || defined(_WIN32_WCE)) && !defined(ORTP_STATIC)
+#if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(ORTP_STATIC)
 #ifdef ORTP_EXPORTS
    #define ORTP_VAR_PUBLIC    extern __declspec(dllexport)
 #else
diff --git a/include/ortp/rtcp.h b/include/ortp/rtcp.h
index 493fbd0..b708374 100644
--- a/include/ortp/rtcp.h
+++ b/include/ortp/rtcp.h
@@ -88,8 +88,11 @@ typedef struct sender_info
 	uint32_t senders_octet_count;
 } sender_info_t;
 
-uint64_t sender_info_get_ntp_timestamp(const sender_info_t *si);
-#define sender_info_get_rtp_timestamp(si)	((si)->rtp_timestamp)
+static ORTP_INLINE uint64_t sender_info_get_ntp_timestamp(const sender_info_t *si) {
+  return ((((uint64_t)ntohl(si->ntp_timestamp_msw)) << 32) +
+          ((uint64_t) ntohl(si->ntp_timestamp_lsw)));
+}
+#define sender_info_get_rtp_timestamp(si)	ntohl((si)->rtp_timestamp)
 #define sender_info_get_packet_count(si) \
 	ntohl((si)->senders_packet_count)
 #define sender_info_get_octet_count(si) \
@@ -310,6 +313,16 @@ typedef struct rtcp_fb_header {
 	uint32_t media_source_ssrc;
 } rtcp_fb_header_t;
 
+typedef struct rtcp_fb_generic_nack_fci {
+	uint16_t pid;
+	uint16_t blp;
+} rtcp_fb_generic_nack_fci_t;
+
+#define rtcp_fb_generic_nack_fci_get_pid(nack) ntohs((nack)->pid)
+#define rtcp_fb_generic_nack_fci_set_pid(nack, value) ((nack)->pid) = htons(value)
+#define rtcp_fb_generic_nack_fci_get_blp(nack) ntohs((nack)->blp)
+#define rtcp_fb_generic_nack_fci_set_blp(nack, value) ((nack)->blp) = htons(value)
+
 typedef struct rtcp_fb_tmmbr_fci {
 	uint32_t ssrc;
 	uint32_t value;
@@ -486,6 +499,7 @@ ORTP_PUBLIC uint16_t rtcp_XR_voip_metrics_get_jb_abs_max(const mblk_t *m);
 /* RTCP RTPFB accessors */
 ORTP_PUBLIC bool_t rtcp_is_RTPFB(const mblk_t *m);
 ORTP_PUBLIC rtcp_rtpfb_type_t rtcp_RTPFB_get_type(const mblk_t *m);
+ORTP_PUBLIC rtcp_fb_generic_nack_fci_t * rtcp_RTPFB_generic_nack_get_fci(const mblk_t *m);
 ORTP_PUBLIC rtcp_fb_tmmbr_fci_t * rtcp_RTPFB_tmmbr_get_fci(const mblk_t *m);
 ORTP_PUBLIC uint32_t rtcp_RTPFB_get_packet_sender_ssrc(const mblk_t *m);
 ORTP_PUBLIC uint32_t rtcp_RTPFB_get_media_source_ssrc(const mblk_t *m);
@@ -510,12 +524,12 @@ typedef struct OrtpLossRateEstimator{
 	float loss_rate;
 	/**
 	* Total number of outgoing duplicate packets on last
-	* #ortp_loss_rate_estimator_process_report_block iteration.
+	* ortp_loss_rate_estimator_process_report_block iteration.
 	**/
 	int32_t last_dup_packet_sent_count;
 	/**
 	* Total number of outgoing unique packets on last
-	* #ortp_loss_rate_estimator_process_report_block iteration.
+	* ortp_loss_rate_estimator_process_report_block iteration.
 	**/
 	int32_t last_packet_sent_count;
 }OrtpLossRateEstimator;
@@ -537,12 +551,12 @@ ORTP_PUBLIC void ortp_loss_rate_estimator_init(OrtpLossRateEstimator *obj, int m
  * cumulative loss factor which allows us to take into consideration duplicates
  * packets as well.
  * @param[in] obj #OrtpLossRateEstimator object.
- * @param[in] stream #RtpStream stream in which the report block to consider belongs.
+ * @param[in] session #_RtpSession stream in which the report block to consider belongs.
  * @param[in] rb Report block to analyze.
  * @return TRUE if a new loss rate estimation is ready, FALSE otherwise.
  */
 ORTP_PUBLIC bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj,
-																 const struct _RtpStream *stream,
+																 const struct _RtpSession *session,
 																 const report_block_t *rb);
 /**
  * Get the latest loss rate in percentage estimation computed.
diff --git a/include/ortp/rtp.h b/include/ortp/rtp.h
index 6ffd959..d2f02fe 100644
--- a/include/ortp/rtp.h
+++ b/include/ortp/rtp.h
@@ -74,8 +74,10 @@ typedef struct rtp_stats
 	uint64_t bad;				/* incoming packets that did not appear to be RTP */
 	uint64_t discarded;			/* incoming packets discarded because the queue exceeds its max size */
 	uint64_t sent_rtcp_packets;	/* outgoing RTCP packets counter (only packets that embed a report block are considered) */
+	uint64_t recv_rtcp_packets;	/* incoming RTCP packets counter (only packets that embed a report block are considered) */
 } rtp_stats_t;
 
+
 typedef struct jitter_stats
 {
 	uint32_t jitter;			/* interarrival jitter at last emitted sender report */
@@ -112,6 +114,7 @@ extern "C"{
 ORTP_PUBLIC void rtp_add_csrc(mblk_t *mp ,uint32_t csrc);
 #define rtp_set_payload_type(mp,pt)	((rtp_header_t*)((mp)->b_rptr))->paytype=(pt)
 
+#define rtp_get_version(mp)	(((rtp_header_t*)((mp)->b_rptr))->version)
 #define rtp_get_markbit(mp)	(((rtp_header_t*)((mp)->b_rptr))->markbit)
 #define rtp_get_extbit(mp)	(((rtp_header_t*)((mp)->b_rptr))->extbit)
 #define rtp_get_timestamp(mp)	(((rtp_header_t*)((mp)->b_rptr))->timestamp)
diff --git a/include/ortp/rtpprofile.h b/include/ortp/rtpprofile.h
index 1937d8e..d2cf44f 100644
--- a/include/ortp/rtpprofile.h
+++ b/include/ortp/rtpprofile.h
@@ -54,7 +54,7 @@ ORTP_VAR_PUBLIC RtpProfile av_profile;
 ORTP_PUBLIC void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt);
 
 /**
- *	Set payload type number @index unassigned in the profile.
+ *	Set payload type number \a index unassigned in the profile.
  *
  *@param profile an RTP profile
  *@param index	the payload type number
@@ -65,10 +65,10 @@ ORTP_PUBLIC void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType
 /* I prefer have this function inlined because it is very often called in the code */
 /**
  *
- *	Gets the payload description of the payload type @index in the profile.
+ *	Gets the payload description of the payload type \a index in the profile.
  *
- *@param profile an RTP profile (a #RtpProfile object)
- *@param index	the payload type number
+ *@param prof an RTP profile (a #_RtpProfile object)
+ *@param idx	the payload type number
  *@return the payload description (a PayloadType object)
 **/
 static ORTP_INLINE PayloadType * rtp_profile_get_payload(const RtpProfile *prof, int idx){
@@ -81,7 +81,8 @@ ORTP_PUBLIC void rtp_profile_clear_all(RtpProfile *prof);
 ORTP_PUBLIC void rtp_profile_set_name(RtpProfile *prof, const char *name);
 ORTP_PUBLIC PayloadType * rtp_profile_get_payload_from_mime(RtpProfile *profile,const char *mime);
 ORTP_PUBLIC PayloadType * rtp_profile_get_payload_from_rtpmap(RtpProfile *profile, const char *rtpmap);
-ORTP_PUBLIC int rtp_profile_get_payload_number_from_mime(RtpProfile *profile,const char *mime);
+ORTP_PUBLIC int rtp_profile_get_payload_number_from_mime(RtpProfile *profile, const char *mime);
+ORTP_PUBLIC int rtp_profile_get_payload_number_from_mime_and_flag(RtpProfile *profile, const char *mime, int flag);
 ORTP_PUBLIC int rtp_profile_get_payload_number_from_rtpmap(RtpProfile *profile, const char *rtpmap);
 ORTP_PUBLIC int rtp_profile_find_payload_number(RtpProfile *prof,const char *mime,int rate, int channels);
 ORTP_PUBLIC PayloadType * rtp_profile_find_payload(RtpProfile *prof,const char *mime,int rate, int channels);
diff --git a/include/ortp/rtpsession.h b/include/ortp/rtpsession.h
index 6bbdd85..2904cac 100644
--- a/include/ortp/rtpsession.h
+++ b/include/ortp/rtpsession.h
@@ -44,6 +44,7 @@
 
 #define ORTP_AVPF_FEATURE_NONE 0
 #define ORTP_AVPF_FEATURE_TMMBR (1 << 0)
+#define ORTP_AVPF_FEATURE_GENERIC_NACK (1 << 1)
 
 
 typedef enum {
@@ -96,12 +97,13 @@ typedef struct _RtpTransportModifier
 {
 	void *data;
 	struct _RtpSession *session;//<back pointer to the owning session, set by oRTP
+	struct _RtpTransport *transport;//<back point to the owning transport, set by oRTP
 	int  (*t_process_on_send)(struct _RtpTransportModifier *t, mblk_t *msg);
 	int  (*t_process_on_receive)(struct _RtpTransportModifier *t, mblk_t *msg);
-	void  (*t_process_on_schedule)(struct _RtpTransportModifier *t); /*invoked each time rtp_session_recvm even is no message are available*/
+	void  (*t_process_on_schedule)(struct _RtpTransportModifier *t); /*invoked each time rtp_session_recvm is called even is no message are available*/
 	/**
-	 * Mandatory callback responsible of freeing the #RtpTransportModifierAND the pointer.
-	 * @param[in] transport #RtpTransportModifier object to free.
+	 * Mandatory callback responsible of freeing the #_RtpTransportModifier AND the pointer.
+	 * @param[in] transport #_RtpTransportModifier object to free.
 	 */
 	void  (*t_destroy)(struct _RtpTransportModifier *transport);
 } RtpTransportModifier;
@@ -113,10 +115,10 @@ typedef struct _RtpTransport
 	ortp_socket_t (*t_getsocket)(struct _RtpTransport *t);
 	int  (*t_sendto)(struct _RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen);
 	int  (*t_recvfrom)(struct _RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen);
-	void  (*t_close)(struct _RtpTransport *transport, void *userData);
+	void  (*t_close)(struct _RtpTransport *transport);
 	/**
-	 * Mandatory callback responsible of freeing the #RtpTransport object AND the pointer.
-	 * @param[in] transport #RtpTransport object to free.
+	 * Mandatory callback responsible of freeing the #_RtpTransport object AND the pointer.
+	 * @param[in] transport #_RtpTransport object to free.
 	 */
 	void  (*t_destroy)(struct _RtpTransport *transport);
 }  RtpTransport;
@@ -125,7 +127,7 @@ typedef enum _OrtpNetworkSimulatorMode{
 	OrtpNetworkSimulatorInvalid=-1,
 	OrtpNetworkSimulatorInbound,/**<simulation is applied when receiving packets*/
 	OrtpNetworkSimulatorOutbound, /**<simulation is applied to sent packets*/
-	OrtpNetworkSimulatorOutboundControlled /**<simulation is applied to sent packets according to sent timestamp 
+	OrtpNetworkSimulatorOutboundControlled /**<simulation is applied to sent packets according to sent timestamp
 				set in the timestamp field of mblk_t, which is definied only with -DORTP_TIMESTAMP */
 }OrtpNetworkSimulatorMode;
 
@@ -141,6 +143,7 @@ typedef struct _OrtpNetworkSimulatorParams{
 	float consecutive_loss_probability;/**< a probablity of having a subsequent loss after a loss occured, in a 0-1 range. Useful to simulate burst of lost packets*/
 	float jitter_burst_density; /**<density of gap/bursts events. A value of 1 means one gap/burst per second approximately*/
 	float jitter_strength; /**<percentage of max_bandwidth artifically consumed during bursts events*/
+	bool_t RTP_only; /**True for only RTP packet loss, False for both RTP and RTCP */
 	OrtpNetworkSimulatorMode mode; /**<whether simulation is applied to inboud or outbound stream.*/
 }OrtpNetworkSimulatorParams;
 
@@ -182,6 +185,11 @@ typedef struct OrtpRtcpSendAlgorithm {
 	bool_t tmmbn_scheduled;
 } OrtpRtcpSendAlgorithm;
 
+typedef struct OrtpRtcpFbConfiguration {
+	bool_t generic_nack_enabled;
+	bool_t tmmbr_enabled;
+} OrtpRtcpFbConfiguration;
+
 #define ORTP_RTCP_XR_UNAVAILABLE_PARAMETER 127
 
 typedef enum {
@@ -190,10 +198,10 @@ typedef enum {
 	OrtpRtcpXrEnhancedPlc
 } OrtpRtcpXrPlcStatus;
 
-typedef OrtpRtcpXrPlcStatus (*OrtpRtcpXrPlcCallback)(unsigned long userdata);
-typedef int (*OrtpRtcpXrSignalLevelCallback)(unsigned long userdata);
-typedef int (*OrtpRtcpXrNoiseLevelCallback)(unsigned long userdata);
-typedef float (*OrtpRtcpXrAverageQualityIndicatorCallback)(unsigned long userdata);
+typedef OrtpRtcpXrPlcStatus (*OrtpRtcpXrPlcCallback)(void *userdata);
+typedef int (*OrtpRtcpXrSignalLevelCallback)(void *userdata);
+typedef int (*OrtpRtcpXrNoiseLevelCallback)(void *userdata);
+typedef float (*OrtpRtcpXrAverageQualityIndicatorCallback)(void *userdata);
 
 typedef struct OrtpRtcpXrMediaCallbacks {
 	OrtpRtcpXrPlcCallback plc;
@@ -201,7 +209,7 @@ typedef struct OrtpRtcpXrMediaCallbacks {
 	OrtpRtcpXrNoiseLevelCallback noise_level;
 	OrtpRtcpXrAverageQualityIndicatorCallback average_qi;
 	OrtpRtcpXrAverageQualityIndicatorCallback average_lq_qi;
-	unsigned long userdata;
+	void *userdata;
 } OrtpRtcpXrMediaCallbacks;
 
 typedef enum {
@@ -271,7 +279,6 @@ typedef struct _OrtpStream {
 	socklen_t loc_addrlen;
 	struct sockaddr_storage loc_addr;
 	struct _RtpTransport *tr;
-	mblk_t *cached_mp;
 	struct timeval send_bw_start; /* used for bandwidth estimation */
 	struct timeval recv_bw_start; /* used for bandwidth estimation */
 	unsigned int sent_bytes; /* used for bandwidth estimation */
@@ -279,6 +286,7 @@ typedef struct _OrtpStream {
 	float upload_bw;
 	float download_bw;
 	OList *aux_destinations; /*list of OrtpAddress */
+	msgb_allocator_t allocator;
 } OrtpStream;
 
 typedef struct _RtpStream
@@ -312,7 +320,6 @@ typedef struct _RtpStream
 	uint16_t snd_seq; /* send sequence number */
 	uint32_t last_rtcp_packet_count; /*the sender's octet count in the last sent RTCP SR*/
 	uint32_t sent_payload_bytes; /*used for RTCP sender reports*/
-	rtp_stats_t stats;
 	int recv_errno;
 	int send_errno;
 	int snd_socket_size;
@@ -369,7 +376,6 @@ struct _RtpSession
 	RtpSignalTable on_rtcp_bye;
 	struct _OList *signal_tables;
 	struct _OList *eventqs;
-	msgb_allocator_t allocator;
 	RtpStream rtp;
 	RtcpStream rtcp;
 	OrtpRtcpXrStats rtcp_xr_stats;
@@ -386,6 +392,7 @@ struct _RtpSession
 	struct timeval last_recv_time; /* Time of receiving the RTP/RTCP packet. */
 	mblk_t *pending;
 	/* telephony events extension */
+	int tev_send_pt; /*telephone event to be used for sending*/
 	mblk_t *current_tev;		/* the pending telephony events */
 	mblk_t *minimal_sdes;
 	mblk_t *full_sdes;
@@ -396,12 +403,20 @@ struct _RtpSession
 	float rtt;/*last round trip delay calculated*/
 	int cum_loss;
 	OrtpNetworkSimulatorCtx *net_sim_ctx;
+	RtpSession *spliced_session; /*a RtpSession that will retransmit everything received on this session*/
+	rtp_stats_t stats;
 	bool_t symmetric_rtp;
 	bool_t permissive; /*use the permissive algorithm*/
 	bool_t use_connect; /* use connect() on the socket */
 	bool_t ssrc_set;
+	
 	bool_t reuseaddr; /*setsockopt SO_REUSEADDR */
+	bool_t rtcp_mux;
 	unsigned char avpf_features; /**< A bitmask of ORTP_AVPF_FEATURE_* macros. */
+	bool_t use_pktinfo;
+	
+	bool_t is_spliced;
+	
 };
 
 
@@ -415,7 +430,7 @@ extern "C"
 ORTP_PUBLIC const char *ortp_network_simulator_mode_to_string(OrtpNetworkSimulatorMode mode);
 ORTP_PUBLIC OrtpNetworkSimulatorMode ortp_network_simulator_mode_from_string(const char *str);
 
-	
+
 /* public API */
 ORTP_PUBLIC RtpSession *rtp_session_new(int mode);
 ORTP_PUBLIC void rtp_session_set_scheduling_mode(RtpSession *session, int yesno);
@@ -468,6 +483,7 @@ ORTP_PUBLIC void rtp_session_get_transports(const RtpSession *session, RtpTransp
 /*those methods are provided for people who wants to send non-RTP messages using the RTP/RTCP sockets */
 ORTP_PUBLIC ortp_socket_t rtp_session_get_rtp_socket(const RtpSession *session);
 ORTP_PUBLIC ortp_socket_t rtp_session_get_rtcp_socket(const RtpSession *session);
+ORTP_PUBLIC void rtp_session_refresh_sockets(RtpSession *session);
 
 
 /* QOS / DSCP */
@@ -493,15 +509,26 @@ ORTP_PUBLIC int rtp_session_get_send_payload_type(const RtpSession *session);
 ORTP_PUBLIC int rtp_session_get_recv_payload_type(const RtpSession *session);
 ORTP_PUBLIC int rtp_session_set_recv_payload_type(RtpSession *session, int pt);
 
+ORTP_PUBLIC int rtp_session_set_send_telephone_event_payload_type(RtpSession *session, int paytype);
+
 ORTP_PUBLIC int rtp_session_set_payload_type(RtpSession *session, int pt);
 
 ORTP_PUBLIC void rtp_session_set_symmetric_rtp (RtpSession * session, bool_t yesno);
 
 ORTP_PUBLIC bool_t rtp_session_get_symmetric_rtp (const RtpSession * session);
 
+ORTP_PUBLIC void rtp_session_enable_rtcp_mux(RtpSession *session, bool_t yesno);
+
+ORTP_PUBLIC bool_t rtp_session_rtcp_mux_enabled(RtpSession *session);
+
 ORTP_PUBLIC void rtp_session_set_connected_mode(RtpSession *session, bool_t yesno);
 
 ORTP_PUBLIC void rtp_session_enable_rtcp(RtpSession *session, bool_t yesno);
+/*
+ * rtcp status
+ * @return TRUE if rtcp is enabled for this session
+ */
+ORTP_PUBLIC bool_t rtp_session_rtcp_enabled(const RtpSession *session);
 
 ORTP_PUBLIC void rtp_session_set_rtcp_report_interval(RtpSession *session, int value_ms);
 
@@ -514,11 +541,13 @@ ORTP_PUBLIC void rtp_session_set_ssrc_changed_threshold(RtpSession *session, int
 
 /*low level recv and send functions */
 ORTP_PUBLIC mblk_t * rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts);
-ORTP_PUBLIC mblk_t * rtp_session_create_packet(RtpSession *session,int header_size, const uint8_t *payload, int payload_size);
-ORTP_PUBLIC mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, int packet_size);
-ORTP_PUBLIC mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *payload, int payload_size, void (*freefn)(void*));
-ORTP_PUBLIC mblk_t * rtp_session_create_packet_in_place(RtpSession *session,uint8_t *buffer, int size, void (*freefn)(void*) );
+ORTP_PUBLIC mblk_t * rtp_session_create_packet(RtpSession *session, size_t header_size, const uint8_t *payload, size_t payload_size);
+ORTP_PUBLIC mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, size_t packet_size);
+ORTP_PUBLIC mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *payload, size_t payload_size, void (*freefn)(void*));
+ORTP_PUBLIC mblk_t * rtp_session_create_packet_in_place(RtpSession *session,uint8_t *buffer, size_t size, void (*freefn)(void*) );
 ORTP_PUBLIC int rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t userts);
+ORTP_PUBLIC int rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen);
+ORTP_PUBLIC int rtp_session_recvfrom(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, struct sockaddr *from, socklen_t *fromlen);
 /* high level recv and send functions */
 ORTP_PUBLIC int rtp_session_recv_with_ts(RtpSession *session, uint8_t *buffer, int len, uint32_t ts, int *have_more);
 ORTP_PUBLIC int rtp_session_send_with_ts(RtpSession *session, const uint8_t *buffer, int len, uint32_t userts);
@@ -539,6 +568,17 @@ ORTP_PUBLIC float rtp_session_get_rtcp_send_bandwidth(RtpSession *session);
 ORTP_PUBLIC float rtp_session_get_rtcp_recv_bandwidth(RtpSession *session);
 
 ORTP_PUBLIC void rtp_session_send_rtcp_APP(RtpSession *session, uint8_t subtype, const char *name, const uint8_t *data, int datalen);
+/**
+ *	Send the rtcp datagram \a packet to the destination set by rtp_session_set_remote_addr()
+ *  The packet (\a packet) is freed once it is sent.
+ *
+ * @param session a rtp session.
+ * @param m a rtcp packet presented as a mblk_t.
+ * @return the number of bytes sent over the network.
+ **/
+
+ORTP_PUBLIC	int rtp_session_rtcp_sendm_raw(RtpSession * session, mblk_t * m);
+	
 
 ORTP_PUBLIC uint32_t rtp_session_get_current_send_ts(RtpSession *session);
 ORTP_PUBLIC uint32_t rtp_session_get_current_recv_ts(RtpSession *session);
@@ -612,6 +652,7 @@ ORTP_PUBLIC void rtp_session_enable_avpf_feature(RtpSession *session, unsigned c
 ORTP_PUBLIC uint16_t rtp_session_get_avpf_rr_interval(RtpSession *session);
 ORTP_PUBLIC bool_t rtp_session_rtcp_psfb_scheduled(RtpSession *session, rtcp_psfb_type_t type);
 ORTP_PUBLIC bool_t rtp_session_rtcp_rtpfb_scheduled(RtpSession *session, rtcp_rtpfb_type_t type);
+ORTP_PUBLIC void rtp_session_send_rtcp_fb_generic_nack(RtpSession *session, uint16_t pid, uint16_t blp);
 ORTP_PUBLIC void rtp_session_send_rtcp_fb_pli(RtpSession *session);
 ORTP_PUBLIC void rtp_session_send_rtcp_fb_fir(RtpSession *session);
 ORTP_PUBLIC void rtp_session_send_rtcp_fb_sli(RtpSession *session, uint16_t first, uint16_t number, uint8_t picture_id);
@@ -629,38 +670,35 @@ ORTP_PUBLIC void rtp_session_dispatch_event(RtpSession *session, OrtpEvent *ev);
 
 ORTP_PUBLIC void rtp_session_set_reuseaddr(RtpSession *session, bool_t yes);
 
-
-ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags);
-/**
- * #RtpTransport object which can handle multiples security protocols. You can for instance use this object
- * to use both sRTP and tunnel transporter. #mblk_t messages received and sent from the endpoint
- * will pass through the list of modifiers given. First modifier in list will be first to modify the message
- * in send mode and last in receive mode.
- * @param[in] t #RtpTransport object that will be generated.
- * @param[in] is_rtp Whether this object will be used for RTP packets or not.
- * @param[in] endpoint #RtpTransport object in charge of sending/receiving packets. If NULL, it will use standards sendto and recvfrom functions.
- * @param[in] modifiers_count number of #RtpModifier object given in the variadic list. Must be 0 if none are given.
- * @return 0 if successful, -1 otherwise
-**/
-ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet_to(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags,const struct sockaddr *to, socklen_t tolen) ;
+ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet_to_send(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg, int flags);
+ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet_to_send_to(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg, int flags, const struct sockaddr *to, socklen_t tolen);
+ORTP_PUBLIC int meta_rtp_transport_modifier_inject_packet_to_recv(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg, int flags);
+void rtp_session_process_incoming(RtpSession * session, mblk_t *mp, bool_t is_rtp_packet, uint32_t ts);
+void update_sent_bytes(OrtpStream *os, int nbytes);
 
 /**
  * get endpoint if any
- * @param[in] t #RtpTransport object.
- * @return #rtpEndpoint
+ * @param[in] transport RtpTransport object.
+ * @return #_RtpTransport
  *
  * */
 ORTP_PUBLIC RtpTransport* meta_rtp_transport_get_endpoint(const RtpTransport *transport);
 /**
  * set endpoint
- * @param[in] t #RtpTransport object.
- * @param[in] t #RtpEndpoint.
+ * @param[in] transport RtpTransport object.
+ * @param[in] endpoint RtpEndpoint.
  *
  * */
 ORTP_PUBLIC void meta_rtp_transport_set_endpoint(RtpTransport *transport,RtpTransport *endpoint);
 
 ORTP_PUBLIC void meta_rtp_transport_destroy(RtpTransport *tp);
 ORTP_PUBLIC void meta_rtp_transport_append_modifier(RtpTransport *tp,RtpTransportModifier *tpm);
+
+
+
+ORTP_PUBLIC int rtp_session_splice(RtpSession *session, RtpSession *to_session);
+ORTP_PUBLIC int rtp_session_unsplice(RtpSession *session, RtpSession *to_session);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/ortp/rtpsignaltable.h b/include/ortp/rtpsignaltable.h
index b629c26..7667c4f 100644
--- a/include/ortp/rtpsignaltable.h
+++ b/include/ortp/rtpsignaltable.h
@@ -22,7 +22,7 @@
 
 #define RTP_CALLBACK_TABLE_MAX_ENTRIES	5
 
-typedef void (*RtpCallback)(struct _RtpSession *, unsigned long arg1, unsigned long arg2, unsigned long arg3);
+typedef void (*RtpCallback)(struct _RtpSession *, void *arg1, void *arg2, void *arg3);
 
 struct _RtpSignalTable
 {
@@ -42,10 +42,10 @@ int rtp_signal_table_add(RtpSignalTable *table,RtpCallback cb, void *user_data);
 void rtp_signal_table_emit(RtpSignalTable *table);
 
 /* emit but with a second arg */
-void rtp_signal_table_emit2(RtpSignalTable *table, unsigned long arg);
+void rtp_signal_table_emit2(RtpSignalTable *table, void *arg);
 
 /* emit but with a third arg */
-void rtp_signal_table_emit3(RtpSignalTable *table, unsigned long arg1, unsigned long arg2);
+void rtp_signal_table_emit3(RtpSignalTable *table, void *arg1, void *arg2);
 
 int rtp_signal_table_remove_by_callback(RtpSignalTable *table,RtpCallback cb);
 
diff --git a/include/ortp/sessionset.h b/include/ortp/sessionset.h
index 8453307..0266f7a 100644
--- a/include/ortp/sessionset.h
+++ b/include/ortp/sessionset.h
@@ -16,7 +16,7 @@
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
-/** 
+/**
  * \file sessionset.h
  * \brief Sending and receiving multiple streams together with only one thread.
  *
@@ -47,7 +47,7 @@ typedef fd_set ortp_fd_set;
 
 
 #else
-/* WIN32 */
+/* _WIN32 */
 
 #define ORTP_FD_ZERO(s) \
   do {									      \
@@ -83,7 +83,7 @@ typedef struct
   } ortp_fd_set;
 
 
-#endif /*end WIN32*/
+#endif /*end _WIN32*/
 
 struct _SessionSet
 {
@@ -105,7 +105,7 @@ ORTP_PUBLIC SessionSet * session_set_new(void);
 
 /**
  * This macro tests if the session is part of the set. 1 is returned if true, 0 else.
- *@param ss a set (#SessionSet object)
+ *@param ss a set
  *@param rtpsession a rtp session
  *
 **/
@@ -128,12 +128,12 @@ ORTP_PUBLIC SessionSet * session_set_new(void);
 **/
 ORTP_PUBLIC void session_set_destroy(SessionSet *set);
 
-	
+
 ORTP_PUBLIC int session_set_select(SessionSet *recvs, SessionSet *sends, SessionSet *errors);
 ORTP_PUBLIC int session_set_timedselect(SessionSet *recvs, SessionSet *sends, SessionSet *errors,  struct timeval *timeout);
 
 #ifdef __cplusplus
 }
 #endif
-	
+
 #endif
diff --git a/include/ortp/str_utils.h b/include/ortp/str_utils.h
index 7c7f0ab..3caca2f 100644
--- a/include/ortp/str_utils.h
+++ b/include/ortp/str_utils.h
@@ -44,6 +44,7 @@ typedef struct ortp_recv_addr {
 		struct in_addr ipi_addr;
 		struct in6_addr ipi6_addr;
 	} addr;
+	unsigned short port;
 } ortp_recv_addr_t;
 
 typedef struct msgb
@@ -163,8 +164,8 @@ ORTP_PUBLIC void msgb_allocator_uninit(msgb_allocator_t *pa);
  */
 typedef struct _ortp_extremum{
 	float current_extremum;
-	uint64_t extremum_time;
 	float last_stable;
+	uint64_t extremum_time;
 	int period;
 }ortp_extremum;
 
@@ -178,6 +179,8 @@ ORTP_PUBLIC float ortp_extremum_get_current(ortp_extremum *obj);
 **/
 ORTP_PUBLIC float ortp_extremum_get_previous(ortp_extremum *obj);
 
+ORTP_PUBLIC void ortp_recvaddr_to_sockaddr(ortp_recv_addr_t *recvaddr, struct sockaddr *addr, socklen_t *socklen);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/ortp.doxygen.in b/ortp.doxygen.in
index 69ba62d..cd0cb48 100644
--- a/ortp.doxygen.in
+++ b/ortp.doxygen.in
@@ -1,225 +1,2413 @@
-# Doxyfile 1.5.1
+# Doxyfile 1.8.11
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project.
+#
+# All text after a double hash (##) is considered a comment and is placed in
+# front of the TAG it is preceding.
+#
+# All text after a single hash (#) is considered a comment and will be ignored.
+# The format is:
+# TAG = value [value, ...]
+# For lists, items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (\" \").
 
 #---------------------------------------------------------------------------
 # Project related configuration options
 #---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all text
+# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
+# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
+# for the list of possible encodings.
+# The default value is: UTF-8.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
+# double-quotes, unless you are using Doxywizard) that should identify the
+# project for which the documentation is generated. This name is used in the
+# title of most generated pages and in a few other places.
+# The default value is: My Project.
+
 PROJECT_NAME           = oRTP
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
+# could be handy for archiving the generated documentation or if some version
+# control system is used.
+
 PROJECT_NUMBER         = @ORTP_VERSION@
+
+# Using the PROJECT_BRIEF tag one can provide an optional one line description
+# for a project that appears at the top of each page and should give viewer a
+# quick idea about the purpose of the project. Keep the description short.
+
+PROJECT_BRIEF          =
+
+# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
+# in the documentation. The maximum height of the logo should not exceed 55
+# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# the logo to the output directory.
+
+PROJECT_LOGO           =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
+# into which the generated documentation will be written. If a relative path is
+# entered, it will be relative to the location where doxygen was started. If
+# left blank the current directory will be used.
+
 OUTPUT_DIRECTORY       = doc
+
+# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
+# directories (in 2 levels) under the output directory of each output format and
+# will distribute the generated files over these directories. Enabling this
+# option can be useful when feeding doxygen a huge amount of source files, where
+# putting all generated files in the same directory would otherwise causes
+# performance problems for the file system.
+# The default value is: NO.
+
 CREATE_SUBDIRS         = NO
+
+# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
+# characters to appear in the names of generated files. If set to NO, non-ASCII
+# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
+# U+3044.
+# The default value is: NO.
+
+ALLOW_UNICODE_NAMES    = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
+# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
+# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
+# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
+# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
+# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
+# Ukrainian and Vietnamese.
+# The default value is: English.
+
 OUTPUT_LANGUAGE        = English
-USE_WINDOWS_ENCODING   = NO
+
+# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
+# descriptions after the members that are listed in the file and class
+# documentation (similar to Javadoc). Set to NO to disable this.
+# The default value is: YES.
+
 BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
+# description of a member or function before the detailed description
+#
+# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+# The default value is: YES.
+
 REPEAT_BRIEF           = YES
-ABBREVIATE_BRIEF       = 
+
+# This tag implements a quasi-intelligent brief description abbreviator that is
+# used to form the text in various listings. Each string in this list, if found
+# as the leading text of the brief description, will be stripped from the text
+# and the result, after processing the whole list, is used as the annotated
+# text. Otherwise, the brief description is used as-is. If left blank, the
+# following values are used ($name is automatically replaced with the name of
+# the entity):The $name class, The $name widget, The $name file, is, provides,
+# specifies, contains, represents, a, an and the.
+
+ABBREVIATE_BRIEF       =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# doxygen will generate a detailed section even if there is only a brief
+# description.
+# The default value is: NO.
+
 ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+# The default value is: NO.
+
 INLINE_INHERITED_MEMB  = NO
-FULL_PATH_NAMES        = YES
-STRIP_FROM_PATH        = 
-STRIP_FROM_INC_PATH    = 
+
+# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
+# before files name in the file list and in the header files. If set to NO the
+# shortest path that makes the file name unique will be used
+# The default value is: YES.
+
+FULL_PATH_NAMES        = NO
+
+# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
+# Stripping is only done if one of the specified strings matches the left-hand
+# part of the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the path to
+# strip.
+#
+# Note that you can specify absolute paths here, but also relative paths, which
+# will be relative from the directory where doxygen is started.
+# This tag requires that the tag FULL_PATH_NAMES is set to YES.
+
+STRIP_FROM_PATH        =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
+# path mentioned in the documentation of a class, which tells the reader which
+# header file to include in order to use a class. If left blank only the name of
+# the header file containing the class definition is used. Otherwise one should
+# specify the list of include paths that are normally passed to the compiler
+# using the -I flag.
+
+STRIP_FROM_INC_PATH    =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
+# less readable) file names. This can be useful is your file systems doesn't
+# support long names like on DOS, Mac, or CD-ROM.
+# The default value is: NO.
+
 SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
+# first line (until the first dot) of a Javadoc-style comment as the brief
+# description. If set to NO, the Javadoc-style will behave just like regular Qt-
+# style comments (thus requiring an explicit @brief command for a brief
+# description.)
+# The default value is: NO.
+
 JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
+# line (until the first dot) of a Qt-style comment as the brief description. If
+# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
+# requiring an explicit \brief command for a brief description.)
+# The default value is: NO.
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
+# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
+# a brief description. This used to be the default behavior. The new default is
+# to treat a multi-line C++ comment block as a detailed description. Set this
+# tag to YES if you prefer the old behavior instead.
+#
+# Note that setting this tag to YES also means that rational rose comments are
+# not recognized any more.
+# The default value is: NO.
+
 MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP         = NO
+
+# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
+# documentation from any documented member that it re-implements.
+# The default value is: YES.
+
 INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
+# page for each member. If set to NO, the documentation of a member will be part
+# of the file/class/namespace that contains it.
+# The default value is: NO.
+
 SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
+# uses this value to replace tabs by spaces in code fragments.
+# Minimum value: 1, maximum value: 16, default value: 4.
+
 TAB_SIZE               = 8
-ALIASES                = 
+
+# This tag can be used to specify a number of aliases that act as commands in
+# the documentation. An alias has the form:
+# name=value
+# For example adding
+# "sideeffect=@par Side Effects:\n"
+# will allow you to put the command \sideeffect (or @sideeffect) in the
+# documentation, which will result in a user-defined paragraph with heading
+# "Side Effects:". You can put \n's in the value part of an alias to insert
+# newlines.
+
+ALIASES                =
+
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form "name=value". For example adding "class=itcl::class"
+# will allow you to use the command class in the itcl::class meaning.
+
+TCL_SUBST              =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C. For
+# instance, some of the names that are used will be different. The list of all
+# members will be omitted, etc.
+# The default value is: NO.
+
 OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
+# Python sources only. Doxygen will then generate output that is more tailored
+# for that language. For instance, namespaces will be presented as packages,
+# qualified scopes will look different, etc.
+# The default value is: NO.
+
 OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources. Doxygen will then generate output that is tailored for Fortran.
+# The default value is: NO.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for VHDL.
+# The default value is: NO.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it
+# parses. With this tag you can assign which parser to use for a given
+# extension. Doxygen has a built-in mapping, but you can override or extend it
+# using this tag. The format is ext=language, where ext is a file extension, and
+# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
+# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
+# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
+# Fortran. In the later case the parser tries to guess whether the code is fixed
+# or free formatted code, this is the default for Fortran type files), VHDL. For
+# instance to make doxygen treat .inc files as Fortran files (default is PHP),
+# and .f files as C (default is Fortran), use: inc=Fortran f=C.
+#
+# Note: For files without extension you can use no_extension as a placeholder.
+#
+# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
+# the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
+# according to the Markdown format, which allows for more readable
+# documentation. See http://daringfireball.net/projects/markdown/ for details.
+# The output of markdown processing is further processed by doxygen, so you can
+# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
+# case of backward compatibilities issues.
+# The default value is: YES.
+
+MARKDOWN_SUPPORT       = YES
+
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by putting a % sign in front of the word or
+# globally by setting AUTOLINK_SUPPORT to NO.
+# The default value is: YES.
+
+AUTOLINK_SUPPORT       = YES
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should set this
+# tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string);
+# versus func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+# The default value is: NO.
+
 BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+# The default value is: NO.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
+# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
+# will parse them like normal C++ but will assume all classes use public instead
+# of private inheritance when no explicit protection keyword is present.
+# The default value is: NO.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate
+# getter and setter methods for a property. Setting this option to YES will make
+# doxygen to replace the get and set methods by a property in the documentation.
+# This will only work if the methods are indeed getting or setting a simple
+# type. If this is not the case, or you want to show the methods anyway, you
+# should set this option to NO.
+# The default value is: YES.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+# The default value is: NO.
+
 DISTRIBUTE_GROUP_DOC   = NO
+
+# If one adds a struct or class to a group and this option is enabled, then also
+# any nested class or struct is added to the same group. By default this option
+# is disabled and one has to add nested compounds explicitly via \ingroup.
+# The default value is: NO.
+
+GROUP_NESTED_COMPOUNDS = NO
+
+# Set the SUBGROUPING tag to YES to allow class member groups of the same type
+# (for instance a group of public functions) to be put as a subgroup of that
+# type (e.g. under the Public Functions section). Set it to NO to prevent
+# subgrouping. Alternatively, this can be done per class using the
+# \nosubgrouping command.
+# The default value is: YES.
+
 SUBGROUPING            = YES
+
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
+# are shown inside the group in which they are included (e.g. using \ingroup)
+# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
+# and RTF).
+#
+# Note that this feature does not work in combination with
+# SEPARATE_MEMBER_PAGES.
+# The default value is: NO.
+
+INLINE_GROUPED_CLASSES = NO
+
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
+# with only public data fields or simple typedef fields will be shown inline in
+# the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO, structs, classes, and unions are shown on a separate page (for HTML and
+# Man pages) or section (for LaTeX and RTF).
+# The default value is: NO.
+
+INLINE_SIMPLE_STRUCTS  = NO
+
+# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
+# enum is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically be
+# useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+# The default value is: NO.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can be
+# an expensive process and often the same symbol appears multiple times in the
+# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
+# doxygen will become slower. If the cache is too large, memory is wasted. The
+# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
+# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
+# symbols. At the end of a run doxygen will report the cache usage and suggest
+# the optimal cache size from a speed point of view.
+# Minimum value: 0, maximum value: 9, default value: 0.
+
+LOOKUP_CACHE_SIZE      = 0
+
 #---------------------------------------------------------------------------
 # Build related configuration options
 #---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
+# documentation are documented, even if no documentation was available. Private
+# class members and static file members will be hidden unless the
+# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
+# Note: This will also disable the warnings about undocumented members that are
+# normally produced when WARNINGS is set to YES.
+# The default value is: NO.
+
 EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
+# be included in the documentation.
+# The default value is: NO.
+
 EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
+# scope will be included in the documentation.
+# The default value is: NO.
+
+EXTRACT_PACKAGE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
+# included in the documentation.
+# The default value is: NO.
+
 EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO,
+# only classes defined in header files are included. Does not have any effect
+# for Java sources.
+# The default value is: YES.
+
 EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. If set to YES, local methods,
+# which are defined in the implementation section but not in the interface are
+# included in the documentation. If set to NO, only methods in the interface are
+# included.
+# The default value is: NO.
+
 EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base name of
+# the file that contains the anonymous namespace. By default anonymous namespace
+# are hidden.
+# The default value is: NO.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
+# undocumented members inside documented classes or files. If set to NO these
+# members will be included in the various overviews, but no documentation
+# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
 HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy. If set
+# to NO, these classes will be included in the various overviews. This option
+# has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
+
 HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
+# (class|struct|union) declarations. If set to NO, these declarations will be
+# included in the documentation.
+# The default value is: NO.
+
 HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
+# documentation blocks found inside the body of a function. If set to NO, these
+# blocks will be appended to the function's detailed documentation block.
+# The default value is: NO.
+
 HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation that is typed after a
+# \internal command is included. If the tag is set to NO then the documentation
+# will be excluded. Set it to YES to include the internal documentation.
+# The default value is: NO.
+
 INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
+# names in lower-case letters. If set to YES, upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+# The default value is: system dependent.
+
 CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
+# their full class and namespace scopes in the documentation. If set to YES, the
+# scope will be hidden.
+# The default value is: NO.
+
 HIDE_SCOPE_NAMES       = NO
+
+# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
+# append additional text to a page's title, such as Class Reference. If set to
+# YES the compound reference will be hidden.
+# The default value is: NO.
+
+HIDE_COMPOUND_REFERENCE= NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
+# the files that are included by a file in the documentation of that file.
+# The default value is: YES.
+
 SHOW_INCLUDE_FILES     = YES
+
+# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
+# grouped member an include statement to the documentation, telling the reader
+# which file to include in order to use the member.
+# The default value is: NO.
+
+SHOW_GROUPED_MEMB_INC  = NO
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
+# files with double quotes in the documentation rather than with sharp brackets.
+# The default value is: NO.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
+# documentation for inline members.
+# The default value is: YES.
+
 INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
+# (detailed) documentation of file and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order.
+# The default value is: YES.
+
 SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
+# descriptions of file, namespace and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order. Note that
+# this will also influence the order of the classes in the class list.
+# The default value is: NO.
+
 SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
+# (brief and detailed) documentation of class members so that constructors and
+# destructors are listed first. If set to NO the constructors will appear in the
+# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
+# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# member documentation.
+# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# detailed member documentation.
+# The default value is: NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
+# of group names into alphabetical order. If set to NO the group names will
+# appear in their defined order.
+# The default value is: NO.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
+# fully-qualified names, including namespaces. If set to NO, the class list will
+# be sorted only by class name, not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the alphabetical
+# list.
+# The default value is: NO.
+
 SORT_BY_SCOPE_NAME     = NO
+
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# type resolution of all parameters of a function it will reject a match between
+# the prototype and the implementation of a member function even if there is
+# only one candidate or it is obvious which candidate to choose by doing a
+# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
+# accept a match between prototype and implementation in such cases.
+# The default value is: NO.
+
+STRICT_PROTO_MATCHING  = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
+# list. This list is created by putting \todo commands in the documentation.
+# The default value is: YES.
+
 GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
+# list. This list is created by putting \test commands in the documentation.
+# The default value is: YES.
+
 GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
+# list. This list is created by putting \bug commands in the documentation.
+# The default value is: YES.
+
 GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
+# the deprecated list. This list is created by putting \deprecated commands in
+# the documentation.
+# The default value is: YES.
+
 GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS       = 
+
+# The ENABLED_SECTIONS tag can be used to enable conditional documentation
+# sections, marked by \if <section_label> ... \endif and \cond <section_label>
+# ... \endcond blocks.
+
+ENABLED_SECTIONS       =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
+# initial value of a variable or macro / define can have for it to appear in the
+# documentation. If the initializer consists of more lines than specified here
+# it will be hidden. Use a value of 0 to hide initializers completely. The
+# appearance of the value of individual variables and macros / defines can be
+# controlled using \showinitializer or \hideinitializer command in the
+# documentation regardless of this setting.
+# Minimum value: 0, maximum value: 10000, default value: 30.
+
 MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
+# the bottom of the documentation of classes and structs. If set to YES, the
+# list will mention the files that were used to generate the documentation.
+# The default value is: YES.
+
 SHOW_USED_FILES        = YES
-SHOW_DIRECTORIES       = NO
-FILE_VERSION_FILTER    = 
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
+# will remove the Files entry from the Quick Index and from the Folder Tree View
+# (if specified).
+# The default value is: YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
+# page. This will remove the Namespaces entry from the Quick Index and from the
+# Folder Tree View (if specified).
+# The default value is: YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command command input-file, where command is the value of the
+# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
+# by doxygen. Whatever the program writes to standard output is used as the file
+# version. For an example see the documentation.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
+# by doxygen. The layout file controls the global structure of the generated
+# output files in an output format independent way. To create the layout file
+# that represents doxygen's defaults, run doxygen with the -l option. You can
+# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# will be used as the name of the layout file.
+#
+# Note that if you run doxygen from a directory containing a file called
+# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
+# tag is left empty.
+
+LAYOUT_FILE            =
+
+# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
+# the reference definitions. This must be a list of .bib files. The .bib
+# extension is automatically appended if omitted. This requires the bibtex tool
+# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
+# For LaTeX the style of the bibliography can be controlled using
+# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
+# search path. See also \cite for info how to create references.
+
+CITE_BIB_FILES         =
+
 #---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
+# Configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
-QUIET                  = NO
+
+# The QUIET tag can be used to turn on/off the messages that are generated to
+# standard output by doxygen. If QUIET is set to YES this implies that the
+# messages are off.
+# The default value is: NO.
+
+QUIET                  = YES
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
+# this implies that the warnings are on.
+#
+# Tip: Turn warnings on while writing the documentation.
+# The default value is: YES.
+
 WARNINGS               = YES
-WARN_IF_UNDOCUMENTED   = YES
+
+# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
+# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
+# will automatically be disabled.
+# The default value is: YES.
+
+WARN_IF_UNDOCUMENTED   = NO
+
+# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some parameters
+# in a documented function, or documenting parameters that don't exist or using
+# markup commands wrongly.
+# The default value is: YES.
+
 WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# are documented, but have no documentation for their parameters or return
+# value. If set to NO, doxygen will only warn about wrong or incomplete
+# parameter documentation, but not about the absence of documentation.
+# The default value is: NO.
+
 WARN_NO_PARAMDOC       = NO
+
+# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
+# a warning is encountered.
+# The default value is: NO.
+
+WARN_AS_ERROR          = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that doxygen
+# can produce. The string should contain the $file, $line, and $text tags, which
+# will be replaced by the file and line number from which the warning originated
+# and the warning text. Optionally the format may contain $version, which will
+# be replaced by the version of the file (if it could be obtained via
+# FILE_VERSION_FILTER)
+# The default value is: $file:$line: $text.
+
 WARN_FORMAT            = "$file:$line: $text"
-WARN_LOGFILE           = 
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning and error
+# messages should be written. If left blank the output is written to standard
+# error (stderr).
+
+WARN_LOGFILE           =
+
 #---------------------------------------------------------------------------
-# configuration options related to the input files
+# Configuration options related to the input files
 #---------------------------------------------------------------------------
-INPUT                  = @srcdir@/src @srcdir@/include/ortp
-FILE_PATTERNS          = *.c *.h
+
+# The INPUT tag is used to specify the files and/or directories that contain
+# documented source files. You may enter file names like myfile.cpp or
+# directories like /usr/src/myproject. Separate the files or directories with
+# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
+# Note: If this tag is empty the current directory is searched.
+
+INPUT                  = @srcdir@/src \
+                         @srcdir@/include/ortp
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
+# documentation (see: http://www.gnu.org/software/libiconv) for the list of
+# possible encodings.
+# The default value is: UTF-8.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
+# *.h) to filter out the source-files in the directories.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# read by doxygen.
+#
+# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
+# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
+# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
+# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd,
+# *.vhdl, *.ucf, *.qsf, *.as and *.js.
+
+FILE_PATTERNS          = *.c \
+                         *.h \
+                         *.dox
+
+# The RECURSIVE tag can be used to specify whether or not subdirectories should
+# be searched for input files as well.
+# The default value is: NO.
+
 RECURSIVE              = NO
-EXCLUDE                = 
+
+# The EXCLUDE tag can be used to specify files and/or directories that should be
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+#
+# Note that relative paths are relative to the directory from which doxygen is
+# run.
+
+EXCLUDE                =
+
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
+# directories that are symbolic links (a Unix file system feature) are excluded
+# from the input.
+# The default value is: NO.
+
 EXCLUDE_SYMLINKS       = NO
-EXCLUDE_PATTERNS       = 
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories.
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories use the pattern */test/*
+
+EXCLUDE_SYMBOLS        =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or directories
+# that contain example code fragments that are included (see the \include
+# command).
+
 EXAMPLE_PATH           = @srcdir@/src/tests
-EXAMPLE_PATTERNS       = *.c
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank all
+# files are included.
+
+EXAMPLE_PATTERNS       =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude commands
+# irrespective of the value of the RECURSIVE tag.
+# The default value is: NO.
+
 EXAMPLE_RECURSIVE      = NO
-IMAGE_PATH             = 
-INPUT_FILTER           = 
-FILTER_PATTERNS        = 
+
+# The IMAGE_PATH tag can be used to specify one or more files or directories
+# that contain images that are to be included in the documentation (see the
+# \image command).
+
+IMAGE_PATH             =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command:
+#
+# <filter> <input-file>
+#
+# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the
+# name of an input file. Doxygen will then use the output that the filter
+# program writes to standard output. If FILTER_PATTERNS is specified, this tag
+# will be ignored.
+#
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+INPUT_FILTER           =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form: pattern=filter
+# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
+# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
+# patterns match the file name, INPUT_FILTER is applied.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
+
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will also be used to filter the input files that are used for
+# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# The default value is: NO.
+
 FILTER_SOURCE_FILES    = NO
+
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
+# it is also possible to disable source filtering for a specific pattern using
+# *.ext= (so without naming a filter).
+# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
+
+FILTER_SOURCE_PATTERNS =
+
+# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want to reuse the introduction page also for the doxygen output.
+
+USE_MDFILE_AS_MAINPAGE =
+
 #---------------------------------------------------------------------------
-# configuration options related to source browsing
+# Configuration options related to source browsing
 #---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
+# generated. Documented entities will be cross-referenced with these sources.
+#
+# Note: To get rid of all source code in the generated output, make sure that
+# also VERBATIM_HEADERS is set to NO.
+# The default value is: NO.
+
 SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body of functions,
+# classes and enums directly into the documentation.
+# The default value is: NO.
+
 INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
+# special comment blocks from generated source code fragments. Normal C, C++ and
+# Fortran comments will always remain visible.
+# The default value is: YES.
+
 STRIP_CODE_COMMENTS    = YES
-REFERENCED_BY_RELATION = YES
-REFERENCES_RELATION    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
+# function all documented functions referencing it will be listed.
+# The default value is: NO.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES then for each documented function
+# all documented entities called/used by that function will be listed.
+# The default value is: NO.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
+# to YES then the hyperlinks from functions in REFERENCES_RELATION and
+# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
+# link to the documentation.
+# The default value is: YES.
+
 REFERENCES_LINK_SOURCE = YES
+
+# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
+# source code will show a tooltip with additional information such as prototype,
+# brief description and links to the definition and documentation. Since this
+# will make the HTML file larger and loading of large files a bit slower, you
+# can opt to disable this feature.
+# The default value is: YES.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+SOURCE_TOOLTIPS        = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code will
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
+# source browser. The htags tool is part of GNU's global source tagging system
+# (see http://www.gnu.org/software/global/global.html). You will need version
+# 4.8.6 or higher.
+#
+# To use it do the following:
+# - Install the latest version of global
+# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
+# - Make sure the INPUT points to the root of the source tree
+# - Run doxygen as normal
+#
+# Doxygen will invoke htags (and that will in turn invoke gtags), so these
+# tools must be available from the command line (i.e. in the search path).
+#
+# The result: instead of the source browser generated by doxygen, the links to
+# source code will now point to the output of htags.
+# The default value is: NO.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
 USE_HTAGS              = NO
-VERBATIM_HEADERS       = YES
+
+# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
+# verbatim copy of the header file for each class for which an include is
+# specified. Set to NO to disable this.
+# See also: Section \class.
+# The default value is: YES.
+
+VERBATIM_HEADERS       = NO
+
 #---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
+# Configuration options related to the alphabetical class index
 #---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
+# compounds will be generated. Enable this if the project contains a lot of
+# classes, structs, unions or interfaces.
+# The default value is: YES.
+
 ALPHABETICAL_INDEX     = NO
+
+# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
+# which the alphabetical index list will be split.
+# Minimum value: 1, maximum value: 20, default value: 5.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
 COLS_IN_ALPHA_INDEX    = 5
-IGNORE_PREFIX          = 
+
+# In case all classes in a project start with a common prefix, all classes will
+# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
+# can be used to specify a prefix (or a list of prefixes) that should be ignored
+# while generating the index headers.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
+
+IGNORE_PREFIX          =
+
 #---------------------------------------------------------------------------
-# configuration options related to the HTML output
+# Configuration options related to the HTML output
 #---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
+# The default value is: YES.
+
 GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
 HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
+# generated HTML page (for example: .htm, .php, .asp).
+# The default value is: .html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
 HTML_FILE_EXTENSION    = .html
-HTML_HEADER            = 
-HTML_FOOTER            = 
-HTML_STYLESHEET        = 
-HTML_ALIGN_MEMBERS     = YES
-GENERATE_HTMLHELP      = NO
-CHM_FILE               = 
-HHC_LOCATION           = 
-GENERATE_CHI           = NO
-BINARY_TOC             = NO
-TOC_EXPAND             = NO
-DISABLE_INDEX          = NO
-ENUM_VALUES_PER_LINE   = 4
-GENERATE_TREEVIEW      = NO
-TREEVIEW_WIDTH         = 250
+
+# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
+# each generated HTML page. If the tag is left blank doxygen will generate a
+# standard header.
+#
+# To get valid HTML the header file that includes any scripts and style sheets
+# that doxygen needs, which is dependent on the configuration options used (e.g.
+# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
+# default header using
+# doxygen -w html new_header.html new_footer.html new_stylesheet.css
+# YourConfigFile
+# and then modify the file new_header.html. See also section "Doxygen usage"
+# for information on how to generate the default header that doxygen normally
+# uses.
+# Note: The header is subject to change so you typically have to regenerate the
+# default header when upgrading to a newer version of doxygen. For a description
+# of the possible markers and block names see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_HEADER            =
+
+# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
+# generated HTML page. If the tag is left blank doxygen will generate a standard
+# footer. See HTML_HEADER for more information on how to generate a default
+# footer and what special commands can be used inside the footer. See also
+# section "Doxygen usage" for information on how to generate the default footer
+# that doxygen normally uses.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_FOOTER            =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
+# sheet that is used by each HTML page. It can be used to fine-tune the look of
+# the HTML output. If left blank doxygen will generate a default style sheet.
+# See also section "Doxygen usage" for information on how to generate the style
+# sheet that doxygen normally uses.
+# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
+# it is more robust and this tag (HTML_STYLESHEET) will in the future become
+# obsolete.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_STYLESHEET        =
+
+# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# cascading style sheets that are included after the standard style sheets
+# created by doxygen. Using this option one can overrule certain style aspects.
+# This is preferred over using HTML_STYLESHEET since it does not replace the
+# standard style sheet and is therefore more robust against future updates.
+# Doxygen will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list). For an example see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_STYLESHEET  =
+
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the HTML output directory. Note
+# that these files will be copied to the base HTML output directory. Use the
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
+# files will be copied as-is; there are no commands or markers available.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_EXTRA_FILES       =
+
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
+# will adjust the colors in the style sheet and background images according to
+# this color. Hue is specified as an angle on a colorwheel, see
+# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
+# purple, and 360 is red again.
+# Minimum value: 0, maximum value: 359, default value: 220.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_HUE    = 220
+
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
+# in the HTML output. For a value of 0 the output will use grayscales only. A
+# value of 255 will produce the most vivid colors.
+# Minimum value: 0, maximum value: 255, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_SAT    = 100
+
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
+# luminance component of the colors in the HTML output. Values below 100
+# gradually make the output lighter, whereas values above 100 make the output
+# darker. The value divided by 100 is the actual gamma applied, so 80 represents
+# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
+# change the gamma.
+# Minimum value: 40, maximum value: 240, default value: 80.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_COLORSTYLE_GAMMA  = 80
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting this
+# to YES can help to show when doxygen was last run and thus if the
+# documentation is up to date.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_TIMESTAMP         = NO
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
+# shown in the various tree structured indices initially; the user can expand
+# and collapse entries dynamically later on. Doxygen will expand the tree to
+# such a level that at most the specified number of entries are visible (unless
+# a fully collapsed tree already exceeds this amount). So setting the number of
+# entries 1 will produce a full collapsed tree by default. 0 is a special value
+# representing an infinite number of entries and will result in a full expanded
+# tree by default.
+# Minimum value: 0, maximum value: 9999, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+HTML_INDEX_NUM_ENTRIES = 100
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files will be
+# generated that can be used as input for Apple's Xcode 3 integrated development
+# environment (see: http://developer.apple.com/tools/xcode/), introduced with
+# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# Makefile in the HTML output directory. Running make will produce the docset in
+# that directory and running make install will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
+# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# for more information.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_DOCSET        = NO
+
+# This tag determines the name of the docset feed. A documentation feed provides
+# an umbrella under which multiple documentation sets from a single provider
+# (such as a company or product suite) can be grouped.
+# The default value is: Doxygen generated docs.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# This tag specifies a string that should uniquely identify the documentation
+# set bundle. This should be a reverse domain-name style string, e.g.
+# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+# The default value is: org.doxygen.Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
+
+# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
+# The default value is: Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
+
+DOCSET_PUBLISHER_NAME  = Publisher
+
+# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
+# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
+# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
+# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# Windows.
+#
+# The HTML Help Workshop contains a compiler that can convert all HTML output
+# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
+# files are now used as the Windows 98 help format, and will replace the old
+# Windows help format (.hlp) on all Windows platforms in the future. Compressed
+# HTML files also contain an index, a table of contents, and you can search for
+# words in the documentation. The HTML workshop also contains a viewer for
+# compressed HTML files.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_HTMLHELP      = NO
+
+# The CHM_FILE tag can be used to specify the file name of the resulting .chm
+# file. You can add a path in front of the file if the result should not be
+# written to the html output directory.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_FILE               =
+
+# The HHC_LOCATION tag can be used to specify the location (absolute path
+# including file name) of the HTML help compiler (hhc.exe). If non-empty,
+# doxygen will try to run the HTML help compiler on the generated index.hhp.
+# The file has to be specified with full path.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+HHC_LOCATION           =
+
+# The GENERATE_CHI flag controls if a separate .chi index file is generated
+# (YES) or that it should be included in the master .chm file (NO).
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+GENERATE_CHI           = NO
+
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
+# and project file content.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+CHM_INDEX_ENCODING     =
+
+# The BINARY_TOC flag controls whether a binary table of contents is generated
+# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
+# enables the Previous and Next buttons.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members to
+# the table of contents of the HTML help documentation and to the tree view.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
+# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
+# (.qch) of the generated HTML documentation.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
+# the file name of the resulting .qch file. The path specified is relative to
+# the HTML output folder.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
+# Project output. For more information please see Qt Help Project / Namespace
+# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
+# Help Project output. For more information please see Qt Help Project / Virtual
+# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
+# folders).
+# The default value is: doc.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
+# filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
+# project's filter section matches. Qt Help Project / Filter Attributes (see:
+# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# The QHG_LOCATION tag can be used to specify the location of Qt's
+# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
+# generated .qhp file.
+# This tag requires that the tag GENERATE_QHP is set to YES.
+
+QHG_LOCATION           =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
+# generated, together with the HTML files, they form an Eclipse help plugin. To
+# install this plugin and make it available under the help contents menu in
+# Eclipse, the contents of the directory containing the HTML and XML files needs
+# to be copied into the plugins directory of eclipse. The name of the directory
+# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
+# After copying Eclipse needs to be restarted before the help appears.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the Eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have this
+# name. Each documentation set should have its own identifier.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# If you want full control over the layout of the generated HTML pages it might
+# be necessary to disable the index and replace it with your own. The
+# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
+# of each HTML page. A value of NO enables the index and the value YES disables
+# it. Since the tabs in the index contain the same information as the navigation
+# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+DISABLE_INDEX          = NO
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information. If the tag
+# value is set to YES, a side panel will be generated containing a tree-like
+# index structure (just like the one that is generated for HTML Help). For this
+# to work a browser that supports JavaScript, DHTML, CSS and frames is required
+# (i.e. any modern browser). Windows users are probably better off using the
+# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
+# further fine-tune the look of the index. As an example, the default style
+# sheet generated by doxygen has an example that shows how to put an image at
+# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
+# the same information as the tab index, you could consider setting
+# DISABLE_INDEX to YES when enabling this option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+GENERATE_TREEVIEW      = NO
+
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
+# doxygen will group on one line in the generated HTML documentation.
+#
+# Note that a value of 0 will completely suppress the enum values from appearing
+# in the overview section.
+# Minimum value: 0, maximum value: 20, default value: 4.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+ENUM_VALUES_PER_LINE   = 1
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
+# to set the initial width (in pixels) of the frame in which the tree is shown.
+# Minimum value: 0, maximum value: 1500, default value: 250.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+TREEVIEW_WIDTH         = 250
+
+# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
+# external symbols imported via tag files in a separate window.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+EXT_LINKS_IN_WINDOW    = NO
+
+# Use this tag to change the font size of LaTeX formulas included as images in
+# the HTML documentation. When you change the font size after a successful
+# doxygen run you need to manually remove any form_*.png images from the HTML
+# output directory to force them to be regenerated.
+# Minimum value: 8, maximum value: 50, default value: 10.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_FONTSIZE       = 10
+
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images
+# generated for formulas are transparent PNGs. Transparent PNGs are not
+# supported properly for IE 6.0, but are supported on all modern browsers.
+#
+# Note that when changing this option you need to delete any form_*.png files in
+# the HTML output directory before the changes have effect.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+FORMULA_TRANSPARENT    = YES
+
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# http://www.mathjax.org) which uses client side Javascript for the rendering
+# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
+# installed or if you want to formulas look prettier in the HTML output. When
+# enabled you may also need to install MathJax separately and configure the path
+# to it using the MATHJAX_RELPATH option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+USE_MATHJAX            = NO
+
+# When MathJax is enabled you can set the default output format to be used for
+# the MathJax output. See the MathJax site (see:
+# http://docs.mathjax.org/en/latest/output.html) for more details.
+# Possible values are: HTML-CSS (which is slower, but has the best
+# compatibility), NativeMML (i.e. MathML) and SVG.
+# The default value is: HTML-CSS.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_FORMAT         = HTML-CSS
+
+# When MathJax is enabled you need to specify the location relative to the HTML
+# output directory using the MATHJAX_RELPATH option. The destination directory
+# should contain the MathJax.js script. For instance, if the mathjax directory
+# is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
+# Content Delivery Network so you can quickly see the result without installing
+# MathJax. However, it is strongly recommended to install a local copy of
+# MathJax from http://www.mathjax.org before deployment.
+# The default value is: http://cdn.mathjax.org/mathjax/latest.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest
+
+# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
+# extension names that should be enabled during MathJax rendering. For example
+# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_EXTENSIONS     =
+
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
+# of code that will be used on startup of the MathJax code. See the MathJax site
+# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
+# example see the documentation.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_CODEFILE       =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
+# the HTML output. The underlying search engine uses javascript and DHTML and
+# should work on any modern browser. Note that when using HTML help
+# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
+# there is already a search function so this one should typically be disabled.
+# For large projects the javascript based search engine can be slow, then
+# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
+# search using the keyboard; to jump to the search box use <access key> + S
+# (what the <access key> is depends on the OS and browser, but it is typically
+# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down
+# key> to jump into the search results window, the results can be navigated
+# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel
+# the search. The filter options can be selected when the cursor is inside the
+# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>
+# to select a filter and <Enter> or <escape> to activate or cancel the filter
+# option.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
+
+SEARCHENGINE           = NO
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
+# implemented using a web server instead of a web client using Javascript. There
+# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
+# setting. When disabled, doxygen will generate a PHP script for searching and
+# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
+# and searching needs to be provided by external tools. See the section
+# "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SERVER_BASED_SEARCH    = NO
+
+# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
+# script for searching. Instead the search results are written to an XML file
+# which needs to be processed by an external indexer. Doxygen will invoke an
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# search results.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: http://xapian.org/).
+#
+# See the section "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH        = NO
+
+# The SEARCHENGINE_URL should point to a search engine hosted by a web server
+# which will return the search results when EXTERNAL_SEARCH is enabled.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: http://xapian.org/). See the section "External Indexing and
+# Searching" for details.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHENGINE_URL       =
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
+# search data is written to a file for indexing by an external tool. With the
+# SEARCHDATA_FILE tag the name of this file can be specified.
+# The default file is: searchdata.xml.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+SEARCHDATA_FILE        = searchdata.xml
+
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
+# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
+# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
+# projects and redirect the results back to the right project.
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTERNAL_SEARCH_ID     =
+
+# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
+# projects other than the one defined by this configuration file, but that are
+# all added to the same external search index. Each project needs to have a
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
+# to a relative location where the documentation can be found. The format is:
+# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
+# This tag requires that the tag SEARCHENGINE is set to YES.
+
+EXTRA_SEARCH_MAPPINGS  =
+
 #---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
+# Configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
-GENERATE_LATEX         = NO
+
+# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
+# The default value is: YES.
+
+GENERATE_LATEX         = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
 LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked.
+#
+# Note that when enabling USE_PDFLATEX this option is only used for generating
+# bitmaps for formulas in the HTML output, but not in the Makefile that is
+# written to the output directory.
+# The default file is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
 LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
+# index for LaTeX.
+# The default file is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
 MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
 COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used by the
+# printer.
+# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
+# 14 inches) and executive (7.25 x 10.5 inches).
+# The default value is: a4.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
 PAPER_TYPE             = a4wide
-EXTRA_PACKAGES         = 
-LATEX_HEADER           = 
+
+# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
+# that should be included in the LaTeX output. The package can be specified just
+# by its name or with the correct syntax as to be used with the LaTeX
+# \usepackage command. To get the times font for instance you can specify :
+# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
+# To use the option intlimits with the amsmath package you can specify:
+# EXTRA_PACKAGES=[intlimits]{amsmath}
+# If left blank no extra packages will be included.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+EXTRA_PACKAGES         =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
+# generated LaTeX document. The header should contain everything until the first
+# chapter. If it is left blank doxygen will generate a standard header. See
+# section "Doxygen usage" for information on how to let doxygen write the
+# default header to a separate file.
+#
+# Note: Only use a user-defined header if you know what you are doing! The
+# following commands have a special meaning inside the header: $title,
+# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
+# string, for the replacement values of the other commands the user is referred
+# to HTML_HEADER.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_HEADER           =
+
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
+# generated LaTeX document. The footer should contain everything after the last
+# chapter. If it is left blank doxygen will generate a standard footer. See
+# LATEX_HEADER for more information on how to generate a default footer and what
+# special commands can be used inside the footer.
+#
+# Note: Only use a user-defined footer if you know what you are doing!
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_FOOTER           =
+
+# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# LaTeX style sheets that are included after the standard style sheets created
+# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_STYLESHEET =
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the LATEX_OUTPUT output
+# directory. Note that the files will be copied as-is; there are no commands or
+# markers available.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_FILES      =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
+# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
+# contain links (just like the HTML output) instead of page references. This
+# makes the output suitable for online browsing using a PDF viewer.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
 PDF_HYPERLINKS         = NO
+
+# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
+# the PDF file directly from the LaTeX files. Set this option to YES, to get a
+# higher quality PDF documentation.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
 USE_PDFLATEX           = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
+# command to the generated LaTeX files. This will instruct LaTeX to keep running
+# if errors occur, instead of asking the user for help. This option is also used
+# when generating formulas in HTML.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
 LATEX_BATCHMODE        = NO
+
+# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
+# index chapters (such as File Index, Compound Index, etc.) in the output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
 LATEX_HIDE_INDICES     = NO
+
+# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
+# code with syntax highlighting in the LaTeX output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_SOURCE_CODE      = NO
+
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
+# bibliography, e.g. plainnat, or ieeetr. See
+# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# The default value is: plain.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_BIB_STYLE        = plain
+
+# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_TIMESTAMP        = NO
+
 #---------------------------------------------------------------------------
-# configuration options related to the RTF output
+# Configuration options related to the RTF output
 #---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
+# RTF output is optimized for Word 97 and may not look too pretty with other RTF
+# readers/editors.
+# The default value is: NO.
+
 GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: rtf.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
 RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
 COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
+# contain hyperlink fields. The RTF file will contain links (just like the HTML
+# output) instead of page references. This makes the output suitable for online
+# browsing using Word or some other Word compatible readers that support those
+# fields.
+#
+# Note: WordPad (write) and others do not support links.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
 RTF_HYPERLINKS         = NO
-RTF_STYLESHEET_FILE    = 
-RTF_EXTENSIONS_FILE    = 
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's config
+# file, i.e. a series of assignments. You only have to provide replacements,
+# missing definitions are set to their default value.
+#
+# See also section "Doxygen usage" for information on how to generate the
+# default style sheet that doxygen normally uses.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_STYLESHEET_FILE    =
+
+# Set optional variables used in the generation of an RTF document. Syntax is
+# similar to doxygen's config file. A template extensions file can be generated
+# using doxygen -e rtf extensionFile.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_EXTENSIONS_FILE    =
+
+# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
+# with syntax highlighting in the RTF output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_SOURCE_CODE        = NO
+
 #---------------------------------------------------------------------------
-# configuration options related to the man page output
+# Configuration options related to the man page output
 #---------------------------------------------------------------------------
-GENERATE_MAN           = NO
+
+# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
+# classes and files.
+# The default value is: NO.
+
+GENERATE_MAN           = YES
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it. A directory man3 will be created inside the directory specified by
+# MAN_OUTPUT.
+# The default directory is: man.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
 MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to the generated
+# man pages. In case the manual section does not start with a number, the number
+# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
+# optional.
+# The default value is: .3.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
 MAN_EXTENSION          = .3
+
+# The MAN_SUBDIR tag determines the name of the directory created within
+# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+# MAN_EXTENSION with the initial . removed.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_SUBDIR             =
+
+# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
+# will generate one additional man file for each entity documented in the real
+# man page(s). These additional files only source the real man page, but without
+# them the man command would be unable to find the correct page.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
 MAN_LINKS              = NO
+
 #---------------------------------------------------------------------------
-# configuration options related to the XML output
+# Configuration options related to the XML output
 #---------------------------------------------------------------------------
-GENERATE_XML           = NO
+
+# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
+# captures the structure of the code including all documentation.
+# The default value is: NO.
+
+GENERATE_XML           = YES
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: xml.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
 XML_OUTPUT             = xml
-XML_SCHEMA             = 
-XML_DTD                = 
+
+# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
+# listings (including syntax highlighting and cross-referencing information) to
+# the XML output. Note that enabling this will significantly increase the size
+# of the XML output.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_XML is set to YES.
+
 XML_PROGRAMLISTING     = YES
+
 #---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
+# Configuration options related to the DOCBOOK output
 #---------------------------------------------------------------------------
+
+# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
+# that can be used to generate PDF.
+# The default value is: NO.
+
+GENERATE_DOCBOOK       = NO
+
+# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it.
+# The default directory is: docbook.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_OUTPUT         = docbook
+
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
+# program listings (including syntax highlighting and cross-referencing
+# information) to the DOCBOOK output. Note that enabling this will significantly
+# increase the size of the DOCBOOK output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_PROGRAMLISTING = NO
+
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
+# AutoGen Definitions (see http://autogen.sf.net) file that captures the
+# structure of the code including all documentation. Note that this feature is
+# still experimental and incomplete at the moment.
+# The default value is: NO.
+
 GENERATE_AUTOGEN_DEF   = NO
+
 #---------------------------------------------------------------------------
-# configuration options related to the Perl module output
+# Configuration options related to the Perl module output
 #---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
+# file that captures the structure of the code including all documentation.
+#
+# Note that this feature is still experimental and incomplete at the moment.
+# The default value is: NO.
+
 GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
+# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
+# output from the Perl module output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
 PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
+# formatted so it can be parsed by a human reader. This is useful if you want to
+# understand what is going on. On the other hand, if this tag is set to NO, the
+# size of the Perl module output will be much smaller and Perl will parse it
+# just the same.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
 PERLMOD_PRETTY         = YES
-PERLMOD_MAKEVAR_PREFIX = 
+
+# The names of the make variables in the generated doxyrules.make file are
+# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
+# so different doxyrules.make files included by the same Makefile don't
+# overwrite each other's variables.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
+
+PERLMOD_MAKEVAR_PREFIX =
+
 #---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
+# Configuration options related to the preprocessor
 #---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
+# C-preprocessor directives found in the sources and include files.
+# The default value is: YES.
+
 ENABLE_PREPROCESSING   = YES
-MACRO_EXPANSION        = NO
+
+# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
+# in the source code. If set to NO, only conditional compilation will be
+# performed. Macro expansion can be done in a controlled way by setting
+# EXPAND_ONLY_PREDEF to YES.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+MACRO_EXPANSION        = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
+# the macro expansion is limited to the macros specified with the PREDEFINED and
+# EXPAND_AS_DEFINED tags.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
 EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES, the include files in the
+# INCLUDE_PATH will be searched if a #include is found.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
 SEARCH_INCLUDES        = YES
-INCLUDE_PATH           = 
-INCLUDE_FILE_PATTERNS  = 
-PREDEFINED             = 
-EXPAND_AS_DEFINED      = 
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by the
+# preprocessor.
+# This tag requires that the tag SEARCH_INCLUDES is set to YES.
+
+INCLUDE_PATH           = .
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will be
+# used.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+INCLUDE_FILE_PATTERNS  = *.h
+
+# The PREDEFINED tag can be used to specify one or more macro names that are
+# defined before the preprocessor is started (similar to the -D option of e.g.
+# gcc). The argument of the tag is a list of macros of the form: name or
+# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
+# is assumed. To prevent a macro definition from being undefined via #undef or
+# recursively expanded use the := operator instead of the = operator.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+PREDEFINED             = DOXYGEN \
+                         MS2_PUBLIC= \
+                         LINPHONE_PUBLIC= \
+                         ORTP_PUBLIC
+
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
+# tag can be used to specify a list of macro names that should be expanded. The
+# macro definition that is found in the sources will be used. Use the PREDEFINED
+# tag if you want to use a different macro definition that overrules the
+# definition found in the source code.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
+EXPAND_AS_DEFINED      =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
+# remove all references to function-like macros that are alone on a line, have
+# an all uppercase name, and do not end with a semicolon. Such function macros
+# are typically used for boiler-plate code, and will confuse the parser if not
+# removed.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
+
 SKIP_FUNCTION_MACROS   = YES
+
 #---------------------------------------------------------------------------
-# Configuration::additions related to external references   
+# Configuration options related to external references
 #---------------------------------------------------------------------------
-TAGFILES               = 
-GENERATE_TAGFILE       = 
+
+# The TAGFILES tag can be used to specify one or more tag files. For each tag
+# file the location of the external documentation should be added. The format of
+# a tag file without this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where loc1 and loc2 can be relative or absolute paths or URLs. See the
+# section "Linking to external documentation" for more information about the use
+# of tag files.
+# Note: Each tag file must have a unique name (where the name does NOT include
+# the path). If a tag file is not located in the directory in which doxygen is
+# run, you must also specify the path to the tagfile here.
+
+TAGFILES               =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
+# tag file that is based on the input files it reads. See section "Linking to
+# external documentation" for more information about the usage of tag files.
+
+GENERATE_TAGFILE       =
+
+# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
+# the class index. If set to NO, only the inherited external classes will be
+# listed.
+# The default value is: NO.
+
 ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will be
+# listed.
+# The default value is: YES.
+
 EXTERNAL_GROUPS        = YES
+
+# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
+# the related pages index. If set to NO, only the current project's pages will
+# be listed.
+# The default value is: YES.
+
+EXTERNAL_PAGES         = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of 'which perl').
+# The default file (with absolute path) is: /usr/bin/perl.
+
 PERL_PATH              = /usr/bin/perl
+
 #---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
+# Configuration options related to the dot tool
 #---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
+# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
+# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# disabled, but it is recommended to install and use dot, since it yields more
+# powerful graphs.
+# The default value is: YES.
+
 CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see:
+# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
+# You can include diagrams made with dia in doxygen documentation. Doxygen will
+# then run dia to produce the diagram and insert it in the documentation. The
+# DIA_PATH tag allows you to specify the directory where the dia binary resides.
+# If left empty dia is assumed to be found in the default search path.
+
+DIA_PATH               =
+
+# If set to YES the inheritance and collaboration graphs will hide inheritance
+# and usage relations if the target is undocumented or is not a class.
+# The default value is: YES.
+
 HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz (see:
+# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
+# Bell Labs. The other options in this section have no effect if this option is
+# set to NO
+# The default value is: NO.
+
 HAVE_DOT               = NO
+
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
+# to run in parallel. When set to 0 doxygen will base this on the number of
+# processors available in the system. You can set it explicitly to a value
+# larger than 0 to get control over the balance between CPU load and processing
+# speed.
+# Minimum value: 0, maximum value: 32, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_NUM_THREADS        = 0
+
+# When you want a differently looking font in the dot files that doxygen
+# generates you can specify the font name using DOT_FONTNAME. You need to make
+# sure dot is able to find the font, which can be done by putting it in a
+# standard location or by setting the DOTFONTPATH environment variable or by
+# setting DOT_FONTPATH to the directory containing the font.
+# The default value is: Helvetica.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTNAME           = Helvetica
+
+# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
+# dot graphs.
+# Minimum value: 4, maximum value: 24, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the default font as specified with
+# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
+# the path where dot can find it using this tag.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
+# each documented class showing the direct and indirect inheritance relations.
+# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
+# graph for each documented class showing the direct and indirect implementation
+# dependencies (inheritance, containment, and class references variables) of the
+# class with other documented classes.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
+# groups, showing the direct groups dependencies.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 UML_LOOK               = NO
-TEMPLATE_RELATIONS     = NO
+
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
+# class node. If there are many fields or methods and many nodes the graph may
+# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
+# number of items for each type to make the size more manageable. Set this to 0
+# for no limit. Note that the threshold may be exceeded by 50% before the limit
+# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
+# but if the number exceeds 15, the total amount of fields shown is limited to
+# 10.
+# Minimum value: 0, maximum value: 100, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+UML_LIMIT_NUM_FIELDS   = 10
+
+# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
+# collaboration graphs will show the relations between templates and their
+# instances.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+TEMPLATE_RELATIONS     = YES
+
+# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
+# YES then doxygen will generate a graph for each documented file showing the
+# direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 INCLUDE_GRAPH          = YES
+
+# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
+# set to YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command. Disabling a call graph can be
+# accomplished by means of the command \hidecallgraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command. Disabling a caller graph can be
+# accomplished by means of the command \hidecallergraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
+# hierarchy of all classes instead of a textual one.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
+# dependencies a directory has on other directories in a graphical way. The
+# dependency relations are determined by the #include relations between the
+# files in the directories.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. For an explanation of the image formats see the section
+# output formats in the documentation of the dot tool (Graphviz (see:
+# http://www.graphviz.org/)).
+# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
+# to make the SVG files visible in IE 9+ (other browsers do not have this
+# requirement).
+# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo,
+# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
+# png:gdiplus:gdiplus.
+# The default value is: png.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 DOT_IMAGE_FORMAT       = png
-DOT_PATH               = 
-DOTFILE_DIRS           = 
-MAX_DOT_GRAPH_WIDTH    = 1024
-MAX_DOT_GRAPH_HEIGHT   = 1024
-MAX_DOT_GRAPH_DEPTH    = 0
+
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
+# enable generation of interactive SVG images that allow zooming and panning.
+#
+# Note that this requires a modern browser other than Internet Explorer. Tested
+# and working are Firefox, Chrome, Safari, and Opera.
+# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
+# the SVG files visible. Older versions of IE do not have SVG support.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+INTERACTIVE_SVG        = NO
+
+# The DOT_PATH tag can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_PATH               =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the \dotfile
+# command).
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOTFILE_DIRS           =
+
+# The MSCFILE_DIRS tag can be used to specify one or more directories that
+# contain msc files that are included in the documentation (see the \mscfile
+# command).
+
+MSCFILE_DIRS           =
+
+# The DIAFILE_DIRS tag can be used to specify one or more directories that
+# contain dia files that are included in the documentation (see the \diafile
+# command).
+
+DIAFILE_DIRS           =
+
+# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
+# path where java can find the plantuml.jar file. If left blank, it is assumed
+# PlantUML is not used or called during a preprocessing step. Doxygen will
+# generate a warning when it encounters a \startuml command in this case and
+# will not generate output for the diagram.
+
+PLANTUML_JAR_PATH      =
+
+# When using plantuml, the specified paths are searched for files specified by
+# the !include statement in a plantuml block.
+
+PLANTUML_INCLUDE_PATH  =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
+# that will be shown in the graph. If the number of nodes in a graph becomes
+# larger than this value, doxygen will truncate the graph, which is visualized
+# by representing a node as a red box. Note that doxygen if the number of direct
+# children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
+# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# Minimum value: 0, maximum value: 10000, default value: 50.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
+# generated by dot. A depth value of 3 means that only nodes reachable from the
+# root by following a path via at most 3 edges will be shown. Nodes that lay
+# further from the root node will be omitted. Note that setting this option to 1
+# or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+# Minimum value: 0, maximum value: 1000, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
+MAX_DOT_GRAPH_DEPTH    = 1000
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not seem
+# to support this out of the box.
+#
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10) support
+# this, this feature is disabled by default.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
+# explaining the meaning of the various boxes and arrows in the dot generated
+# graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
+# files that are used to generate the various graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
+
 DOT_CLEANUP            = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine   
-#---------------------------------------------------------------------------
-SEARCHENGINE           = NO
diff --git a/ortp.spec.in b/ortp.spec.in
index 91a3530..468498d 100644
--- a/ortp.spec.in
+++ b/ortp.spec.in
@@ -40,7 +40,7 @@ BuildArch:	i686
 
 %description
 oRTP is a LGPL licensed C library implementing the RTP protocol
-(rfc1889). It is available for most unix clones (primilarly Linux and
+(rfc3550). It is available for most unix clones (primilarly Linux and
 HP-UX), and Microsoft Windows.
 
 %package        devel
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index eef646b..2a87b30 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,12 +20,18 @@
 #
 ############################################################################
 
-set(LIBS ${CMAKE_THREAD_LIBS_INIT})
+set(LIBS ${BCTOOLBOX_CORE_LIBRARIES})
+if(NOT ANDROID)
+	list(APPEND LIBS ${CMAKE_THREAD_LIBS_INIT})
+endif()
 if(HAVE_RT)
 	list(APPEND LIBS rt)
 endif()
+if(LIBM)
+	list(APPEND LIBS ${LIBM})
+endif()
 
-set(SOURCE_FILES
+set(ORTP_SOURCE_FILES_C
 	avprofile.c
 	b64.c
 	event.c
@@ -53,51 +59,68 @@ set(SOURCE_FILES
 	telephonyevents.c
 	utils.c
 )
+set(ORTP_SOURCE_FILES_CXX )
 
 if(WIN32)
-	list(APPEND SOURCE_FILES dll_entry.c)
-	if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsPhone")
-		list(APPEND SOURCE_FILES winrttimer.cpp winrttimer.h)
+	list(APPEND ORTP_SOURCE_FILES_C dll_entry.c)
+	if(CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone")
+		list(APPEND ORTP_SOURCE_FILES_CXX winrttimer.cpp winrttimer.h)
 		set_source_files_properties(winrttimer.cpp PROPERTIES COMPILE_FLAGS "/ZW /AI\$(WindowsSDK_MetadataPath)")
 	endif()
 endif()
 
-add_definitions(
-	-DORTP_EXPORTS
-)
-
 if(WIN32)
 	add_definitions(-DWINDOWS_NATIVE)
-	list(APPEND LIBS ws2_32)
-	if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsPhone")
+	if(NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
+		list(APPEND LIBS ws2_32)
+	endif()
+	if(NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
 		list(APPEND LIBS delayimp Winmm Qwave)
 	endif()
 endif()
 
+apply_compile_flags(ORTP_SOURCE_FILES_C "CPP" "C")
+apply_compile_flags(ORTP_SOURCE_FILES_CXX "CPP" "CXX")
+
 if(ENABLE_STATIC)
-	add_library(ortp STATIC ${SOURCE_FILES})
-	target_link_libraries(ortp ${LIBS})
-else()
-	add_library(ortp SHARED ${SOURCE_FILES})
-	set_target_properties(ortp PROPERTIES VERSION ${ORTP_SO_VERSION})
+	add_library(ortp-static STATIC ${ORTP_HEADER_FILES} ${ORTP_SOURCE_FILES_C} ${ORTP_SOURCE_FILES_CXX})
+	set_target_properties(ortp-static PROPERTIES OUTPUT_NAME ortp)
+	target_compile_definitions(ortp-static PRIVATE "ORTP_EXPORTS")
+	target_link_libraries(ortp-static ${LIBS})
+	install(TARGETS ortp-static EXPORT ${EXPORT_TARGETS_NAME}Targets
+		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+	)
+endif()
+if(ENABLE_SHARED)
+	add_library(ortp SHARED ${ORTP_HEADER_FILES} ${ORTP_SOURCE_FILES_C} ${ORTP_SOURCE_FILES_CXX})
+	if(ANDROID)
+		set_target_properties(ortp PROPERTIES OUTPUT_NAME "ortp-${CMAKE_SYSTEM_PROCESSOR}")
+	else()
+		# Do not version shared library on Android
+		set_target_properties(ortp PROPERTIES SOVERSION ${ORTP_SO_VERSION})
+	endif()
+	if(WIN32)
+		target_compile_options(ortp PRIVATE "/DELAYLOAD:Qwave.dll")
+	endif()
+	target_compile_definitions(ortp PRIVATE "ORTP_EXPORTS")
 	target_link_libraries(ortp ${LIBS})
 	if(MSVC)
 		if(CMAKE_BUILD_TYPE STREQUAL "Debug")
 			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/ortp.pdb
-				DESTINATION bin
+				DESTINATION ${CMAKE_INSTALL_BINDIR}
 				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
 			)
 		endif()
 	endif()
+	install(TARGETS ortp EXPORT ${EXPORT_TARGETS_NAME}Targets
+		RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+		ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+		PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+	)
 endif()
 
-install(TARGETS ortp EXPORT ORTPTargets
-	RUNTIME DESTINATION bin
-	LIBRARY DESTINATION lib
-	ARCHIVE DESTINATION lib
-	PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
-)
-
-if(ENABLE_TESTS)
+if(ENABLE_TESTS AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
 	add_subdirectory(tests)
 endif()
diff --git a/src/Makefile.am b/src/Makefile.am
index 19300b7..b5fed70 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,8 @@ AM_CPPFLAGS=\
 	$(STRICT_OPTIONS) \
 	$(STRICT_OPTIONS_CXX) \
 	-I$(top_srcdir)/include/ \
-	-I$(top_srcdir)
+	-I$(top_srcdir) \
+	$(BCTOOLBOX_CFLAGS)
 
 AM_CFLAGS=\
 	$(STRICT_OPTIONS) \
@@ -46,7 +47,7 @@ libortp_la_SOURCES=	\
 			telephonyevents.c  \
 			utils.c utils.h
 
-libortp_la_LIBADD= $(PTHREAD_LIBS) $(RT_LIBS) -lm $(SSL_LIBS)
+libortp_la_LIBADD= $(PTHREAD_LIBS) $(RT_LIBS) -lm $(BCTOOLBOX_LIBS)
 
 libortp_la_LDFLAGS= -version-info $(LIBORTP_SO_VERSION) -no-undefined
 
diff --git a/src/avprofile.c b/src/avprofile.c
index a513311..54502ad 100644
--- a/src/avprofile.c
+++ b/src/avprofile.c
@@ -76,7 +76,7 @@ char offset0[4] = {0x00, 0x00, 0x00, 0x00};
 #define RECV_FMTP(val)		(val)
 #define SEND_FMTP(val)		(val)
 #define NO_AVPF		{PAYLOAD_TYPE_AVPF_NONE, 0}
-#define AVPF(feat, intv)		{(feat), (intv)}
+#define AVPF(feat, intv)		{(feat), FALSE, (intv)}
 #define FLAGS(val)		(val)
 
 #endif
@@ -171,7 +171,6 @@ PayloadType payload_type_lpc1016={
 	FLAGS(0)
 };
 
-
 PayloadType payload_type_gsm={
 	TYPE(PAYLOAD_AUDIO_PACKETIZED),
 	CLOCK_RATE(8000),
@@ -458,6 +457,7 @@ void av_profile_init(RtpProfile *profile)
 {
 	rtp_profile_clear_all(profile);
 	profile->name="AV profile";
+	
 	rtp_profile_set_payload(profile,0,&payload_type_pcmu8000);
 	rtp_profile_set_payload(profile,1,&payload_type_lpc1016);
 	rtp_profile_set_payload(profile,3,&payload_type_gsm);
@@ -472,6 +472,7 @@ void av_profile_init(RtpProfile *profile)
 	rtp_profile_set_payload(profile,31,&payload_type_h261);
 	rtp_profile_set_payload(profile,32,&payload_type_mpv);
 	rtp_profile_set_payload(profile,34,&payload_type_h263);
+
 }
 
 /* these are extra payload types that can be used dynamically */
@@ -505,6 +506,21 @@ PayloadType payload_type_speex_nb={
 	FLAGS(PAYLOAD_TYPE_IS_VBR)
 };
 
+PayloadType payload_type_bv16={
+	TYPE(PAYLOAD_AUDIO_PACKETIZED),
+	CLOCK_RATE(8000),
+	BITS_PER_SAMPLE(0),
+	ZERO_PATTERN(NULL),
+	PATTERN_LENGTH(0),
+	NORMAL_BITRATE(16000),/* 5ms / 80 bits per frame */
+	MIME_TYPE("BV16"),
+	CHANNELS(1),
+	RECV_FMTP(NULL),
+	SEND_FMTP(NULL),
+	NO_AVPF,
+	FLAGS(0)
+};
+
 PayloadType payload_type_speex_wb={
 	TYPE(PAYLOAD_AUDIO_PACKETIZED),
 	CLOCK_RATE(16000),
@@ -602,7 +618,7 @@ PayloadType payload_type_mp4v={
 	CHANNELS(0),
 	RECV_FMTP(NULL),
 	SEND_FMTP(NULL),
-	NO_AVPF,
+	AVPF(PAYLOAD_TYPE_AVPF_FIR | PAYLOAD_TYPE_AVPF_PLI, RTCP_DEFAULT_REPORT_INTERVAL),
 	FLAGS(0)
 };
 
@@ -693,8 +709,8 @@ PayloadType payload_type_h264={
 	CHANNELS(0),
 	RECV_FMTP(NULL),
 	SEND_FMTP(NULL),
-	NO_AVPF,
-	FLAGS(0)
+	AVPF(PAYLOAD_TYPE_AVPF_FIR | PAYLOAD_TYPE_AVPF_PLI, RTCP_DEFAULT_REPORT_INTERVAL),
+	FLAGS(PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED)
 };
 
 PayloadType payload_type_x_snow={
@@ -966,3 +982,18 @@ PayloadType payload_type_isac = {
 	NO_AVPF,
 	FLAGS(PAYLOAD_TYPE_IS_VBR)
 };
+
+PayloadType payload_type_codec2={
+	TYPE(PAYLOAD_AUDIO_PACKETIZED),
+	CLOCK_RATE(8000),
+	BITS_PER_SAMPLE(0),
+	ZERO_PATTERN(NULL),
+	PATTERN_LENGTH(0),
+	NORMAL_BITRATE(3200),
+	MIME_TYPE("CODEC2"),
+	CHANNELS(1),
+	RECV_FMTP(NULL),
+	SEND_FMTP(NULL),
+	NO_AVPF,
+	FLAGS(0)
+};
diff --git a/src/dll_entry.c b/src/dll_entry.c
index 93f7d6b..9479ba5 100644
--- a/src/dll_entry.c
+++ b/src/dll_entry.c
@@ -7,7 +7,7 @@
 typedef struct __STRUCT_SHARED_DATA__
 {
 	DWORD				m_nReference;
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	DWORD				m_dwStartTime;
 #else
 	ULONGLONG			m_ullStartTime;
@@ -27,7 +27,7 @@ extern DWORD dwoRTPLogLevel;
 
 #define	SHMEMSIZE	sizeof(SHARED_DATA)
 
-#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifndef ORTP_WINDOWS_DESKTOP
 static SHARED_DATA		sharedData;
 #endif
 static	LPSHARED_DATA	lpSharedData;
@@ -61,7 +61,7 @@ BOOL WINAPI DllMain(
 				return FALSE;
 			}
 
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
             // Create a named file mapping object. 
             hMapObject = CreateFileMapping( INVALID_HANDLE_VALUE,	// use paging file
 											NULL,					// default security attributes
@@ -100,7 +100,7 @@ BOOL WINAPI DllMain(
 				OutputDebugStringW(L"--> dll_entry.c - oRTP.dll - Initializing module\n");
 #endif
 
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 				lpSharedData->m_dwStartTime	= GetTickCount();
 #else
 				lpSharedData->m_ullStartTime = GetTickCount64();
@@ -164,7 +164,7 @@ BOOL WINAPI DllMain(
 					ortp_exit();
 					UnregisterLog(&dwoRTPLogLevel, "LOG_ORTP");
 
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 					// Unmap shared memory from the process's address space. 
 					UnmapViewOfFile(lpSharedData);
 					lpSharedData = NULL;
diff --git a/src/event.c b/src/event.c
index 555ae42..33a27e4 100644
--- a/src/event.c
+++ b/src/event.c
@@ -19,6 +19,8 @@
 
 #include "ortp/event.h"
 #include "ortp/ortp.h"
+#include "ortp/rtpsession.h"
+#include "utils.h"
 
 OrtpEvent * ortp_event_new(unsigned long type){
 	OrtpEventData *ed;
@@ -90,3 +92,97 @@ void ortp_ev_queue_put(OrtpEvQueue *q, OrtpEvent *ev){
 	ortp_mutex_unlock(&q->mutex);
 }
 
+static bool_t rtcp_is_type(const mblk_t *m, rtcp_type_t type){
+	const rtcp_common_header_t *ch=rtcp_get_common_header(m);
+	return (ch!=NULL && rtcp_common_header_get_packet_type(ch)==type);
+}
+
+OrtpEvDispatcher * ortp_ev_dispatcher_new(RtpSession* session) {
+	OrtpEvDispatcher *d=ortp_new(OrtpEvDispatcher,1);
+	d->session = session;
+	d->q = ortp_ev_queue_new();
+	rtp_session_register_event_queue(session, d->q);
+	d->cbs = NULL;
+
+	return d;
+}
+
+void ortp_ev_dispatcher_destroy(OrtpEvDispatcher *d) {
+	OList* it;
+	for (it=d->cbs;it!=NULL;it=it->next){
+		ortp_free(it->data);
+	}
+	o_list_free(d->cbs);
+	rtp_session_unregister_event_queue(d->session, d->q);
+	ortp_ev_queue_destroy(d->q);
+	ortp_free(d);
+}
+
+static bool_t is_rtcp_event(OrtpEventType type) {
+	return (type == ORTP_EVENT_RTCP_PACKET_RECEIVED || type == ORTP_EVENT_RTCP_PACKET_EMITTED);
+}
+
+static void iterate_cbs(OrtpEvDispatcher *disp, OrtpEvent *ev) {
+	OrtpEventData *d = ortp_event_get_data(ev);
+	do {
+		/*for each packet part, if ANY iterate through the whole callback list to see if
+		anyone is interested in it*/
+		OrtpEventData *d = ortp_event_get_data(ev);
+		OList* it;
+		OrtpEventType evt = ortp_event_get_type(ev);
+		for (it = disp->cbs; it != NULL; it = it->next){
+			OrtpEvDispatcherData *data = (OrtpEvDispatcherData *)it->data;
+			/*
+			const rtcp_common_header_t *ch = rtcp_get_common_header(d->packet);
+			rtcp_type_t packet_type = 0;
+			if (ch != NULL) {
+				packet_type = rtcp_common_header_get_packet_type(ch);
+			}
+			*/
+			if (evt == data->type) {
+				if (!is_rtcp_event(data->type) || rtcp_is_type(d->packet, data->subtype)) {
+					data->on_found(d, data->user_data);
+				}
+			}
+		}
+	} while (d->packet!=NULL && rtcp_next_packet(d->packet));
+}
+
+void ortp_ev_dispatcher_iterate(OrtpEvDispatcher *d) {
+	OrtpEvent *ev = NULL;
+	while ((ev = ortp_ev_queue_get(d->q)) != NULL) {
+		iterate_cbs(d, ev);
+		ortp_event_destroy(ev);
+	}
+}
+
+void ortp_ev_dispatcher_connect(OrtpEvDispatcher *d
+								, OrtpEventType type
+								, rtcp_type_t subtype
+								, OrtpEvDispatcherCb cb
+								, void *user_data) {
+	OrtpEvDispatcherData *data=ortp_new(OrtpEvDispatcherData,1);
+	data->type = type;
+	data->subtype = subtype;
+	data->on_found = cb;
+	data->user_data = user_data;
+	d->cbs = o_list_append(d->cbs, data);
+}
+
+void ortp_ev_dispatcher_disconnect(OrtpEvDispatcher *d
+								, OrtpEventType type
+								, rtcp_type_t subtype
+								, OrtpEvDispatcherCb cb) {
+	OList *it = d->cbs;
+	while (it) {
+		OrtpEvDispatcherData *data = (OrtpEvDispatcherData*)it->data;
+		if (data && data->type == type && data->subtype == subtype && data->on_found == cb) {
+			OList *tofree = it;
+			it = it->next;
+			ortp_free(data);
+			d->cbs = o_list_remove_link(d->cbs, tofree);
+		} else {
+			it = it->next;
+		}
+	}
+}
diff --git a/src/jitterctl.c b/src/jitterctl.c
index 9be835b..5b09efe 100644
--- a/src/jitterctl.c
+++ b/src/jitterctl.c
@@ -132,7 +132,7 @@ void jitter_control_new_packet(JitterControl *ctl, uint32_t packet_ts, uint32_t
 			ctl->adapt_jitt_comp_ts=(int) MAX(ctl->jitt_comp_ts,2*ctl->jitter);
 			//jitter_control_dump_stats(ctl);
 		}
-		
+
 		ctl->slide=slide;
 	}else {
 		/*ctl->slide and jitter size are not updated*/
@@ -153,11 +153,10 @@ float jitter_control_compute_mean_size(JitterControl *ctl){
 
 
 /**
- *rtp_session_set_jitter_compensation:
- *@session: a RtpSession
- *@milisec: the time interval in milisec to be jitter compensed.
+ *@param session: a RtpSession
+ *@param milisec: the time interval in milisec to be jitter compensed.
  *
- * Sets the time interval for which packet are buffered instead of being delivered to the 
+ * Sets the time interval for which packet are buffered instead of being delivered to the
  * application.
  **/
 void
diff --git a/src/logging.c b/src/logging.c
index 586f875..abec6f1 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -1,20 +1,20 @@
 /*
-  The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
-  Copyright (C) 2001  Simon MORLAT simon.morlat at linphone.org
-
-  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
+The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
+Copyright (C) 2001  Simon MORLAT simon.morlat at linphone.org
+
+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
 */
 
 #ifdef HAVE_CONFIG_H
@@ -25,74 +25,152 @@
 #include "utils.h"
 #include <time.h>
 
-static FILE *__log_file=0;
-static unsigned long __log_thread_id = 0;
-static OList *__log_stored_messages_list = NULL;
-static ortp_mutex_t __log_stored_messages_mutex;
+
+typedef struct{
+	char *domain;
+	unsigned int logmask;
+}OrtpLogDomain;
+
+static void ortp_log_domain_destroy(OrtpLogDomain *obj){
+	if (obj->domain) ortp_free(obj->domain);
+	ortp_free(obj);
+}
+
+typedef struct _OrtpLogger{
+	OrtpLogFunc logv_out;
+	unsigned int log_mask; /*the default log mask, if no per-domain settings are found*/
+	FILE *log_file;
+	unsigned long log_thread_id;
+	OList *log_stored_messages_list;
+	OList *log_domains;
+	ortp_mutex_t log_stored_messages_mutex;
+	ortp_mutex_t domains_mutex;
+}OrtpLogger;
+
+
+static OrtpLogger __ortp_logger = { &ortp_logv_out, ORTP_WARNING|ORTP_ERROR|ORTP_FATAL, 0};
+
+void ortp_init_logger(void){
+	ortp_mutex_init(&__ortp_logger.domains_mutex, NULL);
+}
+
+void ortp_uninit_logger(void){
+	ortp_mutex_destroy(&__ortp_logger.domains_mutex);
+	__ortp_logger.log_domains = o_list_free_with_data(__ortp_logger.log_domains, (void (*)(void*))ortp_log_domain_destroy);
+}
 
 /**
- *@param file a FILE pointer where to output the ortp logs.
- *
+*@param file a FILE pointer where to output the ortp logs.
+*
 **/
 void ortp_set_log_file(FILE *file)
 {
-	__log_file=file;
+	__ortp_logger.log_file=file;
 }
 
-static void __ortp_logv_out(OrtpLogLevel lev, const char *fmt, va_list args);
-
-OrtpLogFunc ortp_logv_out=__ortp_logv_out;
-
 /**
- *@param func: your logging function, compatible with the OrtpLogFunc prototype.
- *
+*@param func: your logging function, compatible with the OrtpLogFunc prototype.
+*
 **/
 void ortp_set_log_handler(OrtpLogFunc func){
-	ortp_logv_out=func;
+	__ortp_logger.logv_out=func;
 }
-OrtpLogFunc ortp_get_log_handler(){
-	return ortp_logv_out;
+
+OrtpLogFunc ortp_get_log_handler(void){
+	return __ortp_logger.logv_out;
 }
 
+static OrtpLogDomain * get_log_domain(const char *domain){
+	OList *it;
 
-static unsigned int __ortp_log_mask=ORTP_WARNING|ORTP_ERROR|ORTP_FATAL;
+	if (domain == NULL) return NULL;
+	for (it = __ortp_logger.log_domains; it != NULL; it = it->next){
+		OrtpLogDomain *ld = (OrtpLogDomain*)it->data;
+		if (ld->domain && strcmp(ld->domain, domain) == 0 ){
+			return ld;
+		}
+	}
+	return NULL;
+}
+
+static OrtpLogDomain *get_log_domain_rw(const char *domain){
+	OrtpLogDomain *ret;
+
+	if (domain == NULL) return NULL;
+	ret = get_log_domain(domain);
+	if (ret) return ret;
+	/*it does not exist, hence create it by taking the mutex*/
+	ortp_mutex_lock(&__ortp_logger.domains_mutex);
+	ret = get_log_domain(domain);
+	if (!ret){
+		ret = ortp_new0(OrtpLogDomain,1);
+		ret->domain = ortp_strdup(domain);
+		ret->logmask = __ortp_logger.log_mask;
+		__ortp_logger.log_domains = o_list_prepend(__ortp_logger.log_domains, ret);
+	}
+	ortp_mutex_unlock(&__ortp_logger.domains_mutex);
+	return ret;
+}
 
 /**
- * @ param levelmask a mask of ORTP_DEBUG, ORTP_MESSAGE, ORTP_WARNING, ORTP_ERROR
- * ORTP_FATAL .
+* @ param levelmask a mask of ORTP_DEBUG, ORTP_MESSAGE, ORTP_WARNING, ORTP_ERROR
+* ORTP_FATAL .
 **/
-void ortp_set_log_level_mask(int levelmask){
-	__ortp_log_mask=levelmask;
+void ortp_set_log_level_mask(const char *domain, int levelmask){
+	if (domain == NULL) __ortp_logger.log_mask=levelmask;
+	else get_log_domain_rw(domain)->logmask = levelmask;
+}
+
+
+void ortp_set_log_level(const char *domain, OrtpLogLevel level){
+	int levelmask = ORTP_FATAL;
+	if (level<=ORTP_ERROR){
+		levelmask |= ORTP_ERROR;
+	}
+	if (level<=ORTP_WARNING){
+		levelmask |= ORTP_WARNING;
+	}
+	if (level<=ORTP_MESSAGE){
+		levelmask |= ORTP_MESSAGE;
+	}
+	if (level<=ORTP_TRACE){
+		levelmask |= ORTP_TRACE;
+	}
+	if (level<=ORTP_DEBUG){
+		levelmask |= ORTP_DEBUG;
+	}
+	ortp_set_log_level_mask(domain, levelmask);
 }
 
-int ortp_get_log_level_mask(void) {
-	return __ortp_log_mask;
+unsigned int ortp_get_log_level_mask(const char *domain) {
+	OrtpLogDomain *ld;
+	if (domain == NULL || (ld = get_log_domain(domain)) == NULL) return __ortp_logger.log_mask;
+	else return ld->logmask;
 }
 
 void ortp_set_log_thread_id(unsigned long thread_id) {
 	if (thread_id == 0) {
 		ortp_logv_flush();
-		ortp_mutex_destroy(&__log_stored_messages_mutex);
+		ortp_mutex_destroy(&__ortp_logger.log_stored_messages_mutex);
 	} else {
-		ortp_mutex_init(&__log_stored_messages_mutex, NULL);
+		ortp_mutex_init(&__ortp_logger.log_stored_messages_mutex, NULL);
 	}
-	__log_thread_id = thread_id;
+	__ortp_logger.log_thread_id = thread_id;
 }
 
 char * ortp_strdup_vprintf(const char *fmt, va_list ap)
 {
-	/* Guess we need no more than 100 bytes. */
+/* Guess we need no more than 100 bytes. */
 	int n, size = 200;
 	char *p,*np;
-#ifndef WIN32
+#ifndef _WIN32
 	va_list cap;/*copy of our argument list: a va_list cannot be re-used (SIGSEGV on linux 64 bits)*/
 #endif
 	if ((p = (char *) ortp_malloc (size)) == NULL)
 		return NULL;
-	while (1)
-	{
-		/* Try to print in the allocated space. */
-#ifndef WIN32
+	while (1){
+/* Try to print in the allocated space. */
+#ifndef _WIN32
 		va_copy(cap,ap);
 		n = vsnprintf (p, size, fmt, cap);
 		va_end(cap);
@@ -103,21 +181,19 @@ char * ortp_strdup_vprintf(const char *fmt, va_list ap)
 		/* If that worked, return the string. */
 		if (n > -1 && n < size)
 			return p;
-		//printf("Reallocing space.\n");
+//printf("Reallocing space.\n");
 		/* Else try again with more space. */
 		if (n > -1)	/* glibc 2.1 */
 			size = n + 1;	/* precisely what is needed */
 		else		/* glibc 2.0 */
 			size *= 2;	/* twice the old size */
 		if ((np = (char *) ortp_realloc (p, size)) == NULL)
-		  {
+		{
 			free(p);
 			return NULL;
-		  }
-		else
-		  {
+		} else {
 			p = np;
-		  }
+		}
 	}
 }
 
@@ -132,9 +208,11 @@ char *ortp_strdup_printf(const char *fmt,...){
 
 char * ortp_strcat_vprintf(char* dst, const char *fmt, va_list ap){
 	char *ret;
-	unsigned long dstlen, retlen;
+	size_t dstlen, retlen;
 
 	ret=ortp_strdup_vprintf(fmt, ap);
+	if (!dst) return ret;
+
 	dstlen = strlen(dst);
 	retlen = strlen(ret);
 
@@ -158,7 +236,7 @@ char *ortp_strcat_printf(char* dst, const char *fmt,...){
 	return ret;
 }
 
-#if	defined(WIN32) || defined(_WIN32_WCE)
+#if	defined(_WIN32) || defined(_WIN32_WCE)
 #define ENDLINE "\r\n"
 #else
 #define ENDLINE "\n"
@@ -167,6 +245,7 @@ char *ortp_strcat_printf(char* dst, const char *fmt,...){
 typedef struct {
 	int level;
 	char *msg;
+	char *domain;
 } ortp_stored_log_t;
 
 void _ortp_logv_flush(int dummy, ...) {
@@ -174,20 +253,21 @@ void _ortp_logv_flush(int dummy, ...) {
 	OList *msglist;
 	va_list empty_va_list;
 	va_start(empty_va_list, dummy);
-	ortp_mutex_lock(&__log_stored_messages_mutex);
-	msglist = __log_stored_messages_list;
-	__log_stored_messages_list = NULL;
-	ortp_mutex_unlock(&__log_stored_messages_mutex);
+	ortp_mutex_lock(&__ortp_logger.log_stored_messages_mutex);
+	msglist = __ortp_logger.log_stored_messages_list;
+	__ortp_logger.log_stored_messages_list = NULL;
+	ortp_mutex_unlock(&__ortp_logger.log_stored_messages_mutex);
 	for (elem = msglist; elem != NULL; elem = o_list_next(elem)) {
 		ortp_stored_log_t *l = (ortp_stored_log_t *)elem->data;
-#ifdef WIN32
-		ortp_logv_out(l->level, l->msg, empty_va_list);
+#ifdef _WIN32
+		__ortp_logger.logv_out(l->domain, l->level, l->msg, empty_va_list);
 #else
 		va_list cap;
 		va_copy(cap, empty_va_list);
-		ortp_logv_out(l->level, l->msg, cap);
+		__ortp_logger.logv_out(l->domain, l->level, l->msg, cap);
 		va_end(cap);
 #endif
+		if (l->domain) ortp_free(l->domain);
 		ortp_free(l->msg);
 		ortp_free(l);
 	}
@@ -199,85 +279,100 @@ void ortp_logv_flush(void) {
 	_ortp_logv_flush(0);
 }
 
-void ortp_logv(int level, const char *fmt, va_list args) {
-	if ((ortp_logv_out != NULL) && ortp_log_level_enabled(level)) {
-		if (__log_thread_id == 0) {
-			ortp_logv_out(level, fmt, args);
-		} else if (__log_thread_id == ortp_thread_self()) {
+void ortp_logv(const char *domain, OrtpLogLevel level, const char *fmt, va_list args) {
+	if ((__ortp_logger.logv_out != NULL) && ortp_log_level_enabled(domain, level)) {
+		if (__ortp_logger.log_thread_id == 0) {
+			__ortp_logger.logv_out(domain, level, fmt, args);
+		} else if (__ortp_logger.log_thread_id == ortp_thread_self()) {
 			ortp_logv_flush();
-			ortp_logv_out(level, fmt, args);
+			__ortp_logger.logv_out(domain, level, fmt, args);
 		} else {
 			ortp_stored_log_t *l = ortp_new(ortp_stored_log_t, 1);
+			l->domain = domain ? ortp_strdup(domain) : NULL;
 			l->level = level;
 			l->msg = ortp_strdup_vprintf(fmt, args);
-			ortp_mutex_lock(&__log_stored_messages_mutex);
-			__log_stored_messages_list = o_list_append(__log_stored_messages_list, l);
-			ortp_mutex_unlock(&__log_stored_messages_mutex);
+			ortp_mutex_lock(&__ortp_logger.log_stored_messages_mutex);
+			__ortp_logger.log_stored_messages_list = o_list_append(__ortp_logger.log_stored_messages_list, l);
+			ortp_mutex_unlock(&__ortp_logger.log_stored_messages_mutex);
 		}
 	}
 #if !defined(_WIN32_WCE)
-	if (level == ORTP_FATAL) abort();
+	if (level == ORTP_FATAL) {
+		ortp_logv_flush();
+		abort();
+	}
 #endif
 }
 
-static void __ortp_logv_out(OrtpLogLevel lev, const char *fmt, va_list args){
+/*This function does the default formatting and output to file*/
+void ortp_logv_out(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args){
 	const char *lname="undef";
 	char *msg;
 	struct timeval tp;
 	struct tm *lt;
-#ifndef WIN32
+#ifndef _WIN32
 	struct tm tmbuf;
 #endif
 	time_t tt;
 	ortp_gettimeofday(&tp,NULL);
 	tt = (time_t)tp.tv_sec;
 
-#ifdef WIN32
+#ifdef _WIN32
 	lt = localtime(&tt);
 #else
 	lt = localtime_r(&tt,&tmbuf);
 #endif
 
-	if (__log_file==NULL) __log_file=stderr;
+	if (__ortp_logger.log_file==NULL) __ortp_logger.log_file=stderr;
 	switch(lev){
 		case ORTP_DEBUG:
-			lname="debug";
-			break;
+			lname = "debug";
+		break;
 		case ORTP_MESSAGE:
-			lname="message";
-			break;
+			lname = "message";
+		break;
 		case ORTP_WARNING:
-			lname="warning";
-			break;
+			lname = "warning";
+		break;
 		case ORTP_ERROR:
-			lname="error";
-			break;
+			lname = "error";
+		break;
 		case ORTP_FATAL:
-			lname="fatal";
-			break;
+			lname = "fatal";
+		break;
 		default:
-			ortp_fatal("Bad level !");
+			lname = "badlevel";
 	}
+
 	msg=ortp_strdup_vprintf(fmt,args);
 #if defined(_MSC_VER) && !defined(_WIN32_WCE)
-	#ifndef _UNICODE
-		OutputDebugStringA(msg);
-		OutputDebugStringA("\r\n");
-	#else
-		{
-			int len=strlen(msg);
-			wchar_t *tmp=(wchar_t*)ortp_malloc0((len+1)*sizeof(wchar_t));
-			mbstowcs(tmp,msg,len);
-			OutputDebugStringW(tmp);
-			OutputDebugStringW(L"\r\n");
-			ortp_free(tmp);
-		}
-	#endif
+#ifndef _UNICODE
+	OutputDebugStringA(msg);
+	OutputDebugStringA("\r\n");
+#else
+	{
+		size_t len=strlen(msg);
+		wchar_t *tmp=(wchar_t*)ortp_malloc0((len+1)*sizeof(wchar_t));
+		mbstowcs(tmp,msg,len);
+		OutputDebugStringW(tmp);
+		OutputDebugStringW(L"\r\n");
+		ortp_free(tmp);
+	}
 #endif
-	fprintf(__log_file,"%i-%.2i-%.2i %.2i:%.2i:%.2i:%.3i ortp-%s-%s" ENDLINE
+#endif
+	fprintf(__ortp_logger.log_file,"%i-%.2i-%.2i %.2i:%.2i:%.2i:%.3i ortp-%s-%s" ENDLINE
+		,1900+lt->tm_year,1+lt->tm_mon,lt->tm_mday,lt->tm_hour,lt->tm_min,lt->tm_sec
+		,(int)(tp.tv_usec/1000), lname, msg);
+	fflush(__ortp_logger.log_file);
+
+	// fatal messages should go to stderr too, even if we are using a file since application will abort right after
+	if (__ortp_logger.log_file != stderr && lev == ORTP_FATAL) {
+		fprintf(stderr,"%i-%.2i-%.2i %.2i:%.2i:%.2i:%.3i ortp-%s-%s" ENDLINE
 			,1900+lt->tm_year,1+lt->tm_mon,lt->tm_mday,lt->tm_hour,lt->tm_min,lt->tm_sec
-			,(int)(tp.tv_usec/1000), lname,msg);
-	fflush(__log_file);
+			,(int)(tp.tv_usec/1000), lname, msg);
+		fflush(stderr);
+	}
+
 	ortp_free(msg);
 }
 
@@ -292,6 +387,7 @@ static slog2_buffer_t slog2_buffer_handle[2];
 void ortp_qnx_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args) {
 	uint8_t severity = SLOG2_DEBUG1;
 	uint8_t buffer_idx = 1;
+	char* msg;
 
 	if (slog2_registered != TRUE) {
 		slog2_buffer_config.buffer_set_name = domain;
@@ -309,28 +405,27 @@ void ortp_qnx_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt,
 		}
 	}
 
-	switch (lev) {
+	switch(lev){
 		case ORTP_DEBUG:
 			severity = SLOG2_DEBUG1;
-			buffer_idx = 0;
-			break;
+		break;
 		case ORTP_MESSAGE:
 			severity = SLOG2_INFO;
-			buffer_idx = 0;
-			break;
+		break;
 		case ORTP_WARNING:
 			severity = SLOG2_WARNING;
-			break;
+		break;
 		case ORTP_ERROR:
 			severity = SLOG2_ERROR;
-			break;
+		break;
 		case ORTP_FATAL:
 			severity = SLOG2_CRITICAL;
-			break;
+		break;
 		default:
-			ortp_fatal("Bad level!");
+			severity = SLOG2_CRITICAL;
 	}
 
-	vslog2f(slog2_buffer_handle[buffer_idx], 0, severity, fmt, args);
+	msg = ortp_strdup_vprintf(fmt,args);
+	slog2c(slog2_buffer_handle[buffer_idx], 0, severity, msg);
 }
 #endif /* __QNX__ */
diff --git a/src/netsim.c b/src/netsim.c
index ed87dd7..109be5a 100644
--- a/src/netsim.c
+++ b/src/netsim.c
@@ -57,7 +57,7 @@ void ortp_network_simulator_destroy(OrtpNetworkSimulatorCtx *sim){
 	ortp_free(sim);
 }
 
-#ifndef WIN32
+#ifndef _WIN32
 static const char *sched_policy_to_string(int policy){
 	switch(policy){
 		case SCHED_OTHER: return "SCHED_OTHER";
@@ -68,15 +68,15 @@ static const char *sched_policy_to_string(int policy){
 }
 #endif
 
-static void set_high_prio(){
-#ifndef WIN32
+static void set_high_prio(void){
+#ifndef _WIN32
 	const char *sched_pref=getenv("ORTP_SIMULATOR_SCHED_POLICY");
 	int policy=SCHED_OTHER;
 	struct sched_param param;
 	int result=0;
 	char* env_prio_c=NULL;
 	int min_prio, max_prio, env_prio;
-		
+
 	if (sched_pref && strcasecmp(sched_pref,"SCHED_RR")==0){
 		policy=SCHED_RR;
 	}else if (sched_pref && strcasecmp(sched_pref,"SCHED_FIFO")==0){
@@ -108,7 +108,7 @@ static void * outboud_simulator_thread(void *ctx){
 	OrtpNetworkSimulatorCtx *sim=session->net_sim_ctx;
 	ortpTimeSpec sleep_until;
 	set_high_prio();
-	
+
 	while(sim->thread_started){
 		sleep_until.tv_sec=0;
 		sleep_until.tv_nsec=0;
@@ -156,11 +156,11 @@ void rtp_session_enable_network_simulation(RtpSession *session, const OrtpNetwor
 			sim->params.max_buffer_size=sim->params.max_bandwidth;
 			ortp_message("Network simulation: Max buffer size not set for RTP session [%p], using [%i]",session,sim->params.max_buffer_size);
 		}
+		session->net_sim_ctx=sim;
 		if ((params->mode==OrtpNetworkSimulatorOutbound || params->mode==OrtpNetworkSimulatorOutboundControlled) && !sim->thread_started){
 			sim->thread_started=TRUE;
 			ortp_thread_create(&sim->thread, NULL, outboud_simulator_thread, session);
 		}
-		session->net_sim_ctx=sim;
 
 		ortp_message("Network simulation: enabled with the following parameters:\n"
 				"\tlatency=%d\n"
@@ -182,6 +182,7 @@ void rtp_session_enable_network_simulation(RtpSession *session, const OrtpNetwor
     			);
 	}else{
 		session->net_sim_ctx=NULL;
+		ortp_message("rtp_session_enable_network_simulation:DISABLING NETWORK SIMULATION");
 		if (sim!=NULL) ortp_network_simulator_destroy(sim);
 	}
 }
@@ -272,7 +273,7 @@ static mblk_t *simulate_bandwidth_limit_and_jitter(RtpSession *session, mblk_t *
 	/* queue the packet for sending*/
 	if (input){
 		putq(&sim->q,input);
-		bits=(msgdsize(input)+overhead)*8;
+		bits=((int)msgdsize(input)+overhead)*8;
 		sim->qsize+=bits;
 	}
 	/*flow control*/
@@ -280,7 +281,7 @@ static mblk_t *simulate_bandwidth_limit_and_jitter(RtpSession *session, mblk_t *
 		// ortp_message("rtp_session_network_simulate(): discarding packets.");
 		output=getq(&sim->q);
 		if (output){
-			bits=(msgdsize(output)+overhead)*8;
+			bits=((int)msgdsize(output)+overhead)*8;
 			sim->qsize-=bits;
 			sim->drop_by_congestion++;
 			freemsg(output);
@@ -293,7 +294,7 @@ static mblk_t *simulate_bandwidth_limit_and_jitter(RtpSession *session, mblk_t *
 	if (sim->bit_budget>=0){
 		output=getq(&sim->q);
 		if (output){
-			bits=(msgdsize(output)+overhead)*8;
+			bits=((int)msgdsize(output)+overhead)*8;
 			sim->bit_budget-=bits;
 			sim->qsize-=bits;
 		}
@@ -352,12 +353,20 @@ mblk_t * rtp_session_network_simulate(RtpSession *session, mblk_t *input, bool_t
 		om=simulate_latency(session,om);
 	}
 
+	if ((sim->params.loss_rate > 0) && (om != NULL)) {
+		if (sim->params.RTP_only == TRUE) {
+			if (*is_rtp_packet == TRUE) {
+				om = simulate_loss_rate(sim, om);
+			}
+		} else {
+			om = simulate_loss_rate(sim, om);
+		}
+	}
+
 	if (sim->params.max_bandwidth>0){
 		om=simulate_bandwidth_limit_and_jitter(session,om);
 	}
-	if (sim->params.loss_rate>0 && om){
-		om=simulate_loss_rate(sim,om);
-	}
+
 	/*finally when releasing the packet from the simulator, reset the reserved1 space to default,
 	since it will be used by mediastreamer later*/
 	if (om != NULL){
@@ -367,17 +376,57 @@ mblk_t * rtp_session_network_simulate(RtpSession *session, mblk_t *input, bool_t
 	return om;
 }
 
+/*compares two ortpTimeSpec s1 and s2.
+ * returns a negative value if s1 is earlier than s2, 0 if they are equal, a positive value if s1 is later than s2*/
+int ortp_timespec_compare(const ortpTimeSpec *s1, const ortpTimeSpec *s2){
+	int64_t secdiff = s1->tv_sec - s2->tv_sec;
+	if (secdiff == 0){
+		int64_t nsec_diff = s1->tv_nsec - s2->tv_nsec;
+		if (nsec_diff < 0){
+			return -1;
+		}else if (nsec_diff > 0){
+			return 1;
+		}else return 0;
+	}else if (secdiff < 0){
+		return -1;
+	}else
+		return 1;
+}
+
+#if defined(ORTP_TIMESTAMP)
+static mblk_t * rtp_session_netsim_find_next_packet_to_send(RtpSession *session){
+	mblk_t *om;
+	ortpTimeSpec min_packet_time = { 0, 0};
+	ortpTimeSpec packet_time;
+	mblk_t *next_packet = NULL;
+
+	for(om = qbegin(&session->net_sim_ctx->send_q); !qend(&session->net_sim_ctx->send_q, om); om = qnext(&session->net_sim_ctx->send_q, om)){
+		packet_time.tv_sec=om->timestamp.tv_sec;
+		packet_time.tv_nsec=om->timestamp.tv_usec*1000LL;
+		if (packet_time.tv_sec == 0 && packet_time.tv_nsec == 0){
+			/*this is a packet to drop*/
+			return om;
+		}
+		if (min_packet_time.tv_sec == 0 || ortp_timespec_compare(&packet_time, &min_packet_time) < 0){
+			min_packet_time = packet_time;
+			next_packet = om;
+		}
+	}
+	return next_packet;
+}
+#endif
+
 static void rtp_session_schedule_outbound_network_simulator(RtpSession *session, ortpTimeSpec *sleep_until){
 	mblk_t *om;
 	int count=0;
 	bool_t is_rtp_packet;
-	
+
 	if (!session->net_sim_ctx)
 		return;
-	
+
 	if (!session->net_sim_ctx->params.enabled)
 		return;
-	
+
 	if (session->net_sim_ctx->params.mode==OrtpNetworkSimulatorOutbound){
 		sleep_until->tv_sec=0;
 		sleep_until->tv_nsec=0;
@@ -385,10 +434,10 @@ static void rtp_session_schedule_outbound_network_simulator(RtpSession *session,
 		while((om=getq(&session->net_sim_ctx->send_q))!=NULL){
 			count++;
 			ortp_mutex_unlock(&session->net_sim_ctx->mutex);
-			is_rtp_packet=om->reserved1; /*it was set by _rtp_session_sendto()*/
+			is_rtp_packet=om->reserved1; /*it was set by rtp_session_sendto()*/
 			om=rtp_session_network_simulate(session,om, &is_rtp_packet);
 			if (om){
-				_ortp_sendto(is_rtp_packet ? session->rtp.gs.socket : session->rtcp.gs.socket, om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
+				_ortp_sendto(rtp_session_get_socket(session, is_rtp_packet), om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
 				freemsg(om);
 			}
 			ortp_mutex_lock(&session->net_sim_ctx->mutex);
@@ -399,7 +448,7 @@ static void rtp_session_schedule_outbound_network_simulator(RtpSession *session,
 			is_rtp_packet=TRUE;
 			om=rtp_session_network_simulate(session,NULL, &is_rtp_packet);
 			if (om){
-				_ortp_sendto(is_rtp_packet ? session->rtp.gs.socket : session->rtcp.gs.socket, om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
+				_ortp_sendto(rtp_session_get_socket(session, is_rtp_packet), om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
 				freemsg(om);
 			}
 		}
@@ -408,30 +457,32 @@ static void rtp_session_schedule_outbound_network_simulator(RtpSession *session,
 		ortpTimeSpec current={0};
 		ortpTimeSpec packet_time;
 		mblk_t *todrop=NULL;
+
 		ortp_mutex_lock(&session->net_sim_ctx->mutex);
-		while((om=peekq(&session->net_sim_ctx->send_q))!=NULL){
+		while((om = rtp_session_netsim_find_next_packet_to_send(session)) != NULL){
 			ortp_mutex_unlock(&session->net_sim_ctx->mutex);
 			if (todrop) {
 				freemsg(todrop); /*free the last message while the mutex is not held*/
-				todrop=NULL;
+				todrop = NULL;
 			}
 			_ortp_get_cur_time(&current,TRUE);
 			packet_time.tv_sec=om->timestamp.tv_sec;
 			packet_time.tv_nsec=om->timestamp.tv_usec*1000LL;
 			if (om->timestamp.tv_sec==0 && om->timestamp.tv_usec==0){
-				todrop=om; /*simulate a packet loss*/
-			}else if (packet_time.tv_sec<=current.tv_sec && packet_time.tv_nsec<=current.tv_nsec){
-				is_rtp_packet=om->reserved1; /*it was set by _rtp_session_sendto()*/
+				todrop = om; /*simulate a packet loss*/
+			}else if (ortp_timespec_compare(&packet_time, &current) <= 0){
+				/*it is time to send this packet*/
+				is_rtp_packet=om->reserved1; /*it was set by rtp_session_sendto()*/
 				_ortp_sendto(is_rtp_packet ? session->rtp.gs.socket : session->rtcp.gs.socket, om, 0, (struct sockaddr*)&om->net_addr, om->net_addrlen);
-				todrop=om;
+				todrop = om;
 			}else {
 				/*no packet is to be sent yet; set the time at which we want to be called*/
 				*sleep_until=packet_time;
 				ortp_mutex_lock(&session->net_sim_ctx->mutex);
-				break; 
+				break;
 			}
 			ortp_mutex_lock(&session->net_sim_ctx->mutex);
-			if (todrop) getq(&session->net_sim_ctx->send_q); /* pop the message while the mutex is held*/
+			if (todrop) remq(&session->net_sim_ctx->send_q, todrop); /* remove the message while the mutex is held*/
 		}
 		ortp_mutex_unlock(&session->net_sim_ctx->mutex);
 		if (todrop) freemsg(todrop);
@@ -441,7 +492,6 @@ static void rtp_session_schedule_outbound_network_simulator(RtpSession *session,
 			sleep_until->tv_sec=current.tv_sec;
 			sleep_until->tv_nsec=current.tv_nsec+1000000LL; /*in 1 ms*/
 		}
-		
 #else
 		ortp_mutex_lock(&session->net_sim_ctx->mutex);
 		while((om=getq(&session->net_sim_ctx->send_q))!=NULL){
diff --git a/src/ortp.c b/src/ortp.c
index f82f429..0360ca0 100644
--- a/src/ortp.c
+++ b/src/ortp.c
@@ -22,6 +22,7 @@
 #include "ortp-config.h"
 #endif
 #include "ortp/ortp.h"
+#include "utils.h"
 #include <inttypes.h>
 #include "scheduler.h"
 
@@ -37,8 +38,8 @@ RtpScheduler *__ortp_scheduler;
 
 extern void av_profile_init(RtpProfile *profile);
 
-static void init_random_number_generator(){
-#ifndef WIN32
+static void init_random_number_generator(void){
+#ifndef _WIN32
 	struct timeval t;
 	ortp_gettimeofday(&t,NULL);
 	srandom(t.tv_usec+t.tv_sec);
@@ -47,7 +48,7 @@ static void init_random_number_generator(){
 }
 
 
-#ifdef WIN32
+#ifdef _WIN32
 static bool_t win32_init_sockets(void){
 	WORD wVersionRequested;
 	WSADATA wsaData;
@@ -73,10 +74,10 @@ void ortp_init()
 {
 	if (ortp_initialized++) return;
 
-#ifdef WIN32
+#ifdef _WIN32
 	win32_init_sockets();
 #endif
-
+	ortp_init_logger();
 	av_profile_init(&av_profile);
 	ortp_global_stats_reset();
 	init_random_number_generator();
@@ -87,7 +88,7 @@ void ortp_init()
 
 /**
  *	Initialize the oRTP scheduler. You only have to do that if you intend to use the
- *	scheduled mode of the #RtpSession in your application.
+ *	scheduled mode of the RtpSession in your application.
  *
 **/
 void ortp_scheduler_init()
@@ -127,6 +128,7 @@ void ortp_exit()
 			rtp_scheduler_destroy(__ortp_scheduler);
 			__ortp_scheduler=NULL;
 		}
+		ortp_uninit_logger();
 	}
 }
 
@@ -167,6 +169,8 @@ void rtp_stats_display(const rtp_stats_t *stats, const char *header) {
 	ortp_log(ORTP_MESSAGE, "incoming received too late           %10"PRId64" packets", stats->outoftime);
 	ortp_log(ORTP_MESSAGE, "incoming bad formatted               %10"PRId64" packets", stats->bad);
 	ortp_log(ORTP_MESSAGE, "incoming discarded (queue overflow)  %10"PRId64" packets", stats->discarded);
+	ortp_log(ORTP_MESSAGE, "sent rtcp                            %10"PRId64" packets", stats->sent_rtcp_packets);
+	ortp_log(ORTP_MESSAGE, "received rtcp                        %10"PRId64" packets", stats->recv_rtcp_packets);
 	ortp_log(ORTP_MESSAGE, "===========================================================");
 }
 
diff --git a/src/payloadtype.c b/src/payloadtype.c
index a630a7d..483c88a 100644
--- a/src/payloadtype.c
+++ b/src/payloadtype.c
@@ -189,7 +189,7 @@ bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, si
 			int copied;
 			const char *end=strchr(equal+1,';');
 			if (end==NULL) end=fmtp+strlen(fmtp); /*assuming this is the last param */
-			copied=MIN(result_len-1,end-(equal+1));
+			copied=MIN((int)(result_len-1),(int)(end-(equal+1)));
 			strncpy(result,equal+1,copied);
 			result[copied]='\0';
 			return TRUE;
diff --git a/src/port.c b/src/port.c
index d3d1c08..a3d3256 100644
--- a/src/port.c
+++ b/src/port.c
@@ -201,7 +201,7 @@ unsigned long __ortp_thread_self(void) {
 
 int WIN_mutex_init(ortp_mutex_t *mutex, void *attr)
 {
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	*mutex=CreateMutex(NULL, FALSE, NULL);
 #else
 	InitializeSRWLock(mutex);
@@ -211,7 +211,7 @@ int WIN_mutex_init(ortp_mutex_t *mutex, void *attr)
 
 int WIN_mutex_lock(ortp_mutex_t * hMutex)
 {
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	WaitForSingleObject(*hMutex, INFINITE); /* == WAIT_TIMEOUT; */
 #else
 	AcquireSRWLockExclusive(hMutex);
@@ -221,7 +221,7 @@ int WIN_mutex_lock(ortp_mutex_t * hMutex)
 
 int WIN_mutex_unlock(ortp_mutex_t * hMutex)
 {
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	ReleaseMutex(*hMutex);
 #else
 	ReleaseSRWLockExclusive(hMutex);
@@ -231,7 +231,7 @@ int WIN_mutex_unlock(ortp_mutex_t * hMutex)
 
 int WIN_mutex_destroy(ortp_mutex_t * hMutex)
 {
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	CloseHandle(*hMutex);
 #endif
 	return 0;
@@ -244,9 +244,9 @@ typedef struct thread_param{
 
 static unsigned WINAPI thread_starter(void *data){
 	thread_param_t *params=(thread_param_t*)data;
-	void *ret=params->func(params->arg);
+	params->func(params->arg);
 	ortp_free(data);
-	return (DWORD)ret;
+	return 0;
 }
 
 #if defined _WIN32_WCE
@@ -279,7 +279,7 @@ unsigned long WIN_thread_self(void) {
 
 int WIN_cond_init(ortp_cond_t *cond, void *attr)
 {
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	*cond=CreateEvent(NULL, FALSE, FALSE, NULL);
 #else
 	InitializeConditionVariable(cond);
@@ -289,7 +289,7 @@ int WIN_cond_init(ortp_cond_t *cond, void *attr)
 
 int WIN_cond_wait(ortp_cond_t* hCond, ortp_mutex_t * hMutex)
 {
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	//gulp: this is not very atomic ! bug here ?
 	WIN_mutex_unlock(hMutex);
 	WaitForSingleObject(*hCond, INFINITE);
@@ -302,7 +302,7 @@ int WIN_cond_wait(ortp_cond_t* hCond, ortp_mutex_t * hMutex)
 
 int WIN_cond_signal(ortp_cond_t * hCond)
 {
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	SetEvent(*hCond);
 #else
 	WakeConditionVariable(hCond);
@@ -318,7 +318,7 @@ int WIN_cond_broadcast(ortp_cond_t * hCond)
 
 int WIN_cond_destroy(ortp_cond_t * hCond)
 {
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	CloseHandle(*hCond);
 #endif
 	return 0;
@@ -400,7 +400,7 @@ char * WSAAPI gai_strerror(int errnum){
 
 #endif
 
-#ifndef WIN32
+#ifndef _WIN32
 
 #include <sys/socket.h>
 #include <netdb.h>
@@ -514,7 +514,7 @@ void ortp_shm_close(void *mem){
 
 #endif
 
-#elif defined(WIN32) && !defined(_WIN32_WCE)
+#elif defined(_WIN32) && !defined(_WIN32_WCE)
 
 static char *make_pipe_name(const char *name){
 	return ortp_strdup_printf("\\\\.\\pipe\\%s",name);
@@ -524,7 +524,7 @@ static HANDLE event=NULL;
 
 /* portable named pipes */
 ortp_pipe_t ortp_server_pipe_create(const char *name){
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	ortp_pipe_t h;
 	char *pipename=make_pipe_name(name);
 	h=CreateNamedPipe(pipename,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_MESSAGE|PIPE_WAIT,1,
@@ -547,7 +547,7 @@ even if nobody connects to the pipe.
 ortp_server_pipe_close() makes this function to exit.
 */
 ortp_pipe_t ortp_server_pipe_accept_client(ortp_pipe_t server){
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	OVERLAPPED ol;
 	DWORD undef;
 	HANDLE handles[2];
@@ -570,7 +570,7 @@ ortp_pipe_t ortp_server_pipe_accept_client(ortp_pipe_t server){
 }
 
 int ortp_server_pipe_close_client(ortp_pipe_t server){
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	return DisconnectNamedPipe(server)==TRUE ? 0 : -1;
 #else
 	ortp_error("%s not supported!", __FUNCTION__);
@@ -579,7 +579,7 @@ int ortp_server_pipe_close_client(ortp_pipe_t server){
 }
 
 int ortp_server_pipe_close(ortp_pipe_t spipe){
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	SetEvent(event);
 	//CancelIoEx(spipe,NULL); /*vista only*/
 	return CloseHandle(spipe);
@@ -590,7 +590,7 @@ int ortp_server_pipe_close(ortp_pipe_t spipe){
 }
 
 ortp_pipe_t ortp_client_pipe_connect(const char *name){
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	char *pipename=make_pipe_name(name);
 	ortp_pipe_t hpipe = CreateFile(
 		 pipename,   // pipe name
@@ -639,7 +639,7 @@ typedef struct MapInfo{
 static OList *maplist=NULL;
 
 void *ortp_shm_open(unsigned int keyid, int size, int create){
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	HANDLE h;
 	char name[64];
 	void *buf;
@@ -685,7 +685,7 @@ void *ortp_shm_open(unsigned int keyid, int size, int create){
 }
 
 void ortp_shm_close(void *mem){
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 	OList *elem;
 	for(elem=maplist;elem!=NULL;elem=elem->next){
 		MapInfo *i=(MapInfo*)elem->data;
@@ -713,8 +713,8 @@ void ortp_shm_close(void *mem){
 #endif
 
 void _ortp_get_cur_time(ortpTimeSpec *ret, bool_t realtime){
-#if defined(_WIN32_WCE) || defined(WIN32)
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if defined(_WIN32_WCE) || defined(_WIN32)
+#ifdef ORTP_WINDOWS_DESKTOP
 	DWORD timemillis;
 #	if defined(_WIN32_WCE)
 	timemillis=GetTickCount();
@@ -750,7 +750,7 @@ void _ortp_get_cur_time(ortpTimeSpec *ret, bool_t realtime){
 }
 
 void ortp_get_cur_time(ortpTimeSpec *ret){
-	return _ortp_get_cur_time(ret, FALSE);
+	_ortp_get_cur_time(ret, FALSE);
 }
 
 
@@ -761,8 +761,8 @@ uint64_t ortp_get_cur_time_ms(void) {
 }
 
 void ortp_sleep_ms(int ms){
-#ifdef WIN32
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef _WIN32
+#ifdef ORTP_WINDOWS_DESKTOP
 	Sleep(ms);
 #else
 	HANDLE sleepEvent = CreateEventEx(NULL, NULL, CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
@@ -795,9 +795,9 @@ void ortp_sleep_until(const ortpTimeSpec *ts){
 		diff.tv_nsec+=1000000000LL;
 		diff.tv_sec-=1;
 	}
-#	ifdef WIN32
-		ortp_sleep_ms((diff.tv_sec * 1000LL) + (diff.tv_nsec/1000000LL));
-#	else
+#ifdef _WIN32
+		ortp_sleep_ms((int)((diff.tv_sec * 1000LL) + (diff.tv_nsec/1000000LL)));
+#else
 	{
 		struct timespec dur,rem;
 		dur.tv_sec=diff.tv_sec;
@@ -806,7 +806,7 @@ void ortp_sleep_until(const ortpTimeSpec *ts){
 			dur=rem;
 		};
 	}
-#	endif
+#endif
 #endif
 }
 
@@ -832,12 +832,14 @@ char* strtok_r(char *str, const char *delim, char **nextp){
 #endif
 
 
-#if defined(WIN32) && !defined(_MSC_VER)
+#if defined(_WIN32)
+
+#if !defined(_MSC_VER)
 #include <wincrypt.h>
 static int ortp_wincrypto_random(unsigned int *rand_number){
 	static HCRYPTPROV hProv=(HCRYPTPROV)-1;
 	static int initd=0;
-	
+
 	if (!initd){
 		if (!CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)){
 			ortp_error("ortp_wincrypto_random(): Could not acquire a windows crypto context");
@@ -847,7 +849,7 @@ static int ortp_wincrypto_random(unsigned int *rand_number){
 	}
 	if (hProv==(HCRYPTPROV)-1)
 		return -1;
-	
+
 	if (!CryptGenRandom(hProv,4,(BYTE*)rand_number)){
 		ortp_error("ortp_wincrypto_random(): CryptGenRandom() failed.");
 		return -1;
@@ -855,11 +857,9 @@ static int ortp_wincrypto_random(unsigned int *rand_number){
 	return 0;
 }
 #endif
+#elif defined(__QNXNTO__) || ((defined(__linux) || defined(__APPLE__)) && !defined(HAVE_ARC4RANDOM))
 
-unsigned int ortp_random(void){
-#ifdef HAVE_ARC4RANDOM
-	return arc4random();
-#elif  defined(__linux) || defined(__APPLE__)
+static unsigned int ortp_urandom(void) {
 	static int fd=-1;
 	if (fd==-1) fd=open("/dev/urandom",O_RDONLY);
 	if (fd!=-1){
@@ -867,13 +867,30 @@ unsigned int ortp_random(void){
 		if (read(fd,&tmp,4)!=4){
 			ortp_error("Reading /dev/urandom failed.");
 		}else return tmp;
-	}else ortp_error("Could not open /dev/urandom");
-#elif defined(WIN32)
+	} else ortp_error("Could not open /dev/urandom");
+	return (unsigned int) random();
+}
+
+#endif
+
+
+
+
+unsigned int ortp_random(void){
+#ifdef HAVE_ARC4RANDOM
+#if defined(__QNXNTO__) // There is a false positive with blackberry build
+	return ortp_urandom();
+#else
+	return arc4random();
+#endif
+#elif defined(__linux) || defined(__APPLE__)
+	return ortp_urandom();
+#elif defined(_WIN32)
 	static int initd=0;
 	unsigned int ret;
 #ifdef _MSC_VER
 	/*rand_s() is pretty nice and simple function but is not wrapped by mingw.*/
-	
+
 	if (rand_s(&ret)==0){
 		return ret;
 	}
@@ -892,9 +909,17 @@ unsigned int ortp_random(void){
 	}
 	return rand()<<16 | rand();
 #endif
-	/*fallback to UNIX random()*/
-#ifndef WIN32
-	return (unsigned int) random();
-#endif
 }
 
+bool_t ortp_is_multicast_addr(const struct sockaddr *addr) {
+
+	switch (addr->sa_family) {
+		case AF_INET:
+			return IN_MULTICAST(ntohl(((struct sockaddr_in *) addr)->sin_addr.s_addr));
+		case AF_INET6:
+			return IN6_IS_ADDR_MULTICAST(&(((struct sockaddr_in6 *) addr)->sin6_addr));
+		default:
+			return FALSE;
+	}
+
+}
diff --git a/src/posixtimer.c b/src/posixtimer.c
index 95febb4..713bccc 100644
--- a/src/posixtimer.c
+++ b/src/posixtimer.c
@@ -38,7 +38,7 @@
 static struct timeval orig,cur;
 static uint32_t posix_timer_time=0;		/*in milisecond */
 
-void posix_timer_init()
+void posix_timer_init(void)
 {
 	posix_timer.state=RTP_TIMER_RUNNING;
 	ortp_gettimeofday(&orig,NULL);
@@ -48,7 +48,7 @@ void posix_timer_init()
 
 
 
-void posix_timer_do()
+void posix_timer_do(void)
 {
 	int diff,time;
 	struct timeval tv;
@@ -74,7 +74,7 @@ void posix_timer_do()
 	
 }
 
-void posix_timer_uninit()
+void posix_timer_uninit(void)
 {
 	posix_timer.state=RTP_TIMER_STOPPED;
 }
@@ -86,9 +86,9 @@ RtpTimer posix_timer={	0,
 						{0,POSIXTIMER_INTERVAL}};
 							
 							
-#else //WIN32
+#else //_WIN32
 
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 
 #include <windows.h>
 #include <mmsystem.h>
@@ -172,7 +172,7 @@ RtpTimer posix_timer={	0,
 						win_timer_close,
 						{0,TIME_INTERVAL * 1000}};
 
-#else
+#elif defined(ORTP_WINDOWS_PHONE)
 
 #include "winrttimer.h"
 
diff --git a/src/rtcp.c b/src/rtcp.c
index 058f2d4..fa282d7 100644
--- a/src/rtcp.c
+++ b/src/rtcp.c
@@ -175,12 +175,12 @@ void rtp_session_remove_contributing_source(RtpSession *session, uint32_t ssrc)
 	rtp_session_rtcp_send(session,tmp);
 }
 
-void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, int bytes_len){
+void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, size_t bytes_len){
 	rtcp_common_header_set_version(ch,2);
 	rtcp_common_header_set_padbit(ch,0);
 	rtcp_common_header_set_packet_type(ch,type);
 	rtcp_common_header_set_rc(ch,rc);	/* as we don't yet support multi source receiving */
-	rtcp_common_header_set_length(ch,(bytes_len/4)-1);
+	rtcp_common_header_set_length(ch,(unsigned short)((bytes_len/4)-1));
 }
 
 mblk_t* rtp_session_create_rtcp_sdes_packet(RtpSession *session, bool_t full) {
@@ -221,9 +221,9 @@ static void sender_info_init(sender_info_t *info, RtpSession *session){
 	info->ntp_timestamp_msw=htonl(ntp >>32);
 	info->ntp_timestamp_lsw=htonl(ntp & 0xFFFFFFFF);
 	info->rtp_timestamp=htonl(session->rtp.snd_last_ts);
-	info->senders_packet_count=(uint32_t) htonl((u_long) session->rtp.stats.packet_sent);
+	info->senders_packet_count=(uint32_t) htonl((u_long) session->stats.packet_sent);
 	info->senders_octet_count=(uint32_t) htonl((u_long) session->rtp.sent_payload_bytes);
-	session->rtp.last_rtcp_packet_count=session->rtp.stats.packet_sent;
+	session->rtp.last_rtcp_packet_count=session->stats.packet_sent;
 }
 
 static void report_block_init(report_block_t *b, RtpSession *session){
@@ -242,11 +242,11 @@ static void report_block_init(report_block_t *b, RtpSession *session){
 			packet_loss = session->lost_packets_test_vector;
 			/* The test value is the definite cumulative one, no need to increment
 			it each time a packet is sent */
-			stream->stats.cum_packet_loss = packet_loss;
+			session->stats.cum_packet_loss = packet_loss;
 		}else {
 			/* Normal mode */
 			packet_loss = expected_packets - stream->hwrcv_since_last_SR;
-			stream->stats.cum_packet_loss += packet_loss;
+			session->stats.cum_packet_loss += packet_loss;
 		}
 		if (expected_packets>0){/*prevent division by zero and negative loss fraction*/
 			loss_fraction=(int)( 256 * packet_loss) / expected_packets;
@@ -267,7 +267,7 @@ static void report_block_init(report_block_t *b, RtpSession *session){
 		, stream->hwrcv_extseq - stream->hwrcv_seq_at_last_SR, stream->hwrcv_extseq, stream->hwrcv_seq_at_last_SR
 		, stream->hwrcv_since_last_SR
 		, packet_loss
-		, (long)stream->stats.cum_packet_loss
+		, (long)session->stats.cum_packet_loss
 		, loss_fraction/2.56
 	);
 
@@ -287,7 +287,7 @@ static void report_block_init(report_block_t *b, RtpSession *session){
 	b->ssrc=htonl(session->rcv.ssrc);
 
 
-	report_block_set_cum_packet_lost(b, stream->stats.cum_packet_loss);
+	report_block_set_cum_packet_lost(b, session->stats.cum_packet_loss);
 	report_block_set_fraction_lost(b, loss_fraction);
 
 	if ( session->flags & RTCP_OVERRIDE_JITTER ) {
@@ -322,7 +322,7 @@ static void report_block_init(report_block_t *b, RtpSession *session){
 static void extended_statistics( RtpSession *session, report_block_t * rb ) {
 	/* the jitter raw value is kept in stream clock units */
 	uint32_t jitter = session->rtp.jittctl.inter_jitter;
-	session->rtp.stats.sent_rtcp_packets ++;
+	session->stats.sent_rtcp_packets ++;
 	session->rtp.jitter_stats.sum_jitter += jitter;
 	session->rtp.jitter_stats.jitter=jitter;
 	/* stores the biggest jitter for that session and its date (in millisecond) since Epoch */
@@ -340,7 +340,7 @@ static void extended_statistics( RtpSession *session, report_block_t * rb ) {
 
 static int rtcp_sr_init(RtpSession *session, uint8_t *buf, int size){
 	rtcp_sr_t *sr=(rtcp_sr_t*)buf;
-	int rr=(session->rtp.stats.packet_recv>0);
+	int rr=(session->stats.packet_recv>0);
 	int sr_size=sizeof(rtcp_sr_t)-sizeof(report_block_t)+(rr*sizeof(report_block_t));
 	if (size<sr_size) return 0;
 	rtcp_common_header_init(&sr->ch,session,RTCP_SR,rr,sr_size);
@@ -447,11 +447,11 @@ static void rtp_session_create_and_send_rtcp_packet(RtpSession *session, bool_t
 	mblk_t *m=NULL;
 	bool_t is_sr = FALSE;
 
-	if (session->rtp.last_rtcp_packet_count < session->rtp.stats.packet_sent) {
+	if (session->rtp.last_rtcp_packet_count < session->stats.packet_sent) {
 		m = make_sr(session);
-		session->rtp.last_rtcp_packet_count = session->rtp.stats.packet_sent;
+		session->rtp.last_rtcp_packet_count = session->stats.packet_sent;
 		is_sr = TRUE;
-	} else if (session->rtp.stats.packet_recv > 0) {
+	} else if (session->stats.packet_recv > 0) {
 		/* Don't send RR when no packet are received yet */
 		m = make_rr(session);
 		is_sr = FALSE;
@@ -491,9 +491,9 @@ void compute_rtcp_interval(RtpSession *session) {
 
 	if (rtp_session_avpf_enabled(session) == TRUE) {
 		session->rtcp.send_algo.T_rr_interval = rtp_session_get_avpf_rr_interval(session);
-		rtcp_min_time = session->rtcp.send_algo.Tmin;
+		rtcp_min_time = (float)session->rtcp.send_algo.Tmin;
 	} else {
-		rtcp_min_time = session->rtcp.send_algo.T_rr_interval;
+		rtcp_min_time = (float)session->rtcp.send_algo.T_rr_interval;
 		if (session->rtcp.send_algo.initial == TRUE) {
 			rtcp_min_time /= 2.;
 		}
@@ -502,14 +502,14 @@ void compute_rtcp_interval(RtpSession *session) {
 	t = ((session->rtcp.send_algo.avg_rtcp_size * 8 * 2) / rtcp_bw) * 1000;
 	if (t < rtcp_min_time) t = rtcp_min_time;
 	t = rtcp_rand(t);
-	t = t / (2.71828 - 1.5); /* Compensation */
+	t = t / (2.71828f - 1.5f); /* Compensation */
 	session->rtcp.send_algo.T_rr = (uint32_t)t;
 }
 
 void update_avg_rtcp_size(RtpSession *session, int bytes) {
 	int overhead = (ortp_stream_is_ipv6(&session->rtcp.gs) == TRUE) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
 	int size = bytes + overhead;
-	session->rtcp.send_algo.avg_rtcp_size = ((size + (15 * session->rtcp.send_algo.avg_rtcp_size)) / 16.);
+	session->rtcp.send_algo.avg_rtcp_size = ((size + (15 * session->rtcp.send_algo.avg_rtcp_size)) / 16.f);
 }
 
 static void rtp_session_schedule_first_rtcp_send(RtpSession *session) {
@@ -645,7 +645,7 @@ int rtp_session_bye(RtpSession *session, const char *reason) {
     bye = rtcp_create_simple_bye_packet(session->snd.ssrc, reason);
 
     /* SR or RR is determined by the fact whether stream was sent*/
-    if (session->rtp.stats.packet_sent>0)
+    if (session->stats.packet_sent>0)
     {
         cm = allocb(sizeof(rtcp_sr_t), 0);
         cm->b_wptr += rtcp_sr_init(session,cm->b_wptr, sizeof(rtcp_sr_t));
@@ -653,7 +653,7 @@ int rtp_session_bye(RtpSession *session, const char *reason) {
         sdes = rtp_session_create_rtcp_sdes_packet(session, TRUE);
         /* link them */
         concatb(concatb(cm, sdes), bye);
-    } else if (session->rtp.stats.packet_recv>0){
+    } else if (session->stats.packet_recv>0){
         /* make a RR packet */
         cm = allocb(sizeof(rtcp_rr_t), 0);
         cm->b_wptr += rtcp_rr_init(session, cm->b_wptr, sizeof(rtcp_rr_t));
@@ -678,17 +678,17 @@ void ortp_loss_rate_estimator_init(OrtpLossRateEstimator *obj, int min_packet_co
 	obj->min_packet_count_interval=min_packet_count_interval;
 	obj->last_ext_seq=rtp_session_get_seq_number(session);
 	obj->last_cum_loss=rtp_session_get_cum_loss(session);
-	obj->last_packet_sent_count=session->rtp.stats.packet_sent;
-	obj->last_dup_packet_sent_count=session->rtp.stats.packet_dup_sent;
+	obj->last_packet_sent_count=session->stats.packet_sent;
+	obj->last_dup_packet_sent_count=session->stats.packet_dup_sent;
 	obj->min_time_ms_interval=min_time_ms_interval;
 	obj->last_estimate_time_ms=(uint64_t)-1;
 }
 
-bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj, const RtpStream *stream, const report_block_t *rb){
+bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj, const RtpSession *session, const report_block_t *rb){
 	int32_t cum_loss=report_block_get_cum_packet_lost(rb);
 	int32_t extseq=report_block_get_high_ext_seq(rb);
-	int32_t diff_unique_outgoing=stream->stats.packet_sent-obj->last_packet_sent_count;
-	int32_t diff_total_outgoing=diff_unique_outgoing+stream->stats.packet_dup_sent-obj->last_dup_packet_sent_count;
+	int32_t diff_unique_outgoing=session->stats.packet_sent-obj->last_packet_sent_count;
+	int32_t diff_total_outgoing=diff_unique_outgoing+session->stats.packet_dup_sent-obj->last_dup_packet_sent_count;
 	int32_t diff;
 	uint64_t curtime;
 	bool_t got_value=FALSE;
@@ -706,15 +706,15 @@ bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj,
 		ortp_warning("ortp_loss_rate_estimator_process %p: Suspected discontinuity in sequence numbering from %d to %d.", obj, obj->last_ext_seq, extseq);
 		obj->last_ext_seq=extseq;
 		obj->last_cum_loss=cum_loss;
-		obj->last_packet_sent_count=stream->stats.packet_sent;
-		obj->last_dup_packet_sent_count=stream->stats.packet_dup_sent;
+		obj->last_packet_sent_count=session->stats.packet_sent;
+		obj->last_dup_packet_sent_count=session->stats.packet_dup_sent;
 	}else if (diff>obj->min_packet_count_interval && curtime-obj->last_estimate_time_ms>=obj->min_time_ms_interval){
 		/*we have sufficient interval*/
 		int32_t new_losses=cum_loss-obj->last_cum_loss;
 		/*if we are using duplicates, they will not be visible in 'diff' variable.
 		But since we are the emitter, we can retrieve the total count of packet we
 		sent and use this value to compute the loss rate instead.*/
-		obj->loss_rate=100.0*(1. - MAX(0, (diff_unique_outgoing - new_losses) * 1.f / diff_total_outgoing));
+		obj->loss_rate = 100.f * (1.f - MAX(0, (diff_unique_outgoing - new_losses) * 1.f / diff_total_outgoing));
 
 		/*update last values with current*/
 		got_value=TRUE;
@@ -725,8 +725,8 @@ bool_t ortp_loss_rate_estimator_process_report_block(OrtpLossRateEstimator *obj,
 		}
 		obj->last_ext_seq=extseq;
 		obj->last_cum_loss=cum_loss;
-		obj->last_packet_sent_count=stream->stats.packet_sent;
-		obj->last_dup_packet_sent_count=stream->stats.packet_dup_sent;
+		obj->last_packet_sent_count=session->stats.packet_sent;
+		obj->last_dup_packet_sent_count=session->stats.packet_dup_sent;
 	}
 	return got_value;
 
diff --git a/src/rtcp_fb.c b/src/rtcp_fb.c
index cdb1af9..7b7fa1e 100644
--- a/src/rtcp_fb.c
+++ b/src/rtcp_fb.c
@@ -73,25 +73,35 @@ static mblk_t * make_rtcp_fb_pli(RtpSession *session) {
 }
 
 static mblk_t * make_rtcp_fb_fir(RtpSession *session) {
-	int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_fir_fci_t);
+	int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + 2 * sizeof(rtcp_fb_fir_fci_t);
 	mblk_t *h = allocb(size, 0);
 	rtcp_common_header_t *ch;
 	rtcp_fb_header_t *fbh;
-	rtcp_fb_fir_fci_t *fci;
+	rtcp_fb_fir_fci_t *fci1;
+	rtcp_fb_fir_fci_t *fci2;
 
 	/* Fill FIR */
 	ch = (rtcp_common_header_t *)h->b_wptr;
 	h->b_wptr += sizeof(rtcp_common_header_t);
 	fbh = (rtcp_fb_header_t *)h->b_wptr;
 	h->b_wptr += sizeof(rtcp_fb_header_t);
-	fci = (rtcp_fb_fir_fci_t *)h->b_wptr;
+	fci1 = (rtcp_fb_fir_fci_t *)h->b_wptr;
+	h->b_wptr += sizeof(rtcp_fb_fir_fci_t);
+	fci2 = (rtcp_fb_fir_fci_t *)h->b_wptr;
 	h->b_wptr += sizeof(rtcp_fb_fir_fci_t);
 	fbh->packet_sender_ssrc = htonl(0);
 	fbh->media_source_ssrc = htonl(rtp_session_get_recv_ssrc(session));
-	fci->ssrc = htonl(rtp_session_get_send_ssrc(session));
-	fci->seq_nr = session->rtcp.rtcp_fb_fir_seq_nr++;
-	fci->pad1 = 0;
-	fci->pad2 = 0;
+	fci1->ssrc = htonl(rtp_session_get_send_ssrc(session));
+	fci1->seq_nr = session->rtcp.rtcp_fb_fir_seq_nr;
+	fci1->pad1 = 0;
+	fci1->pad2 = 0;
+	/* TODO: This second FCI is only put for compatibility with older oRTP versions where the recv ssrc
+	 * was used whereas its the send ssrc that needs to be used. Remove this someday! */
+	fci2->ssrc = htonl(rtp_session_get_recv_ssrc(session));
+	fci2->seq_nr = session->rtcp.rtcp_fb_fir_seq_nr;
+	fci2->pad1 = 0;
+	fci2->pad2 = 0;
+	session->rtcp.rtcp_fb_fir_seq_nr++;
 
 	/* Fill common header */
 	rtcp_common_header_init(ch, session, RTCP_PSFB, RTCP_PSFB_FIR, msgdsize(h));
@@ -170,6 +180,30 @@ static mblk_t * make_rtcp_fb_rpsi(RtpSession *session, uint8_t *bit_string, uint
 	return h;
 }
 
+static mblk_t * make_rtcp_fb_generic_nack(RtpSession *session, uint16_t pid, uint16_t blp) {
+	int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_generic_nack_fci_t);
+	mblk_t *h = allocb(size, 0);
+	rtcp_common_header_t *ch;
+	rtcp_fb_header_t *fbh;
+	rtcp_fb_generic_nack_fci_t *fci;
+
+	ch = (rtcp_common_header_t *)h->b_wptr;
+	h->b_wptr += sizeof(rtcp_common_header_t);
+	fbh = (rtcp_fb_header_t *)h->b_wptr;
+	h->b_wptr += sizeof(rtcp_fb_header_t);
+	fci = (rtcp_fb_generic_nack_fci_t *)h->b_wptr;
+	h->b_wptr += sizeof(rtcp_fb_generic_nack_fci_t);
+	fbh->packet_sender_ssrc = htonl(rtp_session_get_send_ssrc(session));
+	fbh->media_source_ssrc = htonl(0);
+	rtcp_fb_generic_nack_fci_set_pid(fci, pid);
+	rtcp_fb_generic_nack_fci_set_blp(fci, blp);
+
+	/* Fill common header */
+	rtcp_common_header_init(ch, session, RTCP_RTPFB, RTCP_RTPFB_NACK, msgdsize(h));
+
+	return h;
+}
+
 static mblk_t * make_rtcp_fb_tmmbr(RtpSession *session, uint64_t mxtbr, uint16_t measured_overhead) {
 	int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_tmmbr_fci_t);
 	mblk_t *h = allocb(size, 0);
@@ -259,6 +293,15 @@ bool_t rtp_session_rtcp_rtpfb_scheduled(RtpSession *session, rtcp_rtpfb_type_t t
 	return FALSE;
 }
 
+void rtp_session_send_rtcp_fb_generic_nack(RtpSession *session, uint16_t pid, uint16_t blp) {
+	mblk_t *m;
+	if ((rtp_session_avpf_enabled(session) == TRUE) && (rtp_session_avpf_feature_enabled(session, ORTP_AVPF_FEATURE_GENERIC_NACK) == TRUE)) {
+		m = make_rtcp_fb_generic_nack(session, pid, blp);
+		rtp_session_add_fb_packet_to_send(session, m);
+		rtp_session_send_fb_rtcp_packet_and_reschedule(session);
+	}
+}
+
 void rtp_session_send_rtcp_fb_pli(RtpSession *session) {
 	mblk_t *m;
 	if ((rtp_session_avpf_enabled(session) == TRUE) && (rtp_session_avpf_payload_type_feature_enabled(session, PAYLOAD_TYPE_AVPF_PLI) == TRUE)) {
@@ -287,11 +330,18 @@ void rtp_session_send_rtcp_fb_fir(RtpSession *session) {
 
 void rtp_session_send_rtcp_fb_sli(RtpSession *session, uint16_t first, uint16_t number, uint8_t picture_id) {
 	mblk_t *m;
-	if ((rtp_session_avpf_enabled(session) == TRUE) && (rtp_session_avpf_payload_type_feature_enabled(session, PAYLOAD_TYPE_AVPF_SLI) == TRUE)) {
-		m = make_rtcp_fb_sli(session, first, number, picture_id);
-		rtp_session_add_fb_packet_to_send(session, m);
-		if (is_fb_packet_to_be_sent_immediately(session) == TRUE) {
-			rtp_session_send_fb_rtcp_packet_and_reschedule(session);
+	if (rtp_session_avpf_enabled(session) == TRUE) {
+		/* Only send SLI if SLI and RPSI features have been enabled. SLI without RPSI is not really useful. */
+		if ((rtp_session_avpf_payload_type_feature_enabled(session, PAYLOAD_TYPE_AVPF_SLI) == TRUE)
+			&& (rtp_session_avpf_payload_type_feature_enabled(session, PAYLOAD_TYPE_AVPF_RPSI) == TRUE)) {
+			m = make_rtcp_fb_sli(session, first, number, picture_id);
+			rtp_session_add_fb_packet_to_send(session, m);
+			if (is_fb_packet_to_be_sent_immediately(session) == TRUE) {
+				rtp_session_send_fb_rtcp_packet_and_reschedule(session);
+			}
+		} else {
+			// Try to fallback to sending a PLI if the SLI feature has not been enabled.
+			rtp_session_send_rtcp_fb_pli(session);
 		}
 	}
 }
@@ -333,12 +383,12 @@ void rtp_session_send_rtcp_fb_tmmbn(RtpSession *session, uint32_t ssrc) {
 }
 
 bool_t rtp_session_avpf_enabled(RtpSession *session) {
-	PayloadType *pt = rtp_profile_get_payload(session->rcv.profile, session->rcv.pt);
+	PayloadType *pt = rtp_profile_get_payload(session->snd.profile, session->snd.pt);
 	return pt && (payload_type_get_flags(pt) & PAYLOAD_TYPE_RTCP_FEEDBACK_ENABLED);
 }
 
 bool_t rtp_session_avpf_payload_type_feature_enabled(RtpSession *session, unsigned char feature) {
-	PayloadType *pt = rtp_profile_get_payload(session->rcv.profile, session->rcv.pt);
+	PayloadType *pt = rtp_profile_get_payload(session->snd.profile, session->snd.pt);
 	PayloadTypeAvpfParams params;
 	if (!pt) return FALSE;
 	params = payload_type_get_avpf_params(pt);
diff --git a/src/rtcp_xr.c b/src/rtcp_xr.c
index 6203634..671e8aa 100644
--- a/src/rtcp_xr.c
+++ b/src/rtcp_xr.c
@@ -143,7 +143,7 @@ static int rtcp_xr_voip_metrics_init(uint8_t *buf, RtpSession *session) {
 	uint32_t lost_packets;
 	rtcp_xr_voip_metrics_report_block_t *block = (rtcp_xr_voip_metrics_report_block_t *)buf;
 	float rtt = rtp_session_get_round_trip_propagation(session);
-	uint16_t int_rtt = (rtt >= 0) ? (rtt * 1000) : 0;
+	uint16_t int_rtt = (uint16_t)((rtt >= 0) ? (rtt * 1000) : 0);
 	float qi = -1;
 	float lq_qi = -1;
 
diff --git a/src/rtcpparse.c b/src/rtcpparse.c
index e54a373..55de6ff 100644
--- a/src/rtcpparse.c
+++ b/src/rtcpparse.c
@@ -21,21 +21,19 @@
 #include "ortp/ortp.h"
 #include "utils.h"
 
-static int rtcp_get_size(const mblk_t *m){
+static size_t rtcp_get_size(const mblk_t *m){
 	const rtcp_common_header_t *ch=rtcp_get_common_header(m);
-	if (ch==NULL) return -1;
+	if (ch==NULL) return 0;
 	return (1+rtcp_common_header_get_length(ch))*4;
 }
 
-/*in case of coumpound packet, set read pointer of m to the beginning of the next RTCP
+/*in case of compound packet, set read pointer of m to the beginning of the next RTCP
 packet */
 bool_t rtcp_next_packet(mblk_t *m){
-	int nextlen=rtcp_get_size(m);
-	if (nextlen>=0){
-		if (m->b_rptr+nextlen<m->b_wptr){
-			m->b_rptr+=nextlen;
-			return TRUE;
-		}
+	size_t nextlen=rtcp_get_size(m);
+	if ((nextlen > 0) && (m->b_rptr + nextlen < m->b_wptr)){
+		m->b_rptr+=nextlen;
+		return TRUE;
 	}
 	return FALSE;
 }
@@ -46,14 +44,14 @@ void rtcp_rewind(mblk_t *m){
 
 /* get common header; this function will also check the sanity of the packet*/
 const rtcp_common_header_t * rtcp_get_common_header(const mblk_t *m){
-	int size=msgdsize(m);
+	size_t size=msgdsize(m);
 	rtcp_common_header_t *ch;
 	if (m->b_cont!=NULL){
 		ortp_fatal("RTCP parser does not work on fragmented mblk_t. Use msgpullup() before to re-assemble the packet.");
 		return NULL;
 	}
 	if (size<sizeof(rtcp_common_header_t)){
-		ortp_warning("Bad RTCP packet, too short.");
+		ortp_warning("Bad RTCP packet, too short [%i b]. on block [%p]",(int)size,m);
 		return NULL;
 	}
 	ch=(rtcp_common_header_t*)m->b_rptr;
@@ -86,7 +84,7 @@ const sender_info_t * rtcp_SR_get_sender_info(const mblk_t *m){
 const report_block_t * rtcp_SR_get_report_block(const mblk_t *m, int idx){
 	rtcp_sr_t *sr=(rtcp_sr_t*)m->b_rptr;
 	report_block_t *rb=&sr->rb[idx];
-	int size=rtcp_get_size(m);
+	size_t size=rtcp_get_size(m);
 	if ( ( (uint8_t*)rb)+sizeof(report_block_t) <= m->b_rptr + size ) {
 		return rb;
 	}else{
@@ -118,7 +116,7 @@ uint32_t rtcp_RR_get_ssrc(const mblk_t *m){
 const report_block_t * rtcp_RR_get_report_block(const mblk_t *m,int idx){
 	rtcp_rr_t *rr=(rtcp_rr_t*)m->b_rptr;
 	report_block_t *rb=&rr->rb[idx];
-	int size=rtcp_get_size(m);
+	size_t size=rtcp_get_size(m);
 	if ( ( (uint8_t*)rb)+sizeof(report_block_t) <= (m->b_rptr + size ) ){
 		return rb;
 	}else{
@@ -169,7 +167,7 @@ void rtcp_sdes_parse(const mblk_t *m, SdesItemFoundCallback cb, void *user_data)
 
 				if (type==RTCP_SDES_END){
 					/* pad to next 32bit boundary*/
-					rptr=(uint8_t*)(((unsigned long)rptr+4) & ~0x3);
+					rptr=(uint8_t *)((intptr_t)(rptr+4) & ~0x3);
 					nchunk++;
 					if (nchunk<rtcp_common_header_get_rc(ch)){
 						chunk_start=TRUE;
@@ -243,7 +241,7 @@ bool_t rtcp_BYE_get_reason(const mblk_t *m, const char **reason, int *reason_len
 /*APP accessors */
 bool_t rtcp_is_APP(const mblk_t *m){
 	const rtcp_common_header_t *ch=rtcp_get_common_header(m);
-	int size=rtcp_get_size(m);
+	size_t size=rtcp_get_size(m);
 	if (ch!=NULL && rtcp_common_header_get_packet_type(ch)==RTCP_APP){
 		if (msgdsize(m)<size){
 			ortp_warning("Too short RTCP APP packet.");
@@ -274,7 +272,7 @@ void rtcp_APP_get_name(const mblk_t *m, char *name){
 }
 /* retrieve the data. when returning, data points directly into the mblk_t */
 void rtcp_APP_get_data(const mblk_t *m, uint8_t **data, int *len){
-	int datalen=rtcp_get_size(m)-sizeof(rtcp_app_t);
+	int datalen=(int)rtcp_get_size(m)-sizeof(rtcp_app_t);
 	if (datalen>0){
 		*data=(uint8_t*)m->b_rptr+sizeof(rtcp_app_t);
 		*len=datalen;
@@ -542,9 +540,18 @@ uint32_t rtcp_RTPFB_get_media_source_ssrc(const mblk_t *m) {
 	return ntohl(fbh->media_source_ssrc);
 }
 
+rtcp_fb_generic_nack_fci_t * rtcp_RTPFB_generic_nack_get_fci(const mblk_t *m) {
+	size_t size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_generic_nack_fci_t);
+	size_t rtcp_size = rtcp_get_size(m);
+	if (size > rtcp_size) {
+		return NULL;
+	}
+	return (rtcp_fb_generic_nack_fci_t *)(m->b_rptr + size - sizeof(rtcp_fb_generic_nack_fci_t));
+}
+
 rtcp_fb_tmmbr_fci_t * rtcp_RTPFB_tmmbr_get_fci(const mblk_t *m) {
-	unsigned int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_tmmbr_fci_t);
-	unsigned int rtcp_size = rtcp_get_size(m);
+	size_t size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + sizeof(rtcp_fb_tmmbr_fci_t);
+	size_t rtcp_size = rtcp_get_size(m);
 	if (size > rtcp_size) {
 		return NULL;
 	}
@@ -587,8 +594,8 @@ uint32_t rtcp_PSFB_get_media_source_ssrc(const mblk_t *m) {
 }
 
 rtcp_fb_fir_fci_t * rtcp_PSFB_fir_get_fci(const mblk_t *m, unsigned int idx) {
-	unsigned int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + ((idx + 1) * sizeof(rtcp_fb_fir_fci_t));
-	unsigned int rtcp_size = rtcp_get_size(m);
+	size_t size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + ((idx + 1) * sizeof(rtcp_fb_fir_fci_t));
+	size_t rtcp_size = rtcp_get_size(m);
 	if (size > rtcp_size) {
 		return NULL;
 	}
@@ -596,8 +603,8 @@ rtcp_fb_fir_fci_t * rtcp_PSFB_fir_get_fci(const mblk_t *m, unsigned int idx) {
 }
 
 rtcp_fb_sli_fci_t * rtcp_PSFB_sli_get_fci(const mblk_t *m, unsigned int idx) {
-	unsigned int size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + ((idx + 1) * sizeof(rtcp_fb_sli_fci_t));
-	unsigned int rtcp_size = rtcp_get_size(m);
+	size_t size = sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + ((idx + 1) * sizeof(rtcp_fb_sli_fci_t));
+	size_t rtcp_size = rtcp_get_size(m);
 	if (size > rtcp_size) {
 		return NULL;
 	}
@@ -610,6 +617,6 @@ rtcp_fb_rpsi_fci_t * rtcp_PSFB_rpsi_get_fci(const mblk_t *m) {
 
 uint16_t rtcp_PSFB_rpsi_get_fci_bit_string_len(const mblk_t *m) {
 	rtcp_fb_rpsi_fci_t *fci = rtcp_PSFB_rpsi_get_fci(m);
-	uint16_t bit_string_len_in_bytes = rtcp_get_size(m) - (sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + 2);
+	uint16_t bit_string_len_in_bytes = (uint16_t)(rtcp_get_size(m) - (sizeof(rtcp_common_header_t) + sizeof(rtcp_fb_header_t) + 2));
 	return ((bit_string_len_in_bytes * 8) - fci->pb);
 }
diff --git a/src/rtpparse.c b/src/rtpparse.c
index fc6077b..992556e 100644
--- a/src/rtpparse.c
+++ b/src/rtpparse.c
@@ -130,13 +130,13 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
 	rtp_header_t *rtp;
 	int msgsize;
 	RtpStream *rtpstream=&session->rtp;
-	rtp_stats_t *stats=&rtpstream->stats;
+	rtp_stats_t *stats=&session->stats;
 
-	msgsize=mp->b_wptr-mp->b_rptr;
+	msgsize=(int)(mp->b_wptr-mp->b_rptr);
 
 	if (msgsize<RTP_FIXED_HEADER_SIZE){
 		ortp_warning("Packet too small to be a rtp packet (%i)!",msgsize);
-		rtpstream->stats.bad++;
+		session->stats.bad++;
 		ortp_global_stats.bad++;
 		freemsg(mp);
 		return;
@@ -209,13 +209,7 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
 			}
 			if (session->inc_same_ssrc_count>=session->rtp.ssrc_changed_thres){
 				/* store the sender rtp address to do symmetric RTP */
-				if (!session->use_connect){
-					if (session->rtp.gs.socket>0 && session->symmetric_rtp){
-						/* store the sender rtp address to do symmetric RTP */
-						memcpy(&session->rtp.gs.rem_addr,addr,addrlen);
-						session->rtp.gs.rem_addrlen=addrlen;
-					}
-				}
+				rtp_session_update_remote_sock_addr(session,mp,TRUE,FALSE);
 				session->rtp.rcv_last_ts = rtp->timestamp;
 				session->rcv.ssrc=rtp->ssrc;
 				rtp_signal_table_emit(&session->on_ssrc_changed);
@@ -235,14 +229,7 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
 	}else{
 		session->ssrc_set=TRUE;
 		session->rcv.ssrc=rtp->ssrc;
-
-		if (!session->use_connect){
-			if (session->rtp.gs.socket>0 && session->symmetric_rtp){
-				/* store the sender rtp address to do symmetric RTP */
-				memcpy(&session->rtp.gs.rem_addr,addr,addrlen);
-				session->rtp.gs.rem_addrlen=addrlen;
-			}
-		}
+		rtp_session_update_remote_sock_addr(session,mp,TRUE,FALSE);
 	}
 
 	/* update some statistics */
@@ -301,7 +288,7 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
 		/* detect timestamp important jumps in the future, to workaround stupid rtp senders */
 		if (RTP_TIMESTAMP_IS_NEWER_THAN(rtp->timestamp,session->rtp.rcv_last_ts+session->rtp.ts_jump)){
 			ortp_warning("rtp_parse: timestamp jump in the future detected.");
-			rtp_signal_table_emit2(&session->on_timestamp_jump,(long)&rtp->timestamp);
+			rtp_signal_table_emit2(&session->on_timestamp_jump,&rtp->timestamp);
 		}
 		else if (RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(session->rtp.rcv_last_ts,rtp->timestamp) 
 			|| RTP_SEQ_IS_STRICTLY_GREATER_THAN(session->rtp.rcv_last_seq,rtp->seq_number)){
@@ -313,8 +300,7 @@ void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_t
 
 			if ( RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(session->rtp.rcv_last_ts, rtp->timestamp + session->rtp.ts_jump) ){
 				ortp_warning("rtp_parse: negative timestamp jump detected");
-				rtp_signal_table_emit2(&session->on_timestamp_jump,
-							(long)&rtp->timestamp);
+				rtp_signal_table_emit2(&session->on_timestamp_jump, &rtp->timestamp);
 			}
 			ortp_debug("rtp_parse: discarding too old packet (ts=%i)",rtp->timestamp);
 			freemsg(mp);
diff --git a/src/rtpprofile.c b/src/rtpprofile.c
index 8c34b7d..29edf1c 100644
--- a/src/rtpprofile.c
+++ b/src/rtpprofile.c
@@ -20,17 +20,22 @@
 #include "ortp/ortp.h"
 
 
-int rtp_profile_get_payload_number_from_mime(RtpProfile *profile,const char *mime)
+int rtp_profile_get_payload_number_from_mime(RtpProfile *profile, const char *mime)
+{
+	return rtp_profile_get_payload_number_from_mime_and_flag(profile, mime, -1);
+}
+
+int rtp_profile_get_payload_number_from_mime_and_flag(RtpProfile *profile, const char *mime, int flag)
 {
 	PayloadType *pt;
 	int i;
-	for (i=0;i<RTP_PROFILE_MAX_PAYLOADS;i++)
-	{
-		pt=rtp_profile_get_payload(profile,i);
-		if (pt!=NULL)
-		{
-			if (strcasecmp(pt->mime_type,mime)==0){
-				return i;
+	for (i = 0; i < RTP_PROFILE_MAX_PAYLOADS; i++) {
+		pt = rtp_profile_get_payload(profile, i);
+		if (pt != NULL) {
+			if (strcasecmp(pt->mime_type, mime) == 0) {
+				if (flag < 0 || pt->flags & flag) {
+					return i;
+				}
 			}
 		}
 	}
@@ -150,12 +155,12 @@ RtpProfile * rtp_profile_new(const char *name)
  * @param pt the payload type description
  *
 **/
-void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt){
+void rtp_profile_set_payload(RtpProfile *profile, int idx, PayloadType *pt){
 	if (idx<0 || idx>=RTP_PROFILE_MAX_PAYLOADS) {
 		ortp_error("Bad index %i",idx);
 		return;
 	}
-	prof->payload[idx]=pt;
+	profile->payload[idx]=pt;
 }
 
 /**
@@ -163,10 +168,10 @@ void rtp_profile_set_payload(RtpProfile *prof, int idx, PayloadType *pt){
  *@param profile a RTP profile
  *
 **/
-void rtp_profile_clear_all(RtpProfile *obj){
+void rtp_profile_clear_all(RtpProfile *profile){
 	int i;
 	for (i=0;i<RTP_PROFILE_MAX_PAYLOADS;i++){
-		obj->payload[i]=0;
+		profile->payload[i]=0;
 	}
 }
 
@@ -174,12 +179,12 @@ void rtp_profile_clear_all(RtpProfile *obj){
 /**
  * Set a name to the rtp profile. (This is not required)
  * @param profile a rtp profile object
- * @param nm a string
+ * @param name a string
  *
 **/
-void rtp_profile_set_name(RtpProfile *obj, const char *name){
-	if (obj->name!=NULL) ortp_free(obj->name);
-	obj->name=ortp_strdup(name);
+void rtp_profile_set_name(RtpProfile *profile, const char *name){
+	if (profile->name!=NULL) ortp_free(profile->name);
+	profile->name=ortp_strdup(name);
 }
 
 /* ! payload are not cloned*/
diff --git a/src/rtpsession.c b/src/rtpsession.c
index cb46b38..3debb12 100644
--- a/src/rtpsession.c
+++ b/src/rtpsession.c
@@ -33,20 +33,20 @@
 #if (_WIN32_WINNT >= 0x0600)
 #include <delayimp.h>
 #undef ExternC /* avoid redefinition... */
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 #include <QOS2.h>
 #endif
 #endif
 
 /**
- * #RtpTransport object which can handle multiples security protocols. You can for instance use this object
- * to use both sRTP and tunnel transporter. #mblk_t messages received and sent from the endpoint
+ * #_RtpTransport object which can handle multiples security protocols. You can for instance use this object
+ * to use both sRTP and tunnel transporter. mblk_t messages received and sent from the endpoint
  * will pass through the list of modifiers given. First modifier in list will be first to modify the message
  * in send mode and last in receive mode.
  * @param[in] is_rtp Whether this object will be used for RTP packets or not.
- * @param[in] endpoint #RtpTransport object in charge of sending/receiving packets. If NULL, it will use standards sendto and recvfrom functions.
- * @param[in] modifiers_count number of #RtpModifier object given in the variadic list. Must be 0 if none are given.
- * @returns #RtpTransport object that will be generated or NULL.
+ * @param[in] endpoint #_RtpTransport object in charge of sending/receiving packets. If NULL, it will use standards sendto and recvfrom functions.
+ * @param[in] modifiers_count number of #_RtpTransport object given in the variadic list. Must be 0 if none are given.
+ * @returns #_RtpTransport object that will be generated or NULL.
 **/
 RtpTransport* meta_rtp_transport_new(bool_t is_rtp, RtpTransport *endpoint, unsigned modifiers_count, ...);
 
@@ -101,7 +101,7 @@ extern void rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_ts,
 		struct sockaddr *addr, socklen_t addrlen);
 
 
-static uint32_t uint32_t_random(){
+static uint32_t uint32_t_random(void){
 	return ortp_random();
 }
 
@@ -248,7 +248,7 @@ rtp_session_init (RtpSession * session, int mode)
 	rtp_session_set_profile (session, &av_profile); /*the default profile to work with */
 	session->rtp.gs.socket=-1;
 	session->rtcp.gs.socket=-1;
-#ifndef WIN32
+#ifndef _WIN32
 	session->rtp.snd_socket_size=0;	/*use OS default value unless on windows where they are definitely too short*/
 	session->rtp.rcv_socket_size=0;
 #else
@@ -297,11 +297,13 @@ rtp_session_init (RtpSession * session, int mode)
 	session->symmetric_rtp = FALSE;
 	session->permissive=FALSE;
 	session->reuseaddr=TRUE;
-	msgb_allocator_init(&session->allocator);
+	msgb_allocator_init(&session->rtp.gs.allocator);
+	msgb_allocator_init(&session->rtcp.gs.allocator);
 	/*set default rtptransport*/
 	rtp_session_set_transports(	session
 								,meta_rtp_transport_new(TRUE,NULL, 0)
 								,meta_rtp_transport_new(FALSE,NULL, 0));
+	session->tev_send_pt = -1; /*check in rtp profile when needed*/
 }
 
 
@@ -329,12 +331,12 @@ rtp_session_new (int mode)
 }
 
 /**
- * Sets the scheduling mode of the rtp session. If @yesno is TRUE, the rtp session is in
+ * Sets the scheduling mode of the rtp session. If \a yesno is TRUE, the rtp session is in
  *	the scheduled mode, that means that you can use session_set_select() to block until it's time
  *	to receive or send on this session according to the timestamp passed to the respective functions.
  *  You can also use blocking mode (see rtp_session_set_blocking_mode() ), to simply block within
  *	the receive and send functions.
- *	If @yesno is FALSE, the ortp scheduler will not manage those sessions, meaning that blocking mode
+ *	If \a yesno is FALSE, the ortp scheduler will not manage those sessions, meaning that blocking mode
  *  and the use of session_set_select() for this session are disabled.
  *@param session a rtp session.
  *@param yesno 	a boolean to indicate the scheduling mode.
@@ -367,11 +369,11 @@ rtp_session_set_scheduling_mode (RtpSession * session, int yesno)
 /**
  *	This function implicitely enables the scheduling mode if yesno is TRUE.
  *	rtp_session_set_blocking_mode() defines the behaviour of the rtp_session_recv_with_ts() and
- *	rtp_session_send_with_ts() functions. If @yesno is TRUE, rtp_session_recv_with_ts()
+ *	rtp_session_send_with_ts() functions. If \a yesno is TRUE, rtp_session_recv_with_ts()
  *	will block until it is time for the packet to be received, according to the timestamp
  *	passed to the function. After this time, the function returns.
  *	For rtp_session_send_with_ts(), it will block until it is time for the packet to be sent.
- *	If @yesno is FALSE, then the two functions will return immediately.
+ *	If \a yesno is FALSE, then the two functions will return immediately.
  *
  *  @param session a rtp session
  *  @param yesno a boolean
@@ -415,6 +417,10 @@ void rtp_session_enable_rtcp(RtpSession *session, bool_t yesno){
 	session->rtcp.enabled=yesno;
 }
 
+bool_t rtp_session_rtcp_enabled(const RtpSession *session) {
+	return  session->rtcp.enabled;
+}
+
 /**
  * Sets the default interval in milliseconds for RTCP reports emitted by the session
  *
@@ -524,9 +530,9 @@ void rtp_session_set_rtp_socket_recv_buffer_size(RtpSession * session, unsigned
 
 /**
  *	This function provides the way for an application to be informed of various events that
- *	may occur during a rtp session. @signal is a string identifying the event, and @cb is
+ *	may occur during a rtp session. \a signal_name is a string identifying the event, and \a cb is
  *	a user supplied function in charge of processing it. The application can register
- *	several callbacks for the same signal, in the limit of #RTP_CALLBACK_TABLE_MAX_ENTRIES.
+ *	several callbacks for the same signal, in the limit of \a RTP_CALLBACK_TABLE_MAX_ENTRIES.
  *	Here are name and meaning of supported signals types:
  *
  *	"ssrc_changed" : the SSRC of the incoming stream has changed.
@@ -572,7 +578,7 @@ rtp_session_signal_connect (RtpSession * session, const char *signal_name,
 
 
 /**
- *	Removes callback function @cb to the list of callbacks for signal @signal.
+ *	Removes callback function \a cb to the list of callbacks for signal \a signal.
  *
  * @param session a rtp session
  * @param signal_name	a signal name
@@ -598,7 +604,7 @@ rtp_session_signal_disconnect_by_callback (RtpSession * session, const char *sig
 /**
  * Set the initial sequence number for outgoing stream..
  * @param session		a rtp session freshly created.
- * @param addr			a 16 bit unsigned number.
+ * @param seq			a 16 bit unsigned number.
  *
 **/
 void rtp_session_set_seq_number(RtpSession *session, uint16_t seq){
@@ -706,6 +712,20 @@ int rtp_session_get_send_payload_type(const RtpSession *session){
 }
 
 /**
+ * Assign the payload type number for sending telephone-event.
+ * It is required that a "telephone-event" PayloadType is assigned in the RtpProfile set for the RtpSession.
+ * This function is in most of cases useless, unless there is an ambiguity where several PayloadType for "telephone-event" are present in the RtpProfile.
+ * This might happen during SIP offeranswer scenarios. This function allows to remove any ambiguity by letting the application choose the one to be used.
+ * @param session the RtpSession
+ * @param paytype the payload type number
+ * @returns 0, -1 on error.
+**/
+int rtp_session_set_send_telephone_event_payload_type(RtpSession *session, int paytype){
+	session->tev_send_pt = paytype;
+	return 0;
+}
+
+/**
  *
  *	Sets the expected payload type for incoming packets.
  *	If the actual payload type in incoming packets is different that this expected payload type, thus
@@ -744,7 +764,7 @@ int rtp_session_get_recv_payload_type(const RtpSession *session){
  *	the "payload_type_changed" signal is emitted.
  *
  * @param session a rtp session
- * @param paytype the payload type number
+ * @param pt the payload type number
  * @return 0 on success, -1 if the payload is not defined.
 **/
 int rtp_session_set_payload_type(RtpSession *session, int pt){
@@ -779,10 +799,10 @@ static void rtp_header_init_from_session(rtp_header_t *rtp, RtpSession *session)
  *@param payload_size size of data carried by the rtp packet.
  *@return a rtp packet in a mblk_t (message block) structure.
 **/
-mblk_t * rtp_session_create_packet(RtpSession *session,int header_size, const uint8_t *payload, int payload_size)
+mblk_t * rtp_session_create_packet(RtpSession *session,size_t header_size, const uint8_t *payload, size_t payload_size)
 {
 	mblk_t *mp;
-	int msglen=header_size+payload_size;
+	size_t msglen=header_size+payload_size;
 	rtp_header_t *rtp;
 
 	mp=allocb(msglen,BPRI_MED);
@@ -801,7 +821,7 @@ mblk_t * rtp_session_create_packet(RtpSession *session,int header_size, const ui
 /**
  * Create a packet already including headers
  */
-mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, int packet_size) {
+mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, size_t packet_size) {
 	mblk_t *mp;
 
 	mp=allocb(packet_size,BPRI_MED);
@@ -819,7 +839,7 @@ mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, int packet_size) {
  *	sent with rtp_session_sendm_with_ts().
  *	oRTP will send this packet using libc's sendmsg() (if this function is availlable!) so that there will be no
  *	packet concatenation involving copies to be done in user-space.
- *  @freefn can be NULL, in that case payload will be kept untouched.
+ *  \a freefn can be NULL, in that case payload will be kept untouched.
  *
  * @param session a rtp session.
  * @param payload the data to be sent with this packet
@@ -828,7 +848,7 @@ mblk_t * rtp_session_create_packet_raw(const uint8_t *packet, int packet_size) {
  * @return: a rtp packet in a mblk_t (message block) structure.
 **/
 
-mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *payload, int payload_size, void (*freefn)(void*))
+mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *payload, size_t payload_size, void (*freefn)(void*))
 {
 	mblk_t *mp,*mpayload;
 	int header_size=RTP_FIXED_HEADER_SIZE; /* revisit when support for csrc is done */
@@ -852,7 +872,7 @@ mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *paylo
  * In the header, ssrc and payload_type according to the session's
  *context. Timestamp and seq number are not set, there will be set when the packet is going to be
  *	sent with rtp_session_sendm_with_ts().
- *  @freefn can be NULL, in that case payload will be kept untouched.
+ * \a freefn can be NULL, in that case payload will be kept untouched.
  *
  * @param session a rtp session.
  * @param buffer a buffer that contains first just enough place to write a RTP header, then the data to send.
@@ -860,7 +880,7 @@ mblk_t * rtp_session_create_packet_with_data(RtpSession *session, uint8_t *paylo
  * @param freefn a function that will be called once the buffer is no more needed (the data has been sent).
  * @return a rtp packet in a mblk_t (message block) structure.
 **/
-mblk_t * rtp_session_create_packet_in_place(RtpSession *session,uint8_t *buffer, int size, void (*freefn)(void*) )
+mblk_t * rtp_session_create_packet_in_place(RtpSession *session,uint8_t *buffer, size_t size, void (*freefn)(void*) )
 {
 	mblk_t *mp;
 	rtp_header_t *rtp;
@@ -873,13 +893,12 @@ mblk_t * rtp_session_create_packet_in_place(RtpSession *session,uint8_t *buffer,
 }
 
 
-int
-__rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t packet_ts, uint32_t send_ts)
+ORTP_PUBLIC int __rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t packet_ts, uint32_t send_ts)
 {
 	rtp_header_t *rtp;
 	uint32_t packet_time;
 	int error = 0;
-	int packsize;
+	size_t packsize;
 	RtpScheduler *sched=session->sched;
 	RtpStream *stream=&session->rtp;
 
@@ -942,15 +961,15 @@ __rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t packet_t
 		}
 		session->rtp.snd_last_ts = packet_ts;
 
-		stream->sent_payload_bytes+=packsize-RTP_FIXED_HEADER_SIZE;
+		stream->sent_payload_bytes+=(uint32_t)(packsize-RTP_FIXED_HEADER_SIZE);
 
 		ortp_global_stats.sent += (1+(int)session->duplication_left) * packsize;
-		stream->stats.sent += (1+(int)session->duplication_left) * packsize;
+		session->stats.sent += (1+(int)session->duplication_left) * packsize;
 
 		ortp_global_stats.packet_sent++;
-		stream->stats.packet_sent++;
+		session->stats.packet_sent++;
 
-		stream->stats.packet_dup_sent+=(int)session->duplication_left;
+		session->stats.packet_dup_sent+=(int)session->duplication_left;
 		ortp_global_stats.packet_sent+=(int)session->duplication_left;;
 	}
 
@@ -969,13 +988,13 @@ __rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t packet_t
 }
 
 /**
- *	Send the rtp datagram @mp to the destination set by rtp_session_set_remote_addr()
- *	with timestamp @timestamp. For audio data, the timestamp is the number
+ *	Send the rtp datagram \a packet to the destination set by rtp_session_set_remote_addr()
+ *	with timestamp \a timestamp. For audio data, the timestamp is the number
  *	of the first sample resulting of the data transmitted. See rfc1889 for details.
- *  The packet (@mp) is freed once it is sended.
+ *  The packet (\a packet) is freed once it is sent.
  *
  *@param session a rtp session.
- *@param mp a rtp packet presented as a mblk_t.
+ *@param packet a rtp packet presented as a mblk_t.
  *@param timestamp the timestamp of the data to be sent.
  * @return the number of bytes sent over the network.
 **/
@@ -989,15 +1008,14 @@ int rtp_session_sendm_with_ts(RtpSession *session, mblk_t *packet, uint32_t time
 
 /**
  *	Send a rtp datagram to the destination set by rtp_session_set_remote_addr() containing
- *	the data from @buffer with timestamp @userts. This is a high level function that uses
+ *	the data from \a buffer with timestamp \a userts. This is a high level function that uses
  *	rtp_session_create_packet() and rtp_session_sendm_with_ts() to send the data.
  *
  *@param session a rtp session.
  *@param buffer a buffer containing the data to be sent in a rtp packet.
  *@param len the length of the data buffer, in bytes.
  *@param userts	the timestamp of the data to be sent. Refer to the rfc to know what it is.
- *
- *@param return the number of bytes sent over the network.
+ *@return the number of bytes sent over the network.
 **/
 int
 rtp_session_send_with_ts (RtpSession * session, const uint8_t * buffer, int len,
@@ -1048,11 +1066,31 @@ rtp_session_pick_with_cseq (RtpSession * session, const uint16_t sequence_number
 	return NULL;
 }
 
+static void check_for_seq_number_gap(RtpSession *session, rtp_header_t *rtp) {
+	uint16_t pid;
+	uint16_t i;
+	/*don't check anything before first packet delivered*/
+	if (session->flags & RTP_SESSION_FIRST_PACKET_DELIVERED && RTP_SEQ_IS_STRICTLY_GREATER_THAN(rtp->seq_number, session->rtp.rcv_last_seq + 1)) {
+		uint16_t first_missed_seq = session->rtp.rcv_last_seq + 1;
+		uint16_t diff = rtp->seq_number - first_missed_seq;
+		pid = first_missed_seq;
+		for (i = 0; i <= (diff / 16); i++) {
+			uint16_t seq;
+			uint16_t blp = 0;
+			for (seq = pid + 1; (seq < rtp->seq_number) && ((seq - pid) < 16); seq++) {
+				blp |= (1 << (seq - pid - 1));
+			}
+			rtp_session_send_rtcp_fb_generic_nack(session, pid, blp);
+			pid = seq;
+		}
+	}
+}
+
 /**
  *	Try to get a rtp packet presented as a mblk_t structure from the rtp session.
- *	The @user_ts parameter is relative to the first timestamp of the incoming stream. In other
+ *	The \a user_ts parameter is relative to the first timestamp of the incoming stream. In other
  *	words, the application does not have to know the first timestamp of the stream, it can
- *	simply call for the first time this function with @user_ts=0, and then incrementing it
+ *	simply call for the first time this function with \a user_ts=0, and then incrementing it
  *	as it want. The RtpSession takes care of synchronisation between the stream timestamp
  *	and the user timestamp given here.
  *
@@ -1087,7 +1125,6 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
 	uint32_t ts;
 	uint32_t packet_time;
 	RtpScheduler *sched=session->sched;
-	RtpStream *stream=&session->rtp;
 	int rejected=0;
 	bool_t read_socket=TRUE;
 
@@ -1121,10 +1158,10 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
 	/* check for telephone event first */
 	mp=getq(&session->rtp.tev_rq);
 	if (mp!=NULL){
-		int msgsize=msgdsize(mp);
+		size_t msgsize=msgdsize(mp);
 		ortp_global_stats.recv += msgsize;
-		stream->stats.recv += msgsize;
-		rtp_signal_table_emit2(&session->on_telephone_event_packet,(long)mp);
+		session->stats.recv += msgsize;
+		rtp_signal_table_emit2(&session->on_telephone_event_packet,mp);
 		rtp_session_check_telephone_events(session,mp);
 		freemsg(mp);
 		mp=NULL;
@@ -1160,7 +1197,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
 		}
 	}else mp=getq(&session->rtp.rq);/*no jitter buffer at all*/
 
-	stream->stats.outoftime+=rejected;
+	session->stats.outoftime+=rejected;
 	ortp_global_stats.outoftime+=rejected;
 	session->rtcp_xr_stats.discarded_count += rejected;
 
@@ -1169,10 +1206,10 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
 	end:
 	if (mp != NULL)
 	{
-		int msgsize = msgdsize (mp);	/* evaluate how much bytes (including header) is received by app */
+		size_t msgsize = msgdsize(mp);	/* evaluate how much bytes (including header) is received by app */
 		uint32_t packet_ts;
 		ortp_global_stats.recv += msgsize;
-		stream->stats.recv += msgsize;
+		session->stats.recv += msgsize;
 		rtp = (rtp_header_t *) mp->b_rptr;
 		packet_ts=rtp->timestamp;
 		ortp_debug("Returning mp with ts=%i", packet_ts);
@@ -1181,6 +1218,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
 		{
 			payload_type_changed_notify(session, rtp->paytype);
 		}
+		check_for_seq_number_gap(session, rtp);
 		/* update the packet's timestamp so that it corrected by the
 		adaptive jitter buffer mechanism */
 		if (session->rtp.jittctl.adaptive){
@@ -1237,7 +1275,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
  *	rtp_session_recvm_with_ts() does better job.
  *
  *	Tries to read the bytes of the incoming rtp stream related to timestamp ts. In case
- *	where the user supplied buffer @buffer is not large enough to get all the data
+ *	where the user supplied buffer \a buffer is not large enough to get all the data
  *	related to timestamp ts, then *( have_more) is set to 1 to indicate that the application
  *	should recall the function with the same timestamp to get more data.
  *
@@ -1247,7 +1285,7 @@ rtp_session_recvm_with_ts (RtpSession * session, uint32_t user_ts)
  *	fits the query or not.
  *
  *	Important note: it is clear that the application cannot know the timestamp of the first
- *	packet of the incoming stream, because it can be random. The @ts timestamp given to the
+ *	packet of the incoming stream, because it can be random. The \a ts timestamp given to the
  *	function is used relatively to first timestamp of the stream. In simple words, 0 is a good
  *	value to start calling this function.
  *
@@ -1284,7 +1322,7 @@ int rtp_session_recv_with_ts (RtpSession * session, uint8_t * buffer,
 			if (mp!=NULL) rtp_get_payload(mp,&mp->b_rptr);
 		}
 		if (mp){
-			plen=mp->b_wptr-mp->b_rptr;
+			plen=(int)(mp->b_wptr-mp->b_rptr);
 			if (plen<=len){
 				memcpy(buffer,mp->b_rptr,plen);
 				buffer+=plen;
@@ -1368,7 +1406,7 @@ uint32_t rtp_session_get_current_recv_ts(RtpSession *session){
  * to reset the session in order to resynchronize, or any other action like stopping the call
  * and reporting an error.
  * @param session the rtp session
- * @param ts_step a time interval in miliseconds
+ * @param milisecs a time interval in miliseconds
  *
 **/
 void rtp_session_set_time_jump_limit(RtpSession *session, int milisecs){
@@ -1379,36 +1417,43 @@ void rtp_session_set_time_jump_limit(RtpSession *session, int milisecs){
 	else session->rtp.ts_jump=ts;
 }
 
-/**
- * Closes the rtp and rtcp sockets.
-**/
-void rtp_session_release_sockets(RtpSession *session){
+void _rtp_session_release_sockets(RtpSession *session, bool_t release_transports){
+	
+	if (release_transports){
+		if (session->rtp.gs.tr) {
+			if (session->rtp.gs.tr->t_close)
+				session->rtp.gs.tr->t_close(session->rtp.gs.tr);
+			session->rtp.gs.tr->t_destroy(session->rtp.gs.tr);
+
+		}
+		session->rtp.gs.tr = 0;
+
+		if (session->rtcp.gs.tr)  {
+			if (session->rtcp.gs.tr->t_close)
+				session->rtcp.gs.tr->t_close(session->rtcp.gs.tr);
+			session->rtcp.gs.tr->t_destroy(session->rtcp.gs.tr);
+		}
+		session->rtcp.gs.tr = 0;
+	}
+	
 	if (session->rtp.gs.socket!=(ortp_socket_t)-1) close_socket (session->rtp.gs.socket);
 	if (session->rtcp.gs.socket!=(ortp_socket_t)-1) close_socket (session->rtcp.gs.socket);
 	session->rtp.gs.socket=-1;
 	session->rtcp.gs.socket=-1;
 
-	if (session->rtp.gs.tr) {
-		if (session->rtp.gs.tr->t_close)
-			session->rtp.gs.tr->t_close(session->rtp.gs.tr, session->rtp.gs.tr->data);
-		session->rtp.gs.tr->t_destroy(session->rtp.gs.tr);
-
-	}
-	session->rtp.gs.tr = 0;
-
-	if (session->rtcp.gs.tr)  {
-		if (session->rtcp.gs.tr->t_close)
-			session->rtcp.gs.tr->t_close(session->rtcp.gs.tr, session->rtcp.gs.tr->data);
-		session->rtcp.gs.tr->t_destroy(session->rtcp.gs.tr);
-	}
-	session->rtcp.gs.tr = 0;
-
 	/* don't discard remote addresses, then can be preserved for next use.
 	session->rtp.gs.rem_addrlen=0;
 	session->rtcp.gs.rem_addrlen=0;
 	*/
 }
 
+/**
+ * Closes the rtp and rtcp sockets, and associated RtpTransport.
+**/
+void rtp_session_release_sockets(RtpSession *session){
+	_rtp_session_release_sockets(session, TRUE);
+}
+
 ortp_socket_t rtp_session_get_rtp_socket(const RtpSession *session){
 	return rtp_session_using_transport(session, rtp) ? (session->rtp.gs.tr->t_getsocket)(session->rtp.gs.tr) : session->rtp.gs.socket;
 }
@@ -1448,10 +1493,7 @@ void ortp_stream_clear_aux_addresses(OrtpStream *os){
 }
 
 static void ortp_stream_uninit(OrtpStream *os){
-	if (os->cached_mp) {
-		freemsg(os->cached_mp);
-		os->cached_mp=NULL;
-	}
+	msgb_allocator_uninit(&os->allocator);
 	ortp_stream_clear_aux_addresses(os);
 }
 
@@ -1483,7 +1525,6 @@ void rtp_session_uninit (RtpSession * session)
 		freemsg(session->minimal_sdes);
 
 	session->signal_tables = o_list_free(session->signal_tables);
-	msgb_allocator_uninit(&session->allocator);
 
 	if (session->net_sim_ctx)
 		ortp_network_simulator_destroy(session->net_sim_ctx);
@@ -1494,7 +1535,7 @@ void rtp_session_uninit (RtpSession * session)
 	if (rtcp_meta_transport)
 		meta_rtp_transport_destroy(rtcp_meta_transport);
 
-#if (_WIN32_WINNT >= 0x0600) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if (_WIN32_WINNT >= 0x0600) && defined(ORTP_WINDOWS_DESKTOP)
 	if (session->rtp.QoSFlowID != 0)
 	{
 		OSVERSIONINFOEX ovi;
@@ -1505,24 +1546,17 @@ void rtp_session_uninit (RtpSession * session)
 		ortp_message("check OS support for qwave.lib: %i %i %i\n",
 					ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber);
 		if (ovi.dwMajorVersion > 5) {
-
-			if (FAILED(__HrLoadAllImportsForDll("qwave.dll"))) {
-				ortp_warning("Failed to load qwave.dll: no QoS available\n" );
-			}
-			else
-			{
-				BOOL QoSResult;
-				QoSResult = QOSRemoveSocketFromFlow(session->rtp.QoSHandle,
-													0,
-													session->rtp.QoSFlowID,
-													0);
-
-				if (QoSResult != TRUE){
-					ortp_error("QOSRemoveSocketFromFlow failed to end a flow with error %d\n",
-							GetLastError());
-				}
-				session->rtp.QoSFlowID=0;
+			BOOL QoSResult;
+			QoSResult = QOSRemoveSocketFromFlow(session->rtp.QoSHandle,
+												0,
+												session->rtp.QoSFlowID,
+												0);
+
+			if (QoSResult != TRUE){
+				ortp_error("QOSRemoveSocketFromFlow failed to end a flow with error %d\n",
+						GetLastError());
 			}
+			session->rtp.QoSFlowID=0;
 		}
 	}
 
@@ -1593,7 +1627,7 @@ void rtp_session_reset (RtpSession * session)
 	session->rtp.sent_payload_bytes=0;
 	rtp_session_clear_send_error_code(session);
 	rtp_session_clear_recv_error_code(session);
-	rtp_stats_reset(&session->rtp.stats);
+	rtp_stats_reset(&session->stats);
 	rtp_session_resync(session);
 	session->ssrc_set=FALSE;
 }
@@ -1602,7 +1636,7 @@ void rtp_session_reset (RtpSession * session)
  * Retrieve the session's statistics.
 **/
 const rtp_stats_t * rtp_session_get_stats(const RtpSession *session){
-	return &session->rtp.stats;
+	return &session->stats;
 }
 
 /**
@@ -1663,7 +1697,7 @@ void rtp_session_rtcp_set_delay_value( struct _RtpSession *s, const unsigned int
 }
 
 void rtp_session_reset_stats(RtpSession *session){
-	memset(&session->rtp.stats,0,sizeof(rtp_stats_t));
+	memset(&session->stats,0,sizeof(rtp_stats_t));
 }
 
 /**
@@ -1699,6 +1733,14 @@ rtp_session_set_symmetric_rtp (RtpSession * session, bool_t yesno)
 	session->symmetric_rtp =yesno;
 }
 
+void rtp_session_enable_rtcp_mux(RtpSession *session, bool_t yesno){
+	session->rtcp_mux = yesno;
+}
+
+bool_t rtp_session_rtcp_mux_enabled(RtpSession *session){
+	return session->rtcp_mux;
+}
+
 /**
  *	If yesno is TRUE, thus a connect() syscall is done on the socket to
  *	the destination address set by rtp_session_set_remote_addr(), or
@@ -1719,10 +1761,10 @@ void rtp_session_set_connected_mode(RtpSession *session, bool_t yesno){
 static float compute_bw(struct timeval *orig, unsigned int bytes, const struct timeval *current){
 	float bw;
 	float time;
-	
-	time=(float)(current->tv_sec - orig->tv_sec) +
-		((float)(current->tv_usec - orig->tv_usec)*1e-6);
-	bw=((float)bytes)*8/(time+0.0001);
+
+	time=(float)((double)(current->tv_sec - orig->tv_sec) +
+		((double)(current->tv_usec - orig->tv_usec)*1e-6));
+	bw=((float)bytes)*8/(time+0.0001f);
 	/*+0.0001 avoids a division by zero without changing the results significatively*/
 	*orig=*current;
 	return bw;
@@ -1741,7 +1783,7 @@ static void compute_send_bandwidth(OrtpStream *os, const struct timeval *current
 float rtp_session_compute_recv_bandwidth(RtpSession *session) {
 	struct timeval current;
 	ortp_gettimeofday(&current,NULL);
-	
+
 	compute_recv_bandwidth(&session->rtp.gs, &current);
 	compute_recv_bandwidth(&session->rtcp.gs, &current);
 	return session->rtp.gs.download_bw + session->rtcp.gs.download_bw;
@@ -1750,7 +1792,7 @@ float rtp_session_compute_recv_bandwidth(RtpSession *session) {
 float rtp_session_compute_send_bandwidth(RtpSession *session) {
 	struct timeval current;
 	ortp_gettimeofday(&current,NULL);
-	
+
 	compute_send_bandwidth(&session->rtp.gs, &current);
 	compute_send_bandwidth(&session->rtcp.gs, &current);
 	return session->rtp.gs.upload_bw + session->rtcp.gs.upload_bw;
@@ -1861,7 +1903,7 @@ int rtp_get_payload(mblk_t *packet, unsigned char **start){
 			tmp=packet->b_cont->b_rptr+(header_len- (packet->b_wptr-packet->b_rptr));
 			if (tmp<=packet->b_cont->b_wptr){
 				*start=tmp;
-				return packet->b_cont->b_wptr-tmp;
+				return (int)(packet->b_cont->b_wptr-tmp);
 			}
 		}
 		ortp_warning("Invalid RTP packet");
@@ -1874,14 +1916,14 @@ int rtp_get_payload(mblk_t *packet, unsigned char **start){
 		}
 	}
 	*start=tmp;
-	return packet->b_wptr-tmp;
+	return (int)(packet->b_wptr-tmp);
 }
 
 /**
  * Obtain the extension header if any.
  * @param packet the RTP packet.
  * @param profile the profile field of the extension header
- * @param start_ext_header pointer that will be set to the beginning of the payload of the extension header.
+ * @param start_ext pointer that will be set to the beginning of the payload of the extension header.
  * @return the size of the extension in bytes (the payload size, it can be 0), -1 if parsing of the extension header failed or if no extension is present.
 **/
 int rtp_get_extheader(mblk_t *packet, uint16_t *profile, uint8_t **start_ext){
@@ -1935,7 +1977,7 @@ uint32_t rtp_session_time_to_ts(RtpSession *session, int millisecs){
 	if (payload == NULL)
 	{
 		ortp_warning
-			("rtp_session_ts_to_t: use of unsupported payload type %d.", session->snd.pt);
+			("rtp_session_time_to_ts: use of unsupported payload type %d.", session->snd.pt);
 		return 0;
 	}
 	/* the return value is in milisecond */
@@ -2020,7 +2062,8 @@ void meta_rtp_set_session(RtpSession *s,MetaRtpTransportImpl *m){
 }
 
 int meta_rtp_transport_sendto(RtpTransport *t, mblk_t *msg , int flags, const struct sockaddr *to, socklen_t tolen) {
-	int prev_ret,ret;
+	size_t prev_ret;
+	int ret;
 	OList *elem;
 	MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
 
@@ -2042,15 +2085,15 @@ int meta_rtp_transport_sendto(RtpTransport *t, mblk_t *msg , int flags, const st
 	if (m->endpoint!=NULL){
 		ret=m->endpoint->t_sendto(m->endpoint,msg,flags,to,tolen);
 	}else{
-		ret=_rtp_session_sendto(t->session, m->is_rtp,msg,flags,to,tolen);
+		ret=rtp_session_sendto(t->session, m->is_rtp,msg,flags,to,tolen);
 	}
 	return ret;
 }
 
 /**
- * allow a modifier to inject a packet wich will be treated by successive modifiers
+ * allow a modifier to inject a packet which will be treated by successive modifiers
  */
-int meta_rtp_transport_modifier_inject_packet(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags) {
+int meta_rtp_transport_modifier_inject_packet_to_send(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg, int flags) {
 	struct sockaddr *to;
 	socklen_t tolen;
 	MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
@@ -2063,57 +2106,102 @@ int meta_rtp_transport_modifier_inject_packet(const RtpTransport *t, RtpTranspor
 	if (m->is_rtp) {
 		to=(struct sockaddr*)&t->session->rtp.gs.rem_addr;
 		tolen=t->session->rtp.gs.rem_addrlen;
-	} else { 
-		to=(struct sockaddr*)&t->session->rtcp.gs.rem_addr;
-		tolen=t->session->rtcp.gs.rem_addrlen;
+	} else {
+		to = (struct sockaddr*)&t->session->rtcp.gs.rem_addr;
+		tolen = t->session->rtcp.gs.rem_addrlen;
 	}
-	return meta_rtp_transport_modifier_inject_packet_to(t,tpm,msg,flags,to,tolen);
+	return meta_rtp_transport_modifier_inject_packet_to_send_to(t, tpm, msg, flags, to, tolen);
 }
+
 /**
- * allow a modifier to inject a packet wich will be treated by successive modifiers
+ * allow a modifier to inject a packet which will be treated by successive modifiers
  */
-int meta_rtp_transport_modifier_inject_packet_to(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg , int flags,const struct sockaddr *to, socklen_t tolen) {
-	int prev_ret,ret;
-	OList *elem;
-	bool_t packetInjected = tpm?FALSE:TRUE; /*if no modifier, start from the begening*/
+int meta_rtp_transport_modifier_inject_packet_to_send_to(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg, int flags, const struct sockaddr *to, socklen_t tolen) {
+	size_t prev_ret;
+	int ret;
+	bool_t foundMyself = tpm ? FALSE : TRUE; /*if no modifier, start from the beginning*/
 	MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
+	OList *elem = m->modifiers;
 
-	if (!m->has_set_session){
-		meta_rtp_set_session(t->session,m);
+	if (!m->has_set_session) {
+		meta_rtp_set_session(t->session, m);
 	}
 
-	prev_ret=msgdsize(msg);
-	for (elem=m->modifiers;elem!=NULL;elem=o_list_next(elem)){
-
+	prev_ret = msgdsize(msg);
+	for (;elem != NULL; elem = o_list_next(elem)) {
 		/* run modifiers only after packet injection, the modifier given in parameter is not applied */
-		if (packetInjected == TRUE) {
-			RtpTransportModifier *rtm=(RtpTransportModifier*)elem->data;
-			ret = rtm->t_process_on_send(rtm,msg);
+		RtpTransportModifier *rtm = (RtpTransportModifier*)elem->data;
+		if (foundMyself == TRUE) {
+			ret = rtm->t_process_on_send(rtm, msg);
 
-			if (ret<=0){
+			if (ret <= 0) {
 				// something went wrong in the modifier (failed to encrypt for instance)
 				return ret;
 			}
-			msg->b_wptr+=(ret-prev_ret);
-			prev_ret=ret;
+			msg->b_wptr += (ret - prev_ret);
+			prev_ret = ret;
 		}
 
 		/* check if we must inject the packet */
-		if (elem->data == tpm) {
-			packetInjected = TRUE;
+		if (rtm == tpm) {
+			foundMyself = TRUE;
 		}
+	}
 
+	if (m->endpoint != NULL) {
+		ret = m->endpoint->t_sendto(m->endpoint, msg, flags, to, tolen);
+	} else {
+		ret = rtp_session_sendto(t->session, m->is_rtp, msg, flags, to, tolen);
 	}
+	update_sent_bytes(&t->session->rtp.gs, ret);
+	return ret;
+}
 
-	if (m->endpoint!=NULL){
-		ret=m->endpoint->t_sendto(m->endpoint,msg,flags,to,tolen);
-	}else{
-		ret=_rtp_session_sendto(t->session, m->is_rtp,msg,flags,to,tolen);
+/**
+ * allow a modifier to inject a packet which will be treated by successive modifiers
+ */
+int meta_rtp_transport_modifier_inject_packet_to_recv(const RtpTransport *t, RtpTransportModifier *tpm, mblk_t *msg, int flags) {
+	int ret = 0;
+	size_t prev_ret;
+	bool_t foundMyself = tpm ? FALSE : TRUE; /*if no modifier, start from the beginning*/
+	MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
+	OList *elem = m->modifiers;
+	OList *last_elem = NULL;
+
+	if (!m->has_set_session) {
+		meta_rtp_set_session(t->session, m);
 	}
+
+	for (;elem != NULL; elem = o_list_next(elem)) {
+		last_elem = elem;
+	}
+
+	prev_ret = msgdsize(msg);
+	for (;last_elem != NULL; last_elem = o_list_prev(last_elem)) {
+		/* run modifiers only after packet injection, the modifier given in parameter is not applied */
+		RtpTransportModifier *rtm = (RtpTransportModifier*)last_elem->data;
+		if (foundMyself == TRUE) {
+			ret = rtm->t_process_on_receive(rtm, msg);
+			if (ret < 0) {
+				// something went wrong in the modifier (failed to decrypt for instance)
+				break;
+			}
+			msg->b_wptr += (ret - prev_ret);
+			prev_ret = ret;
+		}
+
+		/* check if we must inject the packet */
+		if (rtm == tpm) {
+			foundMyself = TRUE;
+		}
+	}
+
+	rtp_session_process_incoming(t->session, msg, m->is_rtp, msg->reserved1);
+
 	return ret;
 }
 
-int  meta_rtp_transport_recvfrom(RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen) {
+int meta_rtp_transport_recvfrom(RtpTransport *t, mblk_t *msg, int flags, struct sockaddr *from, socklen_t *fromlen) {
 	int ret,prev_ret;
 	MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
 	OList *elem=m->modifiers;
@@ -2125,8 +2213,13 @@ int  meta_rtp_transport_recvfrom(RtpTransport *t, mblk_t *msg, int flags, struct
 
 	if (m->endpoint!=NULL){
 		ret=m->endpoint->t_recvfrom(m->endpoint,msg,flags,from,fromlen);
+		if (ret > 0) {
+			/*store recv addr for use by modifiers*/
+			memcpy(&msg->net_addr,from,*fromlen);
+			msg->net_addrlen = *fromlen;
+		}
 	}else{
-		ret=rtp_session_rtp_recv_abstract(m->is_rtp?t->session->rtp.gs.socket:t->session->rtcp.gs.socket,msg,flags,from,fromlen);
+		ret=rtp_session_recvfrom(t->session,m->is_rtp,msg,flags,from,fromlen);
 	}
 
 	/*received packet must be treated in reversed order: first in last out
@@ -2145,10 +2238,6 @@ int  meta_rtp_transport_recvfrom(RtpTransport *t, mblk_t *msg, int flags, struct
 	prev_ret=ret;
 	msg->b_wptr+=ret;
 
-	/*store recv addr for use by modifiers*/
-	memcpy(&msg->net_addr,from,*fromlen);
-	msg->net_addrlen = *fromlen;
-
 	for (;last_elem!=NULL;last_elem=o_list_prev(last_elem)){
 		RtpTransportModifier *rtm=(RtpTransportModifier*)last_elem->data;
 		ret = rtm->t_process_on_receive(rtm,msg);
@@ -2165,10 +2254,10 @@ int  meta_rtp_transport_recvfrom(RtpTransport *t, mblk_t *msg, int flags, struct
 	return ret;
 }
 
-void  meta_rtp_transport_close(RtpTransport *t, void *user_data) {
-	MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)user_data;
+void  meta_rtp_transport_close(RtpTransport *t) {
+	MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)t->data;
 	if (m->endpoint!=NULL){
-		m->endpoint->t_close(m->endpoint,m->endpoint->data);
+		m->endpoint->t_close(m->endpoint);
 	}
 }
 
@@ -2217,6 +2306,7 @@ void meta_rtp_transport_destroy(RtpTransport *tp) {
 
 	for (elem=m->modifiers;elem!=NULL;elem=o_list_next(elem)){
 		RtpTransportModifier *rtm=(RtpTransportModifier*)elem->data;
+		rtm->transport = NULL;
 		rtm->t_destroy(rtm);
 	}
 	o_list_free(m->modifiers);
@@ -2227,6 +2317,7 @@ void meta_rtp_transport_destroy(RtpTransport *tp) {
 
 void meta_rtp_transport_append_modifier(RtpTransport *tp,RtpTransportModifier *tpm) {
 	MetaRtpTransportImpl *m = (MetaRtpTransportImpl*)tp->data;
+	tpm->transport = tp;
 	m->modifiers=o_list_append(m->modifiers, tpm);
 	if(m->has_set_session) {
 		tpm->session = tp->session;
@@ -2235,3 +2326,37 @@ void meta_rtp_transport_append_modifier(RtpTransport *tp,RtpTransportModifier *t
 bool_t rtp_session_get_symmetric_rtp(const RtpSession *session) {
 	return session->symmetric_rtp;
 }
+
+int rtp_session_splice(RtpSession *session, RtpSession *to_session){
+	if (session->spliced_session){
+		ortp_error("rtp_session_splice(): session %p already splicing into session %p", session, session->spliced_session);
+		return -1;
+	}
+	session->spliced_session = to_session;
+	to_session->is_spliced = TRUE;
+	ortp_message("rtp_session_splice(): session %p splicing to %p", session, to_session);
+	return 0;
+}
+
+int rtp_session_unsplice(RtpSession *session, RtpSession *to_session){
+	if (session->spliced_session != to_session){
+		ortp_error("rtp_session_unsplice() session %p is not spliced to session %p", session, to_session);
+		return -1;
+	}
+	session->spliced_session = NULL;
+	to_session->is_spliced = FALSE;
+	ortp_message("rtp_session_unsplice(): session %p no longer splicing to %p", session, to_session);
+	return 0;
+}
+
+/*
+ * send packet through the peered session, the mblk_t is not freed.
+**/
+void rtp_session_do_splice(RtpSession *session, mblk_t *packet, bool_t is_rtp){
+	RtpSession *peer = session->spliced_session;
+	if (peer){
+		OrtpStream *os = is_rtp ? &session->rtp.gs : &session->rtcp.gs;
+		_ortp_sendto(os->socket, packet, 0, (struct sockaddr*)&os->rem_addr, os->rem_addrlen);
+	}
+}
+
diff --git a/src/rtpsession_inet.c b/src/rtpsession_inet.c
index dcb1152..3f11a5a 100644
--- a/src/rtpsession_inet.c
+++ b/src/rtpsession_inet.c
@@ -25,6 +25,7 @@
 #ifdef HAVE_CONFIG_H
 #include "ortp-config.h" /*needed for HAVE_SYS_UIO_H and HAVE_ARC4RANDOM */
 #endif
+#include <bctoolbox/port.h>
 #include "ortp/ortp.h"
 #include "utils.h"
 #include "ortp/rtpsession.h"
@@ -33,12 +34,12 @@
 #if (_WIN32_WINNT >= 0x0600)
 #include <delayimp.h>
 #undef ExternC
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#ifdef ORTP_WINDOWS_DESKTOP
 #include <QOS2.h>
 #endif
 #endif
 
-#if (defined(WIN32) || defined(_WIN32_WCE)) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if (defined(_WIN32) || defined(_WIN32_WCE)) && defined(ORTP_WINDOWS_DESKTOP)
 #include <mswsock.h>
 #endif
 
@@ -49,19 +50,33 @@
 
 #define can_connect(s)	( (s)->use_connect && !(s)->symmetric_rtp)
 
-#if defined(WIN32) || defined(_WIN32_WCE)
+#if defined(_WIN32) || defined(_WIN32_WCE)
 #ifndef WSAID_WSARECVMSG
 /* http://source.winehq.org/git/wine.git/blob/HEAD:/include/mswsock.h */
 #define WSAID_WSARECVMSG {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}
+#ifndef MAX_NATURAL_ALIGNMENT
 #define MAX_NATURAL_ALIGNMENT sizeof(DWORD)
+#endif
+#ifndef TYPE_ALIGNMENT
 #define TYPE_ALIGNMENT(t) FIELD_OFFSET(struct { char x; t test; },test)
+#endif
 typedef WSACMSGHDR *LPWSACMSGHDR;
+#ifndef WSA_CMSGHDR_ALIGN
 #define WSA_CMSGHDR_ALIGN(length) (((length) + TYPE_ALIGNMENT(WSACMSGHDR)-1) & (~(TYPE_ALIGNMENT(WSACMSGHDR)-1)))
+#endif
+#ifndef WSA_CMSGDATA_ALIGN
 #define WSA_CMSGDATA_ALIGN(length) (((length) + MAX_NATURAL_ALIGNMENT-1) & (~(MAX_NATURAL_ALIGNMENT-1)))
+#endif
+#ifndef WSA_CMSG_FIRSTHDR
 #define WSA_CMSG_FIRSTHDR(msg) (((msg)->Control.len >= sizeof(WSACMSGHDR)) ? (LPWSACMSGHDR)(msg)->Control.buf : (LPWSACMSGHDR)NULL)
+#endif
+#ifndef WSA_CMSG_NXTHDR
 #define WSA_CMSG_NXTHDR(msg,cmsg) ((!(cmsg)) ? WSA_CMSG_FIRSTHDR(msg) : ((((u_char *)(cmsg) + WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len) + sizeof(WSACMSGHDR)) > (u_char *)((msg)->Control.buf) + (msg)->Control.len) ? (LPWSACMSGHDR)NULL : (LPWSACMSGHDR)((u_char *)(cmsg) + WSA_CMSGHDR_ALIGN((cmsg)->cmsg_len))))
+#endif
+#ifndef WSA_CMSG_DATA
 #define WSA_CMSG_DATA(cmsg) ((u_char *)(cmsg) + WSA_CMSGDATA_ALIGN(sizeof(WSACMSGHDR)))
 #endif
+#endif
 #undef CMSG_FIRSTHDR
 #define CMSG_FIRSTHDR WSA_CMSG_FIRSTHDR
 #undef CMSG_NXTHDR
@@ -73,7 +88,7 @@ static LPFN_WSARECVMSG ortp_WSARecvMsg = NULL;
 
 #endif
 
-#if defined(WIN32) || defined(_WIN32_WCE) || defined(__QNX__)
+#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__QNX__)
 /* Mingw32 does not define AI_V4MAPPED, however it is supported starting from Windows Vista. QNX also does not define AI_V4MAPPED. */
 #	ifndef AI_V4MAPPED
 #	define AI_V4MAPPED 0x00000800
@@ -93,7 +108,7 @@ static LPFN_WSARECVMSG ortp_WSARecvMsg = NULL;
 static int
 _rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr, int rtp_port, const char * rtcp_addr, int rtcp_port, bool_t is_aux);
 
-static bool_t try_connect(int fd, const struct sockaddr *dest, socklen_t addrlen){
+static bool_t try_connect(ortp_socket_t fd, const struct sockaddr *dest, socklen_t addrlen){
 	if (connect(fd,dest,addrlen)<0){
 		ortp_warning("Could not connect() socket: %s",getSocketError());
 		return FALSE;
@@ -103,18 +118,11 @@ static bool_t try_connect(int fd, const struct sockaddr *dest, socklen_t addrlen
 
 static int set_multicast_group(ortp_socket_t sock, const char *addr){
 #ifndef __hpux
-	struct addrinfo hints, *res;
+	struct addrinfo *res;
 	int err;
 
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = AF_UNSPEC;
-	hints.ai_socktype = SOCK_DGRAM;
-
-	err = getaddrinfo(addr,"0", &hints, &res);
-	if (err!=0) {
-		ortp_warning ("Error in getaddrinfo on (addr=%s): %s", addr, gai_strerror(err));
-		return -1;
-	}
+	res = bctbx_name_to_addrinfo(AF_UNSPEC, SOCK_DGRAM, addr, 0);
+	if (res == NULL) return -1;
 
 	switch (res->ai_family){
 		case AF_INET:
@@ -157,22 +165,13 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
 	int err;
 	int optval = 1;
 	ortp_socket_t sock=-1;
-	char num[8];
-	struct addrinfo hints, *res0, *res;
+	struct addrinfo *res0, *res;
 
 	if (*port==-1) *port=0;
 	if (*port==0) reuse_addr=FALSE;
 
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = AF_UNSPEC;
-	hints.ai_socktype = SOCK_DGRAM;
-
-	snprintf(num, sizeof(num), "%d",*port);
-	err = getaddrinfo(addr,num, &hints, &res0);
-	if (err!=0) {
-		ortp_warning ("Error in getaddrinfo on (addr=%s port=%i): %s", addr, *port, gai_strerror(err));
-		return -1;
-	}
+	res0 = bctbx_name_to_addrinfo(AF_UNSPEC, SOCK_DGRAM, addr, *port);
+	if (res0 == NULL) return -1;
 
 	for (res = res0; res; res = res->ai_next) {
 		sock = socket(res->ai_family, res->ai_socktype, 0);
@@ -234,10 +233,10 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
 		}
 
 		*sock_family=res->ai_family;
-		err = bind (sock, res->ai_addr, res->ai_addrlen);
+		err = bind(sock, res->ai_addr, (int)res->ai_addrlen);
 		if (err != 0){
 			ortp_error ("Fail to bind rtp socket to (addr=%s port=%i) : %s.", addr, *port, getSocketError());
-			close_socket (sock);
+			close_socket(sock);
 			sock=-1;
 			continue;
 		}
@@ -246,11 +245,11 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
 		break;
 	}
 	memcpy(bound_addr,res0->ai_addr,res0->ai_addrlen);
-	*bound_addr_len=res0->ai_addrlen;
+	*bound_addr_len=(socklen_t)res0->ai_addrlen;
 
-	freeaddrinfo(res0);
+	bctbx_freeaddrinfo(res0);
 
-#if defined(WIN32) || defined(_WIN32_WCE)
+#if defined(_WIN32) || defined(_WIN32_WCE)
 	if (ortp_WSARecvMsg == NULL) {
 		GUID guid = WSAID_WSARECVMSG;
 		DWORD bytes_returned;
@@ -268,23 +267,21 @@ static ortp_socket_t create_and_bind(const char *addr, int *port, int *sock_fami
 			err=getsockname(sock,(struct sockaddr*)&saddr,&slen);
 			if (err==-1){
 				ortp_error("getsockname(): %s",getSocketError());
-				close(sock);
+				close_socket(sock);
 				return (ortp_socket_t)-1;
 			}
-			err=getnameinfo((struct sockaddr*)&saddr, slen, NULL, 0, num, sizeof(num), NI_NUMERICHOST | NI_NUMERICSERV);
+			err = bctbx_sockaddr_to_ip_address((struct sockaddr *)&saddr, slen, NULL, 0, port);
 			if (err!=0){
-				ortp_error("getnameinfo(): %s",gai_strerror(err));
-				close(sock);
+				close_socket(sock);
 				return (ortp_socket_t)-1;
 			}
-			*port=atoi(num);
 		}
 
 	}
 	return sock;
 }
 
-static void set_socket_sizes(int sock, unsigned int sndbufsz, unsigned int rcvbufsz){
+static void set_socket_sizes(ortp_socket_t sock, unsigned int sndbufsz, unsigned int rcvbufsz){
 	int err;
 	bool_t done=FALSE;
 	if (sndbufsz>0){
@@ -321,16 +318,16 @@ static void set_socket_sizes(int sock, unsigned int sndbufsz, unsigned int rcvbu
 
 /**
  *rtp_session_set_local_addr:
- *@session:		a rtp session freshly created.
- *@addr:		a local IP address in the xxx.xxx.xxx.xxx form.
- *@rtp_port:		a local port or -1 to let oRTP choose the port randomly
- *@rtcp_port:		a local port or -1 to let oRTP choose the port randomly
+ *@param session:		a rtp session freshly created.
+ *@param addr:		a local IP address in the xxx.xxx.xxx.xxx form.
+ *@param rtp_port:		a local port or -1 to let oRTP choose the port randomly
+ *@param rtcp_port:		a local port or -1 to let oRTP choose the port randomly
  *
  *	Specify the local addr to be use to listen for rtp packets or to send rtp packet from.
  *	In case where the rtp session is send-only, then it is not required to call this function:
  *	when calling rtp_session_set_remote_addr(), if no local address has been set, then the
  *	default INADRR_ANY (0.0.0.0) IP address with a random port will be used. Calling
- *	rtp_sesession_set_local_addr() is mandatory when the session is recv-only or duplex.
+ *	rtp_session_set_local_addr() is mandatory when the session is recv-only or duplex.
  *
  *	Returns: 0 on success.
 **/
@@ -342,7 +339,7 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por
 	int sockfamily;
 	if (session->rtp.gs.socket!=(ortp_socket_t)-1){
 		/* don't rebind, but close before*/
-		rtp_session_release_sockets(session);
+		_rtp_session_release_sockets(session, FALSE);
 	}
 	/* try to bind the rtp port */
 
@@ -367,6 +364,7 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por
 		rtp_session_set_dscp( session, -1 );
 		rtp_session_set_multicast_ttl( session, -1 );
 		rtp_session_set_multicast_loopback( session, -1 );
+		if (session->use_pktinfo) rtp_session_set_pktinfo(session, TRUE);
 		ortp_message("RtpSession bound to [%s] ports [%i] [%i]", addr, rtp_port, rtcp_port);
 		return 0;
 	}
@@ -374,6 +372,32 @@ rtp_session_set_local_addr (RtpSession * session, const char * addr, int rtp_por
 	return -1;
 }
 
+static void _rtp_session_recreate_sockets(RtpSession *session){
+	char addr[NI_MAXHOST];
+	int err = bctbx_sockaddr_to_ip_address((struct sockaddr *)&session->rtp.gs.loc_addr, session->rtp.gs.loc_addrlen, addr, sizeof(addr), NULL);
+	if (err != 0) return;
+	/*re create and bind sockets as they were done previously*/
+	ortp_message("RtpSession %p is going to re-create its socket.", session);
+	rtp_session_set_local_addr(session, addr, session->rtp.gs.loc_port, session->rtcp.gs.loc_port);
+}
+
+static void _rtp_session_check_socket_refresh(RtpSession *session){
+	if (session->flags & RTP_SESSION_SOCKET_REFRESH_REQUESTED){
+		session->flags &= ~RTP_SESSION_SOCKET_REFRESH_REQUESTED;
+		_rtp_session_recreate_sockets(session);
+	}
+}
+
+/**
+ * Requests the session to re-create and bind its RTP and RTCP sockets same as they are currently.
+ * This is used when a change in the routing rules of the host or process was made, in order to have
+ * this routing rules change taking effect on the RTP/RTCP packets sent by the session.
+**/
+void rtp_session_refresh_sockets(RtpSession *session){
+	if (session->rtp.gs.socket != (ortp_socket_t) -1){
+		session->flags |= RTP_SESSION_SOCKET_REFRESH_REQUESTED;
+	}
+}
 
 int rtp_session_join_multicast_group(RtpSession *session, const char *ip){
 	int err;
@@ -388,8 +412,8 @@ int rtp_session_join_multicast_group(RtpSession *session, const char *ip){
 
 /**
  *rtp_session_set_pktinfo:
- *@session: a rtp session
- *@activate: activation flag (0 to deactivate, other value to activate)
+ *@param session: a rtp session
+ *@param activate: activation flag (0 to deactivate, other value to activate)
  *
  * (De)activates packet info for incoming and outgoing packets.
  *
@@ -400,18 +424,18 @@ int rtp_session_set_pktinfo(RtpSession *session, int activate)
 {
 	int retval;
 	int optname;
-#if defined(WIN32) || defined(_WIN32_WCE)
+#if defined(_WIN32) || defined(_WIN32_WCE)
 	char optval[sizeof(DWORD)];
 	int optlen = sizeof(optval);
 #else
 	int *optval = &activate;
 	int optlen = sizeof(activate);
 #endif
-
+	session->use_pktinfo = activate;
 	// Dont't do anything if socket hasn't been created yet
 	if (session->rtp.gs.socket == (ortp_socket_t)-1) return 0;
 
-#if defined(WIN32) || defined(_WIN32_WCE)
+#if defined(_WIN32) || defined(_WIN32_WCE)
 	memset(optval, activate, sizeof(optval));
 #endif
 
@@ -448,8 +472,8 @@ int rtp_session_set_pktinfo(RtpSession *session, int activate)
 
 /**
  *rtp_session_set_multicast_ttl:
- *@session: a rtp session
- *@ttl: desired Multicast Time-To-Live
+ *@param session: a rtp session
+ *@param ttl: desired Multicast Time-To-Live
  *
  * Sets the TTL (Time-To-Live) for outgoing multicast packets.
  *
@@ -502,7 +526,7 @@ int rtp_session_set_multicast_ttl(RtpSession *session, int ttl)
 
 /**
  *rtp_session_get_multicast_ttl:
- *@session: a rtp session
+ *@param session: a rtp session
  *
  * Returns the TTL (Time-To-Live) for outgoing multicast packets.
  *
@@ -514,9 +538,8 @@ int rtp_session_get_multicast_ttl(RtpSession *session)
 
 
 /**
- *rtp_session_set_multicast_loopback:
- *@session: a rtp session
- *@ttl: desired Multicast Time-To-Live
+ *@param session: a rtp session
+ *@param yesno: desired Multicast Time-To-Live
  *
  * Sets the TTL (Time-To-Live) for outgoing multicast packets.
  *
@@ -574,7 +597,7 @@ int rtp_session_set_multicast_loopback(RtpSession *session, int yesno)
 
 /**
  *rtp_session_get_multicast_loopback:
- *@session: a rtp session
+ *@param session: a rtp session
  *
  * Returns the multicast loopback state of rtp session (true or false).
  *
@@ -586,8 +609,8 @@ int rtp_session_get_multicast_loopback(RtpSession *session)
 
 /**
  *rtp_session_set_dscp:
- *@session: a rtp session
- *@dscp: desired DSCP PHB value
+ *@param session: a rtp session
+ *@param dscp: desired DSCP PHB value
  *
  * Sets the DSCP (Differentiated Services Code Point) for outgoing RTP packets.
  *
@@ -599,7 +622,7 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
 	int tos;
 	int proto;
 	int value_type;
-#if (_WIN32_WINNT >= 0x0600)
+#if (_WIN32_WINNT >= 0x0600) && defined(ORTP_WINDOWS_DESKTOP)
 	OSVERSIONINFOEX ovi;
 #endif
 
@@ -609,7 +632,7 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
 	// Don't do anything if socket hasn't been created yet
 	if (session->rtp.gs.socket == (ortp_socket_t)-1) return 0;
 
-#if (_WIN32_WINNT >= 0x0600) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if (_WIN32_WINNT >= 0x0600) && defined(ORTP_WINDOWS_DESKTOP)
 	memset(&ovi, 0, sizeof(ovi));
 	ovi.dwOSVersionInfoSize = sizeof(ovi);
 	GetVersionEx((LPOSVERSIONINFO) & ovi);
@@ -617,53 +640,46 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
 	ortp_message("check OS support for qwave.lib: %i %i %i\n",
 				ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber);
 	if (ovi.dwMajorVersion > 5) {
-
-		if (FAILED(__HrLoadAllImportsForDll("qwave.dll"))) {
-			ortp_warning("Failed to load qwave.dll: no QoS available\n" );
-		}
+		if (session->dscp==0)
+			tos=QOSTrafficTypeBestEffort;
+		else if (session->dscp==0x8)
+			tos=QOSTrafficTypeBackground;
+		else if (session->dscp==0x28)
+			tos=QOSTrafficTypeAudioVideo;
+		else if (session->dscp==0x38)
+			tos=QOSTrafficTypeVoice;
 		else
-		{
-			if (session->dscp==0)
-				tos=QOSTrafficTypeBestEffort;
-			else if (session->dscp==0x8)
-				tos=QOSTrafficTypeBackground;
-			else if (session->dscp==0x28)
-				tos=QOSTrafficTypeAudioVideo;
-			else if (session->dscp==0x38)
-				tos=QOSTrafficTypeVoice;
-			else
-				tos=QOSTrafficTypeExcellentEffort; /* 0x28 */
-
-			if (session->rtp.QoSHandle==NULL) {
-				QOS_VERSION version;
-				BOOL QoSResult;
-
-				version.MajorVersion = 1;
-				version.MinorVersion = 0;
-
-				QoSResult = QOSCreateHandle(&version, &session->rtp.QoSHandle);
-
-				if (QoSResult != TRUE){
-					ortp_error("QOSCreateHandle failed to create handle with error %d\n",
-						GetLastError());
-					retval=-1;
-				}
+			tos=QOSTrafficTypeExcellentEffort; /* 0x28 */
+
+		if (session->rtp.QoSHandle==NULL) {
+			QOS_VERSION version;
+			BOOL QoSResult;
+
+			version.MajorVersion = 1;
+			version.MinorVersion = 0;
+
+			QoSResult = QOSCreateHandle(&version, &session->rtp.QoSHandle);
+
+			if (QoSResult != TRUE){
+				ortp_error("QOSCreateHandle failed to create handle with error %d\n",
+					GetLastError());
+				retval=-1;
 			}
-			if (session->rtp.QoSHandle!=NULL) {
-				BOOL QoSResult;
-				QoSResult = QOSAddSocketToFlow(
-					session->rtp.QoSHandle,
-					session->rtp.gs.socket,
-					(struct sockaddr*)&session->rtp.gs.rem_addr,
-					tos,
-					QOS_NON_ADAPTIVE_FLOW,
-					&session->rtp.QoSFlowID);
-
-				if (QoSResult != TRUE){
-					ortp_error("QOSAddSocketToFlow failed to add a flow with error %d\n",
-						GetLastError());
-					retval=-1;
-				}
+		}
+		if (session->rtp.QoSHandle!=NULL) {
+			BOOL QoSResult;
+			QoSResult = QOSAddSocketToFlow(
+				session->rtp.QoSHandle,
+				session->rtp.gs.socket,
+				(struct sockaddr*)&session->rtp.gs.rem_addr,
+				tos,
+				QOS_NON_ADAPTIVE_FLOW,
+				&session->rtp.QoSFlowID);
+
+			if (QoSResult != TRUE){
+				ortp_error("QOSAddSocketToFlow failed to add a flow with error %d\n",
+					GetLastError());
+				retval=-1;
 			}
 		}
 	} else {
@@ -695,7 +711,7 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
 				ortp_error("Fail to set DSCP value on rtcp socket: %s",getSocketError());
 			}
 		}
-#if (_WIN32_WINNT >= 0x0600) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if (_WIN32_WINNT >= 0x0600) && defined(ORTP_WINDOWS_DESKTOP)
 	}
 #endif
 	return retval;
@@ -704,7 +720,7 @@ int rtp_session_set_dscp(RtpSession *session, int dscp){
 
 /**
  *rtp_session_get_dscp:
- *@session: a rtp session
+ *@param session: a rtp session
  *
  * Returns the DSCP (Differentiated Services Code Point) for outgoing RTP packets.
  *
@@ -717,7 +733,7 @@ int rtp_session_get_dscp(const RtpSession *session)
 
 /**
  *rtp_session_get_local_port:
- *@session:	a rtp session for which rtp_session_set_local_addr() or rtp_session_set_remote_addr() has been called
+ *@param session:	a rtp session for which rtp_session_set_local_addr() or rtp_session_set_remote_addr() has been called
  *
  *	This function can be useful to retrieve the local port that was randomly choosen by
  *	rtp_session_set_remote_addr() when rtp_session_set_local_addr() was not called.
@@ -735,9 +751,9 @@ int rtp_session_get_local_rtcp_port(const RtpSession *session){
 
 /**
  *rtp_session_set_remote_addr:
- *@session:		a rtp session freshly created.
- *@addr:		a local IP address in the xxx.xxx.xxx.xxx form.
- *@port:		a local port.
+ *@param session:		a rtp session freshly created.
+ *@param addr:		a local IP address in the xxx.xxx.xxx.xxx form.
+ *@param port:		a local port.
  *
  *	Sets the remote address of the rtp session, ie the destination address where rtp packet
  *	are sent. If the session is recv-only or duplex, it also sets the origin of incoming RTP
@@ -752,11 +768,11 @@ rtp_session_set_remote_addr (RtpSession * session, const char * addr, int port){
 
 /**
  *rtp_session_set_remote_addr_full:
- *@session:		a rtp session freshly created.
- *@rtp_addr:		a local IP address in the xxx.xxx.xxx.xxx form.
- *@rtp_port:		a local rtp port.
- *@rtcp_addr:		a local IP address in the xxx.xxx.xxx.xxx form.
- *@rtcp_port:		a local rtcp port.
+ *@param session:		a rtp session freshly created.
+ *@param rtp_addr:		a local IP address in the xxx.xxx.xxx.xxx form.
+ *@param rtp_port:		a local rtp port.
+ *@param rtcp_addr:		a local IP address in the xxx.xxx.xxx.xxx form.
+ *@param rtcp_port:		a local rtcp port.
  *
  *	Sets the remote address of the rtp session, ie the destination address where rtp packet
  *	are sent. If the session is recv-only or duplex, it also sets the origin of incoming RTP
@@ -772,9 +788,10 @@ rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr, i
 
 static int
 _rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr, int rtp_port, const char * rtcp_addr, int rtcp_port, bool_t is_aux){
+	char rtp_printable_addr[64];
+	char rtcp_printable_addr[64];
 	int err;
-	struct addrinfo hints, *res0, *res;
-	char num[8];
+	struct addrinfo *res0, *res;
 	struct sockaddr_storage *rtp_saddr=&session->rtp.gs.rem_addr;
 	socklen_t *rtp_saddr_len=&session->rtp.gs.rem_addrlen;
 	struct sockaddr_storage *rtcp_saddr=&session->rtcp.gs.rem_addr;
@@ -790,24 +807,12 @@ _rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr,
 		rtcp_saddr_len=&aux_rtcp->len;
 	}
 
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = (session->rtp.gs.socket == -1) ? AF_UNSPEC : session->rtp.gs.sockfamily;
-	hints.ai_socktype = SOCK_DGRAM;
-#ifndef ANDROID
-	hints.ai_flags |= hints.ai_family==AF_INET6 ? AI_V4MAPPED | AI_ALL : 0;
-#else
-	/*
-	 * Bionic has a crappy implementation of getaddrinfo() that doesn't support the AI_V4MAPPED flag.
-	 * However since linux kernel is very tolerant, you can pass an IPv4 sockaddr to sendto without causing problem.
-	 */
-#endif
-
-	snprintf(num, sizeof(num), "%d", rtp_port);
-	err = getaddrinfo(rtp_addr, num, &hints, &res0);
-	if (err) {
-		ortp_warning("Error in socket address (hints.ai_family=%i, hints.ai_flags=%i): %s", hints.ai_family, hints.ai_flags, gai_strerror(err));
+	res0 = bctbx_name_to_addrinfo((session->rtp.gs.socket == -1) ? AF_UNSPEC : session->rtp.gs.sockfamily, SOCK_DGRAM, rtp_addr, rtp_port);
+	if (res0 == NULL) {
 		err=-1;
 		goto end;
+	} else {
+		bctbx_addrinfo_to_printable_ip_address(res0, rtp_printable_addr, sizeof(rtp_printable_addr));
 	}
 	if (session->rtp.gs.socket == -1){
 		/* the session has not its socket bound, do it */
@@ -822,47 +827,40 @@ _rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr,
 		}
 	}
 
-
 	err=-1;
 	for (res = res0; res; res = res->ai_next) {
 		/* set a destination address that has the same type as the local address */
 		if (res->ai_family==session->rtp.gs.sockfamily ) {
 			memcpy(rtp_saddr, res->ai_addr, res->ai_addrlen);
-			*rtp_saddr_len=res->ai_addrlen;
+			*rtp_saddr_len=(socklen_t)res->ai_addrlen;
 			err=0;
 			break;
 		}
 	}
-	freeaddrinfo(res0);
+	bctbx_freeaddrinfo(res0);
 	if (err) {
 		ortp_warning("Could not set destination for RTP socket to %s:%i.",rtp_addr,rtp_port);
 		goto end;
 	}
 
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = (session->rtp.gs.socket == -1) ? AF_UNSPEC : session->rtp.gs.sockfamily;
-	hints.ai_socktype = SOCK_DGRAM;
-#ifndef ANDROID
-	hints.ai_flags |= hints.ai_family==AF_INET6 ? AI_V4MAPPED | AI_ALL : 0;
-#endif
-	snprintf(num, sizeof(num), "%d", rtcp_port);
-	err = getaddrinfo(rtcp_addr, num, &hints, &res0);
-	if (err) {
-		ortp_warning ("Error: %s", gai_strerror(err));
+	res0 = bctbx_name_to_addrinfo((session->rtcp.gs.socket == -1) ? AF_UNSPEC : session->rtcp.gs.sockfamily, SOCK_DGRAM, rtcp_addr, rtcp_port);
+	if (res0 == NULL) {
 		err=-1;
 		goto end;
+	} else {
+		bctbx_addrinfo_to_printable_ip_address(res0, rtcp_printable_addr, sizeof(rtcp_printable_addr));
 	}
 	err=-1;
 	for (res = res0; res; res = res->ai_next) {
 		/* set a destination address that has the same type as the local address */
-		if (res->ai_family==session->rtp.gs.sockfamily ) {
+		if (res->ai_family==session->rtcp.gs.sockfamily ) {
 			err=0;
 			memcpy(rtcp_saddr, res->ai_addr, res->ai_addrlen);
-			*rtcp_saddr_len=res->ai_addrlen;
+			*rtcp_saddr_len=(socklen_t)res->ai_addrlen;
 			break;
 		}
 	}
-	freeaddrinfo(res0);
+	bctbx_freeaddrinfo(res0);
 	if (err) {
 		ortp_warning("Could not set destination for RCTP socket to %s:%i.",rtcp_addr,rtcp_port);
 		goto end;
@@ -889,11 +887,9 @@ _rtp_session_set_remote_addr_full (RtpSession * session, const char * rtp_addr,
 		session->flags&=~RTP_SOCKET_CONNECTED;
 		session->flags&=~RTCP_SOCKET_CONNECTED;
 	}
-	ortp_message("RtpSession [%p] sending to rtp [%s:%i] rtcp [%s:%i] %s"	,session
-									,rtp_addr
-									,rtp_port
-									,rtcp_addr
-									,rtcp_port
+	ortp_message("RtpSession [%p] sending to rtp %s rtcp %s %s",session
+									,rtp_printable_addr
+									,rtcp_printable_addr
 									,is_aux ? "as auxiliary destination" : "");
 	end:
 	if (is_aux){
@@ -914,11 +910,11 @@ int rtp_session_set_remote_addr_and_port(RtpSession * session, const char * addr
 
 /**
  *rtp_session_add_remote_aux_addr_full:
- *@session:		a rtp session freshly created.
- *@rtp_addr:		a local IP address in the xxx.xxx.xxx.xxx form.
- *@rtp_port:		a local rtp port.
- *@rtcp_addr:		a local IP address in the xxx.xxx.xxx.xxx form.
- *@rtcp_port:		a local rtcp port.
+ *@param session:		a rtp session freshly created.
+ *@param rtp_addr:		a local IP address in the xxx.xxx.xxx.xxx form.
+ *@param rtp_port:		a local rtp port.
+ *@param rtcp_addr:		a local IP address in the xxx.xxx.xxx.xxx form.
+ *@param rtcp_port:		a local rtcp port.
  *
  *	Add an auxiliary remote address for the rtp session, ie a destination address where rtp packet
  *	are sent.
@@ -968,7 +964,7 @@ void rtp_session_get_transports(const RtpSession *session, RtpTransport **rtptr,
 
 /**
  *rtp_session_flush_sockets:
- *@session: a rtp session
+ *@param session: a rtp session
  *
  * Flushes the sockets for all pending incoming packets.
  * This can be usefull if you did not listen to the stream for a while
@@ -1009,6 +1005,14 @@ static int rtp_sendmsg(int sock,mblk_t *m, const struct sockaddr *rem_addr, sock
 }
 #endif
 
+ortp_socket_t rtp_session_get_socket(RtpSession *session, bool_t is_rtp){
+	if (session->rtcp_mux){
+		return session->rtp.gs.socket;
+	}else{
+		return is_rtp ? session->rtp.gs.socket : session->rtcp.gs.socket;
+	}
+}
+
 int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen){
 	int error;
 #ifdef USE_SENDMSG
@@ -1022,12 +1026,14 @@ int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockad
 	return error;
 }
 
-int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen){
+int rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen){
 	int ret;
 
+	_rtp_session_check_socket_refresh(session);
+	
 	if (session->net_sim_ctx && (session->net_sim_ctx->params.mode==OrtpNetworkSimulatorOutbound
 			|| session->net_sim_ctx->params.mode==OrtpNetworkSimulatorOutboundControlled)){
-		ret=msgdsize(m);
+		ret=(int)msgdsize(m);
 		m=dupmsg(m);
 		memcpy(&m->net_addr,destaddr,destlen);
 		m->net_addrlen=destlen;
@@ -1036,13 +1042,22 @@ int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags
 		putq(&session->net_sim_ctx->send_q, m);
 		ortp_mutex_unlock(&session->net_sim_ctx->mutex);
 	}else{
-		ortp_socket_t sockfd=is_rtp ? session->rtp.gs.socket : session->rtcp.gs.socket;
+		ortp_socket_t sockfd = rtp_session_get_socket(session, is_rtp);
 		ret=_ortp_sendto(sockfd, m, flags, destaddr, destlen);
 	}
 	return ret;
 }
 
-static void update_sent_bytes(OrtpStream *os, int nbytes) {
+int rtp_session_recvfrom(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, struct sockaddr *from, socklen_t *fromlen) {
+	int ret = rtp_session_rtp_recv_abstract(is_rtp ? session->rtp.gs.socket : session->rtcp.gs.socket, m, flags, from, fromlen);
+	if (ret >= 0) {
+		/* Store the local port in the recv_addr of the mblk_t, the address is already filled in rtp_session_rtp_recv_abstract */
+		m->recv_addr.port = htons(is_rtp ? session->rtp.gs.loc_port : session->rtcp.gs.loc_port);
+	}
+	return ret;
+}
+
+void update_sent_bytes(OrtpStream *os, int nbytes) {
 	int overhead = ortp_stream_is_ipv6(os) ? IP6_UDP_OVERHEAD : IP_UDP_OVERHEAD;
 	if ((os->sent_bytes == 0) && (os->send_bw_start.tv_sec == 0) && (os->send_bw_start.tv_usec == 0)) {
 		/* Initialize bandwidth computing time when has not been started yet. */
@@ -1060,26 +1075,25 @@ static void update_recv_bytes(OrtpStream *os, int nbytes) {
 }
 
 static void log_send_error(RtpSession *session, const char *type, mblk_t *m, struct sockaddr *destaddr, socklen_t destlen){
-	char host[65]={0};
-	char port[12]={0};
-	getnameinfo(destaddr,destlen,host,sizeof(host)-1,port,sizeof(port)-1,NI_NUMERICHOST|NI_NUMERICSERV);
-	ortp_warning ("RtpSession [%p] error sending [%s] packet [%p] to ip=[%s] port=[%s]: %s",
-		session, type, m, host, port, getSocketError());
+	char printable_ip_address[65]={0};
+	bctbx_sockaddr_to_printable_ip_address(destaddr, destlen, printable_ip_address, sizeof(printable_ip_address));
+	ortp_warning ("RtpSession [%p] error sending [%s] packet [%p] to %s: %s",
+		session, type, m, printable_ip_address, getSocketError());
 }
 
 static int rtp_session_rtp_sendto(RtpSession * session, mblk_t * m, struct sockaddr *destaddr, socklen_t destlen, bool_t is_aux){
 	int error;
-
+	
 	if (rtp_session_using_transport(session, rtp)){
 		error = (session->rtp.gs.tr->t_sendto) (session->rtp.gs.tr,m,0,destaddr,destlen);
 	}else{
-		error=_rtp_session_sendto(session, TRUE,m,0,destaddr,destlen);
+		error=rtp_session_sendto(session, TRUE,m,0,destaddr,destlen);
 	}
 	if (!is_aux){
 		/*errors to auxiliary destinations are not notified*/
 		if (error < 0){
 			if (session->on_network_error.count>0){
-				rtp_signal_table_emit3(&session->on_network_error,(long)"Error sending RTP packet",INT_TO_POINTER(getSocketErrorCode()));
+				rtp_signal_table_emit3(&session->on_network_error,"Error sending RTP packet",ORTP_INT_TO_POINTER(getSocketErrorCode()));
 			}else log_send_error(session,"rtp",m,destaddr,destlen);
 			session->rtp.send_errno=getSocketErrorCode();
 		}else{
@@ -1096,6 +1110,11 @@ int rtp_session_rtp_send (RtpSession * session, mblk_t * m){
 	struct sockaddr *destaddr=(struct sockaddr*)&session->rtp.gs.rem_addr;
 	socklen_t destlen=session->rtp.gs.rem_addrlen;
 	OList *elem=NULL;
+	
+	if (session->is_spliced) {
+		freemsg(m);
+		return 0;
+	}
 
 	hdr = (rtp_header_t *) m->b_rptr;
 	if (hdr->version == 0) {
@@ -1114,7 +1133,7 @@ int rtp_session_rtp_send (RtpSession * session, mblk_t * m){
 		destlen=0;
 	}
 	/*first send to main destination*/
-	if (destlen) error=rtp_session_rtp_sendto(session,m,destaddr,destlen,FALSE);
+	error=rtp_session_rtp_sendto(session,m,destaddr,destlen,FALSE);
 	/*then iterate over auxiliary destinations*/
 	for(elem=session->rtp.gs.aux_destinations;elem!=NULL;elem=elem->next){
 		OrtpAddress *addr=(OrtpAddress*)elem->data;
@@ -1126,7 +1145,7 @@ int rtp_session_rtp_send (RtpSession * session, mblk_t * m){
 
 static int rtp_session_rtcp_sendto(RtpSession * session, mblk_t * m, struct sockaddr *destaddr, socklen_t destlen, bool_t is_aux){
 	int error=0;
-	ortp_socket_t sockfd=session->rtcp.gs.socket;
+	ortp_socket_t sockfd = rtp_session_get_socket(session, FALSE);
 
 	if (rtp_session_using_transport(session, rtcp)){
 			error = (session->rtcp.gs.tr->t_sendto) (session->rtcp.gs.tr, m, 0,
@@ -1137,7 +1156,7 @@ static int rtp_session_rtcp_sendto(RtpSession * session, mblk_t * m, struct sock
 	if (!is_aux){
 		if (error < 0){
 			if (session->on_network_error.count>0){
-				rtp_signal_table_emit3(&session->on_network_error,(long)"Error sending RTCP packet",INT_TO_POINTER(getSocketErrorCode()));
+				rtp_signal_table_emit3(&session->on_network_error,"Error sending RTCP packet",ORTP_INT_TO_POINTER(getSocketErrorCode()));
 			}else{
 				log_send_error(session,"rtcp",m,destaddr,destlen);
 			}
@@ -1153,11 +1172,15 @@ int
 rtp_session_rtcp_send (RtpSession * session, mblk_t * m){
 	int error=0;
 	ortp_socket_t sockfd=session->rtcp.gs.socket;
-	struct sockaddr *destaddr=(struct sockaddr*)&session->rtcp.gs.rem_addr;
-	socklen_t destlen=session->rtcp.gs.rem_addrlen;
+	struct sockaddr *destaddr=session->rtcp_mux ? (struct sockaddr*)&session->rtp.gs.rem_addr : (struct sockaddr*)&session->rtcp.gs.rem_addr;
+	socklen_t destlen=session->rtcp_mux ? session->rtp.gs.rem_addrlen : session->rtcp.gs.rem_addrlen;
 	OList *elem=NULL;
 	bool_t using_connected_socket=(session->flags & RTCP_SOCKET_CONNECTED)!=0;
 
+	if (session->is_spliced) {
+		freemsg(m);
+		return 0;
+	}
 	if (using_connected_socket) {
 		destaddr=NULL;
 		destlen=0;
@@ -1278,15 +1301,19 @@ int rtp_session_rtp_recv_abstract(ortp_socket_t socket, mblk_t *msg, int flags,
 			}
 #endif
 		}
+		/*store recv addr for use by modifiers*/
+		memcpy(&msg->net_addr,from,*fromlen);
+		msg->net_addrlen = *fromlen;
 	}
 	return ret;
 }
 
-void rtp_session_notify_inc_rtcp(RtpSession *session, mblk_t *m){
+void rtp_session_notify_inc_rtcp(RtpSession *session, mblk_t *m, bool_t received_via_rtcp_mux){
 	if (session->eventqs!=NULL){
 		OrtpEvent *ev=ortp_event_new(ORTP_EVENT_RTCP_PACKET_RECEIVED);
 		OrtpEventData *d=ortp_event_get_data(ev);
 		d->packet=m;
+		d->info.socket_type = received_via_rtcp_mux ? OrtpRTPSocket : OrtpRTCPSocket;
 		rtp_session_dispatch_event(session,ev);
 	}
 	else freemsg(m);  /* avoid memory leak */
@@ -1302,7 +1329,7 @@ static void compute_rtt(RtpSession *session, const struct timeval *now, uint32_t
 		if (rtt_frac>=0){
 			rtt_frac/=65536.0;
 
-			session->rtt=rtt_frac;
+			session->rtt=(float)rtt_frac;
 			/*ortp_message("rtt estimated to %f s",session->rtt);*/
 		}else ortp_warning("Negative RTT computation, maybe due to clock adjustments.");
 	}
@@ -1387,8 +1414,7 @@ static int process_rtcp_packet( RtpSession *session, mblk_t *block, struct socka
 
 	rtcp = (rtcp_common_header_t *)block->b_rptr;
 
-	if (rtcp->version != 2)
-	{
+	if (rtcp->version != 2){
 		/* try to see if it is a STUN packet */
 		uint16_t stunlen = *((uint16_t *)(block->b_rptr + sizeof(uint16_t)));
 		stunlen = ntohs(stunlen);
@@ -1402,15 +1428,15 @@ static int process_rtcp_packet( RtpSession *session, mblk_t *block, struct socka
 				memcpy(&ed->source_addr,addr,addrlen);
 				ed->info.socket_type = OrtpRTCPSocket;
 				rtp_session_dispatch_event(session, ev);
-				return -1;
 			}
+		}else{
+			/* discard in two case: the packet is not stun OR nobody is interested by STUN (no eventqs) */
+			ortp_warning("RtpSession [%p] receiving rtcp packet with version number != 2, discarded", session);
 		}
-		/* discard in two case: the packet is not stun OR nobody is interested by STUN (no eventqs) */
-		ortp_debug("Receiving rtcp packet with version number !=2...discarded");
-		return 0;
+		return -1;
 	}
 
-	update_recv_bytes(&session->rtcp.gs, block->b_wptr - block->b_rptr);
+	update_recv_bytes(&session->rtcp.gs, (int)(block->b_wptr - block->b_rptr));
 
 	/* compound rtcp packet can be composed by more than one rtcp message */
 	do{
@@ -1471,6 +1497,7 @@ static void rtp_process_incoming_packet(RtpSession * session, mblk_t * mp, bool_
 
 	struct sockaddr *remaddr = NULL;
 	socklen_t addrlen;
+	bool_t received_via_rtcp_mux = FALSE;
 
 	if (!mp){
 		return;
@@ -1478,28 +1505,42 @@ static void rtp_process_incoming_packet(RtpSession * session, mblk_t * mp, bool_
 	remaddr = (struct sockaddr *)&mp->net_addr;
 	addrlen = mp->net_addrlen;
 
+	/*in case of rtcp-mux, we are allowed to reconsider whether it is an RTP or RTCP packet*/
+	if (session->rtcp_mux && is_rtp_packet){
+		if (rtp_get_version(mp) == 2){
+			int pt = rtp_get_payload_type(mp);
+			if (pt >= 64 && pt <= 95){
+				/*this is assumed to be an RTCP packet*/
+				is_rtp_packet = FALSE;
+				received_via_rtcp_mux = TRUE;
+			}
+		}
+	}
+	
+	if (session->spliced_session){
+		/*this will forward all traffic to the spliced session*/
+		rtp_session_do_splice(session, mp, is_rtp_packet);
+	}
+	
+	/* store the sender RTP address to do symmetric RTP at start mainly for stun packets. 
+	 * --For rtp packet symmetric RTP is handled in rtp_session_rtp_parse() after first valid rtp packet received.
+	 * --For rtcp, only swicth if valid rtcp packet && first rtcp packet received*/
+	rtp_session_update_remote_sock_addr(session,mp,is_rtp_packet,is_rtp_packet || (rtp_get_version(mp) != 2));
+	
 	if (is_rtp_packet){
-		if (session->use_connect){
-			/* In the case where use_connect is false, symmetric RTP is handled in rtp_session_rtp_parse() */
-			if (session->symmetric_rtp && !sock_connected){
-				/* store the sender RTP address to do symmetric RTP */
-				memcpy(&session->rtp.gs.rem_addr,&remaddr,addrlen);
-				session->rtp.gs.rem_addrlen=addrlen;
-				if (try_connect(session->rtp.gs.socket,remaddr,addrlen))
+		if (session->use_connect && session->symmetric_rtp && !sock_connected ){
+			/* In the case where use_connect is false, */
+			if (try_connect(session->rtp.gs.socket,remaddr,addrlen)) {
 					session->flags|=RTP_SOCKET_CONNECTED;
 			}
 		}
 		/* then parse the message and put on jitter buffer queue */
-		update_recv_bytes(&session->rtp.gs, mp->b_wptr - mp->b_rptr);
+		update_recv_bytes(&session->rtp.gs, (int)(mp->b_wptr - mp->b_rptr));
 		rtp_session_rtp_parse(session, mp, user_ts, remaddr,addrlen);
 		/*for bandwidth measurements:*/
 	}else {
-		if (session->symmetric_rtp && !sock_connected){
-			/* store the sender RTP address to do symmetric RTP */
-			memcpy(&session->rtcp.gs.rem_addr,remaddr,addrlen);
-			session->rtcp.gs.rem_addrlen=addrlen;
-			if (session->use_connect){
-				if (try_connect(session->rtcp.gs.socket,remaddr,addrlen))
+		if (session->use_connect && session->symmetric_rtp && !sock_connected){
+			if (try_connect(session->rtcp.gs.socket,remaddr,addrlen)) {
 					session->flags|=RTCP_SOCKET_CONNECTED;
 			}
 		}
@@ -1508,8 +1549,9 @@ static void rtp_process_incoming_packet(RtpSession * session, mblk_t * mp, bool_
 			and we don't want to send RTCP XR packet before notifying the application
 			that a message has been received*/
 			mblk_t * copy = copymsg(mp);
+			session->stats.recv_rtcp_packets++;
 			/* post an event to notify the application */
-			rtp_session_notify_inc_rtcp(session,mp);
+			rtp_session_notify_inc_rtcp(session, mp, received_via_rtcp_mux);
 			/* reply to collaborative RTCP XR packets if needed. */
 			if (session->rtcp.xr_conf.enabled == TRUE){
 				reply_to_collaborative_rtcp_xr_packet(session, copy);
@@ -1519,44 +1561,42 @@ static void rtp_process_incoming_packet(RtpSession * session, mblk_t * mp, bool_
 	}
 }
 
+void rtp_session_process_incoming(RtpSession * session, mblk_t *mp, bool_t is_rtp_packet, uint32_t ts) {
+	if (session->net_sim_ctx && session->net_sim_ctx->params.mode == OrtpNetworkSimulatorInbound) {
+		/*drain possible packets queued in the network simulator*/
+		mp = rtp_session_network_simulate(session, mp, &is_rtp_packet);
+		rtp_process_incoming_packet(session, mp, is_rtp_packet, ts);
+	} else if (mp != NULL) {
+		rtp_process_incoming_packet(session, mp, is_rtp_packet, ts);
+	}
+}
+
 int rtp_session_rtp_recv (RtpSession * session, uint32_t user_ts) {
 	int error;
-	ortp_socket_t sockfd=session->rtp.gs.socket;
 	struct sockaddr_storage remaddr;
-
 	socklen_t addrlen = sizeof (remaddr);
 	mblk_t *mp;
 
-	if ((sockfd==(ortp_socket_t)-1) && !rtp_session_using_transport(session, rtp)) return -1;  /*session has no sockets for the moment*/
+	if ((session->rtp.gs.socket==(ortp_socket_t)-1) && !rtp_session_using_transport(session, rtp)) return -1;  /*session has no sockets for the moment*/
 
 	while (1)
 	{
 		bool_t sock_connected=!!(session->flags & RTP_SOCKET_CONNECTED);
 		bool_t is_rtp_packet = TRUE;
 
-		if (session->rtp.gs.cached_mp==NULL){
-			 session->rtp.gs.cached_mp = msgb_allocator_alloc(&session->allocator,session->recv_buf_size);
-		}
-		mp=session->rtp.gs.cached_mp;
+		mp = msgb_allocator_alloc(&session->rtp.gs.allocator, session->recv_buf_size);
+		mp->reserved1 = user_ts;
+
 		if (sock_connected){
-			error=rtp_session_rtp_recv_abstract(sockfd, mp, 0, NULL, NULL);
+			error=rtp_session_recvfrom(session, TRUE, mp, 0, NULL, NULL);
 		}else if (rtp_session_using_transport(session, rtp)) {
 			error = (session->rtp.gs.tr->t_recvfrom)(session->rtp.gs.tr, mp, 0, (struct sockaddr *) &remaddr, &addrlen);
 		} else {
-			error = rtp_session_rtp_recv_abstract(sockfd, mp, 0, (struct sockaddr *) &remaddr, &addrlen);
+			error = rtp_session_recvfrom(session, TRUE, mp, 0, (struct sockaddr *) &remaddr, &addrlen);
 		}
 		if (error > 0){
 			mp->b_wptr+=error;
-
-			/*if we use the network simulator, store packet source address for later use(otherwise it will be used immediately)*/
-			memcpy(&mp->net_addr,&remaddr,addrlen);
-			mp->net_addrlen = addrlen;
-			if (session->net_sim_ctx && session->net_sim_ctx->params.mode==OrtpNetworkSimulatorInbound){
-				mp=rtp_session_network_simulate(session,mp,&is_rtp_packet);
-			}
-			rtp_process_incoming_packet(session,mp,is_rtp_packet,user_ts);
-
-			session->rtp.gs.cached_mp=NULL;
+			rtp_session_process_incoming(session, mp, is_rtp_packet, user_ts);
 		}
 		else
 		{
@@ -1564,7 +1604,7 @@ int rtp_session_rtp_recv (RtpSession * session, uint32_t user_ts) {
 			if (error==-1 && !is_would_block_error((errnum=getSocketErrorCode())) )
 			{
 				if (session->on_network_error.count>0){
-					rtp_signal_table_emit3(&session->on_network_error,(long)"Error receiving RTP packet",INT_TO_POINTER(getSocketErrorCode()));
+					rtp_signal_table_emit3(&session->on_network_error,"Error receiving RTP packet",ORTP_INT_TO_POINTER(getSocketErrorCode()));
 				}else ortp_warning("Error receiving RTP packet: %s, err num  [%i],error [%i]",getSocketError(),errnum,error);
 #ifdef __ios
 				/*hack for iOS and non-working socket because of background mode*/
@@ -1575,13 +1615,9 @@ int rtp_session_rtp_recv (RtpSession * session, uint32_t user_ts) {
 #endif
 			}else{
 				/*EWOULDBLOCK errors or transports returning 0 are ignored.*/
-				if (session->net_sim_ctx && session->net_sim_ctx->params.mode==OrtpNetworkSimulatorInbound){
-					/*drain possible packets queued in the network simulator*/
-					mp=rtp_session_network_simulate(session,NULL,&is_rtp_packet);
-					rtp_process_incoming_packet(session,mp,is_rtp_packet,user_ts);
-				}
+				rtp_session_process_incoming(session, NULL, is_rtp_packet, user_ts);
 			}
-			/* don't free the cached_mp, it will be reused next time */
+			freemsg(mp);
 			return -1;
 		}
 	}
@@ -1602,13 +1638,12 @@ int rtp_session_rtcp_recv (RtpSession * session) {
 	{
 		bool_t sock_connected=!!(session->flags & RTCP_SOCKET_CONNECTED);
 		bool_t is_rtp_packet = FALSE;
-		if (session->rtcp.gs.cached_mp==NULL){
-			 session->rtcp.gs.cached_mp = allocb (RTCP_MAX_RECV_BUFSIZE, 0);
-		}
 
-		mp=session->rtcp.gs.cached_mp;
+		mp = msgb_allocator_alloc(&session->rtp.gs.allocator, RTCP_MAX_RECV_BUFSIZE);
+		mp->reserved1 = session->rtp.rcv_last_app_ts;
+
 		if (sock_connected){
-			error=rtp_session_rtp_recv_abstract(session->rtcp.gs.socket, mp, 0, NULL, NULL);
+			error=rtp_session_recvfrom(session, FALSE, mp, 0, NULL, NULL);
 		}else{
 			addrlen=sizeof (remaddr);
 
@@ -1617,7 +1652,7 @@ int rtp_session_rtcp_recv (RtpSession * session) {
 					(struct sockaddr *) &remaddr,
 					&addrlen);
 			}else{
-				error=rtp_session_rtp_recv_abstract (session->rtcp.gs.socket,mp, 0,
+				error=rtp_session_recvfrom(session, FALSE, mp, 0,
 					(struct sockaddr *) &remaddr,
 					&addrlen);
 			}
@@ -1625,15 +1660,7 @@ int rtp_session_rtcp_recv (RtpSession * session) {
 		if (error > 0)
 		{
 			mp->b_wptr += error;
-
-			memcpy(&mp->net_addr,&remaddr,addrlen);
-			mp->net_addrlen = addrlen;
-
-			if (session->net_sim_ctx && session->net_sim_ctx->params.mode==OrtpNetworkSimulatorInbound){
-				mp=rtp_session_network_simulate(session,mp,&is_rtp_packet);
-			}
-			rtp_process_incoming_packet(session,mp,is_rtp_packet,session->rtp.rcv_last_app_ts);
-			session->rtcp.gs.cached_mp=NULL;
+			rtp_session_process_incoming(session, mp, is_rtp_packet, session->rtp.rcv_last_app_ts);
 		}
 		else
 		{
@@ -1641,7 +1668,7 @@ int rtp_session_rtcp_recv (RtpSession * session) {
 			if (error==-1 && !is_would_block_error((errnum=getSocketErrorCode())) )
 			{
 				if (session->on_network_error.count>0){
-					rtp_signal_table_emit3(&session->on_network_error,(long)"Error receiving RTCP packet",INT_TO_POINTER(getSocketErrorCode()));
+					rtp_signal_table_emit3(&session->on_network_error,"Error receiving RTCP packet",ORTP_INT_TO_POINTER(getSocketErrorCode()));
 				}else ortp_warning("Error receiving RTCP packet: %s, err num  [%i],error [%i]",getSocketError(),errnum,error);
 #ifdef __ios
 				/*hack for iOS and non-working socket because of background mode*/
@@ -1653,15 +1680,58 @@ int rtp_session_rtcp_recv (RtpSession * session) {
 				session->rtp.recv_errno=errnum;
 			}else{
 				/*EWOULDBLOCK errors or transports returning 0 are ignored.*/
-				if (session->net_sim_ctx && session->net_sim_ctx->params.mode==OrtpNetworkSimulatorInbound){
-					/*drain possible packets queued in the network simulator*/
-					mp=rtp_session_network_simulate(session,NULL,&is_rtp_packet);
-					rtp_process_incoming_packet(session,mp,is_rtp_packet,session->rtp.rcv_last_app_ts);
-				}
+				rtp_session_process_incoming(session, NULL, is_rtp_packet, session->rtp.rcv_last_app_ts);
 			}
-			/* don't free the cached_mp, it will be reused next time */
+
+			freemsg(mp);
 			return -1; /* avoids an infinite loop ! */
 		}
 	}
 	return error;
 }
+
+int  rtp_session_update_remote_sock_addr(RtpSession * session, mblk_t * mp, bool_t is_rtp,bool_t only_at_start) {
+	struct sockaddr_storage * rem_addr = NULL;
+	socklen_t rem_addrlen;
+	const char* socket_type;
+	bool_t sock_connected;
+	bool_t do_address_change = /*(rtp_get_version(mp) == 2 && */ !only_at_start;
+	
+	if (!rtp_session_get_symmetric_rtp(session))
+		return -1; /*nothing to try if not rtp symetric*/
+	
+	if (is_rtp) {
+		rem_addr = &session->rtp.gs.rem_addr;
+		rem_addrlen = session->rtp.gs.rem_addrlen;
+		socket_type = "rtp";
+		sock_connected = session->flags & RTP_SOCKET_CONNECTED;
+		do_address_change =  session->rtp.gs.socket != (ortp_socket_t)-1  && ( do_address_change || rtp_session_get_stats(session)->packet_recv == 0);
+	} else {
+		rem_addr = &session->rtcp.gs.rem_addr;
+		rem_addrlen = session->rtcp.gs.rem_addrlen;
+		sock_connected = session->flags & RTCP_SOCKET_CONNECTED;
+		socket_type = "rtcp";
+		do_address_change = session->rtcp.gs.socket != (ortp_socket_t)-1  && (do_address_change || rtp_session_get_stats(session)->recv_rtcp_packets == 0);
+	}
+	
+	if (do_address_change
+		&& rem_addr
+		&& !sock_connected
+		&& !ortp_is_multicast_addr((const struct sockaddr*)rem_addr)
+		&& memcmp(rem_addr,&mp->net_addr,mp->net_addrlen) !=0) {
+		char current_ip_address[64]={0};
+		char new_ip_address[64]={0};
+
+		bctbx_sockaddr_to_printable_ip_address((struct sockaddr *)rem_addr, rem_addrlen, current_ip_address, sizeof(current_ip_address));
+		bctbx_sockaddr_to_printable_ip_address((struct sockaddr *)&mp->net_addr, mp->net_addrlen, new_ip_address, sizeof(new_ip_address));
+		ortp_message("Switching %s destination from %s to %s for session [%p]"
+			   , socket_type
+			   , current_ip_address
+			   , new_ip_address
+			   , session);
+		
+		memcpy(rem_addr,&mp->net_addr,mp->net_addrlen);
+		return 0;
+	}
+	return -1;
+	}
\ No newline at end of file
diff --git a/src/rtpsession_priv.h b/src/rtpsession_priv.h
index 7ea4265..093841d 100644
--- a/src/rtpsession_priv.h
+++ b/src/rtpsession_priv.h
@@ -43,7 +43,8 @@ typedef enum {
 	RTCP_OVERRIDE_JITTER=1<<12,
 	RTCP_OVERRIDE_DELAY=1<<13,
 	RTP_SESSION_RECV_SEQ_INIT=1<<14,
-	RTP_SESSION_FLUSH=1<<15
+	RTP_SESSION_FLUSH=1<<15,
+	RTP_SESSION_SOCKET_REFRESH_REQUESTED=1<<16
 }RtpSessionFlags;
 
 #define rtp_session_using_transport(s, stream) (((s)->flags & RTP_SESSION_USING_TRANSPORT) && (s->stream.gs.tr != 0))
@@ -56,7 +57,8 @@ mblk_t * rtp_getq(queue_t *q, uint32_t ts, int *rejected);
 int rtp_session_rtp_recv(RtpSession * session, uint32_t ts);
 int rtp_session_rtcp_recv(RtpSession * session);
 int rtp_session_rtp_send (RtpSession * session, mblk_t * m);
-int rtp_session_rtcp_send (RtpSession * session, mblk_t * m);
+
+#define rtp_session_rtcp_send rtp_session_rtcp_sendm_raw
 
 void rtp_session_rtp_parse(RtpSession *session, mblk_t *mp, uint32_t local_str_ts, struct sockaddr *addr, socklen_t addrlen);
 
@@ -66,7 +68,7 @@ void update_avg_rtcp_size(RtpSession *session, int bytes);
 mblk_t * rtp_session_network_simulate(RtpSession *session, mblk_t *input, bool_t *is_rtp_packet);
 void ortp_network_simulator_destroy(OrtpNetworkSimulatorCtx *sim);
 
-void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, int bytes_len);
+void rtcp_common_header_init(rtcp_common_header_t *ch, RtpSession *s,int type, int rc, size_t bytes_len);
 
 mblk_t * make_xr_rcvr_rtt(RtpSession *session);
 mblk_t * make_xr_dlrr(RtpSession *session);
@@ -87,4 +89,21 @@ void rtp_session_set_transports(RtpSession *session, RtpTransport *rtptr, RtpTra
 
 ORTP_PUBLIC bool_t rtp_profile_is_telephone_event(const RtpProfile *prof, int pt);
 
+ortp_socket_t rtp_session_get_socket(RtpSession *session, bool_t is_rtp);
+
+void rtp_session_do_splice(RtpSession *session, mblk_t *packet, bool_t is_rtp);
+
+/*
+ * Update remote addr in the following case:
+ * rtp symetric == TRUE && socket not connected && remote addr has changed && ((rtp/rtcp packet && not only at start) or (no rtp/rtcp packets received))
+ * @param[in] session  on which to perform change
+ * @param[in] mp packet where remote addr is retreived
+ * @param[in] is_rtp true if rtp
+ * @param[in] only_at_start only perform changes if no valid packets received yet
+ * @return 0 if chaged was performed
+ *
+ */
+	
+ORTP_PUBLIC int rtp_session_update_remote_sock_addr(RtpSession * session, mblk_t * mp, bool_t is_rtp,bool_t only_at_start);
+
 #endif
diff --git a/src/rtpsignaltable.c b/src/rtpsignaltable.c
index 9e51e97..63cfb2b 100644
--- a/src/rtpsignaltable.c
+++ b/src/rtpsignaltable.c
@@ -54,31 +54,31 @@ void rtp_signal_table_emit(RtpSignalTable *table)
 	for (i=0,c=0;c<table->count;i++){
 		if (table->callback[i]!=NULL){
 			c++;	/*I like it*/
-			table->callback[i](table->session,(unsigned long)table->user_data[i],0,0);
+			table->callback[i](table->session,table->user_data[i],0,0);
 		}
 	}
 }
 
-void rtp_signal_table_emit2(RtpSignalTable *table,unsigned long arg)
+void rtp_signal_table_emit2(RtpSignalTable *table, void *arg)
 {
 	int i,c;
 
 	for (i=0,c=0;c<table->count;i++){
 		if (table->callback[i]!=NULL){
 			c++;	/*I like it*/
-			table->callback[i](table->session,arg,(unsigned long)table->user_data[i],0);
+			table->callback[i](table->session,arg,table->user_data[i],0);
 		}
 	}
 }
 
-void rtp_signal_table_emit3(RtpSignalTable *table, unsigned long arg1, unsigned long arg2)
+void rtp_signal_table_emit3(RtpSignalTable *table, void *arg1, void *arg2)
 {
 	int i,c;
 
 	for (i=0,c=0;c<table->count;i++){
 		if (table->callback[i]!=NULL){
 			c++;	/*I like it*/
-			table->callback[i](table->session,arg1,arg2,(unsigned long)table->user_data[i]);
+			table->callback[i](table->session,arg1,arg2,table->user_data[i]);
 		}
 	}
 }
diff --git a/src/rtptimer.h b/src/rtptimer.h
index c4a01a4..93c5801 100644
--- a/src/rtptimer.h
+++ b/src/rtptimer.h
@@ -45,8 +45,8 @@ struct _RtpTimer
 
 typedef struct _RtpTimer RtpTimer;
 
-void rtp_timer_set_interval(RtpTimer *timer, struct timeval *interval);
+ORTP_PUBLIC void rtp_timer_set_interval(RtpTimer *timer, struct timeval *interval);
 
-extern RtpTimer posix_timer;
+ORTP_VAR_PUBLIC RtpTimer posix_timer;
 
 #endif
diff --git a/src/scheduler.c b/src/scheduler.c
index 5c65a96..ab3d83e 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -31,7 +31,9 @@ void rtp_scheduler_init(RtpScheduler *sched)
 	sched->list=0;
 	sched->time_=0;
 	/* default to the posix timer */
+#if !defined(ORTP_WINDOWS_UNIVERSAL)
 	rtp_scheduler_set_timer(sched,&posix_timer);
+#endif
 	ortp_mutex_init(&sched->lock,NULL);
 	ortp_cond_init(&sched->unblock_select_cond,NULL);
 	sched->max_sessions=sizeof(SessionSet)*8;
diff --git a/src/sessionset.c b/src/sessionset.c
index 1a79fa4..31b674a 100644
--- a/src/sessionset.c
+++ b/src/sessionset.c
@@ -45,7 +45,7 @@ void session_set_destroy(SessionSet *set)
 	ortp_free(set);
 }
 
-int count_power_items_simple(int v) 
+int count_power_items_simple(int v)
 {
     int c = 0,j;
     for (j=0;j<32;j++){
@@ -56,7 +56,7 @@ int count_power_items_simple(int v)
     return c;
 }
 
-int count_power_items_fast(int v) 
+int count_power_items_fast(int v)
 {
     int c = 0;
     while(v) {
@@ -89,20 +89,20 @@ int session_set_and(SessionSet *sched_set, int maxs, SessionSet *user_set, Sessi
 }
 
 /**
- *	This function performs similarly as libc select() function, but performs on #RtpSession 
+ *	This function performs similarly as libc select() function, but performs on RtpSession
  *	instead of file descriptors.
  *	session_set_select() suspends the calling process until some events arrive on one of the
  *	three sets passed in argument. Two of the sets can be NULL.
- *	The first set @recvs is interpreted as a set of RtpSession waiting for receive events:
+ *	The first set \a recvs is interpreted as a set of RtpSession waiting for receive events:
  *	a new buffer (perhaps empty) is availlable on one or more sessions of the set, or the last
- *	receive operation with rtp_session_recv_with_ts() would have finished if it were in 
+ *	receive operation with rtp_session_recv_with_ts() would have finished if it were in
  *	blocking mode.
  *	The second set is interpreted as a set of RtpSession waiting for send events, i.e. the last
  *	rtp_session_send_with_ts() call on a session would have finished if it were in blocking mode.
- *	
+ *
  *	When some events arrived on some of sets, then the function returns and sets are changed
  *	to indicate the sessions where events happened.
- *	Sessions can be added to sets using session_set_set(), a session has to be tested to be 
+ *	Sessions can be added to sets using session_set_set(), a session has to be tested to be
  *	part of a set using session_set_is_set().
  *
  * @param recvs a set of rtp sessions to be watched for read events
@@ -115,10 +115,10 @@ int session_set_select(SessionSet *recvs, SessionSet *sends, SessionSet *errors)
 	int ret=0,bits;
 	SessionSet temp;
 	RtpScheduler *sched=ortp_get_scheduler();
-	
+
 	/*lock the scheduler to not read the masks while they are being modified by the scheduler*/
 	rtp_scheduler_lock(sched);
-	
+
 	while(1){
 		/* computes the SessionSet intersection (in the other words mask intersection) between
 		the mask given by the user and scheduler masks */
diff --git a/src/str_utils.c b/src/str_utils.c
index 4586088..cb2285d 100644
--- a/src/str_utils.c
+++ b/src/str_utils.c
@@ -33,19 +33,14 @@ void qinit(queue_t *q){
 
 void mblk_init(mblk_t *mp)
 {
-	mp->b_cont=mp->b_prev=mp->b_next=NULL;
-	mp->b_rptr=mp->b_wptr=NULL;
-	mp->reserved1=0;
-	mp->reserved2=0;
-#if defined(ORTP_TIMESTAMP)
-	memset(&(mp->timestamp), 0, sizeof(struct timeval));
-#endif
-	mp->ttl_or_hl = 0;
+	memset(mp, 0, sizeof(mblk_t));
 }
 
 void mblk_meta_copy(const mblk_t *source, mblk_t *dest) {
 	dest->reserved1 = source->reserved1;
 	dest->reserved2 = source->reserved2;
+	memcpy(&dest->net_addr,&source->net_addr,source->net_addrlen);
+	dest->net_addrlen = source->net_addrlen;
 #if defined(ORTP_TIMESTAMP)
 	dest->timestamp = source->timestamp;
 #endif
@@ -82,8 +77,7 @@ mblk_t *allocb(size_t size, int pri)
 	mblk_t *mp;
 	dblk_t *datab;
 
-	mp=(mblk_t *) ortp_malloc(sizeof(mblk_t));
-	mblk_init(mp);
+	mp=(mblk_t *) ortp_malloc0(sizeof(mblk_t));
 	datab=datab_alloc(size);
 
 	mp->b_datap=datab;
@@ -97,11 +91,9 @@ mblk_t *esballoc(uint8_t *buf, size_t size, int pri, void (*freefn)(void*) )
 	mblk_t *mp;
 	dblk_t *datab;
 
-	mp=(mblk_t *) ortp_malloc(sizeof(mblk_t));
-	mblk_init(mp);
+	mp=(mblk_t *) ortp_malloc0(sizeof(mblk_t));
 	datab=(dblk_t *) ortp_malloc(sizeof(dblk_t));
 
-
 	datab->db_base=buf;
 	datab->db_lim=buf+size;
 	datab->db_ref=1;
@@ -142,8 +134,7 @@ mblk_t *dupb(mblk_t *mp)
 	return_val_if_fail(mp->b_datap->db_base!=NULL,NULL);
 
 	datab_ref(mp->b_datap);
-	newm=(mblk_t *) ortp_malloc(sizeof(mblk_t));
-	mblk_init(newm);
+	newm=(mblk_t *) ortp_malloc0(sizeof(mblk_t));
 	mblk_meta_copy(mp, newm);
 	newm->b_datap=mp->b_datap;
 	newm->b_rptr=mp->b_rptr;
@@ -242,15 +233,15 @@ void msgpullup(mblk_t *mp,size_t len)
 {
 	mblk_t *firstm=mp;
 	dblk_t *db;
-	int wlen=0;
+	size_t wlen=0;
 
 	if (mp->b_cont==NULL && len==-1) return;	/*nothing to do, message is not fragmented */
 
 	if (len==-1) len=msgdsize(mp);
 	db=datab_alloc(len);
 	while(wlen<len && mp!=NULL){
-		int remain=len-wlen;
-		int mlen=mp->b_wptr-mp->b_rptr;
+		int remain=(int)(len-wlen);
+		int mlen=(int)(mp->b_wptr-mp->b_rptr);
 		if (mlen<=remain){
 			memcpy(&db->db_base[wlen],mp->b_rptr,mlen);
 			wlen+=mlen;
@@ -298,7 +289,7 @@ mblk_t * appendb(mblk_t *mp, const char *data, size_t size, bool_t pad){
 	size_t padcnt=0;
 	size_t i;
 	if (pad){
-		padcnt= (size_t)(4L-( (long)(((long)mp->b_wptr)+size) % 4L)) % 4L;
+		padcnt = (size_t)(4 - ((((intptr_t)mp->b_wptr) + size) % 4)) % 4;
 	}
 	if ((mp->b_wptr + size +padcnt) > mp->b_datap->db_lim){
 		/* buffer is not large enough: append a new block (with the same size ?)*/
@@ -337,7 +328,7 @@ mblk_t *msgb_allocator_alloc(msgb_allocator_t *a, size_t size){
 
 	/*lookup for an unused msgb (data block with ref count ==1)*/
 	for(m=qbegin(q);!qend(q,m);m=qnext(q,m)){
-		if (m->b_datap->db_ref==1 && m->b_datap->db_lim-m->b_datap->db_base>=size){
+		if ((m->b_datap->db_ref == 1) && ((size_t)(m->b_datap->db_lim - m->b_datap->db_base) >= size)){
 			found=m;
 			break;
 		}
@@ -352,3 +343,19 @@ mblk_t *msgb_allocator_alloc(msgb_allocator_t *a, size_t size){
 void msgb_allocator_uninit(msgb_allocator_t *a){
 	flushq(&a->q,-1);
 }
+
+void ortp_recvaddr_to_sockaddr(ortp_recv_addr_t *recvaddr, struct sockaddr *addr, socklen_t *socklen) {
+	if (recvaddr->family == AF_INET) {
+		struct sockaddr_in *addr_in = (struct sockaddr_in *)addr;
+		addr_in->sin_family = AF_INET;
+		addr_in->sin_addr = recvaddr->addr.ipi_addr;
+		addr_in->sin_port = recvaddr->port;
+		*socklen = sizeof(struct sockaddr_in);
+	} else if (recvaddr->family == AF_INET6) {
+		struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr;
+		addr_in6->sin6_family = AF_INET6;
+		addr_in6->sin6_addr = recvaddr->addr.ipi6_addr;
+		addr_in6->sin6_port = recvaddr->port;
+		*socklen = sizeof(struct sockaddr_in6);
+	}
+}
diff --git a/src/telephonyevents.c b/src/telephonyevents.c
index a2a2596..9fed723 100644
--- a/src/telephonyevents.c
+++ b/src/telephonyevents.c
@@ -35,9 +35,9 @@ PayloadType	payload_type_telephone_event={
 };
 
 /**
- * Tells whether telephony events payload type is supported within the 
+ * Tells whether telephony events payload type is supported within the
  * context of the rtp session.
- * @param session a rtp session 
+ * @param session a rtp session
  *
  * @return the payload type number used for telephony events if found, -1 if not found.
 **/
@@ -54,9 +54,9 @@ bool_t rtp_profile_is_telephone_event(const RtpProfile *prof, int pt_num){
 
 
 /**
- * Tells whether telephone event payload type is supported for send within the 
+ * Tells whether telephone event payload type is supported for send within the
  * context of the rtp session.
- * @param session a rtp session 
+ * @param session a rtp session
  *
  * @return the payload type number used for telephony events if found, -1 if not found.
 **/
@@ -67,9 +67,9 @@ int rtp_session_send_telephone_events_supported(RtpSession *session)
 }
 
 /**
- * Tells whether telephone event payload type is supported for receiving within the 
+ * Tells whether telephone event payload type is supported for receiving within the
  * context of the rtp session.
- * @param session a rtp session 
+ * @param session a rtp session
  *
  * @return the payload type number used for telephony events if found, -1 if not found.
 **/int rtp_session_recv_telephone_events_supported(RtpSession *session)
@@ -88,17 +88,32 @@ int rtp_session_send_telephone_events_supported(RtpSession *session)
  * @param start boolean to indicate if the marker bit should be set.
  *
  * @return a message block containing the rtp packet if successfull, NULL if the rtp session
- *cannot support telephony event (because the rtp profile it is bound to does not include
- *a telephony event payload type).
+ * cannot support telephony event (because the rtp profile it is bound to does not include
+ * a telephony event payload type).
 **/
 mblk_t	*rtp_session_create_telephone_event_packet(RtpSession *session, int start)
 {
 	mblk_t *mp;
 	rtp_header_t *rtp;
 	PayloadType *cur_pt=rtp_profile_get_payload(session->snd.profile, rtp_session_get_send_payload_type(session));
-	int tev_pt=rtp_profile_find_payload_number(session->snd.profile, "telephone-event", cur_pt ? cur_pt->clock_rate : 8000, 1);
+	int tev_pt = session->tev_send_pt;
+
+	if (tev_pt != -1){
+		PayloadType *cur_tev_pt=rtp_profile_get_payload(session->snd.profile, tev_pt);
+		if (!cur_tev_pt){
+			ortp_error("Undefined telephone-event payload type %i choosen for sending telephone event", tev_pt);
+			tev_pt = -1;
+		}else if (cur_pt && cur_tev_pt->clock_rate != cur_pt->clock_rate){
+			ortp_warning("Telephone-event payload type %i has clockrate %i while main audio codec has clockrate %i: this is not permitted.",
+				tev_pt, cur_tev_pt->clock_rate, cur_pt->clock_rate);
+		}
+	}
+
+	if (tev_pt == -1){
+		tev_pt = rtp_profile_find_payload_number(session->snd.profile, "telephone-event", cur_pt ? cur_pt->clock_rate : 8000, 1);
+	}
 	return_val_if_fail(tev_pt!=-1,NULL);
-	
+
 	mp=allocb(RTP_FIXED_HEADER_SIZE+TELEPHONY_EVENTS_ALLOCATED_SIZE,BPRI_MED);
 	if (mp==NULL) return NULL;
 	rtp=(rtp_header_t*)mp->b_rptr;
@@ -110,10 +125,10 @@ mblk_t	*rtp_session_create_telephone_event_packet(RtpSession *session, int start
 	rtp->ssrc = session->snd.ssrc;
 	/* timestamp set later, when packet is sended */
 	/*seq number set later, when packet is sended */
-	
+
 	/*set the payload type */
 	rtp->paytype=tev_pt;
-	
+
 	/*copy the payload */
 	mp->b_wptr+=RTP_FIXED_HEADER_SIZE;
 	return mp;
@@ -266,12 +281,12 @@ int rtp_session_send_dtmf2(RtpSession *session, char dtmf, uint32_t userts, int
 	m2=rtp_session_create_telephone_event_packet(session,0);
 	if (m2==NULL) return -1;
 	rtp_session_add_telephone_event(session,m2,tev_type,0,10, durationtier+durationtier);
-		
+
 	/* create a third and final packet */
 	m3=rtp_session_create_telephone_event_packet(session,0);
 	if (m3==NULL) return -1;
 	rtp_session_add_telephone_event(session,m3,tev_type,1,10,duration);
-	
+
 	/* and now sends them */
 	rtp_session_sendm_with_ts(session,m1,userts);
 	rtp_session_sendm_with_ts(session,m2,userts);
@@ -293,7 +308,7 @@ int rtp_session_send_dtmf2(RtpSession *session, char dtmf, uint32_t userts, int
 
 
 /**
- *	Reads telephony events from a rtp packet. *@tab points to the beginning of the event buffer.
+ *	Reads telephony events from a rtp packet. \a *tab points to the beginning of the event buffer.
  *
  * @param session a rtp session from which telephony events are received.
  * @param packet a rtp packet as a mblk_t.
@@ -324,7 +339,7 @@ int rtp_session_read_telephone_event(RtpSession *session,
 static void notify_tev(RtpSession *session, telephone_event_t *event){
 	OrtpEvent *ev;
 	OrtpEventData *evd;
-	rtp_signal_table_emit2(&session->on_telephone_event,(long)(long)event[0].event);
+	rtp_signal_table_emit2(&session->on_telephone_event,ORTP_INT_TO_POINTER(event[0].event));
 	if (session->eventqs!=NULL){
 		ev=ortp_event_new(ORTP_EVENT_TELEPHONE_EVENT);
 		evd=ortp_event_get_data(ev);
@@ -353,15 +368,15 @@ void rtp_session_check_telephone_events(RtpSession *session, mblk_t *m0)
 	mblk_t *cur_tev;
 	unsigned char *payload;
 	int datasize;
-	
+
 	hdr=(rtp_header_t*)m0->b_rptr;
-	
+
 	datasize=rtp_get_payload(m0,&payload);
 
 	num=datasize/sizeof(telephone_event_t);
 	events=(telephone_event_t*)payload;
-	
-	
+
+
 	if (hdr->markbit==1)
 	{
 		/* this is a start of new events. Store the event buffer for later use*/
@@ -411,7 +426,7 @@ void rtp_session_check_telephone_events(RtpSession *session, mblk_t *m0)
 	else
 	{
 		/* there is no pending events, but we did not received marked bit packet
-		either the sending implementation is not compliant, either it has been lost, 
+		either the sending implementation is not compliant, either it has been lost,
 		we must deal with it anyway.*/
 		session->current_tev=copymsg(m0);
 		/* inform the application if there are tone ends */
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 8df554c..1ee22d8 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -21,33 +21,46 @@
 ############################################################################
 
 set(RTPSEND_SOURCES rtpsend.c)
+apply_compile_flags(RTPSEND_SOURCES "CPP" "C")
 add_executable(rtpsend ${RTPSEND_SOURCES})
 target_link_libraries(rtpsend ortp)
 
 set(RTPRECV_SOURCES rtprecv.c)
+apply_compile_flags(RTPRECV_SOURCES "CPP" "C")
 add_executable(rtprecv ${RTPRECV_SOURCES})
 target_link_libraries(rtprecv ortp)
 
 set(MRTPSEND_SOURCES mrtpsend.c)
+apply_compile_flags(MRTPSEND_SOURCES "CPP" "C")
 add_executable(mrtpsend ${MRTPSEND_SOURCES})
 target_link_libraries(mrtpsend ortp)
 
 set(MRTPRECV_SOURCES mrtprecv.c)
+apply_compile_flags(MRTPRECV_SOURCES "CPP" "C")
 add_executable(mrtprecv ${RTPRECV_SOURCES})
 target_link_libraries(mrtprecv ortp)
 
 set(TEST_TIMER_SOURCES test_timer.c)
+apply_compile_flags(TEST_TIMER_SOURCES "CPP" "C")
 add_executable(test_timer ${TEST_TIMER_SOURCES})
 target_link_libraries(test_timer ortp)
 
 set(TEVRTPSEND_SOURCES tevrtpsend.c)
+apply_compile_flags(TEVRTPSEND_SOURCES "CPP" "C")
 add_executable(tevrtpsend ${TEVRTPSEND_SOURCES})
 target_link_libraries(tevrtpsend ortp)
 
 set(TEVRTPRECV_SOURCES tevrtprecv.c)
+apply_compile_flags(TEVRTPRECV_SOURCES "CPP" "C")
 add_executable(tevrtprecv ${TEVRTPRECV_SOURCES})
 target_link_libraries(tevrtprecv ortp)
 
 set(RTPSEND_STUPID_SOURCES rtpsend_stupid.c)
+apply_compile_flags(RTPSEND_STUPID_SOURCES "CPP" "C")
 add_executable(rtpsend_stupid ${RTPSEND_STUPID_SOURCES})
 target_link_libraries(rtpsend_stupid ortp)
+
+install(TARGETS rtpsend rtprecv mrtpsend mrtprecv test_timer tevrtpsend tevrtprecv rtpsend_stupid
+	RUNTIME DESTINATION bin
+	PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+)
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 2122c42..bac29e4 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -31,4 +31,4 @@ endif
 AM_CPPFLAGS=-I$(top_srcdir)/include/
 AM_CFLAGS=-D_ORTP_SOURCE $(PTHREAD_CFLAGS) 
 AM_LDFLAGS=$(PTHREAD_LDFLAGS)
-LDADD=$(top_builddir)/src/libortp.la $(SSL_LIBS)
+LDADD=$(top_builddir)/src/libortp.la $(BCTOOLBOX_LIBS)
diff --git a/src/tests/rtprecv.c b/src/tests/rtprecv.c
index dc113f7..59c81ac 100644
--- a/src/tests/rtprecv.c
+++ b/src/tests/rtprecv.c
@@ -140,7 +140,7 @@ int main(int argc, char*argv[])
 	
 	ortp_init();
 	ortp_scheduler_init();
-	ortp_set_log_level_mask(ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
+	ortp_set_log_level_mask(NULL, ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
 	signal(SIGINT,stop_handler);
 	session=rtp_session_new(RTP_SESSION_RECVONLY);	
 	rtp_session_set_scheduling_mode(session,1);
diff --git a/src/tests/rtpsend.c b/src/tests/rtpsend.c
index d1fefe8..24919d3 100644
--- a/src/tests/rtpsend.c
+++ b/src/tests/rtpsend.c
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
 	
 	ortp_init();
 	ortp_scheduler_init();
-	ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
+	ortp_set_log_level_mask(NULL, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
 	session=rtp_session_new(RTP_SESSION_SENDONLY);	
 	
 	rtp_session_set_scheduling_mode(session,1);
@@ -109,13 +109,8 @@ int main(int argc, char *argv[])
 		}
 		/*this will simulate a burst of late packets */
 		if (jitter && (user_ts%(8000)==0)) {
-			struct timespec pausetime, remtime;
 			ortp_message("Simulating late packets now (%i milliseconds)",jitter);
-			pausetime.tv_sec=jitter/1000;
-			pausetime.tv_nsec=(jitter%1000)*1000000;
-			while(nanosleep(&pausetime,&remtime)==-1 && errno==EINTR){
-				pausetime=remtime;
-			}
+			ortp_sleep_ms(jitter);
 		}
 	}
 
diff --git a/src/tests/rtpsend_stupid.c b/src/tests/rtpsend_stupid.c
index 80db79a..3395d8f 100644
--- a/src/tests/rtpsend_stupid.c
+++ b/src/tests/rtpsend_stupid.c
@@ -27,7 +27,7 @@
 #include <stdio.h>
 #endif
 /*defined in library, but not declared in public headers (this method is only useful for tests)*/
-extern int __rtp_session_sendm_with_ts(RtpSession *session, mblk_t *packet, uint32_t packet_ts, uint32_t send_ts);
+ORTP_PUBLIC extern int __rtp_session_sendm_with_ts(RtpSession *session, mblk_t *packet, uint32_t packet_ts, uint32_t send_ts);
 
 int runcond=1;
 
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
 	
 	ortp_init();
 	ortp_scheduler_init();
-	ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
+	ortp_set_log_level_mask(NULL, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
 	session=rtp_session_new(RTP_SESSION_SENDONLY);	
 	
 	rtp_session_set_scheduling_mode(session,1);
diff --git a/src/tests/tevrtprecv.c b/src/tests/tevrtprecv.c
index ee6ffdb..c713027 100644
--- a/src/tests/tevrtprecv.c
+++ b/src/tests/tevrtprecv.c
@@ -45,7 +45,7 @@ int dtmf_count=0;
 
 void recv_tev_cb(RtpSession *session,unsigned long type, unsigned long dummy, void* user_data)
 {
-	printf("Receiving telephony event:%i\n",type);
+	printf("Receiving telephony event:%lu\n",type);
 	if (type<16) printf("This is dtmf %c\n",dtmf_tab[type]);
 	dtmf_count++;
 }
@@ -66,20 +66,20 @@ int main(int argc, char *argv[])
 
 	ortp_init();
 	ortp_scheduler_init();
-	
+
 	/* set the telephony event payload type to 96 in the av profile.*/
 	rtp_profile_set_payload(&av_profile,96,&payload_type_telephone_event);
-	
-	session=rtp_session_new(RTP_SESSION_RECVONLY);	
-	
+
+	session=rtp_session_new(RTP_SESSION_RECVONLY);
+
 	rtp_session_set_scheduling_mode(session,1);
 	rtp_session_set_blocking_mode(session,1);
 	rtp_session_set_local_addr(session,"0.0.0.0",atoi(argv[2]),-1);
 	rtp_session_set_payload_type(session,0);
-	
+
 	/* register for telephony events */
 	rtp_session_signal_connect(session,"telephone-event",(RtpCallback)recv_tev_cb,0);
-		
+
 	outfile=fopen(argv[1],"wb");
 	if (outfile==NULL) {
 		perror("Cannot open file");
@@ -92,8 +92,7 @@ int main(int argc, char *argv[])
 		while (have_more){
 			err=rtp_session_recv_with_ts(session,buffer,160,ts,&have_more);
 			if (err>0) {
-				size_t ret = fwrite(buffer,1,err,outfile);
-				assert( ret == err );
+				assert(fwrite(buffer,1,err,outfile) == err );
 			}
 		}
 		ts+=160;
diff --git a/src/utils.c b/src/utils.c
index bd2475b..9ca8483 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -33,6 +33,15 @@ OList *o_list_new(void *data){
 	return new_elem;
 }
 
+OList * o_list_prepend(OList *elem, void * data){
+	OList *new_elem=o_list_new(data);
+	if (elem){
+		elem->prev = new_elem;
+		new_elem->next = elem;
+	}
+	return new_elem;
+}
+
 OList * o_list_append(OList *elem, void * data){
 	OList *new_elem=o_list_new(data);
 	OList *it=elem;
@@ -56,6 +65,21 @@ OList * o_list_free(OList *list){
 	return NULL;
 }
 
+OList * o_list_free_with_data(OList *list, void (*freefunc)(void*)){
+	OList *elem = list;
+	OList *tmp;
+	if (!list) return NULL;
+	while(elem->next!=NULL) {
+		tmp = elem;
+		elem = elem->next;
+		freefunc(tmp->data);
+		ortp_free(tmp);
+	}
+	freefunc(elem->data);
+	ortp_free(elem);
+	return NULL;
+}
+
 OList *o_list_remove_link(OList *list, OList *elem){
 	OList *ret;
 	if (elem==list){
diff --git a/src/utils.h b/src/utils.h
index b33ddbc..518f7a5 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -30,6 +30,9 @@
 #include "ortp/event.h"
 #include "ortp/rtpsession.h"
 
+void ortp_init_logger(void);
+void ortp_uninit_logger(void);
+
 struct _OList {
 	struct _OList *next;
 	struct _OList *prev;
@@ -41,13 +44,16 @@ struct _OList {
 #define o_list_prev(elem) ((elem)->prev)
 
 OList * o_list_append(OList *elem, void * data);
+OList * o_list_prepend(OList *elem, void * data);
 OList * o_list_remove(OList *list, void *data);
 OList * o_list_free(OList *elem);
 OList *o_list_remove_link(OList *list, OList *elem);
+OList * o_list_free_with_data(OList *list, void (*freefunc)(void*));
+
 
+#define ORTP_POINTER_TO_INT(p) ((int)(intptr_t)(p))
+#define ORTP_INT_TO_POINTER(i) ((void *)(intptr_t)(i))
 
-#define INT_TO_POINTER(truc)	((long)(long)(truc))
-#define POINTER_TO_INT(truc)	((int)(long)(truc))
 
 typedef struct _dwsplit_t{
 #ifdef ORTP_BIGENDIAN
@@ -71,7 +77,7 @@ typedef union{
 #endif
 #define ntoh24(x) hton24(x)
 
-#if defined(WIN32) || defined(_WIN32_WCE)
+#if defined(_WIN32) || defined(_WIN32_WCE)
 #define is_would_block_error(errnum)	(errnum==WSAEWOULDBLOCK)
 #else
 #define is_would_block_error(errnum)	(errnum==EWOULDBLOCK || errnum==EAGAIN)
@@ -83,6 +89,6 @@ uint64_t ortp_timeval_to_ntp(const struct timeval *tv);
 
 bool_t ortp_stream_is_ipv6(OrtpStream *os);
 
-int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m,  int flags, const struct sockaddr *destaddr, socklen_t destlen);
 int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen);
+void _rtp_session_release_sockets(RtpSession *session, bool_t release_transports);
 #endif
diff --git a/src/winrttimer.cpp b/src/winrttimer.cpp
index d660f64..5e11bbb 100644
--- a/src/winrttimer.cpp
+++ b/src/winrttimer.cpp
@@ -1,12 +1,14 @@
 #include <windows.h>
 
-#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-
-#using <Windows.winmd>
-
 #include "winrttimer.h"
 #include "ortp/logging.h"
 
+#ifndef ORTP_WINDOWS_DESKTOP
+
+#ifdef ORTP_WINDOWS_PHONE
+#using <Windows.winmd>
+#endif
+
 using namespace Windows::Foundation;
 using namespace Windows::System::Threading;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/ortp.git



More information about the Pkg-voip-commits mailing list