Merge branch 'feature/rtc' into develop

pull/1830/head
winlin 5 years ago
commit 7c572dbae3

@ -159,6 +159,8 @@ For previous versions, please read:
## V4 changes ## V4 changes
* v4.0, 2020-06-24, Support static link c++ libraries. 4.0.32
* v4.0, 2020-06-23, Change log cid from int to string. 4.0.31
* v4.0, 2020-06-13, GB28181 with JitterBuffer support. 4.0.30 * v4.0, 2020-06-13, GB28181 with JitterBuffer support. 4.0.30
* v4.0, 2020-06-03, Support enable C++11. 4.0.29 * v4.0, 2020-06-03, Support enable C++11. 4.0.29
* v4.0, 2020-05-31, Remove [srs-librtmp](https://github.com/ossrs/srs/issues/1535#issuecomment-633907655). 4.0.28 * v4.0, 2020-05-31, Remove [srs-librtmp](https://github.com/ossrs/srs/issues/1535#issuecomment-633907655). 4.0.28

@ -87,6 +87,12 @@ else
srs_undefine_macro "SRS_RTC" $SRS_AUTO_HEADERS_H srs_undefine_macro "SRS_RTC" $SRS_AUTO_HEADERS_H
fi fi
if [ $SRS_FFMPEG_FIT = YES ]; then
srs_define_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_SIMULATOR = YES ]; then if [ $SRS_SIMULATOR = YES ]; then
srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
else else

@ -595,7 +595,7 @@ fi
##################################################################################### #####################################################################################
# ffmpeg-fix, for WebRTC to transcode AAC with Opus. # ffmpeg-fix, for WebRTC to transcode AAC with Opus.
##################################################################################### #####################################################################################
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_FFMPEG_FIT == YES ]]; then
FFMPEG_OPTIONS="" FFMPEG_OPTIONS=""
# If disable nasm, disable all ASMs. # If disable nasm, disable all ASMs.

