diff --git a/README.md b/README.md index 0360db477..4a44c81c8 100755 --- a/README.md +++ b/README.md @@ -159,6 +159,8 @@ For previous versions, please read: ## 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-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 diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index fd4bf322d..60c00db9a 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -87,6 +87,12 @@ else srs_undefine_macro "SRS_RTC" $SRS_AUTO_HEADERS_H 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 srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H else diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index f1ced70ad..c42542d8f 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -595,7 +595,7 @@ fi ##################################################################################### # ffmpeg-fix, for WebRTC to transcode AAC with Opus. ##################################################################################### -if [[ $SRS_RTC == YES ]]; then +if [[ $SRS_FFMPEG_FIT == YES ]]; then FFMPEG_OPTIONS="" # If disable nasm, disable all ASMs. diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 58cb2af27..f0b9e56c0 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -22,7 +22,6 @@ SRS_GB28181=NO SRS_CXX11=NO SRS_CXX14=NO SRS_NGINX=NO -SRS_FFMPEG_TOOL=NO SRS_LIBRTMP=NO SRS_RESEARCH=NO SRS_UTEST=NO @@ -46,8 +45,12 @@ SRS_HLS=YES SRS_DVR=YES # ################################################################ -# libraries +# FFmpeg stub is the stub code in SRS for ingester or encoder. 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 SRS_PREFIX=/usr/local/srs SRS_JOBS=1 @@ -153,6 +156,7 @@ Features: --gb28181=on|off Whether build the GB28181 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. + --ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code) for SRS. --prefix= The absolute installation path for srs. Default: $SRS_PREFIX --gcov=on|off Whether enable the GCOV compiler options. @@ -282,7 +286,7 @@ function parse_user_option() { --with-ffmpeg) SRS_FFMPEG_TOOL=YES ;; --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 ;; --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 ;; --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 ;; --without-clean) SRS_CLEAN=NO ;; @@ -526,6 +531,11 @@ function apply_user_presets() { if [[ $SRS_SRT == YES ]]; then SRS_CXX11=YES 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 @@ -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_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_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_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_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_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 diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 9844f51bd..a028598c2 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -440,8 +440,8 @@ rtc_server { # 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 # and net.core.rmem_default or just increase this to get larger UDP recv and send buffer. - # default: 4 - reuseport 4; + # default: 1 + reuseport 1; # Whether merge multiple NALUs into one. # @see https://github.com/ossrs/srs/issues/307#issuecomment-612806318 # default: on diff --git a/trunk/configure b/trunk/configure index a66a8cdf7..20c6a1ed9 100755 --- a/trunk/configure +++ b/trunk/configure @@ -136,20 +136,24 @@ END # st(state-threads) the basic network library for SRS. LibSTRoot="${SRS_OBJS_DIR}/st"; LibSTfile="${LibSTRoot}/libst.a" if [[ $SRS_SHARED_ST == YES ]]; then LibSTfile="-lst"; fi + # srtp if [[ $SRS_RTC == YES ]]; then LibSrtpRoot="${SRS_OBJS_DIR}/srtp2/include"; LibSrtpFile="${SRS_OBJS_DIR}/srtp2/lib/libsrtp2.a" fi + # 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="${LibFfmpegRoot} ${SRS_OBJS_DIR}/opus/include"; LibFfmpegFile="${LibFfmpegFile} ${SRS_OBJS_DIR}/opus/lib/libopus.a" fi + # openssl-1.1.0e, for the RTMP complex handshake. LibSSLRoot="";LibSSLfile="" 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"; fi + # gperftools-2.1, for mem check and mem/cpu profile LibGperfRoot=""; LibGperfFile="" if [ $SRS_GPERF = YES ]; then @@ -158,28 +162,35 @@ fi if [ $SRS_GPERF_MD = YES ]; then LibGperfFile="${SRS_OBJS_DIR}/gperf/lib/libtcmalloc_debug.a"; fi + # srt code path if [[ $SRS_SRT == YES ]]; then LibSRTRoot="${SRS_WORKDIR}/src/srt"; LibSRTfile="${SRS_OBJS_DIR}/srt/lib/libsrt.a" if [[ $SRS_SHARED_SRT == YES ]]; then LibSRTfile="-lsrt"; fi fi + # the link options, always use static link SrsLinkOptions="-ldl"; if [[ $SRS_SRT == YES || $SRS_RTC == YES ]]; then SrsLinkOptions="${SrsLinkOptions} -lpthread"; fi + if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then SrsLinkOptions="${SrsLinkOptions} -lssl -lcrypto"; 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 - SrsLinkOptions="${SrsLinkOptions} -static"; + SrsLinkOptions="${SrsLinkOptions} -static-libstdc++"; fi + # For coverage. if [[ $SRS_GCOV == YES ]]; then SrsLinkOptions="${SrsLinkOptions} ${SrsGcov}"; fi + # For FFMPEG/RTC. if [[ $SRS_RTC == YES && $SRS_NASM == NO && $SRS_OSX == NO ]]; then 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") if [[ $SRS_RTC == YES ]]; then MODULE_FILES+=("srs_rtc_stun_stack") - ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) + ModuleLibIncs+=(${LibSrtpRoot}) +fi +if [[ $SRS_FFMPEG_FIT == YES ]]; then + ModuleLibIncs+=("${LibFfmpegRoot[*]}") fi PROTOCOL_INCS="src/protocol"; MODULE_DIR=${PROTOCOL_INCS} . auto/modules.sh PROTOCOL_OBJS="${MODULE_OBJS[@]}" @@ -246,7 +260,10 @@ if [ $SRS_GPERF = YES ]; then ModuleLibIncs+=(${LibGperfRoot}) fi if [[ $SRS_RTC == YES ]]; then - ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) + ModuleLibIncs+=(${LibSrtpRoot}) +fi +if [[ $SRS_FFMPEG_FIT == YES ]]; then + ModuleLibIncs+=("${LibFfmpegRoot[*]}") 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" @@ -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_coworkers" "srs_app_hybrid") 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") fi +if [[ $SRS_FFMPEG_FIT == YES ]]; then + MODULE_FILES+=("srs_app_rtc_codec") +fi if [[ $SRS_GB28181 == YES ]]; then MODULE_FILES+=("srs_app_gb28181" "srs_app_gb28181_sip" "srs_app_gb28181_jitbuffer") fi @@ -284,7 +304,10 @@ if [[ $SRS_SRT == YES ]]; then fi ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot}) if [[ $SRS_RTC == YES ]]; then - ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) + ModuleLibIncs+=(${LibSrtpRoot}) +fi +if [[ $SRS_FFMPEG_FIT == YES ]]; then + ModuleLibIncs+=("${LibFfmpegRoot[*]}") fi if [[ $SRS_SRT == YES ]]; then ModuleLibIncs+=("${LibSRTRoot[*]}") @@ -298,7 +321,10 @@ MODULE_ID="MAIN" MODULE_DEPENDS=("CORE" "KERNEL" "PROTOCOL") ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot}) if [[ $SRS_RTC == YES ]]; then - ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) + ModuleLibIncs+=(${LibSrtpRoot}) +fi +if [[ $SRS_FFMPEG_FIT == YES ]]; then + ModuleLibIncs+=("${LibFfmpegRoot[*]}") fi MODULE_FILES=() DEFINES="" @@ -325,7 +351,10 @@ done # all depends libraries ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile}) if [[ $SRS_RTC == YES ]]; then - ModuleLibFiles+=("${LibFfmpegFile[*]}" ${LibSrtpFile}) + ModuleLibFiles+=(${LibSrtpFile}) +fi +if [[ $SRS_FFMPEG_FIT == YES ]]; then + ModuleLibFiles+=("${LibFfmpegFile[*]}") fi if [[ $SRS_SRT == YES ]]; then ModuleLibFiles+=("${LibSRTfile[*]}") @@ -334,7 +363,10 @@ fi MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}" ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot}) if [[ $SRS_RTC == YES ]]; then - ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) + ModuleLibIncs+=(${LibSrtpRoot}) +fi +if [[ $SRS_FFMPEG_FIT == YES ]]; then + ModuleLibIncs+=("${LibFfmpegRoot[*]}") fi if [[ $SRS_SRT == YES ]]; then 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[@]}" ModuleLibFiles=(${LibSTfile} ${LibSSLfile} ${LibGperfFile}) if [[ $SRS_RTC == YES ]]; then - ModuleLibFiles+=("${LibFfmpegFile[*]}" ${LibSrtpFile}) + ModuleLibFiles+=(${LibSrtpFile}) +fi +if [[ $SRS_FFMPEG_FIT == YES ]]; then + ModuleLibFiles+=("${LibFfmpegFile[*]}") fi # 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") ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibSSLRoot}) if [[ $SRS_RTC == YES ]]; then - ModuleLibIncs+=("${LibFfmpegRoot[*]}" ${LibSrtpRoot}) + ModuleLibIncs+=(${LibSrtpRoot}) + fi + if [[ $SRS_FFMPEG_FIT == YES ]]; then + ModuleLibIncs+=("${LibFfmpegRoot[*]}") fi if [[ $SRS_SRT == YES ]]; then ModuleLibIncs+=("${LibSRTRoot[*]}") fi ModuleLibFiles=(${LibSTfile} ${LibSSLfile}) if [[ $SRS_RTC == YES ]]; then - ModuleLibFiles+=("${LibFfmpegFile[*]}" ${LibSrtpFile}) + ModuleLibFiles+=(${LibSrtpFile}) + fi + if [[ $SRS_FFMPEG_FIT == YES ]]; then + ModuleLibFiles+=("${LibFfmpegFile[*]}") fi if [[ $SRS_SRT == YES ]]; then ModuleLibFiles+=("${LibSRTfile[*]}") diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index fea008bc4..302a068a5 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -4820,8 +4820,10 @@ int SrsConfig::get_rtc_server_reuseport() int v = get_rtc_server_reuseport2(); #if !defined(SO_REUSEPORT) - srs_warn("REUSEPORT not supported, reset %d to %d", reuseport, DEFAULT); - v = 1 + if (v > 1) { + srs_warn("REUSEPORT not supported, reset %d to %d", reuseport, DEFAULT); + v = 1 + } #endif return v; @@ -4829,7 +4831,7 @@ int SrsConfig::get_rtc_server_reuseport() int SrsConfig::get_rtc_server_reuseport2() { - static int DEFAULT = 4; + static int DEFAULT = 1; SrsConfDirective* conf = root->get("rtc_server"); if (!conf) { diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index b41d6cb48..e0acd57e1 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -247,7 +247,11 @@ SrsRtcSource::SrsRtcSource() rtc_publisher_ = NULL; req = NULL; +#ifdef SRS_FFMPEG_FIT bridger_ = new SrsRtcFromRtmpBridger(this); +#else + bridger_ = new SrsRtcDummyBridger(); +#endif } SrsRtcSource::~SrsRtcSource() @@ -266,9 +270,12 @@ srs_error_t SrsRtcSource::initialize(SrsRequest* r) req = r->copy(); - if ((err = bridger_->initialize(req)) != srs_success) { +#ifdef SRS_FFMPEG_FIT + SrsRtcFromRtmpBridger* bridger = dynamic_cast(bridger_); + if ((err = bridger->initialize(req)) != srs_success) { return srs_error_wrap(err, "bridge initialize"); } +#endif return err; } @@ -414,6 +421,7 @@ srs_error_t SrsRtcSource::on_rtp(SrsRtpPacket2* pkt) return err; } +#ifdef SRS_FFMPEG_FIT SrsRtcFromRtmpBridger::SrsRtcFromRtmpBridger(SrsRtcSource* source) { req = NULL; @@ -936,4 +944,32 @@ srs_error_t SrsRtcFromRtmpBridger::consume_packets(vector& pkts) 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() +{ +} diff --git a/trunk/src/app/srs_app_rtc_source.hpp b/trunk/src/app/srs_app_rtc_source.hpp index 4f370f381..de4bc4daa 100644 --- a/trunk/src/app/srs_app_rtc_source.hpp +++ b/trunk/src/app/srs_app_rtc_source.hpp @@ -115,7 +115,7 @@ private: SrsRequest* req; ISrsRtcPublisher* rtc_publisher_; // Transmux RTMP to RTC. - SrsRtcFromRtmpBridger* bridger_; + ISrsSourceBridger* bridger_; private: // To delivery stream to clients. std::vector consumers; @@ -159,6 +159,7 @@ public: srs_error_t on_rtp(SrsRtpPacket2* pkt); }; +#ifdef SRS_FFMPEG_FIT class SrsRtcFromRtmpBridger : public ISrsSourceBridger { private: @@ -197,6 +198,19 @@ private: srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector& pkts); srs_error_t consume_packets(std::vector& 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 diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index c4a6a0df1..65d68c292 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION4_HPP #define SRS_CORE_VERSION4_HPP -#define SRS_VERSION4_REVISION 30 +#define SRS_VERSION4_REVISION 32 #endif diff --git a/trunk/src/kernel/srs_kernel_error.hpp b/trunk/src/kernel/srs_kernel_error.hpp index 9c6bdb17c..6275087ee 100644 --- a/trunk/src/kernel/srs_kernel_error.hpp +++ b/trunk/src/kernel/srs_kernel_error.hpp @@ -352,6 +352,7 @@ #define ERROR_RTC_DISABLED 5021 #define ERROR_RTC_NO_SESSION 5022 #define ERROR_RTC_INVALID_PARAMS 5023 +#define ERROR_RTC_DUMMY_BRIDGER 5024 /////////////////////////////////////////////////////// // GB28181 API error. diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 55e002f37..3a73b7b55 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -212,6 +212,9 @@ srs_error_t do_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); if (err != srs_success) { diff --git a/trunk/src/protocol/srs_service_st.cpp b/trunk/src/protocol/srs_service_st.cpp index d1558b2aa..f902d5056 100644 --- a/trunk/src/protocol/srs_service_st.cpp +++ b/trunk/src/protocol/srs_service_st.cpp @@ -69,11 +69,20 @@ srs_error_t srs_st_init() if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) { 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; if((r0 = st_init()) != 0){ 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()); return srs_success;