Commit 2ac3fdc3 authored by Alexandre Lision's avatar Alexandre Lision Committed by Guillaume Roguez

ring/contrib: remove CCRTP/UCOMMON/ZRTPCPP deps

This patch have the side effect to refactor audio
and video related parts by moving them into media
sub-directory and making libav common parts
undependent of video.
This patch permits to disable video without
loosing libav support on audio.

Refs #63906

Change-Id: I3d50713fac7f5c2738cc68b9f38573b5b4536b35
parent 8e86991a
......@@ -44,6 +44,8 @@ case "${host_os}" in
SYS=linux
# Necessary for linking .a to a .so
LDFLAGS+=" -Wl,-Bsymbolic"
# Needed for plugin system
LDFLAGS+=" -ldl"
;;
darwin*)
SYS=darwin
......@@ -343,6 +345,18 @@ AS_IF([test "x$with_dbus" = "xyes"], [
AM_CONDITIONAL(RING_DBUS, false));
dnl Check for libav
PKG_CHECK_MODULES(LIBAVCODEC, libavcodec >= 53.5.0,, AC_MSG_ERROR([Missing libavcodec development files]))
LIBAVCODEC_CFLAGS="${LIBAVCODEC_CFLAGS} -D__STDC_CONSTANT_MACROS"
PKG_CHECK_MODULES(LIBAVFORMAT, libavformat >= 54.20.3,, AC_MSG_ERROR([Missing libavformat development files]))
PKG_CHECK_MODULES(LIBSWSCALE, libswscale >= 1.1.0,, AC_MSG_ERROR([Missing libswscale development files]))
PKG_CHECK_MODULES(LIBAVDEVICE, libavdevice >= 53.0.0,, AC_MSG_ERROR([Missing libavdevice development files]))
PKG_CHECK_MODULES(LIBAVUTIL, libavutil >= 51.0.0,, AC_MSG_ERROR([Missing libavutil development files]))
dnl Video is default-enabled
AC_ARG_ENABLE([video], AS_HELP_STRING([--disable-video], [Disable video]))
......@@ -350,30 +364,12 @@ AS_IF([test "x$enable_video" != "xno"],
[
AC_DEFINE(RING_VIDEO, [], [Video support enabled])
AM_CONDITIONAL(RING_VIDEO, true)
PKG_CHECK_MODULES(LIBAVCODEC, libavcodec >= 53.5.0,, AC_MSG_ERROR([Missing libavcodec development files]))
LIBAVCODEC_CFLAGS="${LIBAVCODEC_CFLAGS} -D__STDC_CONSTANT_MACROS"
PKG_CHECK_MODULES(LIBAVFORMAT, libavformat >= 54.20.3,, AC_MSG_ERROR([Missing libavformat development files]))
PKG_CHECK_MODULES(LIBSWSCALE, libswscale >= 1.1.0,, AC_MSG_ERROR([Missing libswscale development files]))
PKG_CHECK_MODULES(LIBAVDEVICE, libavdevice >= 53.0.0,, AC_MSG_ERROR([Missing libavdevice development files]))
PKG_CHECK_MODULES(LIBAVUTIL, libavutil >= 51.0.0,, AC_MSG_ERROR([Missing libavutil development files]))
PKG_CHECK_MODULES(UDEV, libudev,, AC_MSG_ERROR([Missing libudev development files]))
],
[
AM_CONDITIONAL(RING_VIDEO, false)
AC_DEFINE_UNQUOTED([USE_CCRTP], 1, [Use ccrtp instead of libavformat])
]);
LIBCCRTP_MIN_VERSION=1.3.0
PKG_CHECK_MODULES([CCRTP], [libccrtp] >= ${LIBCCRTP_MIN_VERSION},, [
PKG_CHECK_MODULES([CCRTP], [libccrtp1] >= ${LIBCCRTP_MIN_VERSION},, AC_MSG_ERROR([Missing ccrtp development files]))
])
dnl TLS support is enabled if it's installed and up to date
AC_ARG_WITH([tls],
[AS_HELP_STRING([--with-tls],
......@@ -388,25 +384,6 @@ AS_CASE(["$with_tls"],
AC_DEFINE_UNQUOTED([HAVE_TLS], `if test $HAVE_GNUTLS -eq 1; then echo 1; else echo 0; fi`, [Define if you have tls support])
AM_CONDITIONAL(BUILD_TLS, test "$HAVE_GNUTLS" -eq 1)
# ZRTP
# required dependency(ies): libzrtp
dnl Check for libzrtpcpp, a ccRTP extension providing zrtp key exchange
AC_ARG_WITH([zrtp],
[AS_HELP_STRING([--without-zrtp], [disable support for zrtp])],
[],
[with_zrtp=no])
AS_IF([test "x$with_zrtp" = "xyes"], [
PKG_CHECK_MODULES([ZRTPCPP], libzrtpcpp >= 2.3.0, [with_zrtp_configure=yes],
dnl Fallback to older version
[PKG_CHECK_MODULES([ZRTPCPP], libzrtpcpp >= 1.3.0, [with_zrtp_configure=no],
AC_MSG_ERROR([Missing zrtp development files]))])
]);
dnl This is a workaround until libzrtpcpp gets a version macro
AC_DEFINE_UNQUOTED([HAVE_ZRTP], `if test "x$with_zrtp" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have zrtp support])
AC_DEFINE_UNQUOTED([HAVE_ZRTP_CONFIGURE], `if test "x$with_zrtp_configure" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have zrtp >= 2.3.0])
AM_CONDITIONAL(BUILD_ZRTP, test "x$with_zrtp" = "xyes" )
# Instant Messaging
# required dependency(ies): libxpat
AC_ARG_WITH([instant_messaging],
......@@ -598,22 +575,23 @@ AC_CONFIG_FILES([Makefile \
src/im/Makefile \
src/iax/Makefile \
src/ringdht/Makefile \
src/audio/Makefile \
src/audio/audiortp/Makefile \
src/audio/pulseaudio/Makefile \
src/audio/alsa/Makefile \
src/audio/opensl/Makefile \
src/audio/jack/Makefile \
src/audio/coreaudio/Makefile \
src/audio/sound/Makefile \
src/audio/codecs/Makefile \
src/media/Makefile \
src/media/audio/Makefile \
src/media/audio/audiortp/Makefile \
src/media/audio/pulseaudio/Makefile \
src/media/audio/alsa/Makefile \
src/media/audio/opensl/Makefile \
src/media/audio/jack/Makefile \
src/media/audio/coreaudio/Makefile \
src/media/audio/sound/Makefile \
src/media/audio/codecs/Makefile \
src/config/Makefile \
src/client/Makefile \
src/hooks/Makefile \
src/history/Makefile \
src/video/Makefile \
src/video/v4l2/Makefile \
src/video/test/Makefile \
src/media/video/Makefile \
src/media/video/v4l2/Makefile \
src/media/video/test/Makefile \
test/Makefile \
ringtones/Makefile \
man/Makefile \
......
8eb07e2119903bf52dfcc6a7932843bdf14ef686302f333844713c48ba723b5c0211c4b893f29024d4875c3f747fe94eaeadc8a9a4b9993b9766a1373f486062 ccrtp-6d4f1b9ebe9a9b93ec45927b7d8bcda497cc19f6.tar.gz
# CCRTP
# FIXME: switch to next release when it's out
CCRTP_VERSION := 6d4f1b9ebe9a9b93ec45927b7d8bcda497cc19f6
CCRTP_URL := $(GNUTELEPHONY)/ccrtp/archive/$(CCRTP_VERSION).tar.gz
PKGS += ccrtp
ifeq ($(call need_pkg,'libccrtp >= 2.0.3'),)
PKGS_FOUND += ccrtp
endif
DEPS_ccrtp = ucommon gcrypt gnutls
$(TARBALLS)/ccrtp-$(CCRTP_VERSION).tar.gz:
$(call download,$(CCRTP_URL))
.sum-ccrtp: ccrtp-$(CCRTP_VERSION).tar.gz
ccrtp: ccrtp-$(CCRTP_VERSION).tar.gz .sum-ccrtp
$(UNPACK)
$(UPDATE_AUTOCONFIG) && cd $(UNPACK_DIR)
$(MOVE)
.ccrtp: ccrtp
mkdir -p $</m4 && $(RECONF)
cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
cd $< && $(MAKE) install
touch $@
HASH=HEAD
LIBAV_SNAPURL := http://git.libav.org/?p=libav.git;a=snapshot;h=$(HASH);sf=tgz
PKGS += libav
LIBAVCONF = \
--cc="$(CC)" \
--pkg-config="$(PKG_CONFIG)" \
......@@ -104,13 +106,6 @@ else # !Windows
LIBAVCONF += --enable-pthreads
endif
# Only build on Linux for now, since no one else has implemented video
ifdef HAVE_LINUX
ifndef HAVE_ANDROID
PKGS += libav
endif
endif
ifeq ($(call need_pkg,"libavcodec >= 53.5.0 libavformat >= 54.20.3 libswscale libavdevice >= 53.0.0 libavutil >= 51.0.0"),)
PKGS_FOUND += libav
endif
......
# UCOMMON
# FIXME: switch to next release when it's out
UCOMMON_VERSION := 907e98d36cdffa1a0c6c0344993fe0a86f1f239f
UCOMMON_URL := $(GNUTELEPHONY)/ucommon/archive/$(UCOMMON_VERSION).tar.gz
UCOMMON_OPTIONS := --enable-stdcpp --with-pkg-config --disable-utils --disable-tests
ifeq ($(call need_pkg,'ucommon >= ${UCOMMON_VERSION} commoncpp >= ${UCOMMON_VERSION}'),)
PKGS_FOUND += ucommon
endif
DEPS_ucommon = gnutls
$(TARBALLS)/ucommon-$(UCOMMON_VERSION).tar.gz:
$(call download,$(UCOMMON_URL))
.sum-ucommon: ucommon-$(UCOMMON_VERSION).tar.gz
$(warning $@ not implemented)
touch $@
ucommon: ucommon-$(UCOMMON_VERSION).tar.gz .sum-ucommon
$(UNPACK)
ifdef HAVE_WIN32
$(APPLY) $(SRC)/ucommon/windows_platform.patch
endif
$(UPDATE_AUTOCONFIG) && cd $(UNPACK_DIR)
$(MOVE)
.ucommon: ucommon
mkdir -p $</m4 && $(RECONF)
cd $< && $(HOSTVARS) ./configure $(HOSTCONF) $(UCOMMON_OPTIONS)
cd $< && $(MAKE) install
touch $@
--- ucommon/inc/ucommon/platform.h.orig 2014-09-09 15:45:10.488481802 -0400
+++ ucommon/inc/ucommon/platform.h 2014-09-09 15:45:39.268482233 -0400
@@ -161,7 +161,7 @@
#if defined(UCOMMON_RUNTIME) || defined(UCOMMON_STATIC)
#define __SHARED
#else
-#define __SHARED __EXPORT
+#define __SHARED __declspec(dllimport) // Fix compile error.
#endif
#elif UCOMMON_VISIBILITY > 0
8166fdf7cc0cf9f35ca3245e6152be23e30010bf2113bc4be03c3cafb7c300fd8bd065829c151d05fda748c62d79d4d5d696524b2298effcac2498efd84420d0 libzrtpcpp-2.3.3.tar.gz
--- a/CMakeLists.txt.orig 2014-05-06 19:35:46.443707232 -0400
+++ b/CMakeLists.txt 2014-05-06 19:13:04.235686028 -0400
@@ -107,7 +107,7 @@
endif()
# now get info about crypto libraries
-pkg_check_modules(OPENSSL libcrypto>=0.9.8)
+#pkg_check_modules(OPENSSL libcrypto>=0.9.8)
if (OPENSSL_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${OPENSSL_INCLUDE_DIRS}) #update include files search directory
check_include_files(openssl/bn.h HAVE_OPENSSL_BN_H)
--- zrtpcpp/CMakeLists.txt.orig 2014-08-01 13:09:30.402259035 -0400
+++ zrtpcpp/CMakeLists.txt 2014-08-01 13:09:35.089304129 -0400
@@ -167,10 +167,6 @@
add_subdirectory(src)
-if (enable_ccrtp)
- add_subdirectory(demo)
-endif()
-
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/package/)
MESSAGE(STATUS "package dir not found")
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/package/)
# ZRTPCPP
ZRTPCPP_VERSION := 2.3.3
ZRTPCPP_URL := $(GNUTELEPHONY)/ZRTPCPP/archive/v$(ZRTPCPP_VERSION).tar.gz
PKGS += zrtpcpp
ifeq ($(call need_pkg,'libzrtpcpp >= 2.0.0'),)
PKGS_FOUND += zrtpcpp
endif
DEPS_zrtpcpp = ccrtp ucommon gcrypt
ZRTPCPP_CMAKECONF := -DBUILD_STATIC:BOOL=ON \
-DBUILD_SHARED:BOOL=OFF \
-DBUILD_SHARED_LIBS:BOOL=OFF
$(TARBALLS)/libzrtpcpp-$(ZRTPCPP_VERSION).tar.gz:
$(call download,$(ZRTPCPP_URL))
.sum-zrtpcpp: libzrtpcpp-$(ZRTPCPP_VERSION).tar.gz
zrtpcpp: libzrtpcpp-$(ZRTPCPP_VERSION).tar.gz .sum-zrtpcpp
$(UNPACK)
mv ZRTPCPP-$(ZRTPCPP_VERSION) libzrtpcpp-$(ZRTPCPP_VERSION)
$(APPLY) $(SRC)/zrtpcpp/forcegcrypt.patch
$(APPLY) $(SRC)/zrtpcpp/threadcbsupdate.patch
$(APPLY) $(SRC)/zrtpcpp/standardheader.patch
$(APPLY) $(SRC)/zrtpcpp/nodemo.patch
$(MOVE)
.zrtpcpp: zrtpcpp toolchain.cmake
cd $< && $(HOSTVARS) $(CMAKE) . $(ZRTPCPP_CMAKECONF)
cd $< && $(MAKE) install VERBOSE=1
touch $@
--- a/src/libzrtpcpp/crypto/gcrypt/InitializeGcrypt.cpp.orig 2014-06-25 20:40:20.000000000 -0400
+++ b/src/libzrtpcpp/crypto/gcrypt/InitializeGcrypt.cpp 2014-06-25 20:40:32.000000000 -0400
@@ -17,7 +17,7 @@
#include <stdio.h>
-#include <malloc.h>
+#include <stdlib.h>
#include <errno.h>
#include <gcrypt.h>
--- a/src/libzrtpcpp/crypto/gcrypt/InitializeGcrypt.cpp.orig 2014-06-12 17:36:14.367890764 -0400
+++ b/src/libzrtpcpp/crypto/gcrypt/InitializeGcrypt.cpp 2014-06-12 17:36:52.899889626 -0400
@@ -68,9 +68,12 @@
}
static struct gcry_thread_cbs gcry_threads = {
- GCRY_THREAD_OPTION_PTHREAD, NULL,
+ GCRY_THREAD_OPTION_PTHREAD,
+#if 0
+ NULL,
gcry_thread_mutex_init, gcry_thread_mutex_destroy,
gcry_thread_mutex_lock, gcry_thread_mutex_unlock
+#endif
};
#else
......@@ -24,6 +24,7 @@ endif
AM_CPPFLAGS = \
-I$(src)/src \
-I$(src)/src/config \
-I$(src)/src/media \
-I$(src)/test \
-I$(src)/src/public \
$(SIP_CFLAGS) \
......
include ../globals.mak
if RING_VIDEO
RING_VIDEO_SUBDIR = video
RING_VIDEO_LIBS=./video/libvideo.la \
./video/v4l2/libv4l2.la
RING_VIDEO_LIBS=./media/video/libvideo.la \
./media/video/v4l2/libv4l2.la
endif
if BUILD_INSTANT_MESSAGING
......@@ -35,7 +34,7 @@ TLS_LIB = @GNUTLS_LIBS@
TLS_CFLAGS = @GNUTLS_CFLAGS@
endif
SUBDIRS = client audio config hooks history sip $(IAX_SUBDIR) $(RINGACC_SUBDIR) $(INSTANT_MESSAGING_SUBDIR) $(RING_VIDEO_SUBDIR)
SUBDIRS = client media config hooks history sip $(IAX_SUBDIR) $(RINGACC_SUBDIR) $(INSTANT_MESSAGING_SUBDIR) $(RING_VIDEO_SUBDIR)
# libring
......@@ -43,7 +42,7 @@ lib_LTLIBRARIES = libring.la
libring_la_LIBADD = \
./sip/libsiplink.la \
./audio/libaudio.la \
./media/libmedia.la \
./client/libclient.la \
./config/libconfig.la \
./hooks/libhooks.la \
......@@ -54,9 +53,7 @@ libring_la_LIBADD = \
$(RING_VIDEO_LIBS)
libring_la_LDFLAGS = \
@ZRTPCPP_LIBS@ \
@PJPROJECT_LIBS@ \
@CCRTP_LIBS@ \
@ALSA_LIBS@ \
@PULSEAUDIO_LIBS@ \
@SAMPLERATE_LIBS@ \
......@@ -72,10 +69,13 @@ if USE_DHT
libring_la_LDFLAGS += $(OPENDHT_LIBS)
endif
if HAVE_OSX
#FIXME necessary for -lintl
libring_la_LDFLAGS += -L/usr/local/opt/gettext/lib
endif
libring_la_CFLAGS = \
@ZRTPCPP_CFLAGS@ \
@PJPROJECT_CFLAGS@ \
@CCRTP_CFLAGS@ \
@ALSA_CFLAGS@ \
@PULSEAUDIO_CFLAGS@ \
@SAMPLERATE_CFLAGS@ \
......@@ -131,5 +131,4 @@ libring_la_SOURCES = conference.cpp \
string_utils.h \
string_utils.cpp \
rw_mutex.h \
ring.h \
ring_api.cpp
......@@ -39,7 +39,7 @@
#include <iterator>
#ifdef RING_VIDEO
#include "video/libav_utils.h"
#include "libav_utils.h"
#endif
#include "logger.h"
......
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com>
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#include "audio_rtp_factory.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_ZRTP
#include "audio_zrtp_session.h"
#endif
#include "audio_symmetric_rtp_session.h"
#include "manager.h"
#include "sip/sdp.h"
#include "sip/sipcall.h"
#include "sip/sipaccount.h"
#include "logger.h"
namespace ring {
AudioRtpFactory::AudioRtpFactory(SIPCall *ca) : rtpSession_(),
audioRtpThreadMutex_(), srtpEnabled_(false), helloHashEnabled_(false),
remoteOfferIsSet_(false), call_(ca),
keyExchangeProtocol_(NONE)
{
// FIXME: workaround for uncatchable ost::Socket "exceptions"
ost::Thread::setException(ost::Thread::throwNothing);
}
AudioRtpFactory::~AudioRtpFactory()
{}
void AudioRtpFactory::initConfig()
{
stop();
const std::string accountId(call_->getAccountId());
const auto sipaccount = Manager::instance().getAccount<SIPAccount>(accountId);
if (sipaccount) {
srtpEnabled_ = sipaccount->getSrtpEnabled();
std::string key(sipaccount->getSrtpKeyExchange());
if (srtpEnabled_) {
#if HAVE_ZRTP
if (key == "sdes")
keyExchangeProtocol_ = SDES;
else if (key == "zrtp")
keyExchangeProtocol_ = ZRTP;
#else
keyExchangeProtocol_ = SDES;
#endif
} else {
keyExchangeProtocol_ = NONE;
}
helloHashEnabled_ = sipaccount->getZrtpHelloHash();
} else {
srtpEnabled_ = false;
keyExchangeProtocol_ = NONE;
helloHashEnabled_ = false;
}
}
void AudioRtpFactory::initSession()
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (srtpEnabled_) {
switch (keyExchangeProtocol_) {
#if HAVE_ZRTP
case ZRTP: {
const std::string zidFilename(Manager::instance().voipPreferences.getZidFile());
rtpSession_.reset(new AudioZrtpSession(*call_, zidFilename, call_->getLocalIp()));
// TODO: be careful with that. The hello hash is computed asynchronously. Maybe it's
// not even available at that point.
if (helloHashEnabled_)
call_->getSDP().setZrtpHash(static_cast<AudioZrtpSession *>(rtpSession_.get())->getHelloHash());
break;
}
#endif
case SDES: {
rtpSession_.reset(new AudioSrtpSession(*call_));
break;
}
default:
throw UnsupportedRtpSessionType("Unsupported Rtp Session Exception Type!");
}
} else {
#if HAVE_IPV6
if (call_->getLocalIp().isIpv6()) {
rtpSession_.reset(new AudioSymmetricRtpSessionIPv6(*call_));
} else
#endif
{
rtpSession_.reset(new AudioSymmetricRtpSession(*call_));
}
}
}
std::vector<long>
AudioRtpFactory::getSocketDescriptors()
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (!rtpSession_)
throw AudioRtpFactoryException("RTP session was null when trying to get socket descriptors");
return rtpSession_->getSocketDescriptors();
}
void AudioRtpFactory::start(const std::vector<AudioCodec*> &audioCodecs)
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (!rtpSession_)
throw AudioRtpFactoryException("RTP session was null when trying to start audio thread");
rtpSession_->startRtpThreads(audioCodecs);
}
void AudioRtpFactory::stop()
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
rtpSession_.reset();
}
void AudioRtpFactory::updateSessionMedia(const std::vector<AudioCodec*> &audioCodecs)
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (!rtpSession_)
throw AudioRtpFactoryException("rtpSession_ was NULL when trying to update IP address");
rtpSession_->updateSessionMedia(audioCodecs);
}
void AudioRtpFactory::updateDestinationIpAddress()
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (!rtpSession_)
throw AudioRtpFactoryException("RTP session was null when trying to update IP address");
rtpSession_->updateDestinationIpAddress();
}
#if HAVE_ZRTP
AudioZrtpSession * AudioRtpFactory::getAudioZrtpSession()
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (rtpSession_ and keyExchangeProtocol_ == ZRTP)
return static_cast<AudioZrtpSession *>(rtpSession_.get());
else
throw AudioRtpFactoryException("rtpSession_ is NULL in getAudioZrtpSession");
}
#endif
void AudioRtpFactory::initLocalCryptoInfo()
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (rtpSession_ && keyExchangeProtocol_ == SDES) {
AudioSrtpSession *srtp = static_cast<AudioSrtpSession*>(rtpSession_.get());
// the context is invalidated and deleted by the call to initLocalCryptoInfo
srtp->initLocalCryptoInfo();
call_->getSDP().setLocalSdpCrypto(srtp->getLocalCryptoInfo());
}
}
void AudioRtpFactory::initLocalCryptoInfoOnOffHold()
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (rtpSession_ && keyExchangeProtocol_ == SDES) {
AudioSrtpSession *srtp = static_cast<AudioSrtpSession*>(rtpSession_.get());
// the context is invalidated and deleted by the call to initLocalCryptoInfo
srtp->initLocalCryptoInfoOnOffhold();
call_->getSDP().setLocalSdpCrypto(srtp->getLocalCryptoInfo());
}
}
void AudioRtpFactory::setRemoteCryptoInfo(SdesNegotiator& nego)
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (!rtpSession_)
throw AudioRtpFactoryException("rtpSession_ is NULL in setRemoteCryptoInfo");
if (keyExchangeProtocol_ == SDES) {
AudioSrtpSession *srtp = static_cast<AudioSrtpSession *>(rtpSession_.get());
try {
srtp->setRemoteCryptoInfo(nego);
} catch (const AudioSrtpException &e) {
throw AudioRtpFactoryException(e.what());
}
} else {
RING_ERR("Should not store remote crypto info for non-SDES sessions");
}
}
void AudioRtpFactory::setDtmfPayloadType(unsigned int payloadType)
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (rtpSession_)
rtpSession_->setDtmfPayloadType(payloadType);
}
void AudioRtpFactory::sendDtmfDigit(int digit)
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (rtpSession_)
rtpSession_->putDtmfEvent(digit);
}
void AudioRtpFactory::saveLocalContext()
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (rtpSession_ and keyExchangeProtocol_ == SDES)
cachedAudioRtpState_.reset(rtpSession_->saveState());
}
void AudioRtpFactory::restoreLocalContext()
{
std::lock_guard<std::mutex> lock(audioRtpThreadMutex_);
if (rtpSession_ and keyExchangeProtocol_ == SDES)
rtpSession_->restoreState(*cachedAudioRtpState_);
}
}
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com>
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* 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