@ -22,7 +22,6 @@ SRS_GB28181=NO
SRS_CXX11=NO SRS_CXX11=NO
SRS_CXX14=NO SRS_CXX14=NO
SRS_NGINX=NO SRS_NGINX=NO
SRS_FFMPEG_TOOL=NO
SRS_LIBRTMP=NO SRS_LIBRTMP=NO
SRS_RESEARCH=NO SRS_RESEARCH=NO
SRS_UTEST=NO SRS_UTEST=NO
@ -46,8 +45,12 @@ SRS_HLS=YES
SRS_DVR=YES SRS_DVR=YES
# #
################################################################ ################################################################
# libraries # FFmpeg stub is the stub code in SRS for ingester or encoder.
SRS_FFMPEG_STUB=NO SRS_FFMPEG_STUB=NO
# FFmpeg tool is the binary for FFmpeg tool, to exec ingest or transcode.
SRS_FFMPEG_TOOL=NO
# FFmpeg fit is the source code for RTC, to transcode audio or video in SRS.
SRS_FFMPEG_FIT=RESERVED
# arguments # arguments
SRS_PREFIX=/usr/local/srs SRS_PREFIX=/usr/local/srs
SRS_JOBS=1 SRS_JOBS=1
@ -153,6 +156,7 @@ Features:
--gb28181=on|off Whether build the GB28181 support for SRS. --gb28181=on|off Whether build the GB28181 support for SRS.
--cxx11=on|off Whether enable the C++11 support for SRS. --cxx11=on|off Whether enable the C++11 support for SRS.
--cxx14=on|off Whether enable the C++14 support for SRS. --cxx14=on|off Whether enable the C++14 support for SRS.
--ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code) for SRS.
--prefix=<path> The absolute installation path for srs. Default: $SRS_PREFIX --prefix=<path> The absolute installation path for srs. Default: $SRS_PREFIX
--gcov=on|off Whether enable the GCOV compiler options. --gcov=on|off Whether enable the GCOV compiler options.
@ -282,7 +286,7 @@ function parse_user_option() {
--with-ffmpeg) SRS_FFMPEG_TOOL=YES ;; --with-ffmpeg) SRS_FFMPEG_TOOL=YES ;;
--without-ffmpeg) SRS_FFMPEG_TOOL=NO ;; --without-ffmpeg) SRS_FFMPEG_TOOL=NO ;;
--ffmpeg) if [[ $value == off ]]; then SRS_FFMPEG_TOOL=NO; else SRS_FFMPEG_TOOL=YES; fi ;; --ffmpeg-tool) if [[ $value == off ]]; then SRS_FFMPEG_TOOL=NO; else SRS_FFMPEG_TOOL=YES; fi ;;
--with-transcode) SRS_TRANSCODE=YES ;; --with-transcode) SRS_TRANSCODE=YES ;;
--without-transcode) echo "ignore option \"$option\"" ;; --without-transcode) echo "ignore option \"$option\"" ;;
@ -327,6 +331,7 @@ function parse_user_option() {
--cxx11) if [[ $value == off ]]; then SRS_CXX11=NO; else SRS_CXX11=YES; fi ;; --cxx11) if [[ $value == off ]]; then SRS_CXX11=NO; else SRS_CXX11=YES; fi ;;
--cxx14) if [[ $value == off ]]; then SRS_CXX14=NO; else SRS_CXX14=YES; fi ;; --cxx14) if [[ $value == off ]]; then SRS_CXX14=NO; else SRS_CXX14=YES; fi ;;
--ffmpeg-fit) if [[ $value == off ]]; then SRS_FFMPEG_FIT=NO; else SRS_FFMPEG_FIT=YES; fi ;;
--with-clean) SRS_CLEAN=YES ;; --with-clean) SRS_CLEAN=YES ;;
--without-clean) SRS_CLEAN=NO ;; --without-clean) SRS_CLEAN=NO ;;
@ -526,6 +531,11 @@ function apply_user_presets() {
if [[ $SRS_SRT == YES ]]; then if [[ $SRS_SRT == YES ]]; then
SRS_CXX11=YES SRS_CXX11=YES
fi fi
# Enable FFmpeg fit for RTC to trancode audio from AAC to OPUS, if user has't disabled it.
if [[ $SRS_RTC == YES && $SRS_FFMPEG_FIT == RESERVED ]]; then
SRS_FFMPEG_FIT=YES
fi
} }
apply_user_presets apply_user_presets
@ -625,8 +635,9 @@ function regenerate_options() {
if [ $SRS_RTC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=off"; fi if [ $SRS_RTC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --rtc=off"; fi
if [ $SRS_SIMULATOR = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=off"; fi if [ $SRS_SIMULATOR = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --simulator=off"; fi
if [ $SRS_GB28181 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=off"; fi if [ $SRS_GB28181 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=off"; fi
if [ $SRS_CXX11 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=off"; fi if [ $SRS_CXX11 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx11=off"; fi
if [ $SRS_CXX14 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx14=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx14=off"; fi if [ $SRS_CXX14 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx14=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cxx14=off"; fi
if [ $SRS_FFMPEG_FIT = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-fit=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --ffmpeg-fit=off"; fi
if [ $SRS_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=off"; fi if [ $SRS_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --nasm=off"; fi
if [ $SRS_SRTP_ASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=off"; fi if [ $SRS_SRTP_ASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srtp-nasm=off"; fi
if [ $SRS_SENDMMSG = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sendmmsg=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sendmmsg=off"; fi if [ $SRS_SENDMMSG = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sendmmsg=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sendmmsg=off"; fi

@ -440,8 +440,8 @@ rtc_server {
# We listen multiple times at the same port, by REUSEPORT, to increase the UDP queue. # We listen multiple times at the same port, by REUSEPORT, to increase the UDP queue.
# Note that you can set to 1 and increase the system UDP buffer size by net.core.rmem_max # Note that you can set to 1 and increase the system UDP buffer size by net.core.rmem_max
# and net.core.rmem_default or just increase this to get larger UDP recv and send buffer. # and net.core.rmem_default or just increase this to get larger UDP recv and send buffer.
# default: 4 # default: 1
reuseport 4; reuseport 1;
# Whether merge multiple NALUs into one. # Whether merge multiple NALUs into one.
# @see https://github.com/ossrs/srs/issues/307#issuecomment-612806318 # @see https://github.com/ossrs/srs/issues/307#issuecomment-612806318
# default: on # default: on

69
trunk/configure vendored

@ -136,20 +136,24 @@ END
# st(state-threads) the basic network library for SRS. # st(state-threads) the basic network library for SRS.
LibSTRoot="${SRS_OBJS_DIR}/st"; LibSTfile="${LibSTRoot}/libst.a" LibSTRoot="${SRS_OBJS_DIR}/st"; LibSTfile="${LibSTRoot}/libst.a"
if [[ $SRS_SHARED_ST == YES ]]; then LibSTfile="-lst"; fi if [[ $SRS_SHARED_ST == YES ]]; then LibSTfile="-lst"; fi
# srtp # srtp
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
LibSrtpRoot="${SRS_OBJS_DIR}/srtp2/include"; LibSrtpFile="${SRS_OBJS_DIR}/srtp2/lib/libsrtp2.a" LibSrtpRoot="${SRS_OBJS_DIR}/srtp2/include"; LibSrtpFile="${SRS_OBJS_DIR}/srtp2/lib/libsrtp2.a"
fi fi
# FFMPEG for WebRTC transcoding, such as aac to opus. # FFMPEG for WebRTC transcoding, such as aac to opus.
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_FFMPEG_FIT == YES ]]; then
LibFfmpegRoot="${SRS_OBJS_DIR}/ffmpeg/include"; LibFfmpegFile="${SRS_OBJS_DIR}/ffmpeg/lib/libavcodec.a ${SRS_OBJS_DIR}/ffmpeg/lib/libswresample.a ${SRS_OBJS_DIR}/ffmpeg/lib/libavutil.a" LibFfmpegRoot="${SRS_OBJS_DIR}/ffmpeg/include"; LibFfmpegFile="${SRS_OBJS_DIR}/ffmpeg/lib/libavcodec.a ${SRS_OBJS_DIR}/ffmpeg/lib/libswresample.a ${SRS_OBJS_DIR}/ffmpeg/lib/libavutil.a"
LibFfmpegRoot="${LibFfmpegRoot} ${SRS_OBJS_DIR}/opus/include"; LibFfmpegFile="${LibFfmpegFile} ${SRS_OBJS_DIR}/opus/lib/libopus.a" LibFfmpegRoot="${LibFfmpegRoot} ${SRS_OBJS_DIR}/opus/include"; LibFfmpegFile="${LibFfmpegFile} ${SRS_OBJS_DIR}/opus/lib/libopus.a"
fi fi
# openssl-1.1.0e, for the RTMP complex handshake. # openssl-1.1.0e, for the RTMP complex handshake.
LibSSLRoot="";LibSSLfile="" LibSSLRoot="";LibSSLfile=""
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == NO ]]; then if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == NO ]]; then
LibSSLRoot="${SRS_OBJS_DIR}/openssl/include"; LibSSLfile="${SRS_OBJS_DIR}/openssl/lib/libssl.a ${SRS_OBJS_DIR}/openssl/lib/libcrypto.a"; LibSSLRoot="${SRS_OBJS_DIR}/openssl/include"; LibSSLfile="${SRS_OBJS_DIR}/openssl/lib/libssl.a ${SRS_OBJS_DIR}/openssl/lib/libcrypto.a";
fi fi
# gperftools-2.1, for mem check and mem/cpu profile # gperftools-2.1, for mem check and mem/cpu profile
LibGperfRoot=""; LibGperfFile="" LibGperfRoot=""; LibGperfFile=""
if [ $SRS_GPERF = YES ]; then if [ $SRS_GPERF = YES ]; then
@ -158,28 +162,35 @@ fi
if [ $SRS_GPERF_MD = YES ]; then if [ $SRS_GPERF_MD = YES ]; then
LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a"; LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a";
fi fi
# srt code path # srt code path
if [[ $SRS_SRT == YES ]]; then if [[ $SRS_SRT == YES ]]; then
LibSRTRoot="${SRS_WORKDIR}/src/srt"; LibSRTfile="${SRS_OBJS_DIR}/srt/lib/libsrt.a" LibSRTRoot="${SRS_WORKDIR}/src/srt"; LibSRTfile="${SRS_OBJS_DIR}/srt/lib/libsrt.a"
if [[ $SRS_SHARED_SRT == YES ]]; then LibSRTfile="-lsrt"; fi if [[ $SRS_SHARED_SRT == YES ]]; then LibSRTfile="-lsrt"; fi
fi fi
# the link options, always use static link # the link options, always use static link
SrsLinkOptions="-ldl"; SrsLinkOptions="-ldl";
if [[ $SRS_SRT == YES || $SRS_RTC == YES ]]; then if [[ $SRS_SRT == YES || $SRS_RTC == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} -lpthread"; SrsLinkOptions="${SrsLinkOptions} -lpthread";
fi fi
if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} -lssl -lcrypto"; SrsLinkOptions="${SrsLinkOptions} -lssl -lcrypto";
fi fi
# if static specified, add static
# TODO: FIXME: remove static. # Static link the c++ libraries, for user who build SRS by a new version of gcc,
# so we need to link the c++ libraries staticly but not all.
# @see https://stackoverflow.com/a/26107550
if [ $SRS_STATIC = YES ]; then if [ $SRS_STATIC = YES ]; then
SrsLinkOptions="${SrsLinkOptions} -static"; SrsLinkOptions="${SrsLinkOptions} -static-libstdc++";
fi fi
# For coverage. # For coverage.
if [[ $SRS_GCOV == YES ]]; then if [[ $SRS_GCOV == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} ${SrsGcov}"; SrsLinkOptions="${SrsLinkOptions} ${SrsGcov}";
fi fi
# For FFMPEG/RTC. # For FFMPEG/RTC.
if [[ $SRS_RTC == YES && $SRS_NASM == NO && $SRS_OSX == NO ]]; then if [[ $SRS_RTC == YES && $SRS_NASM == NO && $SRS_OSX == NO ]]; then
SrsLinkOptions="${SrsLinkOptions} -lrt"; SrsLinkOptions="${SrsLinkOptions} -lrt";
@ -222,7 +233,10 @@ MODULE_FILES=("srs_protocol_amf0" "srs_protocol_io" "srs_rtmp_stack"
"srs_service_rtmp_conn" "srs_service_utility" "srs_service_conn") "srs_service_rtmp_conn" "srs_service_utility" "srs_service_conn")
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
MODULE_FILES+=("srs_rtc_stun_stack") MODULE_FILES+=("srs_rtc_stun_stack")
ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi fi
PROTOCOL_INCS="src/protocol"; MODULE_DIR=${PROTOCOL_INCS} . auto/modules.sh PROTOCOL_INCS="src/protocol"; MODULE_DIR=${PROTOCOL_INCS} . auto/modules.sh
PROTOCOL_OBJS="${MODULE_OBJS[@]}" PROTOCOL_OBJS="${MODULE_OBJS[@]}"
@ -246,7 +260,10 @@ if [ $SRS_GPERF = YES ]; then
ModuleLibIncs+=(${LibGperfRoot}) ModuleLibIncs+=(${LibGperfRoot})
fi fi
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi fi
MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_source" 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_refer" "srs_app_hls" "srs_app_forward" "srs_app_encoder" "srs_app_http_stream"
@ -260,9 +277,12 @@ MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_sourc
"srs_app_hourglass" "srs_app_dash" "srs_app_fragment" "srs_app_dvr" "srs_app_hourglass" "srs_app_dash" "srs_app_fragment" "srs_app_dvr"
"srs_app_coworkers" "srs_app_hybrid") "srs_app_coworkers" "srs_app_hybrid")
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
MODULE_FILES+=("srs_app_rtc_conn" "srs_app_rtc_dtls" "srs_app_rtc_codec" "srs_app_rtc_sdp" MODULE_FILES+=("srs_app_rtc_conn" "srs_app_rtc_dtls" "srs_app_rtc_sdp"
"srs_app_rtc_queue" "srs_app_rtc_server" "srs_app_rtc_source" "srs_app_rtc_api") "srs_app_rtc_queue" "srs_app_rtc_server" "srs_app_rtc_source" "srs_app_rtc_api")
fi fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
MODULE_FILES+=("srs_app_rtc_codec")
fi
if [[ $SRS_GB28181 == YES ]]; then if [[ $SRS_GB28181 == YES ]]; then
MODULE_FILES+=("srs_app_gb28181" "srs_app_gb28181_sip" "srs_app_gb28181_jitbuffer") MODULE_FILES+=("srs_app_gb28181" "srs_app_gb28181_sip" "srs_app_gb28181_jitbuffer")
fi fi
@ -284,7 +304,10 @@ if [[ $SRS_SRT == YES ]]; then
fi fi
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot}) ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot})
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi fi
if [[ $SRS_SRT == YES ]]; then if [[ $SRS_SRT == YES ]]; then
ModuleLibIncs+=("${LibSRTRoot[*]}") ModuleLibIncs+=("${LibSRTRoot[*]}")
@ -298,7 +321,10 @@ MODULE_ID="MAIN"
MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL") MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL")
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot}) ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot})
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi fi
MODULE_FILES=() MODULE_FILES=()
DEFINES="" DEFINES=""
@ -325,7 +351,10 @@ done
# all depends libraries # all depends libraries
ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile}) ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile})
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
ModuleLibFiles+=("${LibFfmpegFile[*]}" ${LibSrtpFile}) ModuleLibFiles+=(${LibSrtpFile})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibFiles+=("${LibFfmpegFile[*]}")
fi fi
if [[ $SRS_SRT == YES ]]; then if [[ $SRS_SRT == YES ]]; then
ModuleLibFiles+=("${LibSRTfile[*]}") ModuleLibFiles+=("${LibSRTfile[*]}")
@ -334,7 +363,10 @@ fi
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}" MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}"
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot}) ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot})
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi fi
if [[ $SRS_SRT == YES ]]; then if [[ $SRS_SRT == YES ]]; then
MODULE_OBJS="${MODULE_OBJS} ${SRT_OBJS[@]}" MODULE_OBJS="${MODULE_OBJS} ${SRT_OBJS[@]}"
@ -348,7 +380,10 @@ BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${MAIN_OBJS[@]}" MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${MAIN_OBJS[@]}"
ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile}) ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile})
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
ModuleLibFiles+=("${LibFfmpegFile[*]}" ${LibSrtpFile}) ModuleLibFiles+=(${LibSrtpFile})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibFiles+=("${LibFfmpegFile[*]}")
fi fi
# #
for SRS_MODULE in ${SRS_MODULES[*]}; do for SRS_MODULE in ${SRS_MODULES[*]}; do
@ -370,14 +405,20 @@ if [ $SRS_UTEST = YES ]; then
"srs_utest_mp4" "srs_utest_service" "srs_utest_app" "srs_utest_rtc") "srs_utest_mp4" "srs_utest_service" "srs_utest_app" "srs_utest_rtc")
ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot}) ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot})
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) ModuleLibIncs+=(${LibSrtpRoot})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibIncs+=("${LibFfmpegRoot[*]}")
fi fi
if [[ $SRS_SRT == YES ]]; then if [[ $SRS_SRT == YES ]]; then
ModuleLibIncs+=("${LibSRTRoot[*]}") ModuleLibIncs+=("${LibSRTRoot[*]}")
fi fi
ModuleLibFiles=(${LibSTfile} ${LibSSLfile}) ModuleLibFiles=(${LibSTfile} ${LibSSLfile})
if [[ $SRS_RTC == YES ]]; then if [[ $SRS_RTC == YES ]]; then
ModuleLibFiles+=("${LibFfmpegFile[*]}" ${LibSrtpFile}) ModuleLibFiles+=(${LibSrtpFile})
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
ModuleLibFiles+=("${LibFfmpegFile[*]}")
fi fi
if [[ $SRS_SRT == YES ]]; then if [[ $SRS_SRT == YES ]]; then
ModuleLibFiles+=("${LibSRTfile[*]}") ModuleLibFiles+=("${LibSRTfile[*]}")

