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 d66e35146..b0cf323d5 100755 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [![](https://codecov.io/gh/ossrs/srs/branch/3.0release/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/3.0release) [![](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]. @@ -116,6 +116,7 @@ For previous versions, please read: - [x] Support origin cluster, please read [#464][bug #464], [RTMP 302][bug #92]. - [x] Support listen at IPv4 and IPv6, read [#460][bug #460]. - [x] Support SO_REUSEPORT, to improve edge server performance, read [#775][bug #775]. +- [x] Improve test coverage for core/kernel/protocol/service. - [x] [Experimental] Support docker by [srs-docker](https://github.com/ossrs/srs-docker). - [x] [Experimental] Support DVR in MP4 format, read [#738][bug #738]. - [x] [Experimental] Support MPEG-DASH, the future live streaming protocol, read [#299][bug #299]. @@ -129,7 +130,6 @@ For previous versions, please read: - [x] [Deprecated] Support Adobe HDS(f4m), please read wiki([CN][v2_CN_DeliveryHDS], [EN][v2_EN_DeliveryHDS]) and [#1535][bug #1535]. - [x] [Deprecated] Support bandwidth testing([CN][v1_CN_BandwidthTestTool], [EN][v1_EN_BandwidthTestTool]), please read [#1535][bug #1535]. - [x] [Deprecated] Support Adobe FMS/AMS token traverse([CN][v3_CN_DRM2], [EN][v3_EN_DRM2]) authentication, please read [#1535][bug #1535]. -- [ ] Utest cover almost all kernel code. - [ ] Enhanced forwarding with vhost and variables. - [ ] Support source cleanup for idle streams. - [ ] Support H.265 by pushing H.265 over RTMP, deliverying in HLS, read [#465][bug #465]. @@ -146,6 +146,16 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-01-25, Fix [#1108][bug #1108], reap DVR tmp file when unpublish. 3.0.106 +* 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 * v3.0, 2020-01-10, [3.0 alpha8(3.0.97)][r3.0a8] released. 121555 lines. * v3.0, 2020-01-09, For [#1042][bug #1042], improve test coverage for service. 3.0.97 * v3.0, 2020-01-08, Merge [#1554][bug #1554], support logrotate copytruncate. 3.0.96 @@ -275,6 +285,7 @@ For previous versions, please read: ## V2 changes +* v2.0, 2020-01-25, [2.0 release8(2.0.272)][r2.0r8] released. 87292 lines. * v2.0, 2020-01-08, Merge [#1554][bug #1554], support logrotate copytruncate. 2.0.272 * v2.0, 2020-01-05, Merge [#1551][bug #1551], fix memory leak in RTSP stack. 2.0.270 * v2.0, 2019-12-26, For [#1488][bug #1488], pass client ip to http callback. 2.0.269 @@ -712,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. @@ -1592,10 +1604,19 @@ Winlin [bug #1544]: https://github.com/ossrs/srs/issues/1544 [bug #1255]: https://github.com/ossrs/srs/issues/1255 [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 #1108]: https://github.com/ossrs/srs/issues/1108 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [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 @@ -1605,6 +1626,7 @@ Winlin [r3.0a2]: https://github.com/ossrs/srs/releases/tag/v3.0-a2 [r3.0a1]: https://github.com/ossrs/srs/releases/tag/v3.0-a1 [r3.0a0]: https://github.com/ossrs/srs/releases/tag/v3.0-a0 +[r2.0r8]: https://github.com/ossrs/srs/releases/tag/v2.0-r8 [r2.0r7]: https://github.com/ossrs/srs/releases/tag/v2.0-r7 [r2.0r6]: https://github.com/ossrs/srs/releases/tag/v2.0-r6 [r2.0r5]: https://github.com/ossrs/srs/releases/tag/v2.0-r5 diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 96f5526d3..b4c04545c 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 @@ -141,6 +138,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 a46685e6f..7c5a69780 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -55,8 +55,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 @@ -78,7 +76,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 @@ -99,8 +96,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 @@ -157,63 +160,59 @@ Options: --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. -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. +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). -Toolchain options: - --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Pass to ST as EXTRA_CFLAGS. + --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. -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. - --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. both ubuntu12 and ubuntu14 are ok for SRS. - 2. the centos5, centos6 and centos7 are ok for SRS. - 3. all linux and unix-like os are ok for SRS. - 4. windows is absolutely impossible for SRS. + 1. For performance improving, read https://blog.csdn.net/win_lin/article/details/53503869 END } @@ -243,15 +242,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 ;; @@ -266,20 +260,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 ;; @@ -294,6 +294,7 @@ function parse_user_option() { --memory-watch) SRS_MEM_WATCH=YES ;; --export-librtmp-project) SRS_EXPORT_LIBRTMP_PROJECT=${value} ;; --export-librtmp-single) SRS_EXPORT_LIBRTMP_SINGLE=${value} ;; + --with-valgrind) SRS_VALGRIND=YES ;; --without-valgrind) SRS_VALGRIND=NO ;; --with-http-callback) SRS_HTTP_CALLBACK=YES ;; @@ -301,11 +302,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\"" @@ -318,7 +327,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 @@ -350,7 +359,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 @@ -400,18 +409,6 @@ function apply_user_presets() { SRS_STATIC=NO fi - # for osx(darwin) - if [ $SRS_OSX = YES ]; then - SRS_HDS=YES - SRS_LIBRTMP=YES - SRS_RESEARCH=NO - SRS_UTEST=YES - SRS_STATIC=NO - # valgrind is not supported by macOS sierra, read - # https://stackoverflow.com/questions/40650338/valgrind-on-macos-sierra - SRS_VALGRIND=NO - fi - # if dev specified, open features if possible. if [ $SRS_DEV = YES ]; then SRS_HDS=YES @@ -456,6 +453,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 @@ -553,7 +558,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}" } @@ -563,24 +573,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. @@ -626,15 +636,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/summary.sh b/trunk/auto/summary.sh index f19a27722..0af1673b1 100755 --- a/trunk/auto/summary.sh +++ b/trunk/auto/summary.sh @@ -43,16 +43,13 @@ echo -e " \${BLACK}+-------------------------------------------------------- echo -e " |\${GREEN}The main server usage: ./objs/srs -c conf/srs.conf, start the srs server\${BLACK}" echo -e " | ${SrsHlsSummaryColor}About HLS, please read https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS\${BLACK}" echo -e " | ${SrsDvrSummaryColor}About DVR, please read https://github.com/ossrs/srs/wiki/v3_CN_DVR\${BLACK}" -echo -e " | ${SrsNginxSummaryColor}About NGINX, please read https://github.com/ossrs/srs/wiki/v2_CN_DeliveryHLS\${BLACK}" echo -e " | ${SrsSslSummaryColor}About SSL, please read https://github.com/ossrs/srs/wiki/v1_CN_RTMPHandshake\${BLACK}" -echo -e " | ${SrsFfmpegSummaryColor}About FFMPEG, please read https://github.com/ossrs/srs/wiki/v3_CN_FFMPEG\${BLACK}" echo -e " | ${SrsTranscodeSummaryColor}About transcoding, please read https://github.com/ossrs/srs/wiki/v3_CN_FFMPEG\${BLACK}" echo -e " | ${SrsIngestSummaryColor}About ingester, please read https://github.com/ossrs/srs/wiki/v1_CN_Ingest\${BLACK}" echo -e " | ${SrsHttpCallbackSummaryColor}About http-callback, please read https://github.com/ossrs/srs/wiki/v3_CN_HTTPCallback\${BLACK}" -echo -e " | ${SrsHttpServerSummaryColor}Aoubt embeded http-server, please read https://github.com/ossrs/srs/wiki/v2_CN_HTTPServer\${BLACK}" +echo -e " | ${SrsHttpServerSummaryColor}Aoubt http-server, please read https://github.com/ossrs/srs/wiki/v2_CN_HTTPServer\${BLACK}" echo -e " | ${SrsHttpApiSummaryColor}About http-api, please read https://github.com/ossrs/srs/wiki/v3_CN_HTTPApi\${BLACK}" echo -e " | ${SrsStreamCasterSummaryColor}About stream-caster, please read https://github.com/ossrs/srs/wiki/v2_CN_Streamer\${BLACK}" -echo -e " | ${SrsKafkaSummaryColor}About kafka, please read https://github.com/ossrs/srs/wiki/v3_CN_Kafka\${BLACK}" echo -e " | ${SrsValgrindSummaryColor}About VALGRIND, please read https://github.com/ossrs/state-threads/issues/2\${BLACK}" echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}" echo -e "\${GREEN}binaries, please read https://github.com/ossrs/srs/wiki/v2_CN_Build\${BLACK}" diff --git a/trunk/auto/utest.sh b/trunk/auto/utest.sh index ab96caea2..cb1a877c9 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/conf/dash.conf b/trunk/conf/dash.conf new file mode 100644 index 000000000..9d7f21fdd --- /dev/null +++ b/trunk/conf/dash.conf @@ -0,0 +1,23 @@ +# the config for srs to delivery dash +# @see https://github.com/ossrs/srs/wiki/v1_CN_SampleDASH +# @see full.conf for detail config. + +listen 1935; +max_connections 1000; +daemon off; +srs_log_tank console; +http_server { + enabled on; + listen 8080; + dir ./objs/nginx/html; +} +vhost __defaultVhost__ { + dash { + enabled on; + dash_fragment 30; + dash_update_period 150; + dash_timeshift 300; + dash_path ./objs/nginx/html; + dash_mpd_file [app]/[stream].mpd; + } +} diff --git a/trunk/conf/hls.conf b/trunk/conf/hls.conf index d0fa42397..17416a294 100644 --- a/trunk/conf/hls.conf +++ b/trunk/conf/hls.conf @@ -6,6 +6,11 @@ listen 1935; max_connections 1000; daemon off; srs_log_tank console; +http_server { + enabled on; + listen 8080; + dir ./objs/nginx/html; +} vhost __defaultVhost__ { hls { enabled on; diff --git a/trunk/configure b/trunk/configure index 5b8cd4b0f..98b340db2 100755 --- a/trunk/configure +++ b/trunk/configure @@ -122,16 +122,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 @@ -608,7 +608,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_config.cpp b/trunk/src/app/srs_app_config.cpp index 2987b4891..0fa544fab 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -6814,22 +6814,22 @@ string SrsConfig::get_vhost_http_dir(string vhost) bool SrsConfig::get_vhost_http_remux_enabled(string vhost) { static bool DEFAULT = false; - + SrsConfDirective* conf = get_vhost(vhost); if (!conf) { return DEFAULT; } - + conf = conf->get("http_remux"); if (!conf) { return DEFAULT; } - + conf = conf->get("enabled"); if (!conf || conf->arg0().empty()) { return DEFAULT; } - + return SRS_CONF_PERFER_FALSE(conf->arg0()); } diff --git a/trunk/src/app/srs_app_dvr.cpp b/trunk/src/app/srs_app_dvr.cpp index d29d22a23..aca14581a 100644 --- a/trunk/src/app/srs_app_dvr.cpp +++ b/trunk/src/app/srs_app_dvr.cpp @@ -609,13 +609,25 @@ srs_error_t SrsDvrPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsReque return srs_error_wrap(err, "segmenter"); } + return err; +} + +srs_error_t SrsDvrPlan::on_publish() +{ + srs_error_t err = srs_success; + if ((err = async->start()) != srs_success) { return srs_error_wrap(err, "async"); } - + return err; } +void SrsDvrPlan::on_unpublish() +{ + async->stop(); +} + srs_error_t SrsDvrPlan::on_meta_data(SrsSharedPtrMessage* shared_metadata) { srs_error_t err = srs_success; @@ -699,6 +711,10 @@ SrsDvrSessionPlan::~SrsDvrSessionPlan() srs_error_t SrsDvrSessionPlan::on_publish() { srs_error_t err = srs_success; + + if ((err = SrsDvrPlan::on_publish()) != srs_success) { + return err; + } // support multiple publish. if (dvr_enabled) { @@ -724,6 +740,8 @@ srs_error_t SrsDvrSessionPlan::on_publish() void SrsDvrSessionPlan::on_unpublish() { + SrsDvrPlan::on_unpublish(); + // support multiple publish. if (!dvr_enabled) { return; @@ -766,6 +784,10 @@ srs_error_t SrsDvrSegmentPlan::initialize(SrsOriginHub* h, SrsDvrSegmenter* s, S srs_error_t SrsDvrSegmentPlan::on_publish() { srs_error_t err = srs_success; + + if ((err = SrsDvrPlan::on_publish()) != srs_success) { + return err; + } // support multiple publish. if (dvr_enabled) { @@ -791,6 +813,16 @@ srs_error_t SrsDvrSegmentPlan::on_publish() void SrsDvrSegmentPlan::on_unpublish() { + srs_error_t err = srs_success; + + SrsDvrPlan::on_unpublish(); + + if ((err = segment->close()) != srs_success) { + srs_warn("ignore err %s", srs_error_desc(err).c_str()); + srs_freep(err); + } + + dvr_enabled = false; } srs_error_t SrsDvrSegmentPlan::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format) diff --git a/trunk/src/app/srs_app_dvr.hpp b/trunk/src/app/srs_app_dvr.hpp index 62ea1cb1e..716d45e0e 100644 --- a/trunk/src/app/srs_app_dvr.hpp +++ b/trunk/src/app/srs_app_dvr.hpp @@ -185,8 +185,8 @@ public: virtual ~SrsDvrPlan(); public: virtual srs_error_t initialize(SrsOriginHub* h, SrsDvrSegmenter* s, SrsRequest* r); - virtual srs_error_t on_publish() = 0; - virtual void on_unpublish() = 0; + virtual srs_error_t on_publish(); + virtual void on_unpublish(); virtual srs_error_t on_meta_data(SrsSharedPtrMessage* shared_metadata); virtual srs_error_t on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format); virtual srs_error_t on_video(SrsSharedPtrMessage* shared_video, SrsFormat* format); diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp index 8d9d116a8..8a0592dcf 100644 --- a/trunk/src/app/srs_app_edge.cpp +++ b/trunk/src/app/srs_app_edge.cpp @@ -416,9 +416,14 @@ srs_error_t SrsEdgeIngester::process_publish_message(SrsCommonMessage* msg, stri return err; } SrsAmf0Object* ex = prop->to_object(); - - if ((prop = ex->ensure_property_string("redirect")) == NULL) { - return err; + + // The redirect is tcUrl while redirect2 is RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798 + if ((prop = ex->ensure_property_string("redirect2")) == NULL) { + // TODO: FIXME: Remove it when SRS3 released, it's temporarily support for SRS3 alpha versions(a0 to a8). + if ((prop = ex->ensure_property_string("redirect")) == NULL) { + return err; + } } redirect = prop->to_str(); diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 0f18f74a5..72ec535ca 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -268,16 +268,27 @@ int SrsHlsMuxer::deviation() } srs_error_t SrsHlsMuxer::initialize() +{ + return srs_success; +} + +srs_error_t SrsHlsMuxer::on_publish(SrsRequest* req) { srs_error_t err = srs_success; - + if ((err = async->start()) != srs_success) { return srs_error_wrap(err, "async start"); } - + return err; } +srs_error_t SrsHlsMuxer::on_unpublish() +{ + async->stop(); + return srs_success; +} + srs_error_t SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, string path, string m3u8_file, string ts_file, srs_utime_t fragment, srs_utime_t window, bool ts_floor, double aof_ratio, bool cleanup, bool wait_keyframe, bool keys, @@ -899,8 +910,11 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req) // TODO: FIXME: support load exists m3u8, to continue publish stream. // for the HLS donot requires the EXT-X-MEDIA-SEQUENCE be monotonically increase. + + if ((err = muxer->on_publish(req)) != srs_success) { + return srs_error_wrap(err, "muxer publish"); + } - // open muxer if ((err = muxer->update_config(req, entry_prefix, path, m3u8_file, ts_file, hls_fragment, hls_window, ts_floor, hls_aof_ratio, cleanup, wait_keyframe,hls_keys,hls_fragments_per_key, hls_key_file, hls_key_file_path, hls_key_url)) != srs_success ) { @@ -924,6 +938,10 @@ srs_error_t SrsHlsController::on_publish(SrsRequest* req) srs_error_t SrsHlsController::on_unpublish() { srs_error_t err = srs_success; + + if ((err = muxer->on_unpublish()) != srs_success) { + return srs_error_wrap(err, "muxer unpublish"); + } if ((err = muxer->flush_audio(tsmc)) != srs_success) { return srs_error_wrap(err, "hls: flush audio"); diff --git a/trunk/src/app/srs_app_hls.hpp b/trunk/src/app/srs_app_hls.hpp index 194c183fb..1dd72eba5 100644 --- a/trunk/src/app/srs_app_hls.hpp +++ b/trunk/src/app/srs_app_hls.hpp @@ -185,6 +185,9 @@ public: public: // Initialize the hls muxer. virtual srs_error_t initialize(); + // When publish or unpublish stream. + virtual srs_error_t on_publish(SrsRequest* req); + virtual srs_error_t on_unpublish(); // When publish, update the config for muxer. virtual srs_error_t update_config(SrsRequest* r, std::string entry_prefix, std::string path, std::string m3u8_file, std::string ts_file, diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index 21d84be59..2a0d8e939 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -1023,7 +1023,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle if (it == tflvs.end()) { return err; } - + // hstrs always enabled. // for origin, the http stream will be mount already when publish, // so it must never enter this line for stream already mounted. @@ -1064,7 +1064,7 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle if (srs_string_count(upath, "/") != srs_string_count(entry->mount, "/")) { return err; } - + // convert to concreate class. SrsHttpMessage* hreq = dynamic_cast(request); srs_assert(hreq); @@ -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); @@ -1127,7 +1127,7 @@ srs_error_t SrsHttpStreamServer::initialize_flv_streaming() if (!conf->is_vhost()) { continue; } - + if ((err = initialize_flv_entry(conf->arg0())) != srs_success) { return srs_error_wrap(err, "init flv entries"); } @@ -1139,7 +1139,7 @@ srs_error_t SrsHttpStreamServer::initialize_flv_streaming() srs_error_t SrsHttpStreamServer::initialize_flv_entry(std::string vhost) { srs_error_t err = srs_success; - + if (!_srs_config->get_vhost_http_remux_enabled(vhost)) { return err; } diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 6ed6ca712..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); @@ -621,8 +621,10 @@ srs_error_t SrsRtmpConn::playing(SrsSource* source) } return srs_error_wrap(err, "discover coworkers, url=%s", url.c_str()); } - srs_trace("rtmp: redirect in cluster, from=%s:%d, target=%s:%d, url=%s", - req->host.c_str(), req->port, host.c_str(), port, url.c_str()); + + string rurl = srs_generate_rtmp_url(host, port, req->host, req->vhost, req->app, req->stream, req->param); + srs_trace("rtmp: redirect in cluster, from=%s:%d, target=%s:%d, url=%s, rurl=%s", + req->host.c_str(), req->port, host.c_str(), port, url.c_str(), rurl.c_str()); // Ignore if host or port is invalid. if (host.empty() || port == 0) { @@ -630,7 +632,7 @@ srs_error_t SrsRtmpConn::playing(SrsSource* source) } bool accepted = false; - if ((err = rtmp->redirect(req, host, port, accepted)) != srs_success) { + if ((err = rtmp->redirect(req, rurl, accepted)) != srs_success) { srs_error_reset(err); } else { return srs_error_new(ERROR_CONTROL_REDIRECT, "redirected"); diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index c85930da3..85666ce2d 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. @@ -957,7 +957,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 788773c80..f48528015 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -154,7 +154,7 @@ int64_t SrsRtmpJitter::get_time() SrsFastVector::SrsFastVector() { count = 0; - nb_msgs = SRS_PERF_MW_MSGS * 8; + nb_msgs = 8; msgs = new SrsSharedPtrMessage*[nb_msgs]; } @@ -212,12 +212,12 @@ void SrsFastVector::push_back(SrsSharedPtrMessage* msg) { // increase vector. if (count >= nb_msgs) { - int size = nb_msgs * 2; + int size = srs_max(SRS_PERF_MW_MSGS * 8, nb_msgs * 2); SrsSharedPtrMessage** buf = new SrsSharedPtrMessage*[size]; for (int i = 0; i < nb_msgs; i++) { buf[i] = msgs[i]; } - srs_warn("fast vector incrase %d=>%d", nb_msgs, size); + srs_info("fast vector incrase %d=>%d", nb_msgs, size); // use new array. srs_freepa(msgs); @@ -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 5a80e8f8e..2bca91cdf 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 97 +#define VERSION_REVISION 106 // 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 797e0d90a..e0570240e 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); @@ -237,16 +237,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 @@ -259,9 +249,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/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index ae43916ce..bec1ad35c 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -2415,17 +2415,20 @@ srs_error_t SrsRtmpServer::response_connect_app(SrsRequest *req, const char* ser } #define SRS_RTMP_REDIRECT_TIMEOUT (3 * SRS_UTIME_SECONDS) -srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string host, int port, bool& accepted) +srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string url, bool& accepted) { srs_error_t err = srs_success; if (true) { - string url = srs_generate_rtmp_url(host, port, r->host, r->vhost, r->app, r->stream, r->param); - SrsAmf0Object* ex = SrsAmf0Any::object(); ex->set("code", SrsAmf0Any::number(302)); - ex->set("redirect", SrsAmf0Any::str(url.c_str())); - + + // The redirect is tcUrl while redirect2 is RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798 + string tcUrl = srs_path_dirname(url); + ex->set("redirect", SrsAmf0Any::str(tcUrl.c_str())); + ex->set("redirect2", SrsAmf0Any::str(url.c_str())); + SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket(); pkt->data->set(StatusLevel, SrsAmf0Any::str(StatusLevelError)); diff --git a/trunk/src/protocol/srs_rtmp_stack.hpp b/trunk/src/protocol/srs_rtmp_stack.hpp index 82c9bf006..c43c4ee17 100644 --- a/trunk/src/protocol/srs_rtmp_stack.hpp +++ b/trunk/src/protocol/srs_rtmp_stack.hpp @@ -707,9 +707,9 @@ public: // @param server_ip the ip of server. virtual srs_error_t response_connect_app(SrsRequest* req, const char* server_ip = NULL); // Redirect the connection to another rtmp server. - // @param the hostname or ip of target. + // @param a RTMP url to redirect to. // @param whether the client accept the redirect. - virtual srs_error_t redirect(SrsRequest* r, std::string host, int port, bool& accepted); + virtual srs_error_t redirect(SrsRequest* r, std::string url, bool& accepted); // Reject the connect app request. virtual void response_connect_reject(SrsRequest* req, const char* desc); // Response client the onBWDone message. 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); } diff --git a/trunk/src/utest/srs_utest_rtmp.cpp b/trunk/src/utest/srs_utest_rtmp.cpp index 47ec84aa6..7acc3d4c2 100644 --- a/trunk/src/utest/srs_utest_rtmp.cpp +++ b/trunk/src/utest/srs_utest_rtmp.cpp @@ -1751,7 +1751,8 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect) string host = "target.net"; int port = 8888; bool accepted = false; - HELPER_EXPECT_SUCCESS(r.redirect(&req, host, port, accepted)); + string rurl = srs_generate_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param); + HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted)); if (true) { MockBufferIO tio; @@ -1776,6 +1777,14 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect) prop = ex->get_property("redirect"); ASSERT_TRUE(prop && prop->is_string()); + // The recirect is tcUrl, not RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574995475 + EXPECT_STREQ("rtmp://target.net:8888/live", prop->to_str().c_str()); + + prop = ex->get_property("redirect2"); + ASSERT_TRUE(prop && prop->is_string()); + // The recirect2 is RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798 EXPECT_STREQ("rtmp://target.net:8888/live/livestream", prop->to_str().c_str()); srs_freep(msg); @@ -1808,7 +1817,8 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect) string host = "target.net"; int port = 8888; bool accepted = false; - HELPER_EXPECT_SUCCESS(r.redirect(&req, host, port, accepted)); + string rurl = srs_generate_rtmp_url(host, port, req.host, req.vhost, req.app, req.stream, req.param); + HELPER_EXPECT_SUCCESS(r.redirect(&req, rurl, accepted)); EXPECT_TRUE(accepted); if (true) { @@ -1834,6 +1844,14 @@ VOID TEST(ProtocolRTMPTest, ServerRedirect) prop = ex->get_property("redirect"); ASSERT_TRUE(prop && prop->is_string()); + // The recirect is tcUrl, not RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574995475 + EXPECT_STREQ("rtmp://target.net:8888/live", prop->to_str().c_str()); + + prop = ex->get_property("redirect2"); + ASSERT_TRUE(prop && prop->is_string()); + // The recirect2 is RTMP URL. + // https://github.com/ossrs/srs/issues/1575#issuecomment-574999798 EXPECT_STREQ("rtmp://target.net:8888/live/livestream", prop->to_str().c_str()); srs_freep(msg); diff --git a/trunk/src/utest/srs_utest_service.cpp b/trunk/src/utest/srs_utest_service.cpp index 7532e42a9..87a1c49d1 100644 --- a/trunk/src/utest/srs_utest_service.cpp +++ b/trunk/src/utest/srs_utest_service.cpp @@ -835,6 +835,7 @@ public: SrsSTCoroutine trd; srs_netfd_t fd; MockOnCycleThread3() : trd("mock", this, 0) { + fd = NULL; }; virtual ~MockOnCycleThread3() { trd.stop(); @@ -1087,6 +1088,7 @@ public: SrsSTCoroutine trd; srs_netfd_t fd; MockOnCycleThread4() : trd("mock", this, 0) { + fd = NULL; }; virtual ~MockOnCycleThread4() { trd.stop();