From fdaee20b8155f2825df01dde8626d375cee05831 Mon Sep 17 00:00:00 2001 From: "xialixin@kanzhun.com" Date: Thu, 18 Feb 2021 21:51:49 +0800 Subject: [PATCH] For #2200, Enable RTC and FLV for GB28181 --- trunk/auto/depends.sh | 9 + trunk/conf/push.gb28181.conf | 33 +- trunk/configure | 21 +- trunk/research/players/srs_gb28181.html | 868 +++++++----------- trunk/src/app/srs_app_gb28181.cpp | 89 +- trunk/src/app/srs_app_gb28181.hpp | 25 +- trunk/src/app/srs_app_gb28181_sip.cpp | 2 +- trunk/src/app/srs_app_gb28181_sip.hpp | 2 +- ...itbuffer.cpp => srs_app_rtc_jitbuffer.cpp} | 860 +++++++++++++---- ...itbuffer.hpp => srs_app_rtc_jitbuffer.hpp} | 223 +++-- .../srs_sip_stack.cpp => app/srs_app_sip.cpp} | 2 +- .../srs_sip_stack.hpp => app/srs_app_sip.hpp} | 0 12 files changed, 1289 insertions(+), 845 deletions(-) rename trunk/src/app/{srs_app_gb28181_jitbuffer.cpp => srs_app_rtc_jitbuffer.cpp} (62%) rename trunk/src/app/{srs_app_gb28181_jitbuffer.hpp => srs_app_rtc_jitbuffer.hpp} (69%) rename trunk/src/{protocol/srs_sip_stack.cpp => app/srs_app_sip.cpp} (99%) rename trunk/src/{protocol/srs_sip_stack.hpp => app/srs_app_sip.hpp} (100%) diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 11b5785d0..cda4091ea 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -269,6 +269,15 @@ function OSX_prepare() echo "Please install pkg-config"; exit -1; fi + if [[ $SRS_GB28181 == YES ]]; then + if [[ ! -f /usr/local/opt/libiconv/lib/libiconv.a ]]; then + echo "install libiconv" + echo "brew install libiconv" + brew install libiconv; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi + echo "install libiconv success" + fi + fi + echo "OSX install tools success" return 0 } diff --git a/trunk/conf/push.gb28181.conf b/trunk/conf/push.gb28181.conf index 7f2076243..c64a6dde0 100644 --- a/trunk/conf/push.gb28181.conf +++ b/trunk/conf/push.gb28181.conf @@ -8,7 +8,12 @@ srs_log_tank console; http_api { enabled on; listen 1985; -} +} + +http_server { + enabled on; + listen 8080; +} stats { network 0; @@ -29,7 +34,7 @@ stream_caster { listen 9000; # 多路复用端口类型,on为tcp,off为udp # 默认:off - tcp_enable on; + tcp_enable off; # rtp接收监听端口范围,最小值 rtp_port_min 58200; @@ -111,5 +116,27 @@ stream_caster { query_catalog_interval 60; } } -vhost __defaultVhost__ { + +rtc_server { + enabled on; + # Listen at udp://8000 + listen 8000; + # + # The $CANDIDATE means fetch from env, if not configed, use * as default. + # + # The * means retrieving server IP automatically, from all network interfaces, + # @see https://github.com/ossrs/srs/issues/307#issuecomment-599028124 + candidate $CANDIDATE; +} + +vhost __defaultVhost__ { + rtc { + enabled on; + bframe discard; + } + + http_remux { + enabled on; + mount [vhost]/[app]/[stream].flv; + } } diff --git a/trunk/configure b/trunk/configure index 4dd1d99ae..2a715da88 100755 --- a/trunk/configure +++ b/trunk/configure @@ -169,6 +169,11 @@ if [[ $SRS_SRT == YES ]]; then if [[ $SRS_SHARED_SRT == YES ]]; then LibSRTfile="-lsrt"; fi fi +# For iconv on macOS only, CentOS seems ok. +if [[ $SRS_GB28181 == YES && $SRS_OSX == YES ]]; then + LibIconvRoot="/usr/local/opt/libiconv/include"; LibIconvfile="/usr/local/opt/libiconv/lib/libiconv.a" +fi + # the link options, always use static link SrsLinkOptions="-ldl -lpthread"; if [[ $SRS_SSL == YES && $SRS_USE_SYS_SSL == YES ]]; then @@ -231,9 +236,6 @@ if [[ $SRS_RTC == YES ]]; then MODULE_FILES+=("srs_rtc_stun_stack") ModuleLibIncs+=(${LibSrtpRoot}) fi -if [[ $SRS_GB28181 == YES ]]; then - MODULE_FILES+=("srs_sip_stack") -fi if [[ $SRS_FFMPEG_FIT == YES ]]; then ModuleLibIncs+=("${LibFfmpegRoot[*]}") fi @@ -283,8 +285,16 @@ 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") + MODULE_FILES+=("srs_app_gb28181" "srs_app_gb28181_sip") fi +if [[ $SRS_GB28181 == YES || $SRS_RTC == YES ]]; then + MODULE_FILES+=("srs_app_rtc_jitbuffer") +fi +if [[ $SRS_GB28181 == YES ]]; then + MODULE_FILES+=("srs_app_sip") + ModuleLibIncs+=(${LibIconvRoot}) +fi + DEFINES="" # add each modules for app for SRS_MODULE in ${SRS_MODULES[*]}; do @@ -358,6 +368,9 @@ fi if [[ $SRS_SRT == YES ]]; then ModuleLibFiles+=("${LibSRTfile[*]}") fi +if [[ $SRS_GB28181 == YES ]]; then + ModuleLibFiles+=("${LibIconvfile[*]}") +fi # all depends objects MODULE_OBJS="${CORE_OBJS[@]} ${KERNEL_OBJS[@]} ${PROTOCOL_OBJS[@]} ${APP_OBJS[@]} ${SERVER_OBJS[@]}" ModuleLibIncs=(${SRS_OBJS_DIR} ${LibSTRoot} ${LibGperfRoot} ${LibSSLRoot}) diff --git a/trunk/research/players/srs_gb28181.html b/trunk/research/players/srs_gb28181.html index 660b04fbc..b36ca886f 100644 --- a/trunk/research/players/srs_gb28181.html +++ b/trunk/research/players/srs_gb28181.html @@ -122,7 +122,7 @@ 当前通道:
- +
@@ -141,187 +141,17 @@
- -