@ -4820,8 +4820,10 @@ int SrsConfig::get_rtc_server_reuseport()
int v = get_rtc_server_reuseport2(); int v = get_rtc_server_reuseport2();
#if !defined(SO_REUSEPORT) #if !defined(SO_REUSEPORT)
srs_warn("REUSEPORT not supported, reset %d to %d", reuseport, DEFAULT); if (v > 1) {
v = 1 srs_warn("REUSEPORT not supported, reset %d to %d", reuseport, DEFAULT);
v = 1
}
#endif #endif
return v; return v;
@ -4829,7 +4831,7 @@ int SrsConfig::get_rtc_server_reuseport()
int SrsConfig::get_rtc_server_reuseport2() int SrsConfig::get_rtc_server_reuseport2()
{ {
static int DEFAULT = 4; static int DEFAULT = 1;
SrsConfDirective* conf = root->get("rtc_server"); SrsConfDirective* conf = root->get("rtc_server");
if (!conf) { if (!conf) {

@ -247,7 +247,11 @@ SrsRtcSource::SrsRtcSource()
rtc_publisher_ = NULL; rtc_publisher_ = NULL;
req = NULL; req = NULL;
#ifdef SRS_FFMPEG_FIT
bridger_ = new SrsRtcFromRtmpBridger(this); bridger_ = new SrsRtcFromRtmpBridger(this);
#else
bridger_ = new SrsRtcDummyBridger();
#endif
} }
SrsRtcSource::~SrsRtcSource() SrsRtcSource::~SrsRtcSource()
@ -266,9 +270,12 @@ srs_error_t SrsRtcSource::initialize(SrsRequest* r)
req = r->copy(); req = r->copy();
if ((err = bridger_->initialize(req)) != srs_success) { #ifdef SRS_FFMPEG_FIT
SrsRtcFromRtmpBridger* bridger = dynamic_cast<SrsRtcFromRtmpBridger*>(bridger_);
if ((err = bridger->initialize(req)) != srs_success) {
return srs_error_wrap(err, "bridge initialize"); return srs_error_wrap(err, "bridge initialize");
} }
#endif
return err; return err;
} }
@ -414,6 +421,7 @@ srs_error_t SrsRtcSource::on_rtp(SrsRtpPacket2* pkt)
return err; return err;
} }
#ifdef SRS_FFMPEG_FIT
SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcSource* source) SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcSource* source)
{ {
req = NULL; req = NULL;
@ -936,4 +944,32 @@ srs_error_t SrsRtcFromRtmpBridger::consume_packets(vector<SrsRtpPacket2*>& pkts)
return err; return err;
} }
#endif
SrsRtcDummyBridger::SrsRtcDummyBridger()
{
}
SrsRtcDummyBridger::~SrsRtcDummyBridger()
{
}
srs_error_t SrsRtcDummyBridger::on_publish()
{
return srs_error_new(ERROR_RTC_DUMMY_BRIDGER, "no FFmpeg fit");
}
srs_error_t SrsRtcDummyBridger::on_audio(SrsSharedPtrMessage* /*audio*/)
{
return srs_error_new(ERROR_RTC_DUMMY_BRIDGER, "no FFmpeg fit");
}
srs_error_t SrsRtcDummyBridger::on_video(SrsSharedPtrMessage* /*video*/)
{
return srs_error_new(ERROR_RTC_DUMMY_BRIDGER, "no FFmpeg fit");
}
void SrsRtcDummyBridger::on_unpublish()
{
}

