From 8ea9783de7f004be3d356fadf1bda1596bcdcce1 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 3 Oct 2021 19:32:06 +0800 Subject: [PATCH 1/2] OpenWRT: Disable mprotect of ST. 5.0.16 --- trunk/3rdparty/st-srs/stk.c | 5 ++- trunk/auto/depends.sh | 60 ++++++++++++++-------------- trunk/conf/openwrt.conf | 24 +++++++++++ trunk/doc/CHANGELOG.md | 3 +- trunk/src/core/srs_core_version5.hpp | 2 +- 5 files changed, 61 insertions(+), 33 deletions(-) create mode 100644 trunk/conf/openwrt.conf diff --git a/trunk/3rdparty/st-srs/stk.c b/trunk/3rdparty/st-srs/stk.c index 6569e78e8..a37c3e62e 100644 --- a/trunk/3rdparty/st-srs/stk.c +++ b/trunk/3rdparty/st-srs/stk.c @@ -89,8 +89,9 @@ _st_stack_t *_st_stack_new(int stack_size) ts->stk_size = stack_size; ts->stk_bottom = ts->vaddr + REDZONE; ts->stk_top = ts->stk_bottom + stack_size; - -#ifdef DEBUG + + /* For example, in OpenWRT, the memory at the begin minus 16B by mprotect is read-only. */ +#if defined(DEBUG) && !defined(MD_NO_PROTECT) mprotect(ts->vaddr, REDZONE, PROT_NONE); mprotect(ts->stk_top + extra, REDZONE, PROT_NONE); #endif diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index cdabc7038..ceb10b77c 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -598,36 +598,38 @@ fi ##################################################################################### # srtp ##################################################################################### -SRTP_OPTIONS="" -# If use ASM for SRTP, we enable openssl(with ASM). -if [[ $SRS_SRTP_ASM == YES ]]; then - SRTP_OPTIONS="--enable-openssl" - SRTP_CONFIGURE="env PKG_CONFIG_PATH=$(cd ${SRS_OBJS}/${SRS_PLATFORM} && pwd)/openssl/lib/pkgconfig ./configure" -else - SRTP_CONFIGURE="./configure" +if [[ $SRS_RTC == YES ]]; then + SRTP_OPTIONS="" + # If use ASM for SRTP, we enable openssl(with ASM). + if [[ $SRS_SRTP_ASM == YES ]]; then + SRTP_OPTIONS="--enable-openssl" + SRTP_CONFIGURE="env PKG_CONFIG_PATH=$(cd ${SRS_OBJS}/${SRS_PLATFORM} && pwd)/openssl/lib/pkgconfig ./configure" + else + SRTP_CONFIGURE="./configure" + fi + if [[ $SRS_CROSS_BUILD == YES ]]; then + SRTP_OPTIONS="$SRTP_OPTIONS --host=$SRS_CROSS_BUILD_HOST" + fi + # Patched ST from https://github.com/ossrs/state-threads/tree/srs + if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/_release/lib/libsrtp2.a ]]; then + echo "The libsrtp-2-fit is ok."; + else + echo "Building libsrtp-2-fit."; + ( + rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS}/${SRS_PLATFORM} && + rm -rf libsrtp-2-fit && cp -R ../../3rdparty/libsrtp-2-fit . && cd libsrtp-2-fit && + $SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=`pwd`/_release && + make ${SRS_JOBS} && make install && + cd .. && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2 + ) + fi + # check status + ret=$?; if [[ $ret -ne 0 ]]; then echo "Build libsrtp-2-fit failed, ret=$ret"; exit $ret; fi + # Always update the links. + (cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2) + (cd ${SRS_OBJS} && rm -rf srtp2 && ln -sf ${SRS_PLATFORM}/libsrtp-2-fit/_release srtp2) + if [ ! -f ${SRS_OBJS}/srtp2/lib/libsrtp2.a ]; then echo "Build libsrtp-2-fit static lib failed."; exit -1; fi fi -if [[ $SRS_CROSS_BUILD == YES ]]; then - SRTP_OPTIONS="$SRTP_OPTIONS --host=$SRS_CROSS_BUILD_HOST" -fi -# Patched ST from https://github.com/ossrs/state-threads/tree/srs -if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/_release/lib/libsrtp2.a ]]; then - echo "The libsrtp-2-fit is ok."; -else - echo "Building libsrtp-2-fit."; - ( - rm -rf ${SRS_OBJS}/srtp2 && cd ${SRS_OBJS}/${SRS_PLATFORM} && - rm -rf libsrtp-2-fit && cp -R ../../3rdparty/libsrtp-2-fit . && cd libsrtp-2-fit && - $SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=`pwd`/_release && - make ${SRS_JOBS} && make install && - cd .. && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2 - ) -fi -# check status -ret=$?; if [[ $ret -ne 0 ]]; then echo "Build libsrtp-2-fit failed, ret=$ret"; exit $ret; fi -# Always update the links. -(cd ${SRS_OBJS}/${SRS_PLATFORM} && rm -rf srtp2 && ln -sf libsrtp-2-fit/_release srtp2) -(cd ${SRS_OBJS} && rm -rf srtp2 && ln -sf ${SRS_PLATFORM}/libsrtp-2-fit/_release srtp2) -if [ ! -f ${SRS_OBJS}/srtp2/lib/libsrtp2.a ]; then echo "Build libsrtp-2-fit static lib failed."; exit -1; fi ##################################################################################### # libopus, for WebRTC to transcode AAC with Opus. diff --git a/trunk/conf/openwrt.conf b/trunk/conf/openwrt.conf new file mode 100644 index 000000000..b2a82023f --- /dev/null +++ b/trunk/conf/openwrt.conf @@ -0,0 +1,24 @@ +# no-daemon and write log to console config for srs. +# @see full.conf for detail config. + +listen 1935; +max_connections 1000; +daemon off; +srs_log_tank console; +http_api { + enabled on; + listen 1985; +} +http_server { + enabled on; + listen 8080; +} +vhost __defaultVhost__ { + hls { + enabled on; + } + http_remux { + enabled on; + mount [vhost]/[app]/[stream].flv; + } +} diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index a48d11927..67107872b 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,7 +8,8 @@ The changelog for SRS. ## SRS 5.0 Changelog -* v4.0, 2021-10-03, Actions: Create source tar lik srs-server-5.0.14.tar.gz +* v5.0, 2021-10-03, OpenWRT: Disable mprotect of ST. 5.0.16 +* v5.0, 2021-10-03, Actions: Create source tar lik srs-server-5.0.14.tar.gz * v5.0, 2021-10-02, ST: Support Cygwin64 and MIPS. 5.0.13 * v5.0, 2021-09-23, Merge [#2578](https://github.com/ossrs/srs/pull/2578) Support http callback on_play/stop. 5.0.12 * v5.0, 2021-08-07, Fix [#2508](https://github.com/ossrs/srs/pull/2508), Support features query by API. 5.0.10 diff --git a/trunk/src/core/srs_core_version5.hpp b/trunk/src/core/srs_core_version5.hpp index 8d8d06e93..479cca7e7 100644 --- a/trunk/src/core/srs_core_version5.hpp +++ b/trunk/src/core/srs_core_version5.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 0 -#define VERSION_REVISION 15 +#define VERSION_REVISION 16 #endif From a19c0fa12165224a51d99d53b0ba880326283cea Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 3 Oct 2021 20:51:07 +0800 Subject: [PATCH 2/2] OpenWRT: Try to create dir for pidfile --- trunk/conf/openwrt.conf | 2 +- trunk/src/app/srs_app_server.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/trunk/conf/openwrt.conf b/trunk/conf/openwrt.conf index b2a82023f..c6dba121a 100644 --- a/trunk/conf/openwrt.conf +++ b/trunk/conf/openwrt.conf @@ -15,7 +15,7 @@ http_server { } vhost __defaultVhost__ { hls { - enabled on; + enabled off; } http_remux { enabled on; diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 1fd14ff96..1b3109960 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -744,12 +744,22 @@ srs_error_t SrsServer::initialize_signal() srs_error_t SrsServer::acquire_pid_file() { + srs_error_t err = srs_success; + // when srs in dolphin mode, no need the pid file. if (_srs_config->is_dolphin()) { return srs_success; } std::string pid_file = _srs_config->get_pid_file(); + + // Try to create dir for pid file. + string pid_dir = srs_path_dirname(pid_file); + if (!srs_path_exists(pid_dir)) { + if ((err = srs_create_dir_recursively(pid_dir)) != srs_success) { + return srs_error_wrap(err, "create %s", pid_dir.c_str()); + } + } // -rw-r--r-- // 644