From e8380cda2995e6de3ce429cd3416c9a2ec295022 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 27 Oct 2021 18:33:49 +0800 Subject: [PATCH 1/3] Demos: Remove the unused H5 demo files. (#2469) --- trunk/auto/depends.sh | 9 -- trunk/etc/init.d/srs-demo | 184 -------------------------------- trunk/etc/init.d/srs-demo-19350 | 184 -------------------------------- trunk/scripts/build.sh | 14 --- trunk/scripts/run.sh | 55 ---------- trunk/scripts/stop.sh | 12 --- 6 files changed, 458 deletions(-) delete mode 100755 trunk/etc/init.d/srs-demo delete mode 100755 trunk/etc/init.d/srs-demo-19350 delete mode 100755 trunk/scripts/build.sh delete mode 100755 trunk/scripts/run.sh delete mode 100755 trunk/scripts/stop.sh diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index a546fe692..1fb18643f 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -445,16 +445,7 @@ mkdir -p ${SRS_OBJS}/nginx # the demo dir. # create forward dir mkdir -p ${SRS_OBJS}/nginx/html/live && -mkdir -p ${SRS_OBJS}/nginx/html/forward/live - -# generate default html pages for android. -html_file=${SRS_OBJS}/nginx/html/live/demo.html && hls_stream=demo.m3u8 && write_nginx_html5 html_file=${SRS_OBJS}/nginx/html/live/livestream.html && hls_stream=livestream.m3u8 && write_nginx_html5 -html_file=${SRS_OBJS}/nginx/html/live/livestream_ld.html && hls_stream=livestream_ld.m3u8 && write_nginx_html5 -html_file=${SRS_OBJS}/nginx/html/live/livestream_sd.html && hls_stream=livestream_sd.m3u8 && write_nginx_html5 -html_file=${SRS_OBJS}/nginx/html/forward/live/livestream.html && hls_stream=livestream.m3u8 && write_nginx_html5 -html_file=${SRS_OBJS}/nginx/html/forward/live/livestream_ld.html && hls_stream=livestream_ld.m3u8 && write_nginx_html5 -html_file=${SRS_OBJS}/nginx/html/forward/live/livestream_sd.html && hls_stream=livestream_sd.m3u8 && write_nginx_html5 # copy players to nginx html dir. rm -rf ${SRS_OBJS}/nginx/html/players && diff --git a/trunk/etc/init.d/srs-demo b/trunk/etc/init.d/srs-demo deleted file mode 100755 index f714dbc1a..000000000 --- a/trunk/etc/init.d/srs-demo +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash - -### BEGIN INIT INFO -# Provides: ossrs(srs) -# Required-Start: $all -# Required-Stop: $all -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: ossrs(srs) -# Description: https://github.com/ossrs/srs -### END INIT INFO - -# the config of ROOT, user must modify it when start srs from other directory, -# it's ok to use the script by command ./etc/init.d/ossrs -ROOT="./" -APP="./objs/srs" -CONFIG="./conf/demo.conf" -DEFAULT_PID_FILE='./objs/srs.demo.pid' -DEFAULT_LOG_FILE='./objs/srs.demo.log' - -######################################################################## -# utility functions -######################################################################## -RED="\\033[31m" -GREEN="\\033[32m" -YELLOW="\\033[33m" -BLACK="\\033[0m" -POS="\\033[60G" - -ok_msg() { - echo -e "${1}${POS}${BLACK}[${GREEN} OK ${BLACK}]" -} - -failed_msg() { - echo -e "${1}${POS}${BLACK}[${RED}FAILED${BLACK}]" -} - -# load process info of srs -# @set variable $srs_pid to the process id in srs.pid file. -# @return 0, if process exists; otherwise: -# 1, for pid file not exists. -# 2, for get proecess info by pid failed. -# @set variable $error_msg if error. -# @set variable $pid_file to pid file. -load_process_info() { - # get pid file - pid_file=`cd ${ROOT} && cat ${CONFIG} |grep ^pid|awk '{print $2}'|awk -F ';' '{print $1}'` - if [[ -z $pid_file ]]; then pid_file=${DEFAULT_PID_FILE}; fi - # get abs path - pid_dir=`dirname $pid_file` - pid_file=`(cd ${ROOT}; cd $pid_dir; pwd)`/`basename $pid_file` - - srs_pid=`cat $pid_file 2>/dev/null` - ret=$?; if [[ 0 -ne $ret ]]; then error_msg="file $pid_file does not exists"; return 1; fi - - ps -p ${srs_pid} >/dev/null 2>/dev/null - ret=$?; if [[ 0 -ne $ret ]]; then error_msg="process $srs_pid does not exists"; return 2; fi - - return 0; -} - -start() { - # if exists, exit. - load_process_info - if [[ 0 -eq $? ]]; then failed_msg "SRS started(pid ${srs_pid}), should not start it again."; return 0; fi - - # not exists, start server - ok_msg "Starting SRS..." - - # get log file - log_file=`cd ${ROOT} && cat ${CONFIG} |grep '^log_file'| awk '{print $2}'| awk -F ';' '{print $1}'` - if [[ -z $log_file ]]; then log_file=${DEFAULT_LOG_FILE}; fi - # get abs path - log_dir=`dirname $log_file` - log_file=`(cd ${ROOT} && cd $log_dir && pwd)`/`basename $log_file` - - # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000" - if [[ -z $log_file ]]; then - (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) - else - (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file.sys 2>&1) - fi - - # check again after start server - for ((i = 0; i < 5; i++)); do - # sleep a little while, for srs may start then crash. - sleep 0.1 - load_process_info - ret=$?; if [[ 0 -ne $ret ]]; then - failed_msg "SRS start failed"; - failed_msg "see $log_file"; - return $ret; - fi - done - - # check whether started. - load_process_info - ret=$?; if [[ 0 -eq $? ]]; then ok_msg "SRS started(pid ${srs_pid})"; return 0; fi - - failed_msg "SRS not started" - return $ret -} - -stop() { - # not start, exit - load_process_info - if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi - - ok_msg "Stopping SRS(pid ${srs_pid})..." - - # process exists, kill util stop - for((;;)); do - load_process_info - if [[ 0 -eq $? ]]; then - kill -s SIGTERM ${srs_pid} 2>/dev/null - ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi - sleep 0.1 - else - ok_msg "SRS stopped" - break; - fi - done - - sleep 0.1 - return 0 -} - -# get the status of srs process -# @return 0 if srs is running; otherwise, 1 for stopped. -status() { - load_process_info - ret=$?; if [[ 0 -eq $ret ]]; then echo "SRS(pid ${srs_pid}) is running."; return 0; fi - - echo "SRS is stopped, $error_msg" - return 1 -} - -reload() { - # not start, exit - load_process_info - if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi - - ok_msg "Reload SRS(pid ${srs_pid})..." - - # process exists, reload it - kill -s SIGHUP ${srs_pid} 2>/dev/null - ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "Reload SRS failed ret=$ret"; return $ret; fi - - load_process_info - if [[ 0 -ne $? ]]; then failed_msg "SRS reload failed."; return $ret; fi - - ok_msg "SRS reloaded" - return 0 -} - -menu() { - case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - status) - status - ;; - reload) - reload - ;; - *) - echo "Usage: $0 {start|stop|status|restart|reload}" - return 1 - ;; - esac -} - -menu $1 - -code=$? -exit ${code} diff --git a/trunk/etc/init.d/srs-demo-19350 b/trunk/etc/init.d/srs-demo-19350 deleted file mode 100755 index 4e55540c8..000000000 --- a/trunk/etc/init.d/srs-demo-19350 +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash - -### BEGIN INIT INFO -# Provides: ossrs(srs) -# Required-Start: $all -# Required-Stop: $all -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: ossrs(srs) -# Description: https://github.com/ossrs/srs -### END INIT INFO - -# the config of ROOT, user must modify it when start srs from other directory, -# it's ok to use the script by command ./etc/init.d/ossrs -ROOT="./" -APP="./objs/srs" -CONFIG="./conf/demo.19350.conf" -DEFAULT_PID_FILE='./objs/srs.demo.19350.pid' -DEFAULT_LOG_FILE='./objs/srs.demo.19350.log' - -######################################################################## -# utility functions -######################################################################## -RED="\\033[31m" -GREEN="\\033[32m" -YELLOW="\\033[33m" -BLACK="\\033[0m" -POS="\\033[60G" - -ok_msg() { - echo -e "${1}${POS}${BLACK}[${GREEN} OK ${BLACK}]" -} - -failed_msg() { - echo -e "${1}${POS}${BLACK}[${RED}FAILED${BLACK}]" -} - -# load process info of srs -# @set variable $srs_pid to the process id in srs.pid file. -# @return 0, if process exists; otherwise: -# 1, for pid file not exists. -# 2, for get proecess info by pid failed. -# @set variable $error_msg if error. -# @set variable $pid_file to pid file. -load_process_info() { - # get pid file - pid_file=`cd ${ROOT} && cat ${CONFIG} |grep ^pid|awk '{print $2}'|awk -F ';' '{print $1}'` - if [[ -z $pid_file ]]; then pid_file=${DEFAULT_PID_FILE}; fi - # get abs path - pid_dir=`dirname $pid_file` - pid_file=`(cd ${ROOT}; cd $pid_dir; pwd)`/`basename $pid_file` - - srs_pid=`cat $pid_file 2>/dev/null` - ret=$?; if [[ 0 -ne $ret ]]; then error_msg="file $pid_file does not exists"; return 1; fi - - ps -p ${srs_pid} >/dev/null 2>/dev/null - ret=$?; if [[ 0 -ne $ret ]]; then error_msg="process $srs_pid does not exists"; return 2; fi - - return 0; -} - -start() { - # if exists, exit. - load_process_info - if [[ 0 -eq $? ]]; then failed_msg "SRS started(pid ${srs_pid}), should not start it again."; return 0; fi - - # not exists, start server - ok_msg "Starting SRS..." - - # get log file - log_file=`cd ${ROOT} && cat ${CONFIG} |grep '^log_file'| awk '{print $2}'| awk -F ';' '{print $1}'` - if [[ -z $log_file ]]; then log_file=${DEFAULT_LOG_FILE}; fi - # get abs path - log_dir=`dirname $log_file` - log_file=`(cd ${ROOT} && cd $log_dir && pwd)`/`basename $log_file` - - # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000" - if [[ -z $log_file ]]; then - (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) - else - (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file.sys 2>&1) - fi - - # check again after start server - for ((i = 0; i < 5; i++)); do - # sleep a little while, for srs may start then crash. - sleep 0.1 - load_process_info - ret=$?; if [[ 0 -ne $ret ]]; then - failed_msg "SRS start failed"; - failed_msg "see $log_file"; - return $ret; - fi - done - - # check whether started. - load_process_info - ret=$?; if [[ 0 -eq $? ]]; then ok_msg "SRS started(pid ${srs_pid})"; return 0; fi - - failed_msg "SRS not started" - return $ret -} - -stop() { - # not start, exit - load_process_info - if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi - - ok_msg "Stopping SRS(pid ${srs_pid})..." - - # process exists, kill util stop - for((;;)); do - load_process_info - if [[ 0 -eq $? ]]; then - kill -s SIGTERM ${srs_pid} 2>/dev/null - ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi - sleep 0.1 - else - ok_msg "SRS stopped" - break; - fi - done - - sleep 0.1 - return 0 -} - -# get the status of srs process -# @return 0 if srs is running; otherwise, 1 for stopped. -status() { - load_process_info - ret=$?; if [[ 0 -eq $ret ]]; then echo "SRS(pid ${srs_pid}) is running."; return 0; fi - - echo "SRS is stopped, $error_msg" - return 1 -} - -reload() { - # not start, exit - load_process_info - if [[ 0 -ne $? ]]; then failed_msg "SRS not start."; return 0; fi - - ok_msg "Reload SRS(pid ${srs_pid})..." - - # process exists, reload it - kill -s SIGHUP ${srs_pid} 2>/dev/null - ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "Reload SRS failed ret=$ret"; return $ret; fi - - load_process_info - if [[ 0 -ne $? ]]; then failed_msg "SRS reload failed."; return $ret; fi - - ok_msg "SRS reloaded" - return 0 -} - -menu() { - case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - status) - status - ;; - reload) - reload - ;; - *) - echo "Usage: $0 {start|stop|status|restart|reload}" - return 1 - ;; - esac -} - -menu $1 - -code=$? -exit ${code} diff --git a/trunk/scripts/build.sh b/trunk/scripts/build.sh deleted file mode 100755 index 0aa4ef309..000000000 --- a/trunk/scripts/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -src_dir='src' -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi - -# step 1: build srs -# nginx is not needed, we use cherrypy to delivery hls. -# demo needs ffmpeg to transcode the live stream. -echo "编译SRS" -./configure --demo && make -ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:编译SRS失败"; exit $ret; fi - -echo "编译SRS成功" -echo "你可以启动SRS:" -echo " bash scripts/run.sh" diff --git a/trunk/scripts/run.sh b/trunk/scripts/run.sh deleted file mode 100755 index 98413c1a4..000000000 --- a/trunk/scripts/run.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -src_dir='src' -if [[ ! -d $src_dir ]]; then echo "错误:必须在src同目录执行脚本"; exit 1; fi - -# linux shell color support. -RED="\\033[31m" -GREEN="\\033[32m" -YELLOW="\\033[33m" -BLACK="\\033[0m" - -./etc/init.d/srs-demo restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS失败"; exit $ret; fi -echo "启动SRS服务器成功" - -./etc/init.d/srs-demo-19350 restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动SRS转发服务器失败"; exit $ret; fi -echo "启动SRS转发服务器成功" - -./etc/init.d/srs-api restart; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:启动API服务器失败"; exit $ret; fi -echo "启动API服务器成功" - -ip=`ifconfig|grep "inet "|grep -v "127.0.0.1"|awk -F 'inet ' 'NR==1 {print $2}'|awk '{print $1}'|sed "s/addr://g"` -port=8085 -cat</dev/null 2>&1 -if [[ 0 -eq $? && `getenforce` != 'Disabled' ]]; then - echo -e "${RED}请关闭selinux:${BLACK}"; - echo -e "${RED} 打开配置文件:sudo vi /etc/sysconfig/selinux${BLACK}"; - echo -e "${RED} 修改为:SELINUX=disabled${BLACK}"; - echo -e "${RED} 重启系统:sudo reboot${BLACK}"; -fi - -if [[ -f /etc/init.d/iptables ]]; then - sudo /etc/init.d/iptables status >/dev/null 2>&1; - if [[ $? -ne 3 ]]; then - echo -e "${RED}请关闭防火墙:${BLACK}"; - echo -e "${RED} sudo /etc/init.d/iptables stop${BLACK}"; - fi -fi - -echo -e "${GREEN}请在hosts中添加一行:${BLACK}" -echo -e "${RED} $ip demo.srs.com${BLACK}" -echo -e "${GREEN}演示地址:${BLACK}" -echo -e "${RED} http://$ip:$port${BLACK}" -echo -e "@see https://github.com/ossrs/srs/wiki/v1_CN_SampleDemo" diff --git a/trunk/scripts/stop.sh b/trunk/scripts/stop.sh deleted file mode 100755 index 714654194..000000000 --- a/trunk/scripts/stop.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -./etc/init.d/srs-demo stop; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:停止SRS失败"; exit $ret; fi -echo "停止SRS服务器成功" - -./etc/init.d/srs-demo-19350 stop; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:停止SRS转发服务器失败"; exit $ret; fi -echo "停止SRS转发服务器成功" - -./etc/init.d/srs-api stop; ret=$?; if [[ 0 -ne $ret ]]; then echo "错误:停止API服务器失败"; exit $ret; fi -echo "停止API服务器成功" - -echo "SRS系统服务均已停止" From ed1c499bd3c5e9ad92278a0b36997ad4f34daf77 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 28 Oct 2021 07:52:24 +0800 Subject: [PATCH 2/3] Gop: Ignore zero timestamp when shrinking. v4.0.187 (#2186) --- trunk/doc/CHANGELOG.md | 1 + trunk/src/app/srs_app_source.cpp | 17 ++++++++++------- trunk/src/core/srs_core_version4.hpp | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 860df66e1..a568386eb 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2021-10-28, Merge [#2186](https://github.com/ossrs/srs/pull/2186): Gop: Ignore zero timestamp when shrinking. v4.0.187 * v4.0, 2021-10-27, Merge [#1963](https://github.com/ossrs/srs/pull/1963): Cluster: Origin server shouldn't be it's own coworker. v4.0.186 * v4.0, 2021-10-25, Merge [#2692](https://github.com/ossrs/srs/pull/2692): API: Add server_id into http_hooks. v4.0.185 * v4.0, 2021-10-22, Merge [#2687](https://github.com/ossrs/srs/pull/2687): API: Always stat client event if auth fail. v4.0.183 diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index aae228b48..d6209b651 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -255,8 +255,11 @@ srs_error_t SrsMessageQueue::enqueue(SrsSharedPtrMessage* msg, bool* is_overflow srs_error_t err = srs_success; msgs.push_back(msg); - - if (msg->is_av()) { + + // If jitter is off, the timestamp of first sequence header is zero, which wll cause SRS to shrink and drop the + // keyframes even if there is not overflow packets in queue, so we must ignore the zero timestamps, please + // @see https://github.com/ossrs/srs/pull/2186#issuecomment-953383063 + if (msg->is_av() && msg->timestamp != 0) { if (av_start_time == -1) { av_start_time = srs_utime_t(msg->timestamp * SRS_UTIME_MILLISECONDS); } @@ -267,7 +270,7 @@ srs_error_t SrsMessageQueue::enqueue(SrsSharedPtrMessage* msg, bool* is_overflow if (max_queue_size <= 0) { return err; } - + while (av_end_time - av_start_time > max_queue_size) { // notice the caller queue already overflow and shrinked. if (is_overflow) { @@ -338,8 +341,7 @@ void SrsMessageQueue::shrink() SrsSharedPtrMessage* audio_sh = NULL; int msgs_size = (int)msgs.size(); - // remove all msg - // igone the sequence header + // Remove all msgs, mark the sequence headers. for (int i = 0; i < (int)msgs.size(); i++) { SrsSharedPtrMessage* msg = msgs.at(i); @@ -358,9 +360,10 @@ void SrsMessageQueue::shrink() } msgs.clear(); - // update av_start_time + // Update av_start_time, the start time of queue. av_start_time = av_end_time; - //push_back secquence header and update timestamp + + // Push back sequence headers and update their timestamps. if (video_sh) { video_sh->timestamp = srsu2ms(av_end_time); msgs.push_back(video_sh); diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index bb24f9adf..9b733cf82 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 186 +#define VERSION_REVISION 187 #endif From 49f288295eed061ea9da268331c037634325dd4c Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 28 Oct 2021 08:00:45 +0800 Subject: [PATCH 3/3] Release SRS v4.0.187 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bd417fb8c..1199d62be 100755 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ A big THANK YOU goes to: ## Releases +* 2021-10-28, Release [v4.0.187](https://github.com/ossrs/srs/releases/tag/v4.0.187), 4.0 dev7, v4.0.187, 143831 lines. * 2021-10-12, Release [v4.0.177](https://github.com/ossrs/srs/releases/tag/v4.0.177), 4.0 dev6, v4.0.177, 143686 lines. * 2021-09-05, Release [v4.0.161](https://github.com/ossrs/srs/releases/tag/v4.0.161), 4.0 dev5, v4.0.161, 145865 lines. * 2021-08-15, Release [v4.0.156](https://github.com/ossrs/srs/releases/tag/v4.0.156), 4.0 dev4, v4.0.156, 145490 lines.