@ -115,7 +115,7 @@ private:
SrsRequest* req; SrsRequest* req;
ISrsRtcPublisher* rtc_publisher_; ISrsRtcPublisher* rtc_publisher_;
// Transmux RTMP to RTC. // Transmux RTMP to RTC.
SrsRtcFromRtmpBridger* bridger_; ISrsSourceBridger* bridger_;
private: private:
// To delivery stream to clients. // To delivery stream to clients.
std::vector<SrsRtcConsumer*> consumers; std::vector<SrsRtcConsumer*> consumers;
@ -159,6 +159,7 @@ public:
srs_error_t on_rtp(SrsRtpPacket2* pkt); srs_error_t on_rtp(SrsRtpPacket2* pkt);
}; };
#ifdef SRS_FFMPEG_FIT
class SrsRtcFromRtmpBridger : public ISrsSourceBridger class SrsRtcFromRtmpBridger : public ISrsSourceBridger
{ {
private: private:
@ -197,6 +198,19 @@ private:
srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacket2*>& pkts); srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacket2*>& pkts);
srs_error_t consume_packets(std::vector<SrsRtpPacket2*>& pkts); srs_error_t consume_packets(std::vector<SrsRtpPacket2*>& pkts);
}; };
#endif
class SrsRtcDummyBridger : public ISrsSourceBridger
{
public:
SrsRtcDummyBridger();
virtual ~SrsRtcDummyBridger();
public:
virtual srs_error_t on_publish();
virtual srs_error_t on_audio(SrsSharedPtrMessage* audio);
virtual srs_error_t on_video(SrsSharedPtrMessage* video);
virtual void on_unpublish();
};
#endif #endif

