diff --git a/AUTHORS.txt b/AUTHORS.txt index aa1670a7f..89d65917f 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -51,4 +51,5 @@ CONTRIBUTORS ordered by first contribution. * Himer * xialixin * alphonsetai -* Michael.Ma \ No newline at end of file +* Michael.Ma +* lam2003 \ No newline at end of file diff --git a/README.md b/README.md index 1c778156b..bea5e5e45 100755 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [![](https://codecov.io/gh/ossrs/srs/branch/develop/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/develop) [![](https://cloud.githubusercontent.com/assets/2777660/22814959/c51cbe72-ef92-11e6-81cc-32b657b285d5.png)](https://github.com/ossrs/srs/wiki/v1_CN_Contact#wechat) -SRS/3.0,[OuXuli][release3],是一个简单的流媒体直播集群,简单的快乐。
-SRS(Simple RTMP Server) is a simple live streaming cluster, a simple joy. +SRS/3.0,[OuXuli][release3],是一个流媒体直播集群,高效、稳定、易用,简单而快乐。
+SRS(Simple RTMP Server) is a live streaming cluster, high efficiency, stable and simple. > Remark: Although SRS is licenced under [MIT][LICENSE], but there are some depended libraries which are distributed using their own licenses, please read [License Mixing][LicenseMixing]. @@ -148,6 +148,12 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-21, [3.0 alpha9(3.0.105)][r3.0a9] released. 121577 lines. +* v3.0, 2020-01-21, Fix [#1221][bug #1221], remove complex configure options. 3.0.104 +* v3.0, 2020-01-21, Fix [#1547][bug #1547], support crossbuild for ARM/MIPS. +* v3.0, 2020-01-21, For [#1547][bug #1547], support setting cc/cxx/ar/ld/randlib tools. 3.0.103 +* v3.0, 2020-01-19, For [#1580][bug #1580], fix cid range problem. 3.0.102 +* v3.0, 2020-01-19, For [#1070][bug #1070], define FLV CodecID for [AV1][bug #1070] and [opus][bug #307]. 3.0.101 * v3.0, 2020-01-16, For [#1575][bug #1575], correct RTMP redirect as tcUrl, add redirect2 as RTMP URL. 3.0.100 * v3.0, 2020-01-15, For [#1509][bug #1509], decrease the fast vector init size from 64KB to 64B. 3.0.99 * v3.0, 2020-01-15, For [#1509][bug #1509], release coroutine when source is idle. 3.0.98 @@ -717,6 +723,7 @@ For previous versions, please read: ## Releases +* 2020-01-21, [Release v3.0-a9][r3.0a9], 3.0 alpha9, 3.0.105, 121577 lines. * 2020-01-10, [Release v3.0-a8][r3.0a8], 3.0 alpha8, 3.0.97, 121555 lines. * 2019-12-29, [Release v3.0-a7][r3.0a7], 3.0 alpha7, 3.0.90, 116356 lines. * 2019-12-26, [Release v3.0-a6][r3.0a6], 3.0 alpha6, 3.0.85, 116056 lines. @@ -1599,6 +1606,11 @@ Winlin [bug #1543]: https://github.com/ossrs/srs/issues/1543 [bug #1509]: https://github.com/ossrs/srs/issues/1509 [bug #1575]: https://github.com/ossrs/srs/issues/1575 +[bug #307]: https://github.com/ossrs/srs/issues/307 +[bug #1070]: https://github.com/ossrs/srs/issues/1070 +[bug #1580]: https://github.com/ossrs/srs/issues/1580 +[bug #1547]: https://github.com/ossrs/srs/issues/1547 +[bug #1221]: https://github.com/ossrs/srs/issues/1221 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [bug #1111]: https://github.com/ossrs/srs/issues/1111 @@ -1607,6 +1619,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r3.0a9]: https://github.com/ossrs/srs/releases/tag/v3.0-a9 [r3.0a8]: https://github.com/ossrs/srs/releases/tag/v3.0-a8 [r3.0a7]: https://github.com/ossrs/srs/releases/tag/v3.0-a7 [r3.0a6]: https://github.com/ossrs/srs/releases/tag/v3.0-a6 diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 10e76e99f..87720b840 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -40,9 +40,6 @@ function srs_undefine_macro() } # export the preset. -if [ $SRS_OSX = YES ]; then - srs_define_macro "SRS_OSX" $SRS_AUTO_HEADERS_H -fi if [ $SRS_X86_X64 = YES ]; then srs_define_macro "SRS_X86_X64" $SRS_AUTO_HEADERS_H fi @@ -135,6 +132,11 @@ if [ $SRS_LOG_TRACE = YES ]; then else srs_undefine_macro "SRS_AUTO_TRACE" $SRS_AUTO_HEADERS_H fi +if [ $SRS_CROSS_BUILD = YES ]; then + srs_define_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H +else + srs_undefine_macro "SRS_AUTO_CROSSBUILD" $SRS_AUTO_HEADERS_H +fi # prefix echo "" >> $SRS_AUTO_HEADERS_H diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index dd4471f62..bf183c0a6 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -96,7 +96,7 @@ function Ubuntu_prepare() if [[ $SRS_VALGRIND == YES ]]; then if [[ ! -f /usr/include/valgrind/valgrind.h ]]; then echo "Installing valgrind-dev." - require_sudoer "sudo apt-get install -y --force-yes valgrind-dev" + require_sudoer "sudo apt-get install -y --force-yes valgrind-dbg" sudo apt-get install -y --force-yes valgrind-dev; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi echo "The valgrind-dev is installed." fi @@ -185,101 +185,11 @@ fi ##################################################################################### # for Centos, auto install tools by yum ##################################################################################### -OS_IS_OSX=NO -function OSX_prepare() -{ - uname -s|grep Darwin >/dev/null 2>&1 - ret=$?; if [[ 0 -ne $ret ]]; then - if [ $SRS_OSX = YES ]; then - echo "Current OS `uname -s` is not OSX, please check your configure options." - exit 1; - fi - return 0; - fi - - OS_IS_OSX=YES - echo "Installing tools for OSX." - # requires the osx when os - if [ $OS_IS_OSX = YES ]; then - if [ $SRS_OSX = NO ]; then - echo "Invalid configure options for OSX, please specify --osx." - exit 1 - fi - fi - - brew --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing brew." - echo "ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"" - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The brew is installed." - fi - - gcc --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing gcc." - echo "brew install gcc" - brew install gcc; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The gcc is installed." - fi - - g++ --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing gcc-c++." - echo "brew install gcc-c++" - brew install gcc-c++; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The gcc-c++ is installed." - fi - - make --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing make." - echo "brew install make" - brew install make; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The make is installed." - fi - - patch --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing patch." - echo "brew install patch" - brew install patch; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The patch is installed." - fi - - unzip --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing unzip." - echo "brew install unzip" - brew install unzip; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The unzip is installed." - fi - - if [[ $SRS_VALGRIND == YES ]]; then - valgrind --help >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing valgrind." - echo "brew install valgrind" - brew install valgrind; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The valgrind is installed." - fi - fi - - echo "Tools for OSX are installed." - return 0 -} -# donot prepare tools, for srs-librtmp depends only gcc and g++. -if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then - OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "Install tools for OSX failed, ret=$ret"; exit $ret; fi -fi - # We must use a bash function instead of variable. function sed_utility() { - if [ $OS_IS_OSX = YES ]; then - sed -i '' "$@" - else - sed -i "$@" - fi - + sed -i "$@" ret=$?; if [[ $ret -ne 0 ]]; then - if [ $OS_IS_OSX = YES ]; then - echo "sed -i '' \"$@\"" - else - echo "sed -i \"$@\"" - fi + echo "sed -i \"$@\"" return $ret fi } @@ -294,7 +204,7 @@ SED="sed_utility" && echo "SED is $SED" # directly build on arm/mips, for example, pi or cubie, # export srs-librtmp # others is invalid. -if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $OS_IS_OSX = NO && $SRS_EXPORT_LIBRTMP_PROJECT = NO ]]; then +if [[ $OS_IS_UBUNTU = NO && $OS_IS_CENTOS = NO && $SRS_EXPORT_LIBRTMP_PROJECT = NO ]]; then if [[ $SRS_PI = NO && $SRS_CUBIE = NO && $SRS_CROSS_BUILD = NO ]]; then echo "Your OS `uname -s` is not supported." exit 1 @@ -307,16 +217,12 @@ fi if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then # check the cross build flag file, if flag changed, need to rebuild the st. _ST_MAKE=linux-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_EPOLL" - # for osx, use darwin for st, donot use epoll. - if [ $OS_IS_OSX = YES ]; then - _ST_MAKE=darwin-debug && _ST_EXTRA_CFLAGS="-DMD_HAVE_KQUEUE -I/usr/local/include" - fi if [[ $SRS_VALGRIND == YES ]]; then _ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_VALGRIND" fi # Pass the global extra flags. - if [[ $SRS_EXTRA_CFLAGS != '' ]]; then - _ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS $SRS_EXTRA_CFLAGS" + if [[ $SRS_EXTRA_FLAGS != '' ]]; then + _ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS $SRS_EXTRA_FLAGS" fi # Patched ST from https://github.com/ossrs/state-threads/tree/srs if [[ -f ${SRS_OBJS}/st/libst.a ]]; then @@ -326,7 +232,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then ( rm -rf ${SRS_OBJS}/st-srs && cd ${SRS_OBJS} && ln -sf ../3rdparty/st-srs && cd st-srs && - make clean && make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" && + make clean && make ${_ST_MAKE} EXTRA_CFLAGS="${_ST_EXTRA_CFLAGS}" \ + CC=${SRS_TOOL_CC} AR=${SRS_TOOL_AR} LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} && cd .. && rm -f st && ln -sf st-srs/obj st ) fi @@ -413,53 +320,55 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then fi ##################################################################################### -# openssl, for rtmp complex handshake +# openssl, for rtmp complex handshake and HLS encryption. ##################################################################################### -# extra configure options -CONFIGURE_TOOL="./config" -if [ $SRS_OSX = YES ]; then - CONFIGURE_TOOL="./Configure darwin64-`uname -m`-cc" +if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then + echo "Warning: Use system libssl, without compiling openssl." fi -OPENSSL_HOTFIX="-DOPENSSL_NO_HEARTBEATS" # @see http://www.openssl.org/news/secadv/20140407.txt # Affected users should upgrade to OpenSSL 1.1.0e. Users unable to immediately # upgrade can alternatively recompile OpenSSL with -DOPENSSL_NO_HEARTBEATS. -if [ $SRS_SSL = YES ]; then - if [[ -f /usr/local/lib64/libssl.a && ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]]; then - (mkdir -p ${SRS_OBJS}/openssl/lib && cd ${SRS_OBJS}/openssl/lib && - ln -sf /usr/local/lib64/libssl.a && ln -sf /usr/local/lib64/libcrypto.a) - (mkdir -p ${SRS_OBJS}/openssl/include && cd ${SRS_OBJS}/openssl/include && - ln -sf /usr/local/include/openssl) - fi - if [ $SRS_USE_SYS_SSL = YES ]; then - echo "Warning: Use system libssl, without compiling openssl." +if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL != YES ]]; then + OPENSSL_HOTFIX="-DOPENSSL_NO_HEARTBEATS" + OPENSSL_CONFIG="./config" + # https://stackoverflow.com/questions/15539062/cross-compiling-of-openssl-for-linux-arm-v5te-linux-gnueabi-toolchain + if [[ $SRS_CROSS_BUILD == YES ]]; then + OPENSSL_CONFIG="./Configure linux-armv4" else - # cross build not specified, if exists flag, need to rebuild for no-arm platform. - if [[ -f ${SRS_OBJS}/openssl/lib/libssl.a ]]; then - echo "Openssl-1.1.0e is ok."; - else - echo "Building openssl-1.1.0e."; - ( - rm -rf ${SRS_OBJS}/openssl-1.1.0e && cd ${SRS_OBJS} && - unzip -q ../3rdparty/openssl-1.1.0e.zip && cd openssl-1.1.0e && - $CONFIGURE_TOOL --prefix=`pwd`/_release -no-shared no-threads $OPENSSL_HOTFIX && - make && make install_sw && - cd .. && rm -rf openssl && ln -sf openssl-1.1.0e/_release openssl - ) + # If not crossbuild, try to use exists libraries. + if [[ -f /usr/local/lib64/libssl.a && ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]]; then + (mkdir -p ${SRS_OBJS}/openssl/lib && cd ${SRS_OBJS}/openssl/lib && + ln -sf /usr/local/lib64/libssl.a && ln -sf /usr/local/lib64/libcrypto.a) + (mkdir -p ${SRS_OBJS}/openssl/include && cd ${SRS_OBJS}/openssl/include && + ln -sf /usr/local/include/openssl) fi - # check status - ret=$?; if [[ $ret -ne 0 ]]; then echo "Build openssl-1.1.0e failed, ret=$ret"; exit $ret; fi - if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build openssl-1.1.0e failed."; exit -1; fi fi + # cross build not specified, if exists flag, need to rebuild for no-arm platform. + if [[ -f ${SRS_OBJS}/openssl/lib/libssl.a ]]; then + echo "Openssl-1.1.0e is ok."; + else + echo "Building openssl-1.1.0e."; + ( + rm -rf ${SRS_OBJS}/openssl-1.1.0e && cd ${SRS_OBJS} && + unzip -q ../3rdparty/openssl-1.1.0e.zip && cd openssl-1.1.0e && + ${OPENSSL_CONFIG} --prefix=`pwd`/_release -no-shared -no-threads -no-asm $OPENSSL_HOTFIX && + make CC=${SRS_TOOL_CC} AR="${SRS_TOOL_AR} -rs" LD=${SRS_TOOL_LD} RANDLIB=${SRS_TOOL_RANDLIB} && make install_sw && + cd .. && rm -rf openssl && ln -sf openssl-1.1.0e/_release openssl + ) + fi + # check status + ret=$?; if [[ $ret -ne 0 ]]; then echo "Build openssl-1.1.0e failed, ret=$ret"; exit $ret; fi + if [ ! -f ${SRS_OBJS}/openssl/lib/libssl.a ]; then echo "Build openssl-1.1.0e failed."; exit -1; fi fi ##################################################################################### # live transcoding, ffmpeg-4.1, x264-core157, lame-3.99.5, libaacplus-2.0.2. ##################################################################################### +# Always link the ffmpeg tools if exists. +if [[ -f /usr/local/bin/ffmpeg && ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then + mkdir -p ${SRS_OBJS}/ffmpeg/bin && ln -sf /usr/local/bin/ffmpeg ${SRS_OBJS}/ffmpeg/bin/ffmpeg +fi if [ $SRS_FFMPEG_TOOL = YES ]; then - if [[ -f /usr/local/bin/ffmpeg && ! -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then - mkdir -p ${SRS_OBJS}/ffmpeg/bin && ln -sf /usr/local/bin/ffmpeg ${SRS_OBJS}/ffmpeg/bin/ffmpeg - fi if [[ -f ${SRS_OBJS}/ffmpeg/bin/ffmpeg ]]; then echo "ffmpeg-4.1 is ok."; else @@ -545,4 +454,3 @@ fi # generated the test script ##################################################################################### rm -rf ${SRS_OBJS}/srs.test && ln -sf `pwd`/scripts/srs.test objs/srs.test - diff --git a/trunk/auto/generate-srs-librtmp-single.sh b/trunk/auto/generate-srs-librtmp-single.sh index 6def4b9a4..cb2174daa 100755 --- a/trunk/auto/generate-srs-librtmp-single.sh +++ b/trunk/auto/generate-srs-librtmp-single.sh @@ -1,12 +1,5 @@ #!/bin/bash -OS_IS_OSX=NO -uname -s|grep Darwin >/dev/null 2>&1 -ret=$?; if [[ 0 -eq $ret ]]; then - OS_IS_OSX=YES -fi -echo "Is OSX: ${OS_IS_OSX}" - # when export srs-librtmp single files # package the whole project to srs_librtmp.h and srs_librtmp.cpp # diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index d19e18356..8e9fae371 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -54,8 +54,6 @@ SRS_GCOV=NO SRS_LOG_VERBOSE=NO SRS_LOG_INFO=NO SRS_LOG_TRACE=NO -# The extra c/c++ flags to build SRS. Note that we also pass to ST as EXTRA_CFLAGS. -SRS_EXTRA_CFLAGS= # ################################################################ # experts @@ -77,7 +75,6 @@ SRS_VALGRIND=NO SRS_X86_X64=NO # for osx system SRS_OSX=NO -SRS_ALLOW_OSX=NO # dev, open all features for dev, no gperf/prof/arm. SRS_DEV=NO # dev, open main server feature for dev, no utest/research/librtmp @@ -98,8 +95,14 @@ SRS_DISABLE_ALL=NO SRS_ENABLE_ALL=NO # ##################################################################################### -# We don't support crossbuild for ARM/MIPS, please directly build it on ARM/MIPS server. +# Toolchain crossbuild for ARM or MIPS. SRS_CROSS_BUILD=NO +SRS_TOOL_CC=gcc +SRS_TOOL_CXX=g++ +SRS_TOOL_AR=ar +SRS_TOOL_LD=ld +SRS_TOOL_RANDLIB=randlib +SRS_EXTRA_FLAGS= ##################################################################################### # menu @@ -107,106 +110,84 @@ SRS_CROSS_BUILD=NO function show_help() { cat << END -Options: - -h, --help print this message - - --with-ssl enable rtmp complex handshake, requires openssl-devel installed. - --with-hds enable hds streaming, mux RTMP to F4M/F4V files. - --with-nginx enable delivery HTTP stream with nginx. - --with-stream-caster enable stream caster to serve other stream over other protocol. - --with-ffmpeg enable transcoding tool ffmpeg. - --with-transcode enable transcoding features. - --with-ingest enable ingest features. - --with-stat enable the data statistic, for http api. - --with-librtmp enable srs-librtmp, library for client. - --with-research build the research tools. - --with-utest build the utest for SRS. - --with-gperf build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only). - https://blog.csdn.net/win_lin/article/details/53503869 - --with-gmc build memory check for SRS with gperf tools. - --with-gmd build memory defense(corrupt memory) for SRS with gperf tools. - --with-gmp build memory profile for SRS with gperf tools. - --with-gcp build cpu profile for SRS with gperf tools. - --with-gprof build SRS with gprof(GNU profile tool). - --with-arm-ubuntu12 cross build SRS on ubuntu12 for armhf(v7cpu). - --with-mips-ubuntu12 cross build SRS on ubuntu12 for mips. - - --without-ssl disable rtmp complex handshake. - --without-hds disable hds, the adobe http dynamic streaming. - --without-nginx disable delivery HTTP stream with nginx. - --without-stream-caster disable stream caster, only listen and serve RTMP/HTTP. - --without-ffmpeg disable the ffmpeg transcode tool feature. - --without-transcode disable the transcoding feature. - --without-ingest disable the ingest feature. - --without-stat disable the data statistic feature. - --without-librtmp disable srs-librtmp, library for client. - --without-research do not build the research tools. - --without-utest do not build the utest for SRS. - --without-gperf do not build SRS with gperf tools(without tcmalloc and gmd/gmc/gmp/gcp). - --without-gmc do not build memory check for SRS with gperf tools. - --without-gmd do not build memory defense for SRS with gperf tools. - --without-gmp do not build memory 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-arm-ubuntu12 do not cross build srs on ubuntu12 for armhf(v7cpu). - --without-mips-ubuntu12 do not cross build srs on ubuntu12 for mips. - +Presets: + --x86-64, --x86-x64 [default] For x86/x64 cpu, common pc and servers. + --arm Enable crossbuild for ARM, should also set bellow toolchain options. + --mips Enable crossbuild for MIPS + +Features: + -h, --help Print this message and exit 0. + + --with-ssl Enable rtmp complex handshake, requires openssl-devel installed. + --with-hds Enable hds streaming, mux RTMP to F4M/F4V files. + --with-stream-caster Enable stream caster to serve other stream over other protocol. + --with-stat Enable the data statistic, for http api. + --with-librtmp Enable srs-librtmp, library for client. + --with-research Build the research tools. + --with-utest Build the utest for SRS. + + --without-ssl Disable rtmp complex handshake. + --without-hds Disable hds, the adobe http dynamic streaming. + --without-stream-caster Disable stream caster, only listen and serve RTMP/HTTP. + --without-stat Disable the data statistic feature. + --without-librtmp Disable srs-librtmp, library for client. + --without-research Do not build the research tools. + --without-utest Do not build the utest for SRS. + --prefix= The absolute installation path for srs. Default: $SRS_PREFIX --static Whether add '-static' to link options. --gcov Whether enable the GCOV compiler options. --jobs[=N] Allow N jobs at once; infinite jobs with no arg. - used for make in the configure, for example, to make ffmpeg. - --log-verbose whether enable the log verbose level. default: no. - --log-info whether enable the log info level. default: no. - --log-trace whether enable the log trace level. default: yes. + Used for make in the configure, for example, to make ffmpeg. + --log-verbose Whether enable the log verbose level. default: no. + --log-info Whether enable the log info level. default: no. + --log-trace Whether enable the log trace level. default: yes. + +Performance: @see https://blog.csdn.net/win_lin/article/details/53503869 + --with-valgrind Support valgrind for memory check. + --with-gperf Build SRS with gperf tools(no gmd/gmc/gmp/gcp, with tcmalloc only). + --with-gmc Build memory check for SRS with gperf tools. + --with-gmd Build memory defense(corrupt memory) for SRS with gperf tools. + --with-gmp Build memory profile for SRS with gperf tools. + --with-gcp Build cpu profile for SRS with gperf tools. + --with-gprof Build SRS with gprof(GNU profile tool). + + --without-valgrind Do not support valgrind for memory check. + --without-gperf Do not build SRS with gperf tools(without tcmalloc and gmd/gmc/gmp/gcp). + --without-gmc Do not build memory check for SRS with gperf tools. + --without-gmd Do not build memory defense for SRS with gperf tools. + --without-gmp Do not build memory 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). + +Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuecomment-576078411 + --arm Enable crossbuild for ARM. + --mips Enable crossbuild for MIPS. + --cc= Use c compiler CC, default is gcc. + --cxx= Use c++ compiler CXX, default is g++. + --ar= Use archive tool AR, default is ar. + --ld= Use linker tool LD, default is ld. + --randlib= Use randlib tool RANDLIB, default is randlib. + --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS. -Presets: - --x86-x64 [default] for x86/x64 cpu, common pc and servers. - --osx for osx(darwin) system to build SRS. - --pi for raspberry-pi(directly build), open features hls/ssl/static. - --cubie for cubieboard(directly build), open features except ffmpeg/nginx. - --arm alias for --with-arm-ubuntu12, for ubuntu12, arm crossbuild - --mips alias for --with-mips-ubuntu12, for ubuntu12, mips crossbuild - --fast the most fast compile, nothing, only support vp6 RTMP. - --pure-rtmp only support RTMP with ssl. - --disable-all disable all features, only support vp6 RTMP. - --dev for dev, open all features, no nginx/gperf/gprof/arm. - --fast-dev for dev fast compile, the RTMP server, without librtmp/utest/research. - --demo for srs demo, @see: https://github.com/ossrs/srs/wiki/v1_CN_SampleDemo - --full enable all features, no gperf/gprof/arm. - --x86-64 alias for --x86-x64. - -Toolchain options: - --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Pass to ST as EXTRA_CFLAGS. - -Recomment to enable: - --with-http-api enable HTTP API, to communicate with SRS. - --with-http-callback enable HTTP hooks, build cherrypy as demo api server. - --with-http-server enable HTTP server to delivery http stream. - --with-hls enable HLS streaming, mux RTMP to M3U8/TS files. - --with-dvr enable DVR, record RTMP to FLV/MP4 files. - Conflicts: 1. --with-gmc vs --with-gmp: @see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html 2. --with-gperf/gmc/gmp vs --with-gprof: - gperftools not compatible with gprof. + The gperftools not compatible with gprof. 3. --arm vs --with-ffmpeg/gperf/gmc/gmp/gprof: - the complex tools not available for arm. + The complex tools not available for arm. Experts: - --use-sys-ssl donot compile ssl, use system ssl(-lssl) if required. - --memory-watch enable memory watch to detect memory leaking(hurts performance). - --export-librtmp-project= export srs-librtmp to specified project in path. - --export-librtmp-single= export srs-librtmp to a single file(.h+.cpp) in path. - --with-valgrind support valgrind for memory check. - --without-valgrind donot support valgrind for memory check. + --use-sys-ssl Do not compile ssl, use system ssl(-lssl) if required. + --export-librtmp-project= Export srs-librtmp to specified project in path. + --export-librtmp-single= Export srs-librtmp to a single file(.h+.cpp) in path. Workflow: - 1. apply "Presets". if not specified, use default preset. - 2. apply "Options". user specified option will override the preset. - 3. check conflicts. @see Conflicts section. - 4. generate detail features. + 1. Apply "Presets". if not specified, use default preset. + 2. Apply "Features", "Performance" and others. user specified option will override the preset. + 3. Check conflicts, fail if exists conflicts. + 4. Generate Makefile. Remark: 1. For performance improving, read https://blog.csdn.net/win_lin/article/details/53503869 @@ -238,15 +219,10 @@ function parse_user_option() { --with-gprof) SRS_GPROF=YES ;; --with-arm-ubuntu12) SRS_CROSS_BUILD=YES ;; --with-mips-ubuntu12) SRS_CROSS_BUILD=YES ;; - - --without-ssl) SRS_SSL=NO ;; + --without-hds) SRS_HDS=NO ;; --without-nginx) SRS_NGINX=NO ;; --without-ffmpeg) SRS_FFMPEG_TOOL=NO ;; - --without-transcode) SRS_TRANSCODE=NO ;; - --without-ingest) SRS_INGEST=NO ;; - --without-stat) SRS_STAT=NO ;; - --without-stream-caster) SRS_STREAM_CASTER=NO ;; --without-librtmp) SRS_LIBRTMP=NO ;; --without-research) SRS_RESEARCH=NO ;; --without-utest) SRS_UTEST=NO ;; @@ -260,20 +236,26 @@ function parse_user_option() { --without-mips-ubuntu12) SRS_CROSS_BUILD=NO ;; --jobs) SRS_JOBS=${value} ;; - --extra-flags) SRS_EXTRA_CFLAGS=${value} ;; --prefix) SRS_PREFIX=${value} ;; --static) SRS_STATIC=YES ;; --log-verbose) SRS_LOG_VERBOSE=YES ;; --log-info) SRS_LOG_INFO=YES ;; --log-trace) SRS_LOG_TRACE=YES ;; --gcov) SRS_GCOV=YES ;; - + + --arm) SRS_CROSS_BUILD=YES ;; + --mips) SRS_CROSS_BUILD=YES ;; + --cc) SRS_TOOL_CC=${value} ;; + --cxx) SRS_TOOL_CXX=${value} ;; + --ar) SRS_TOOL_AR=${value} ;; + --ld) SRS_TOOL_LD=${value} ;; + --randlib) SRS_TOOL_RANDLIB=${value} ;; + --extra-flags) SRS_EXTRA_FLAGS=${value} ;; + --x86-x64) SRS_X86_X64=YES ;; --x86-64) SRS_X86_X64=YES ;; --osx) SRS_OSX=YES ;; - --allow-osx) SRS_ALLOW_OSX=YES ;; - --arm) SRS_CROSS_BUILD=YES ;; - --mips) SRS_CROSS_BUILD=YES ;; + --allow-osx) SRS_OSX=YES ;; --pi) SRS_PI=YES ;; --cubie) SRS_CUBIE=YES ;; --dev) SRS_DEV=YES ;; @@ -296,11 +278,19 @@ function parse_user_option() { --with-http-server) SRS_HTTP_SERVER=YES ;; --with-hls) SRS_HLS=YES ;; --with-dvr) SRS_DVR=YES ;; - --without-http-callback) SRS_HTTP_CALLBACK=NO ;; - --without-http-api) SRS_HTTP_API=NO ;; - --without-http-server) SRS_HTTP_SERVER=NO ;; - --without-hls) SRS_HLS=NO ;; - --without-dvr) SRS_DVR=NO ;; + + --without-stream-caster) ;& + --without-ingest) ;& + --without-ssl) ;& + --without-stat) ;& + --without-transcode) ;& + --without-http-callback) ;& + --without-http-server) ;& + --without-http-api) ;& + --without-hls) ;& + --without-dvr) + echo "ignore option \"$option\"" + ;; *) echo "$0: error: invalid option \"$option\"" @@ -313,7 +303,7 @@ function parse_user_option_to_value_and_option() { case "$option" in -*=*) value=`echo "$option" | sed -e 's|[-_a-zA-Z0-9/]*=||'` - option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/. ]*||'` + option=`echo "$option" | sed -e 's|=[-_a-zA-Z0-9/. +]*||'` ;; *) value="" ;; esac @@ -345,7 +335,7 @@ function apply_user_presets() { # set default preset if not specifies if [[ $SRS_PURE_RTMP == NO && $SRS_FAST == NO && $SRS_DISABLE_ALL == NO && $SRS_ENABLE_ALL == NO && \ $SRS_DEV == NO && $SRS_FAST_DEV == NO && $SRS_DEMO == NO && $SRS_PI == NO && $SRS_CUBIE == NO && \ - $SRS_X86_X64 == NO && $SRS_OSX == NO \ + $SRS_X86_X64 == NO && $SRS_OSX == NO && $SRS_CROSS_BUILD == NO \ ]]; then SRS_X86_X64=YES; opt="--x86-x64 $opt"; fi @@ -439,6 +429,14 @@ function apply_user_presets() { SRS_UTEST=NO SRS_STATIC=NO fi + + # if crossbuild, disable research and librtmp. + if [[ $SRS_CROSS_BUILD == YES ]]; then + SRS_LIBRTMP=NO + SRS_RESEARCH=NO + SRS_UTEST=NO + SRS_STATIC=NO + fi } apply_user_presets @@ -535,7 +533,12 @@ SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}" if [ $SRS_LOG_INFO = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-info"; fi if [ $SRS_LOG_TRACE = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-trace"; fi if [ $SRS_GCOV = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcov"; fi - if [[ $SRS_EXTRA_CFLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-flags=\\\"$SRS_EXTRA_CFLAGS\\\""; fi + if [[ $SRS_EXTRA_FLAGS != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --extra-flags=\\\"$SRS_EXTRA_FLAGS\\\""; fi + if [[ $SRS_TOOL_CC != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cc=$SRS_TOOL_CC"; fi + if [[ $SRS_TOOL_CXX != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx=$SRS_TOOL_CXX"; fi + if [[ $SRS_TOOL_AR != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ar=$SRS_TOOL_AR"; fi + if [[ $SRS_TOOL_LD != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ld=$SRS_TOOL_LD"; fi + if [[ $SRS_TOOL_RANDLIB != '' ]]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --randlib=$SRS_TOOL_RANDLIB"; fi echo "User config: $SRS_AUTO_USER_CONFIGURE" echo "Detail config: ${SRS_AUTO_CONFIGURE}" } @@ -545,24 +548,24 @@ regenerate_options # check user options ##################################################################################### function check_option_conflicts() { - if [ $SRS_CROSS_BUILD = YES ]; then - echo "We don't support crossbuild for ARM/MIPS, please directly build it on ARM/MIPS server." - exit -1 + if [[ $SRS_TOOL_CC == '' || $SRS_TOOL_CXX == '' || $SRS_TOOL_AR == '' || $SRS_TOOL_LD == '' || $SRS_TOOL_RANDLIB == '' ]]; then + echo "No crossbuild tools, cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR, ld: $SRS_TOOL_LD, randlib: $SRS_TOOL_RANDLIB"; exit -1 + fi + + if [[ $SRS_CROSS_BUILD == YES && ($SRS_TOOL_CC == 'gcc' || $SRS_TOOL_CXX == 'g++' || $SRS_TOOL_AR == 'ar') ]]; then + echo "For crossbuild, must not use default toolchain, cc: $SRS_TOOL_CC, cxx: $SRS_TOOL_CXX, ar: $SRS_TOOL_AR"; exit -1 fi if [ $SRS_OSX = YES ]; then - echo "We don't support OSX, please use docker https://github.com/ossrs/srs-docker" - exit -1 + echo "We don't support OSX, please use docker https://github.com/ossrs/srs-docker"; exit -1 fi if [[ $SRS_NGINX == YES ]]; then - echo "Don't support building NGINX, please use docker https://github.com/ossrs/srs-docker" - exit -1 + echo "Don't support building NGINX, please use docker https://github.com/ossrs/srs-docker"; exit -1 fi if [[ $SRS_FFMPEG_TOOL == YES ]]; then - echo "Don't support building FFMPEG, please use docker https://github.com/ossrs/srs-docker" - exit -1 + echo "Don't support building FFMPEG, please use docker https://github.com/ossrs/srs-docker"; exit -1 fi # TODO: FIXME: check more os. @@ -608,15 +611,5 @@ function check_option_conflicts() { if [ $__check_ok = NO ]; then exit 1; fi - - if [[ $SRS_OSX == YES && $SRS_ALLOW_OSX == NO ]]; then - macOSVersion=`sw_vers -productVersion` - macOSVersionMajor=`echo $macOSVersion|awk -F '.' '{print $1}'` - macOSVersionMinor=`echo $macOSVersion|awk -F '.' '{print $2}'` - if [[ $macOSVersionMajor -ge 10 && $macOSVersionMinor -ge 14 ]]; then - echo "macOS $macOSVersion is not supported, read https://github.com/ossrs/srs/issues/1250" - exit -1 - fi - fi } check_option_conflicts diff --git a/trunk/auto/utest.sh b/trunk/auto/utest.sh index d658bf7f4..18b4978cd 100755 --- a/trunk/auto/utest.sh +++ b/trunk/auto/utest.sh @@ -23,12 +23,6 @@ GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS_DIR}/gtest # the extra defines to compile utest. EXTRA_DEFINES="" -# for osx to disable the error. -# gtest/include/gtest/internal/gtest-port.h:499:13: fatal error: 'tr1/tuple' file not found -if [ $SRS_OSX = YES ]; then - EXTRA_DEFINES="$EXTRA_DEFINES -DGTEST_HAS_TR1_TUPLE=0" -fi - cat << END > ${FILE} # user must run make the ${SRS_OBJS_DIR}/utest dir # at the same dir of Makefile. diff --git a/trunk/configure b/trunk/configure index 3b366397f..d09ebc09e 100755 --- a/trunk/configure +++ b/trunk/configure @@ -119,16 +119,16 @@ if [[ $SRS_GCOV == YES ]]; then CXXFLAGS="${CXXFLAGS} ${SrsGcov}"; fi # User configed options. -if [[ $SRS_EXTRA_CFLAGS != '' ]]; then - CXXFLAGS="${CXXFLAGS} $SRS_EXTRA_CFLAGS"; +if [[ $SRS_EXTRA_FLAGS != '' ]]; then + CXXFLAGS="${CXXFLAGS} $SRS_EXTRA_FLAGS"; fi # Start to generate the Makefile. cat << END >> ${SRS_OBJS}/${SRS_MAKEFILE} -GCC = gcc -CXX = g++ -AR = ar +GCC = ${SRS_TOOL_CC} +CXX = ${SRS_TOOL_CXX} +AR = ${SRS_TOOL_AR} ARFLAGS = -rs -LINK = g++ +LINK = ${SRS_TOOL_CXX} CXXFLAGS = ${CXXFLAGS} .PHONY: default srs srs_ingest_hls librtmp @@ -568,7 +568,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then echo "" echo "Configure summary:" echo " ${SRS_AUTO_USER_CONFIGURE}" - echo " ${SRS_AUTO_CONFIGURE}" + echo " ${SRS_AUTO_CONFIGURE}" if [ $SRS_HLS = YES ]; then echo -e "${GREEN}HLS is enabled.${BLACK}" else diff --git a/trunk/scripts/new_authors.sh b/trunk/scripts/new_authors.sh index f0a94123c..7bc0dadd0 100755 --- a/trunk/scripts/new_authors.sh +++ b/trunk/scripts/new_authors.sh @@ -11,6 +11,7 @@ for author in $authors; do echo $author| grep 'winterserver' >/dev/null 2>&1 && continue; echo $author| grep 'wenjie.zhao' >/dev/null 2>&1 && continue; echo $author| grep 'zhaowenjie' >/dev/null 2>&1 && continue; + echo $author| grep 'noreply' >/dev/null 2>&1 && continue; grep $author $AFILE 1>/dev/null 2>/dev/null && continue; diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index dddacdf92..2a0d8e939 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -1089,7 +1089,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle } SrsSource* s = NULL; - if ((err = SrsSource::fetch_or_create(r, server, &s)) != srs_success) { + if ((err = _srs_sources->fetch_or_create(r, server, &s)) != srs_success) { return srs_error_wrap(err, "source create"); } srs_assert(s != NULL); diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index f846df0dc..5ffe4b0cd 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -496,7 +496,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle() // find a source to serve. SrsSource* source = NULL; - if ((err = SrsSource::fetch_or_create(req, server, &source)) != srs_success) { + if ((err = _srs_sources->fetch_or_create(req, server, &source)) != srs_success) { return srs_error_wrap(err, "rtmp: fetch source"); } srs_assert(source != NULL); diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 8c6d21470..2a3039f1a 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -523,7 +523,7 @@ void SrsServer::dispose() // @remark don't dispose ingesters, for too slow. // dispose the source for hls and dvr. - SrsSource::dispose_all(); + _srs_sources->dispose(); // @remark don't dispose all connections, for too slow. @@ -952,7 +952,7 @@ srs_error_t SrsServer::do_cycle() } // notice the stream sources to cycle. - if ((err = SrsSource::cycle_all()) != srs_success) { + if ((err = _srs_sources->cycle()) != srs_success) { return srs_error_wrap(err, "source cycle"); } diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 39e704226..f48528015 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1635,9 +1635,17 @@ srs_error_t SrsMetaCache::update_vsh(SrsSharedPtrMessage* msg) return vformat->on_video(msg); } -std::map SrsSource::pool; +SrsSourceManager* _srs_sources = new SrsSourceManager(); -srs_error_t SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps) +SrsSourceManager::SrsSourceManager() +{ +} + +SrsSourceManager::~SrsSourceManager() +{ +} + +srs_error_t SrsSourceManager::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps) { srs_error_t err = srs_success; @@ -1665,7 +1673,7 @@ srs_error_t SrsSource::fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsS return err; } -SrsSource* SrsSource::fetch(SrsRequest* r) +SrsSource* SrsSourceManager::fetch(SrsRequest* r) { SrsSource* source = NULL; @@ -1679,12 +1687,12 @@ SrsSource* SrsSource::fetch(SrsRequest* r) // we always update the request of resource, // for origin auth is on, the token in request maybe invalid, // and we only need to update the token of request, it's simple. - source->req->update_auth(r); + source->update_auth(r); return source; } -void SrsSource::dispose_all() +void SrsSourceManager::dispose() { std::map::iterator it; for (it = pool.begin(); it != pool.end(); ++it) { @@ -1694,16 +1702,16 @@ void SrsSource::dispose_all() return; } -srs_error_t SrsSource::cycle_all() +srs_error_t SrsSourceManager::cycle() { int cid = _srs_context->get_id(); - srs_error_t err = do_cycle_all(); + srs_error_t err = do_cycle(); _srs_context->set_id(cid); return err; } -srs_error_t SrsSource::do_cycle_all() +srs_error_t SrsSourceManager::do_cycle() { srs_error_t err = srs_success; @@ -1744,7 +1752,7 @@ srs_error_t SrsSource::do_cycle_all() return err; } -void SrsSource::destroy() +void SrsSourceManager::destroy() { std::map::iterator it; for (it = pool.begin(); it != pool.end(); ++it) { @@ -1994,6 +2002,11 @@ bool SrsSource::inactive() return _can_publish; } +void SrsSource::update_auth(SrsRequest* r) +{ + req->update_auth(r); +} + bool SrsSource::can_publish(bool is_edge) { if (is_edge) { diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index 847857f33..b0696346e 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -438,32 +438,43 @@ public: virtual srs_error_t update_vsh(SrsSharedPtrMessage* msg); }; -// live streaming source. -class SrsSource : public ISrsReloadHandler +// The source manager to create and refresh all stream sources. +class SrsSourceManager { - friend class SrsOriginHub; private: - static std::map pool; + std::map pool; +public: + SrsSourceManager(); + virtual ~SrsSourceManager(); public: // create source when fetch from cache failed. // @param r the client request. // @param h the event handler for source. // @param pps the matched source, if success never be NULL. - static srs_error_t fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps); + virtual srs_error_t fetch_or_create(SrsRequest* r, ISrsSourceHandler* h, SrsSource** pps); private: // Get the exists source, NULL when not exists. // update the request and return the exists source. - static SrsSource* fetch(SrsRequest* r); + virtual SrsSource* fetch(SrsRequest* r); public: // dispose and cycle all sources. - static void dispose_all(); - static srs_error_t cycle_all(); + virtual void dispose(); + virtual srs_error_t cycle(); private: - static srs_error_t do_cycle_all(); + virtual srs_error_t do_cycle(); public: // when system exit, destroy the sources, // For gmc to analysis mem leaks. - static void destroy(); + virtual void destroy(); +}; + +// Global singleton instance. +extern SrsSourceManager* _srs_sources; + +// live streaming source. +class SrsSource : public ISrsReloadHandler +{ + friend class SrsOriginHub; private: // For publish, it's the publish client id. // For edge, it's the edge ingest id. @@ -531,6 +542,8 @@ public: // Whether source is inactive, which means there is no publishing stream source. // @remark For edge, it's inactive util stream has been pulled from origin. virtual bool inactive(); + // Update the authentication information in request. + virtual void update_auth(SrsRequest* r); public: virtual bool can_publish(bool is_edge); virtual srs_error_t on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata); diff --git a/trunk/src/app/srs_app_utility.cpp b/trunk/src/app/srs_app_utility.cpp index 2dc149ddc..04ece7184 100644 --- a/trunk/src/app/srs_app_utility.cpp +++ b/trunk/src/app/srs_app_utility.cpp @@ -31,9 +31,6 @@ #include #include -#ifdef SRS_OSX -#include -#endif #include #include #include @@ -329,7 +326,6 @@ SrsProcSystemStat* srs_get_system_proc_stat() bool get_proc_system_stat(SrsProcSystemStat& r) { -#ifndef SRS_OSX FILE* f = fopen("/proc/stat", "r"); if (f == NULL) { srs_warn("open system cpu stat failed, ignore"); @@ -359,10 +355,7 @@ bool get_proc_system_stat(SrsProcSystemStat& r) } fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.ok = true; return true; @@ -370,7 +363,6 @@ bool get_proc_system_stat(SrsProcSystemStat& r) bool get_proc_self_stat(SrsProcSelfStat& r) { -#ifndef SRS_OSX FILE* f = fopen("/proc/self/stat", "r"); if (f == NULL) { srs_warn("open self cpu stat failed, ignore"); @@ -397,10 +389,7 @@ bool get_proc_self_stat(SrsProcSelfStat& r) &r.guest_time, &r.cguest_time); fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.ok = true; return true; @@ -495,7 +484,6 @@ SrsDiskStat* srs_get_disk_stat() bool srs_get_disk_vmstat_stat(SrsDiskStat& r) { -#ifndef SRS_OSX FILE* f = fopen("/proc/vmstat", "r"); if (f == NULL) { srs_warn("open vmstat failed, ignore"); @@ -515,10 +503,7 @@ bool srs_get_disk_vmstat_stat(SrsDiskStat& r) } fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.ok = true; return true; @@ -535,7 +520,6 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r) return true; } -#ifndef SRS_OSX FILE* f = fopen("/proc/diskstats", "r"); if (f == NULL) { srs_warn("open vmstat failed, ignore"); @@ -600,10 +584,7 @@ bool srs_get_disk_diskstats_stat(SrsDiskStat& r) } fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.ok = true; return true; @@ -695,7 +676,6 @@ void srs_update_meminfo() { SrsMemInfo& r = _srs_system_meminfo; -#ifndef SRS_OSX FILE* f = fopen("/proc/meminfo", "r"); if (f == NULL) { srs_warn("open meminfo failed, ignore"); @@ -721,10 +701,7 @@ void srs_update_meminfo() } fclose(f); -#else - // TODO: FIXME: impelments it. -#endif - + r.sample_time = srsu2ms(srs_get_system_time()); r.MemActive = r.MemTotal - r.MemFree; r.RealInUse = r.MemActive - r.Buffers - r.Cached; @@ -791,7 +768,6 @@ void srs_update_platform_info() r.srs_startup_time = srsu2ms(srs_get_system_startup_time()); -#ifndef SRS_OSX if (true) { FILE* f = fopen("/proc/uptime", "r"); if (f == NULL) { @@ -820,43 +796,6 @@ void srs_update_platform_info() fclose(f); } -#else - // man 3 sysctl - if (true) { - struct timeval tv; - size_t len = sizeof(timeval); - - int mib[2]; - mib[0] = CTL_KERN; - mib[1] = KERN_BOOTTIME; - if (sysctl(mib, 2, &tv, &len, NULL, 0) < 0) { - srs_warn("sysctl boottime failed, ignore"); - return; - } - - time_t bsec = tv.tv_sec; - time_t csec = ::time(NULL); - r.os_uptime = difftime(csec, bsec); - } - - // man 3 sysctl - if (true) { - struct loadavg la; - size_t len = sizeof(loadavg); - - int mib[2]; - mib[0] = CTL_VM; - mib[1] = VM_LOADAVG; - if (sysctl(mib, 2, &la, &len, NULL, 0) < 0) { - srs_warn("sysctl loadavg failed, ignore"); - return; - } - - r.load_one_minutes = (double)la.ldavg[0] / la.fscale; - r.load_five_minutes = (double)la.ldavg[1] / la.fscale; - r.load_fifteen_minutes = (double)la.ldavg[2] / la.fscale; - } -#endif r.ok = true; } @@ -903,7 +842,6 @@ int srs_get_network_devices_count() void srs_update_network_devices() { -#ifndef SRS_OSX if (true) { FILE* f = fopen("/proc/net/dev", "r"); if (f == NULL) { @@ -940,9 +878,6 @@ void srs_update_network_devices() fclose(f); } -#else - // TODO: FIXME: impelments it. -#endif } SrsNetworkRtmpServer::SrsNetworkRtmpServer() @@ -990,7 +925,6 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) int nb_tcp_mem = 0; int nb_udp4 = 0; -#ifndef SRS_OSX if (true) { FILE* f = fopen("/proc/net/sockstat", "r"); if (f == NULL) { @@ -1020,20 +954,9 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) fclose(f); } -#else - // TODO: FIXME: impelments it. - nb_socks = 0; - nb_tcp4_hashed = 0; - nb_tcp_orphans = 0; - nb_tcp_tws = 0; - nb_tcp_total = 0; - nb_tcp_mem = 0; - nb_udp4 = 0; -#endif int nb_tcp_estab = 0; -#ifndef SRS_OSX if (true) { FILE* f = fopen("/proc/net/snmp", "r"); if (f == NULL) { @@ -1063,10 +986,7 @@ void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps) fclose(f); } -#else - // TODO: FIXME: impelments it. -#endif - + // @see: https://github.com/shemminger/iproute2/blob/master/misc/ss.c // TODO: FIXME: ignore the slabstat, @see: get_slabstat() if (true) { diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 283e34e95..732f4b120 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 100 +#define VERSION_REVISION 105 // The macros generated by configure script. #include diff --git a/trunk/src/kernel/srs_kernel_codec.cpp b/trunk/src/kernel/srs_kernel_codec.cpp index a0b11f424..2f6c14bff 100644 --- a/trunk/src/kernel/srs_kernel_codec.cpp +++ b/trunk/src/kernel/srs_kernel_codec.cpp @@ -43,6 +43,8 @@ string srs_video_codec_id2str(SrsVideoCodecId codec) return "VP6"; case SrsVideoCodecIdHEVC: return "HEVC"; + case SrsVideoCodecIdAV1: + return "AV1"; case SrsVideoCodecIdReserved: case SrsVideoCodecIdReserved1: case SrsVideoCodecIdReserved2: @@ -650,7 +652,10 @@ bool SrsFormat::is_aac_sequence_header() bool SrsFormat::is_avc_sequence_header() { - return vcodec && (vcodec->id == SrsVideoCodecIdAVC || vcodec->id == SrsVideoCodecIdHEVC) + bool h264 = (vcodec && vcodec->id == SrsVideoCodecIdAVC); + bool h265 = (vcodec && vcodec->id == SrsVideoCodecIdHEVC); + bool av1 = (vcodec && vcodec->id == SrsVideoCodecIdAV1); + return vcodec && (h264 || h265 || av1) && video && video->avc_packet_type == SrsVideoAvcFrameTraitSequenceHeader; } diff --git a/trunk/src/kernel/srs_kernel_codec.hpp b/trunk/src/kernel/srs_kernel_codec.hpp index e25442edc..2f8d436b6 100644 --- a/trunk/src/kernel/srs_kernel_codec.hpp +++ b/trunk/src/kernel/srs_kernel_codec.hpp @@ -62,6 +62,8 @@ enum SrsVideoCodecId SrsVideoCodecIdAVC = 7, // See page 79 at @doc https://github.com/CDN-Union/H265/blob/master/Document/video_file_format_spec_v10_1_ksyun_20170615.doc SrsVideoCodecIdHEVC = 12, + // https://mp.weixin.qq.com/s/H3qI7zsON5sdf4oDJ9qlkg + SrsVideoCodecIdAV1 = 13, }; std::string srs_video_codec_id2str(SrsVideoCodecId codec); diff --git a/trunk/src/kernel/srs_kernel_flv.cpp b/trunk/src/kernel/srs_kernel_flv.cpp index e897e1b38..63238b4c6 100644 --- a/trunk/src/kernel/srs_kernel_flv.cpp +++ b/trunk/src/kernel/srs_kernel_flv.cpp @@ -291,7 +291,7 @@ bool SrsSharedPtrMessage::check(int stream_id) // we donot use the complex basic header, // ensure the basic header is 1bytes. - if (ptr->header.perfer_cid < 2) { + if (ptr->header.perfer_cid < 2 || ptr->header.perfer_cid > 63) { srs_info("change the chunk_id=%d to default=%d", ptr->header.perfer_cid, RTMP_CID_ProtocolControl); ptr->header.perfer_cid = RTMP_CID_ProtocolControl; } diff --git a/trunk/src/kernel/srs_kernel_ts.cpp b/trunk/src/kernel/srs_kernel_ts.cpp index 1c3b92edf..27d40315c 100644 --- a/trunk/src/kernel/srs_kernel_ts.cpp +++ b/trunk/src/kernel/srs_kernel_ts.cpp @@ -313,6 +313,7 @@ srs_error_t SrsTsContext::encode(ISrsStreamWriter* writer, SrsTsMessage* msg, Sr case SrsVideoCodecIdOn2VP6WithAlphaChannel: case SrsVideoCodecIdScreenVideoVersion2: case SrsVideoCodecIdHEVC: + case SrsVideoCodecIdAV1: vs = SrsTsStreamReserved; break; } diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index ee49069f4..a2f9728e0 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -1666,7 +1666,7 @@ int srs_mp4_to_flv_tag(srs_mp4_t mp4, srs_mp4_sample_t* s, char* type, uint32_t* // E.4.3.1 VIDEODATA, flv_v10_1.pdf, page 5 p.write_1bytes(uint8_t(s->frame_type<<4) | uint8_t(s->codec)); - if (s->codec == SrsVideoCodecIdAVC || s->codec == SrsVideoCodecIdHEVC) { + if (s->codec == SrsVideoCodecIdAVC || s->codec == SrsVideoCodecIdHEVC || s->codec == SrsVideoCodecIdAV1) { *type = SRS_RTMP_TYPE_VIDEO; p.write_1bytes(uint8_t(s->frame_trait == (uint16_t)SrsVideoAvcFrameTraitSequenceHeader? 0:1)); diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 3bfd9ebb1..25cfbaf30 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -119,7 +119,7 @@ srs_error_t do_main(int argc, char** argv) // config already applied to log. srs_trace("%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE); - srs_trace("contributors: " SRS_AUTO_CONSTRIBUTORS); + srs_trace("contributors: %s", SRS_AUTO_CONSTRIBUTORS); srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s", _srs_config->cwd().c_str(), cwd.c_str(), SRS_AUTO_BUILD_DATE, SRS_AUTO_USER_CONFIGURE, SRS_AUTO_UNAME); srs_trace("configure detail: " SRS_AUTO_CONFIGURE); @@ -236,16 +236,6 @@ void show_macro_features() if (true) { stringstream ss; ss << "SRS on "; -#ifdef SRS_OSX - ss << "OSX"; -#endif -#ifdef SRS_PI - ss << "RespberryPi"; -#endif -#ifdef SRS_CUBIE - ss << "CubieBoard"; -#endif - #if defined(__amd64__) ss << " amd64"; #endif @@ -258,9 +248,11 @@ void show_macro_features() #if defined(__arm__) ss << "arm"; #endif - -#ifndef SRS_OSX - ss << ", glibc" << (int)__GLIBC__ << "." << (int)__GLIBC_MINOR__; +#if defined(__aarch64__) + ss << " aarch64"; +#endif +#if defined(SRS_AUTO_CROSSBUILD) + ss << "(crossbuild)"; #endif ss << ", conf:" << _srs_config->config() << ", limit:" << _srs_config->get_max_connections() diff --git a/trunk/src/service/srs_service_st.cpp b/trunk/src/service/srs_service_st.cpp index 6cd04ba93..d8d9c3892 100644 --- a/trunk/src/service/srs_service_st.cpp +++ b/trunk/src/service/srs_service_st.cpp @@ -115,7 +115,12 @@ srs_error_t srs_fd_reuseport(int fd) #if defined(SO_REUSEPORT) int v = 1; if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &v, sizeof(int)) == -1) { - return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEPORT fd=%v", fd); + #ifdef SRS_AUTO_CROSSBUILD + srs_warn("SO_REUSEPORT disabled for crossbuild"); + return srs_success; + #else + return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEPORT fd=%v", fd); + #endif } #else #warning "SO_REUSEPORT is not supported by your OS" diff --git a/trunk/src/utest/srs_utest.cpp b/trunk/src/utest/srs_utest.cpp index 74b702167..19f3d8499 100644 --- a/trunk/src/utest/srs_utest.cpp +++ b/trunk/src/utest/srs_utest.cpp @@ -46,23 +46,18 @@ ISrsThreadContext* _srs_context = new ISrsThreadContext(); SrsConfig* _srs_config = NULL; SrsServer* _srs_server = NULL; -// Disable coroutine test for OSX. -#if !defined(SRS_OSX) #include -#endif // Initialize global settings. srs_error_t prepare_main() { srs_error_t err = srs_success; - #if !defined(SRS_OSX) if ((err = srs_st_init()) != srs_success) { return srs_error_wrap(err, "init st"); } srs_freep(_srs_context); _srs_context = new SrsThreadContext(); - #endif return err; } diff --git a/trunk/src/utest/srs_utest_app.cpp b/trunk/src/utest/srs_utest_app.cpp index 344cc0f43..5d158d5d6 100644 --- a/trunk/src/utest/srs_utest_app.cpp +++ b/trunk/src/utest/srs_utest_app.cpp @@ -27,9 +27,6 @@ using namespace std; #include #include -// Disable coroutine test for OSX. -#if !defined(SRS_OSX) - #include VOID TEST(AppCoroutineTest, Dummy) @@ -375,5 +372,3 @@ VOID TEST(AppFragmentTest, CheckDuration) } } -#endif - diff --git a/trunk/src/utest/srs_utest_kernel.cpp b/trunk/src/utest/srs_utest_kernel.cpp index c80e8fc58..5a113da84 100644 --- a/trunk/src/utest/srs_utest_kernel.cpp +++ b/trunk/src/utest/srs_utest_kernel.cpp @@ -3028,6 +3028,7 @@ VOID TEST(KernelCodecTest, CoverAll) EXPECT_TRUE("H264" == srs_video_codec_id2str(SrsVideoCodecIdAVC)); EXPECT_TRUE("VP6" == srs_video_codec_id2str(SrsVideoCodecIdOn2VP6)); EXPECT_TRUE("HEVC" == srs_video_codec_id2str(SrsVideoCodecIdHEVC)); + EXPECT_TRUE("AV1" == srs_video_codec_id2str(SrsVideoCodecIdAV1)); EXPECT_TRUE("Other" == srs_video_codec_id2str(SrsVideoCodecIdScreenVideo)); } @@ -3293,6 +3294,9 @@ VOID TEST(KernelCodecTest, IsSequenceHeaderSpecial) f.vcodec->id = SrsVideoCodecIdHEVC; EXPECT_FALSE(f.is_avc_sequence_header()); + f.vcodec->id = SrsVideoCodecIdAV1; + EXPECT_FALSE(f.is_avc_sequence_header()); + f.video->avc_packet_type = SrsVideoAvcFrameTraitSequenceHeader; EXPECT_TRUE(f.is_avc_sequence_header()); } @@ -4647,7 +4651,10 @@ VOID TEST(KernelTSTest, CoverContextEncode) err = ctx.encode(&f, &m, SrsVideoCodecIdHEVC, SrsAudioCodecIdOpus); HELPER_EXPECT_FAILED(err); - + + err = ctx.encode(&f, &m, SrsVideoCodecIdAV1, SrsAudioCodecIdOpus); + HELPER_EXPECT_FAILED(err); + err = ctx.encode_pat_pmt(&f, 0, SrsTsStreamReserved, 0, SrsTsStreamReserved); HELPER_EXPECT_FAILED(err); }