diff --git a/.run/private.run.xml b/.run/private.run.xml index 6496d2e86..ca5b126cf 100644 --- a/.run/private.run.xml +++ b/.run/private.run.xml @@ -1,5 +1,8 @@ + + + diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index dfc589754..4a7cf3416 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -15,58 +15,69 @@ server_id srs-ie193id; # The pid file to write the pid, for managing the SRS process and avoiding duplicated processes. # If need to run multiple processes, please change this pid file to another one. # Note: Do not support reloading, for SRS5+ +# Overwrite by env SRS_PID # Default: ./objs/srs.pid pid ./objs/srs.pid; # the log dir for FFMPEG. # if enabled ffmpeg, each transcoding stream will create a log file. # /dev/null to disable the log. # Note: Do not support reloading, for SRS5+ +# Overwrite by env SRS_FF_LOG_DIR # default: ./objs ff_log_dir ./objs; # the log level for FFMPEG. # info warning error fatal panic quiet # trace debug verbose # Note: Do not support reloading, for SRS5+ +# Overwrite by env SRS_FF_LOG_LEVEL # default: info ff_log_level info; # the log tank, console or file. # if console, print log to console. # if file, write log to file. requires srs_log_file if log to file. # Note: Do not support reloading, for SRS5+ +# Overwrite by env SRS_SRS_LOG_TANK # default: file. srs_log_tank console; # the log level, for all log tanks. # can be: verbose, info, trace, warn, error # Note: Do not support reloading, for SRS5+ +# Overwrite by env SRS_SRS_LOG_LEVEL # default: trace srs_log_level trace; # when srs_log_tank is file, specifies the log file. # Note: Do not support reloading, for SRS5+ +# Overwrite by env SRS_SRS_LOG_FILE # default: ./objs/srs.log srs_log_file ./objs/srs.log; # the max connections. # if exceed the max connections, server will drop the new connection. +# Overwrite by env SRS_MAX_CONNECTIONS # default: 1000 max_connections 1000; # whether start as daemon # @remark: do not support reload. +# Overwrite by env SRS_DAEMON # default: on daemon off; # whether use utc_time to generate the time struct, # if off, use localtime() to generate it, # if on, use gmtime() instead, which use UTC time. # Note: Do not support reloading, for SRS5+ +# Overwrite by env SRS_UTC_TIME # default: off utc_time off; # config for the pithy print in ms, # which always print constant message specified by interval, # whatever the clients in concurrency. +# Overwrite by env SRS_PITHY_PRINT_MS # default: 10000 pithy_print_ms 10000; # the work dir for server, to chdir(work_dir) when not empty or "./" # user can config this directory to change the dir. # @reamrk do not support reload. +# Overwrite by env SRS_WORK_DIR # default: ./ work_dir ./; # whether quit when parent process changed, @@ -74,42 +85,51 @@ work_dir ./; # supervisor process exited. # @remark conflict with daemon, error when both daemon and asprocess are on. # @reamrk do not support reload. +# Overwrite by env SRS_ASPROCESS # default: off asprocess off; # Whether client empty IP is ok, for example, health checking by SLB. # If ok(on), we will ignore this connection without warnings or errors. +# Overwrite by env SRS_EMPTY_IP_OK # default: on empty_ip_ok on; # Whether in docker. When SRS starting, it will detect the docker, however # it might detect failed, then read this config. +# Overwrite by env SRS_IN_DOCKER # Default: off in_docker off; # For gracefully quit, wait for a while then close listeners, # because K8S notify SRS with SIGQUIT and update Service simultaneously, # maybe there is some new connections incoming before Service updated. # @see https://github.com/ossrs/srs/issues/1595#issuecomment-587516567 +# Overwrite by env SRS_GRACE_START_WAIT # default: 2300 grace_start_wait 2300; # For gracefully quit, final wait for cleanup in milliseconds. # @see https://github.com/ossrs/srs/issues/1579#issuecomment-587414898 +# Overwrite by env SRS_GRACE_FINAL_WAIT # default: 3200 grace_final_wait 3200; # Whether force gracefully quit, never fast quit. # By default, SIGTERM which means fast quit, is sent by K8S, so we need to # force SRS to treat SIGTERM as gracefully quit for gray release or canary. # @see https://github.com/ossrs/srs/issues/1579#issuecomment-587475077 +# Overwrite by env SRS_FORCE_GRACE_QUIT # default: off force_grace_quit off; # Whether disable daemon for docker. # If on, it will set daemon to off in docker, even daemon is on. +# Overwrite by env SRS_DISABLE_DAEMON_FOR_DOCKER # default: on disable_daemon_for_docker on; # Whether auto reload by watching the config file by inotify. +# Overwrite by env SRS_INOTIFY_AUTO_RELOAD # default: off inotify_auto_reload off; # Whether enable inotify_auto_reload for docker. # If on, it will set inotify_auto_reload to on in docker, even it's off. +# Overwrite by env SRS_AUTO_RELOAD_FOR_DOCKER # default: on auto_reload_for_docker on; @@ -125,6 +145,7 @@ listen 1935; # 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; @@ -150,17 +171,20 @@ http_api { # Default: 1985 listen 8080; # whether enable crossdomain request. + # Overwrite by env SRS_HTTP_API_CROSSDOMAIN # default: on crossdomain on; # the HTTP RAW API is more powerful api to change srs state and reload. raw_api { # whether enable the HTTP RAW API. + # Overwrite by env SRS_HTTP_API_RAW_API_ENABLED # default: off enabled off; # whether enable rpc reload. # default: off allow_reload off; # whether enable rpc query. + # Overwrite by env SRS_HTTP_API_RAW_API_ALLOW_RELOAD # Always off by https://github.com/ossrs/srs/issues/2653 #allow_query off; # whether enable rpc update. @@ -181,10 +205,12 @@ http_api { listen 8088; # The SSL private key file, generated by: # openssl genrsa -out server.key 2048 + # Overwrite by env SRS_HTTP_API_HTTPS_KEY # default: ./conf/server.key key ./conf/server.key; # The SSL public cert file, generated by: # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" + # Overwrite by env SRS_HTTP_API_HTTPS_CERT # default: ./conf/server.crt cert ./conf/server.crt; } @@ -212,28 +238,32 @@ http_server { # default: 8080 listen 8080; # the default dir for http root. + # Overwrite by env SRS_HTTP_SERVER_DIR # default: ./objs/nginx/html dir ./objs/nginx/html; # whether enable crossdomain request. # for both http static and stream server and apply on all vhosts. + # Overwrite by env SRS_HTTP_SERVER_CROSSDOMAIN # default: on crossdomain on; # For https_server or HTTPS Streaming. https { # Whether enable HTTPS Streaming. - # Overwrite by env SRS_HTTP_SERVER_HTTTPS_ENABLED + # Overwrite by env SRS_HTTP_SERVER_HTTPS_ENABLED # default: off enabled on; # The listen endpoint for HTTPS Streaming. - # Overwrite by env SRS_HTTP_SERVER_HTTTPS_LISTEN + # Overwrite by env SRS_HTTP_SERVER_HTTPS_LISTEN # default: 8088 listen 8088; # The SSL private key file, generated by: # openssl genrsa -out server.key 2048 + # Overwrite by env SRS_HTTP_SERVER_HTTPS_KEY # default: ./conf/server.key key ./conf/server.key; # The SSL public cert file, generated by: # openssl req -new -x509 -key server.key -out server.crt -days 3650 -subj "/C=CN/ST=Beijing/L=Beijing/O=Me/OU=Me/CN=ossrs.net" + # Overwrite by env SRS_HTTP_SERVER_HTTPS_CERT # default: ./conf/server.crt cert ./conf/server.crt; } @@ -245,9 +275,11 @@ http_server { # @doc https://github.com/ossrs/srs/issues/1147#usage srt_server { # whether SRT server is enabled. + # Overwrite by env SRS_SRT_SERVER_ENABLED # default: off enabled on; # The UDP listen port for SRT. + # Overwrite by env SRS_SRT_SERVER_LISTEN listen 10080; # For detail parameters, please read wiki: # @see https://ossrs.net/lts/zh-cn/docs/v5/doc/srt-params @@ -256,50 +288,63 @@ srt_server { # -1: Means the biggest bandwidth is infinity. # 0: Means the bandwidth is determined by SRTO_INPUTBW. # >0: Means the bandwidth is the configuration value. + # Overwrite by env SRS_SRT_SERVER_MAXBW # default: -1 maxbw 1000000000; # The timeout time of the SRT connection on the sender side in ms. When SRT connects to a peer costs time # more than this config, it will be close. + # Overwrite by env SRS_SRT_SERVER_CONNECT_TIMEOUT # default: 3000 connect_timeout 4000; # The timeout time of SRT connection on the receiver side in ms. When the SRT connection is idle # more than this config, it will be close. + # Overwrite by env SRS_SRT_SERVER_PEER_IDLE_TIMEOUT # default: 10000 peer_idle_timeout 8000; # Default app for vmix, see https://github.com/ossrs/srs/pull/1615 + # Overwrite by env SRS_SRT_SERVER_DEFAULT_APP # default: live default_app live; # The peerlatency is set by the sender side and will notify the receiver side. + # Overwrite by env SRS_SRT_SERVER_PEERLATENCY # default: 0 peerlatency 0; # The recvlatency means latency from sender to receiver. + # Overwrite by env SRS_SRT_SERVER_RECVLATENCY # default: 120 recvlatency 0; # This latency configuration configures both recvlatency and peerlatency to the same value. + # Overwrite by env SRS_SRT_SERVER_LATENCY # default: 120 latency 0; # The tsbpd mode means timestamp based packet delivery. # SRT sender side will pack timestamp in each packet. If this config is true, # the receiver will read the packet according to the timestamp in the head of the packet. + # Overwrite by env SRS_SRT_SERVER_TSBPDMODE # default: on tsbpdmode off; # The tlpkdrop means too-late Packet Drop # SRT sender side will pack timestamp in each packet, When the network is congested, # the packet will drop if latency is bigger than the configuration in both sender side and receiver side. # And on the sender side, it also will be dropped because latency is bigger than configuration. + # Overwrite by env SRS_SRT_SERVER_TLPKDROP_TLPKTDROP # default: on tlpktdrop off; # The send buffer size of SRT. + # Overwrite by env SRS_SRT_SERVER_SENDBUF # default: 8192 * (1500-28) sendbuf 2000000; # The recv buffer size of SRT. + # Overwrite by env SRS_SRT_SERVER_RECVBUF # default: 8192 * (1500-28) recvbuf 2000000; } vhost srt.vhost.srs.com { srt { + # Overwrite by env SRS_SRT_ENABLED for all vhosts. enabled on; + # Overwrite by env SRS_SRT_TO_RTMP for all vhosts. srt_to_rtmp on; } } @@ -379,19 +424,23 @@ rtc_server { keep_api_domain off; # Whether use ECDSA certificate. # If not, use RSA certificate. + # Overwrite by env SRS_RTC_SERVER_ECDSA # default: on ecdsa on; # Whether encrypt RTP packet by SRTP. # @remark Should always turn it on, or Chrome will fail. + # Overwrite by env SRS_RTC_SERVER_ENCRYPT # default: on encrypt on; # We listen multiple times at the same port, by REUSEPORT, to increase the UDP queue. # Note that you can set to 1 and increase the system UDP buffer size by net.core.rmem_max # and net.core.rmem_default or just increase this to get larger UDP recv and send buffer. + # Overwrite by env SRS_RTC_SERVER_REUSEPORT # default: 1 reuseport 1; # Whether merge multiple NALUs into one. # @see https://github.com/ossrs/srs/issues/307#issuecomment-612806318 + # Overwrite by env SRS_RTC_SERVER_MERGE_NALUS # default: off merge_nalus off; # The black-hole to copy packet to, for debugging. @@ -400,9 +449,11 @@ rtc_server { # we are able to capture the plaintext packets by wireshark. black_hole { # Whether enable the black-hole. + # Overwrite by env SRS_RTC_SERVER_BLACK_HOLE_ENABLED # default: off enabled off; # The black-hole address for session. + # Overwrite by env SRS_RTC_SERVER_BLACK_HOLE_ADDR addr 127.0.0.1:10000; } } @@ -414,28 +465,36 @@ vhost rtc.vhost.srs.com { # default: off enabled on; # Whether support NACK. + # Overwrite by env SRS_VHOST_RTC_NACK for all vhosts. # default: on nack on; # Whether directly use the packet, avoid copy. + # Overwrite by env SRS_VHOST_RTC_NACK_NO_COPY for all vhosts. # default: on nack_no_copy on; # Whether support TWCC. + # Overwrite by env SRS_VHOST_RTC_TWCC for all vhosts. # default: on twcc on; # The timeout in seconds for session timeout. # Client will send ping(STUN binding request) to server, we use it as heartbeat. + # Overwrite by env SRS_VHOST_RTC_STUN_TIMEOUT for all vhosts. # default: 30 stun_timeout 30; # The strict check when process stun. + # Overwrite by env SRS_VHOST_RTC_STUN_STRICT_CHECK for all vhosts. # default: off stun_strict_check on; # The role of dtls when peer is actpass: passive or active + # Overwrite by env SRS_VHOST_RTC_DTLS_ROLE for all vhosts. # default: passive dtls_role passive; # The version of dtls, support dtls1.0, dtls1.2, and auto + # Overwrite by env SRS_VHOST_RTC_DTLS_VERSION for all vhosts. # default: auto dtls_version auto; # Drop the packet with the pt(payload type), 0 never drop. + # Overwrite by env SRS_VHOST_RTC_DROP_FOR_PT for all vhosts. # default: 0 drop_for_pt 0; ############################################################### @@ -446,6 +505,7 @@ vhost rtc.vhost.srs.com { rtmp_to_rtc off; # Whether keep B-frame, which is normal feature in live streaming, # but usually disabled in RTC. + # Overwrite by env SRS_VHOST_RTC_KEEP_BFRAME for all vhosts. # default: off keep_bframe off; ############################################################### @@ -455,22 +515,26 @@ vhost rtc.vhost.srs.com { rtc_to_rtmp off; # The PLI interval in seconds, for RTC to RTMP. # Note the available range is [0.5, 30] + # Overwrite by env SRS_VHOST_RTC_PLI_FOR_RTMP for all vhosts. # Default: 6.0 pli_for_rtmp 6.0; } ############################################################### # For transmuxing RTMP to RTC, it will impact the default values if RTC is on. # Whether enable min delay mode for vhost. + # Overwrite by env SRS_VHOST_MIN_LATENCY for all vhosts. # default: on, for RTC. min_latency on; play { # set the MW(merged-write) latency in ms. # @remark For WebRTC, we enable pass-by-timestamp mode, so we ignore this config. + # Overwrite by env SRS_VHOST_PLAY_MW_LATENCY for all vhosts. # default: 0 (For WebRTC) mw_latency 0; # Set the MW(merged-write) min messages. # default: 0 (For Real-Time, that is min_latency on) # default: 1 (For WebRTC, that is min_latency off) + # Overwrite by env SRS_VHOST_PLAY_MW_MSGS for all vhosts. mw_msgs 0; } } @@ -525,12 +589,14 @@ stream_caster { # 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: on query_latest_version on; @@ -543,6 +609,7 @@ 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; } @@ -550,30 +617,37 @@ threads { # For system circuit breaker. circuit_breaker { # Whether enable the circuit breaker. + # Overwrite by env SRS_CIRCUIT_BREAKER_ENABLED # Default: on enabled on; # The CPU percent(0, 100) ever 1s, as system high water-level, which enable the circuit-break # mechanism, for example, NACK will be disabled if high water-level. + # Overwrite by env SRS_CIRCUIT_BREAKER_HIGH_THRESHOLD # Default: 90 high_threshold 90; # Reset the high water-level, if number of pulse under high_threshold. # @remark 0 to disable the high water-level. + # Overwrite by env SRS_CIRCUIT_BREAKER_HIGH_PULSE # Default: 2 high_pulse 2; # The CPU percent(0, 100) ever 1s, as system critical water-level, which enable the circuit-break # mechanism, for example, TWCC will be disabled if high water-level. # @note All circuit-break mechanism of high-water-level scope are enabled in critical. + # Overwrite by env SRS_CIRCUIT_BREAKER_CRITICAL_THRESHOLD # Default: 95 critical_threshold 95; # Reset the critical water-level, if number of pulse under critical_threshold. # @remark 0 to disable the critical water-level. + # Overwrite by env SRS_CIRCUIT_BREAKER_CRITICAL_PULSE # Default: 1 critical_pulse 1; # If dying, also drop packets for players. + # Overwrite by env SRS_CIRCUIT_BREAKER_DYING_THRESHOLD # Default: 99 dying_threshold 99; # If CPU exceed the dying_pulse times, enter dying. # @remark 0 to disable the dying water-level. + # Overwrite by env SRS_CIRCUIT_BREAKER_DYING_PULSE # Default: 5 dying_pulse 5; } @@ -685,10 +759,12 @@ exporter { # 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. @@ -697,9 +773,11 @@ heartbeat { # "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: @@ -707,6 +785,7 @@ heartbeat { # "summaries": summaries object. # } # @remark: optional config. + # Overwrite by env SRS_HEARTBEAT_SUMMARIES # default: off summaries off; } @@ -757,6 +836,7 @@ vhost scope.vhost.srs.com { # 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; @@ -942,11 +1022,13 @@ vhost play.srs.com { # 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; # 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; @@ -962,6 +1044,7 @@ vhost play.srs.com { # 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. @@ -976,12 +1059,14 @@ vhost play.srs.com { # @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; @@ -989,6 +1074,7 @@ vhost play.srs.com { # 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; @@ -998,6 +1084,7 @@ vhost play.srs.com { # 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; @@ -1005,6 +1092,7 @@ vhost play.srs.com { # 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, @@ -1014,11 +1102,13 @@ vhost play.srs.com { # @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; } @@ -1132,6 +1222,7 @@ vhost publish.srs.com { publish { # about MR, read https://github.com/ossrs/srs/issues/241 # 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), @@ -1142,22 +1233,27 @@ vhost publish.srs.com { # 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; } @@ -1226,6 +1322,7 @@ 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, @@ -1246,11 +1343,13 @@ vhost http.static.srs.com { # 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; } } @@ -1260,12 +1359,14 @@ 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; # the stream mount for rtmp to remux to live streaming. @@ -1293,6 +1394,7 @@ vhost http.remux.srs.com { # 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; } @@ -1460,25 +1562,31 @@ vhost dash.srs.com { dash { # Whether DASH is enabled. # Transmux RTMP to DASH if on. + # Overwrite by env SRS_VHOST_DASH_ENABLED for all vhosts. # Default: off enabled on; # The duration of segment in seconds. + # Overwrite by env SRS_VHOST_DASH_DASH_FRAGMENT for all vhosts. # Default: 30 dash_fragment 30; # The period to update the MPD in seconds. + # Overwrite by env SRS_VHOST_DASH_DASH_UPDATE_PERIOD for all vhosts. # Default: 150 dash_update_period 150; # The depth of timeshift buffer in seconds. + # Overwrite by env SRS_VHOST_DASH_DASH_TIMESHIFT for all vhosts. # Default: 300 dash_timeshift 300; # The base/home dir/path for dash. # All init and segment files will write under this dir. + # Overwrite by env SRS_VHOST_DASH_DASH_PATH for all vhosts. dash_path ./objs/nginx/html; # The DASH MPD file path. # We supports some variables to generate the filename. # [vhost], the vhost of stream. # [app], the app of stream. # [stream], the stream name of stream. + # Overwrite by env SRS_VHOST_DASH_DASH_MPD_FILE for all vhosts. # Default: [app]/[stream].mpd dash_mpd_file [app]/[stream].mpd; } diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index da138f7b1..4fd02e4a6 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -59,11 +59,15 @@ const char* _srs_version = "XCORE-" RTMP_SIG_SRS_SERVER; #define SRS_CR (char)SRS_CONSTS_CR // Overwrite the config by env. -#define SRS_OVERWRITE_BY_ENV_STRING(key) if (getenv(key)) return getenv(key) -#define SRS_OVERWRITE_BY_ENV_BOOL(key) if (getenv(key)) return SRS_CONF_PERFER_FALSE(string(getenv(key))) -#define SRS_OVERWRITE_BY_ENV_BOOL2(key) if (getenv(key)) return SRS_CONF_PERFER_TRUE(string(getenv(key))) -#define SRS_OVERWRITE_BY_ENV_INT(key) if (getenv(key)) return ::atoi(getenv(key)) -#define SRS_OVERWRITE_BY_ENV_SECONDS(key) if (getenv(key)) return ::atoi(getenv(key)) * SRS_UTIME_SECONDS +#define SRS_OVERWRITE_BY_ENV_STRING(key) if (!srs_getenv(key).empty()) return srs_getenv(key) +#define SRS_OVERWRITE_BY_ENV_BOOL(key) if (!srs_getenv(key).empty()) return SRS_CONF_PERFER_FALSE(srs_getenv(key)) +#define SRS_OVERWRITE_BY_ENV_BOOL2(key) if (!srs_getenv(key).empty()) return SRS_CONF_PERFER_TRUE(srs_getenv(key)) +#define SRS_OVERWRITE_BY_ENV_INT(key) if (!srs_getenv(key).empty()) return ::atoi(srs_getenv(key).c_str()) +#define SRS_OVERWRITE_BY_ENV_FLOAT(key) if (!srs_getenv(key).empty()) return ::atof(srs_getenv(key).c_str()) +#define SRS_OVERWRITE_BY_ENV_SECONDS(key) if (!srs_getenv(key).empty()) return srs_utime_t(::atoi(srs_getenv(key).c_str()) * SRS_UTIME_SECONDS) +#define SRS_OVERWRITE_BY_ENV_MILLISECONDS(key) if (!srs_getenv(key).empty()) return (srs_utime_t)(::atoi(srs_getenv(key).c_str()) * SRS_UTIME_MILLISECONDS) +#define SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS(key) if (!srs_getenv(key).empty()) return srs_utime_t(::atof(srs_getenv(key).c_str()) * SRS_UTIME_SECONDS) +#define SRS_OVERWRITE_BY_ENV_FLOAT_MILLISECONDS(key) if (!srs_getenv(key).empty()) return srs_utime_t(::atof(srs_getenv(key).c_str()) * SRS_UTIME_MILLISECONDS) /** * dumps the ingest/transcode-engine in @param dir to amf0 object @param engine. @@ -1827,9 +1831,9 @@ srs_error_t SrsConfig::parse_options(int argc, char** argv) } // Overwrite the config by env SRS_CONFIG_FILE. - if (::getenv("SRS_CONFIG_FILE")) { + if (!srs_getenv("srs.config.file").empty()) { string ov = config_file; - config_file = ::getenv("SRS_CONFIG_FILE"); + config_file = srs_getenv("srs.config.file"); srs_trace("ENV: Overwrite config %s to %s", ov.c_str(), config_file.c_str()); } @@ -2749,6 +2753,8 @@ string SrsConfig::argv() bool SrsConfig::get_daemon() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.daemon"); + SrsConfDirective* conf = root->get("daemon"); if (!conf || conf->arg0().empty()) { return true; @@ -2759,6 +2765,8 @@ bool SrsConfig::get_daemon() bool SrsConfig::get_in_docker() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.in_docker"); + static bool DEFAULT = false; SrsConfDirective* conf = root->get("in_docker"); @@ -2849,13 +2857,13 @@ string SrsConfig::get_server_id() // Get the server id from env, config or DEFAULT. string server_id; - if (getenv("SRS_SERVER_ID")) { - server_id = getenv("SRS_SERVER_ID"); - } - - SrsConfDirective* conf = root->get("server_id"); - if (conf) { - server_id = conf->arg0(); + if (!srs_getenv("srs.server_id").empty()) { + server_id = srs_getenv("srs.server_id"); + } else { + SrsConfDirective* conf = root->get("server_id"); + if (conf) { + server_id = conf->arg0(); + } } if (server_id.empty()) { @@ -2863,15 +2871,15 @@ string SrsConfig::get_server_id() } // Write server id to tmp file. - if (!server_id.empty()) { - srs_try_write_file(srs_server_id_path(get_pid_file()), server_id); - } + srs_try_write_file(srs_server_id_path(get_pid_file()), server_id); return server_id; } int SrsConfig::get_max_connections() { + SRS_OVERWRITE_BY_ENV_INT("srs.max_connections"); + static int DEFAULT = 1000; SrsConfDirective* conf = root->get("max_connections"); @@ -2886,9 +2894,8 @@ vector SrsConfig::get_listens() { std::vector ports; - // SRS_OVERWRITE_BY_ENV_STRING("SRS_LISTEN") - if (getenv("SRS_LISTEN")) { - ports.push_back(getenv("SRS_LISTEN")); + if (!srs_getenv("srs.listen").empty()) { + ports.push_back(srs_getenv("srs.listen")); return ports; } @@ -2906,6 +2913,8 @@ vector SrsConfig::get_listens() string SrsConfig::get_pid_file() { + SRS_OVERWRITE_BY_ENV_STRING("srs.pid"); + static string DEFAULT = "./objs/srs.pid"; SrsConfDirective* conf = root->get("pid"); @@ -2919,6 +2928,8 @@ string SrsConfig::get_pid_file() srs_utime_t SrsConfig::get_pithy_print() { + SRS_OVERWRITE_BY_ENV_MILLISECONDS("srs.pithy_print_ms"); + static srs_utime_t DEFAULT = 10 * SRS_UTIME_SECONDS; SrsConfDirective* conf = root->get("pithy_print_ms"); @@ -2931,6 +2942,8 @@ srs_utime_t SrsConfig::get_pithy_print() bool SrsConfig::get_utc_time() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.utc_time"); + static bool DEFAULT = false; SrsConfDirective* conf = root->get("utc_time"); @@ -2941,7 +2954,10 @@ bool SrsConfig::get_utc_time() return SRS_CONF_PERFER_FALSE(conf->arg0()); } -string SrsConfig::get_work_dir() { +string SrsConfig::get_work_dir() +{ + SRS_OVERWRITE_BY_ENV_STRING("srs.work_dir"); + static string DEFAULT = "./"; SrsConfDirective* conf = root->get("work_dir"); @@ -2954,6 +2970,8 @@ string SrsConfig::get_work_dir() { bool SrsConfig::get_asprocess() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.asprocess"); + static bool DEFAULT = false; SrsConfDirective* conf = root->get("asprocess"); @@ -2966,6 +2984,8 @@ bool SrsConfig::get_asprocess() bool SrsConfig::whether_query_latest_version() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.query_latest_version"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("query_latest_version"); @@ -2978,7 +2998,7 @@ bool SrsConfig::whether_query_latest_version() srs_utime_t SrsConfig::first_wait_for_qlv() { - SRS_OVERWRITE_BY_ENV_SECONDS("SRS_FIRST_WAIT_FOR_QLV"); + SRS_OVERWRITE_BY_ENV_SECONDS("srs.first_wait_for_qlv"); static srs_utime_t DEFAULT = 5 * 60 * SRS_UTIME_SECONDS; @@ -2992,6 +3012,8 @@ srs_utime_t SrsConfig::first_wait_for_qlv() bool SrsConfig::empty_ip_ok() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.empty_ip_ok"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("empty_ip_ok"); @@ -3004,6 +3026,8 @@ bool SrsConfig::empty_ip_ok() srs_utime_t SrsConfig::get_grace_start_wait() { + SRS_OVERWRITE_BY_ENV_MILLISECONDS("srs.grace_start_wait"); + static srs_utime_t DEFAULT = 2300 * SRS_UTIME_MILLISECONDS; SrsConfDirective* conf = root->get("grace_start_wait"); @@ -3016,6 +3040,8 @@ srs_utime_t SrsConfig::get_grace_start_wait() srs_utime_t SrsConfig::get_grace_final_wait() { + SRS_OVERWRITE_BY_ENV_MILLISECONDS("srs.grace_final_wait"); + static srs_utime_t DEFAULT = 3200 * SRS_UTIME_MILLISECONDS; SrsConfDirective* conf = root->get("grace_final_wait"); @@ -3028,6 +3054,8 @@ srs_utime_t SrsConfig::get_grace_final_wait() bool SrsConfig::is_force_grace_quit() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.force_grace_quit"); + static bool DEFAULT = false; SrsConfDirective* conf = root->get("force_grace_quit"); @@ -3040,6 +3068,8 @@ bool SrsConfig::is_force_grace_quit() bool SrsConfig::disable_daemon_for_docker() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.disable_daemon_for_docker"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("disable_daemon_for_docker"); @@ -3052,6 +3082,8 @@ bool SrsConfig::disable_daemon_for_docker() bool SrsConfig::inotify_auto_reload() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.inotify_auto_reload"); + static bool DEFAULT = false; SrsConfDirective* conf = root->get("inotify_auto_reload"); @@ -3064,6 +3096,8 @@ bool SrsConfig::inotify_auto_reload() bool SrsConfig::auto_reload_for_docker() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.auto_reload_for_docker"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("auto_reload_for_docker"); @@ -3077,6 +3111,13 @@ bool SrsConfig::auto_reload_for_docker() // TODO: FIXME: Support reload. double SrsConfig::tcmalloc_release_rate() { + if (!srs_getenv("srs.tcmalloc_release_rate").empty()) { + double trr = ::atof(srs_getenv("srs.tcmalloc_release_rate").c_str()); + trr = srs_min(10, trr); + trr = srs_max(0, trr); + return trr; + } + static double DEFAULT = SRS_PERF_TCMALLOC_RELEASE_RATE; SrsConfDirective* conf = root->get("tcmalloc_release_rate"); @@ -3092,6 +3133,8 @@ double SrsConfig::tcmalloc_release_rate() srs_utime_t SrsConfig::get_threads_interval() { + SRS_OVERWRITE_BY_ENV_SECONDS("srs.threads.interval"); + static srs_utime_t DEFAULT = 5 * SRS_UTIME_SECONDS; SrsConfDirective* conf = root->get("threads"); @@ -3114,6 +3157,8 @@ srs_utime_t SrsConfig::get_threads_interval() bool SrsConfig::get_circuit_breaker() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.circuit_breaker.enabled"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("circuit_breaker"); @@ -3131,6 +3176,8 @@ bool SrsConfig::get_circuit_breaker() int SrsConfig::get_high_threshold() { + SRS_OVERWRITE_BY_ENV_INT("srs.circuit_breaker.high_threshold"); + static int DEFAULT = 90; SrsConfDirective* conf = root->get("circuit_breaker"); @@ -3148,6 +3195,8 @@ int SrsConfig::get_high_threshold() int SrsConfig::get_high_pulse() { + SRS_OVERWRITE_BY_ENV_INT("srs.circuit_breaker.high_pulse"); + static int DEFAULT = 2; SrsConfDirective* conf = root->get("circuit_breaker"); @@ -3165,6 +3214,8 @@ int SrsConfig::get_high_pulse() int SrsConfig::get_critical_threshold() { + SRS_OVERWRITE_BY_ENV_INT("srs.circuit_breaker.critical_threshold"); + static int DEFAULT = 95; SrsConfDirective* conf = root->get("circuit_breaker"); @@ -3182,6 +3233,8 @@ int SrsConfig::get_critical_threshold() int SrsConfig::get_critical_pulse() { + SRS_OVERWRITE_BY_ENV_INT("srs.circuit_breaker.critical_pulse"); + static int DEFAULT = 1; SrsConfDirective* conf = root->get("circuit_breaker"); @@ -3199,6 +3252,8 @@ int SrsConfig::get_critical_pulse() int SrsConfig::get_dying_threshold() { + SRS_OVERWRITE_BY_ENV_INT("srs.circuit_breaker.dying_threshold"); + static int DEFAULT = 99; SrsConfDirective* conf = root->get("circuit_breaker"); @@ -3216,6 +3271,8 @@ int SrsConfig::get_dying_threshold() int SrsConfig::get_dying_pulse() { + SRS_OVERWRITE_BY_ENV_INT("srs.circuit_breaker.dying_threshold"); + static int DEFAULT = 5; SrsConfDirective* conf = root->get("circuit_breaker"); @@ -3233,7 +3290,7 @@ int SrsConfig::get_dying_pulse() bool SrsConfig::get_tencentcloud_cls_enabled() { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_TENCENTCLOUD_CLS_ENABLED"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.tencentcloud_cls.enabled"); static bool DEFAULT = false; @@ -3252,7 +3309,7 @@ bool SrsConfig::get_tencentcloud_cls_enabled() bool SrsConfig::get_tencentcloud_cls_stat_heartbeat() { - SRS_OVERWRITE_BY_ENV_BOOL2("SRS_TENCENTCLOUD_CLS_STAT_HEARTBEAT"); + SRS_OVERWRITE_BY_ENV_BOOL2("srs.tencentcloud_cls.stat_heartbeat"); static bool DEFAULT = true; @@ -3271,7 +3328,7 @@ bool SrsConfig::get_tencentcloud_cls_stat_heartbeat() bool SrsConfig::get_tencentcloud_cls_stat_streams() { - SRS_OVERWRITE_BY_ENV_BOOL2("SRS_TENCENTCLOUD_CLS_STAT_STREAMS"); + SRS_OVERWRITE_BY_ENV_BOOL2("srs.tencentcloud_cls.stat_streams"); static bool DEFAULT = true; @@ -3290,7 +3347,7 @@ bool SrsConfig::get_tencentcloud_cls_stat_streams() bool SrsConfig::get_tencentcloud_cls_debug_logging() { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_TENCENTCLOUD_CLS_DEBUG_LOGGING"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.tencentcloud_cls.debug_logging"); static bool DEFAULT = false; @@ -3309,7 +3366,7 @@ bool SrsConfig::get_tencentcloud_cls_debug_logging() int SrsConfig::get_tencentcloud_cls_heartbeat_ratio() { - SRS_OVERWRITE_BY_ENV_INT("SRS_TENCENTCLOUD_CLS_HEARTBEAT_RATIO"); + SRS_OVERWRITE_BY_ENV_INT("srs.tencentcloud_cls.heartbeat_ratio"); static int DEFAULT = 1; @@ -3328,7 +3385,7 @@ int SrsConfig::get_tencentcloud_cls_heartbeat_ratio() int SrsConfig::get_tencentcloud_cls_streams_ratio() { - SRS_OVERWRITE_BY_ENV_INT("SRS_TENCENTCLOUD_CLS_STREAMS_RATIO"); + SRS_OVERWRITE_BY_ENV_INT("srs.tencentcloud_cls.streams_ratio"); static int DEFAULT = 1; @@ -3347,7 +3404,7 @@ int SrsConfig::get_tencentcloud_cls_streams_ratio() string SrsConfig::get_tencentcloud_cls_label() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_CLS_LABEL"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.label"); static string DEFAULT = ""; @@ -3366,7 +3423,7 @@ string SrsConfig::get_tencentcloud_cls_label() string SrsConfig::get_tencentcloud_cls_tag() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_CLS_TAG"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.tag"); static string DEFAULT = ""; @@ -3385,7 +3442,7 @@ string SrsConfig::get_tencentcloud_cls_tag() string SrsConfig::get_tencentcloud_cls_secret_id() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_CLS_SECRET_ID"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.secret_id"); static string DEFAULT = ""; @@ -3404,7 +3461,7 @@ string SrsConfig::get_tencentcloud_cls_secret_id() string SrsConfig::get_tencentcloud_cls_secret_key() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_CLS_SECRET_KEY"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.secret_key"); static string DEFAULT = ""; @@ -3423,7 +3480,7 @@ string SrsConfig::get_tencentcloud_cls_secret_key() string SrsConfig::get_tencentcloud_cls_endpoint() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_CLS_ENDPOINT"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.endpoint"); static string DEFAULT = ""; @@ -3442,7 +3499,7 @@ string SrsConfig::get_tencentcloud_cls_endpoint() string SrsConfig::get_tencentcloud_cls_topic_id() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_CLS_TOPIC_ID"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.topic_id"); static string DEFAULT = ""; @@ -3461,7 +3518,7 @@ string SrsConfig::get_tencentcloud_cls_topic_id() bool SrsConfig::get_tencentcloud_apm_enabled() { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_TENCENTCLOUD_APM_ENABLED"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.tencentcloud_apm.enabled"); static bool DEFAULT = false; @@ -3480,7 +3537,7 @@ bool SrsConfig::get_tencentcloud_apm_enabled() string SrsConfig::get_tencentcloud_apm_team() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_APM_TEAM"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_apm.team"); static string DEFAULT = ""; @@ -3499,7 +3556,7 @@ string SrsConfig::get_tencentcloud_apm_team() string SrsConfig::get_tencentcloud_apm_token() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_APM_TOKEN"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_apm.token"); static string DEFAULT = ""; @@ -3518,7 +3575,7 @@ string SrsConfig::get_tencentcloud_apm_token() string SrsConfig::get_tencentcloud_apm_endpoint() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_APM_ENDPOINT"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_apm.endpoint"); static string DEFAULT = ""; @@ -3537,7 +3594,7 @@ string SrsConfig::get_tencentcloud_apm_endpoint() string SrsConfig::get_tencentcloud_apm_service_name() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_TENCENTCLOUD_APM_SERVICE_NAME"); + SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_apm.service_name"); static string DEFAULT = "srs-server"; @@ -3556,7 +3613,7 @@ string SrsConfig::get_tencentcloud_apm_service_name() bool SrsConfig::get_tencentcloud_apm_debug_logging() { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_TENCENTCLOUD_APM_DEBUG_LOGGING"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.tencentcloud_apm.debug_logging"); static bool DEFAULT = false; @@ -3788,7 +3845,7 @@ bool SrsConfig::get_rtc_server_enabled() bool SrsConfig::get_rtc_server_enabled(SrsConfDirective* conf) { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_RTC_SERVER_ENABLED"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.rtc_server.enabled"); static bool DEFAULT = false; @@ -3806,7 +3863,7 @@ bool SrsConfig::get_rtc_server_enabled(SrsConfDirective* conf) int SrsConfig::get_rtc_server_listen() { - SRS_OVERWRITE_BY_ENV_INT("SRS_RTC_SERVER_LISTEN"); + SRS_OVERWRITE_BY_ENV_INT("srs.rtc_server.listen"); static int DEFAULT = 8000; @@ -3825,7 +3882,7 @@ int SrsConfig::get_rtc_server_listen() std::string SrsConfig::get_rtc_server_candidates() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_RTC_SERVER_CANDIDATE"); + SRS_OVERWRITE_BY_ENV_STRING("srs.rtc_server.candidate"); static string DEFAULT = "*"; @@ -3854,7 +3911,7 @@ std::string SrsConfig::get_rtc_server_candidates() bool SrsConfig::get_api_as_candidates() { - SRS_OVERWRITE_BY_ENV_BOOL2("SRS_RTC_SERVER_API_AS_CANDIDATES"); + SRS_OVERWRITE_BY_ENV_BOOL2("srs.rtc_server.api_as_candidates"); static bool DEFAULT = true; @@ -3873,7 +3930,7 @@ bool SrsConfig::get_api_as_candidates() bool SrsConfig::get_resolve_api_domain() { - SRS_OVERWRITE_BY_ENV_BOOL2("SRS_RTC_SERVER_RESOLVE_API_DOMAIN"); + SRS_OVERWRITE_BY_ENV_BOOL2("srs.rtc_server.resolve_api_domain"); static bool DEFAULT = true; @@ -3892,7 +3949,7 @@ bool SrsConfig::get_resolve_api_domain() bool SrsConfig::get_keep_api_domain() { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_RTC_SERVER_KEEP_API_DOMAIN"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.rtc_server.keep_api_domain"); static bool DEFAULT = false; @@ -3911,7 +3968,7 @@ bool SrsConfig::get_keep_api_domain() bool SrsConfig::get_use_auto_detect_network_ip() { - SRS_OVERWRITE_BY_ENV_BOOL2("SRS_RTC_SERVER_USE_AUTO_DETECT_NETWORK_IP"); + SRS_OVERWRITE_BY_ENV_BOOL2("srs.rtc_server.use_auto_detect_network_ip"); static bool DEFAULT = true; @@ -3930,7 +3987,7 @@ bool SrsConfig::get_use_auto_detect_network_ip() bool SrsConfig::get_rtc_server_tcp_enabled() { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_RTC_SERVER_TCP_ENABLED"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.rtc_server.tcp.enabled"); static bool DEFAULT = false; @@ -3954,7 +4011,7 @@ bool SrsConfig::get_rtc_server_tcp_enabled() int SrsConfig::get_rtc_server_tcp_listen() { - SRS_OVERWRITE_BY_ENV_INT("SRS_RTC_SERVER_TCP_LISTEN"); + SRS_OVERWRITE_BY_ENV_INT("srs.rtc_server.tcp.listen"); static int DEFAULT = 8000; @@ -3978,7 +4035,7 @@ int SrsConfig::get_rtc_server_tcp_listen() std::string SrsConfig::get_rtc_server_protocol() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_RTC_SERVER_PROTOCOL"); + SRS_OVERWRITE_BY_ENV_STRING("srs.rtc_server.protocol"); static string DEFAULT = "udp"; @@ -3997,7 +4054,7 @@ std::string SrsConfig::get_rtc_server_protocol() std::string SrsConfig::get_rtc_server_ip_family() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_RTC_SERVER_IP_FAMILY"); + SRS_OVERWRITE_BY_ENV_STRING("srs.rtc_server.ip_family"); static string DEFAULT = "ipv4"; @@ -4016,6 +4073,8 @@ std::string SrsConfig::get_rtc_server_ip_family() bool SrsConfig::get_rtc_server_ecdsa() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.rtc_server.ecdsa"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("rtc_server"); @@ -4033,6 +4092,8 @@ bool SrsConfig::get_rtc_server_ecdsa() bool SrsConfig::get_rtc_server_encrypt() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.rtc_server.encrypt"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("rtc_server"); @@ -4064,6 +4125,8 @@ int SrsConfig::get_rtc_server_reuseport() int SrsConfig::get_rtc_server_reuseport2() { + SRS_OVERWRITE_BY_ENV_INT("srs.rtc_server.reuseport"); + static int DEFAULT = 1; SrsConfDirective* conf = root->get("rtc_server"); @@ -4081,6 +4144,8 @@ int SrsConfig::get_rtc_server_reuseport2() bool SrsConfig::get_rtc_server_merge_nalus() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.rtc_server.merge_nalus"); + static int DEFAULT = false; SrsConfDirective* conf = root->get("rtc_server"); @@ -4093,11 +4158,13 @@ bool SrsConfig::get_rtc_server_merge_nalus() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PERFER_FALSE(conf->arg0()); } bool SrsConfig::get_rtc_server_black_hole() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.rtc_server.black_hole.enabled"); + static bool DEFAULT = false; SrsConfDirective* conf = root->get("rtc_server"); @@ -4120,6 +4187,8 @@ bool SrsConfig::get_rtc_server_black_hole() std::string SrsConfig::get_rtc_server_black_hole_addr() { + SRS_OVERWRITE_BY_ENV_STRING("srs.rtc_server.black_hole.addr"); + static string DEFAULT = ""; SrsConfDirective* conf = root->get("rtc_server"); @@ -4148,7 +4217,7 @@ SrsConfDirective* SrsConfig::get_rtc(string vhost) bool SrsConfig::get_rtc_enabled(string vhost) { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_VHOST_RTC_ENABLED"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.rtc.enabled"); static bool DEFAULT = false; @@ -4168,6 +4237,8 @@ bool SrsConfig::get_rtc_enabled(string vhost) bool SrsConfig::get_rtc_keep_bframe(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.rtc.keep_bframe"); + static bool DEFAULT = false; SrsConfDirective* conf = get_rtc(vhost); @@ -4186,7 +4257,7 @@ bool SrsConfig::get_rtc_keep_bframe(string vhost) bool SrsConfig::get_rtc_from_rtmp(string vhost) { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_VHOST_RTC_RTMP_TO_RTC"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.rtc.rtmp_to_rtc"); static bool DEFAULT = false; @@ -4206,6 +4277,8 @@ bool SrsConfig::get_rtc_from_rtmp(string vhost) srs_utime_t SrsConfig::get_rtc_stun_timeout(string vhost) { + SRS_OVERWRITE_BY_ENV_SECONDS("srs.vhost.rtc.stun_timeout"); + static srs_utime_t DEFAULT = 30 * SRS_UTIME_SECONDS; SrsConfDirective* conf = get_rtc(vhost); @@ -4224,6 +4297,8 @@ srs_utime_t SrsConfig::get_rtc_stun_timeout(string vhost) bool SrsConfig::get_rtc_stun_strict_check(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.rtc.stun_strict_check"); + static bool DEFAULT = false; SrsConfDirective* conf = get_rtc(vhost); @@ -4242,6 +4317,8 @@ bool SrsConfig::get_rtc_stun_strict_check(string vhost) std::string SrsConfig::get_rtc_dtls_role(string vhost) { + SRS_OVERWRITE_BY_ENV_STRING("srs.vhost.rtc.dtls_role"); + static std::string DEFAULT = "passive"; SrsConfDirective* conf = get_rtc(vhost); @@ -4260,6 +4337,8 @@ std::string SrsConfig::get_rtc_dtls_role(string vhost) std::string SrsConfig::get_rtc_dtls_version(string vhost) { + SRS_OVERWRITE_BY_ENV_STRING("srs.vhost.rtc.dtls_version"); + static std::string DEFAULT = "auto"; SrsConfDirective* conf = get_rtc(vhost); @@ -4278,6 +4357,8 @@ std::string SrsConfig::get_rtc_dtls_version(string vhost) int SrsConfig::get_rtc_drop_for_pt(string vhost) { + SRS_OVERWRITE_BY_ENV_INT("srs.vhost.rtc.drop_for_pt"); + static int DEFAULT = 0; SrsConfDirective* conf = get_rtc(vhost); @@ -4295,7 +4376,7 @@ int SrsConfig::get_rtc_drop_for_pt(string vhost) bool SrsConfig::get_rtc_to_rtmp(string vhost) { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_VHOST_RTC_RTC_TO_RTMP"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.rtc.rtc_to_rtmp"); static bool DEFAULT = false; @@ -4315,18 +4396,24 @@ bool SrsConfig::get_rtc_to_rtmp(string vhost) srs_utime_t SrsConfig::get_rtc_pli_for_rtmp(string vhost) { static srs_utime_t DEFAULT = 6 * SRS_UTIME_SECONDS; + srs_utime_t v = 0; - SrsConfDirective* conf = get_rtc(vhost); - if (!conf) { - return DEFAULT; - } + if (!srs_getenv("srs.vhost.rtc.pli_for_rtmp").empty()) { + v = (srs_utime_t)(::atof(srs_getenv("srs.vhost.rtc.pli_for_rtmp").c_str()) * SRS_UTIME_SECONDS); + } else { + SrsConfDirective* conf = get_rtc(vhost); + if (!conf) { + return DEFAULT; + } - conf = conf->get("pli_for_rtmp"); - if (!conf || conf->arg0().empty()) { - return DEFAULT; + conf = conf->get("pli_for_rtmp"); + if (!conf || conf->arg0().empty()) { + return DEFAULT; + } + + v = (srs_utime_t)(::atof(conf->arg0().c_str()) * SRS_UTIME_SECONDS); } - srs_utime_t v = (srs_utime_t)(::atof(conf->arg0().c_str()) * SRS_UTIME_SECONDS); if (v < 500 * SRS_UTIME_MILLISECONDS || v > 30 * SRS_UTIME_SECONDS) { srs_warn("Reset pli %dms to %dms", srsu2msi(v), srsu2msi(DEFAULT)); return DEFAULT; @@ -4337,6 +4424,8 @@ srs_utime_t SrsConfig::get_rtc_pli_for_rtmp(string vhost) bool SrsConfig::get_rtc_nack_enabled(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.vhost.rtc.nack"); + static bool DEFAULT = true; SrsConfDirective* conf = get_rtc(vhost); @@ -4354,6 +4443,8 @@ bool SrsConfig::get_rtc_nack_enabled(string vhost) bool SrsConfig::get_rtc_nack_no_copy(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.vhost.rtc.nack_no_copy"); + static bool DEFAULT = true; SrsConfDirective* conf = get_rtc(vhost); @@ -4371,6 +4462,8 @@ bool SrsConfig::get_rtc_nack_no_copy(string vhost) bool SrsConfig::get_rtc_twcc_enabled(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.vhost.rtc.twcc"); + static bool DEFAULT = true; SrsConfDirective* conf = get_rtc(vhost); @@ -4451,6 +4544,8 @@ bool SrsConfig::get_vhost_enabled(SrsConfDirective* conf) bool SrsConfig::get_gop_cache(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.vhost.play.gop_cache"); + SrsConfDirective* conf = get_vhost(vhost); if (!conf) { return SRS_PERF_GOP_CACHE; @@ -4493,6 +4588,8 @@ bool SrsConfig::get_debug_srs_upnode(string vhost) bool SrsConfig::get_atc(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.play.atc"); + static bool DEFAULT = false; SrsConfDirective* conf = get_vhost(vhost); @@ -4515,6 +4612,8 @@ bool SrsConfig::get_atc(string vhost) bool SrsConfig::get_atc_auto(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.play.atc_auto"); + static bool DEFAULT = false; SrsConfDirective* conf = get_vhost(vhost); @@ -4537,6 +4636,10 @@ bool SrsConfig::get_atc_auto(string vhost) int SrsConfig::get_time_jitter(string vhost) { + if (!srs_getenv("srs.vhost.play.mw_latency").empty()) { + return srs_time_jitter_string2int(srs_getenv("srs.vhost.play.mw_latency")); + } + static string DEFAULT = "full"; SrsConfDirective* conf = get_vhost(vhost); @@ -4559,6 +4662,8 @@ int SrsConfig::get_time_jitter(string vhost) bool SrsConfig::get_mix_correct(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.play.mix_correct"); + static bool DEFAULT = false; SrsConfDirective* conf = get_vhost(vhost); @@ -4581,6 +4686,8 @@ bool SrsConfig::get_mix_correct(string vhost) srs_utime_t SrsConfig::get_queue_length(string vhost) { + SRS_OVERWRITE_BY_ENV_SECONDS("srs.vhost.play.queue_length"); + static srs_utime_t DEFAULT = SRS_PERF_PLAY_QUEUE; SrsConfDirective* conf = get_vhost(vhost); @@ -4733,6 +4840,8 @@ int SrsConfig::get_chunk_size(string vhost) bool SrsConfig::get_parse_sps(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.vhost.publish.parse_sps"); + static bool DEFAULT = true; SrsConfDirective* conf = get_vhost(vhost); @@ -4756,6 +4865,8 @@ bool SrsConfig::get_parse_sps(string vhost) bool SrsConfig::try_annexb_first(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.vhost.publish.try_annexb_first"); + static bool DEFAULT = true; SrsConfDirective* conf = get_vhost(vhost); @@ -4779,6 +4890,8 @@ bool SrsConfig::try_annexb_first(string vhost) bool SrsConfig::get_mr_enabled(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.publish.mr"); + SrsConfDirective* conf = get_vhost(vhost); if (!conf) { return SRS_PERF_MR_ENABLED; @@ -4799,6 +4912,8 @@ bool SrsConfig::get_mr_enabled(string vhost) srs_utime_t SrsConfig::get_mr_sleep(string vhost) { + SRS_OVERWRITE_BY_ENV_MILLISECONDS("srs.vhost.publish.mr_latency"); + static srs_utime_t DEFAULT = SRS_PERF_MR_SLEEP; SrsConfDirective* conf = get_vhost(vhost); @@ -4821,6 +4936,16 @@ srs_utime_t SrsConfig::get_mr_sleep(string vhost) srs_utime_t SrsConfig::get_mw_sleep(string vhost, bool is_rtc) { + if (!srs_getenv("srs.vhost.play.mw_latency").empty()) { + int v = ::atoi(srs_getenv("srs.vhost.play.mw_latency").c_str()); + if (is_rtc && v > 0) { + srs_warn("For RTC, we ignore mw_latency"); + return 0; + } + + return (srs_utime_t)(v * SRS_UTIME_MILLISECONDS); + } + static srs_utime_t SYS_DEFAULT = SRS_PERF_MW_SLEEP; static srs_utime_t RTC_DEFAULT = 0; @@ -4852,6 +4977,16 @@ srs_utime_t SrsConfig::get_mw_sleep(string vhost, bool is_rtc) int SrsConfig::get_mw_msgs(string vhost, bool is_realtime, bool is_rtc) { + if (!srs_getenv("srs.vhost.play.mw_msgs").empty()) { + int v = ::atoi(srs_getenv("srs.vhost.play.mw_msgs").c_str()); + if (v > SRS_PERF_MW_MSGS) { + srs_warn("reset mw_msgs %d to max %d", v, SRS_PERF_MW_MSGS); + v = SRS_PERF_MW_MSGS; + } + + return v; + } + int DEFAULT = SRS_PERF_MW_MIN_MSGS; if (is_rtc) { DEFAULT = SRS_PERF_MW_MIN_MSGS_FOR_RTC; @@ -4886,6 +5021,12 @@ int SrsConfig::get_mw_msgs(string vhost, bool is_realtime, bool is_rtc) bool SrsConfig::get_realtime_enabled(string vhost, bool is_rtc) { + if (is_rtc) { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.vhost.min_latency"); + } else { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.min_latency"); + } + static bool SYS_DEFAULT = SRS_PERF_MIN_LATENCY_ENABLED; static bool RTC_DEFAULT = true; @@ -4910,6 +5051,8 @@ bool SrsConfig::get_realtime_enabled(string vhost, bool is_rtc) bool SrsConfig::get_tcp_nodelay(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.tcp_nodelay"); + static bool DEFAULT = false; SrsConfDirective* conf = get_vhost(vhost); @@ -4927,6 +5070,8 @@ bool SrsConfig::get_tcp_nodelay(string vhost) srs_utime_t SrsConfig::get_send_min_interval(string vhost) { + SRS_OVERWRITE_BY_ENV_FLOAT_MILLISECONDS("srs.vhost.play.send_min_interval"); + static srs_utime_t DEFAULT = 0; SrsConfDirective* conf = get_vhost(vhost); @@ -4949,6 +5094,8 @@ srs_utime_t SrsConfig::get_send_min_interval(string vhost) bool SrsConfig::get_reduce_sequence_header(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.play.reduce_sequence_header"); + static bool DEFAULT = false; SrsConfDirective* conf = get_vhost(vhost); @@ -4971,6 +5118,8 @@ bool SrsConfig::get_reduce_sequence_header(string vhost) srs_utime_t SrsConfig::get_publish_1stpkt_timeout(string vhost) { + SRS_OVERWRITE_BY_ENV_MILLISECONDS("srs.vhost.publish.firstpkt_timeout"); + // when no msg recevied for publisher, use larger timeout. static srs_utime_t DEFAULT = 20 * SRS_UTIME_SECONDS; @@ -4994,6 +5143,8 @@ srs_utime_t SrsConfig::get_publish_1stpkt_timeout(string vhost) srs_utime_t SrsConfig::get_publish_normal_timeout(string vhost) { + SRS_OVERWRITE_BY_ENV_MILLISECONDS("srs.vhost.publish.normal_timeout"); + // the timeout for publish recv. // we must use more smaller timeout, for the recv never know the status // of underlayer socket. @@ -5019,6 +5170,8 @@ srs_utime_t SrsConfig::get_publish_normal_timeout(string vhost) int SrsConfig::get_global_chunk_size() { + SRS_OVERWRITE_BY_ENV_INT("srs.chunk_size"); + SrsConfDirective* conf = root->get("chunk_size"); if (!conf || conf->arg0().empty()) { return SRS_CONSTS_RTMP_SRS_CHUNK_SIZE; @@ -6046,6 +6199,10 @@ extern bool _srs_in_docker; bool SrsConfig::get_log_tank_file() { + if (!srs_getenv("srs.srs_log_tank").empty()) { + return srs_getenv("srs.srs_log_tank") != "console"; + } + static bool DEFAULT = true; if (_srs_in_docker) { @@ -6062,6 +6219,8 @@ bool SrsConfig::get_log_tank_file() string SrsConfig::get_log_level() { + SRS_OVERWRITE_BY_ENV_STRING("srs.srs_log_level"); + static string DEFAULT = "trace"; SrsConfDirective* conf = root->get("srs_log_level"); @@ -6074,6 +6233,8 @@ string SrsConfig::get_log_level() string SrsConfig::get_log_file() { + SRS_OVERWRITE_BY_ENV_STRING("srs.srs_log_file"); + static string DEFAULT = "./objs/srs.log"; SrsConfDirective* conf = root->get("srs_log_file"); @@ -6092,6 +6253,8 @@ bool SrsConfig::get_ff_log_enabled() string SrsConfig::get_ff_log_dir() { + SRS_OVERWRITE_BY_ENV_STRING("srs.ff_log_dir"); + static string DEFAULT = "./objs"; SrsConfDirective* conf = root->get("ff_log_dir"); @@ -6104,6 +6267,8 @@ string SrsConfig::get_ff_log_dir() string SrsConfig::get_ff_log_level() { + SRS_OVERWRITE_BY_ENV_STRING("srs.ff_log_level"); + static string DEFAULT = "info"; SrsConfDirective* conf = root->get("ff_log_level"); @@ -6122,6 +6287,8 @@ SrsConfDirective* SrsConfig::get_dash(string vhost) bool SrsConfig::get_dash_enabled(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.vhost.dash.enabled"); + static bool DEFAULT = false; SrsConfDirective* conf = get_vhost(vhost); @@ -6151,6 +6318,8 @@ bool SrsConfig::get_dash_enabled(SrsConfDirective* vhost) srs_utime_t SrsConfig::get_dash_fragment(string vhost) { + SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS("srs.vhost.dash.dash_fragment"); + static int DEFAULT = 30 * SRS_UTIME_SECONDS; SrsConfDirective* conf = get_dash(vhost); @@ -6168,6 +6337,8 @@ srs_utime_t SrsConfig::get_dash_fragment(string vhost) srs_utime_t SrsConfig::get_dash_update_period(string vhost) { + SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS("srs.vhost.dash.dash_update_period"); + static srs_utime_t DEFAULT = 150 * SRS_UTIME_SECONDS; SrsConfDirective* conf = get_dash(vhost); @@ -6185,6 +6356,8 @@ srs_utime_t SrsConfig::get_dash_update_period(string vhost) srs_utime_t SrsConfig::get_dash_timeshift(string vhost) { + SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS("srs.vhost.dash.dash_timeshift"); + static srs_utime_t DEFAULT = 300 * SRS_UTIME_SECONDS; SrsConfDirective* conf = get_dash(vhost); @@ -6202,6 +6375,8 @@ srs_utime_t SrsConfig::get_dash_timeshift(string vhost) string SrsConfig::get_dash_path(string vhost) { + SRS_OVERWRITE_BY_ENV_STRING("srs.vhost.dash.dash_path"); + static string DEFAULT = "./objs/nginx/html"; SrsConfDirective* conf = get_dash(vhost); @@ -6219,6 +6394,8 @@ string SrsConfig::get_dash_path(string vhost) string SrsConfig::get_dash_mpd_file(string vhost) { + SRS_OVERWRITE_BY_ENV_STRING("srs.vhost.dash.dash_mpd_file"); + static string DEFAULT = "[app]/[stream].mpd"; SrsConfDirective* conf = get_dash(vhost); @@ -6921,7 +7098,7 @@ bool SrsConfig::get_http_api_enabled() bool SrsConfig::get_http_api_enabled(SrsConfDirective* conf) { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_HTTP_API_ENABLED"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.http_api.enabled"); static bool DEFAULT = false; @@ -6939,7 +7116,7 @@ bool SrsConfig::get_http_api_enabled(SrsConfDirective* conf) string SrsConfig::get_http_api_listen() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_HTTP_API_LISTEN"); + SRS_OVERWRITE_BY_ENV_STRING("srs.http_api.listen"); static string DEFAULT = "1985"; @@ -6959,6 +7136,8 @@ string SrsConfig::get_http_api_listen() bool SrsConfig::get_http_api_crossdomain() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.http_api.crossdomain"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("http_api"); @@ -6976,6 +7155,8 @@ bool SrsConfig::get_http_api_crossdomain() bool SrsConfig::get_raw_api() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.http_api.raw_api.enabled"); + static bool DEFAULT = false; SrsConfDirective* conf = root->get("http_api"); @@ -6998,6 +7179,8 @@ bool SrsConfig::get_raw_api() bool SrsConfig::get_raw_api_allow_reload() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.http_api.raw_api.allow_reload"); + static bool DEFAULT = false; SrsConfDirective* conf = root->get("http_api"); @@ -7042,7 +7225,7 @@ SrsConfDirective* SrsConfig::get_https_api() bool SrsConfig::get_https_api_enabled() { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_HTTP_API_HTTPS_ENABLED"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.http_api.https.enabled"); static bool DEFAULT = false; @@ -7061,7 +7244,7 @@ bool SrsConfig::get_https_api_enabled() string SrsConfig::get_https_api_listen() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_HTTP_API_HTTPS_LISTEN"); + SRS_OVERWRITE_BY_ENV_STRING("srs.http_api.https.listen"); #ifdef SRS_UTEST // We should not use static default, because we need to reset for different testcase. @@ -7094,6 +7277,8 @@ string SrsConfig::get_https_api_listen() string SrsConfig::get_https_api_ssl_key() { + SRS_OVERWRITE_BY_ENV_STRING("srs.http_api.https.key"); + static string DEFAULT = "./conf/server.key"; SrsConfDirective* conf = get_https_api(); @@ -7111,6 +7296,8 @@ string SrsConfig::get_https_api_ssl_key() string SrsConfig::get_https_api_ssl_cert() { + SRS_OVERWRITE_BY_ENV_STRING("srs.http_api.https.cert"); + static string DEFAULT = "./conf/server.crt"; SrsConfDirective* conf = get_https_api(); @@ -7128,6 +7315,8 @@ string SrsConfig::get_https_api_ssl_cert() bool SrsConfig::get_srt_enabled() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.srt_server.enabled"); + static bool DEFAULT = false; SrsConfDirective* conf = root->get("srt_server"); @@ -7145,6 +7334,8 @@ bool SrsConfig::get_srt_enabled() unsigned short SrsConfig::get_srt_listen_port() { + SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.listen"); + static unsigned short DEFAULT = 10080; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7160,6 +7351,8 @@ unsigned short SrsConfig::get_srt_listen_port() int SrsConfig::get_srto_maxbw() { + SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.maxbw"); + static int64_t DEFAULT = -1; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7175,6 +7368,8 @@ int SrsConfig::get_srto_maxbw() int SrsConfig::get_srto_mss() { + SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.mms"); + static int DEFAULT = 1500; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7190,6 +7385,8 @@ int SrsConfig::get_srto_mss() bool SrsConfig::get_srto_tsbpdmode() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.srt_server.tsbpdmode"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7205,6 +7402,8 @@ bool SrsConfig::get_srto_tsbpdmode() int SrsConfig::get_srto_latency() { + SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.latency"); + static int DEFAULT = 120; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7220,6 +7419,8 @@ int SrsConfig::get_srto_latency() int SrsConfig::get_srto_recv_latency() { + SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.recvlatency"); + static int DEFAULT = 120; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7235,6 +7436,8 @@ int SrsConfig::get_srto_recv_latency() int SrsConfig::get_srto_peer_latency() { + SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.peerlatency"); + static int DEFAULT = 0; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7250,6 +7453,8 @@ int SrsConfig::get_srto_peer_latency() bool SrsConfig::get_srt_sei_filter() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.srt_server.sei_filter"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7265,6 +7470,8 @@ bool SrsConfig::get_srt_sei_filter() bool SrsConfig::get_srto_tlpktdrop() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.srt_server.tlpkdrop.tlpktdrop"); + static bool DEFAULT = true; SrsConfDirective* srt_server_conf = root->get("srt_server"); if (!srt_server_conf) { @@ -7272,7 +7479,7 @@ bool SrsConfig::get_srto_tlpktdrop() } SrsConfDirective* conf = srt_server_conf->get("tlpkdrop"); - if (! conf) { + if (!conf) { // make it compatible tlpkdrop and tlpktdrop opt. conf = srt_server_conf->get("tlpktdrop"); } @@ -7284,6 +7491,8 @@ bool SrsConfig::get_srto_tlpktdrop() srs_utime_t SrsConfig::get_srto_conntimeout() { + SRS_OVERWRITE_BY_ENV_MILLISECONDS("srs.srt_server.connect_timeout"); + static srs_utime_t DEFAULT = 3 * SRS_UTIME_SECONDS; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7299,6 +7508,8 @@ srs_utime_t SrsConfig::get_srto_conntimeout() srs_utime_t SrsConfig::get_srto_peeridletimeout() { + SRS_OVERWRITE_BY_ENV_MILLISECONDS("srs.srt_server.peer_idle_timeout"); + static srs_utime_t DEFAULT = 10 * SRS_UTIME_SECONDS; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7314,6 +7525,8 @@ srs_utime_t SrsConfig::get_srto_peeridletimeout() int SrsConfig::get_srto_sendbuf() { + SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.sendbuf"); + static int DEFAULT = 8192 * (1500-28); SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7329,6 +7542,8 @@ int SrsConfig::get_srto_sendbuf() int SrsConfig::get_srto_recvbuf() { + SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.recvbuf"); + static int DEFAULT = 8192 * (1500-28); SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7344,6 +7559,8 @@ int SrsConfig::get_srto_recvbuf() int SrsConfig::get_srto_payloadsize() { + SRS_OVERWRITE_BY_ENV_INT("srs.srt_server.payloadsize"); + static int DEFAULT = 1316; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7359,6 +7576,8 @@ int SrsConfig::get_srto_payloadsize() string SrsConfig::get_default_app_name() { + SRS_OVERWRITE_BY_ENV_STRING("srs.srt_server.default_app"); + static string DEFAULT = "live"; SrsConfDirective* conf = root->get("srt_server"); if (!conf) { @@ -7380,6 +7599,8 @@ SrsConfDirective* SrsConfig::get_srt(std::string vhost) bool SrsConfig::get_srt_enabled(std::string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.srt.enabled"); + static bool DEFAULT = false; SrsConfDirective* conf = get_srt(vhost); @@ -7398,6 +7619,8 @@ bool SrsConfig::get_srt_enabled(std::string vhost) bool SrsConfig::get_srt_to_rtmp(std::string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.srt.srt_to_rtmp"); + static bool DEFAULT = true; SrsConfDirective* conf = get_srt(vhost); @@ -7421,7 +7644,7 @@ bool SrsConfig::get_http_stream_enabled() bool SrsConfig::get_http_stream_enabled(SrsConfDirective* conf) { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_HTTP_SERVER_ENABLED"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.http_server.enabled"); static bool DEFAULT = false; @@ -7439,7 +7662,7 @@ bool SrsConfig::get_http_stream_enabled(SrsConfDirective* conf) string SrsConfig::get_http_stream_listen() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_HTTP_SERVER_LISTEN"); + SRS_OVERWRITE_BY_ENV_STRING("srs.http_server.listen"); static string DEFAULT = "8080"; @@ -7458,6 +7681,8 @@ string SrsConfig::get_http_stream_listen() string SrsConfig::get_http_stream_dir() { + SRS_OVERWRITE_BY_ENV_STRING("srs.http_server.dir"); + static string DEFAULT = "./objs/nginx/html"; SrsConfDirective* conf = root->get("http_server"); @@ -7475,6 +7700,8 @@ string SrsConfig::get_http_stream_dir() bool SrsConfig::get_http_stream_crossdomain() { + SRS_OVERWRITE_BY_ENV_BOOL2("srs.http_server.crossdomain"); + static bool DEFAULT = true; SrsConfDirective* conf = root->get("http_server"); @@ -7502,7 +7729,7 @@ SrsConfDirective* SrsConfig::get_https_stream() bool SrsConfig::get_https_stream_enabled() { - SRS_OVERWRITE_BY_ENV_BOOL("SRS_HTTP_SERVER_HTTTPS_ENABLED"); + SRS_OVERWRITE_BY_ENV_BOOL("srs.http_server.https.enabled"); static bool DEFAULT = false; @@ -7521,7 +7748,7 @@ bool SrsConfig::get_https_stream_enabled() string SrsConfig::get_https_stream_listen() { - SRS_OVERWRITE_BY_ENV_STRING("SRS_HTTP_SERVER_HTTTPS_LISTEN"); + SRS_OVERWRITE_BY_ENV_STRING("srs.http_server.https.listen"); static string DEFAULT = "8088"; @@ -7540,6 +7767,8 @@ string SrsConfig::get_https_stream_listen() string SrsConfig::get_https_stream_ssl_key() { + SRS_OVERWRITE_BY_ENV_STRING("srs.http_server.https.key"); + static string DEFAULT = "./conf/server.key"; SrsConfDirective* conf = get_https_stream(); @@ -7557,6 +7786,8 @@ string SrsConfig::get_https_stream_ssl_key() string SrsConfig::get_https_stream_ssl_cert() { + SRS_OVERWRITE_BY_ENV_STRING("srs.http_server.https.cert"); + static string DEFAULT = "./conf/server.crt"; SrsConfDirective* conf = get_https_stream(); @@ -7574,6 +7805,8 @@ string SrsConfig::get_https_stream_ssl_cert() bool SrsConfig::get_vhost_http_enabled(string vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.http_static.enabled"); + static bool DEFAULT = false; SrsConfDirective* conf = get_vhost(vhost); @@ -7596,6 +7829,8 @@ bool SrsConfig::get_vhost_http_enabled(string vhost) string SrsConfig::get_vhost_http_mount(string vhost) { + SRS_OVERWRITE_BY_ENV_STRING("srs.http_static.mount"); + static string DEFAULT = "[vhost]/"; SrsConfDirective* conf = get_vhost(vhost); @@ -7618,6 +7853,8 @@ string SrsConfig::get_vhost_http_mount(string vhost) string SrsConfig::get_vhost_http_dir(string vhost) { + SRS_OVERWRITE_BY_ENV_STRING("srs.http_static.dir"); + static string DEFAULT = "./objs/nginx/html"; SrsConfDirective* conf = get_vhost(vhost); @@ -7652,6 +7889,8 @@ bool SrsConfig::get_vhost_http_remux_enabled(string vhost) bool SrsConfig::get_vhost_http_remux_enabled(SrsConfDirective* vhost) { + SRS_OVERWRITE_BY_ENV_BOOL("srs.http_remux.enabled"); + static bool DEFAULT = false; SrsConfDirective* conf = vhost->get("http_remux"); @@ -7669,6 +7908,8 @@ bool SrsConfig::get_vhost_http_remux_enabled(SrsConfDirective* vhost) srs_utime_t SrsConfig::get_vhost_http_remux_fast_cache(string vhost) { + SRS_OVERWRITE_BY_ENV_FLOAT_SECONDS("srs.http_remux.fast_cache"); + static srs_utime_t DEFAULT = 0; SrsConfDirective* conf = get_vhost(vhost); @@ -7691,6 +7932,8 @@ srs_utime_t SrsConfig::get_vhost_http_remux_fast_cache(string vhost) string SrsConfig::get_vhost_http_remux_mount(string vhost) { + SRS_OVERWRITE_BY_ENV_STRING("srs.http_remux.mount"); + static string DEFAULT = "[vhost]/[app]/[stream].flv"; SrsConfDirective* conf = get_vhost(vhost); @@ -7718,6 +7961,8 @@ SrsConfDirective* SrsConfig::get_heartbeart() bool SrsConfig::get_heartbeat_enabled() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.heartbeat.enabled"); + static bool DEFAULT = false; SrsConfDirective* conf = get_heartbeart(); @@ -7735,6 +7980,8 @@ bool SrsConfig::get_heartbeat_enabled() srs_utime_t SrsConfig::get_heartbeat_interval() { + SRS_OVERWRITE_BY_ENV_SECONDS("srs.heartbeat.interval"); + static srs_utime_t DEFAULT = (srs_utime_t)(10 * SRS_UTIME_SECONDS); SrsConfDirective* conf = get_heartbeart(); @@ -7752,6 +7999,8 @@ srs_utime_t SrsConfig::get_heartbeat_interval() string SrsConfig::get_heartbeat_url() { + SRS_OVERWRITE_BY_ENV_STRING("srs.heartbeat.url"); + static string DEFAULT = "http://" SRS_CONSTS_LOCALHOST ":8085/api/v1/servers"; SrsConfDirective* conf = get_heartbeart(); @@ -7769,6 +8018,8 @@ string SrsConfig::get_heartbeat_url() string SrsConfig::get_heartbeat_device_id() { + SRS_OVERWRITE_BY_ENV_STRING("srs.heartbeat.device_id"); + static string DEFAULT = ""; SrsConfDirective* conf = get_heartbeart(); @@ -7786,6 +8037,8 @@ string SrsConfig::get_heartbeat_device_id() bool SrsConfig::get_heartbeat_summaries() { + SRS_OVERWRITE_BY_ENV_BOOL("srs.heartbeat.summaries"); + static bool DEFAULT = false; SrsConfDirective* conf = get_heartbeart(); diff --git a/trunk/src/app/srs_app_latest_version.cpp b/trunk/src/app/srs_app_latest_version.cpp index f54f18785..e4c783a83 100644 --- a/trunk/src/app/srs_app_latest_version.cpp +++ b/trunk/src/app/srs_app_latest_version.cpp @@ -27,6 +27,9 @@ using namespace std; // Whether we are in docker, defined in main module. extern bool _srs_in_docker; +// Whether setup config by environment variables. +extern bool _srs_config_by_env; + // Check the feature by cond #define SRS_CHECK_FEATURE(cond, ss) if (cond) ss << "&" << #cond << "=1" #define SRS_CHECK_FEATURE2(cond, key, ss) if (cond) ss << "&" << key << "=1" @@ -159,6 +162,7 @@ void srs_build_features(stringstream& ss) SRS_CHECK_FEATURE(exec, ss); SRS_CHECK_FEATURE(transcode, ss); SRS_CHECK_FEATURE(security, ss); + SRS_CHECK_FEATURE2(_srs_config_by_env, "env", ss); SRS_CHECK_FEATURE2(_srs_cls->enabled(), "cls", ss); SRS_CHECK_FEATURE3(_srs_cls->nn_logs(), "logs", _srs_cls->nn_logs(), ss); diff --git a/trunk/src/app/srs_app_utility.cpp b/trunk/src/app/srs_app_utility.cpp index 63c84411a..3d129c84d 100644 --- a/trunk/src/app/srs_app_utility.cpp +++ b/trunk/src/app/srs_app_utility.cpp @@ -1421,7 +1421,7 @@ string srs_string_dumps_hex(const char* str, int length, int limit, char seperat return string(buf, len); } -string srs_getenv(string key) +string srs_getenv(const string& key) { string ekey = key; if (srs_string_starts_with(key, "$")) { @@ -1432,6 +1432,15 @@ string srs_getenv(string key) return ""; } + std::string::iterator it; + for (it = ekey.begin(); it != ekey.end(); ++it) { + if (*it >= 'a' && *it <= 'z') { + *it += ('A' - 'a'); + } else if (*it == '.') { + *it = '_'; + } + } + char* value = ::getenv(ekey.c_str()); if (value) { return value; diff --git a/trunk/src/app/srs_app_utility.hpp b/trunk/src/app/srs_app_utility.hpp index a63ca25a6..56f2a2cc5 100644 --- a/trunk/src/app/srs_app_utility.hpp +++ b/trunk/src/app/srs_app_utility.hpp @@ -685,7 +685,7 @@ extern std::string srs_string_dumps_hex(const char* str, int length, int limit, // Get ENV variable, which may starts with $. // srs_getenv("EIP") === srs_getenv("$EIP") -extern std::string srs_getenv(std::string key); +extern std::string srs_getenv(const std::string& key); #endif diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 106323ada..f687d7b46 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -68,10 +68,13 @@ extern const char* _srs_version; // @global main SRS server, for debugging SrsServer* _srs_server = NULL; +// Whether setup config by environment variables, see https://github.com/ossrs/srs/issues/2277 +bool _srs_config_by_env = false; + /** * main entrance. */ -srs_error_t do_main(int argc, char** argv) +srs_error_t do_main(int argc, char** argv, char** envp) { srs_error_t err = srs_success; @@ -129,13 +132,22 @@ srs_error_t do_main(int argc, char** argv) if ((err = _srs_log->initialize()) != srs_success) { return srs_error_wrap(err, "log initialize"); } + + // Detect whether set SRS config by envrionment variables. + for (char** pp = envp; *pp; pp++) { + char* p = *pp; + if (p[0] == 'S' && p[1] == 'R' && p[2] == 'S' && p[3] == '_') { + _srs_config_by_env = true; + break; + } + } // config already applied to log. - srs_trace2(TAG_MAIN, "%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE); + srs_trace("%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE); srs_trace("authors: %sand %s", RTMP_SIG_SRS_AUTHORS, SRS_CONSTRIBUTORS); - srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d, pkg: %s, region: %s, source: %s", - _srs_config->cwd().c_str(), cwd.c_str(), SRS_BUILD_DATE, SRS_USER_CONFIGURE, SRS_UNAME, SRS_OSX_BOOL, SRS_PACKAGER, - srs_getenv("SRS_REGION").c_str(), srs_getenv("SRS_SOURCE").c_str()); + srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d, env: %d, pkg: %s", + _srs_config->cwd().c_str(), cwd.c_str(), SRS_BUILD_DATE, SRS_USER_CONFIGURE, SRS_UNAME, SRS_OSX_BOOL, + _srs_config_by_env, SRS_PACKAGER); srs_trace("configure detail: " SRS_CONFIGURE); #ifdef SRS_EMBEDED_TOOL_CHAIN srs_trace("crossbuild tool chain: " SRS_EMBEDED_TOOL_CHAIN); @@ -208,9 +220,9 @@ srs_error_t do_main(int argc, char** argv) return err; } -int main(int argc, char** argv) +int main(int argc, char** argv, char** envp) { - srs_error_t err = do_main(argc, argv); + srs_error_t err = do_main(argc, argv, envp); if (err != srs_success) { srs_error("Failed, %s", srs_error_desc(err).c_str()); diff --git a/trunk/src/utest/srs_utest.cpp b/trunk/src/utest/srs_utest.cpp index 5277835a6..e1b468bb9 100644 --- a/trunk/src/utest/srs_utest.cpp +++ b/trunk/src/utest/srs_utest.cpp @@ -35,6 +35,7 @@ ISrsContext* _srs_context = NULL; SrsConfig* _srs_config = NULL; SrsServer* _srs_server = NULL; bool _srs_in_docker = false; +bool _srs_config_by_env = false; #include