@ -24,6 +24,6 @@
#ifndef SRS_CORE_VERSION4_HPP #ifndef SRS_CORE_VERSION4_HPP
#define SRS_CORE_VERSION4_HPP #define SRS_CORE_VERSION4_HPP
#define SRS_VERSION4_REVISION 30 #define SRS_VERSION4_REVISION 32
#endif #endif

@ -352,6 +352,7 @@
#define ERROR_RTC_DISABLED 5021 #define ERROR_RTC_DISABLED 5021
#define ERROR_RTC_NO_SESSION 5022 #define ERROR_RTC_NO_SESSION 5022
#define ERROR_RTC_INVALID_PARAMS 5023 #define ERROR_RTC_INVALID_PARAMS 5023
#define ERROR_RTC_DUMMY_BRIDGER 5024
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
// GB28181 API error. // GB28181 API error.

@ -212,6 +212,9 @@ srs_error_t do_main(int argc, char** argv)
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
// For background context id.
_srs_context->generate_id();
srs_error_t err = do_main(argc, argv); srs_error_t err = do_main(argc, argv);
if (err != srs_success) { if (err != srs_success) {

@ -70,10 +70,19 @@ srs_error_t srs_st_init()
return srs_error_new(ERROR_ST_SET_EPOLL, "st enable st failed, current is %s", st_get_eventsys_name()); return srs_error_new(ERROR_ST_SET_EPOLL, "st enable st failed, current is %s", st_get_eventsys_name());
} }
// Before ST init, we might have already inited the background cid.
string cid = _srs_context->get_id();
if (cid.empty()) {
cid = _srs_context->generate_id();
}
int r0 = 0; int r0 = 0;
if((r0 = st_init()) != 0){ if((r0 = st_init()) != 0){
return srs_error_new(ERROR_ST_INITIALIZE, "st initialize failed, r0=%d", r0); return srs_error_new(ERROR_ST_INITIALIZE, "st initialize failed, r0=%d", r0);
} }
// Switch to the background cid.
_srs_context->set_id(cid);
srs_trace("st_init success, use %s", st_get_eventsys_name()); srs_trace("st_init success, use %s", st_get_eventsys_name());
return srs_success; return srs_success;

Loading…
Cancel
Save