Commit 83f960cc authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'master' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone

Conflicts:
	tools/build-system/launchpad/dput.conf
parents 4528e2d9 ad979d4f
[submodule "kde"]
path = kde
url = https://github.com/Elv13/sflphone-kde.git
...@@ -10,7 +10,7 @@ AM_INIT_AUTOMAKE ...@@ -10,7 +10,7 @@ AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
# Silent build by default. Use make V=1 to increase verbosity # Silent build by default. Use make V=1 to increase verbosity
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) #m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
dnl Improve make variable MAKE dnl Improve make variable MAKE
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
...@@ -63,29 +63,29 @@ AC_CHECK_TYPES([ptrdiff_t]) ...@@ -63,29 +63,29 @@ AC_CHECK_TYPES([ptrdiff_t])
dnl ******************************** dnl ********************************
dnl Check for needed functions dnl Check for needed functions
dnl ******************************** dnl ********************************
AC_FUNC_CHOWN #AC_FUNC_CHOWN
AC_FUNC_ERROR_AT_LINE #AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK #AC_FUNC_FORK
AC_PROG_GCC_TRADITIONAL #AC_PROG_GCC_TRADITIONAL
AC_FUNC_MALLOC #AC_FUNC_MALLOC
AC_FUNC_MEMCMP #AC_FUNC_MEMCMP
AC_FUNC_REALLOC #AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES #AC_FUNC_SELECT_ARGTYPES
AC_DIAGNOSE([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void. #AC_DIAGNOSE([obsolete],[your code may safely assume C89 semantics that RETSIGTYPE is void.
Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl #Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])dnl
AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE( #AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <sys/types.h> #[AC_LANG_PROGRAM([#include <sys/types.h>
#include <signal.h> ##include <signal.h>
], #],
[return *(signal (0, 0)) (0) == 1;])], # [return *(signal (0, 0)) (0) == 1;])],
[ac_cv_type_signal=int], # [ac_cv_type_signal=int],
[ac_cv_type_signal=void])]) # [ac_cv_type_signal=void])])
AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers #AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers
(`int' or `void').]) # (`int' or `void').])
AC_FUNC_STAT #AC_FUNC_STAT
AC_FUNC_UTIME_NULL #AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF #AC_FUNC_VPRINTF
dnl Check for GNU ccRTP dnl Check for GNU ccRTP
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
...@@ -110,7 +110,6 @@ AC_ARG_WITH([pulse], ...@@ -110,7 +110,6 @@ AC_ARG_WITH([pulse],
[ AS_HELP_STRING([--without-pulse], [disable support for pulseaudio]) ], [ AS_HELP_STRING([--without-pulse], [disable support for pulseaudio]) ],
[], [],
[with_pulse=yes]) [with_pulse=yes])
AS_IF([test "x$with_pulse" = "xyes"], [ AS_IF([test "x$with_pulse" = "xyes"], [
PKG_CHECK_MODULES(PULSEAUDIO, libpulse >= ${LIBPULSE_MIN_VERSION},, AC_MSG_ERROR([Missing pulseaudio development package: libpulse-dev])) PKG_CHECK_MODULES(PULSEAUDIO, libpulse >= ${LIBPULSE_MIN_VERSION},, AC_MSG_ERROR([Missing pulseaudio development package: libpulse-dev]))
]); ]);
...@@ -161,13 +160,43 @@ PKG_CHECK_MODULES([CCRTP], [libccrtp] >= ${LIBCCRTP_MIN_VERSION},, [ ...@@ -161,13 +160,43 @@ PKG_CHECK_MODULES([CCRTP], [libccrtp] >= ${LIBCCRTP_MIN_VERSION},, [
PKG_CHECK_MODULES([CCRTP], [libccrtp1] >= ${LIBCCRTP_MIN_VERSION},, AC_MSG_ERROR([Missing ccrtp development package: libccrtp-dev])) PKG_CHECK_MODULES([CCRTP], [libccrtp1] >= ${LIBCCRTP_MIN_VERSION},, AC_MSG_ERROR([Missing ccrtp development package: libccrtp-dev]))
]) ])
# TLS
# required dependency(ies): libssl
dnl Check for OpenSSL to link against pjsip and provide SIPS TLS support dnl Check for OpenSSL to link against pjsip and provide SIPS TLS support
PKG_CHECK_MODULES([libssl], libssl,, AC_MSG_ERROR([Missing ssl development package: libssl-dev])) AC_ARG_WITH([tls],
[ AS_HELP_STRING([--without-tls], [disable support for tls]) ],
[],
[with_tls=yes])
AS_IF([test "x$with_tls" = "xyes"], [
PKG_CHECK_MODULES([libssl], libssl,, AC_MSG_ERROR([Missing ssl development package: libssl-dev]))
]);
AC_DEFINE_UNQUOTED([HAVE_TLS], `if test "x$with_tls" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have tls support])
AM_CONDITIONAL(BUILD_TLS, test "x$with_tls" = "xyes" )
# ZRTP
# required dependency(ies): libzrtp
dnl Check for libzrtpcpp, a ccRTP extension providing zrtp key exchange dnl Check for libzrtpcpp, a ccRTP extension providing zrtp key exchange
LIBZRTPCPP_MIN_VERSION=1.3.0 LIBZRTPCPP_MIN_VERSION=1.3.0
PKG_CHECK_MODULES(ZRTPCPP, libzrtpcpp >= ${LIBZRTPCPP_MIN_VERSION},, AC_MSG_ERROR([Missing zrtp development package: libzrtpcpp-dev])) AC_ARG_WITH([zrtp],
[ AS_HELP_STRING([--without-zrtp], [disable support for zrtp]) ],
[],
[with_zrtp=yes])
AS_IF([test "x$with_zrtp" = "xyes"], [
PKG_CHECK_MODULES([ZRTPCPP], libzrtpcpp >= ${LIBZRTPCPP_MIN_VERSION},, AC_MSG_ERROR([Missing zrtp development package: libzrtpcpp-dev]))
]);
AC_DEFINE_UNQUOTED([HAVE_ZRTP], `if test "x$with_zrtp" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have zrtp support])
AM_CONDITIONAL(BUILD_ZRTP, test "x$with_zrtp" = "xyes" )
# DBUS
# required dependency(ies): libdbus-c++
dnl DBus-C++ detection dnl DBus-C++ detection
dnl pkg-config doesn't like 0.6.0-pre1 version number, it assumes that it is dnl pkg-config doesn't like 0.6.0-pre1 version number, it assumes that it is
dnl more recent than (unreleased) 0.6.0 dnl more recent than (unreleased) 0.6.0
...@@ -175,17 +204,51 @@ DBUS_CPP_REQUIRED_VERSION=0.6.0-pre1 ...@@ -175,17 +204,51 @@ DBUS_CPP_REQUIRED_VERSION=0.6.0-pre1
PKG_CHECK_MODULES(DBUSCPP, dbus-c++-1,, PKG_CHECK_MODULES(DBUSCPP, dbus-c++-1,,
AC_MSG_ERROR([You need the DBus-c++ libraries (version $DBUS_CPP_REQUIRED_VERSION or better)])) AC_MSG_ERROR([You need the DBus-c++ libraries (version $DBUS_CPP_REQUIRED_VERSION or better)]))
AX_LIB_EXPAT([1.95.8])
AS_IF([test "$HAVE_EXPAT" != "yes"], [AC_MSG_ERROR([libexpat could not be found, which is required to build this package.])], [])
# Instant Messaging
# required dependency(ies): libxpat
AC_ARG_WITH([instant_messaging],
[ AS_HELP_STRING([--without-instant_messaging], [disable support for instant-messaging]) ],
[],
[with_instant_messaging=yes])
AS_IF([test "x$with_instant_messaging" = "xyes"], [
AX_LIB_EXPAT([1.95.0])
AS_IF([test "$HAVE_EXPAT" != "yes"], [AC_MSG_ERROR([libexpat could not be found, which is required to build this package.])], [])
]);
AC_DEFINE_UNQUOTED([HAVE_INSTANT_MESSAGING], `if test "x$with_instant_messaging" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have instant messaging support])
AM_CONDITIONAL(BUILD_INSTANT_MESSAGING, test "x$with_instant_messaging" = "xyes" )
# PTHREAD
# required dependency(ies): libxpat
AX_PTHREAD AX_PTHREAD
AX_PATH_LIB_PCRE
# SDES Key Exchange
# required dependency(ies): libpcre
AC_ARG_WITH([sdes],
[ AS_HELP_STRING([--without-sdes], [disable support for sdes key exchange]) ],
[],
[with_sdes=yes])
AS_IF([test "x$with_sdes" = "xyes"], [
AX_PATH_LIB_PCRE
]);
AC_DEFINE_UNQUOTED([HAVE_SDES], `if test "x$with_sdes" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have sdes support])
AM_CONDITIONAL(BUILD_SDES, test "x$with_sdes" = "xyes" )
dnl Check for libcppunit-dev dnl Check for libcppunit-dev
CPPUNIT_MIN_VERSION=1.12 CPPUNIT_MIN_VERSION=1.12
PKG_CHECK_MODULES(CPPUNIT, cppunit >= ${CPPUNIT_MIN_VERSION}, AM_CONDITIONAL(BUILD_TEST, test 1 = 1 ), AM_CONDITIONAL(BUILD_TEST, test 0 = 1 )) PKG_CHECK_MODULES(CPPUNIT, cppunit >= ${CPPUNIT_MIN_VERSION}, AM_CONDITIONAL(BUILD_TEST, test 1 = 1 ), AM_CONDITIONAL(BUILD_TEST, test 0 = 1 ))
# GSM CODEC
# required dependency(ies): libgsm
dnl check for libgsm1 (doesn't use pkg-config) dnl check for libgsm1 (doesn't use pkg-config)
dnl Check for libgsm dnl Check for libgsm
AC_ARG_WITH([gsm], [AS_HELP_STRING([--without-gsm], AC_ARG_WITH([gsm], [AS_HELP_STRING([--without-gsm],
...@@ -202,10 +265,13 @@ AS_IF([test "x$with_gsm" != xno], ...@@ -202,10 +265,13 @@ AS_IF([test "x$with_gsm" != xno],
AC_DEFINE_UNQUOTED([HAVE_GSM], `if test "x$with_gsm" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libgsm]) AC_DEFINE_UNQUOTED([HAVE_GSM], `if test "x$with_gsm" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libgsm])
AM_CONDITIONAL(BUILD_GSM, test "x$with_gsm" = "xyes" ) AM_CONDITIONAL(BUILD_GSM, test "x$with_gsm" = "xyes" )
# SPEEX CODEC
# required dependency(ies): libspeex
dnl Check for libspeex dnl Check for libspeex
AC_ARG_WITH([speex], AC_ARG_WITH([speex],
[AS_HELP_STRING([--without-speex], [AS_HELP_STRING([--without-speex], [disable support for speex codec])],
[disable support for speex codec])],
[], [],
[with_speex=yes]) [with_speex=yes])
...@@ -219,12 +285,29 @@ AS_IF([test "x$with_speex" != xno], ...@@ -219,12 +285,29 @@ AS_IF([test "x$with_speex" != xno],
AC_DEFINE_UNQUOTED([HAVE_SPEEX], `if test "x$with_speex" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libspeex]) AC_DEFINE_UNQUOTED([HAVE_SPEEX], `if test "x$with_speex" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libspeex])
AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" ) AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" )
# SPEEX DSP
# required dependency(ies): libspeexdsp
dnl check in case the libspeexdsp is not installed dnl check in case the libspeexdsp is not installed
AC_CHECK_HEADER([speex/speex_preprocess.h], , AC_MSG_FAILURE([Unable to find the libspeexdsp headers (you may need to install the libspeexdsp-dev package) used for Noise Suppression and Automatic Gain Control.])) AC_ARG_WITH([speexdsp],
AC_SEARCH_LIBS([speex_preprocess_run], [speexdsp], [], [ [AS_HELP_STRING([--without-speexdsp],
AC_MSG_ERROR([Unable to find speexdsp development files]) [disable support for speexdp Noise Suppression and Automatic Gain Control])],
]) [],
[with_speexdsp=yes])
AS_IF([test "x$with_speexdsp" != xno],
AC_CHECK_HEADER([speex/speex_preprocess.h], , AC_MSG_FAILURE([Unable to find the libspeexdsp headers (you may need to install the libspeexdsp-dev package) used for Noise Suppression and Automatic Gain Control.]))
AC_SEARCH_LIBS([speex_preprocess_run], [speexdsp], [], [AC_MSG_ERROR([Unable to find speexdsp development files])])
)
AC_DEFINE_UNQUOTED([HAVE_SPEEXDSP], `if test "x$with_speexdsp" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libspeexdsp])
AM_CONDITIONAL(BUILD_SPEEXDSP, test "x$with_speexdsp" = "xyes" )
# IAX
# required dependency(ies): libiax2 (static)
dnl Check for IAX dnl Check for IAX
AC_ARG_WITH([iax2], [AS_HELP_STRING([--without-iax2], AC_ARG_WITH([iax2], [AS_HELP_STRING([--without-iax2],
[disable support for the iax2 protocol])], [], [with_iax2=yes]) [disable support for the iax2 protocol])], [], [with_iax2=yes])
...@@ -232,13 +315,21 @@ AC_ARG_WITH([iax2], [AS_HELP_STRING([--without-iax2], ...@@ -232,13 +315,21 @@ AC_ARG_WITH([iax2], [AS_HELP_STRING([--without-iax2],
AC_DEFINE_UNQUOTED([HAVE_IAX], `if test "x$with_iax2" = "xyes"; then echo 1; else echo 0;fi`, [Define if you have libiax2]) AC_DEFINE_UNQUOTED([HAVE_IAX], `if test "x$with_iax2" = "xyes"; then echo 1; else echo 0;fi`, [Define if you have libiax2])
AM_CONDITIONAL(USE_IAX, test "x$with_iax2" = "xyes" ) AM_CONDITIONAL(USE_IAX, test "x$with_iax2" = "xyes" )
dnl Check for network-manager
# NETWORK MANAGER
# required dependency(ies): libiax2 (static)
dnl Check for network-manager
AC_ARG_WITH([networkmanager], [AS_HELP_STRING([--without-networkmanager], AC_ARG_WITH([networkmanager], [AS_HELP_STRING([--without-networkmanager],
[disable support for network-manager events])], [], [disable support for network-manager events])], [],
[with_networkmanager=yes]) [with_networkmanager=yes])
AM_CONDITIONAL(USE_NETWORKMANAGER, test "x$with_networkmanager" = "xyes" ) AM_CONDITIONAL(USE_NETWORKMANAGER, test "x$with_networkmanager" = "xyes" )
# DOXYGEN
# required dependency(ies): doxygen
# check for doxygen, mostly stolen from http://log4cpp.sourceforge.net/ # check for doxygen, mostly stolen from http://log4cpp.sourceforge.net/
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
AC_DEFUN([BB_ENABLE_DOXYGEN], AC_DEFUN([BB_ENABLE_DOXYGEN],
...@@ -256,7 +347,9 @@ AC_DEFUN([BB_ENABLE_DOXYGEN], ...@@ -256,7 +347,9 @@ AC_DEFUN([BB_ENABLE_DOXYGEN],
# Acutally perform the doxygen check # Acutally perform the doxygen check
BB_ENABLE_DOXYGEN BB_ENABLE_DOXYGEN
CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -Weffc++ -Wfatal-errors"
CXXFLAGS="${CXXFLAGS} -g -Wno-return-type -Wall -Wextra -Wnon-virtual-dtor -Weffc++"
dnl What to generate dnl What to generate
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
......
if USE_IAX
SUBDIRS = iax2 SUBDIRS = iax2
endif
EXTRA_DIST=pjproject EXTRA_DIST=pjproject
SECTION="1" SECTION="1"
TEMPLATES=\ TEMPLATES=sflphoned.pod
sflphoned.pod
man_MANS = sflphoned.1 man_MANS=sflphoned.1
POD2MAN=pod2man POD2MAN=pod2man
EXTRA_DIST= $(man_MANS) EXTRA_DIST=$(man_MANS) $(TEMPLATES)
all: $(MANPAGES) all: $(MANPAGES)
SUFFIXES=.pod .1 SUFFIXES=.pod .1
......
...@@ -5,27 +5,29 @@ libexec_PROGRAMS = sflphoned ...@@ -5,27 +5,29 @@ libexec_PROGRAMS = sflphoned
if SFL_VIDEO if SFL_VIDEO
SFL_VIDEO_SUBDIR = video SFL_VIDEO_SUBDIR = video
SFL_VIDEO_LIB=./video/libvideo.la
endif endif
SUBDIRS = dbus audio config hooks history sip iax im $(SFL_VIDEO_SUBDIR) if BUILD_INSTANT_MESSAGING
INSTANT_MESSAGING_SUBDIR = im
sflphoned_SOURCES = main.cpp IM_LIB=./im/libim.la
endif
# Redefine the USE_IAX variable here, so that it could be used in managerimpl # Redefine the USE_IAX variable here, so that it could be used in managerimpl
if USE_IAX if USE_IAX
IAX_SUBDIR=iax
IAX_CXXFLAG=-DUSE_IAX IAX_CXXFLAG=-DUSE_IAX
IAX_LIB=./iax/libiaxlink.la IAX_LIB=./iax/libiaxlink.la $(top_builddir)/libs/iax2/libiax2.la
else
IAX_CXXFLAG=
IAX_LIB=
endif endif
if USE_NETWORKMANAGER if USE_NETWORKMANAGER
NETWORKMANAGER=-DUSE_NETWORKMANAGER NETWORKMANAGER=-DUSE_NETWORKMANAGER
else
NETWORKMANAGER=
endif endif
SUBDIRS = dbus audio config hooks history sip $(IAX_SUBDIR) $(INSTANT_MESSAGING_SUBDIR) $(SFL_VIDEO_SUBDIR)
sflphoned_SOURCES = main.cpp
sflphoned_CXXFLAGS = \ sflphoned_CXXFLAGS = \
-DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(IAX_CXXFLAG) $(NETWORKMANAGER) \ -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" $(IAX_CXXFLAG) $(NETWORKMANAGER) \
-DVERSION=\"$(VERSION)\" -DVERSION=\"$(VERSION)\"
...@@ -54,22 +56,18 @@ noinst_HEADERS = \ ...@@ -54,22 +56,18 @@ noinst_HEADERS = \
cc_thread.h \ cc_thread.h \
cc_config.h \ cc_config.h \
sfl_types.h \ sfl_types.h \
array_size.h array_size.h \
account_schema.h \
if SFL_VIDEO registration_states.h
SFL_VIDEO_LIB=./video/libvideo.la
endif
libsflphone_la_LIBADD = \ libsflphone_la_LIBADD = \
$(top_builddir)/libs/iax2/libiax2.la \
$(IAX_LIB) \ $(IAX_LIB) \
./im/libim.la \
./sip/libsiplink.la \ ./sip/libsiplink.la \
./audio/libaudio.la \ ./audio/libaudio.la \
./dbus/libdbus.la \ ./dbus/libdbus.la \
./config/libconfig.la \ ./config/libconfig.la \
./hooks/libhooks.la \ ./hooks/libhooks.la \
./history/libhistory.la $(SFL_VIDEO_LIB) ./history/libhistory.la $(SFL_VIDEO_LIB) $(IM_LIB)
libsflphone_la_LDFLAGS = \ libsflphone_la_LDFLAGS = \
@CCGNU2_LIBS@ \ @CCGNU2_LIBS@ \
......
...@@ -29,26 +29,54 @@ ...@@ -29,26 +29,54 @@
* shall include the source code for the parts of OpenSSL used as well * shall include the source code for the parts of OpenSSL used as well
* as that of the covered work. * as that of the covered work.
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "account.h" #include "account.h"
#include "manager.h" #include <algorithm>
#include "dbus/configurationmanager.h"
#ifdef SFL_VIDEO #ifdef SFL_VIDEO
#include "video/video_endpoint.h" #include "video/libav_utils.h"
#endif #endif
Account::Account(const std::string &accountID, const std::string &type) : #include "logger.h"
#include "manager.h"
#include "dbus/configurationmanager.h"
const char * const Account::AUDIO_CODECS_KEY = "audioCodecs"; // 0/9/110/111/112/
const char * const Account::VIDEO_CODECS_KEY = "videoCodecs";
const char * const Account::VIDEO_CODEC_ENABLED = "enabled";
const char * const Account::VIDEO_CODEC_NAME = "name";
const char * const Account::VIDEO_CODEC_PARAMETERS ="parameters";
const char * const Account::VIDEO_CODEC_BITRATE = "bitrate";
const char * const Account::RINGTONE_PATH_KEY = "ringtonePath";
const char * const Account::RINGTONE_ENABLED_KEY = "ringtoneEnabled";
const char * const Account::DISPLAY_NAME_KEY = "displayName";
const char * const Account::ALIAS_KEY = "alias";
const char * const Account::TYPE_KEY = "type";
const char * const Account::ID_KEY = "id";
const char * const Account::USERNAME_KEY = "username";
const char * const Account::AUTHENTICATION_USERNAME_KEY = "authenticationUsername";
const char * const Account::PASSWORD_KEY = "password";
const char * const Account::HOSTNAME_KEY = "hostname";
const char * const Account::ACCOUNT_ENABLE_KEY = "enable";
const char * const Account::MAILBOX_KEY = "mailbox";
using std::map;
using std::string;
using std::vector;
Account::Account(const string &accountID, const string &type) :
accountID_(accountID) accountID_(accountID)
, username_() , username_()
, hostname_() , hostname_()
, alias_() , alias_()
, enabled_(true) , enabled_(true)
, type_(type) , type_(type)
, registrationState_(Unregistered) , registrationState_(UNREGISTERED)
, audioCodecList_() , audioCodecList_()
, videoCodecList_() , videoCodecList_()
, audioCodecStr_() , audioCodecStr_()
, videoCodecStr_()
, ringtonePath_("/usr/share/sflphone/ringtones/konga.ul") , ringtonePath_("/usr/share/sflphone/ringtones/konga.ul")
, ringtoneEnabled_(true) , ringtoneEnabled_(true)
, displayName_("") , displayName_("")
...@@ -79,7 +107,7 @@ void Account::loadDefaultCodecs() ...@@ -79,7 +107,7 @@ void Account::loadDefaultCodecs()
// CodecMap codecMap = Manager::instance ().getCodecDescriptorMap ().getCodecsMap(); // CodecMap codecMap = Manager::instance ().getCodecDescriptorMap ().getCodecsMap();
// Initialize codec // Initialize codec
std::vector<std::string> result; vector<string> result;
result.push_back("0"); result.push_back("0");
result.push_back("3"); result.push_back("3");
result.push_back("8"); result.push_back("8");
...@@ -90,31 +118,90 @@ void Account::loadDefaultCodecs() ...@@ -90,31 +118,90 @@ void Account::loadDefaultCodecs()
setActiveAudioCodecs(result); setActiveAudioCodecs(result);
#ifdef SFL_VIDEO #ifdef SFL_VIDEO
setActiveVideoCodecs(sfl_video::getCodecList()); // we don't need to validate via setVideoCodecs, since these are defaults
videoCodecList_ = libav_utils::getDefaultCodecs();
#endif #endif
} }
void Account::setActiveVideoCodecs(const std::vector<std::string> &list) #ifdef SFL_VIDEO
namespace {
bool isPositiveInteger(const string &s)
{
string::const_iterator it = s.begin();
while (it != s.end() and std::isdigit(*it))
++it;
return not s.empty() and it == s.end();
}
bool isBoolean(const string &s)
{
return s == "true" or s == "false";
}
template <typename Predicate>
bool isFieldValid(const map<string, string> &codec, const char *field, Predicate p)
{
map<string, string>::const_iterator key(codec.find(field));
return key != codec.end() and p(key->second);
}
bool isCodecValid(const map<string, string> &codec, const vector<map<string, string> > &defaults)
{
const map<string, string>::const_iterator name(codec.find(Account::VIDEO_CODEC_NAME));
if (name == codec.end()) {
ERROR("Field \"name\" missing in codec specification");
return false;
}
// check that it's in the list of valid codecs and that it has all the required fields
for (vector<map<string, string> >::const_iterator i = defaults.begin(); i != defaults.end(); ++i) {
const map<string, string>::const_iterator defaultName = i->find(Account::VIDEO_CODEC_NAME);
if (defaultName->second == name->second) {
return isFieldValid(codec, Account::VIDEO_CODEC_BITRATE, isPositiveInteger)
and isFieldValid(codec, Account::VIDEO_CODEC_ENABLED, isBoolean);
}
}
ERROR("Codec %s not supported", name->second.c_str());
return false;
}
bool isCodecListValid(const vector<map<string, string> > &list)
{
const vector<map<string, string> > defaults(libav_utils::getDefaultCodecs());
if (list.size() != defaults.size()) {
ERROR("New codec list has a different length than the list of supported codecs");
return false;
}
// make sure that all codecs are present
for (vector<map<string, string> >::const_iterator i = list.begin();
i != list.end(); ++i) {
if (not isCodecValid(*i, defaults))
return false;
}
return true;
}
}
#endif
void Account::setVideoCodecs(const vector<map<string, string> > &list)
{ {
#ifdef SFL_VIDEO #ifdef SFL_VIDEO
// first clear the previously stored codecs if (isCodecListValid(list))
videoCodecList_.clear(); videoCodecList_ = list;
videoCodecList_ = !list.empty() ? list : sfl_video::getCodecList();
// update the codec string according to new codec selection
videoCodecStr_ = ManagerImpl::join_string(list);
#else #else
(void) list; (void) list;
#endif #endif
} }
void Account::setActiveAudioCodecs(const std::vector<std::string> &list) void Account::setActiveAudioCodecs(const vector<string> &list)
{ {
// first clear the previously stored codecs // first clear the previously stored codecs
audioCodecList_.clear(); audioCodecList_.clear();
// list contains the ordered payload of active codecs picked by the user for this account // list contains the ordered payload of active codecs picked by the user for this account
// we used the CodecOrder vector to save the order. // we used the CodecOrder vector to save the order.
for (std::vector<std::string>::const_iterator iter = list.begin(); iter != list.end(); for (vector<string>::const_iterator iter = list.begin(); iter != list.end();
++iter) {