Commit a9c46d1f authored by Sandrine Avakian's avatar Sandrine Avakian
Browse files

Merge branch 'master' of git.linphone.org:mediastreamer2 into dev_codecbv16

parents b4994bdb 622a95dd
......@@ -68,7 +68,6 @@ option(ENABLE_RELATIVE_PREFIX "Find resources relatively to the installation dir
option(ENABLE_TOOLS "Turn on or off compilation of tools." YES)
option(ENABLE_UNIT_TESTS "Enable compilation of unit tests." YES)
cmake_dependent_option(ENABLE_DTLS "Build with DTLS support." YES "ENABLE_SRTP" NO)
option(ENABLE_SRTP "Build with the SRTP transport support." YES)
cmake_dependent_option(ENABLE_ZRTP "Build with ZRTP support." YES "ENABLE_SRTP" NO)
......@@ -151,7 +150,8 @@ if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
else()
find_package(ORTP REQUIRED)
endif()
find_package(PolarSSL)
if(ENABLE_PCAP)
find_package(PCAP QUIET)
endif()
......@@ -176,7 +176,6 @@ if(ENABLE_SRTP)
if(NOT SRTP_FOUND)
message(WARNING "Could not find SRTP library, Mediastreamer2 will be compiled without SRTP support.")
set(ENABLE_SRTP OFF CACHE BOOL "Build with the SRTP transport support." FORCE)
set(ENABLE_DTLS OFF CACHE BOOL "Build mediastreamer2 with DTLS support." FORCE)
endif()
endif()
if(ENABLE_ZRTP)
......@@ -190,16 +189,6 @@ if(ENABLE_ZRTP)
set(ENABLE_ZRTP OFF CACHE BOOL "Build mediastreamer2 with ZRTP support." FORCE)
endif()
endif()
if(ENABLE_DTLS AND ENABLE_SRTP) # DTLS requires SRTP
if(NOT POLARSSL_FOUND OR NOT HAVE_SSL_GET_DTLS_SRTP_PROTECTION_PROFILE)
if (NOT POLARSSL_FOUND)
message(WARNING "Could not find polarssl library required by DTLS, mediastreamer2 will be compiled without DTLS support.")
else()
message(WARNING "Polarssl library was found but misses HAVE_SSL_GET_DTLS_SRTP_PROTECTION_PROFILE required by DTLS, mediastreamer2 will be compiled without DTLS support.")
endif()
set(ENABLE_DTLS OFF CACHE BOOL "Build mediastreamer2 with DTLS support." FORCE)
endif()
endif()
if(ENABLE_GSM)
find_package(GSM)
if(NOT GSM_FOUND)
......@@ -319,6 +308,11 @@ if(ENABLE_SOUND AND NOT(WIN32 OR ENABLE_ALSA OR ENABLE_ARTSC OR ENABLE_MACSND OR
message(FATAL_ERROR "Could not find a support sound driver API. Use -DENABLE_SOUND=NO if you don't care about having sound.")
endif()
if(LINPHONE_BUILDER_GROUP_EXTERNAL_SOURCE_PATH_BUILDERS)
include("${EP_bctoolbox_CONFIG_DIR}/BcToolboxConfig.cmake")
else()
find_package(BcToolBox REQUIRED)
endif()
include_directories(
include
......@@ -328,6 +322,7 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src
${ORTP_INCLUDE_DIRS}
${BCTOOLBOX_INCLUDE_DIRS}
)
if(BZRTP_FOUND)
......@@ -336,9 +331,6 @@ endif()
if(SRTP_FOUND)
include_directories(${SRTP_INCLUDE_DIRS})
endif()
if(POLARSSL_FOUND)
include_directories(${POLARSSL_INCLUDE_DIRS})
endif()
if(GSM_FOUND)
include_directories(${GSM_INCLUDE_DIRS})
endif()
......@@ -420,9 +412,6 @@ endif()
if(BZRTP_FOUND)
set(HAVE_ZRTP 1)
endif()
if(ENABLE_DTLS)
set(HAVE_DTLS 1)
endif()
if(ENABLE_ALSA)
set(__ALSA_ENABLED__ 1)
endif()
......
############################################################################
# FindPolarSSL.txt
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
#
# - Find the polarssl include file and library
#
# POLARSSL_FOUND - system has polarssl
# POLARSSL_INCLUDE_DIRS - the polarssl include directory
# POLARSSL_LIBRARIES - The libraries needed to use polarssl
include(CMakePushCheckState)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
include(CheckSymbolExists)
set(_POLARSSL_ROOT_PATHS
${CMAKE_INSTALL_PREFIX}
)
find_path(POLARSSL_INCLUDE_DIRS
NAMES polarssl/ssl.h
HINTS _POLARSSL_ROOT_PATHS
PATH_SUFFIXES include
)
if(POLARSSL_INCLUDE_DIRS)
set(HAVE_POLARSSL_SSL_H 1)
endif()
find_library(POLARSSL_LIBRARIES
NAMES polarssl
HINTS _POLARSSL_ROOT_PATHS
PATH_SUFFIXES bin lib
)
if(POLARSSL_LIBRARIES)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${POLARSSL_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${POLARSSL_LIBRARIES})
check_c_source_compiles("#include <polarssl/version.h>
#include <polarssl/x509.h>
#if POLARSSL_VERSION_NUMBER >= 0x01030000
#include <polarssl/compat-1.2.h>
#endif
int main(int argc, char *argv[]) {
x509parse_crtpath(0,0);
return 0;
}"
X509PARSE_CRTPATH_OK)
check_symbol_exists(ssl_get_dtls_srtp_protection_profile "polarssl/ssl.h" HAVE_SSL_GET_DTLS_SRTP_PROTECTION_PROFILE)
cmake_pop_check_state()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PolarSSL
DEFAULT_MSG
POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES HAVE_POLARSSL_SSL_H
)
mark_as_advanced(POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES HAVE_POLARSSL_SSL_H X509PARSE_CRTPATH_OK HAVE_SSL_GET_DTLS_SRTP_PROTECTION_PROFILE)
......@@ -1119,6 +1119,15 @@ else
fi
dnl check bctoolbox library
PKG_CHECK_MODULES(BCTOOLBOX, bctoolbox >= 0.0.0, found_bctoolbox=true, found_bctoolbox=false)
if test "$found_bctoolbox" = "true" ; then
LIBS="$LIBS $BCTOOLBOX_LIBS"
CFLAGS="$CFLAGS $BCTOOLBOX_CFLAGS"
else
AC_MSG_ERROR("Could not found Bctoolbox")
fi
dnl check for libzrtp support (RFC 6189: Media Path Key Agreement for Unicast Secure RTP)
AC_ARG_ENABLE(zrtp,
[AS_HELP_STRING([--enable-zrtp], [Turn on or off compilation of zrtp (default=detect)])],
......@@ -1130,6 +1139,7 @@ AC_ARG_ENABLE(zrtp,
[zrtp=detect]
)
if test "$zrtp" != "false" ; then
PKG_CHECK_MODULES(LIBBZRTP, libbzrtp >= 1.0.0, found_zrtp=true, found_zrtp=false)
if test "$zrtp$found_zrtp" = "truefalse" ; then
......@@ -1156,79 +1166,6 @@ fi
AM_CONDITIONAL(LIBBZRTP,test x$zrtp != xfalse)
dnl Polarssl lib is requested for DTLS
AC_ARG_WITH( polarssl,
[ --with-polarssl Set prefix where polarssl can be found (ex:/usr, /usr/local)[[default=PREFIX or /usr if NONE]] ],
[ polarssl_prefix=${withval}],[ if test "$prefix" != "NONE"; then
polarssl_prefix=${prefix}
else
polarssl_prefix="/usr"
fi ])
found_polarssl=no
if test "$polarssl_prefix" != "none" ; then
if test "$polarssl_prefix" != "/usr" ; then
POLARSSL_CFLAGS="-I${polarssl_prefix}/include"
POLARSSL_LIBS="-L${polarssl_prefix}/lib"
fi
CPPFLAGS_save=$CPPFLAGS
LIBS_save=$LIBS
CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
LIBS="$LIBS $POLARSSL_LIBS"
AC_CHECK_LIB(mbedtls, sha1_update , [found_polarssl=yes POLARSSL_LIBS="$POLARSSL_LIBS -lmbedtls"],
[AC_CHECK_LIB(polarssl, sha1_update, [found_polarssl=yes POLARSSL_LIBS="$POLARSSL_LIBS -lpolarssl"],[AC_MSG_NOTICE([polarssl library not found !])])])
if test "x$found_polarssl" == "xyes" ; then
AC_CHECK_HEADERS(polarssl/ssl.h, [found_polarssl=yes],[found_polarssl=no POLARSSL_CFLAGS="" POLARSSL_LIBS=""])
fi
CPPFLAGS=$CPPFLAGS_save
LIBS=$LIBS_save
fi
dnl check for DTLS-SRTP support, need polarssl version >= 1.4
AC_ARG_ENABLE(dtls,
[AS_HELP_STRING([--enable-dtls], [Turn on or off compilation of dtls (default=no)])],
[case "${enableval}" in
yes) dtls=true ;;
no) dtls=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-dtls) ;;
esac],
[dtls=false]
)
if test "$dtls" = "true" ; then
if test "$have_srtp" = "false" ; then
AC_MSG_ERROR("DTLS-SRTP requires SRTP")
fi
if test "x$found_polarssl" != "xyes" ; then
AC_MSG_ERROR("DTLS-SRTP requires POLARSSL")
fi
dnl check for polarssl presence and support for DTLS
CPPFLAGS_save=$CPPFLAGS
LIBS_save=$LIBS
CPPFLAGS="$CPPFLAGS $POLARSSL_CFLAGS"
LIBS="$LIBS $POLARSSL_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <polarssl/ssl.h>
]],
[[ssl_set_dtls_srtp_protection_profiles(0,0,0)]])],
[AC_DEFINE(HAVE_DTLS, 1, [Defined when dtls support is compiled])
AC_MSG_NOTICE([polarssl usable for DTLS-SRTP])],[AC_MSG_ERROR([polarssl not usable for DTLS-SRTP])])
CPPFLAGS=$CPPFLAGS_save
LIBS=$LIBS_save
else
echo "DTLS-SRTP compilation is disabled."
fi
AC_SUBST(POLARSSL_CFLAGS)
AC_SUBST(POLARSSL_LIBS)
dnl check for bcg729 annexB presence to use for VAD/DTX (RFC3389 : Real-time Transport Protocol (RTP) Payload for Comfort Noise (CN))
AC_ARG_ENABLE(g729bCN,
[AS_HELP_STRING([--enable-g729bCN], [Turn on or off usage of G729AnnexB in RFC3389 implementation of Comfort Noise Payload (default=no)])],
......@@ -1379,6 +1316,5 @@ echo "Summary of build options:"
printf "* %-30s %s\n" "Video support" $video
printf "* %-30s %s\n" "sRTP encryption" $have_srtp
printf "* %-30s %s\n" "zRTP encryption" $zrtp
printf "* %-30s %s\n" "SRTP-DTLS encryption" $dtls
printf "* %-30s %s\n" "Non-free codecs" $non_free_codecs
......@@ -375,6 +375,7 @@ endif()
set(VOIP_LIBS
${BCTOOLBOX_LIBRARIES}
${ORTP_LIBRARIES}
mediastreamer_base
)
......@@ -398,9 +399,6 @@ endif()
if(SRTP_FOUND)
list(APPEND VOIP_LIBS ${SRTP_LIBRARIES})
endif()
if(POLARSSL_FOUND)
list(APPEND VOIP_LIBS ${POLARSSL_LIBRARIES})
endif()
if(GSM_FOUND)
list(APPEND VOIP_LIBS ${GSM_LIBRARIES})
endif()
......
......@@ -57,7 +57,7 @@ libmediastreamer_voip_la_LIBADD= libmediastreamer_base.la \
$(PCAP_LIBS) \
$(OPUS_LIBS) \
$(SRTP_LIBS) \
$(POLARSSL_LIBS)
$(BCTOOLBOX_LIBS)
if LIBBZRTP
......@@ -398,7 +398,7 @@ AM_CFLAGS=\
$(PCAP_CFLAGS) \
$(OPUS_CFLAGS) \
$(SRTP_CFLAGS) \
$(POLARSSL_CFLAGS)
$(BCTOOLBOX_CFLAGS)
AM_CXXFLAGS=\
$(STRICT_OPTIONS) \
......
This diff is collapsed.
......@@ -86,7 +86,7 @@ static void send_stun_packet(SenderData *d, bool_t enable_rtp, bool_t enable_rtc
mp = allocb(len, BPRI_MED);
memcpy(mp->b_wptr, buf, len);
mp->b_wptr += len;
ms_message("Stun packet sent on rtcp for session [%p]",s);
ms_message("Stun packet sent on rtcp for session [%p]",s);
rtp_session_rtcp_sendm_raw(s,mp);
}
}
......
......@@ -195,8 +195,8 @@ static void audio_stream_configure_resampler(AudioStream *st, MSFilter *resample
ms_filter_call_method(resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&to_rate);
ms_filter_call_method(resampler, MS_FILTER_SET_NCHANNELS, &from_channels);
ms_filter_call_method(resampler, MS_FILTER_SET_OUTPUT_NCHANNELS, &to_channels);
ms_message("configuring %s-->%s from rate [%i] to rate [%i] and from channel [%i] to channel [%i]",
from->desc->name, to->desc->name, from_rate, to_rate, from_channels, to_channels);
ms_message("configuring %s:%p-->%s:%p from rate [%i] to rate [%i] and from channel [%i] to channel [%i]",
from->desc->name, from, to->desc->name, to, from_rate, to_rate, from_channels, to_channels);
}
static void audio_stream_process_rtcp(MediaStream *media_stream, mblk_t *m){
......@@ -824,7 +824,6 @@ int audio_stream_start_from_io(AudioStream *stream, RtpProfile *profile, const c
} else {
stream->soundread=ms_factory_create_filter(stream->ms.factory, MS_FILE_PLAYER_ID);
stream->read_resampler=ms_factory_create_filter(stream->ms.factory, MS_RESAMPLE_ID);
}
if (io->output.type == MSResourceSoundcard) {
if (stream->soundwrite==NULL)
......@@ -834,14 +833,10 @@ int audio_stream_start_from_io(AudioStream *stream, RtpProfile *profile, const c
pt = rtp_profile_get_payload(rtp_session_get_profile(stream->rtp_io_session),
rtp_session_get_send_payload_type(stream->rtp_io_session));
stream->soundwrite = ms_factory_create_filter(stream->ms.factory, MS_RTP_SEND_ID);
ms_filter_call_method(stream->soundwrite, MS_RTP_SEND_SET_SESSION, stream->rtp_io_session);
stream->write_encoder = ms_factory_create_decoder(stream->ms.factory,pt->mime_type);
stream->write_encoder = ms_factory_create_encoder(stream->ms.factory,pt->mime_type);
} else {
stream->soundwrite=ms_factory_create_filter(stream->ms.factory, MS_FILE_REC_ID);
}
/* creates the couple of encoder/decoder */
......@@ -1059,10 +1054,14 @@ int audio_stream_start_from_io(AudioStream *stream, RtpProfile *profile, const c
/*configure resamplers if needed*/
if (stream->read_resampler) {
audio_stream_configure_resampler(stream, stream->read_resampler, stream->soundread, stream->ms.encoder);
MSFilter *from = stream->soundread;
if (stream->read_decoder) from = stream->read_decoder;
audio_stream_configure_resampler(stream, stream->read_resampler, from, stream->ms.encoder);
}
if (stream->write_resampler) {
audio_stream_configure_resampler(stream, stream->write_resampler, stream->ms.decoder, stream->soundwrite);
MSFilter *to = stream->soundwrite;
if (stream->write_encoder) to = stream->write_encoder;
audio_stream_configure_resampler(stream, stream->write_resampler, stream->ms.decoder, to);
}
if (stream->ms.rc_enable){
......
......@@ -118,6 +118,7 @@
#include "mediastreamer2/stun_udp.h"
#include "mediastreamer2/stun.h"
#include "ortp/ortp.h"
#include "bctoolbox/crypto.h"
static char *ipaddr(const StunAddress4 *addr)
{
......@@ -1328,25 +1329,6 @@ randomPort(void)
}
#ifndef HAVE_POLARSSL_SSL_H
void
stunCalculateIntegrity_longterm(char* hmac, const char* input, int length,
const char *username, const char *realm, const char *password)
{
strncpy(hmac,"hmac-not-implemented",20);
ms_error("hmac-not-implemented for stun, mediastreamer2 needs polarssl dependency");
}
void
stunCalculateIntegrity_shortterm(char* hmac, const char* input, int length, const char* key)
{
strncpy(hmac,"hmac-not-implemented",20);
ms_error("hmac-not-implemented for stun, mediastreamer2 needs polarssl dependency");
}
#else
#include "polarssl/sha1.h"
#include "polarssl/md5.h"
void
stunCalculateIntegrity_longterm(char* hmac, const char* input, int length,
const char *username, const char *realm, const char *password)
......@@ -1355,23 +1337,21 @@ stunCalculateIntegrity_longterm(char* hmac, const char* input, int length,
char HA1_text[1024];
snprintf(HA1_text, sizeof(HA1_text), "%s:%s:%s", username, realm, password);
md5((unsigned char *)HA1_text, strlen(HA1_text), HA1);
bctoolbox_md5((unsigned char *)HA1_text, strlen(HA1_text), HA1);
sha1_hmac(HA1, sizeof(HA1),
bctoolbox_hmacSha1(HA1, sizeof(HA1),
(const unsigned char*) input, length,
(unsigned char*)hmac);
20, (unsigned char*)hmac); /* SHA1 output length is 20 bytes, get them all */
}
void
stunCalculateIntegrity_shortterm(char* hmac, const char* input, int length, const char* key)
{
sha1_hmac((const unsigned char *)key, strlen(key),
bctoolbox_hmacSha1((const unsigned char *)key, strlen(key),
(const unsigned char*) input, length,
(unsigned char*)hmac);
20, (unsigned char*)hmac); /* SHA1 output length is 20 bytes, get them all */
}
#endif
uint32_t
stunCalculateFingerprint(const char* input, int length)
{
......
......@@ -43,7 +43,7 @@ TEST_DEPLIBS+=\
$(VP8_LIBS) \
$(VIDEO_LIBS) \
$(PCAP_LIBS) \
$(POLARSSL_LIBS)
$(BCTOOLBOX_LIBS)
if ORTP_ENABLED
if MS2_FILTERS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment