diff --git a/trunk/3rdparty/srs-bench/Makefile b/trunk/3rdparty/srs-bench/Makefile index 813d1409a..033e09684 100644 --- a/trunk/3rdparty/srs-bench/Makefile +++ b/trunk/3rdparty/srs-bench/Makefile @@ -5,13 +5,13 @@ default: bench test clean: rm -f ./objs/srs_bench ./objs/srs_test -.format.txt: *.go srs/*.go vnet/*.go janus/*.go +.format.txt: *.go srs/*.go vnet/*.go janus/*.go gb28181/*.go gofmt -w . echo "done" > .format.txt bench: ./objs/srs_bench -./objs/srs_bench: .format.txt *.go srs/*.go vnet/*.go janus/*.go Makefile +./objs/srs_bench: .format.txt *.go srs/*.go vnet/*.go janus/*.go gb28181/*.go Makefile go build -mod=vendor -o objs/srs_bench . test: ./objs/srs_test diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 1f765edbb..c84dc7924 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -276,6 +276,7 @@ function parse_user_option() { --with-stream-caster) SRS_STREAM_CASTER=YES ;; --stream-caster) SRS_STREAM_CASTER=$(switch2value $value) ;; + --stream-converter) SRS_STREAM_CASTER=$(switch2value $value) ;; --with-utest) SRS_UTEST=YES ;; --without-utest) SRS_UTEST=NO ;; @@ -474,7 +475,7 @@ fi function apply_detail_options() { # Always enable HTTP utilies. if [ $SRS_HTTP_CORE = NO ]; then SRS_HTTP_CORE=YES; echo -e "${YELLOW}[WARN] Always enable HTTP utilies.${BLACK}"; fi - if [ $SRS_STREAM_CASTER = NO ]; then SRS_STREAM_CASTER=YES; echo -e "${YELLOW}[WARN] Always enable StreamCaster.${BLACK}"; fi + if [ $SRS_STREAM_CASTER = NO ]; then SRS_STREAM_CASTER=YES; echo -e "${YELLOW}[WARN] Always enable StreamConverter.${BLACK}"; fi if [ $SRS_INGEST = NO ]; then SRS_INGEST=YES; echo -e "${YELLOW}[WARN] Always enable Ingest.${BLACK}"; fi if [ $SRS_SSL = NO ]; then SRS_SSL=YES; echo -e "${YELLOW}[WARN] Always enable SSL.${BLACK}"; fi if [ $SRS_STAT = NO ]; then SRS_STAT=YES; echo -e "${YELLOW}[WARN] Always enable Statistic.${BLACK}"; fi @@ -514,7 +515,7 @@ function regenerate_options() { SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --stat=$(value2switch $SRS_STAT)" SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --http-callback=$(value2switch $SRS_HTTP_CALLBACK)" SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --http-server=$(value2switch $SRS_HTTP_SERVER)" - SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --stream-caster=$(value2switch $SRS_STREAM_CASTER)" + SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --stream-converter=$(value2switch $SRS_STREAM_CASTER)" SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --http-api=$(value2switch $SRS_HTTP_API)" SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --utest=$(value2switch $SRS_UTEST)" SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cherrypy=$(value2switch $SRS_CHERRYPY)" @@ -607,7 +608,7 @@ function check_option_conflicts() { # check variable neccessary if [ $SRS_HDS = RESERVED ]; then echo "you must specifies the hds, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_SSL = RESERVED ]; then echo "you must specifies the ssl, see: ./configure --help"; __check_ok=NO; fi - if [ $SRS_STREAM_CASTER = RESERVED ]; then echo "you must specifies the stream-caster, see: ./configure --help"; __check_ok=NO; fi + if [ $SRS_STREAM_CASTER = RESERVED ]; then echo "you must specifies the stream-converter, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_UTEST = RESERVED ]; then echo "you must specifies the utest, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_GPERF = RESERVED ]; then echo "you must specifies the gperf, see: ./configure --help"; __check_ok=NO; fi if [ $SRS_GPERF_MC = RESERVED ]; then echo "you must specifies the gperf-mc, see: ./configure --help"; __check_ok=NO; fi diff --git a/trunk/auto/summary.sh b/trunk/auto/summary.sh index c6535e4a8..51b057c4d 100755 --- a/trunk/auto/summary.sh +++ b/trunk/auto/summary.sh @@ -11,7 +11,7 @@ SrsIngestSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_INGEST = YES ]; then Sr SrsHttpCallbackSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_HTTP_CALLBACK = YES ]; then SrsHttpCallbackSummaryColor="\${GREEN}"; fi SrsHttpServerSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_HTTP_SERVER = YES ]; then SrsHttpServerSummaryColor="\${GREEN}"; fi SrsHttpApiSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_HTTP_API = YES ]; then SrsHttpApiSummaryColor="\${GREEN}"; fi -SrsStreamCasterSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_STREAM_CASTER = YES ]; then SrsStreamCasterSummaryColor="\${GREEN}"; fi +SrsStreamConverterSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_STREAM_CASTER = YES ]; then SrsStreamConverterSummaryColor="\${GREEN}"; fi SrsUtestSummaryColor="\${YELLOW}(Disabled) "; if [ $SRS_UTEST = YES ]; then SrsUtestSummaryColor="\${GREEN}"; fi SrsGperfSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_GPERF = YES ]; then SrsGperfSummaryColor="\${GREEN}"; fi SrsGperfMCSummaryColor="\${GREEN}(Disabled) "; if [ $SRS_GPERF_MC = YES ]; then SrsGperfMCSummaryColor="\${YELLOW}"; fi @@ -45,7 +45,7 @@ echo -e " | ${SrsIngestSummaryColor}About ingester, please read https:// echo -e " | ${SrsHttpCallbackSummaryColor}About http-callback, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/http-callback\${BLACK}" echo -e " | ${SrsHttpServerSummaryColor}Aoubt http-server, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/http-server\${BLACK}" echo -e " | ${SrsHttpApiSummaryColor}About http-api, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/http-api\${BLACK}" -echo -e " | ${SrsStreamCasterSummaryColor}About stream-caster, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/streamer\${BLACK}" +echo -e " | ${SrsStreamConverterSummaryColor}About stream-caster, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/streamer\${BLACK}" echo -e " | ${SrsValgrindSummaryColor}About VALGRIND, please read https://github.com/ossrs/state-threads/issues/2\${BLACK}" echo -e " \${BLACK}+------------------------------------------------------------------------------------\${BLACK}" echo -e "\${GREEN}binaries, please read https://ossrs.net/lts/zh-cn/docs/v4/doc/install\${BLACK}" diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 3a1fb38e5..a8e172872 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -540,67 +540,67 @@ vhost rtc.vhost.srs.com { } ############################################################################################# -# Streamer sections +# Stream converter sections ############################################################################################# -# the streamer cast stream from other protocol to SRS over RTMP. +# The stream converter coverts stream from other protocol to SRS over RTMP. # @see https://github.com/ossrs/srs/tree/develop#stream-architecture -# Push MPEGTS over UDP, see https://github.com/ossrs/srs/issues/250 +# Push MPEGTS over UDP to SRS. stream_caster { - # whether stream caster is enabled. - # default: off - enabled on; - # the caster type of stream, the casters: - # mpegts_over_udp, MPEG-TS over UDP caster. - caster mpegts_over_udp; - # the output rtmp url. - # for mpegts_over_udp caster, the typically output url: + # Whether stream converter is enabled. + # Default: off + enabled on; + # The type of stream converter, could be: + # mpegts_over_udp, push MPEG-TS over UDP and convert to RTMP. + caster mpegts_over_udp; + # The output rtmp url. + # For mpegts_over_udp converter, the typically output url: # rtmp://127.0.0.1/live/livestream - output rtmp://127.0.0.1/live/livestream; - # the listen port for stream caster. - # for mpegts_over_udp caster, listen at udp port. for example, 8935. - listen 8935; + output rtmp://127.0.0.1/live/livestream; + # The listen port for stream converter. + # For mpegts_over_udp converter, listen at udp port. for example, 8935. + listen 8935; } -# Push HTTP-FLV stream, see https://github.com/ossrs/srs/issues/2611 +# Push FLV by HTTP POST to SRS. stream_caster { - # whether stream caster is enabled. - # default: off - enabled on; - # the caster type of stream, the casters: - # flv, FLV over HTTP by POST. - caster flv; - # the output rtmp url. - # for flv caster, the typically output url: + # Whether stream converter is enabled. + # Default: off + enabled on; + # The type of stream converter, could be: + # flv, push FLV by HTTP POST and convert to RTMP. + caster flv; + # The output rtmp url. + # For flv converter, the typically output url: # rtmp://127.0.0.1/[app]/[stream] - # for example, POST to url: + # For example, POST to url: # http://127.0.0.1:8936/live/livestream.flv - # where the [app] is "live" and [stream] is "livestream", output is: + # Where the [app] is "live" and [stream] is "livestream", output is: # rtmp://127.0.0.1/live/livestream - output rtmp://127.0.0.1/[app]/[stream]; - # the listen port for stream caster. - # for flv caster, listen at tcp port. for example, 8936. - listen 8936; + output rtmp://127.0.0.1/[app]/[stream]; + # The listen port for stream converter. + # For flv converter, listen at tcp port. for example, 8936. + listen 8936; } # For GB28181 server, see https://github.com/ossrs/srs/issues/3176 # For SIP specification, see https://www.ietf.org/rfc/rfc3261.html # For GB28181 2016 spec, see https://openstd.samr.gov.cn/bzgk/gb/newGbInfo?hcno=469659DC56B9B8187671FF08748CEC89 stream_caster { - # Whether GB28181 server is enabled. + # Whether stream converter is enabled. # Default: off enabled off; - # The caster type of stream, the casters: - # gb28181, Push GB28181 stream to SRS. + # The type of stream converter, could be: + # gb28181, Push GB28181 stream and convert to RTMP. caster gb28181; # The output rtmp url. - # For gb28181 caster, the typically output url: + # For gb28181 converter, the typically output url: # rtmp://127.0.0.1/live/[stream] # The available variables: # [stream] The video channel codec ID. output rtmp://127.0.0.1/live/[stream]; - # The listen TCP/UDP port for stream caster. - # For gb28181 caster, listen at TCP/UDP port. for example, 9000. + # The listen TCP/UDP port for stream converter. + # For gb28181 converter, listen at TCP/UDP port. for example, 9000. # @remark We always enable bundle for media streams at this port. listen 9000; # SIP server for GB28181. Please note that this is only a demonstrated SIP server, please never use it in your diff --git a/trunk/conf/gb28181.conf b/trunk/conf/gb28181.conf index 7ce7c606c..45d329903 100644 --- a/trunk/conf/gb28181.conf +++ b/trunk/conf/gb28181.conf @@ -12,6 +12,8 @@ stream_caster { sip { enabled on; listen 5060; + # @see https://ossrs.net/lts/zh-cn/docs/v5/doc/gb28181#config-candidate + candidate $CANDIDATE; } } diff --git a/trunk/conf/push.flv.conf b/trunk/conf/push.flv.conf index 985f7a784..568becc0c 100644 --- a/trunk/conf/push.flv.conf +++ b/trunk/conf/push.flv.conf @@ -6,20 +6,40 @@ listen 1935; max_connections 1000; daemon off; srs_log_tank console; -http_server { - enabled on; - listen 8080; - dir ./objs/nginx/html; -} stream_caster { enabled on; caster flv; output rtmp://127.0.0.1/[app]/[stream]; listen 8936; } +http_server { + enabled on; + listen 8080; + dir ./objs/nginx/html; +} +http_api { + enabled on; + listen 1985; +} +rtc_server { + enabled on; + listen 8000; # UDP port + # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate + candidate $CANDIDATE; +} vhost __defaultVhost__ { + rtc { + enabled on; + # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc + rtmp_to_rtc on; + # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp + rtc_to_rtmp on; + } http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; + enabled on; + mount [vhost]/[app]/[stream].flv; + } + hls { + enabled on; } } diff --git a/trunk/conf/push.mpegts.over.udp.conf b/trunk/conf/push.mpegts.over.udp.conf index 594347923..67cdeba37 100644 --- a/trunk/conf/push.mpegts.over.udp.conf +++ b/trunk/conf/push.mpegts.over.udp.conf @@ -18,9 +18,29 @@ http_server { listen 8080; dir ./objs/nginx/html; } +http_api { + enabled on; + listen 1985; +} +rtc_server { + enabled on; + listen 8000; # UDP port + # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate + candidate $CANDIDATE; +} vhost __defaultVhost__ { + rtc { + enabled on; + # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc + rtmp_to_rtc on; + # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp + rtc_to_rtmp on; + } http_remux { - enabled on; - mount [vhost]/[app]/[stream].flv; + enabled on; + mount [vhost]/[app]/[stream].flv; + } + hls { + enabled on; } } diff --git a/trunk/configure b/trunk/configure index 4d8af43f0..1f9596099 100755 --- a/trunk/configure +++ b/trunk/configure @@ -642,9 +642,9 @@ else echo -e "${YELLOW}Warning: HLS is disabled.${BLACK}" fi if [ $SRS_STREAM_CASTER = YES ]; then - echo -e "${YELLOW}Experiment: StreamCaster is enabled.${BLACK}" + echo -e "${YELLOW}Experiment: StreamConverter is enabled.${BLACK}" else - echo -e "${GREEN}Note: StreamCaster is disabled.${BLACK}" + echo -e "${GREEN}Note: StreamConverter is disabled.${BLACK}" fi if [ $SRS_HDS = YES ]; then echo -e "${YELLOW}Experiment: HDS is enabled.${BLACK}" diff --git a/trunk/doc/Architecture.md b/trunk/doc/Architecture.md index 2c111f5c0..3bdf3bd1a 100644 --- a/trunk/doc/Architecture.md +++ b/trunk/doc/Architecture.md @@ -35,8 +35,8 @@ The stream architecture of SRS. +----------------------+ | | | MediaSource(2) | | | | (MPEGTSoverUDP | | | -| HTTP-FLV, --push-+->- StreamCaster(4) -(rtmp)-+-> SRS | -| SRT, | | | +| HTTP-FLV, --push-+->-- Stream(4) ----(rtmp)-+-> SRS | +| SRT, | Converter | | | ......) | | | +----------------------+ | | | FFMPEG --push(srt)--+->- SRTModule(5) ---(rtmp)-+-> SRS | @@ -48,7 +48,7 @@ Remark: 1. Encoder: Encoder pushs RTMP stream to SRS. 1. MediaSource: Supports any media source, ingesting by ffmpeg. 1. Ingester: Forks a ffmpeg(or other tools) to ingest as rtmp to SRS, please read [Ingest][v4_CN_Ingest]. -1. Streamer: Remuxs other protocols to RTMP, please read [Streamer][v4_CN_Streamer]. +1. Stream Converter: Remuxs other protocols to RTMP, please read [Stream Converter][v4_CN_Streamer]. 1. EXEC: Like NGINX-RTMP, EXEC forks external tools for events, please read [ng-exec][v4_CN_NgExec]. 1. SRTModule: A isolate module which run in [hybrid](https://github.com/ossrs/srs/issues/1147#issuecomment-577574883) model. diff --git a/trunk/src/app/srs_app_gb28181.cpp b/trunk/src/app/srs_app_gb28181.cpp index 454f8c205..3d5a27a2e 100644 --- a/trunk/src/app/srs_app_gb28181.cpp +++ b/trunk/src/app/srs_app_gb28181.cpp @@ -1745,7 +1745,7 @@ srs_error_t SrsGbMuxer::write_h264_ipb_frame(char* frame, int frame_size, uint32 // when sps or pps not sent, ignore the packet. if (!h264_sps_pps_sent_) { - return srs_error_new(ERROR_H264_DROP_BEFORE_SPS_PPS, "drop sps/pps"); + return srs_error_new(ERROR_H264_DROP_BEFORE_SPS_PPS, "drop for no sps/pps"); } // 5bits, 7.3.1 NAL unit syntax, @@ -1892,6 +1892,9 @@ srs_error_t SrsGbMuxer::connect() return err; } + // Cleanup the data before connect again. + close(); + string url = srs_string_replace(output_, "[stream]", session_->sip_transport()->resource()->device_id()); srs_trace("Muxer: Convert GB to RTMP %s", url.c_str()); @@ -1915,6 +1918,14 @@ srs_error_t SrsGbMuxer::connect() void SrsGbMuxer::close() { srs_freep(sdk_); + + // Regenerate the AAC sequence header. + aac_specific_config_ = ""; + + // Wait for the next AVC sequence header. + h264_sps_pps_sent_ = false; + h264_sps_ = ""; + h264_pps_ = ""; } SrsSipResponseWriter::SrsSipResponseWriter(ISrsProtocolReadWriter* io) : SrsHttpResponseWriter(io) diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 038392ab4..5595322f2 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -82,8 +82,14 @@ srs_error_t aac_raw_append_adts_header(SrsSharedPtrMessage* shared_audio, SrsFor return err; } + // If no audio RAW frame, or not parsed for no sequence header, drop the packet. + if (format->audio->nb_samples == 0) { + srs_warn("RTC: Drop AAC %d bytes for no sample", shared_audio->size); + return err; + } + if (format->audio->nb_samples != 1) { - return srs_error_new(ERROR_RTC_RTP_MUXER, "adts"); + return srs_error_new(ERROR_RTC_RTP_MUXER, "adts samples=%d", format->audio->nb_samples); } int nb_buf = format->audio->samples[0].size + 7; diff --git a/trunk/src/core/srs_core_version5.hpp b/trunk/src/core/srs_core_version5.hpp index 7dc2419b8..2bbb24a52 100644 --- a/trunk/src/core/srs_core_version5.hpp +++ b/trunk/src/core/srs_core_version5.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 0 -#define VERSION_REVISION 74 +#define VERSION_REVISION 75 #endif diff --git a/trunk/src/kernel/srs_kernel_error.hpp b/trunk/src/kernel/srs_kernel_error.hpp index 785549f90..081198852 100644 --- a/trunk/src/kernel/srs_kernel_error.hpp +++ b/trunk/src/kernel/srs_kernel_error.hpp @@ -268,7 +268,7 @@ XX(ERROR_HTTP_WITH_BODY , 3097, "HttpWithBody", "Failed for HTTP body") /**************************************************/ -/* HTTP/StreamCaster protocol error. */ +/* HTTP/StreamConverter protocol error. */ #define SRS_ERRNO_MAP_HTTP(XX) \ XX(ERROR_HTTP_PATTERN_EMPTY , 4000, "HttpPatternEmpty", "Failed to handle HTTP request for no pattern") \ XX(ERROR_HTTP_PATTERN_DUPLICATED , 4001, "HttpPatternDuplicated", "Failed to handle HTTP request for pattern duplicated") \ diff --git a/trunk/src/utest/srs_utest_config.cpp b/trunk/src/utest/srs_utest_config.cpp index 70bb305aa..8e2e4668d 100644 --- a/trunk/src/utest/srs_utest_config.cpp +++ b/trunk/src/utest/srs_utest_config.cpp @@ -2766,7 +2766,7 @@ VOID TEST(ConfigMainTest, CheckGlobalConfig) } } -VOID TEST(ConfigMainTest, CheckStreamCaster) +VOID TEST(ConfigMainTest, CheckStreamConverter) { srs_error_t err;