From c7f6eef4ac1ccf78c45804bea3441802400a9821 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 11:51:35 +0800 Subject: [PATCH 01/10] Refine config file, link to issue. --- trunk/conf/srt.conf | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/trunk/conf/srt.conf b/trunk/conf/srt.conf index 35614f2aa..9dc1e564e 100644 --- a/trunk/conf/srt.conf +++ b/trunk/conf/srt.conf @@ -1,10 +1,8 @@ -# main config for srs. -# @see full.conf for detail config. +# SRT config. listen 1935; max_connections 1000; -srs_log_tank file; -srs_log_file ./objs/srs.log; +srs_log_tank console; daemon off; http_api { @@ -22,22 +20,12 @@ srt_server { listen 10080; } +# @doc https://github.com/ossrs/srs/issues/1147#issuecomment-577492117 vhost __defaultVhost__ { } - vhost srs.srt.com.cn { } -# 无vhost配置(__defaultVhost__), 示例: -# srt推流地址:srt://127.0.0.1:10080?streamid=live/test1?m=push -# srt拉流地址:srt://127.0.0.1:10080?streamid=live/test1?m=pull -# rtmp拉流地址:rtmp://127.0.0.1/live/test1 - -# 带有vhost配置, 示例: -# srt推流地址:srt://127.0.0.1:10080?streamid=srs.srt.com.cn/live/test1?m=push -# srt拉流地址:srt://127.0.0.1:10080?streamid=srs.srt.com.cn/live/test1?m=pull -# rtmp拉流地址:rtmp://127.0.0.1/live?vhost=srs.srt.com.cn/test1 - stats { network 0; disk sda sdb xvda xvdb; From a27c4f709566fbf4580601d405bc9f1b4d75f92c Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 12:09:54 +0800 Subject: [PATCH 02/10] Revert "remove modules for srt compile" This reverts commit d4c08c44d84a475df7437354f93dfcdb420c409d. --- trunk/configure | 11 ++++------- trunk/modules/hls-ingester/config | 7 +++++++ trunk/modules/mp4-parser/config | 7 +++++++ trunk/modules/readme.txt | 27 +++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 trunk/modules/hls-ingester/config create mode 100644 trunk/modules/mp4-parser/config create mode 100644 trunk/modules/readme.txt diff --git a/trunk/configure b/trunk/configure index 797b2207c..9efe2fdbd 100755 --- a/trunk/configure +++ b/trunk/configure @@ -158,9 +158,6 @@ fi if [ $SRS_GPERF_MD = YES ]; then LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a"; fi -#srt code path -LibSRTRoot="${SRS_WORKDIR}/src/srt" - # the link options, always use static link SrsLinkOptions="-pthread -ldl -lsrt"; if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then @@ -216,7 +213,7 @@ MODULE_ID="SRT" MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP") ModuleLibIncs=(${SRS_OBJS_DIR}) MODULE_FILES=("srt_server" "srt_handle" "srt_conn" "srt_to_rtmp" "ts_demux" "srt_data") -SRT_INCS=${LibSRTRoot}; MODULE_DIR=${LibSRTRoot} . auto/modules.sh +SRT_INCS="src/srt"; MODULE_DIR=${SRT_INCS} . auto/modules.sh SRT_OBJS="${MODULE_OBJS[@]}" fi @@ -238,7 +235,7 @@ fi if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then MODULE_ID="APP" MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE") - ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot} ${LibSRTRoot}) + ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot}) MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_source" "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http_stream" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config" @@ -273,7 +270,7 @@ LIBS_OBJS="${MODULE_OBJS[@]}" if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then MODULE_ID="SERVER" MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP" "SRT") - ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot} ${LibSRTRoot}) + ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot}) MODULE_FILES=("srs_main_server") SERVER_INCS="src/main"; MODULE_DIR=${SERVER_INCS} . auto/modules.sh SERVER_OBJS="${MODULE_OBJS[@]}" @@ -339,7 +336,7 @@ if [ $SRS_UTEST = YES ]; then MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol" "srs_utest_kernel" "srs_utest_core" "srs_utest_config" "srs_utest_rtmp" "srs_utest_http" "srs_utest_avc" "srs_utest_reload" "srs_utest_mp4" "srs_utest_service" "srs_utest_app") - ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot} ${LibSRTRoot}) + ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot}) ModuleLibFiles=(${LibSTfile} ${LibSSLfile}) MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP" "SRT") MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]}" diff --git a/trunk/modules/hls-ingester/config b/trunk/modules/hls-ingester/config new file mode 100644 index 000000000..eda6a1363 --- /dev/null +++ b/trunk/modules/hls-ingester/config @@ -0,0 +1,7 @@ + +# The module to ingest hls to replace ffmpeg with better behavior. +SRS_MODULE_NAME=("srs_hls_ingester") +SRS_MODULE_MAIN=("srs_main_ingest_hls") +SRS_MODULE_APP=() +SRS_MODULE_DEFINES="" +SRS_MODULE_MAKEFILE="" diff --git a/trunk/modules/mp4-parser/config b/trunk/modules/mp4-parser/config new file mode 100644 index 000000000..7f9adfd66 --- /dev/null +++ b/trunk/modules/mp4-parser/config @@ -0,0 +1,7 @@ + +# The module to parse mp4 file. +SRS_MODULE_NAME=("srs_mp4_parser") +SRS_MODULE_MAIN=("srs_main_mp4_parser") +SRS_MODULE_APP=() +SRS_MODULE_DEFINES="" +SRS_MODULE_MAKEFILE="" diff --git a/trunk/modules/readme.txt b/trunk/modules/readme.txt new file mode 100644 index 000000000..32d7891f0 --- /dev/null +++ b/trunk/modules/readme.txt @@ -0,0 +1,27 @@ +SRS Module Rules(SRS模块规则) +1. Each module in its seperate home directory(一个模块一个目录). +2. There is a config file in home(目录下放一个config文件). +3. All variables in configure are available(所有的configure中的变量模块中可以使用). + +The Variables in config(模块中需要定义变量,例如): +1. SRS_MODULE_NAME:The application binary name, optional. (模块名称,用来做Makefile的phony以及执行binary文件名。模块的二进制输出。为空时没有独立的二进制。) +2. SRS_MODULE_MAIN:The source file in src/main directory, optional. (模块的main函数所在的cpp文件,在src/main目录。模块在main的文件。可以为空。) +3. SRS_MODULE_APP:The source file in src/app directory, optional. (模块在src/app目录的源文件列表。模块在app的文件。可以为空。) +4. SRS_MODULE_DEFINES: The extra defined macros, optional. (模块编译时的额外宏定义。在app和main模块加入。可以为空。) +5. SRS_MODULE_MAKEFILE: The specified Makefile, optional. (模块的Makefile。在make时会执行这个Makefile。可以为空。) + +Reset all Variables at the beginning(在配置开头必须清空这些变量): +SRS_MODULE_NAME=() +SRS_MODULE_MAIN=() +SRS_MODULE_APP=() +SRS_MODULE_DEFINES="" +SRS_MODULE_MAKEFILE="" + +For example(下面是一个实例): +SRS_MODULE_NAME=("srs_rtmfpd") +SRS_MODULE_MAIN=("srs_main_rtmfpd") +SRS_MODULE_APP=("srs_app_rtfmpd") +SRS_MODULE_DEFINES="-DRTMFPD" +SRS_MODULE_MAKEFILE="modules/rtmfpd/Makefile" + +winlin, 2015.3 From 106113c5f0743ac09864ca7440861993e27dc432 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 12:15:02 +0800 Subject: [PATCH 03/10] For previous revert, pick some code for LibSRTRoot --- trunk/configure | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/trunk/configure b/trunk/configure index 9efe2fdbd..c3f90ecfd 100755 --- a/trunk/configure +++ b/trunk/configure @@ -158,6 +158,8 @@ fi if [ $SRS_GPERF_MD = YES ]; then LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a"; fi +# srt code path +LibSRTRoot="${SRS_WORKDIR}/src/srt" # the link options, always use static link SrsLinkOptions="-pthread -ldl -lsrt"; if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then @@ -213,7 +215,7 @@ MODULE_ID="SRT" MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP") ModuleLibIncs=(${SRS_OBJS_DIR}) MODULE_FILES=("srt_server" "srt_handle" "srt_conn" "srt_to_rtmp" "ts_demux" "srt_data") -SRT_INCS="src/srt"; MODULE_DIR=${SRT_INCS} . auto/modules.sh +SRT_INCS=${LibSRTRoot}; MODULE_DIR=${LibSRTRoot} . auto/modules.sh SRT_OBJS="${MODULE_OBJS[@]}" fi @@ -235,7 +237,7 @@ fi if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then MODULE_ID="APP" MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE") - ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot}) + ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot} ${LibSRTRoot}) MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_source" "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http_stream" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config" @@ -270,7 +272,7 @@ LIBS_OBJS="${MODULE_OBJS[@]}" if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then MODULE_ID="SERVER" MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP" "SRT") - ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot}) + ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot} ${LibSRTRoot}) MODULE_FILES=("srs_main_server") SERVER_INCS="src/main"; MODULE_DIR=${SERVER_INCS} . auto/modules.sh SERVER_OBJS="${MODULE_OBJS[@]}" @@ -336,7 +338,7 @@ if [ $SRS_UTEST = YES ]; then MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol" "srs_utest_kernel" "srs_utest_core" "srs_utest_config" "srs_utest_rtmp" "srs_utest_http" "srs_utest_avc" "srs_utest_reload" "srs_utest_mp4" "srs_utest_service" "srs_utest_app") - ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot}) + ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot} ${LibSRTRoot}) ModuleLibFiles=(${LibSTfile} ${LibSSLfile}) MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP" "SRT") MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]}" From 2de8d788f62877b8ca4288ef062f134f5481e132 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 12:32:15 +0800 Subject: [PATCH 04/10] Revert configure changes(srs_ingest_hls,utest) in previous commit --- trunk/configure | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/trunk/configure b/trunk/configure index c3f90ecfd..06fee5cf4 100755 --- a/trunk/configure +++ b/trunk/configure @@ -133,7 +133,8 @@ ARFLAGS = -rs LINK = g++ CXXFLAGS = ${CXXFLAGS} -.PHONY: default srs librtmp +.PHONY: default srs srs_ingest_hls librtmp + default: END @@ -359,7 +360,7 @@ mv ${SRS_WORKDIR}/${SRS_MAKEFILE} ${SRS_WORKDIR}/${SRS_MAKEFILE}.bk # generate phony header cat << END > ${SRS_WORKDIR}/${SRS_MAKEFILE} -.PHONY: default _default install install-api help clean server librtmp _prepare_dir $__mphonys +.PHONY: default _default install install-api help clean server srs_ingest_hls librtmp utest _prepare_dir $__mphonys # install prefix. SRS_PREFIX=${SRS_PREFIX} @@ -374,7 +375,7 @@ END # the server, librtmp and utest # where the bellow will check and disable some entry by only echo. cat << END >> ${SRS_WORKDIR}/${SRS_MAKEFILE} -_default: server librtmp __modules $__mdefaults +_default: server srs_ingest_hls librtmp utest __modules $__mdefaults @bash objs/_srs_build_summary.sh help: From fb5928f927f7a0bbb056d04df5dfaa2dc7275e88 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 13:24:47 +0800 Subject: [PATCH 05/10] Fix build failed for SRT with modules. --- trunk/auto/utest.sh | 2 +- trunk/configure | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/trunk/auto/utest.sh b/trunk/auto/utest.sh index d658bf7f4..ab96caea2 100755 --- a/trunk/auto/utest.sh +++ b/trunk/auto/utest.sh @@ -58,7 +58,7 @@ USER_DIR = . CPPFLAGS += -I\$(GTEST_DIR)/include # Flags passed to the C++ compiler. -CXXFLAGS += -g -Wall -Wextra -O0 ${EXTRA_DEFINES} +CXXFLAGS += ${CXXFLAGS} -Wextra ${EXTRA_DEFINES} # All tests produced by this Makefile. Remember to add new tests you # created to the list. diff --git a/trunk/configure b/trunk/configure index 06fee5cf4..a639df52b 100755 --- a/trunk/configure +++ b/trunk/configure @@ -319,7 +319,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh # # For modules, without the app module. - MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${SRT_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${MAIN_OBJS[@]}" + MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${MAIN_OBJS[@]}" # for SRS_MODULE in ${SRS_MODULES[*]}; do . $SRS_MODULE/config @@ -342,7 +342,7 @@ if [ $SRS_UTEST = YES ]; then ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot} ${LibSRTRoot}) ModuleLibFiles=(${LibSTfile} ${LibSSLfile}) MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP" "SRT") - MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]}" + MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]} ${SRT_OBJS[@]}" LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh fi From fb29096505184fe3a1668651aa1d73c20baecb3b Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 14:22:22 +0800 Subject: [PATCH 06/10] For SRT, allow/default disable it by --without-srt --- trunk/auto/options.sh | 1 + trunk/configure | 59 ++++++++++++++++++++++++++++++------------- 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 00d95d407..a46685e6f 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -16,6 +16,7 @@ help=no ################################################################ # feature options SRS_HDS=NO +SRS_SRT=NO SRS_NGINX=NO SRS_FFMPEG_TOOL=NO SRS_LIBRTMP=NO diff --git a/trunk/configure b/trunk/configure index a639df52b..5b8cd4b0f 100755 --- a/trunk/configure +++ b/trunk/configure @@ -96,10 +96,11 @@ END GDBDebug=" -g -O0" # the warning level. WarnLevel=" -Wall" -# c++11 enable. -cpp11=" -std=c++11 -pthread" # the compile standard. CppStd="-ansi" +if [[ $SRS_SRT == YES ]]; then + CppStd="-std=c++11" +fi # for library compile if [[ $SRS_EXPORT_LIBRTMP_PROJECT == YES ]]; then LibraryCompile=" -fPIC" @@ -109,7 +110,7 @@ SrsGprof=""; SrsGprofLink=""; if [ $SRS_GPROF = YES ]; then SrsGprof=" -pg -lc_p # performance of gperf SrsGperf=""; SrsGperfLink=""; if [ $SRS_GPERF = YES ]; then SrsGperfLink=" -lpthread"; fi # the cxx flag generated. -CXXFLAGS="${CXXFLAGS} ${CppStd}${WarnLevel}${cpp11}${GDBDebug}${LibraryCompile}${SrsGprof}" +CXXFLAGS="${CXXFLAGS} ${CppStd}${WarnLevel}${GDBDebug}${LibraryCompile}${SrsGprof}" if [ $SRS_GPERF = YES ]; then CXXFLAGS="${CXXFLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free"; fi @@ -160,9 +161,14 @@ if [ $SRS_GPERF_MD = YES ]; then LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a"; fi # srt code path -LibSRTRoot="${SRS_WORKDIR}/src/srt" +if [[ $SRS_SRT == YES ]]; then + LibSRTRoot="${SRS_WORKDIR}/src/srt" +fi # the link options, always use static link -SrsLinkOptions="-pthread -ldl -lsrt"; +SrsLinkOptions="-ldl"; +if [[ $SRS_SRT == YES ]]; then + SrsLinkOptions="${SrsLinkOptions} -pthread -lsrt"; +fi if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then SrsLinkOptions="${SrsLinkOptions} -lssl -lcrypto"; fi @@ -212,12 +218,12 @@ PROTOCOL_OBJS="${MODULE_OBJS[@]}" # #srt protocol features. if [ $SRS_SRT = YES ]; then -MODULE_ID="SRT" -MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP") -ModuleLibIncs=(${SRS_OBJS_DIR}) -MODULE_FILES=("srt_server" "srt_handle" "srt_conn" "srt_to_rtmp" "ts_demux" "srt_data") -SRT_INCS=${LibSRTRoot}; MODULE_DIR=${LibSRTRoot} . auto/modules.sh -SRT_OBJS="${MODULE_OBJS[@]}" + MODULE_ID="SRT" + MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP") + ModuleLibIncs=(${SRS_OBJS_DIR}) + MODULE_FILES=("srt_server" "srt_handle" "srt_conn" "srt_to_rtmp" "ts_demux" "srt_data") + SRT_INCS=${LibSRTRoot}; MODULE_DIR=${LibSRTRoot} . auto/modules.sh + SRT_OBJS="${MODULE_OBJS[@]}" fi # @@ -238,7 +244,10 @@ fi if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then MODULE_ID="APP" MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE") - ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot} ${LibSRTRoot}) + ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibSSLRoot}) + if [[ $SRS_SRT == YES ]]; then + ModuleLibIncs+=("${LibSRTRoot[*]}") + fi MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_source" "srs_app_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http_stream" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config" @@ -272,8 +281,14 @@ LIBS_OBJS="${MODULE_OBJS[@]}" #Server Module, for SRS only. if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then MODULE_ID="SERVER" - MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP" "SRT") - ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot} ${LibSRTRoot}) + MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP") + if [[ $SRS_SRT == YES ]]; then + MODULE_DEPENDS+=("SRT") + fi + ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot}) + if [[ $SRS_SRT == YES ]]; then + ModuleLibIncs+=("${LibSRTRoot[*]}") + fi MODULE_FILES=("srs_main_server") SERVER_INCS="src/main"; MODULE_DIR=${SERVER_INCS} . auto/modules.sh SERVER_OBJS="${MODULE_OBJS[@]}" @@ -312,7 +327,11 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then # all depends libraries ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile}) # all depends objects - MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SRT_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}" + MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}" + ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibSSLRoot}) + if [[ $SRS_SRT == YES ]]; then + MODULE_OBJS="${MODULE_OBJS} ${SRT_OBJS[@]}" + fi LINK_OPTIONS="${SrsLinkOptions}${SrsGprofLink}${SrsGperfLink}" # # srs: srs(simple rtmp server) over st(state-threads) @@ -339,9 +358,15 @@ if [ $SRS_UTEST = YES ]; then MODULE_FILES=("srs_utest" "srs_utest_amf0" "srs_utest_protocol" "srs_utest_kernel" "srs_utest_core" "srs_utest_config" "srs_utest_rtmp" "srs_utest_http" "srs_utest_avc" "srs_utest_reload" "srs_utest_mp4" "srs_utest_service" "srs_utest_app") - ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot} ${LibSRTRoot}) + ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot}) + if [[ $SRS_SRT == YES ]]; then + ModuleLibIncs+=("${LibSRTRoot[*]}") + fi ModuleLibFiles=(${LibSTfile} ${LibSSLfile}) - MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP" "SRT") + MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL" "SERVICE" "APP") + if [[ $SRS_SRT == YES ]]; then + MODULE_DEPENDS+=("SRT") + fi MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${SERVICE_OBJS[@]} ${APP_OBJS[@]} ${SRT_OBJS[@]}" LINK_OPTIONS="-lpthread ${SrsLinkOptions}" MODULE_DIR="src/utest" APP_NAME="srs_utest" . auto/utest.sh fi From f1437574293598e41c9e46dca8e15de794b7553d Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 14:23:09 +0800 Subject: [PATCH 07/10] Use macro to disable SRT in code --- trunk/auto/auto_headers.sh | 6 ++++++ trunk/src/app/srs_app_server.cpp | 4 ++++ trunk/src/app/srs_app_server.hpp | 9 ++++++--- trunk/src/main/srs_main_server.cpp | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 10e76e99f..96f5526d3 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -70,6 +70,12 @@ else srs_undefine_macro "SRS_AUTO_HDS" $SRS_AUTO_HEADERS_H fi +if [ $SRS_SRT = YES ]; then + srs_define_macro "SRS_AUTO_SRT" $SRS_AUTO_HEADERS_H +else + srs_undefine_macro "SRS_AUTO_SRT" $SRS_AUTO_HEADERS_H +fi + if [ $SRS_MEM_WATCH = YES ]; then srs_define_macro "SRS_AUTO_MEM_WATCH" $SRS_AUTO_HEADERS_H else diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 62d97fd97..c85930da3 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -688,9 +688,11 @@ srs_error_t SrsServer::listen() if ((err = conn_manager->start()) != srs_success) { return srs_error_wrap(err, "connection manager"); } +#ifdef SRS_AUTO_SRT if ((err = listen_srt()) != srs_success) { return srs_error_wrap(err, "srt listen"); } +#endif return err; } @@ -1007,6 +1009,7 @@ srs_error_t SrsServer::do_cycle() return err; } +#ifdef SRS_AUTO_SRT srs_error_t SrsServer::listen_srt() { srs_error_t err = srs_success; @@ -1030,6 +1033,7 @@ srs_error_t SrsServer::listen_srt() { } return err; } +#endif srs_error_t SrsServer::listen_rtmp() { diff --git a/trunk/src/app/srs_app_server.hpp b/trunk/src/app/srs_app_server.hpp index c03fc996a..a852f0a14 100644 --- a/trunk/src/app/srs_app_server.hpp +++ b/trunk/src/app/srs_app_server.hpp @@ -36,8 +36,10 @@ #include #include #include +#ifdef SRS_AUTO_SRT #include "../srt/srt_server.hpp" #include "../srt/srt_to_rtmp.hpp" +#endif class SrsServer; class SrsConnection; @@ -211,11 +213,10 @@ private: SrsHttpHeartbeat* http_heartbeat; SrsIngester* ingester; SrsCoroutineManager* conn_manager; - -private: +#ifdef SRS_AUTO_SRT //srt server SRT_SERVER_PTR srt_ptr; - +#endif private: // The pid file fd, lock the file write when server is running. // @remark the init.d script should cleanup the pid file, when stop service, @@ -286,8 +287,10 @@ private: virtual srs_error_t listen_http_api(); virtual srs_error_t listen_http_stream(); virtual srs_error_t listen_stream_caster(); +#ifdef SRS_AUTO_SRT //start listen srt udp port virtual srs_error_t listen_srt(); +#endif // Close the listeners for specified type, // Remove the listen object from manager. virtual void close_listeners(SrsListenerType type); diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 3bfd9ebb1..797e0d90a 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -214,6 +214,7 @@ void show_macro_features() ss << ", dash:" << "on"; ss << ", hls:" << srs_bool2switch(true); ss << ", hds:" << srs_bool2switch(SRS_AUTO_HDS_BOOL); + ss << ", srt:" << srs_bool2switch(SRS_AUTO_SRT_BOOL); // hc(http callback) ss << ", hc:" << srs_bool2switch(true); // ha(http api) From a7b8695cb0fcf39f3f10ba3b467cb5b3365bf6f3 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 14:33:11 +0800 Subject: [PATCH 08/10] Refactor code, include without path --- trunk/src/app/srs_app_server.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trunk/src/app/srs_app_server.hpp b/trunk/src/app/srs_app_server.hpp index a852f0a14..e08a5f8d9 100644 --- a/trunk/src/app/srs_app_server.hpp +++ b/trunk/src/app/srs_app_server.hpp @@ -37,8 +37,8 @@ #include #include #ifdef SRS_AUTO_SRT -#include "../srt/srt_server.hpp" -#include "../srt/srt_to_rtmp.hpp" +#include +#include #endif class SrsServer; @@ -214,7 +214,7 @@ private: SrsIngester* ingester; SrsCoroutineManager* conn_manager; #ifdef SRS_AUTO_SRT - //srt server + // srt server SRT_SERVER_PTR srt_ptr; #endif private: From aacf519169ce088c43777640fd1f38306d2f3eaf Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 14:42:06 +0800 Subject: [PATCH 09/10] Revert log for forwarder in source --- trunk/src/app/srs_app_source.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index bfe3e1577..788773c80 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1456,7 +1456,6 @@ srs_error_t SrsOriginHub::create_forwarders() if (!_srs_config->get_forward_enabled(req->vhost)) { return err; } - srs_trace("srs vhost(%s) forward is enable.", req->host.c_str()); SrsConfDirective* conf = _srs_config->get_forwards(req->vhost); for (int i = 0; conf && i < (int)conf->args.size(); i++) { From bc26df4893f1e5bb1ce2a4ae88997c5f24d7df35 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Jan 2020 14:44:30 +0800 Subject: [PATCH 10/10] Remove noused debug function srs_trace_data --- trunk/src/kernel/srs_kernel_log.hpp | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/trunk/src/kernel/srs_kernel_log.hpp b/trunk/src/kernel/srs_kernel_log.hpp index 670a5b9c6..1d7af37bb 100644 --- a/trunk/src/kernel/srs_kernel_log.hpp +++ b/trunk/src/kernel/srs_kernel_log.hpp @@ -142,26 +142,5 @@ extern ISrsThreadContext* _srs_context; #define srs_trace(msg, ...) (void)0 #endif -inline void srs_trace_data(const char* data_p, int len, const char* dscr) -{ - const int MAX = 256; - char debug_data[MAX]; - char debug_len = 0; - - debug_len += sprintf(debug_data + debug_len, "%s", dscr); - - for (int index = 0; index < len; index++) { - if (index % 16 == 0) { - debug_len += sprintf(debug_data + debug_len, "\r\n"); - } - debug_len += sprintf(debug_data + debug_len, " %02x", (unsigned char)data_p[index]); - if (index >= 32) { - break; - } - } - - srs_trace("%s", debug_data); - return; -} #endif