diff --git a/trunk/3rdparty/srs-docs/doc/rtmp.md b/trunk/3rdparty/srs-docs/doc/rtmp.md index 18c9a9dff..1aa98dfd0 100644 --- a/trunk/3rdparty/srs-docs/doc/rtmp.md +++ b/trunk/3rdparty/srs-docs/doc/rtmp.md @@ -287,11 +287,20 @@ ffplay rtmps://localhost:1443/live/livestream The RTMPS configuration requires SSL certificate setup similar to other HTTPS services in SRS: ```bash -# the rtmp listen ports, split by space, each listen entry is <[ip:]port> -# for example, 192.168.1.100:1935 10.10.10.100:1935 -# where the ip is optional, default to 0.0.0.0, that is 1935 equals to 0.0.0.0:1935 -# Overwrite by env SRS_LISTEN -listen 1935; +rtmp { + # the rtmp listen ports, split by space, each listen entry is <[ip:]port> + # for example, 192.168.1.100:1935 10.10.10.100:1935 + # where the ip is optional, default to 0.0.0.0, that is 1935 equals to 0.0.0.0:1935 + # Overwrite by env SRS_LISTEN + listen 1935; + # the default chunk size is 128, max is 65536, + # some client does not support chunk size change, + # however, most clients support it and it can improve + # performance about 10%. + # Overwrite by env SRS_CHUNK_SIZE + # default: 60000 + chunk_size 60000; +} # SSL configuration for RTMPS rtmps { diff --git a/trunk/3rdparty/srs-docs/doc/windows.md b/trunk/3rdparty/srs-docs/doc/windows.md index 2738afc30..563f1c197 100644 --- a/trunk/3rdparty/srs-docs/doc/windows.md +++ b/trunk/3rdparty/srs-docs/doc/windows.md @@ -9,79 +9,15 @@ hide_table_of_contents: false SRS 5.0.89+ supports Windows(Cygwin64). -## Build from code +SRS 7.0.60+ remove the supports for Windows, because it's too complex to maintain. -Please install [Cygwin64](https://cygwin.com/install.html). - -Install packages `gcc-g++` `make` `automake` `patch` `pkg-config` `tcl` `cmake`, please see [packages](https://github.com/cygwin/cygwin-install-action#parameters). - -Build SRS with cygwin terminal: +Please use WSL(Windows Subsystem for Linux) which starts a Ubuntu in Windows, +so you can simply build and run SRS by: ```bash -git checkout develop -./configure -make +wsl --install -d Ubuntu-22.04 ``` -If success, there should be a `./objs/srs.exe`, please follow [Getting Started](./getting-started.md) to use it. - -## Install from binary - -For each [release](https://github.com/ossrs/srs/releases) of SRS, from SRS 5.0.89, there is always a binary installer of SRS Windows, normally as the artifact of release, which allows you to install and run SRS very easy. - -Bellow is some examples, note that you should always use the latest [release](https://github.com/ossrs/srs/releases), not the fixed one: - -* [Latest release](https://github.com/ossrs/srs/releases) -* [SRS-Windows-x86_64-5.0.89-setup.exe](https://github.com/ossrs/srs/releases/tag/v5.0.89) -* [SRS-Windows-x86_64-5.0.19-setup.exe](https://github.com/ossrs/srs/releases/tag/v5.0.19) - -> Note: SRS 5.0.89+ supports cygwin pipeline, to build and packge automatically by GitHub Actions. - -![](/img/windows-2022-11-20-001.png) - -Run SRS as administrator: - -![](/img/windows-2022-11-20-002.png) - -Publish to SRS Windows by FFmpeg: - -```bash -ffmpeg -re -i ~/srs/doc/source.flv -c copy -f flv rtmp://win11/live/livestream -``` - -Play by VLC or [srs-player](http://win11:8080/) - -![](/img/windows-2022-11-20-003.png) - -Most of SRS features are available in Windows, for example, RTMP, HTTP-FLV, HLS, WebRTC, HTTP-API, Prometheus Exporter, etc. - -## Package by NSIS - -If want to package by [NSIS](https://nsis.sourceforge.io/Download), please run in cygwin terminal: - -```bash -"/cygdrive/c/Program Files (x86)/NSIS/makensis.exe" \ - /DSRS_VERSION=$(./objs/srs -v 2>&1) \ - /DCYGWIN_DIR="C:\cygwin64" \ - packaging/nsis/srs.nsi -``` - -## Known Issues - -* [Cygwin: Build with SRT is ok, but crash when running. #3251](https://github.com/ossrs/srs/issues/3251) -* [Cygwin: Support address sanitizer for windows. #3252](https://github.com/ossrs/srs/issues/3252) -* [Cygwin: ST stuck when working in multiple threads mode. #3253](https://github.com/ossrs/srs/issues/3253) -* [Cygwin: Support iocp and windows native build. #3256](https://github.com/ossrs/srs/issues/3256) -* [Cygwin: Build srtp with openssl fail for no srtp_aes_icm_ctx_t #3254](https://github.com/ossrs/srs/issues/3254) - -## Links - -ST supports windows: https://github.com/ossrs/state-threads/issues/20 - -Commits about SRS Windows: https://github.com/ossrs/srs-windows/issues/2 - -Windows docker also works for SRS, however, `srs.exe` is more popular for windows developers. - Winlin 2022.11 ![](https://ossrs.io/gif/v1/sls.gif?site=ossrs.io&path=/lts/doc/en/v7/windows) diff --git a/trunk/conf/clion-ingest.conf b/trunk/conf/clion-ingest.conf index 246894d22..a163e957a 100644 --- a/trunk/conf/clion-ingest.conf +++ b/trunk/conf/clion-ingest.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_server { enabled on; listen 8080; diff --git a/trunk/conf/clion-srt.conf b/trunk/conf/clion-srt.conf index 4dd356b1e..deccd90bb 100644 --- a/trunk/conf/clion-srt.conf +++ b/trunk/conf/clion-srt.conf @@ -1,10 +1,14 @@ # SRT config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_api { enabled on; listen 8080; diff --git a/trunk/conf/clion.conf b/trunk/conf/clion.conf index eed8cd2ee..72854b79b 100644 --- a/trunk/conf/clion.conf +++ b/trunk/conf/clion.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_server { enabled on; listen 8080; diff --git a/trunk/conf/compatible.conf b/trunk/conf/compatible.conf index 6b7a2042f..eef10a4f1 100644 --- a/trunk/conf/compatible.conf +++ b/trunk/conf/compatible.conf @@ -1,9 +1,13 @@ -listen 1935; + pid ./objs/srs.pid; srs_log_tank console; srs_log_level trace; max_connections 1000; daemon off; +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/console.conf b/trunk/conf/console.conf index 064e71f17..900f6b936 100644 --- a/trunk/conf/console.conf +++ b/trunk/conf/console.conf @@ -1,10 +1,12 @@ # no-daemon and write log to console config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/console.ipv46.conf b/trunk/conf/console.ipv46.conf index 2e6ff1f34..9e97d9780 100644 --- a/trunk/conf/console.ipv46.conf +++ b/trunk/conf/console.ipv46.conf @@ -1,10 +1,14 @@ # no-daemon and write log to console config for srs. # @see full.conf for detail config. -listen 1935 [::]:1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935 [::]:1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/dash.conf b/trunk/conf/dash.conf index 35859a631..757407c33 100644 --- a/trunk/conf/dash.conf +++ b/trunk/conf/dash.conf @@ -2,10 +2,12 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/sample-dash # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/demo.19350.conf b/trunk/conf/demo.19350.conf index e1bad53b2..f7132c9e1 100644 --- a/trunk/conf/demo.19350.conf +++ b/trunk/conf/demo.19350.conf @@ -1,12 +1,16 @@ # the config for srs demo # @see full.conf for detail config. -listen 19350; max_connections 1000; daemon off; srs_log_tank console; pid ./objs/srs.demo.19350.pid; +# RTMP server configuration +rtmp { + listen 19350; +} + vhost __defaultVhost__ { enabled on; play { diff --git a/trunk/conf/demo.conf b/trunk/conf/demo.conf index 609a47a12..5e88094b1 100644 --- a/trunk/conf/demo.conf +++ b/trunk/conf/demo.conf @@ -1,14 +1,16 @@ # the config for srs demo # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; pid ./objs/srs.demo.pid; -chunk_size 60000; max_connections 2000; +rtmp { + listen 1935; + chunk_size 60000; +} http_api { enabled on; diff --git a/trunk/conf/docker.conf b/trunk/conf/docker.conf index 73a6a172c..0a6f37892 100644 --- a/trunk/conf/docker.conf +++ b/trunk/conf/docker.conf @@ -1,12 +1,14 @@ # docker config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; # For docker, please use docker logs to manage the logs of SRS. # See https://docs.docker.com/config/containers/logging/ srs_log_tank console; daemon off; +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/dvr.mp4.conf b/trunk/conf/dvr.mp4.conf index 67c0c9fb5..cdd737061 100644 --- a/trunk/conf/dvr.mp4.conf +++ b/trunk/conf/dvr.mp4.conf @@ -2,10 +2,12 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/dvr # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} vhost __defaultVhost__ { dvr { enabled on; diff --git a/trunk/conf/dvr.path.conf b/trunk/conf/dvr.path.conf index 06b55f4bc..e9d26e5ea 100644 --- a/trunk/conf/dvr.path.conf +++ b/trunk/conf/dvr.path.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/dvr#custom-path # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { dvr { enabled on; diff --git a/trunk/conf/dvr.segment.conf b/trunk/conf/dvr.segment.conf index 7f6a6f981..f502fc081 100644 --- a/trunk/conf/dvr.segment.conf +++ b/trunk/conf/dvr.segment.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/dvr # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { dvr { enabled on; diff --git a/trunk/conf/dvr.session.conf b/trunk/conf/dvr.session.conf index 73c7df312..85feb11b4 100644 --- a/trunk/conf/dvr.session.conf +++ b/trunk/conf/dvr.session.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/dvr # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { dvr { enabled on; diff --git a/trunk/conf/edge.conf b/trunk/conf/edge.conf index 0e55b99aa..1dc2a3e40 100644 --- a/trunk/conf/edge.conf +++ b/trunk/conf/edge.conf @@ -2,11 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/edge # @see full.conf for detail config. -listen 1935; max_connections 1000; pid objs/edge.pid; daemon off; srs_log_tank console; + +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/edge.token.traverse.conf b/trunk/conf/edge.token.traverse.conf index 4b01608d7..4b856758f 100644 --- a/trunk/conf/edge.token.traverse.conf +++ b/trunk/conf/edge.token.traverse.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/drm # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { cluster { mode remote; diff --git a/trunk/conf/edge2.conf b/trunk/conf/edge2.conf index 3e2b2a041..e32080634 100644 --- a/trunk/conf/edge2.conf +++ b/trunk/conf/edge2.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/edge # @see full.conf for detail config. -listen 1935; max_connections 1000; pid objs/edge2.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { cluster { mode remote; diff --git a/trunk/conf/exec.conf b/trunk/conf/exec.conf index 87893dc81..327435cf5 100644 --- a/trunk/conf/exec.conf +++ b/trunk/conf/exec.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/nginx-exec # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { exec { enabled on; diff --git a/trunk/conf/ffmpeg.transcode.conf b/trunk/conf/ffmpeg.transcode.conf index 24c3cbf91..56ac4e63d 100644 --- a/trunk/conf/ffmpeg.transcode.conf +++ b/trunk/conf/ffmpeg.transcode.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/sample-ffmpeg # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { transcode { enabled on; diff --git a/trunk/conf/force.daemon.conf b/trunk/conf/force.daemon.conf index ebe81562c..4cc70a5fb 100644 --- a/trunk/conf/force.daemon.conf +++ b/trunk/conf/force.daemon.conf @@ -1,6 +1,14 @@ -listen 1935; + max_connections 1000; -daemon on; disable_daemon_for_docker off; srs_log_tank file; + +daemon on; +disable_daemon_for_docker off; +srs_log_tank file; + +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/forward.backend.conf b/trunk/conf/forward.backend.conf index eefc8fc36..f17f5de4a 100644 --- a/trunk/conf/forward.backend.conf +++ b/trunk/conf/forward.backend.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/forward # @see full.conf for detail config. -listen 1935; max_connections 1000; pid ./objs/srs.backend.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { forward { enabled on; diff --git a/trunk/conf/forward.master.conf b/trunk/conf/forward.master.conf index 873ebd651..9ef3933dc 100644 --- a/trunk/conf/forward.master.conf +++ b/trunk/conf/forward.master.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/forward # @see full.conf for detail config. -listen 1935; max_connections 1000; pid ./objs/srs.master.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { forward { enabled on; diff --git a/trunk/conf/forward.slave.conf b/trunk/conf/forward.slave.conf index 9cce1143d..d4b805112 100644 --- a/trunk/conf/forward.slave.conf +++ b/trunk/conf/forward.slave.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/forward # @see full.conf for detail config. -listen 19350; max_connections 1000; pid ./objs/srs.slave.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 19350; +} vhost __defaultVhost__ { } diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 8ee1aee62..d725c2fd3 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -1,6 +1,18 @@ # All configurations for SRS, you can find whatever you want about configuration of SRS. # Note that please never use this file as configuration of SRS, because it's just a full set of configurations. +# +# +# +# +# +# +#******************************************************************************************** +#******************************************************************************************** +# CAUTION: The features below are quite stable and actively maintained. +#******************************************************************************************** +#******************************************************************************************** + ############################################################################################# # Global sections ############################################################################################# @@ -144,22 +156,31 @@ inotify_auto_reload off; # Overwrite by env SRS_AUTO_RELOAD_FOR_DOCKER # default: on auto_reload_for_docker on; +# For tcmalloc, the release rate. +# @see https://gperftools.github.io/gperftools/tcmalloc.html +# @remark Should run configure --with-gperf +# Overwrite by env SRS_TCMALLOC_RELEASE_RATE +# default: 0.8 +tcmalloc_release_rate 0.8; ############################################################################################# # RTMP/RTMPS sections ############################################################################################# -# the rtmp listen ports, split by space, each listen entry is <[ip:]port> -# for example, 192.168.1.100:1935 10.10.10.100:1935 -# where the ip is optional, default to 0.0.0.0, that is 1935 equals to 0.0.0.0:1935 -# Overwrite by env SRS_LISTEN -listen 1935; -# the default chunk size is 128, max is 65536, -# some client does not support chunk size change, -# however, most clients support it and it can improve -# performance about 10%. -# Overwrite by env SRS_CHUNK_SIZE -# default: 60000 -chunk_size 60000; +# the rtmp server section +rtmp { + # the rtmp listen ports, split by space, each listen entry is <[ip:]port> + # for example, 192.168.1.100:1935 10.10.10.100:1935 + # where the ip is optional, default to 0.0.0.0, that is 1935 equals to 0.0.0.0:1935 + # Overwrite by env SRS_LISTEN + listen 1935; + # the default chunk size is 128, max is 65536, + # some client does not support chunk size change, + # however, most clients support it and it can improve + # performance about 10%. + # Overwrite by env SRS_CHUNK_SIZE + # default: 60000 + chunk_size 60000; +} # the rtmps server section rtmps { @@ -182,6 +203,199 @@ rtmps { cert ./conf/server.crt; } +# vhost level config for RTMP/RTMPS. +vhost rtmp.rtmps.vhost.srs.com { + # whether enable min delay mode for vhost. + # for min latency mode: + # 1. disable the publish.mr for vhost. + # 2. use timeout for cond wait for consumer queue. + # @see https://github.com/ossrs/srs/issues/257 + # default: off (for RTMP/HTTP-FLV) + # default: on (for WebRTC) + min_latency off; + + # whether enable the TCP_NODELAY + # if on, set the nodelay of fd by setsockopt + # Overwrite by env SRS_VHOST_TCP_NODELAY for all vhosts. + # default: off + tcp_nodelay off; + + # the default chunk size is 128, max is 65536, + # some client does not support chunk size change, + # vhost chunk size will override the global value. + # Overwrite by env SRS_VHOST_CHUNK_SIZE for all vhosts. + # default: global chunk size. + chunk_size 128; + + # The input ack size, 0 to not set. + # Generally, it's set by the message from peer, + # but for some peer(encoder), it never send message but use a different ack size. + # We can chnage the default ack size in server-side, to send acknowledge message, + # or the encoder maybe blocked after publishing for some time. + # Overwrite by env SRS_VHOST_IN_ACK_SIZE for all vhosts. + # Default: 0 + in_ack_size 0; + + # The output ack size, 0 to not set. + # This is used to notify the peer(player) to send acknowledge to server. + # Overwrite by env SRS_VHOST_OUT_ACK_SIZE for all vhosts. + # Default: 2500000 + out_ack_size 2500000; + + # for play client, both RTMP and other HTTP stream clients, + # for instance, the HTTP FLV stream clients. + play { + # whether cache the last gop. + # if on, cache the last gop and dispatch to client, + # to enabled fast startup for client, client play immediately. + # if off, send the latest media data to client, + # client need to wait for the next Iframe to decode and show the video. + # set to off if requires min delay; + # set to on if requires client fast startup. + # Overwrite by env SRS_VHOST_PLAY_GOP_CACHE for all vhosts. + # default: on + gop_cache off; + + # Limit the max frames in gop cache. It might cause OOM if video stream has no IDR frame, so we limit to N + # frames by default. Note that it's the size of gop cache, including videos, audios and other messages. + # Overwrite by env SRS_VHOST_PLAY_GOP_CACHE_MAX_FRAMES for all vhosts. + # default: 2500 + gop_cache_max_frames 2500; + + # the max live queue length in seconds. + # if the messages in the queue exceed the max length, + # drop the old whole gop. + # Overwrite by env SRS_VHOST_PLAY_QUEUE_LENGTH for all vhosts. + # default: 30 + queue_length 10; + + # about the stream monotonically increasing: + # 1. video timestamp is monotonically increasing, + # 2. audio timestamp is monotonically increasing, + # 3. video and audio timestamp is interleaved/mixed monotonically increasing. + # it's specified by RTMP specification, @see 3. Byte Order, Alignment, and Time Format + # however, some encoder cannot provides this feature, please set this to off to ignore time jitter. + # the time jitter algorithm: + # 1. full, to ensure stream start at zero, and ensure stream monotonically increasing. + # 2. zero, only ensure stream start at zero, ignore timestamp jitter. + # 3. off, disable the time jitter algorithm, like atc. + # @remark for full, correct timestamp only when |delta| > 250ms. + # @remark disabled when atc is on. + # Overwrite by env SRS_VHOST_PLAY_TIME_JITTER for all vhosts. + # default: full + time_jitter full; + # vhost for atc for hls/hds/rtmp backup. + # generally, atc default to off, server delivery rtmp stream to client(flash) timestamp from 0. + # when atc is on, server delivery rtmp stream by absolute time. + # atc is used, for instance, encoder will copy stream to master and slave server, + # server use atc to delivery stream to edge/client, where stream time from master/slave server + # is always the same, client/tools can slice RTMP stream to HLS according to the same time, + # if the time not the same, the HLS stream cannot slice to support system backup. + # + # @see http://www.adobe.com/cn/devnet/adobe-media-server/articles/varnish-sample-for-failover.html + # @see http://www.baidu.com/#wd=hds%20hls%20atc + # + # @remark when atc is on, auto off the time_jitter + # Overwrite by env SRS_VHOST_PLAY_ATC for all vhosts. + # default: off + atc off; + # whether use the interleaved/mixed algorithm to correct the timestamp. + # if on, always ensure the timestamp of audio+video is interleaved/mixed monotonically increase. + # if off, use time_jitter to correct the timestamp if required. + # @remark to use mix_correct, atc should on(or time_jitter should off). + # Overwrite by env SRS_VHOST_PLAY_MIX_CORRECT for all vhosts. + # default: off + mix_correct off; + + # whether enable the auto atc, + # if enabled, detect the bravo_atc="true" in onMetaData packet, + # set atc to on if matched. + # always ignore the onMetaData if atc_auto is off. + # Overwrite by env SRS_VHOST_PLAY_ATC_AUTO for all vhosts. + # default: off + atc_auto off; + + # set the MW(merged-write) latency in ms. + # SRS always set mw on, so we just set the latency value. + # the latency of stream >= mw_latency + mr_latency + # the value recomment is [300, 1800] + # @remark For WebRTC, we enable pass-by-timestamp mode, so we ignore this config. + # default: 350 (For RTMP/HTTP-FLV) + # Overwrite by env SRS_VHOST_PLAY_MW_LATENCY for all vhosts. + # default: 0 (For WebRTC) + mw_latency 350; + + # Set the MW(merged-write) min messages. + # default: 0 (For Real-Time, min_latency on) + # default: 1 (For WebRTC, min_latency off) + # default: 8 (For RTMP/HTTP-FLV, min_latency off). + # Overwrite by env SRS_VHOST_PLAY_MW_MSGS for all vhosts. + mw_msgs 8; + + # the minimal packets send interval in ms, + # used to control the ndiff of stream by srs_rtmp_dump, + # for example, some device can only accept some stream which + # delivery packets in constant interval(not cbr). + # @remark 0 to disable the minimal interval. + # @remark >0 to make the srs to send message one by one. + # @remark user can get the right packets interval in ms by srs_rtmp_dump. + # Overwrite by env SRS_VHOST_PLAY_SEND_MIN_INTERVAL for all vhosts. + # default: 0 + send_min_interval 10.0; + # whether reduce the sequence header, + # for some client which cannot got duplicated sequence header, + # while the sequence header is not changed yet. + # Overwrite by env SRS_VHOST_PLAY_REDUCE_SEQUENCE_HEADER for all vhosts. + # default: off + reduce_sequence_header on; + } + + # the config for FMLE/Flash publisher, which push RTMP to SRS. + publish { + # when enabled the mr, SRS will read as large as possible. + # Overwrite by env SRS_VHOST_PUBLISH_MR for all vhosts. + # default: off + mr off; + # the latency in ms for MR(merged-read), + # the performance+ when latency+, and memory+, + # memory(buffer) = latency * kbps / 8 + # for example, latency=500ms, kbps=3000kbps, each publish connection will consume + # memory = 500 * 3000 / 8 = 187500B = 183KB + # when there are 2500 publisher, the total memory of SRS at least: + # 183KB * 2500 = 446MB + # the recommended value is [300, 2000] + # Overwrite by env SRS_VHOST_PUBLISH_MR_LATENCY for all vhosts. + # default: 350 + mr_latency 350; + + # the 1st packet timeout in ms for encoder. + # Overwrite by env SRS_VHOST_PUBLISH_FIRSTPKT_TIMEOUT for all vhosts. + # default: 20000 + firstpkt_timeout 20000; + # the normal packet timeout in ms for encoder. + # Overwrite by env SRS_VHOST_PUBLISH_NORMAL_TIMEOUT for all vhosts. + # default: 5000 + normal_timeout 7000; + # whether parse the sps when publish stream. + # we can got the resolution of video for stat api. + # but we may failed to cause publish failed. + # @remark If disabled, HLS might never update the sps/pps, it depends on this. + # Overwrite by env SRS_VHOST_PUBLISH_PARSE_SPS for all vhosts. + # default: on + parse_sps on; + # When parsing SPS/PPS, whether try ANNEXB first. If not, try IBMF first, then ANNEXB. + # Overwrite by env SRS_VHOST_PUBLISH_TRY_ANNEXB_FIRST for all vhosts. + # default: on + try_annexb_first on; + # The timeout in seconds to disconnect publisher when idle, which means no players. + # Note that 0 means no timeout or this feature is disabled. + # Note that this feature conflicts with forward, because it disconnect the publisher stream. + # Overwrite by env SRS_VHOST_PUBLISH_KICKOFF_FOR_IDLE for all vhosts. + # default: 0 + kickoff_for_idle 0; + } +} + ############################################################################################# # HTTP sections ############################################################################################# @@ -317,6 +531,119 @@ http_server { } } +# vhost for http flv/aac/mp3 live stream for each vhost. +vhost http.remux.srs.com { + # http flv/mp3/aac/ts stream vhost specified config + http_remux { + # whether enable the http live streaming service for vhost. + # Overwrite by env SRS_VHOST_HTTP_REMUX_ENABLED for all vhosts. + # default: off + enabled on; + # the fast cache for audio stream(mp3/aac), + # to cache more audio and send to client in a time to make android(weixin) happy. + # @remark the flv/ts stream ignore it + # @remark 0 to disable fast cache for http audio stream. + # Overwrite by env SRS_VHOST_HTTP_REMUX_FAST_CACHE for all vhosts. + # default: 0 + fast_cache 30; + # Whether drop packet if not match header. For example, there is has_audio and has video flag in FLV header, if + # this is set to on and has_audio is false, then SRS will drop audio packets when got audio packets. Generally + # it should work, but sometimes you might need SRS to keep packets even when FLV header is set to false. + # See https://github.com/ossrs/srs/issues/939#issuecomment-1348740526 + # TODO: Only support HTTP-FLV stream right now. + # Overwrite by env SRS_VHOST_HTTP_REMUX_DROP_IF_NOT_MATCH for all vhosts. + # Default: on + drop_if_not_match on; + # Whether stream has audio track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header audio flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_AUDIO for all vhosts. + # Default: on + has_audio on; + # Whether stream has video track, used as default value for stream metadata, for example, FLV header contains + # this flag. Sometimes you might want to force the metadata by disable guess_has_av. + # For HTTP-FLV, use this as default value for FLV header video flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_VIDEO for all vhosts. + # Default: on + has_video on; + # Whether guessing stream about audio or video track, used to generate the flags in, such as FLV header. If + # guessing, depends on sequence header and frames in gop cache, so it might be incorrect especially your stream + # is not regular. If not guessing, use the configured default value has_audio and has_video. + # For HTTP-FLV, enable guessing for av header flag, because FLV can't change the header. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, ignore guessing because TS refresh the PMT when codec changed. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 + # Overwrite by env SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV for all vhosts. + # Default: on + guess_has_av on; + # the stream mount for rtmp to remux to live streaming. + # typical mount to [vhost]/[app]/[stream].flv + # the variables: + # [vhost] current vhost for http live stream. + # [app] current app for http live stream. + # [stream] current stream for http live stream. + # @remark the [vhost] is optional, used to mount at specified vhost. + # the extension: + # .flv mount http live flv stream, use default gop cache. + # .ts mount http live ts stream, use default gop cache. + # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. + # .aac mount http live aac stream, ignore video and audio aac codec required. + # for example: + # mount to [vhost]/[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # mount to /[app]/[stream].flv + # access by http://ossrs.net:8080/live/livestream.flv + # or by http://192.168.1.173:8080/live/livestream.flv + # mount to [vhost]/[app]/[stream].mp3 + # access by http://ossrs.net:8080/live/livestream.mp3 + # mount to [vhost]/[app]/[stream].aac + # access by http://ossrs.net:8080/live/livestream.aac + # mount to [vhost]/[app]/[stream].ts + # access by http://ossrs.net:8080/live/livestream.ts + # @remark the port of http is specified by http_server section. + # Overwrite by env SRS_VHOST_HTTP_REMUX_MOUNT for all vhosts. + # default: [vhost]/[app]/[stream].flv + mount [vhost]/[app]/[stream].flv; + } +} + +# vhost for http static and flv vod stream for each vhost. +vhost http.static.srs.com { + # http static vhost specified config + http_static { + # whether enabled the http static service for vhost. + # Overwrite by env SRS_VHOST_HTTP_STATIC_ENABLED for all vhosts. + # default: off + enabled on; + # the url to mount to, + # typical mount to [vhost]/ + # the variables: + # [vhost] current vhost for http server. + # @remark the [vhost] is optional, used to mount at specified vhost. + # @remark the http of __defaultVhost__ will override the http_server section. + # for example: + # mount to [vhost]/ + # access by http://ossrs.net:8080/xxx.html + # mount to [vhost]/hls + # access by http://ossrs.net:8080/hls/xxx.html + # mount to / + # access by http://ossrs.net:8080/xxx.html + # or by http://192.168.1.173:8080/xxx.html + # mount to /hls + # access by http://ossrs.net:8080/hls/xxx.html + # or by http://192.168.1.173:8080/hls/xxx.html + # @remark the port of http is specified by http_server section. + # Overwrite by env SRS_VHOST_HTTP_STATIC_MOUNT for all vhosts. + # default: [vhost]/ + mount [vhost]/hls; + # main dir of vhost, + # to delivery HTTP stream of this vhost. + # default: ./objs/nginx/html + # Overwrite by env SRS_VHOST_HTTP_STATIC_DIR for all vhosts. + dir ./objs/nginx/html/hls; + } +} + ############################################################################################# # SRT server section ############################################################################################# @@ -631,155 +958,8 @@ vhost rtc.vhost.srs.com { } ############################################################################################# -# RTSP server sections +# Circuit breaker sections ############################################################################################# -rtsp_server { - # Whether enable RTSP server. - # Overwrite by env SRS_RTSP_SERVER_ENABLED - # default: off - enabled on; - # The listen port for RTSP server. - # Overwrite by env SRS_RTSP_SERVER_LISTEN - # default: 554 - listen 8554; -} - -vhost rtsp.vhost.srs.com { - rtsp { - # Whether enable RTSP server. - # Overwrite by env SRS_VHOST_RTSP_ENABLED for all vhosts. - # default: off - enabled on; - # Whether transmux RTMP to RTSP. - # Overwrite by env SRS_VHOST_RTSP_RTMP_TO_RTSP for all vhosts. - # default: on - rtmp_to_rtsp on; - } -} - -############################################################################################# -# Stream converter sections -############################################################################################# -# 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 to SRS. -stream_caster { - # 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 converter. - # For mpegts_over_udp converter, listen at udp port. for example, 8935. - listen 8935; -} - -# Push FLV by HTTP POST to SRS. -stream_caster { - # 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: - # http://127.0.0.1:8936/live/livestream.flv - # 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 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 stream converter is enabled. - # Default: off - enabled off; - # The type of stream converter, could be: - # gb28181, Push GB28181 stream and convert to RTMP. - caster gb28181; - # The output rtmp 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 port for stream converter. - # For gb28181 converter, listen at TCP 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 - # online production environment. Instead please use [jsip](https://github.com/usnistgov/jsip) and there is a demo - # [srs-sip](https://github.com/ossrs/srs-sip) also base on it, for more information please see project - # [GB: External SIP](https://ossrs.io/lts/en-us/docs/v7/doc/gb28181#external-sip). - sip { - # Whether enable embedded SIP server. Please disable it if you want to use your own SIP server, see - # [GB: External SIP](https://ossrs.io/lts/en-us/docs/v7/doc/gb28181#external-sip). - # Default: on - enabled on; - # The SIP listen port, for TCP protocol. - # Default: 5060 - listen 5060; - # The SIP or media transport timeout in seconds. - # Default: 60 - timeout 60; - # When media disconnect, the wait time in seconds to re-invite device to publish. During this wait time, device - # might send bye or unregister message(expire is 0), so that we will cancel the re-invite. - # Default: 5 - reinvite 5; - # The exposed candidate IPs, response in SDP connection line. It can be: - # * Retrieve server IP automatically, from all network interfaces. - # $CANDIDATE Read the IP from ENV variable, use * if not set. - # x.x.x.x A specified IP address or DNS name, use * if 0.0.0.0. - # Default: * - candidate *; - } -} - -############################################################################################# -# other global sections -############################################################################################# -# For tcmalloc, the release rate. -# @see https://gperftools.github.io/gperftools/tcmalloc.html -# @remark Should run configure --with-gperf -# Overwrite by env SRS_TCMALLOC_RELEASE_RATE -# default: 0.8 -tcmalloc_release_rate 0.8; - -# Query the latest available version of SRS, write a log to notice user to upgrade. -# @see https://github.com/ossrs/srs/issues/2424 -# @see https://github.com/ossrs/srs/issues/2508 -# Overwrite by env SRS_QUERY_LATEST_VERSION -# Default: off -query_latest_version off; - -# First wait when qlv(query latest version), in seconds. -# Only available when qlv is enabled. -# Overwrite by env SRS_FIRST_WAIT_FOR_QLV -# Default: 300 -first_wait_for_qlv 300; - -# For thread pool. -threads { - # The thread pool manager cycle interval, in seconds. - # Overwrite by env SRS_THREADS_INTERVAL - # Default: 5 - interval 5; -} - # For system circuit breaker. circuit_breaker { # Whether enable the circuit breaker. @@ -818,85 +998,9 @@ circuit_breaker { dying_pulse 5; } -# TencentCloud CLS(Cloud Log Service) config, logging to cloud. -# See https://cloud.tencent.com/document/product/614/11254 -tencentcloud_cls { - # Whether CLS is enabled. - # Overwrite by env SRS_TENCENTCLOUD_CLS_ENABLED - # default: off - enabled off; - # The logging label to category the cluster servers. - # Overwrite by env SRS_TENCENTCLOUD_CLS_LABEL - label cn-beijing; - # The logging tag to category the cluster servers. - # Overwrite by env SRS_TENCENTCLOUD_CLS_TAG - tag cn-edge; - # The SecretId to access CLS service, see https://console.cloud.tencent.com/cam/capi - # Overwrite by env SRS_TENCENTCLOUD_CLS_SECRET_ID - secret_id AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; - # The SecretKey to access CLS service, see https://console.cloud.tencent.com/cam/capi - # Overwrite by env SRS_TENCENTCLOUD_CLS_SECRET_KEY - secret_key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; - # The endpoint of CLS, format as .cls.tencentcs.com. For example: - # ap-guangzhou.cls.tencentcs.com - # Note that tencentyun.com is for internal network, while tencentcs.com is for public internet. - # See https://cloud.tencent.com/document/product/614/18940 - # Overwrite by env SRS_TENCENTCLOUD_CLS_ENDPOINT - endpoint ap-guangzhou.cls.tencentcs.com; - # The topic ID of CLS, see https://cloud.tencent.com/document/product/614/41035 - # Overwrite by env SRS_TENCENTCLOUD_CLS_TOPIC_ID - topic_id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; - # Whether enable logging for each log sending. - # Overwrite by env SRS_TENCENTCLOUD_CLS_DEBUG_LOGGING - # Default: off - debug_logging off; - # Whether enable the heartbeat stat every (5 * heartbeat_ratio)s. - # Overwrite by env SRS_TENCENTCLOUD_CLS_STAT_HEARTBEAT - # Default: on - stat_heartbeat on; - # Setup the heartbeat interval ratio, 1 means 5s, 2 means 10s, etc. - # Overwrite by env SRS_TENCENTCLOUD_CLS_HEARTBEAT_RATIO - # Default: 1 - heartbeat_ratio 1; - # Whether enable the streams stat every (5 * streams_ratio)s. - # Overwrite by env SRS_TENCENTCLOUD_CLS_STAT_STREAMS - # Default: on - stat_streams on; - # Setup the streams interval ratio, 1 means 5s, 2 means 10s, etc. - # Overwrite by env SRS_TENCENTCLOUD_CLS_STREAMS_RATIO - # Default: 1 - streams_ratio 1; -} - -# TencentCloud APM(Application Performance Management) config. -# See https://cloud.tencent.com/document/product/1463/57462 -tencentcloud_apm { - # Whether APM is enabled. - # Overwrite by env SRS_TENCENTCLOUD_APM_ENABLED - # default: off - enabled on; - # The APM team or business system ID, to which spans belongs to. For example, the team is apm-FsOsPOIMl (just an - # example, not available), please get your team from https://console.cloud.tencent.com/apm/monitor/team - # Overwrite by env SRS_TENCENTCLOUD_APM_TEAM - team apm-xxxxxxxxx; - # The APM token for authentication. For example, the token is xzddEaegsxGadEpGEDFx (just an example, not available), - # please get your token from https://console.cloud.tencent.com/apm/monitor/access - # Overwrite by env SRS_TENCENTCLOUD_APM_TOKEN - token xxxxxxxx; - # The APM endpoint. See https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/otlp/otlptrace - # Please note that 4317 is for GRPC/HTTP2, while SRS only support HTTP and the port shoule be 55681. - # Overwrite by env SRS_TENCENTCLOUD_APM_ENDPOINT - endpoint ap-guangzhou.apm.tencentcs.com:55681; - # The service.name of resource. - # Overwrite by env SRS_TENCENTCLOUD_APM_SERVICE_NAME - # Default: srs-server - service_name srs-server; - # Whether enable logging for each log sending. - # Overwrite by env SRS_TENCENTCLOUD_APM_DEBUG_LOGGING - # Default: off - debug_logging off; -} - +############################################################################################# +# Proetheus exporter sections +############################################################################################# # Prometheus exporter config. # See https://prometheus.io/docs/instrumenting/exporters exporter { @@ -918,536 +1022,8 @@ exporter { } ############################################################################################# -# heartbeat/stats sections +# Security and referer sections ############################################################################################# -# heartbeat to api server -# @remark, the ip report to server, is retrieve from system stat, -# which need the config item stats.network. -heartbeat { - # whether heartbeat is enabled. - # Overwrite by env SRS_HEARTBEAT_ENABLED - # default: off - enabled off; - # the interval seconds for heartbeat, - # recommend 0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,3,...,6,9,12,.... - # Overwrite by env SRS_HEARTBEAT_INTERVAL - # default: 9.9 - interval 9.3; - # when startup, srs will heartbeat to this api. - # @remark: must be a restful http api url, where SRS will POST with following data: - # { - # "device_id": "my-srs-device", - # "ip": "192.168.1.100" - # } - # Overwrite by env SRS_HEARTBEAT_URL - # default: http://127.0.0.1:8085/api/v1/servers - url http://127.0.0.1:8085/api/v1/servers; - # the id of device. - # Overwrite by env SRS_HEARTBEAT_DEVICE_ID - device_id "my-srs-device"; - # whether report with summaries - # if on, put /api/v1/summaries to the request data: - # { - # "summaries": summaries object. - # } - # @remark: optional config. - # Overwrite by env SRS_HEARTBEAT_SUMMARIES - # default: off - summaries off; - # Whether report with listen ports. - # if on, request with the ports of SRS: - # { - # "rtmp": ["1935"], "http": ["8080"], "api": ["1985"], "srt": ["10080"], "rtc": ["8000"] - # } - # Overwrite by env SRS_HEARTBEAT_PORTS - # default: off - ports off; -} - -# system statistics section. -# the main cycle will retrieve the system stat, -# for example, the cpu/mem/network/disk-io data, -# the http api, for instance, /api/v1/summaries will show these data. -# @remark the heartbeat depends on the network, -# for example, the eth0 maybe the device which index is 0. -stats { - # Whether enable the stat of system resources. - # Default: on - enabled on; - # the index of device ip. - # we may retrieve more than one network device. - # default: 0 - network 0; - # the device name to stat the disk iops. - # ignore the device of /proc/diskstats if not configured. - disk sda sdb xvda xvdb; -} - -############################################################################################# -# RTMP/HTTP VHOST sections -############################################################################################# -# vhost list, the __defaultVhost__ is the default vhost -# for example, user use ip to access the stream: rtmp://192.168.1.2/live/livestream. -# for which cannot identify the required vhost. -vhost __defaultVhost__ { -} - -# the vhost scope configs. -vhost scope.vhost.srs.com { - # whether the vhost is enabled. - # if off, all request access denied. - # default: on - enabled off; - - # whether enable min delay mode for vhost. - # for min latency mode: - # 1. disable the publish.mr for vhost. - # 2. use timeout for cond wait for consumer queue. - # @see https://github.com/ossrs/srs/issues/257 - # default: off (for RTMP/HTTP-FLV) - # default: on (for WebRTC) - min_latency off; - - # whether enable the TCP_NODELAY - # if on, set the nodelay of fd by setsockopt - # Overwrite by env SRS_VHOST_TCP_NODELAY for all vhosts. - # default: off - tcp_nodelay off; - - # the default chunk size is 128, max is 65536, - # some client does not support chunk size change, - # vhost chunk size will override the global value. - # Overwrite by env SRS_VHOST_CHUNK_SIZE for all vhosts. - # default: global chunk size. - chunk_size 128; - - # The input ack size, 0 to not set. - # Generally, it's set by the message from peer, - # but for some peer(encoder), it never send message but use a different ack size. - # We can chnage the default ack size in server-side, to send acknowledge message, - # or the encoder maybe blocked after publishing for some time. - # Overwrite by env SRS_VHOST_IN_ACK_SIZE for all vhosts. - # Default: 0 - in_ack_size 0; - - # The output ack size, 0 to not set. - # This is used to notify the peer(player) to send acknowledge to server. - # Overwrite by env SRS_VHOST_OUT_ACK_SIZE for all vhosts. - # Default: 2500000 - out_ack_size 2500000; -} - -# set the chunk size of vhost. -vhost chunksize.srs.com { - # @see scope.vhost.srs.com - chunk_size 128; -} - -# the vhost disabled. -vhost removed.srs.com { - # @see scope.vhost.srs.com - enabled off; -} - -# vhost for stream cluster for RTMP/FLV -vhost cluster.srs.com { - # The config for cluster. - cluster { - # The cluster mode, local or remote. - # local: It's an origin server, serve streams itself. - # remote: It's an edge server, fetch or push stream to origin server. - # default: local - mode remote; - - # For edge(mode remote), user must specifies the origin server - # format as: [:port] - # @remark user can specifies multiple origin for error backup, by space, - # for example, 192.168.1.100:1935 192.168.1.101:1935 192.168.1.102:1935 - origin 127.0.0.1:1935 localhost:1935; - - # For edge(mode remote), whether open the token traverse mode, - # if token traverse on, all connections of edge will forward to origin to check(auth), - # it's very important for the edge to do the token auth. - # the better way is use http callback to do the token auth by the edge, - # but if user prefer origin check(auth), the token_traverse if better solution. - # default: off - token_traverse off; - - # For edge(mode remote), the vhost to transform for edge, - # to fetch from the specified vhost at origin, - # if not specified, use the current vhost of edge in origin, the variable [vhost]. - # default: [vhost] - vhost same.edge.srs.com; - - # For edge(mode remote), when upnode(forward to, edge push to, edge pull from) is srs, - # it's strongly recommend to open the debug_srs_upnode, - # when connect to upnode, it will take the debug info, - # for example, the id, source id, pid. - # please see https://ossrs.io/lts/en-us/docs/v7/doc/log - # default: on - debug_srs_upnode on; - - # For origin(mode local) cluster, turn on the cluster. - # @remark Origin cluster only supports RTMP, use Edge to transmux RTMP to FLV. - # default: off - # TODO: FIXME: Support reload. - origin_cluster off; - - # For origin (mode local) cluster, the co-worker's HTTP APIs. - # This origin will connect to co-workers and communicate with them. - # please see https://ossrs.io/lts/en-us/docs/v7/doc/origin-cluster#legacy - # TODO: FIXME: Support reload. - coworkers 127.0.0.1:9091 127.0.0.1:9092; - - # The protocol to connect to origin. - # rtmp, Connect origin by RTMP - # flv, Connect origin by HTTP-FLV - # flvs, Connect origin by HTTPS-FLV - # Default: rtmp - protocol rtmp; - - # Whether follow client protocol to connect to origin. - # @remark The FLV might use different signature(in query string) to RTMP. - # Default: off - follow_client off; - } -} - -# vhost for edge, edge and origin is the same vhost -vhost same.edge.srs.com { - # @see cluster.srs.com - cluster { - mode remote; - origin 127.0.0.1:1935 localhost:1935; - token_traverse off; - } -} - -# vhost for edge, edge transform vhost to fetch from another vhost. -vhost transform.edge.srs.com { - # @see cluster.srs.com - cluster { - mode remote; - origin 127.0.0.1:1935; - vhost same.edge.srs.com; - } -} - -# the vhost for srs debug info, whether send args in connect(tcUrl). -vhost debug.srs.com { - # @see cluster.srs.com - cluster { - debug_srs_upnode on; - } -} - -# the vhost which forward publish streams. -vhost same.vhost.forward.srs.com { - # forward stream to other servers. - forward { - # whether enable the forward. - # default: off - enabled on; - # forward all publish stream to the specified server. - # this used to split/forward the current stream for cluster active-standby, - # active-active for cdn to build high available fault tolerance system. - # format: {ip}:{port} {ip_N}:{port_N} - destination 127.0.0.1:1936 127.0.0.1:1937; - - # when client(encoder) publish to vhost/app/stream, call the hook in creating backend forwarder. - # the request in the POST data string is a object encode by json: - # { - # "action": "on_forward", - # "server_id": "vid-k21d7y2", - # "client_id": "9o7g1330", - # "ip": "127.0.0.1", - # "vhost": "__defaultVhost__", - # "app": "live", - # "tcUrl": "rtmp://127.0.0.1:1935/live", - # "stream": "livestream", - # "param": "" - # } - # if valid, the hook must return HTTP code 200(Status OK) and response - # an int value specifies the error code(0 corresponding to success): - # { - # "code": 0, - # "data": { - # "urls":[ - # "rtmp://127.0.0.1:19350/test/teststream" - # ] - # } - # } - # PS: you can transform params to backend service, such as: - # { "param": "?forward=rtmp://127.0.0.1:19351/test/livestream" } - # then backend return forward's url in response. - # if backend return empty urls, destanition is still disabled. - # only support one api hook, format: - # backend http://xxx/api0 - backend http://127.0.0.1:8085/api/v1/forward; - } -} - -# the play specified configs -vhost play.srs.com { - # for play client, both RTMP and other stream clients, - # for instance, the HTTP FLV stream clients. - play { - # whether cache the last gop. - # if on, cache the last gop and dispatch to client, - # to enabled fast startup for client, client play immediately. - # if off, send the latest media data to client, - # client need to wait for the next Iframe to decode and show the video. - # set to off if requires min delay; - # set to on if requires client fast startup. - # Overwrite by env SRS_VHOST_PLAY_GOP_CACHE for all vhosts. - # default: on - gop_cache off; - - # Limit the max frames in gop cache. It might cause OOM if video stream has no IDR frame, so we limit to N - # frames by default. Note that it's the size of gop cache, including videos, audios and other messages. - # Overwrite by env SRS_VHOST_PLAY_GOP_CACHE_MAX_FRAMES for all vhosts. - # default: 2500 - gop_cache_max_frames 2500; - - # the max live queue length in seconds. - # if the messages in the queue exceed the max length, - # drop the old whole gop. - # Overwrite by env SRS_VHOST_PLAY_QUEUE_LENGTH for all vhosts. - # default: 30 - queue_length 10; - - # about the stream monotonically increasing: - # 1. video timestamp is monotonically increasing, - # 2. audio timestamp is monotonically increasing, - # 3. video and audio timestamp is interleaved/mixed monotonically increasing. - # it's specified by RTMP specification, @see 3. Byte Order, Alignment, and Time Format - # however, some encoder cannot provides this feature, please set this to off to ignore time jitter. - # the time jitter algorithm: - # 1. full, to ensure stream start at zero, and ensure stream monotonically increasing. - # 2. zero, only ensure stream start at zero, ignore timestamp jitter. - # 3. off, disable the time jitter algorithm, like atc. - # @remark for full, correct timestamp only when |delta| > 250ms. - # @remark disabled when atc is on. - # Overwrite by env SRS_VHOST_PLAY_TIME_JITTER for all vhosts. - # default: full - time_jitter full; - # vhost for atc for hls/hds/rtmp backup. - # generally, atc default to off, server delivery rtmp stream to client(flash) timestamp from 0. - # when atc is on, server delivery rtmp stream by absolute time. - # atc is used, for instance, encoder will copy stream to master and slave server, - # server use atc to delivery stream to edge/client, where stream time from master/slave server - # is always the same, client/tools can slice RTMP stream to HLS according to the same time, - # if the time not the same, the HLS stream cannot slice to support system backup. - # - # @see http://www.adobe.com/cn/devnet/adobe-media-server/articles/varnish-sample-for-failover.html - # @see http://www.baidu.com/#wd=hds%20hls%20atc - # - # @remark when atc is on, auto off the time_jitter - # Overwrite by env SRS_VHOST_PLAY_ATC for all vhosts. - # default: off - atc off; - # whether use the interleaved/mixed algorithm to correct the timestamp. - # if on, always ensure the timestamp of audio+video is interleaved/mixed monotonically increase. - # if off, use time_jitter to correct the timestamp if required. - # @remark to use mix_correct, atc should on(or time_jitter should off). - # Overwrite by env SRS_VHOST_PLAY_MIX_CORRECT for all vhosts. - # default: off - mix_correct off; - - # whether enable the auto atc, - # if enabled, detect the bravo_atc="true" in onMetaData packet, - # set atc to on if matched. - # always ignore the onMetaData if atc_auto is off. - # Overwrite by env SRS_VHOST_PLAY_ATC_AUTO for all vhosts. - # default: off - atc_auto off; - - # set the MW(merged-write) latency in ms. - # SRS always set mw on, so we just set the latency value. - # the latency of stream >= mw_latency + mr_latency - # the value recomment is [300, 1800] - # @remark For WebRTC, we enable pass-by-timestamp mode, so we ignore this config. - # default: 350 (For RTMP/HTTP-FLV) - # Overwrite by env SRS_VHOST_PLAY_MW_LATENCY for all vhosts. - # default: 0 (For WebRTC) - mw_latency 350; - - # Set the MW(merged-write) min messages. - # default: 0 (For Real-Time, min_latency on) - # default: 1 (For WebRTC, min_latency off) - # default: 8 (For RTMP/HTTP-FLV, min_latency off). - # Overwrite by env SRS_VHOST_PLAY_MW_MSGS for all vhosts. - mw_msgs 8; - - # the minimal packets send interval in ms, - # used to control the ndiff of stream by srs_rtmp_dump, - # for example, some device can only accept some stream which - # delivery packets in constant interval(not cbr). - # @remark 0 to disable the minimal interval. - # @remark >0 to make the srs to send message one by one. - # @remark user can get the right packets interval in ms by srs_rtmp_dump. - # Overwrite by env SRS_VHOST_PLAY_SEND_MIN_INTERVAL for all vhosts. - # default: 0 - send_min_interval 10.0; - # whether reduce the sequence header, - # for some client which cannot got duplicated sequence header, - # while the sequence header is not changed yet. - # Overwrite by env SRS_VHOST_PLAY_REDUCE_SEQUENCE_HEADER for all vhosts. - # default: off - reduce_sequence_header on; - } -} - -# vhost for time jitter -vhost jitter.srs.com { - # @see play.srs.com - # to use time_jitter full, the default config. - play { - } - # to use mix_correct. - play { - time_jitter off; - mix_correct on; - } - play { - atc on; - mix_correct on; - } - # to use atc - play { - atc on; - } -} - -# vhost for atc. -vhost atc.srs.com { - # @see play.srs.com - play { - atc on; - atc_auto on; - } -} - -# the MR(merged-read) setting for publisher. -# the MW(merged-write) settings for player. -vhost mrw.srs.com { - # @see scope.vhost.srs.com - min_latency off; - - # @see play.srs.com - play { - mw_latency 350; - mw_msgs 8; - } - - # @see publish.srs.com - publish { - mr on; - mr_latency 350; - } -} - -# the vhost for min delay, do not cache any stream. -vhost min.delay.com { - # @see scope.vhost.srs.com - min_latency on; - # @see scope.vhost.srs.com - tcp_nodelay on; - - # @see play.srs.com - play { - mw_latency 100; - mw_msgs 4; - gop_cache off; - queue_length 10; - } - - # @see publish.srs.com - publish { - mr off; - } -} - -# whether disable the sps parse, for the resolution of video. -vhost no.parse.sps.com { - # @see publish.srs.com - publish { - parse_sps on; - } -} - -# the vhost to control the stream delivery feature -vhost stream.control.com { - # @see scope.vhost.srs.com - min_latency on; - # @see scope.vhost.srs.com - tcp_nodelay on; - - # @see play.srs.com - play { - mw_latency 100; - mw_msgs 4; - queue_length 10; - send_min_interval 10.0; - reduce_sequence_header on; - } - - # @see publish.srs.com - publish { - mr off; - firstpkt_timeout 20000; - normal_timeout 7000; - } -} - -# the publish specified configs -vhost publish.srs.com { - # the config for FMLE/Flash publisher, which push RTMP to SRS. - publish { - # when enabled the mr, SRS will read as large as possible. - # Overwrite by env SRS_VHOST_PUBLISH_MR for all vhosts. - # default: off - mr off; - # the latency in ms for MR(merged-read), - # the performance+ when latency+, and memory+, - # memory(buffer) = latency * kbps / 8 - # for example, latency=500ms, kbps=3000kbps, each publish connection will consume - # memory = 500 * 3000 / 8 = 187500B = 183KB - # when there are 2500 publisher, the total memory of SRS at least: - # 183KB * 2500 = 446MB - # the recommended value is [300, 2000] - # Overwrite by env SRS_VHOST_PUBLISH_MR_LATENCY for all vhosts. - # default: 350 - mr_latency 350; - - # the 1st packet timeout in ms for encoder. - # Overwrite by env SRS_VHOST_PUBLISH_FIRSTPKT_TIMEOUT for all vhosts. - # default: 20000 - firstpkt_timeout 20000; - # the normal packet timeout in ms for encoder. - # Overwrite by env SRS_VHOST_PUBLISH_NORMAL_TIMEOUT for all vhosts. - # default: 5000 - normal_timeout 7000; - # whether parse the sps when publish stream. - # we can got the resolution of video for stat api. - # but we may failed to cause publish failed. - # @remark If disabled, HLS might never update the sps/pps, it depends on this. - # Overwrite by env SRS_VHOST_PUBLISH_PARSE_SPS for all vhosts. - # default: on - parse_sps on; - # When parsing SPS/PPS, whether try ANNEXB first. If not, try IBMF first, then ANNEXB. - # Overwrite by env SRS_VHOST_PUBLISH_TRY_ANNEXB_FIRST for all vhosts. - # default: on - try_annexb_first on; - # The timeout in seconds to disconnect publisher when idle, which means no players. - # Note that 0 means no timeout or this feature is disabled. - # Note that this feature conflicts with forward, because it disconnect the publisher stream. - # Overwrite by env SRS_VHOST_PUBLISH_KICKOFF_FOR_IDLE for all vhosts. - # default: 0 - kickoff_for_idle 0; - } -} - # the vhost for anti-suck. vhost refer.anti_suck.com { # refer hotlink-denial. @@ -1505,119 +1081,9 @@ vhost security.srs.com { } } -# vhost for http static and flv vod stream for each vhost. -vhost http.static.srs.com { - # http static vhost specified config - http_static { - # whether enabled the http static service for vhost. - # Overwrite by env SRS_VHOST_HTTP_STATIC_ENABLED for all vhosts. - # default: off - enabled on; - # the url to mount to, - # typical mount to [vhost]/ - # the variables: - # [vhost] current vhost for http server. - # @remark the [vhost] is optional, used to mount at specified vhost. - # @remark the http of __defaultVhost__ will override the http_server section. - # for example: - # mount to [vhost]/ - # access by http://ossrs.net:8080/xxx.html - # mount to [vhost]/hls - # access by http://ossrs.net:8080/hls/xxx.html - # mount to / - # access by http://ossrs.net:8080/xxx.html - # or by http://192.168.1.173:8080/xxx.html - # mount to /hls - # access by http://ossrs.net:8080/hls/xxx.html - # or by http://192.168.1.173:8080/hls/xxx.html - # @remark the port of http is specified by http_server section. - # Overwrite by env SRS_VHOST_HTTP_STATIC_MOUNT for all vhosts. - # default: [vhost]/ - mount [vhost]/hls; - # main dir of vhost, - # to delivery HTTP stream of this vhost. - # default: ./objs/nginx/html - # Overwrite by env SRS_VHOST_HTTP_STATIC_DIR for all vhosts. - dir ./objs/nginx/html/hls; - } -} - -# vhost for http flv/aac/mp3 live stream for each vhost. -vhost http.remux.srs.com { - # http flv/mp3/aac/ts stream vhost specified config - http_remux { - # whether enable the http live streaming service for vhost. - # Overwrite by env SRS_VHOST_HTTP_REMUX_ENABLED for all vhosts. - # default: off - enabled on; - # the fast cache for audio stream(mp3/aac), - # to cache more audio and send to client in a time to make android(weixin) happy. - # @remark the flv/ts stream ignore it - # @remark 0 to disable fast cache for http audio stream. - # Overwrite by env SRS_VHOST_HTTP_REMUX_FAST_CACHE for all vhosts. - # default: 0 - fast_cache 30; - # Whether drop packet if not match header. For example, there is has_audio and has video flag in FLV header, if - # this is set to on and has_audio is false, then SRS will drop audio packets when got audio packets. Generally - # it should work, but sometimes you might need SRS to keep packets even when FLV header is set to false. - # See https://github.com/ossrs/srs/issues/939#issuecomment-1348740526 - # TODO: Only support HTTP-FLV stream right now. - # Overwrite by env SRS_VHOST_HTTP_REMUX_DROP_IF_NOT_MATCH for all vhosts. - # Default: on - drop_if_not_match on; - # Whether stream has audio track, used as default value for stream metadata, for example, FLV header contains - # this flag. Sometimes you might want to force the metadata by disable guess_has_av. - # For HTTP-FLV, use this as default value for FLV header audio flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 - # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 - # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_AUDIO for all vhosts. - # Default: on - has_audio on; - # Whether stream has video track, used as default value for stream metadata, for example, FLV header contains - # this flag. Sometimes you might want to force the metadata by disable guess_has_av. - # For HTTP-FLV, use this as default value for FLV header video flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 - # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 - # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_VIDEO for all vhosts. - # Default: on - has_video on; - # Whether guessing stream about audio or video track, used to generate the flags in, such as FLV header. If - # guessing, depends on sequence header and frames in gop cache, so it might be incorrect especially your stream - # is not regular. If not guessing, use the configured default value has_audio and has_video. - # For HTTP-FLV, enable guessing for av header flag, because FLV can't change the header. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 - # For HTTP-TS, ignore guessing because TS refresh the PMT when codec changed. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 - # Overwrite by env SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV for all vhosts. - # Default: on - guess_has_av on; - # the stream mount for rtmp to remux to live streaming. - # typical mount to [vhost]/[app]/[stream].flv - # the variables: - # [vhost] current vhost for http live stream. - # [app] current app for http live stream. - # [stream] current stream for http live stream. - # @remark the [vhost] is optional, used to mount at specified vhost. - # the extension: - # .flv mount http live flv stream, use default gop cache. - # .ts mount http live ts stream, use default gop cache. - # .mp3 mount http live mp3 stream, ignore video and audio mp3 codec required. - # .aac mount http live aac stream, ignore video and audio aac codec required. - # for example: - # mount to [vhost]/[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # mount to /[app]/[stream].flv - # access by http://ossrs.net:8080/live/livestream.flv - # or by http://192.168.1.173:8080/live/livestream.flv - # mount to [vhost]/[app]/[stream].mp3 - # access by http://ossrs.net:8080/live/livestream.mp3 - # mount to [vhost]/[app]/[stream].aac - # access by http://ossrs.net:8080/live/livestream.aac - # mount to [vhost]/[app]/[stream].ts - # access by http://ossrs.net:8080/live/livestream.ts - # @remark the port of http is specified by http_server section. - # Overwrite by env SRS_VHOST_HTTP_REMUX_MOUNT for all vhosts. - # default: [vhost]/[app]/[stream].flv - mount [vhost]/[app]/[stream].flv; - } -} - +############################################################################################# +# HTTP callback sections +############################################################################################# # the http hook callback vhost, srs will invoke the hooks for specified events. vhost hooks.callback.srs.com { http_hooks { @@ -1750,39 +1216,9 @@ vhost hooks.callback.srs.com { } } -# the vhost for exec, fork process when publish stream. -vhost exec.srs.com { - # the exec used to fork process when got some event. - exec { - # whether enable the exec. - # default: off. - enabled off; - # when publish stream, exec the process with variables: - # [vhost] the input stream vhost. - # [port] the input stream port. - # [app] the input stream app. - # [stream] the input stream name. - # [engine] the transcode engine name. - # other variables for exec only: - # [url] the rtmp url which trigger the publish. - # [tcUrl] the client request tcUrl. - # [swfUrl] the client request swfUrl. - # [pageUrl] the client request pageUrl. - # we also support datetime variables. - # [2006], replace this const to current year. - # [01], replace this const to current month. - # [02], replace this const to current date. - # [15], replace this const to current hour. - # [04], replace this const to current minute. - # [05], replace this const to current second. - # [999], replace this const to current millisecond. - # [timestamp],replace this const to current UNIX timestamp in ms. - # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]" - # @remark empty to ignore this exec. - publish ./objs/ffmpeg/bin/ffmpeg -f flv -i [url] -c copy -y ./[stream].flv; - } -} - +############################################################################################# +# DASH streaming sections +############################################################################################# # The vhost for MPEG-DASH. vhost dash.srs.com { dash { @@ -1833,6 +1269,9 @@ vhost dash.srs.com { } } +############################################################################################# +# HLS streaming sections +############################################################################################# # the vhost with hls specified. vhost hls.srs.com { hls { @@ -2071,38 +1510,261 @@ vhost hls.srs.com { # @see https://ossrs.io/lts/en-us/docs/v7/doc/hls#on-hls-notify } } -# the vhost with hls disabled. -vhost no-hls.srs.com { - hls { - # whether the hls is enabled. - # if off, do not write hls(ts and m3u8) when publish. - # default: off - enabled off; - } + +############################################################################################# +# RTMP/HTTP VHOST sections +############################################################################################# +# vhost list, the __defaultVhost__ is the default vhost +# for example, user use ip to access the stream: rtmp://192.168.1.2/live/livestream. +# for which cannot identify the required vhost. +vhost __defaultVhost__ { + # whether the vhost is enabled. + # if off, all request access denied. + # default: on + enabled off; } -# the vhost with adobe hds -vhost hds.srs.com { - hds { - # whether hds enabled - # Overwrite by env SRS_VHOST_HDS_ENABLED for all vhosts. +# +# +# +# +# +# +#******************************************************************************************** +#******************************************************************************************** +# CAUTION: The features below are experimental and new, so use it cautiously. +#******************************************************************************************** +#******************************************************************************************** + +############################################################################################# +# RTSP server sections +############################################################################################# +rtsp_server { + # Whether enable RTSP server. + # Overwrite by env SRS_RTSP_SERVER_ENABLED + # default: off + enabled on; + # The listen port for RTSP server. + # Overwrite by env SRS_RTSP_SERVER_LISTEN + # default: 554 + listen 8554; +} + +vhost rtsp.vhost.srs.com { + rtsp { + # Whether enable RTSP server. + # Overwrite by env SRS_VHOST_RTSP_ENABLED for all vhosts. # default: off enabled on; - # the hds fragment in seconds. - # Overwrite by env SRS_VHOST_HDS_HDS_FRAGMENT for all vhosts. - # default: 10 - hds_fragment 10; - # the hds window in seconds, erase the segment when exceed the window. - # Overwrite by env SRS_VHOST_HDS_HDS_WINDOW for all vhosts. - # default: 60 - hds_window 60; - # the path to store the hds files. - # Overwrite by env SRS_VHOST_HDS_HDS_PATH for all vhosts. - # default: ./objs/nginx/html - hds_path ./objs/nginx/html; + # Whether transmux RTMP to RTSP. + # Overwrite by env SRS_VHOST_RTSP_RTMP_TO_RTSP for all vhosts. + # default: on + rtmp_to_rtsp on; } } +############################################################################################# +# In the config file, the include file can be anywhere in order to enhance the readability +# of the config file and enable the reuse of part of the config file. +# When using include files, make sure that the included files themselves have the correct SRS syntax, +# that is, config directives and blocks, and then specify the paths to these files. +# +# @see https://github.com/ossrs/srs/issues/1399 +############################################################################################# +include ./conf/include.vhost.conf; + +############################################################################################# +# Stream converter sections +############################################################################################# +# 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 to SRS. +stream_caster { + # 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 converter. + # For mpegts_over_udp converter, listen at udp port. for example, 8935. + listen 8935; +} + +# Push FLV by HTTP POST to SRS. +stream_caster { + # 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: + # http://127.0.0.1:8936/live/livestream.flv + # 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 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 stream converter is enabled. + # Default: off + enabled off; + # The type of stream converter, could be: + # gb28181, Push GB28181 stream and convert to RTMP. + caster gb28181; + # The output rtmp 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 port for stream converter. + # For gb28181 converter, listen at TCP 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 + # online production environment. Instead please use [jsip](https://github.com/usnistgov/jsip) and there is a demo + # [srs-sip](https://github.com/ossrs/srs-sip) also base on it, for more information please see project + # [GB: External SIP](https://ossrs.io/lts/en-us/docs/v7/doc/gb28181#external-sip). + sip { + # Whether enable embedded SIP server. Please disable it if you want to use your own SIP server, see + # [GB: External SIP](https://ossrs.io/lts/en-us/docs/v7/doc/gb28181#external-sip). + # Default: on + enabled on; + # The SIP listen port, for TCP protocol. + # Default: 5060 + listen 5060; + # The SIP or media transport timeout in seconds. + # Default: 60 + timeout 60; + # When media disconnect, the wait time in seconds to re-invite device to publish. During this wait time, device + # might send bye or unregister message(expire is 0), so that we will cancel the re-invite. + # Default: 5 + reinvite 5; + # The exposed candidate IPs, response in SDP connection line. It can be: + # * Retrieve server IP automatically, from all network interfaces. + # $CANDIDATE Read the IP from ENV variable, use * if not set. + # x.x.x.x A specified IP address or DNS name, use * if 0.0.0.0. + # Default: * + candidate *; + } +} + +# +# +# +# +# +# +#******************************************************************************************** +#******************************************************************************************** +# CAUTION: The features below are not recommanded, so you should use other replacement tools instead. +#******************************************************************************************** +#******************************************************************************************** + +############################################################################################# +# Forward sections. You should use FFmpeg to forward stream. +############################################################################################# +# the vhost which forward publish streams. +vhost same.vhost.forward.srs.com { + # forward stream to other servers. + forward { + # whether enable the forward. + # default: off + enabled on; + # forward all publish stream to the specified server. + # this used to split/forward the current stream for cluster active-standby, + # active-active for cdn to build high available fault tolerance system. + # format: {ip}:{port} {ip_N}:{port_N} + destination 127.0.0.1:1936 127.0.0.1:1937; + + # when client(encoder) publish to vhost/app/stream, call the hook in creating backend forwarder. + # the request in the POST data string is a object encode by json: + # { + # "action": "on_forward", + # "server_id": "vid-k21d7y2", + # "client_id": "9o7g1330", + # "ip": "127.0.0.1", + # "vhost": "__defaultVhost__", + # "app": "live", + # "tcUrl": "rtmp://127.0.0.1:1935/live", + # "stream": "livestream", + # "param": "" + # } + # if valid, the hook must return HTTP code 200(Status OK) and response + # an int value specifies the error code(0 corresponding to success): + # { + # "code": 0, + # "data": { + # "urls":[ + # "rtmp://127.0.0.1:19350/test/teststream" + # ] + # } + # } + # PS: you can transform params to backend service, such as: + # { "param": "?forward=rtmp://127.0.0.1:19351/test/livestream" } + # then backend return forward's url in response. + # if backend return empty urls, destanition is still disabled. + # only support one api hook, format: + # backend http://xxx/api0 + backend http://127.0.0.1:8085/api/v1/forward; + } +} + +############################################################################################# +# Exec command sections You should use http_hooks and FFmpeg to exec command. +############################################################################################# +# the vhost for exec, fork process when publish stream. +vhost exec.srs.com { + # the exec used to fork process when got some event. + exec { + # whether enable the exec. + # default: off. + enabled off; + # when publish stream, exec the process with variables: + # [vhost] the input stream vhost. + # [port] the input stream port. + # [app] the input stream app. + # [stream] the input stream name. + # [engine] the transcode engine name. + # other variables for exec only: + # [url] the rtmp url which trigger the publish. + # [tcUrl] the client request tcUrl. + # [swfUrl] the client request swfUrl. + # [pageUrl] the client request pageUrl. + # we also support datetime variables. + # [2006], replace this const to current year. + # [01], replace this const to current month. + # [02], replace this const to current date. + # [15], replace this const to current hour. + # [04], replace this const to current minute. + # [05], replace this const to current second. + # [999], replace this const to current millisecond. + # [timestamp],replace this const to current UNIX timestamp in ms. + # @remark we use golang time format "2006-01-02 15:04:05.999" as "[2006]-[01]-[02]_[15].[04].[05]_[999]" + # @remark empty to ignore this exec. + publish ./objs/ffmpeg/bin/ffmpeg -f flv -i [url] -c copy -y ./[stream].flv; + } +} + +############################################################################################# +# DVR to VoD file sections. You should use FFmpeg to record stream. +############################################################################################# # vhost for dvr vhost dvr.srs.com { # DVR RTMP stream to file, @@ -2204,6 +1866,9 @@ vhost dvr.srs.com { } } +############################################################################################# +# Ingest stream to SRS sections. You should use FFmpeg to ingest stream to SRS. +############################################################################################# # vhost for ingest vhost ingest.srs.com { # ingest file/stream/device then push to SRS over RTMP. @@ -2254,54 +1919,9 @@ vhost ingest.srs.com { } } -# the vhost for ingest with transcode engine. -vhost transcode.ingest.srs.com { - ingest livestream { - enabled on; - input { - type file; - url ./doc/source.200kbps.768x320.flv; - } - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine { - enabled off; - perfile { - re; - rtsp_transport tcp; - } - iformat flv; - vfilter { - i ./doc/ffmpeg-logo.png; - filter_complex 'overlay=10:10'; - } - vcodec libx264; - vbitrate 1500; - vfps 25; - vwidth 768; - vheight 320; - vthreads 12; - vprofile main; - vpreset medium; - vparams { - t 100; - coder 1; - b_strategy 2; - bf 3; - refs 10; - } - acodec libfdk_aac; - abitrate 70; - asample_rate 44100; - achannels 2; - aparams { - profile:a aac_low; - } - oformat flv; - output rtmp://127.0.0.1:[port]/[app]/[stream]?vhost=[vhost]; - } - } -} - +############################################################################################# +# Transcode stream by FFmpeg sections. You should use FFmpeg to transcode stream. +############################################################################################# # the main comments for transcode vhost example.transcode.srs.com { # the streaming transcode configs. @@ -2452,358 +2072,252 @@ vhost example.transcode.srs.com { } } } -# the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction -vhost mirror.transcode.srs.com { - transcode { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine mirror { - enabled on; - vfilter { - vf 'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'; - } - vcodec libx264; - vbitrate 300; - vfps 20; - vwidth 768; - vheight 320; - vthreads 2; - vprofile baseline; - vpreset superfast; - vparams { - } - acodec libfdk_aac; - abitrate 45; - asample_rate 44100; - achannels 2; - aparams { - } - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - } -} -# the drawtext filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#drawtext-1 -# remark: we remove the libfreetype which always cause build failed, you must add it manual if needed. -####################################################################################################### -# the crop filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#crop -vhost crop.transcode.srs.com { - transcode { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine crop { - enabled on; - vfilter { - vf 'crop=in_w-20:in_h-160:10:80'; - } - vcodec libx264; - vbitrate 300; - vfps 20; - vwidth 768; - vheight 320; - vthreads 2; - vprofile baseline; - vpreset superfast; - vparams { - } - acodec libfdk_aac; - abitrate 45; - asample_rate 44100; - achannels 2; - aparams { - } - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - } -} -# the logo filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#overlay -vhost logo.transcode.srs.com { - transcode { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine logo { - enabled on; - vfilter { - i ./doc/ffmpeg-logo.png; - filter_complex 'overlay=10:10'; - } - vcodec libx264; - vbitrate 300; - vfps 20; - vwidth 768; - vheight 320; - vthreads 2; - vprofile baseline; - vpreset superfast; - vparams { - } - acodec libfdk_aac; - abitrate 45; - asample_rate 44100; - achannels 2; - aparams { - } - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - } -} -# audio transcode only. -# for example, FMLE publish audio codec in mp3, and do not support HLS output, -# we can transcode the audio to aac and copy video to the new stream with HLS. -vhost audio.transcode.srs.com { - transcode { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine acodec { - enabled on; - vcodec copy; - acodec libfdk_aac; - abitrate 45; - asample_rate 44100; - achannels 2; - aparams { - } - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - } -} -# disable video, transcode/copy audio. -# for example, publish pure audio stream. -vhost vn.transcode.srs.com { - transcode { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine vn { - enabled on; - vcodec vn; - acodec libfdk_aac; - abitrate 45; - asample_rate 44100; - achannels 2; - aparams { - } - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - } -} -# ffmpeg-copy(forward implements by ffmpeg). -# copy the video and audio to a new stream. -vhost copy.transcode.srs.com { - transcode { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine copy { - enabled on; - vcodec copy; - acodec copy; - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - } -} -# forward the input stream query string to output -vhost param.transcode.srs.com { - transcode { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine copy { - enabled on; - vcodec copy; - acodec copy; - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine][param]; - } - } -} -# transcode all app and stream of vhost -# the comments, read example.transcode.srs.com -vhost all.transcode.srs.com { - transcode { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine ffsuper { - enabled on; - iformat flv; - vfilter { - i ./doc/ffmpeg-logo.png; - filter_complex 'overlay=10:10'; - } - vcodec libx264; - vbitrate 1500; - vfps 25; - vwidth 768; - vheight 320; - vthreads 12; - vprofile main; - vpreset medium; - vparams { - t 100; - coder 1; - b_strategy 2; - bf 3; - refs 10; - } - acodec libfdk_aac; - abitrate 70; - asample_rate 44100; - achannels 2; - aparams { - profile:a aac_low; - } - oformat flv; - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - engine ffhd { - enabled on; - vcodec libx264; - vbitrate 1200; - vfps 25; - vwidth 1382; - vheight 576; - vthreads 6; - vprofile main; - vpreset medium; - vparams { - } - acodec libfdk_aac; - abitrate 70; - asample_rate 44100; - achannels 2; - aparams { - } - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - engine ffsd { - enabled on; - vcodec libx264; - vbitrate 800; - vfps 25; - vwidth 1152; - vheight 480; - vthreads 4; - vprofile main; - vpreset fast; - vparams { - } - acodec libfdk_aac; - abitrate 60; - asample_rate 44100; - achannels 2; - aparams { - } - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - engine fffast { - enabled on; - vcodec libx264; - vbitrate 300; - vfps 20; - vwidth 768; - vheight 320; - vthreads 2; - vprofile baseline; - vpreset superfast; - vparams { - } - acodec libfdk_aac; - abitrate 45; - asample_rate 44100; - achannels 2; - aparams { - } - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - engine vcopy { - enabled on; - vcodec copy; - acodec libfdk_aac; - abitrate 45; - asample_rate 44100; - achannels 2; - aparams { - } - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - engine acopy { - enabled on; - vcodec libx264; - vbitrate 300; - vfps 20; - vwidth 768; - vheight 320; - vthreads 2; - vprofile baseline; - vpreset superfast; - vparams { - } - acodec copy; - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - engine copy { - enabled on; - vcodec copy; - acodec copy; - output rtmp://127.0.0.1:[port]/[app]/[stream]_[engine]?vhost=[vhost]; - } - } -} -# transcode all app and stream of app -vhost app.transcode.srs.com { - # the streaming transcode configs. - # if app specified, transcode all streams of app. - transcode live { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine { - enabled off; - } - } -} -# transcode specified stream. -vhost stream.transcode.srs.com { - # the streaming transcode configs. - # if stream specified, transcode the matched stream. - transcode live/livestream { - enabled on; - ffmpeg ./objs/ffmpeg/bin/ffmpeg; - engine { - enabled off; - } - } -} -############################################################################################# -# In the config file, the include file can be anywhere in order to enhance the readability -# of the config file and enable the reuse of part of the config file. -# When using include files, make sure that the included files themselves have the correct SRS syntax, -# that is, config directives and blocks, and then specify the paths to these files. # -# @see https://github.com/ossrs/srs/issues/1399 -############################################################################################# -include ./conf/include.vhost.conf; +# +# +# +# +# +#******************************************************************************************** +#******************************************************************************************** +# CAUTION: The features below are deprecated, so please avoid use it. +#******************************************************************************************** +#******************************************************************************************** ############################################################################################# -# The origin cluster section +# The origin cluster section. Replaced by proxy server. ############################################################################################# -http_api { - enabled on; - listen 9090; -} -vhost a.origin.cluster.srs.com { +# Note that the legacy origin cluster is deprecated, please use the new architecture of +# Origin Cluster as a Proxy Cluster instead, please read https://ossrs.io/lts/en-us/docs/v7/doc/origin-cluster +# for details. + +############################################################################################# +# Edge cluster sections. Will be replaced by relay server, see https://github.com/ossrs/srs/discussions/4402 +############################################################################################# +# vhost for stream cluster for RTMP/FLV +vhost cluster.srs.com { + # The config for cluster. cluster { - mode local; - origin_cluster on; - coworkers 127.0.0.1:9091; + # The cluster mode, local or remote. + # local: It's an origin server, serve streams itself. + # remote: It's an edge server, fetch or push stream to origin server. + # default: local + mode remote; + + # For edge(mode remote), user must specifies the origin server + # format as: [:port] + # @remark user can specifies multiple origin for error backup, by space, + # for example, 192.168.1.100:1935 192.168.1.101:1935 192.168.1.102:1935 + origin 127.0.0.1:1935 localhost:1935; + + # For edge(mode remote), whether open the token traverse mode, + # if token traverse on, all connections of edge will forward to origin to check(auth), + # it's very important for the edge to do the token auth. + # the better way is use http callback to do the token auth by the edge, + # but if user prefer origin check(auth), the token_traverse if better solution. + # default: off + token_traverse off; + + # For edge(mode remote), the vhost to transform for edge, + # to fetch from the specified vhost at origin, + # if not specified, use the current vhost of edge in origin, the variable [vhost]. + # default: [vhost] + vhost same.edge.srs.com; + + # For edge(mode remote), when upnode(forward to, edge push to, edge pull from) is srs, + # it's strongly recommend to open the debug_srs_upnode, + # when connect to upnode, it will take the debug info, + # for example, the id, source id, pid. + # please see https://ossrs.io/lts/en-us/docs/v7/doc/log + # default: on + debug_srs_upnode on; + + # For origin(mode local) cluster, turn on the cluster. + # @remark Origin cluster only supports RTMP, use Edge to transmux RTMP to FLV. + # default: off + # TODO: FIXME: Support reload. + origin_cluster off; + + # For origin (mode local) cluster, the co-worker's HTTP APIs. + # This origin will connect to co-workers and communicate with them. + # please see https://ossrs.io/lts/en-us/docs/v7/doc/origin-cluster#legacy + # TODO: FIXME: Support reload. + coworkers 127.0.0.1:9091 127.0.0.1:9092; + + # The protocol to connect to origin. + # rtmp, Connect origin by RTMP + # flv, Connect origin by HTTP-FLV + # flvs, Connect origin by HTTPS-FLV + # Default: rtmp + protocol rtmp; + + # Whether follow client protocol to connect to origin. + # @remark The FLV might use different signature(in query string) to RTMP. + # Default: off + follow_client off; } } -http_api { - enabled on; - listen 9091; +############################################################################################# +# Tencent Cloud sections +############################################################################################# +# TencentCloud CLS(Cloud Log Service) config, logging to cloud. +# See https://cloud.tencent.com/document/product/614/11254 +tencentcloud_cls { + # Whether CLS is enabled. + # Overwrite by env SRS_TENCENTCLOUD_CLS_ENABLED + # default: off + enabled off; + # The logging label to category the cluster servers. + # Overwrite by env SRS_TENCENTCLOUD_CLS_LABEL + label cn-beijing; + # The logging tag to category the cluster servers. + # Overwrite by env SRS_TENCENTCLOUD_CLS_TAG + tag cn-edge; + # The SecretId to access CLS service, see https://console.cloud.tencent.com/cam/capi + # Overwrite by env SRS_TENCENTCLOUD_CLS_SECRET_ID + secret_id AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; + # The SecretKey to access CLS service, see https://console.cloud.tencent.com/cam/capi + # Overwrite by env SRS_TENCENTCLOUD_CLS_SECRET_KEY + secret_key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; + # The endpoint of CLS, format as .cls.tencentcs.com. For example: + # ap-guangzhou.cls.tencentcs.com + # Note that tencentyun.com is for internal network, while tencentcs.com is for public internet. + # See https://cloud.tencent.com/document/product/614/18940 + # Overwrite by env SRS_TENCENTCLOUD_CLS_ENDPOINT + endpoint ap-guangzhou.cls.tencentcs.com; + # The topic ID of CLS, see https://cloud.tencent.com/document/product/614/41035 + # Overwrite by env SRS_TENCENTCLOUD_CLS_TOPIC_ID + topic_id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx; + # Whether enable logging for each log sending. + # Overwrite by env SRS_TENCENTCLOUD_CLS_DEBUG_LOGGING + # Default: off + debug_logging off; + # Whether enable the heartbeat stat every (5 * heartbeat_ratio)s. + # Overwrite by env SRS_TENCENTCLOUD_CLS_STAT_HEARTBEAT + # Default: on + stat_heartbeat on; + # Setup the heartbeat interval ratio, 1 means 5s, 2 means 10s, etc. + # Overwrite by env SRS_TENCENTCLOUD_CLS_HEARTBEAT_RATIO + # Default: 1 + heartbeat_ratio 1; + # Whether enable the streams stat every (5 * streams_ratio)s. + # Overwrite by env SRS_TENCENTCLOUD_CLS_STAT_STREAMS + # Default: on + stat_streams on; + # Setup the streams interval ratio, 1 means 5s, 2 means 10s, etc. + # Overwrite by env SRS_TENCENTCLOUD_CLS_STREAMS_RATIO + # Default: 1 + streams_ratio 1; } -vhost b.origin.cluster.srs.com { - cluster { - mode local; - origin_cluster on; - coworkers 127.0.0.1:9090; - } + +# TencentCloud APM(Application Performance Management) config. +# See https://cloud.tencent.com/document/product/1463/57462 +tencentcloud_apm { + # Whether APM is enabled. + # Overwrite by env SRS_TENCENTCLOUD_APM_ENABLED + # default: off + enabled on; + # The APM team or business system ID, to which spans belongs to. For example, the team is apm-FsOsPOIMl (just an + # example, not available), please get your team from https://console.cloud.tencent.com/apm/monitor/team + # Overwrite by env SRS_TENCENTCLOUD_APM_TEAM + team apm-xxxxxxxxx; + # The APM token for authentication. For example, the token is xzddEaegsxGadEpGEDFx (just an example, not available), + # please get your token from https://console.cloud.tencent.com/apm/monitor/access + # Overwrite by env SRS_TENCENTCLOUD_APM_TOKEN + token xxxxxxxx; + # The APM endpoint. See https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/otlp/otlptrace + # Please note that 4317 is for GRPC/HTTP2, while SRS only support HTTP and the port shoule be 55681. + # Overwrite by env SRS_TENCENTCLOUD_APM_ENDPOINT + endpoint ap-guangzhou.apm.tencentcs.com:55681; + # The service.name of resource. + # Overwrite by env SRS_TENCENTCLOUD_APM_SERVICE_NAME + # Default: srs-server + service_name srs-server; + # Whether enable logging for each log sending. + # Overwrite by env SRS_TENCENTCLOUD_APM_DEBUG_LOGGING + # Default: off + debug_logging off; +} + +############################################################################################# +# heartbeat/stats sections +############################################################################################# +# Query the latest available version of SRS, write a log to notice user to upgrade. +# @see https://github.com/ossrs/srs/issues/2424 +# @see https://github.com/ossrs/srs/issues/2508 +# Overwrite by env SRS_QUERY_LATEST_VERSION +# Default: off +query_latest_version off; + +# First wait when qlv(query latest version), in seconds. +# Only available when qlv is enabled. +# Overwrite by env SRS_FIRST_WAIT_FOR_QLV +# Default: 300 +first_wait_for_qlv 300; + +# heartbeat to api server +# @remark, the ip report to server, is retrieve from system stat, +# which need the config item stats.network. +heartbeat { + # whether heartbeat is enabled. + # Overwrite by env SRS_HEARTBEAT_ENABLED + # default: off + enabled off; + # the interval seconds for heartbeat, + # recommend 0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,3,...,6,9,12,.... + # Overwrite by env SRS_HEARTBEAT_INTERVAL + # default: 9.9 + interval 9.3; + # when startup, srs will heartbeat to this api. + # @remark: must be a restful http api url, where SRS will POST with following data: + # { + # "device_id": "my-srs-device", + # "ip": "192.168.1.100" + # } + # Overwrite by env SRS_HEARTBEAT_URL + # default: http://127.0.0.1:8085/api/v1/servers + url http://127.0.0.1:8085/api/v1/servers; + # the id of device. + # Overwrite by env SRS_HEARTBEAT_DEVICE_ID + device_id "my-srs-device"; + # whether report with summaries + # if on, put /api/v1/summaries to the request data: + # { + # "summaries": summaries object. + # } + # @remark: optional config. + # Overwrite by env SRS_HEARTBEAT_SUMMARIES + # default: off + summaries off; + # Whether report with listen ports. + # if on, request with the ports of SRS: + # { + # "rtmp": ["1935"], "http": ["8080"], "api": ["1985"], "srt": ["10080"], "rtc": ["8000"] + # } + # Overwrite by env SRS_HEARTBEAT_PORTS + # default: off + ports off; +} + +# system statistics section. +# the main cycle will retrieve the system stat, +# for example, the cpu/mem/network/disk-io data, +# the http api, for instance, /api/v1/summaries will show these data. +# @remark the heartbeat depends on the network, +# for example, the eth0 maybe the device which index is 0. +stats { + # Whether enable the stat of system resources. + # Default: on + enabled on; + # the index of device ip. + # we may retrieve more than one network device. + # default: 0 + network 0; + # the device name to stat the disk iops. + # ignore the device of /proc/diskstats if not configured. + disk sda sdb xvda xvdb; } ############################################################################################# diff --git a/trunk/conf/gb28181-without-sip.conf b/trunk/conf/gb28181-without-sip.conf index 41523c198..31ab65f83 100644 --- a/trunk/conf/gb28181-without-sip.conf +++ b/trunk/conf/gb28181-without-sip.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + stream_caster { enabled on; caster gb28181; diff --git a/trunk/conf/gb28181.conf b/trunk/conf/gb28181.conf index 16c9e8df8..020872d6f 100644 --- a/trunk/conf/gb28181.conf +++ b/trunk/conf/gb28181.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + stream_caster { enabled on; caster gb28181; diff --git a/trunk/conf/go-oryx-edge.conf b/trunk/conf/go-oryx-edge.conf index 909e9794a..cecdb8822 100644 --- a/trunk/conf/go-oryx-edge.conf +++ b/trunk/conf/go-oryx-edge.conf @@ -2,12 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/edge # @see full.conf for detail config. -listen 19351; max_connections 1000; pid objs/edge1.pid; daemon off; srs_log_tank console; -vhost __defaultVhost__ { + +rtmp { + listen 19351; +}vhost __defaultVhost__ { cluster { mode remote; origin 127.0.0.1:19350; diff --git a/trunk/conf/go-oryx-edge2.conf b/trunk/conf/go-oryx-edge2.conf index 9cc7d12db..d0a9400d8 100644 --- a/trunk/conf/go-oryx-edge2.conf +++ b/trunk/conf/go-oryx-edge2.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/edge # @see full.conf for detail config. -listen 19352; max_connections 1000; pid objs/edge2.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 19352; +} vhost __defaultVhost__ { cluster { mode remote; diff --git a/trunk/conf/hds.conf b/trunk/conf/hds.conf index ffe3ea9f6..974351898 100644 --- a/trunk/conf/hds.conf +++ b/trunk/conf/hds.conf @@ -1,11 +1,15 @@ # the config for srs to delivery hds # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + vhost __defaultVhost__ { hds { enabled on; diff --git a/trunk/conf/hevc.flv.conf b/trunk/conf/hevc.flv.conf index ec07a8a90..405f43592 100644 --- a/trunk/conf/hevc.flv.conf +++ b/trunk/conf/hevc.flv.conf @@ -1,7 +1,11 @@ -listen 1935; + max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} srt_server { enabled on; listen 10080; diff --git a/trunk/conf/hevc.ts.conf b/trunk/conf/hevc.ts.conf index ad2a49bb5..c228493df 100644 --- a/trunk/conf/hevc.ts.conf +++ b/trunk/conf/hevc.ts.conf @@ -1,7 +1,11 @@ -listen 1935; + max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} srt_server { enabled on; listen 10080; diff --git a/trunk/conf/hls.conf b/trunk/conf/hls.conf index 03a827284..390e6780d 100644 --- a/trunk/conf/hls.conf +++ b/trunk/conf/hls.conf @@ -2,10 +2,12 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/hls # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/hls.mp4.conf b/trunk/conf/hls.mp4.conf index 0079ba688..cc1cbb192 100644 --- a/trunk/conf/hls.mp4.conf +++ b/trunk/conf/hls.mp4.conf @@ -2,10 +2,14 @@ # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/sample-hls # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/hls.origin.conf b/trunk/conf/hls.origin.conf index fd4b95c9b..be76f1d1a 100644 --- a/trunk/conf/hls.origin.conf +++ b/trunk/conf/hls.origin.conf @@ -1,8 +1,12 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/hls.realtime.conf b/trunk/conf/hls.realtime.conf index 3b188c0b4..488c1e041 100644 --- a/trunk/conf/hls.realtime.conf +++ b/trunk/conf/hls.realtime.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/sample-realtime # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.aac.live.conf b/trunk/conf/http.aac.live.conf index 191e1d376..83d791fb6 100644 --- a/trunk/conf/http.aac.live.conf +++ b/trunk/conf/http.aac.live.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/flv # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.api.auth.conf b/trunk/conf/http.api.auth.conf index 6ba7dee68..c62d08e7a 100644 --- a/trunk/conf/http.api.auth.conf +++ b/trunk/conf/http.api.auth.conf @@ -1,8 +1,12 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/http.api.dedicated.conf b/trunk/conf/http.api.dedicated.conf index 896a04dbf..21f5c817e 100644 --- a/trunk/conf/http.api.dedicated.conf +++ b/trunk/conf/http.api.dedicated.conf @@ -1,10 +1,14 @@ # main config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/http.api.one.port.conf b/trunk/conf/http.api.one.port.conf index 5a6f0b327..03225285c 100644 --- a/trunk/conf/http.api.one.port.conf +++ b/trunk/conf/http.api.one.port.conf @@ -1,10 +1,14 @@ # main config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 8080; diff --git a/trunk/conf/http.api.one.port2.conf b/trunk/conf/http.api.one.port2.conf index e7f31d35e..2479aab6b 100644 --- a/trunk/conf/http.api.one.port2.conf +++ b/trunk/conf/http.api.one.port2.conf @@ -1,10 +1,14 @@ # main config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 8080; diff --git a/trunk/conf/http.api.raw.conf b/trunk/conf/http.api.raw.conf index 6c5531a60..865640c6c 100644 --- a/trunk/conf/http.api.raw.conf +++ b/trunk/conf/http.api.raw.conf @@ -1,10 +1,14 @@ # main config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/http.flv.live.conf b/trunk/conf/http.flv.live.conf index d8f83453e..9c273c10a 100644 --- a/trunk/conf/http.flv.live.conf +++ b/trunk/conf/http.flv.live.conf @@ -2,10 +2,12 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/flv # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.flv.live.edge1.conf b/trunk/conf/http.flv.live.edge1.conf index 0ec999306..05787091f 100644 --- a/trunk/conf/http.flv.live.edge1.conf +++ b/trunk/conf/http.flv.live.edge1.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/flv # @see full.conf for detail config. -listen 19351; max_connections 1000; pid objs/srs.flv.19351.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 19351; +} http_server { enabled on; listen 8081; diff --git a/trunk/conf/http.flv.live.edge2.conf b/trunk/conf/http.flv.live.edge2.conf index 72436bb71..9faeb1fa8 100644 --- a/trunk/conf/http.flv.live.edge2.conf +++ b/trunk/conf/http.flv.live.edge2.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/flv # @see full.conf for detail config. -listen 19352; max_connections 1000; pid objs/srs.flv.19352.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 19352; +} http_server { enabled on; listen 8082; diff --git a/trunk/conf/http.heartbeat.conf b/trunk/conf/http.heartbeat.conf index d2125ed33..55b712feb 100644 --- a/trunk/conf/http.heartbeat.conf +++ b/trunk/conf/http.heartbeat.conf @@ -1,10 +1,14 @@ # the config for srs http heartbeat, report its info to api-server # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} heartbeat { enabled on; interval 9.3; diff --git a/trunk/conf/http.hls.conf b/trunk/conf/http.hls.conf index cd06d737b..659666e81 100644 --- a/trunk/conf/http.hls.conf +++ b/trunk/conf/http.hls.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/hls # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.hooks.callback.conf b/trunk/conf/http.hooks.callback.conf index 59f78683e..91fdba401 100644 --- a/trunk/conf/http.hooks.callback.conf +++ b/trunk/conf/http.hooks.callback.conf @@ -1,10 +1,14 @@ # http-hooks or http-callbacks config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { http_hooks { enabled on; diff --git a/trunk/conf/http.mp3.live.conf b/trunk/conf/http.mp3.live.conf index 98bea0e23..83f781705 100644 --- a/trunk/conf/http.mp3.live.conf +++ b/trunk/conf/http.mp3.live.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/flv # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.server.conf b/trunk/conf/http.server.conf index f3aafc079..87a15f4ef 100644 --- a/trunk/conf/http.server.conf +++ b/trunk/conf/http.server.conf @@ -1,10 +1,14 @@ # the config for srs to serve as http server # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.ts.live.conf b/trunk/conf/http.ts.live.conf index 3c21a1ef1..5ae49557c 100644 --- a/trunk/conf/http.ts.live.conf +++ b/trunk/conf/http.ts.live.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/flv # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/https.docker.conf b/trunk/conf/https.docker.conf index 881ccceec..36a623a68 100644 --- a/trunk/conf/https.docker.conf +++ b/trunk/conf/https.docker.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_server { enabled on; listen 8080; diff --git a/trunk/conf/https.flv.live.conf b/trunk/conf/https.flv.live.conf index 98a68c4c6..1cc5972a7 100644 --- a/trunk/conf/https.flv.live.conf +++ b/trunk/conf/https.flv.live.conf @@ -2,10 +2,14 @@ # @see https://github.com/ossrs/srs/issues/1657#issuecomment-722971676 # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/https.hls.conf b/trunk/conf/https.hls.conf index bfd6e6a6f..8968a0638 100644 --- a/trunk/conf/https.hls.conf +++ b/trunk/conf/https.hls.conf @@ -2,10 +2,14 @@ # @see https://github.com/ossrs/srs/issues/1657#issuecomment-722971676 # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/https.hooks.callback.conf b/trunk/conf/https.hooks.callback.conf index cdd1719eb..69eb43d38 100644 --- a/trunk/conf/https.hooks.callback.conf +++ b/trunk/conf/https.hooks.callback.conf @@ -2,10 +2,14 @@ # @see https://github.com/ossrs/srs/issues/1657#issuecomment-720889906 # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { http_hooks { enabled on; diff --git a/trunk/conf/https.rtc.conf b/trunk/conf/https.rtc.conf index e93e2ec87..a684078e9 100644 --- a/trunk/conf/https.rtc.conf +++ b/trunk/conf/https.rtc.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_server { enabled on; listen 8080; diff --git a/trunk/conf/https.rtmp2rtc.conf b/trunk/conf/https.rtmp2rtc.conf index faf99540b..c2d082f34 100644 --- a/trunk/conf/https.rtmp2rtc.conf +++ b/trunk/conf/https.rtmp2rtc.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_server { enabled on; listen 8080; diff --git a/trunk/conf/https.srs.conf b/trunk/conf/https.srs.conf index 881ccceec..36a623a68 100644 --- a/trunk/conf/https.srs.conf +++ b/trunk/conf/https.srs.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_server { enabled on; listen 8080; diff --git a/trunk/conf/include.conf b/trunk/conf/include.conf index fa2e720f6..43d4d88ed 100644 --- a/trunk/conf/include.conf +++ b/trunk/conf/include.conf @@ -1,11 +1,15 @@ # include directive config for SRS. # @see full.conf for detail config. -listen 1935; max_connections 1000; srs_log_tank console; daemon off; +# RTMP server configuration +rtmp { + listen 1935; +} + http_api { enabled on; listen 1985; diff --git a/trunk/conf/ingest.conf b/trunk/conf/ingest.conf index 93e6a6984..53adac167 100644 --- a/trunk/conf/ingest.conf +++ b/trunk/conf/ingest.conf @@ -2,10 +2,12 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/ingest # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} vhost __defaultVhost__ { ingest livestream { enabled on; diff --git a/trunk/conf/ingest.rtsp.conf b/trunk/conf/ingest.rtsp.conf index 3e1d5e9b2..bf8eaebb1 100644 --- a/trunk/conf/ingest.rtsp.conf +++ b/trunk/conf/ingest.rtsp.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/ingest # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { ingest { enabled on; diff --git a/trunk/conf/live.conf b/trunk/conf/live.conf index e2cf80c28..823338e9e 100644 --- a/trunk/conf/live.conf +++ b/trunk/conf/live.conf @@ -1,10 +1,12 @@ # Live streaming config for SRS. # @see full.conf for detail config. -listen 1935; max_connections 1000; srs_log_tank console; daemon off; +rtmp { + listen 1935; +} http_api { enabled on; diff --git a/trunk/conf/log-file.conf b/trunk/conf/log-file.conf index 10a3589f2..a51a3ec33 100644 --- a/trunk/conf/log-file.conf +++ b/trunk/conf/log-file.conf @@ -1,11 +1,15 @@ # main config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; srs_log_tank file; srs_log_file ./objs/srs.log; daemon off; + +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/mp3.conf b/trunk/conf/mp3.conf index 5d32488ef..db59030fe 100644 --- a/trunk/conf/mp3.conf +++ b/trunk/conf/mp3.conf @@ -1,7 +1,11 @@ -listen 1935; + max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/mp3.http.conf b/trunk/conf/mp3.http.conf index 7b198230f..9eb401d62 100644 --- a/trunk/conf/mp3.http.conf +++ b/trunk/conf/mp3.http.conf @@ -1,7 +1,11 @@ -listen 1935; + max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/mp3.rtc.conf b/trunk/conf/mp3.rtc.conf index be5ac4ba0..186d71dfc 100644 --- a/trunk/conf/mp3.rtc.conf +++ b/trunk/conf/mp3.rtc.conf @@ -1,7 +1,11 @@ -listen 1935; + max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/mp3.ts.conf b/trunk/conf/mp3.ts.conf index c7b7ddd40..7a14200e1 100644 --- a/trunk/conf/mp3.ts.conf +++ b/trunk/conf/mp3.ts.conf @@ -1,7 +1,11 @@ -listen 1935; + max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/openwrt.conf b/trunk/conf/openwrt.conf index c6dba121a..17a30c1b1 100644 --- a/trunk/conf/openwrt.conf +++ b/trunk/conf/openwrt.conf @@ -1,10 +1,14 @@ # no-daemon and write log to console config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/origin.cluster.edge.conf b/trunk/conf/origin.cluster.edge.conf index dfc0a1514..6e13afc3e 100644 --- a/trunk/conf/origin.cluster.edge.conf +++ b/trunk/conf/origin.cluster.edge.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/origin-cluster#legacy # @see full.conf for detail config. -listen 1935; max_connections 1000; pid objs/edge.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { cluster { mode remote; diff --git a/trunk/conf/origin.cluster.serverA.conf b/trunk/conf/origin.cluster.serverA.conf index 1c21252b2..759073c33 100644 --- a/trunk/conf/origin.cluster.serverA.conf +++ b/trunk/conf/origin.cluster.serverA.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/origin-cluster#legacy # @see full.conf for detail config. -listen 19350; max_connections 1000; daemon off; srs_log_tank console; pid ./objs/origin.cluster.serverA.pid; + +# RTMP server configuration +rtmp { + listen 19350; +} http_api { enabled on; listen 9090; diff --git a/trunk/conf/origin.cluster.serverB.conf b/trunk/conf/origin.cluster.serverB.conf index 410d69356..1bf5b25cf 100644 --- a/trunk/conf/origin.cluster.serverB.conf +++ b/trunk/conf/origin.cluster.serverB.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/origin-cluster#legacy # @see full.conf for detail config. -listen 19351; max_connections 1000; daemon off; srs_log_tank console; pid ./objs/origin.cluster.serverB.pid; + +# RTMP server configuration +rtmp { + listen 19351; +} http_api { enabled on; listen 9091; diff --git a/trunk/conf/origin.cluster.serverC.conf b/trunk/conf/origin.cluster.serverC.conf index df161a2f2..2c51010ee 100644 --- a/trunk/conf/origin.cluster.serverC.conf +++ b/trunk/conf/origin.cluster.serverC.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/origin-cluster#legacy # @see full.conf for detail config. -listen 19352; max_connections 1000; daemon off; srs_log_tank console; pid ./objs/origin.cluster.serverC.pid; + +# RTMP server configuration +rtmp { + listen 19352; +} http_api { enabled on; listen 9092; diff --git a/trunk/conf/origin.conf b/trunk/conf/origin.conf index df002ac5c..fbfe6de50 100644 --- a/trunk/conf/origin.conf +++ b/trunk/conf/origin.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/edge # @see full.conf for detail config. -listen 19350; max_connections 1000; pid ./objs/origin.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 19350; +} http_server { enabled on; listen 8081; diff --git a/trunk/conf/origin.hls.only1.conf b/trunk/conf/origin.hls.only1.conf index f84d08190..285fc243e 100644 --- a/trunk/conf/origin.hls.only1.conf +++ b/trunk/conf/origin.hls.only1.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/reuse-port # @see full.conf for detail config. -listen 1935; max_connections 1000; pid ./objs/origin.hls.only1.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/origin.hls.only2.conf b/trunk/conf/origin.hls.only2.conf index efb09c0a3..552dd5671 100644 --- a/trunk/conf/origin.hls.only2.conf +++ b/trunk/conf/origin.hls.only2.conf @@ -2,11 +2,15 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/reuse-port # @see full.conf for detail config. -listen 1935; max_connections 1000; pid ./objs/origin.hls.only2.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/origin1-for-proxy.conf b/trunk/conf/origin1-for-proxy.conf index 8c25f7341..10c51ce1f 100644 --- a/trunk/conf/origin1-for-proxy.conf +++ b/trunk/conf/origin1-for-proxy.conf @@ -1,9 +1,13 @@ -listen 19351; max_connections 1000; pid objs/origin1.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 19351; +} http_server { enabled on; listen 8081; diff --git a/trunk/conf/origin2-for-proxy.conf b/trunk/conf/origin2-for-proxy.conf index 3f39ae0df..779cce4d2 100644 --- a/trunk/conf/origin2-for-proxy.conf +++ b/trunk/conf/origin2-for-proxy.conf @@ -1,9 +1,13 @@ -listen 19352; max_connections 1000; pid objs/origin2.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 19352; +} http_server { enabled on; listen 8082; diff --git a/trunk/conf/origin3-for-proxy.conf b/trunk/conf/origin3-for-proxy.conf index 4be2056f8..a7b6a4ad6 100644 --- a/trunk/conf/origin3-for-proxy.conf +++ b/trunk/conf/origin3-for-proxy.conf @@ -1,9 +1,13 @@ -listen 19353; max_connections 1000; pid objs/origin3.pid; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 19353; +} http_server { enabled on; listen 8083; diff --git a/trunk/conf/prometheus.conf b/trunk/conf/prometheus.conf index f6bc3362c..c32fe8f56 100644 --- a/trunk/conf/prometheus.conf +++ b/trunk/conf/prometheus.conf @@ -1,10 +1,14 @@ # no-daemon and write log to console config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/push.flv.conf b/trunk/conf/push.flv.conf index e43151287..1c41f9e2a 100644 --- a/trunk/conf/push.flv.conf +++ b/trunk/conf/push.flv.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/streamer#push-http-flv-to-srs # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} stream_caster { enabled on; caster flv; diff --git a/trunk/conf/push.gb28181.conf b/trunk/conf/push.gb28181.conf index 760ccef82..3b4157141 100644 --- a/trunk/conf/push.gb28181.conf +++ b/trunk/conf/push.gb28181.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + stream_caster { enabled on; caster gb28181; diff --git a/trunk/conf/push.mpegts.over.udp.conf b/trunk/conf/push.mpegts.over.udp.conf index 3b2ed86a8..c22d6f4d5 100644 --- a/trunk/conf/push.mpegts.over.udp.conf +++ b/trunk/conf/push.mpegts.over.udp.conf @@ -3,10 +3,14 @@ # @see https://github.com/ossrs/srs/issues/250#issuecomment-72321769 # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} stream_caster { enabled on; caster mpegts_over_udp; diff --git a/trunk/conf/realtime.conf b/trunk/conf/realtime.conf index a59bf52e7..2618fc7d6 100644 --- a/trunk/conf/realtime.conf +++ b/trunk/conf/realtime.conf @@ -2,10 +2,12 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/sample-realtime # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} vhost __defaultVhost__ { tcp_nodelay on; min_latency on; diff --git a/trunk/conf/realtime.flv.conf b/trunk/conf/realtime.flv.conf index f33ab5172..93ce76992 100644 --- a/trunk/conf/realtime.flv.conf +++ b/trunk/conf/realtime.flv.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/sample-realtime # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} http_server { enabled on; listen 8080; diff --git a/trunk/conf/regression-test-for-clion.conf b/trunk/conf/regression-test-for-clion.conf index dbd870f9c..eb3408e55 100644 --- a/trunk/conf/regression-test-for-clion.conf +++ b/trunk/conf/regression-test-for-clion.conf @@ -1,11 +1,15 @@ -listen 1935; max_connections 1000; # For clion, use console as output. daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + stream_caster { enabled on; caster gb28181; diff --git a/trunk/conf/regression-test.conf b/trunk/conf/regression-test.conf index 61434b4ec..76b6284db 100644 --- a/trunk/conf/regression-test.conf +++ b/trunk/conf/regression-test.conf @@ -1,5 +1,4 @@ -listen 1935; max_connections 1000; # Force to daemon and write logs to file. @@ -7,6 +6,11 @@ daemon on; disable_daemon_for_docker off; srs_log_tank file; +# RTMP server configuration +rtmp { + listen 1935; +} + stream_caster { enabled on; caster gb28181; diff --git a/trunk/conf/rtc.conf b/trunk/conf/rtc.conf index 2d44cd591..fbdd3cd55 100644 --- a/trunk/conf/rtc.conf +++ b/trunk/conf/rtc.conf @@ -1,10 +1,12 @@ # WebRTC streaming config for SRS. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} http_server { enabled on; diff --git a/trunk/conf/rtc.tcp.only.conf b/trunk/conf/rtc.tcp.only.conf index b70289e50..016fdb295 100644 --- a/trunk/conf/rtc.tcp.only.conf +++ b/trunk/conf/rtc.tcp.only.conf @@ -1,11 +1,15 @@ # WebRTC streaming config for SRS. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_server { enabled on; listen 8080; diff --git a/trunk/conf/rtc.tcp.udp.conf b/trunk/conf/rtc.tcp.udp.conf index 4b5d4a5b8..74cff4a25 100644 --- a/trunk/conf/rtc.tcp.udp.conf +++ b/trunk/conf/rtc.tcp.udp.conf @@ -1,11 +1,15 @@ # WebRTC streaming config for SRS. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_server { enabled on; listen 8080; diff --git a/trunk/conf/rtc2rtmp.conf b/trunk/conf/rtc2rtmp.conf index e6649b3b2..45809119d 100644 --- a/trunk/conf/rtc2rtmp.conf +++ b/trunk/conf/rtc2rtmp.conf @@ -1,8 +1,10 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} http_server { enabled on; diff --git a/trunk/conf/rtmp.conf b/trunk/conf/rtmp.conf index 940f35c73..56de00867 100644 --- a/trunk/conf/rtmp.conf +++ b/trunk/conf/rtmp.conf @@ -2,9 +2,11 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/rtmp # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} vhost __defaultVhost__ { } diff --git a/trunk/conf/rtmp.kickoff.conf b/trunk/conf/rtmp.kickoff.conf index 7ab0db693..58c3eae53 100644 --- a/trunk/conf/rtmp.kickoff.conf +++ b/trunk/conf/rtmp.kickoff.conf @@ -2,10 +2,14 @@ # @see https://github.com/ossrs/srs/wiki/v1_CN_SampleRTMP # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { publish { kickoff_for_idle 60000; diff --git a/trunk/conf/rtmp2rtc.conf b/trunk/conf/rtmp2rtc.conf index e6649b3b2..45809119d 100644 --- a/trunk/conf/rtmp2rtc.conf +++ b/trunk/conf/rtmp2rtc.conf @@ -1,8 +1,10 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} http_server { enabled on; diff --git a/trunk/conf/rtmps.conf b/trunk/conf/rtmps.conf index 3191b72cb..5cf60a65b 100644 --- a/trunk/conf/rtmps.conf +++ b/trunk/conf/rtmps.conf @@ -1,7 +1,10 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} rtmps { enabled on; listen 1443; diff --git a/trunk/conf/rtsp.conf b/trunk/conf/rtsp.conf index d73fe0351..11c6ec647 100644 --- a/trunk/conf/rtsp.conf +++ b/trunk/conf/rtsp.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_server { enabled on; listen 8080; diff --git a/trunk/conf/security.deny.publish.conf b/trunk/conf/security.deny.publish.conf index 574b5fcec..188455557 100644 --- a/trunk/conf/security.deny.publish.conf +++ b/trunk/conf/security.deny.publish.conf @@ -1,10 +1,13 @@ # security config for srs, allow play and deny publish. # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { security { enabled on; diff --git a/trunk/conf/srs.conf b/trunk/conf/srs.conf index abf9dcf87..90db9d490 100644 --- a/trunk/conf/srs.conf +++ b/trunk/conf/srs.conf @@ -1,11 +1,13 @@ # main config for srs. # @see full.conf for detail config. -listen 1935; max_connections 1000; #srs_log_tank file; #srs_log_file ./objs/srs.log; daemon on; +rtmp { + listen 1935; +} http_api { enabled on; listen 1985; diff --git a/trunk/conf/srt.conf b/trunk/conf/srt.conf index 582bc0056..c5d7a1195 100644 --- a/trunk/conf/srt.conf +++ b/trunk/conf/srt.conf @@ -1,10 +1,13 @@ # SRT config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +rtmp { + listen 1935; +} + http_api { enabled on; listen 1985; diff --git a/trunk/conf/srt2rtc.conf b/trunk/conf/srt2rtc.conf index 4116eb8bc..7ea19e414 100644 --- a/trunk/conf/srt2rtc.conf +++ b/trunk/conf/srt2rtc.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_api { enabled on; listen 1985; diff --git a/trunk/conf/srt2ts.conf b/trunk/conf/srt2ts.conf index 942c9e15f..3f4791e64 100644 --- a/trunk/conf/srt2ts.conf +++ b/trunk/conf/srt2ts.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon off; srs_log_tank console; +# RTMP server configuration +rtmp { + listen 1935; +} + http_api { enabled on; listen 1985; diff --git a/trunk/conf/transcode2hls.audio.only.conf b/trunk/conf/transcode2hls.audio.only.conf index 966c87f75..5c4ef3376 100644 --- a/trunk/conf/transcode2hls.audio.only.conf +++ b/trunk/conf/transcode2hls.audio.only.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/hls # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { hls { enabled on; diff --git a/trunk/conf/transform.edge.conf b/trunk/conf/transform.edge.conf index 527735a68..dac31a9f8 100644 --- a/trunk/conf/transform.edge.conf +++ b/trunk/conf/transform.edge.conf @@ -2,10 +2,14 @@ # @see https://ossrs.io/lts/en-us/docs/v7/doc/edge#transform-vhost # @see full.conf for detail config. -listen 1935; max_connections 1000; daemon off; srs_log_tank console; + +# RTMP server configuration +rtmp { + listen 1935; +} vhost __defaultVhost__ { } vhost source.srs.com { diff --git a/trunk/conf/vm.conf b/trunk/conf/vm.conf index 3dcd2c1dd..72aff3536 100644 --- a/trunk/conf/vm.conf +++ b/trunk/conf/vm.conf @@ -1,9 +1,13 @@ -listen 1935; max_connections 1000; daemon on; srs_log_tank file; +# RTMP server configuration +rtmp { + listen 1935; +} + # For LightHouse VM to run SRS, never enable docker. in_docker off; disable_daemon_for_docker off; diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 7414816c6..a360e9b94 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 7.0 Changelog +* v7.0, 2025-08-27, Merge [#4454](https://github.com/ossrs/srs/pull/4454): AI: Config: Move RTMP configs to rtmp{} section. v7.0.64 (#4454) * v7.0, 2025-08-26, Merge [#4451](https://github.com/ossrs/srs/pull/4451): RTC: Fix null pointer crash in RTC2RTMP when start packet is missing. v7.0.63 (#4451) * v7.0, 2025-08-25, Merge [#4452](https://github.com/ossrs/srs/pull/4452): AI: Implement stream publish token system to prevent race conditions across all protocols. v7.0.62 (#4452) * v7.0, 2025-08-22, Merge [#4449](https://github.com/ossrs/srs/pull/4449): Refine source lock. v7.0.61 (#4449) diff --git a/trunk/scripts/copy-srs-docs.sh b/trunk/scripts/copy-srs-docs.sh old mode 100644 new mode 100755 diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 8518045bc..c2a69779d 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -372,6 +372,27 @@ srs_error_t srs_config_transform_vhost(SrsConfDirective *root) { srs_error_t err = srs_success; + // SRS7.0, move global RTMP configs to rtmp section for better organization. + // SRS6: + // listen 1935; chunk_size 60000; + // SRS7+: + // rtmp { listen 1935; chunk_size 60000; } + for (int i = (int)root->directives.size() - 1; i >= 0; i--) { + SrsConfDirective *dir = root->directives.at(i); + + SrsConfDirective *rtmp = root->get_or_create("rtmp"); + if (dir->name == "listen") { + rtmp->get_or_create("listen")->args = dir->args; + } else if (dir->name == "chunk_size") { + rtmp->get_or_create("chunk_size")->args = dir->args; + } else { + continue; + } + + root->directives.erase(root->directives.begin() + i); + srs_freep(dir); + } + for (int i = 0; i < (int)root->directives.size(); i++) { SrsConfDirective *dir = root->directives.at(i); @@ -1665,26 +1686,10 @@ srs_error_t SrsConfig::reload_conf(SrsConfig *conf) root = conf->root; conf->root = NULL; - // never support reload: - // daemon - // - // always support reload without additional code: - // chunk_size, ff_log_dir, - // http_hooks, heartbeat, - // security - - // merge config: listen - if (!srs_directive_equals(root->get("listen"), old_root->get("listen"))) { - if ((err = do_reload_listen()) != srs_success) { - return srs_error_wrap(err, "listen"); - } - } - // merge config: max_connections if (!srs_directive_equals(root->get("max_connections"), old_root->get("max_connections"))) { if ((err = do_reload_max_connections()) != srs_success) { return srs_error_wrap(err, "max connections"); - ; } } @@ -1692,7 +1697,6 @@ srs_error_t SrsConfig::reload_conf(SrsConfig *conf) if (!srs_directive_equals(root->get("pithy_print_ms"), old_root->get("pithy_print_ms"))) { if ((err = do_reload_pithy_print_ms()) != srs_success) { return srs_error_wrap(err, "pithy print ms"); - ; } } @@ -2117,22 +2121,6 @@ srs_error_t SrsConfig::raw_to_json(SrsJsonObject *obj) return err; } -srs_error_t SrsConfig::do_reload_listen() -{ - srs_error_t err = srs_success; - - vector::iterator it; - for (it = subscribes.begin(); it != subscribes.end(); ++it) { - ISrsReloadHandler *subscribe = *it; - if ((err = subscribe->on_reload_listen()) != srs_success) { - return srs_error_wrap(err, "notify subscribes reload listen failed"); - } - } - srs_trace("reload listen success."); - - return err; -} - srs_error_t SrsConfig::do_reload_max_connections() { srs_error_t err = srs_success; @@ -2366,7 +2354,7 @@ srs_error_t SrsConfig::check_normal_config() for (int i = 0; i < (int)root->directives.size(); i++) { SrsConfDirective *conf = root->at(i); std::string n = conf->name; - if (n != "listen" && n != "pid" && n != "chunk_size" && n != "ff_log_dir" && n != "srs_log_tank" && n != "srs_log_level" && n != "srs_log_level_v2" && n != "srs_log_file" && n != "max_connections" && n != "daemon" && n != "heartbeat" && n != "tencentcloud_apm" && n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms" && n != "http_server" && n != "stream_caster" && n != "rtc_server" && n != "srt_server" && n != "utc_time" && n != "work_dir" && n != "asprocess" && n != "server_id" && n != "ff_log_level" && n != "grace_final_wait" && n != "force_grace_quit" && n != "grace_start_wait" && n != "empty_ip_ok" && n != "disable_daemon_for_docker" && n != "inotify_auto_reload" && n != "auto_reload_for_docker" && n != "tcmalloc_release_rate" && n != "query_latest_version" && n != "first_wait_for_qlv" && n != "threads" && n != "circuit_breaker" && n != "is_full" && n != "in_docker" && n != "tencentcloud_cls" && n != "exporter" && n != "rtsp_server" && n != "rtmps") { + if (n != "pid" && n != "ff_log_dir" && n != "srs_log_tank" && n != "srs_log_level" && n != "srs_log_level_v2" && n != "srs_log_file" && n != "max_connections" && n != "daemon" && n != "heartbeat" && n != "tencentcloud_apm" && n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms" && n != "http_server" && n != "stream_caster" && n != "rtc_server" && n != "srt_server" && n != "utc_time" && n != "work_dir" && n != "asprocess" && n != "server_id" && n != "ff_log_level" && n != "grace_final_wait" && n != "force_grace_quit" && n != "grace_start_wait" && n != "empty_ip_ok" && n != "disable_daemon_for_docker" && n != "inotify_auto_reload" && n != "auto_reload_for_docker" && n != "tcmalloc_release_rate" && n != "query_latest_version" && n != "first_wait_for_qlv" && n != "circuit_breaker" && n != "is_full" && n != "in_docker" && n != "tencentcloud_cls" && n != "exporter" && n != "rtsp_server" && n != "rtmp" && n != "rtmps") { return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal directive %s", n.c_str()); } } @@ -2452,6 +2440,15 @@ srs_error_t SrsConfig::check_normal_config() } } } + if (true) { + SrsConfDirective *conf = root->get("rtmp"); + for (int i = 0; conf && i < (int)conf->directives.size(); i++) { + string n = conf->at(i)->name; + if (n != "listen" && n != "chunk_size") { + return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "illegal rtmp.%s", n.c_str()); + } + } + } if (true) { SrsConfDirective *conf = root->get("rtmps"); for (int i = 0; conf && i < (int)conf->directives.size(); i++) { @@ -3070,7 +3067,12 @@ vector SrsConfig::get_listens() return srs_string_split(srs_getenv("srs.listen"), " "); } - SrsConfDirective *conf = root->get("listen"); + SrsConfDirective *rtmp_conf = root->get("rtmp"); + if (!rtmp_conf) { + return ports; + } + + SrsConfDirective *conf = rtmp_conf->get("listen"); if (!conf) { return ports; } @@ -3302,30 +3304,6 @@ double SrsConfig::tcmalloc_release_rate() return trr; } -srs_utime_t SrsConfig::get_threads_interval() -{ - SRS_OVERWRITE_BY_ENV_SECONDS("srs.threads.interval"); // SRS_THREADS_INTERVAL - - static srs_utime_t DEFAULT = 5 * SRS_UTIME_SECONDS; - - SrsConfDirective *conf = root->get("threads"); - if (!conf) { - return DEFAULT; - } - - conf = conf->get("interval"); - if (!conf || conf->arg0().empty()) { - return DEFAULT; - } - - int v = ::atoi(conf->arg0().c_str()); - if (v <= 0) { - return DEFAULT; - } - - return v * SRS_UTIME_SECONDS; -} - bool SrsConfig::get_circuit_breaker() { SRS_OVERWRITE_BY_ENV_BOOL2("srs.circuit_breaker.enabled"); // SRS_CIRCUIT_BREAKER_ENABLED @@ -5653,7 +5631,12 @@ int SrsConfig::get_global_chunk_size() { SRS_OVERWRITE_BY_ENV_INT("srs.vhost.chunk_size"); // SRS_VHOST_CHUNK_SIZE - SrsConfDirective *conf = root->get("chunk_size"); + SrsConfDirective *rtmp_conf = root->get("rtmp"); + if (!rtmp_conf) { + return SRS_CONSTS_RTMP_SRS_CHUNK_SIZE; + } + + SrsConfDirective *conf = rtmp_conf->get("chunk_size"); if (!conf || conf->arg0().empty()) { return SRS_CONSTS_RTMP_SRS_CHUNK_SIZE; } diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 83de76990..659d677a3 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -367,7 +367,6 @@ public: virtual srs_error_t raw_to_json(SrsJsonObject *obj); private: - virtual srs_error_t do_reload_listen(); virtual srs_error_t do_reload_max_connections(); virtual srs_error_t do_reload_pithy_print_ms(); virtual srs_error_t do_reload_vhost_added(std::string vhost); @@ -480,7 +479,6 @@ public: virtual double tcmalloc_release_rate(); // Thread pool section. public: - virtual srs_utime_t get_threads_interval(); virtual bool get_circuit_breaker(); virtual int get_high_threshold(); virtual int get_high_pulse(); diff --git a/trunk/src/app/srs_app_ingest.cpp b/trunk/src/app/srs_app_ingest.cpp index 39e4d875d..bf019490c 100644 --- a/trunk/src/app/srs_app_ingest.cpp +++ b/trunk/src/app/srs_app_ingest.cpp @@ -586,9 +586,3 @@ srs_error_t SrsIngester::on_reload_ingest_updated(string vhost, string ingest_id return err; } - -srs_error_t SrsIngester::on_reload_listen() -{ - expired = true; - return srs_success; -} diff --git a/trunk/src/app/srs_app_ingest.hpp b/trunk/src/app/srs_app_ingest.hpp index fd5b04f55..80c15025a 100644 --- a/trunk/src/app/srs_app_ingest.hpp +++ b/trunk/src/app/srs_app_ingest.hpp @@ -103,7 +103,6 @@ public: virtual srs_error_t on_reload_ingest_removed(std::string vhost, std::string ingest_id); virtual srs_error_t on_reload_ingest_added(std::string vhost, std::string ingest_id); virtual srs_error_t on_reload_ingest_updated(std::string vhost, std::string ingest_id); - virtual srs_error_t on_reload_listen(); }; #endif diff --git a/trunk/src/app/srs_app_reload.cpp b/trunk/src/app/srs_app_reload.cpp index fbd1637d6..d6f5ba42a 100644 --- a/trunk/src/app/srs_app_reload.cpp +++ b/trunk/src/app/srs_app_reload.cpp @@ -18,11 +18,6 @@ ISrsReloadHandler::~ISrsReloadHandler() { } -srs_error_t ISrsReloadHandler::on_reload_listen() -{ - return srs_success; -} - srs_error_t ISrsReloadHandler::on_reload_max_conns() { return srs_success; diff --git a/trunk/src/app/srs_app_reload.hpp b/trunk/src/app/srs_app_reload.hpp index 1f3e03e01..ce117a108 100644 --- a/trunk/src/app/srs_app_reload.hpp +++ b/trunk/src/app/srs_app_reload.hpp @@ -24,7 +24,6 @@ public: public: virtual srs_error_t on_reload_max_conns(); - virtual srs_error_t on_reload_listen(); virtual srs_error_t on_reload_pithy_print(); virtual srs_error_t on_reload_http_api_raw_api(); virtual srs_error_t on_reload_rtc_server(); diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 9131b03e3..6c5e3152f 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -1386,17 +1386,6 @@ void SrsServer::remove(ISrsResource *c) conn_manager->remove(c); } -srs_error_t SrsServer::on_reload_listen() -{ - srs_error_t err = srs_success; - - if ((err = listen()) != srs_success) { - return srs_error_wrap(err, "reload listen"); - } - - return err; -} - srs_error_t SrsServer::on_publish(ISrsRequest *r) { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_server.hpp b/trunk/src/app/srs_app_server.hpp index 960f7c321..97e47c1e0 100644 --- a/trunk/src/app/srs_app_server.hpp +++ b/trunk/src/app/srs_app_server.hpp @@ -253,7 +253,6 @@ public: virtual void remove(ISrsResource *c); // Interface ISrsReloadHandler. public: - virtual srs_error_t on_reload_listen(); // Interface ISrsLiveSourceHandler public: virtual srs_error_t on_publish(ISrsRequest *r); diff --git a/trunk/src/core/srs_core_version7.hpp b/trunk/src/core/srs_core_version7.hpp index 666238901..614dff2d2 100644 --- a/trunk/src/core/srs_core_version7.hpp +++ b/trunk/src/core/srs_core_version7.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 7 #define VERSION_MINOR 0 -#define VERSION_REVISION 63 +#define VERSION_REVISION 64 #endif \ No newline at end of file diff --git a/trunk/src/utest/srs_utest_config.cpp b/trunk/src/utest/srs_utest_config.cpp index 2568bbbe1..597eadd0d 100644 --- a/trunk/src/utest/srs_utest_config.cpp +++ b/trunk/src/utest/srs_utest_config.cpp @@ -1058,42 +1058,42 @@ VOID TEST(ConfigMainTest, CheckConf_chunk_size) if (true) { MockSrsConfig conf; - HELPER_ASSERT_SUCCESS(conf.parse(_MIN_OK_CONF "chunk_size 60000;")); + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1935; chunk_size 60000;}")); } if (true) { MockSrsConfig conf; - HELPER_ASSERT_FAILED(conf.parse(_MIN_OK_CONF "chunk_sizes 60000;")); + HELPER_ASSERT_FAILED(conf.parse("rtmp{listen 1935; chunk_sizes 60000;}")); } if (true) { MockSrsConfig conf; - HELPER_ASSERT_SUCCESS(conf.parse(_MIN_OK_CONF "chunk_size 0;")); + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1935; chunk_size 0;}")); } if (true) { MockSrsConfig conf; - HELPER_ASSERT_SUCCESS(conf.parse(_MIN_OK_CONF "chunk_size 1;")); + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1935; chunk_size 1;}")); } if (true) { MockSrsConfig conf; - HELPER_ASSERT_SUCCESS(conf.parse(_MIN_OK_CONF "chunk_size 127;")); + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1935; chunk_size 127;}")); } if (true) { MockSrsConfig conf; - HELPER_ASSERT_SUCCESS(conf.parse(_MIN_OK_CONF "chunk_size -1;")); + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1935; chunk_size -1;}")); } if (true) { MockSrsConfig conf; - HELPER_ASSERT_SUCCESS(conf.parse(_MIN_OK_CONF "chunk_size -4096;")); + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1935; chunk_size -4096;}")); } if (true) { MockSrsConfig conf; - HELPER_ASSERT_SUCCESS(conf.parse(_MIN_OK_CONF "chunk_size 65537;")); + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1935; chunk_size 65537;}")); } } @@ -2042,6 +2042,98 @@ VOID TEST(ConfigMainTest, CheckConf_chunk_size2) } } +VOID TEST(ConfigMainTest, TransformRtmpConfig) +{ + srs_error_t err; + + // Test backward compatibility: global listen should be transformed to rtmp.listen + if (true) { + MockSrsConfig conf; + HELPER_ASSERT_SUCCESS(conf.parse("listen 1935;")); + + // After parsing and transformation, should be able to get listen from rtmp section + vector listens = conf.get_listens(); + EXPECT_EQ(1, (int)listens.size()); + EXPECT_STREQ("1935", listens.at(0).c_str()); + + // Verify the rtmp section was created + SrsConfDirective *rtmp_section = conf.get_root()->get("rtmp"); + EXPECT_TRUE(rtmp_section != NULL); + if (rtmp_section) { + SrsConfDirective *listen_dir = rtmp_section->get("listen"); + EXPECT_TRUE(listen_dir != NULL); + if (listen_dir) { + EXPECT_STREQ("1935", listen_dir->arg0().c_str()); + } + } + } + + // Test backward compatibility: global chunk_size should be transformed to rtmp.chunk_size + if (true) { + MockSrsConfig conf; + HELPER_ASSERT_SUCCESS(conf.parse("listen 1935; chunk_size 60000;")); + + // After parsing and transformation, should be able to get chunk_size from rtmp section + EXPECT_EQ(60000, conf.get_global_chunk_size()); + + // Verify the rtmp section contains chunk_size + SrsConfDirective *rtmp_section = conf.get_root()->get("rtmp"); + EXPECT_TRUE(rtmp_section != NULL); + if (rtmp_section) { + SrsConfDirective *chunk_size_dir = rtmp_section->get("chunk_size"); + EXPECT_TRUE(chunk_size_dir != NULL); + if (chunk_size_dir) { + EXPECT_STREQ("60000", chunk_size_dir->arg0().c_str()); + } + } + } + + // Test backward compatibility: multiple global RTMP configs + if (true) { + MockSrsConfig conf; + HELPER_ASSERT_SUCCESS(conf.parse("listen 1935 1936; chunk_size 128;")); + + // Verify listen ports + vector listens = conf.get_listens(); + EXPECT_EQ(2, (int)listens.size()); + EXPECT_STREQ("1935", listens.at(0).c_str()); + EXPECT_STREQ("1936", listens.at(1).c_str()); + + // Verify chunk size + EXPECT_EQ(128, conf.get_global_chunk_size()); + } + + // Test that new rtmp section format still works + if (true) { + MockSrsConfig conf; + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1937; chunk_size 256;}")); + + vector listens = conf.get_listens(); + EXPECT_EQ(1, (int)listens.size()); + EXPECT_STREQ("1937", listens.at(0).c_str()); + EXPECT_EQ(256, conf.get_global_chunk_size()); + } + + // Test mixed format: existing rtmp section + global configs (global should be merged) + if (true) { + MockSrsConfig conf; + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1938;} chunk_size 512;")); + + vector listens = conf.get_listens(); + EXPECT_EQ(1, (int)listens.size()); + EXPECT_STREQ("1938", listens.at(0).c_str()); + EXPECT_EQ(512, conf.get_global_chunk_size()); + + // Verify both directives are in the rtmp section + SrsConfDirective *rtmp_section = conf.get_root()->get("rtmp"); + EXPECT_TRUE(rtmp_section != NULL); + if (rtmp_section) { + EXPECT_TRUE(rtmp_section->get("listen") != NULL); + EXPECT_TRUE(rtmp_section->get("chunk_size") != NULL); + } + } +} + VOID TEST(ConfigMainTest, CheckConf_jitter) { srs_error_t err; @@ -2868,13 +2960,13 @@ VOID TEST(ConfigMainTest, CheckGlobalConfig) if (true) { MockSrsConfig conf; - HELPER_ASSERT_SUCCESS(conf.parse("listen 1935;")); + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1935;}")); EXPECT_EQ(1, (int)conf.get_listens().size()); } if (true) { MockSrsConfig conf; - HELPER_ASSERT_SUCCESS(conf.parse("listen 1935 1936;")); + HELPER_ASSERT_SUCCESS(conf.parse("rtmp{listen 1935 1936;}")); EXPECT_EQ(2, (int)conf.get_listens().size()); } @@ -3862,7 +3954,7 @@ VOID TEST(ConfigMainTest, CheckIncludeConfig) if (true) { MockSrsConfig conf; - conf.mock_include("./conf/include_test/include.conf", "listen 1935;include ./conf/include_test/include_1.conf;"); + conf.mock_include("./conf/include_test/include.conf", "rtmp{listen 1935;}include ./conf/include_test/include_1.conf;"); conf.mock_include("./conf/include_test/include_1.conf", "max_connections 1000;daemon off;srs_log_tank console;http_server {enabled on;listen xxx;dir xxx2;}vhost ossrs.net {hls {enabled on;hls_path xxx;hls_m3u8_file xxx1;hls_ts_file xxx2;hls_fragment 10;hls_window 60;}}"); HELPER_ASSERT_SUCCESS(conf.parse("include ./conf/include_test/include.conf;")); @@ -4210,16 +4302,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesGlobal) } } -VOID TEST(ConfigEnvTest, CheckEnvValuesthreads) -{ - if (true) { - MockSrsConfig conf; - - SrsSetEnvConfig(conf, threads_interval, "SRS_THREADS_INTERVAL", "10"); - EXPECT_EQ(10 * SRS_UTIME_SECONDS, conf.get_threads_interval()); - } -} - VOID TEST(ConfigEnvTest, CheckEnvValuesRtmp) { if (true) { diff --git a/trunk/src/utest/srs_utest_config.hpp b/trunk/src/utest/srs_utest_config.hpp index 2586562d1..390389e8a 100644 --- a/trunk/src/utest/srs_utest_config.hpp +++ b/trunk/src/utest/srs_utest_config.hpp @@ -16,7 +16,7 @@ #include -#define _MIN_OK_CONF "listen 1935; " +#define _MIN_OK_CONF "rtmp{listen 1935;} " class MockSrsConfigBuffer : public srs_internal::SrsConfigBuffer { diff --git a/trunk/src/utest/srs_utest_reload.cpp b/trunk/src/utest/srs_utest_reload.cpp index 4731a1605..1ec2b4b68 100644 --- a/trunk/src/utest/srs_utest_reload.cpp +++ b/trunk/src/utest/srs_utest_reload.cpp @@ -21,7 +21,6 @@ MockReloadHandler::~MockReloadHandler() void MockReloadHandler::reset() { - listen_reloaded = false; pithy_print_reloaded = false; vhost_added_reloaded = false; vhost_removed_reloaded = false; @@ -44,8 +43,6 @@ int MockReloadHandler::count_true() { int count_true = 0; - if (listen_reloaded) - count_true++; if (pithy_print_reloaded) count_true++; if (vhost_added_reloaded) @@ -76,8 +73,6 @@ int MockReloadHandler::count_false() { int count_false = 0; - if (!listen_reloaded) - count_false++; if (!pithy_print_reloaded) count_false++; if (!vhost_added_reloaded) @@ -114,12 +109,6 @@ bool MockReloadHandler::all_true() return count_true() == count_total(); } -srs_error_t MockReloadHandler::on_reload_listen() -{ - listen_reloaded = true; - return srs_success; -} - srs_error_t MockReloadHandler::on_reload_pithy_print() { pithy_print_reloaded = true; @@ -229,49 +218,6 @@ VOID TEST(ConfigReloadTest, ReloadEmpty) EXPECT_TRUE(handler.all_false()); } -VOID TEST(ConfigReloadTest, ReloadListen) -{ - srs_error_t err = srs_success; - - MockReloadHandler handler; - MockSrsReloadConfig conf; - - conf.subscribe(&handler); - HELPER_EXPECT_SUCCESS(conf.parse("listen 1935;")); - HELPER_EXPECT_SUCCESS(conf.do_reload("listen 1935;")); - EXPECT_TRUE(handler.all_false()); - handler.reset(); - - HELPER_EXPECT_SUCCESS(conf.do_reload("listen 1936;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - HELPER_EXPECT_SUCCESS(conf.do_reload("listen 1936;")); - EXPECT_TRUE(handler.all_false()); - handler.reset(); - - HELPER_EXPECT_SUCCESS(conf.do_reload("listen 1936 1935;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - HELPER_EXPECT_SUCCESS(conf.do_reload("listen 1935;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - HELPER_EXPECT_SUCCESS(conf.do_reload("listen 1935 1935;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - HELPER_EXPECT_SUCCESS(conf.do_reload("listen 1935;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); -} - VOID TEST(ConfigReloadTest, ReloadPithyPrint) { srs_error_t err = srs_success; diff --git a/trunk/src/utest/srs_utest_reload.hpp b/trunk/src/utest/srs_utest_reload.hpp index 02cb55d59..952714777 100644 --- a/trunk/src/utest/srs_utest_reload.hpp +++ b/trunk/src/utest/srs_utest_reload.hpp @@ -18,7 +18,6 @@ class MockReloadHandler : public ISrsReloadHandler { public: - bool listen_reloaded; bool pithy_print_reloaded; bool vhost_added_reloaded; bool vhost_removed_reloaded; @@ -44,7 +43,6 @@ public: virtual int count_false(); public: - virtual srs_error_t on_reload_listen(); virtual srs_error_t on_reload_pithy_print(); virtual srs_error_t on_reload_vhost_added(std::string vhost); virtual srs_error_t on_reload_vhost_removed(std::string vhost);