From db503975fbaf52f3d4699577560c140743cd7e93 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 7 May 2020 16:29:11 +0800 Subject: [PATCH] Disable simulator API by default. --- trunk/auto/auto_headers.sh | 6 ++++++ trunk/auto/options.sh | 5 +++++ trunk/src/app/srs_app_http_api.cpp | 2 ++ trunk/src/app/srs_app_http_api.hpp | 2 ++ trunk/src/app/srs_app_rtc_conn.cpp | 3 +++ 5 files changed, 18 insertions(+) diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 772d0aeba..6c5838c5c 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -79,6 +79,12 @@ else srs_undefine_macro "SRS_RTC" $SRS_AUTO_HEADERS_H fi +if [ $SRS_SIMULATOR = YES ]; then + srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H +else + srs_undefine_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H +fi + if [ $SRS_GB28181 = YES ]; then srs_define_macro "SRS_GB28181" $SRS_AUTO_HEADERS_H else diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 97f6dcf92..704ec5ad7 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -80,6 +80,8 @@ SRS_VALGRIND=NO SRS_BUILD_TAG= # Whether do "make clean" when configure. SRS_CLEAN=YES +# Whether enable RTC simulate API. +SRS_SIMULATOR=NO # ################################################################ # presets @@ -200,6 +202,7 @@ Experts: --without-clean Configure SRS and never make clean even possible. --detect-sendmmsg=on|off Whether detect the sendmmsg API. --has-sendmmsg=on|off Whether OS supports sendmmsg API. + --simulator=on|off Whether enable RTC network simulator. Workflow: 1. Apply "Presets". if not specified, use default preset. @@ -315,6 +318,7 @@ function parse_user_option() { --with-rtc) SRS_RTC=YES ;; --without-rtc) SRS_RTC=NO ;; --rtc) if [[ $value == off ]]; then SRS_RTC=NO; else SRS_RTC=YES; fi ;; + --simulator) if [[ $value == off ]]; then SRS_SIMULATOR=NO; else SRS_SIMULATOR=YES; fi ;; --with-gb28181) SRS_GB28181=YES ;; --without-gb28181) SRS_GB28181=NO ;; @@ -638,6 +642,7 @@ function regenerate_options() { if [ $SRS_UTEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --utest=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --utest=off"; fi if [ $SRS_SRT = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srt=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --srt=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_GB28181 = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=on"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gb28181=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 diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 2b5e4a3a8..be15ea532 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -1492,6 +1492,7 @@ srs_error_t SrsGoApiRtcPublish::exchange_sdp(SrsRequest* req, const SrsSdp& remo return err; } +#ifdef SRS_SIMULATOR SrsGoApiRtcNACK::SrsGoApiRtcNACK(SrsRtcServer* server) { server_ = server; @@ -1549,6 +1550,7 @@ srs_error_t SrsGoApiRtcNACK::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe return srs_success; } #endif +#endif SrsGoApiClients::SrsGoApiClients() { diff --git a/trunk/src/app/srs_app_http_api.hpp b/trunk/src/app/srs_app_http_api.hpp index 672f8576d..2aa5923c3 100644 --- a/trunk/src/app/srs_app_http_api.hpp +++ b/trunk/src/app/srs_app_http_api.hpp @@ -203,6 +203,7 @@ private: srs_error_t check_remote_sdp(const SrsSdp& remote_sdp); }; +#ifdef SRS_SIMULATOR class SrsGoApiRtcNACK : public ISrsHttpHandler { private: @@ -216,6 +217,7 @@ private: virtual srs_error_t do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, SrsJsonObject* res); }; #endif +#endif class SrsGoApiClients : public ISrsHttpHandler { diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 03eee1f40..d7d613db8 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -3397,9 +3397,12 @@ srs_error_t SrsRtcServer::listen_api() if ((err = http_api_mux->handle("/rtc/v1/publish/", new SrsGoApiRtcPublish(this))) != srs_success) { return srs_error_wrap(err, "handle publish"); } + +#ifdef SRS_SIMULATOR if ((err = http_api_mux->handle("/rtc/v1/nack/", new SrsGoApiRtcNACK(this))) != srs_success) { return srs_error_wrap(err, "handle nack"); } +#endif return err; }