1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 03:41:55 +00:00

For #370, support SRTP with ASM(enable openssl) by default

This commit is contained in:
winlin 2020-04-03 14:37:48 +08:00
parent cdb20c79cc
commit 5e06a2568b
2 changed files with 54 additions and 24 deletions

View file

@ -489,40 +489,49 @@ if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then
if [[ $SRS_RTC == NO || $SRS_NASM == NO ]]; then if [[ $SRS_RTC == NO || $SRS_NASM == NO ]]; then
OPENSSL_OPTIONS="$OPENSSL_OPTIONS -no-asm" OPENSSL_OPTIONS="$OPENSSL_OPTIONS -no-asm"
fi fi
# Which lib we use.
OPENSSL_LIB="openssl-1.1.0e/_release"
if [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_LIB}/lib/libssl.a ]]; then
OPENSSL_LIB="openssl"
fi
# Mac OS X can have issues (its often a neglected platform). # Mac OS X can have issues (its often a neglected platform).
# @see https://wiki.openssl.org/index.php/Compilation_and_Installation # @see https://wiki.openssl.org/index.php/Compilation_and_Installation
if [[ $SRS_OSX == YES ]]; if [[ $SRS_OSX == YES ]]; then
export KERNEL_BITS=64; export KERNEL_BITS=64;
fi fi
# Which openssl we choose, openssl-1.0.* for SRTP with ASM, others we use openssl-1.1.*
OPENSSL_CANDIDATE="openssl-1.1.0e" && OPENSSL_UNZIP="unzip -q ../../3rdparty/$OPENSSL_CANDIDATE.zip"
if [[ $SRS_SRTP_ASM == YES ]]; then
OPENSSL_CANDIDATE="openssl-OpenSSL_1_0_2u" && OPENSSL_UNZIP="tar xf ../../3rdparty/$OPENSSL_CANDIDATE.tar.gz"
fi
# cross build not specified, if exists flag, need to rebuild for no-arm platform. # cross build not specified, if exists flag, need to rebuild for no-arm platform.
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/libssl.a ]]; then if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/openssl/lib/libssl.a ]]; then
echo "Openssl-1.1.0e is ok."; echo "Openssl-1.1.0e is ok.";
else else
echo "Building openssl-1.1.0e."; echo "Building $OPENSSL_CANDIDATE.";
( (
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/openssl-1.1.0e && cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_CANDIDATE} && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
unzip -q ../../3rdparty/openssl-1.1.0e.zip && cd openssl-1.1.0e && ${OPENSSL_UNZIP} && cd $OPENSSL_CANDIDATE && ${OPENSSL_CONFIG} --prefix=`pwd`/_release $OPENSSL_OPTIONS &&
${OPENSSL_CONFIG} --prefix=`pwd`/_release $OPENSSL_OPTIONS &&
make CC=${SRS_TOOL_CC} AR="${SRS_TOOL_AR} -rs" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} ${SRS_JOBS} && make install_sw && make CC=${SRS_TOOL_CC} AR="${SRS_TOOL_AR} -rs" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} ${SRS_JOBS} && make install_sw &&
cd .. && rm -rf openssl && ln -sf openssl-1.1.0e/_release openssl cd .. && rm -rf openssl && ln -sf $OPENSSL_CANDIDATE/_release openssl
) )
fi fi
# Which lib we use.
OPENSSL_LIB="$OPENSSL_CANDIDATE/_release"
if [[ ! -f ${SRS_OBJS}/${SRS_PLATFORM}/${OPENSSL_LIB}/lib/libssl.a ]]; then
OPENSSL_LIB="openssl"
fi
# check status # check status
ret=$?; if [[ $ret -ne 0 ]]; then echo "Build openssl-1.1.0e failed, ret=$ret"; exit $ret; fi ret=$?; if [[ $ret -ne 0 ]]; then echo "Build $OPENSSL_CANDIDATE failed, ret=$ret"; exit $ret; fi
# Always update the links. # Always update the links.
(cd ${SRS_OBJS} && rm -rf openssl && ln -sf ${SRS_PLATFORM}/${OPENSSL_LIB} openssl) (cd ${SRS_OBJS} && rm -rf openssl && ln -sf ${SRS_PLATFORM}/${OPENSSL_LIB} openssl)
if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build openssl-1.1.0e failed."; exit -1; fi if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build $OPENSSL_CANDIDATE failed."; exit -1; fi
fi fi
##################################################################################### #####################################################################################
# srtp # srtp
##################################################################################### #####################################################################################
if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
SRTP_CONFIG="echo 'SRTP without openssl'" && SRTP_OPTIONS=""
# If use ASM for SRTP, we enable openssl(with ASM).
if [[ $SRS_SRTP_ASM == YES ]]; then
SRTP_CONFIG="export PKG_CONFIG_PATH=../openssl/lib/pkgconfig" && SRTP_OPTIONS="--enable-openssl"
fi
# Patched ST from https://github.com/ossrs/state-threads/tree/srs # Patched ST from https://github.com/ossrs/state-threads/tree/srs
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/srtp2/lib/libsrtp2.a ]]; then if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/srtp2/lib/libsrtp2.a ]]; then
echo "The srtp2 is ok."; echo "The srtp2 is ok.";
@ -531,7 +540,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
( (
rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS}/${SRS_PLATFORM} &&
rm -rf libsrtp-2.0.0 && unzip -q ../../3rdparty/libsrtp-2.0.0.zip && cd libsrtp-2.0.0 && rm -rf libsrtp-2.0.0 && unzip -q ../../3rdparty/libsrtp-2.0.0.zip && cd libsrtp-2.0.0 &&
./configure --prefix=`pwd`/_release && make ${SRS_JOBS} && make install && ${SRTP_CONFIG} && ./configure ${SRTP_OPTIONS} --prefix=`pwd`/_release &&
make ${SRS_JOBS} && make install &&
cd .. && rm -f srtp2 && ln -sf libsrtp-2.0.0/_release srtp2 cd .. && rm -f srtp2 && ln -sf libsrtp-2.0.0/_release srtp2
) )
fi fi

View file

@ -19,7 +19,6 @@ SRS_HDS=NO
SRS_SRT=NO SRS_SRT=NO
SRS_RTC=YES SRS_RTC=YES
SRS_GB28181=NO SRS_GB28181=NO
SRS_NASM=YES
SRS_NGINX=NO SRS_NGINX=NO
SRS_FFMPEG_TOOL=NO SRS_FFMPEG_TOOL=NO
SRS_LIBRTMP=NO SRS_LIBRTMP=NO
@ -77,6 +76,10 @@ SRS_EXPORT_LIBRTMP_PROJECT=NO
SRS_EXPORT_LIBRTMP_SINGLE=NO SRS_EXPORT_LIBRTMP_SINGLE=NO
# valgrind # valgrind
SRS_VALGRIND=NO SRS_VALGRIND=NO
# Set the object files tag name.
SRS_BUILD_TAG=
# Whether do "make clean" when configure.
SRS_CLEAN=YES
# #
################################################################ ################################################################
# presets # presets
@ -112,10 +115,11 @@ SRS_TOOL_AR=ar
SRS_TOOL_LD=ld SRS_TOOL_LD=ld
SRS_TOOL_RANDLIB=randlib SRS_TOOL_RANDLIB=randlib
SRS_EXTRA_FLAGS= SRS_EXTRA_FLAGS=
# Set the object files tag name. #
SRS_BUILD_TAG= #####################################################################################
# Whether do "make clean" when configure. # Performance optimize.
SRS_CLEAN=YES SRS_NASM=YES
SRS_SRTP_ASM=YES
##################################################################################### #####################################################################################
# menu # menu
@ -179,6 +183,11 @@ Performance: @see https://blog.csdn.net/win_lin/article/details/5
--without-gcp Do not build cpu profile for SRS with gperf tools. --without-gcp Do not build cpu profile for SRS with gperf tools.
--without-gprof Do not build srs with gprof(GNU profile tool). --without-gprof Do not build srs with gprof(GNU profile tool).
--with-nasm Build FFMPEG for RTC with nasm support.
--without-nasm Build FFMPEG for RTC without nasm support, for CentOS6 nasm is too old.
--with-srtp-nasm Build SRTP with ASM(openssl-asm) support, requires RTC and openssl-1.0.*.
--without-srtp-nasm Disable SRTP ASM support.
Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuecomment-576078411 Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuecomment-576078411
--arm Enable crossbuild for ARM. --arm Enable crossbuild for ARM.
--mips Enable crossbuild for MIPS. --mips Enable crossbuild for MIPS.
@ -188,11 +197,6 @@ Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuec
--ld=<LD> Use linker tool LD, default is ld. --ld=<LD> Use linker tool LD, default is ld.
--randlib=<RANDLIB> Use randlib tool RANDLIB, default is randlib. --randlib=<RANDLIB> Use randlib tool RANDLIB, default is randlib.
--extra-flags=<EFLAGS> Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS. --extra-flags=<EFLAGS> Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS.
--with-nasm Build FFMPEG for RTC with nasm support.
--without-nasm Build FFMPEG for RTC without nasm support, for CentOS6 nasm is too old.
--build-tag=<TAG> Set the build object directory suffix.
--with-clean Configure SRS and do make clean if possible.
--without-clean Configure SRS and never make clean even possible..
Conflicts: Conflicts:
1. --with-gmc vs --with-gmp: 1. --with-gmc vs --with-gmp:
@ -208,6 +212,9 @@ Experts:
--use-shared-srt Use link shared libraries for SRT which uses MPL license. --use-shared-srt Use link shared libraries for SRT which uses MPL license.
--export-librtmp-project=<path> Export srs-librtmp to specified project in path. --export-librtmp-project=<path> Export srs-librtmp to specified project in path.
--export-librtmp-single=<path> Export srs-librtmp to a single file(.h+.cpp) in path. --export-librtmp-single=<path> Export srs-librtmp to a single file(.h+.cpp) in path.
--build-tag=<TAG> Set the build object directory suffix.
--with-clean Configure SRS and do make clean if possible.
--without-clean Configure SRS and never make clean even possible..
Workflow: Workflow:
1. Apply "Presets". if not specified, use default preset. 1. Apply "Presets". if not specified, use default preset.
@ -241,6 +248,7 @@ function parse_user_option() {
--with-rtc) SRS_RTC=YES ;; --with-rtc) SRS_RTC=YES ;;
--with-gb28181) SRS_GB28181=YES ;; --with-gb28181) SRS_GB28181=YES ;;
--with-nasm) SRS_NASM=YES ;; --with-nasm) SRS_NASM=YES ;;
--with-srtp-nasm) SRS_SRTP_ASM=YES ;;
--with-clean) SRS_CLEAN=YES ;; --with-clean) SRS_CLEAN=YES ;;
--with-gperf) SRS_GPERF=YES ;; --with-gperf) SRS_GPERF=YES ;;
--with-gmc) SRS_GPERF_MC=YES ;; --with-gmc) SRS_GPERF_MC=YES ;;
@ -261,6 +269,7 @@ function parse_user_option() {
--without-rtc) SRS_RTC=NO ;; --without-rtc) SRS_RTC=NO ;;
--without-gb28181) SRS_GB28181=NO ;; --without-gb28181) SRS_GB28181=NO ;;
--without-nasm) SRS_NASM=NO ;; --without-nasm) SRS_NASM=NO ;;
--without-srtp-nasm) SRS_SRTP_ASM=NO ;;
--without-clean) SRS_CLEAN=NO ;; --without-clean) SRS_CLEAN=NO ;;
--without-gperf) SRS_GPERF=NO ;; --without-gperf) SRS_GPERF=NO ;;
--without-gmc) SRS_GPERF_MC=NO ;; --without-gmc) SRS_GPERF_MC=NO ;;
@ -564,6 +573,7 @@ function regenerate_options() {
if [ $SRS_RTC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-rtc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-rtc"; fi if [ $SRS_RTC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-rtc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-rtc"; fi
if [ $SRS_GB28181 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gb28181"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gb28181"; fi if [ $SRS_GB28181 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gb28181"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gb28181"; fi
if [ $SRS_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-nasm"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-nasm"; fi if [ $SRS_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-nasm"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-nasm"; fi
if [ $SRS_SRTP_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-srtp-nasm"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-srtp-nasm"; fi
if [ $SRS_CLEAN = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-clean"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-clean"; fi if [ $SRS_CLEAN = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-clean"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-clean"; fi
if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gperf"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gperf"; fi if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gperf"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gperf"; fi
if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmc"; fi if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmc"; fi
@ -616,6 +626,16 @@ function check_option_conflicts() {
exit -1 exit -1
fi fi
if [[ $SRS_SRTP_ASM == YES && $SRS_RTC == NO ]]; then
echo "Disable SRTP ASM, because RTC is disabled."
SRS_SRTP_ASM=NO
fi
if [[ $SRS_SRTP_ASM == YES && $SRS_NASM == NO ]]; then
echo "Disable SRTP ASM, because NASM is disabled."
SRS_SRTP_ASM=NO
fi
# TODO: FIXME: check more os. # TODO: FIXME: check more os.
__check_ok=YES __check_ok=YES