From c30aa479a76a78b8bd4ea7bceb2df6cf44aa0f23 Mon Sep 17 00:00:00 2001 From: chundonglinlin Date: Wed, 12 Jan 2022 09:12:29 +0800 Subject: [PATCH 01/18] RTC: Fix both rtmp and rtc streams can be published at the same time. (#2875) --- trunk/src/app/srs_app_rtc_conn.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 5a4e32ab4..1fd578838 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -1183,20 +1183,20 @@ srs_error_t SrsRtcPublishStream::initialize(SrsRequest* r, SrsRtcSourceDescripti } source->set_publish_stream(this); + // TODO: FIMXE: Check it in SrsRtcConnection::add_publisher? + SrsLiveSource *rtmp = _srs_sources->fetch(r); + if (rtmp && !rtmp->can_publish(false)) { + return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp stream %s busy", r->get_stream_url().c_str()); + } + // Bridge to rtmp #if defined(SRS_RTC) && defined(SRS_FFMPEG_FIT) bool rtc_to_rtmp = _srs_config->get_rtc_to_rtmp(req_->vhost); if (rtc_to_rtmp) { - SrsLiveSource *rtmp = NULL; if ((err = _srs_sources->fetch_or_create(r, _srs_hybrid->srs()->instance(), &rtmp)) != srs_success) { return srs_error_wrap(err, "create source"); } - // TODO: FIMXE: Check it in SrsRtcConnection::add_publisher? - if (!rtmp->can_publish(false)) { - return srs_error_new(ERROR_SYSTEM_STREAM_BUSY, "rtmp stream %s busy", r->get_stream_url().c_str()); - } - // Disable GOP cache for RTC2RTMP bridger, to keep the streams in sync, // especially for stream merging. rtmp->set_cache(false); From 7e25d0d7f4d2468814fd1623a922c2b6f9dbe5e1 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 12 Jan 2022 22:03:46 +0800 Subject: [PATCH 02/18] Refine the running homepage. v4.0.221 --- trunk/doc/CHANGELOG.md | 3 +- .../research/api-server/static-dir/index.html | 67 ++++++++++++++----- trunk/src/core/srs_core_version4.hpp | 2 +- 3 files changed, 52 insertions(+), 20 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 9ab0ff4f4..0cfd30b9b 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,7 +8,8 @@ The changelog for SRS. ## SRS 4.0 Changelog -* v4.0, 2022-01-20, Merge [#2863](https://github.com/ossrs/srs/pull/2863): RTC: fix play crash or no stream for rtmp2rtc tips.(#2863). v4.0.220 +* v4.0, 2022-01-12, Refine the running homepage. v4.0.221 +* v4.0, 2022-01-12, Merge [#2863](https://github.com/ossrs/srs/pull/2863): RTC: fix play crash or no stream for rtmp2rtc tips.(#2863). v4.0.220 * v4.0, 2022-01-05, For [#2717](https://github.com/ossrs/srs/issues/2717): When reopening segment, never update the duration. (#2717). v4.0.219 * v4.0, 2022-01-04, Discover api server and ip as candidates. v4.0.218 * v4.0, 2022-01-04, Install test-on self-sign certificate. v4.0.217 diff --git a/trunk/research/api-server/static-dir/index.html b/trunk/research/api-server/static-dir/index.html index e73a6e75b..d155e15bf 100755 --- a/trunk/research/api-server/static-dir/index.html +++ b/trunk/research/api-server/static-dir/index.html @@ -3,24 +3,55 @@ SRS + -

SRS works!

-

- Click here to enter SRS console.
- 点击进入SRS控制台 -

-

- Click here to start SRS player.
- 点击进入SRS播放器 -

-

SRS Team © 2021

- +
+

SRS works!

+

+ Click here to enter SRS console.
+ 点击进入SRS控制台 +

+

+ Publish stream by FFmpeg or OBS:
+ 请使用工具FFmpeg或者OBS推流到下面地址: +


+        

+

+ Click here to start SRS player.
+ 点击进入SRS播放器 +

+

SRS Team © 2022

+
+ diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 38880bf57..3ef0133b5 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 220 +#define VERSION_REVISION 221 #endif From 574afb43200f077cbe83802ce1e9f6c5bf503168 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 10:44:10 +0800 Subject: [PATCH 03/18] Refine the running homepage. v4.0.221 --- .../research/api-server/static-dir/index.html | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/trunk/research/api-server/static-dir/index.html b/trunk/research/api-server/static-dir/index.html index d155e15bf..5611d5fbe 100755 --- a/trunk/research/api-server/static-dir/index.html +++ b/trunk/research/api-server/static-dir/index.html @@ -26,8 +26,8 @@

SRS works!

- Click here to enter SRS console.
- 点击进入SRS控制台 + Click here to enter SRS console.
+ 点击进入SRS控制台

Publish stream by FFmpeg or OBS:
@@ -35,23 +35,37 @@


         

- Click here to start SRS player.
- 点击进入SRS播放器 + Click here to start SRS player.
+ 点击进入SRS播放器

SRS Team © 2022

From fb93631407122a52767beba1380de8e5b95e07dd Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 11:00:11 +0800 Subject: [PATCH 04/18] Refine the running homepage. v4.0.221 --- trunk/research/api-server/static-dir/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk/research/api-server/static-dir/index.html b/trunk/research/api-server/static-dir/index.html index 5611d5fbe..6c8f0f0e9 100755 --- a/trunk/research/api-server/static-dir/index.html +++ b/trunk/research/api-server/static-dir/index.html @@ -61,9 +61,9 @@ // The player url. if (true) { - const prefix = 'players/'; + const prefix = `players/?schema=${window.location.protocol.replace(':', '')}`; // If not 8080, user should proxy to the default port. - const query = parseInt(window.location.port) === 8080 ? '' : `?port=${window.location.port}`; + const query = parseInt(window.location.port) === 8080 ? '' : `&port=${window.location.port}`; document.getElementById("enPlayer").setAttribute('href', `${prefix}${query}`); document.getElementById("cnPlayer").setAttribute('href', `${prefix}${query}`); } From d47dd81f4624de81e6762549cd7d4c24d6a97d13 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 11:10:11 +0800 Subject: [PATCH 05/18] Refine the running homepage. v4.0.221 --- trunk/research/api-server/static-dir/index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trunk/research/api-server/static-dir/index.html b/trunk/research/api-server/static-dir/index.html index 6c8f0f0e9..d54b70289 100755 --- a/trunk/research/api-server/static-dir/index.html +++ b/trunk/research/api-server/static-dir/index.html @@ -62,8 +62,9 @@ // The player url. if (true) { const prefix = `players/?schema=${window.location.protocol.replace(':', '')}`; + const httpPort = window.location.port || (window.location.protocol === 'http:' ? 80 : 443); // If not 8080, user should proxy to the default port. - const query = parseInt(window.location.port) === 8080 ? '' : `&port=${window.location.port}`; + const query = parseInt(window.location.port) === 8080 ? '' : `&port=${httpPort}`; document.getElementById("enPlayer").setAttribute('href', `${prefix}${query}`); document.getElementById("cnPlayer").setAttribute('href', `${prefix}${query}`); } From 71a4b3c3f7703951f307fbf810d9d3a9ad784283 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 11:38:25 +0800 Subject: [PATCH 06/18] Add conf/lighthouse.conf for LightHouse. v4.0.222 --- trunk/auto/auto_headers.sh | 1 + trunk/auto/options.sh | 4 +++ trunk/conf/lighthouse.conf | 43 ++++++++++++++++++++++++++++ trunk/doc/CHANGELOG.md | 1 + trunk/src/app/srs_app_config.cpp | 2 +- trunk/src/core/srs_core_version4.hpp | 2 +- 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 trunk/conf/lighthouse.conf diff --git a/trunk/auto/auto_headers.sh b/trunk/auto/auto_headers.sh index 2c5f40649..19448404d 100755 --- a/trunk/auto/auto_headers.sh +++ b/trunk/auto/auto_headers.sh @@ -177,6 +177,7 @@ fi # prefix echo "" >> $SRS_AUTO_HEADERS_H echo "#define SRS_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H +echo "#define SRS_DEFAULT_CONFIG \"${SRS_DEFAULT_CONFIG}\"" >> $SRS_AUTO_HEADERS_H echo "" >> $SRS_AUTO_HEADERS_H diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 43100b148..c33acb5f8 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -36,6 +36,7 @@ SRS_FFMPEG_TOOL=NO SRS_FFMPEG_FIT=RESERVED # arguments SRS_PREFIX=/usr/local/srs +SRS_DEFAULT_CONFIG=conf/srs.conf SRS_JOBS=1 SRS_STATIC=NO # If enabled, link shared libraries for libst.so which uses MPL license. @@ -127,6 +128,7 @@ Features: --ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT) --prefix= The absolute installation path. Default: $SRS_PREFIX + --config= The default config file for SRS. Default: $SRS_DEFAULT_CONFIG --gcov=on|off Whether enable the GCOV compiler options. Default: $(value2switch $SRS_GCOV) --debug=on|off Whether enable the debug code, may hurt performance. Default: $(value2switch $SRS_DEBUG) --debug-stats=on|off Whether enable the debug stats, may hurt performance. Default: $(value2switch $SRS_DEBUG_STATS) @@ -220,6 +222,7 @@ function parse_user_option() { --jobs) SRS_JOBS=${value} ;; --prefix) SRS_PREFIX=${value} ;; + --config) SRS_DEFAULT_CONFIG=${value} ;; --static) SRS_STATIC=$(switch2value $value) ;; --cpu) SRS_CROSS_BUILD_CPU=${value} ;; @@ -492,6 +495,7 @@ function regenerate_options() { SRS_AUTO_USER_CONFIGURE=`echo $opt` # regenerate the options for default values. SRS_AUTO_CONFIGURE="--prefix=${SRS_PREFIX}" + SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --config=$SRS_DEFAULT_CONFIG" SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --hls=$(value2switch $SRS_HLS)" SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --hds=$(value2switch $SRS_HDS)" SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --dvr=$(value2switch $SRS_DVR)" diff --git a/trunk/conf/lighthouse.conf b/trunk/conf/lighthouse.conf new file mode 100644 index 000000000..61e5ba5b0 --- /dev/null +++ b/trunk/conf/lighthouse.conf @@ -0,0 +1,43 @@ + +listen 1935; +max_connections 1000; +daemon on; +srs_log_tank file; + +http_server { + enabled on; + listen 8080; + dir ./objs/nginx/html; +} + +http_api { + enabled on; + listen 1985; +} +stats { + network 0; +} +rtc_server { + enabled on; + listen 8000; # UDP port + # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#config-candidate + candidate $CANDIDATE; +} + +vhost __defaultVhost__ { + hls { + enabled on; + } + http_remux { + enabled on; + mount [vhost]/[app]/[stream].flv; + } + rtc { + enabled on; + # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtmp-to-rtc + rtmp_to_rtc on; + # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtc-to-rtmp + rtc_to_rtmp on; + } +} + diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 0cfd30b9b..130d0bce1 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, 2022-01-13, Add conf/lighthouse.conf for LightHouse. v4.0.222 * v4.0, 2022-01-12, Refine the running homepage. v4.0.221 * v4.0, 2022-01-12, Merge [#2863](https://github.com/ossrs/srs/pull/2863): RTC: fix play crash or no stream for rtmp2rtc tips.(#2863). v4.0.220 * v4.0, 2022-01-05, For [#2717](https://github.com/ossrs/srs/issues/2717): When reopening segment, never update the duration. (#2717). v4.0.219 diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index a984b4cd8..f7174dbd7 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -50,7 +50,7 @@ const char* _srs_version = "XCORE-" RTMP_SIG_SRS_SERVER; #define SRS_CONF_PERFER_TRUE(conf_arg) conf_arg != "off" // default config file. -#define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf" +#define SRS_CONF_DEFAULT_COFNIG_FILE SRS_DEFAULT_CONFIG // '\n' #define SRS_LF (char)SRS_CONSTS_LF diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 3ef0133b5..66794be67 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 221 +#define VERSION_REVISION 222 #endif From 7580341a1e506713d5bb69c8dbd03193a7f13489 Mon Sep 17 00:00:00 2001 From: chundonglinlin Date: Thu, 13 Jan 2022 11:43:32 +0800 Subject: [PATCH 07/18] LiveSource/RtcSource: Refine fetch for external exposed interface. (#2873) --- trunk/src/app/srs_app_rtc_source.cpp | 9 ++++----- trunk/src/app/srs_app_rtc_source.hpp | 1 - trunk/src/app/srs_app_source.cpp | 9 ++++----- trunk/src/app/srs_app_source.hpp | 1 - 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 8e79f443a..ea1082c31 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -256,6 +256,10 @@ srs_error_t SrsRtcSourceManager::fetch_or_create(SrsRequest* r, SrsRtcSource** p SrsRtcSource* source = NULL; if ((source = fetch(r)) != NULL) { + // we always update the request of resource, + // for origin auth is on, the token in request maybe invalid, + // and we only need to update the token of request, it's simple. + source->update_auth(r); *pps = source; return err; } @@ -291,11 +295,6 @@ SrsRtcSource* SrsRtcSourceManager::fetch(SrsRequest* r) source = pool[stream_url]; - // we always update the request of resource, - // for origin auth is on, the token in request maybe invalid, - // and we only need to update the token of request, it's simple. - source->update_auth(r); - return source; } diff --git a/trunk/src/app/srs_app_rtc_source.hpp b/trunk/src/app/srs_app_rtc_source.hpp index c98db9561..1b9555a04 100644 --- a/trunk/src/app/srs_app_rtc_source.hpp +++ b/trunk/src/app/srs_app_rtc_source.hpp @@ -114,7 +114,6 @@ public: virtual srs_error_t fetch_or_create(SrsRequest* r, SrsRtcSource** pps); private: // Get the exists source, NULL when not exists. - // update the request and return the exists source. virtual SrsRtcSource* fetch(SrsRequest* r); }; diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index d297f0f4a..5705a13ac 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1713,6 +1713,10 @@ srs_error_t SrsLiveSourceManager::fetch_or_create(SrsRequest* r, ISrsLiveSourceH SrsLiveSource* source = NULL; if ((source = fetch(r)) != NULL) { + // we always update the request of resource, + // for origin auth is on, the token in request maybe invalid, + // and we only need to update the token of request, it's simple. + source->update_auth(r); *pps = source; return err; } @@ -1751,11 +1755,6 @@ SrsLiveSource* SrsLiveSourceManager::fetch(SrsRequest* r) source = pool[stream_url]; - // we always update the request of resource, - // for origin auth is on, the token in request maybe invalid, - // and we only need to update the token of request, it's simple. - source->update_auth(r); - return source; } diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index d1bf0b3dc..78d04958d 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -450,7 +450,6 @@ public: virtual srs_error_t fetch_or_create(SrsRequest* r, ISrsLiveSourceHandler* h, SrsLiveSource** pps); public: // Get the exists source, NULL when not exists. - // update the request and return the exists source. virtual SrsLiveSource* fetch(SrsRequest* r); public: // dispose and cycle all sources. From e6ab5db1138526c546a044917575954fd8427c78 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 11:47:14 +0800 Subject: [PATCH 08/18] LiveSource: Refine fetch for external exposed interface. (#2873). v4.0.223 --- trunk/doc/CHANGELOG.md | 3 ++- trunk/src/core/srs_core_version4.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 130d0bce1..381f1d40b 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,9 +8,10 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2022-01-13, Merge [#2873](https://github.com/ossrs/srs/pull/2873): LiveSource: Refine fetch for external exposed interface. (#2873). v4.0.223 * v4.0, 2022-01-13, Add conf/lighthouse.conf for LightHouse. v4.0.222 * v4.0, 2022-01-12, Refine the running homepage. v4.0.221 -* v4.0, 2022-01-12, Merge [#2863](https://github.com/ossrs/srs/pull/2863): RTC: fix play crash or no stream for rtmp2rtc tips.(#2863). v4.0.220 +* v4.0, 2022-01-12, Merge [#2863](https://github.com/ossrs/srs/pull/2863): RTC: fix play crash or no stream for rtmp2rtc tips. (#2863). v4.0.220 * v4.0, 2022-01-05, For [#2717](https://github.com/ossrs/srs/issues/2717): When reopening segment, never update the duration. (#2717). v4.0.219 * v4.0, 2022-01-04, Discover api server and ip as candidates. v4.0.218 * v4.0, 2022-01-04, Install test-on self-sign certificate. v4.0.217 diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 66794be67..c67b5f8ee 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 222 +#define VERSION_REVISION 223 #endif From db3ceb445bd2f2833b2cccba532ac2661cd422b3 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 12:07:34 +0800 Subject: [PATCH 09/18] Support api_port to specify the WebRTC API port. v4.0.224 --- trunk/doc/CHANGELOG.md | 1 + trunk/research/api-server/static-dir/index.html | 4 ++-- trunk/research/players/js/srs.sdk.js | 4 +++- trunk/src/core/srs_core_version4.hpp | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 381f1d40b..a2436754f 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, 2022-01-14, Support api_port to specify the WebRTC API port. v4.0.224 * v4.0, 2022-01-13, Merge [#2873](https://github.com/ossrs/srs/pull/2873): LiveSource: Refine fetch for external exposed interface. (#2873). v4.0.223 * v4.0, 2022-01-13, Add conf/lighthouse.conf for LightHouse. v4.0.222 * v4.0, 2022-01-12, Refine the running homepage. v4.0.221 diff --git a/trunk/research/api-server/static-dir/index.html b/trunk/research/api-server/static-dir/index.html index d54b70289..684848da3 100755 --- a/trunk/research/api-server/static-dir/index.html +++ b/trunk/research/api-server/static-dir/index.html @@ -63,8 +63,8 @@ if (true) { const prefix = `players/?schema=${window.location.protocol.replace(':', '')}`; const httpPort = window.location.port || (window.location.protocol === 'http:' ? 80 : 443); - // If not 8080, user should proxy to the default port. - const query = parseInt(window.location.port) === 8080 ? '' : `&port=${httpPort}`; + // If not 8080, user should proxy both stream and API to the default port. + const query = parseInt(window.location.port) === 8080 ? '' : `&port=${httpPort}&api_port=${httpPort}`; document.getElementById("enPlayer").setAttribute('href', `${prefix}${query}`); document.getElementById("cnPlayer").setAttribute('href', `${prefix}${query}`); } diff --git a/trunk/research/players/js/srs.sdk.js b/trunk/research/players/js/srs.sdk.js index ed5276b50..af4f48837 100644 --- a/trunk/research/players/js/srs.sdk.js +++ b/trunk/research/players/js/srs.sdk.js @@ -267,6 +267,7 @@ function SrsRtcPlayerAsync() { // webrtc://r.ossrs.net/live/livestream // or specifies the API port: // webrtc://r.ossrs.net:11985/live/livestream + // webrtc://r.ossrs.net/live/livestream?api_port=11985 // or autostart the play: // webrtc://r.ossrs.net/live/livestream?autostart=true // or change the app from live to myapp: @@ -438,8 +439,9 @@ function SrsRtcPlayerAsync() { } else if (window.location.href.indexOf('https://') === 0) { ret.port = 443; } else { + // Allow use api_port to specify the WebRTC API port. // For WebRTC, SRS use 1985 as default API port. - ret.port = 1985; + ret.port = ret.user_query.api_port || 1985; } } } diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index c67b5f8ee..c9415a650 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 223 +#define VERSION_REVISION 224 #endif From c6c2e971899ebd774e64a080d3d34bcffb408b5f Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 12:16:45 +0800 Subject: [PATCH 10/18] Support api_port to specify the WebRTC API port. v4.0.225 --- trunk/research/players/js/srs.page.js | 10 ++++++++-- trunk/research/players/js/srs.sdk.js | 3 ++- trunk/src/core/srs_core_version4.hpp | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/trunk/research/players/js/srs.page.js b/trunk/research/players/js/srs.page.js index 26b3971e1..ffc88cdfa 100755 --- a/trunk/research/players/js/srs.page.js +++ b/trunk/research/players/js/srs.page.js @@ -24,7 +24,7 @@ function update_nav() { } // Special extra params, such as auth_key. -function user_extra_params(query, params) { +function user_extra_params(query, params, rtc) { var queries = params || []; for (var key in query.user_query) { @@ -37,6 +37,10 @@ function user_extra_params(query, params) { continue; } + if (!rtc && key === 'api_port') { + continue; + } + if (query[key]) { queries.push(key + '=' + query[key]); } @@ -90,6 +94,8 @@ function build_default_flv_url() { function build_default_rtc_url(query) { // The format for query string to overwrite configs of server. console.log('?eip=x.x.x.x to overwrite candidate. 覆盖服务器candidate(外网IP)配置'); + console.log('?api_port=x to overwrite WebRTC API(1985).'); + console.log('?schema=http|https to overwrite WebRTC API protocol.'); var server = (!query.server)? window.location.hostname:query.server; var vhost = (!query.vhost)? window.location.hostname:query.vhost; @@ -104,7 +110,7 @@ function build_default_rtc_url(query) { if (query.schema && window.location.protocol !== query.schema + ':') { queries.push('schema=' + query.schema); } - queries = user_extra_params(query, queries); + queries = user_extra_params(query, queries, true); var uri = "webrtc://" + server + api + "/" + app + "/" + stream + "?" + queries.join('&'); while (uri.lastIndexOf("?") === uri.length - 1) { diff --git a/trunk/research/players/js/srs.sdk.js b/trunk/research/players/js/srs.sdk.js index af4f48837..5673aa045 100644 --- a/trunk/research/players/js/srs.sdk.js +++ b/trunk/research/players/js/srs.sdk.js @@ -210,8 +210,9 @@ function SrsRtcPublisherAsync() { } else if (window.location.href.indexOf('https://') === 0) { ret.port = 443; } else { + // Allow use api_port to specify the WebRTC API port. // For WebRTC, SRS use 1985 as default API port. - ret.port = 1985; + ret.port = ret.user_query.api_port || 1985; } } } diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index c9415a650..0999c7ba2 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 224 +#define VERSION_REVISION 225 #endif From 73d0ce1ceeaeaf4b2fe2deb78aa0a337eb2533a9 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 13:32:14 +0800 Subject: [PATCH 11/18] Support api to specify the WebRTC API port. v4.0.225 --- .../research/api-server/static-dir/index.html | 2 +- trunk/research/players/js/srs.page.js | 6 +----- trunk/research/players/js/srs.sdk.js | 20 ++++++++++++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/trunk/research/api-server/static-dir/index.html b/trunk/research/api-server/static-dir/index.html index 684848da3..8d92fc12c 100755 --- a/trunk/research/api-server/static-dir/index.html +++ b/trunk/research/api-server/static-dir/index.html @@ -64,7 +64,7 @@ const prefix = `players/?schema=${window.location.protocol.replace(':', '')}`; const httpPort = window.location.port || (window.location.protocol === 'http:' ? 80 : 443); // If not 8080, user should proxy both stream and API to the default port. - const query = parseInt(window.location.port) === 8080 ? '' : `&port=${httpPort}&api_port=${httpPort}`; + const query = parseInt(window.location.port) === 8080 ? '' : `&port=${httpPort}&api=${httpPort}`; document.getElementById("enPlayer").setAttribute('href', `${prefix}${query}`); document.getElementById("cnPlayer").setAttribute('href', `${prefix}${query}`); } diff --git a/trunk/research/players/js/srs.page.js b/trunk/research/players/js/srs.page.js index ffc88cdfa..d680f3cbd 100755 --- a/trunk/research/players/js/srs.page.js +++ b/trunk/research/players/js/srs.page.js @@ -37,10 +37,6 @@ function user_extra_params(query, params, rtc) { continue; } - if (!rtc && key === 'api_port') { - continue; - } - if (query[key]) { queries.push(key + '=' + query[key]); } @@ -94,7 +90,7 @@ function build_default_flv_url() { function build_default_rtc_url(query) { // The format for query string to overwrite configs of server. console.log('?eip=x.x.x.x to overwrite candidate. 覆盖服务器candidate(外网IP)配置'); - console.log('?api_port=x to overwrite WebRTC API(1985).'); + console.log('?api=x to overwrite WebRTC API(1985).'); console.log('?schema=http|https to overwrite WebRTC API protocol.'); var server = (!query.server)? window.location.hostname:query.server; diff --git a/trunk/research/players/js/srs.sdk.js b/trunk/research/players/js/srs.sdk.js index 5673aa045..5cda7947c 100644 --- a/trunk/research/players/js/srs.sdk.js +++ b/trunk/research/players/js/srs.sdk.js @@ -185,6 +185,12 @@ function SrsRtcPublisherAsync() { var port = a.port; if (!port) { + // Finger out by webrtc url, if contains http or https port, to overwrite default 1985. + if (schema === 'webrtc' && url.indexOf(`webrtc://${a.host}:`) === 0) { + port = (url.indexOf(`webrtc://${a.host}:80`) === 0) ? 80 : 443; + } + + // Guess by schema. if (schema === 'http') { port = 80; } else if (schema === 'https') { @@ -210,9 +216,8 @@ function SrsRtcPublisherAsync() { } else if (window.location.href.indexOf('https://') === 0) { ret.port = 443; } else { - // Allow use api_port to specify the WebRTC API port. // For WebRTC, SRS use 1985 as default API port. - ret.port = ret.user_query.api_port || 1985; + ret.port = 1985; } } } @@ -268,7 +273,7 @@ function SrsRtcPlayerAsync() { // webrtc://r.ossrs.net/live/livestream // or specifies the API port: // webrtc://r.ossrs.net:11985/live/livestream - // webrtc://r.ossrs.net/live/livestream?api_port=11985 + // webrtc://r.ossrs.net:80/live/livestream // or autostart the play: // webrtc://r.ossrs.net/live/livestream?autostart=true // or change the app from live to myapp: @@ -415,6 +420,12 @@ function SrsRtcPlayerAsync() { var port = a.port; if (!port) { + // Finger out by webrtc url, if contains http or https port, to overwrite default 1985. + if (schema === 'webrtc' && url.indexOf(`webrtc://${a.host}:`) === 0) { + port = (url.indexOf(`webrtc://${a.host}:80`) === 0) ? 80 : 443; + } + + // Guess by schema. if (schema === 'http') { port = 80; } else if (schema === 'https') { @@ -440,9 +451,8 @@ function SrsRtcPlayerAsync() { } else if (window.location.href.indexOf('https://') === 0) { ret.port = 443; } else { - // Allow use api_port to specify the WebRTC API port. // For WebRTC, SRS use 1985 as default API port. - ret.port = ret.user_query.api_port || 1985; + ret.port = 1985; } } } From 3881c4c77ed71a9fdb4ecde560dc1f8a16ed66a8 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 14:05:00 +0800 Subject: [PATCH 12/18] Add SrsAutoFreeH to release ptr with hooks. (#2880). v4.0.226 --- trunk/doc/CHANGELOG.md | 4 +++- trunk/src/core/srs_core_autofree.hpp | 18 ++++++++++++++---- trunk/src/core/srs_core_version4.hpp | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index a2436754f..1d13b8e55 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,7 +8,9 @@ The changelog for SRS. ## SRS 4.0 Changelog -* v4.0, 2022-01-14, Support api_port to specify the WebRTC API port. v4.0.224 +* v4.0, 2022-01-13, For [#2880](https://github.com/ossrs/srs/pull/2880): Add SrsAutoFreeH to release ptr with hooks. (#2880). v4.0.226 +* v4.0, 2022-01-13, Support api_port to specify the WebRTC API port. v4.0.226 +* v4.0, 2022-01-13, Support api_port to specify the WebRTC API port. v4.0.224 * v4.0, 2022-01-13, Merge [#2873](https://github.com/ossrs/srs/pull/2873): LiveSource: Refine fetch for external exposed interface. (#2873). v4.0.223 * v4.0, 2022-01-13, Add conf/lighthouse.conf for LightHouse. v4.0.222 * v4.0, 2022-01-12, Refine the running homepage. v4.0.221 diff --git a/trunk/src/core/srs_core_autofree.hpp b/trunk/src/core/srs_core_autofree.hpp index 2212074b8..2159cfe4c 100644 --- a/trunk/src/core/srs_core_autofree.hpp +++ b/trunk/src/core/srs_core_autofree.hpp @@ -30,13 +30,16 @@ // where the char* pstr = new char[size]. // To delete object. #define SrsAutoFree(className, instance) \ - impl_SrsAutoFree _auto_free_##instance(&instance, false, false) + impl_SrsAutoFree _auto_free_##instance(&instance, false, false, NULL) // To delete array. #define SrsAutoFreeA(className, instance) \ - impl_SrsAutoFree _auto_free_array_##instance(&instance, true, false) + impl_SrsAutoFree _auto_free_array_##instance(&instance, true, false, NULL) // Use free instead of delete. #define SrsAutoFreeF(className, instance) \ - impl_SrsAutoFree _auto_free_##instance(&instance, false, true) + impl_SrsAutoFree _auto_free_##instance(&instance, false, true, NULL) +// Use hook instead of delete. +#define SrsAutoFreeH(className, instance, hook) \ + impl_SrsAutoFree _auto_free_##instance(&instance, false, false, hook) // The template implementation. template class impl_SrsAutoFree @@ -45,11 +48,16 @@ private: T** ptr; bool is_array; bool _use_free; + void (*_hook)(T*); public: - impl_SrsAutoFree(T** p, bool array, bool use_free) { + // If use_free, use free(void*) to release the p. + // If specified hook, use hook(p) to release it. + // Use delete to release p, or delete[] if p is an array. + impl_SrsAutoFree(T** p, bool array, bool use_free, void (*hook)(T*)) { ptr = p; is_array = array; _use_free = use_free; + _hook = hook; } virtual ~impl_SrsAutoFree() { @@ -59,6 +67,8 @@ public: if (_use_free) { free(*ptr); + } else if (_hook) { + _hook(*ptr); } else { if (is_array) { delete[] *ptr; diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 0999c7ba2..32ef05add 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 225 +#define VERSION_REVISION 226 #endif From 6a5bc27f9bca885969997e4b4fffec79ca2f69b3 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 15:16:54 +0800 Subject: [PATCH 13/18] Support configure with --config as default config file. v4.0.227 --- trunk/conf/lighthouse.conf | 5 ++ trunk/configure | 4 +- trunk/doc/CHANGELOG.md | 2 +- trunk/etc/init.d/srs-api | 127 --------------------------- trunk/scripts/install.sh | 2 +- trunk/src/core/srs_core_version4.hpp | 2 +- 6 files changed, 11 insertions(+), 131 deletions(-) delete mode 100755 trunk/etc/init.d/srs-api diff --git a/trunk/conf/lighthouse.conf b/trunk/conf/lighthouse.conf index 61e5ba5b0..fd363e350 100644 --- a/trunk/conf/lighthouse.conf +++ b/trunk/conf/lighthouse.conf @@ -4,6 +4,11 @@ max_connections 1000; daemon on; srs_log_tank file; +# For LightHouse VM to run SRS, never enable docker. +in_docker off; +disable_daemon_for_docker off; +auto_reload_for_docker off; + http_server { enabled on; listen 8080; diff --git a/trunk/configure b/trunk/configure index be64ac9bf..5c28041be 100755 --- a/trunk/configure +++ b/trunk/configure @@ -463,6 +463,7 @@ CXXFLAGS = ${CXXFLAGS} # install prefix. SRS_PREFIX=${SRS_PREFIX} +SRS_DEFAULT_CONFIG=${SRS_DEFAULT_CONFIG} __REAL_INSTALL=\$(DESTDIR)\$(SRS_PREFIX) default: server @@ -609,11 +610,12 @@ install: @mkdir -p \$(__REAL_INSTALL)/etc/init.d @cp -f etc/init.d/srs \$(__REAL_INSTALL)/etc/init.d @sed -i "s|^ROOT=.*|ROOT=\"\$(SRS_PREFIX)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs + @sed -i "s|^CONFIG=.*|CONFIG=\"\$(SRS_DEFAULT_CONFIG)\"|g" \$(__REAL_INSTALL)/etc/init.d/srs @echo "Now copy systemctl service files" @mkdir -p \$(__REAL_INSTALL)/usr/lib/systemd/system @cp -f usr/lib/systemd/system/srs.service \$(__REAL_INSTALL)/usr/lib/systemd/system/srs.service @echo "" - @echo "@see: https://github.com/ossrs/srs/wiki/v3_CN_LinuxService" + @echo "@see: https://github.com/ossrs/srs/wiki/v4_CN_LinuxService" END diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 1d13b8e55..db13e5838 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,8 +8,8 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2022-01-13, Support configure with --config as default config file. v4.0.227 * v4.0, 2022-01-13, For [#2880](https://github.com/ossrs/srs/pull/2880): Add SrsAutoFreeH to release ptr with hooks. (#2880). v4.0.226 -* v4.0, 2022-01-13, Support api_port to specify the WebRTC API port. v4.0.226 * v4.0, 2022-01-13, Support api_port to specify the WebRTC API port. v4.0.224 * v4.0, 2022-01-13, Merge [#2873](https://github.com/ossrs/srs/pull/2873): LiveSource: Refine fetch for external exposed interface. (#2873). v4.0.223 * v4.0, 2022-01-13, Add conf/lighthouse.conf for LightHouse. v4.0.222 diff --git a/trunk/etc/init.d/srs-api b/trunk/etc/init.d/srs-api deleted file mode 100755 index 64e5413c7..000000000 --- a/trunk/etc/init.d/srs-api +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash - -### BEGIN INIT INFO -# Provides: ossrs-api(srs-api) -# Required-Start: $all -# Required-Stop: $all -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: ossrs-api(srs-api) -# 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="python ./research/api-server/server.py" -CONFIG="8085" - -######################################################################## -# 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-api -# @set variable $srs_api_id to the process id. -# @return 0, if process exists; otherwise: -# 1, for srs-api not exists. -# @set variable $error_msg if error. -load_process_info() { - srs_api_id=`ps aux|grep python|grep research|grep "api-server"|awk '{print $2}'` - if [[ -z $srs_api_id ]]; then error_msg="srs-api process does not exists"; return 1; fi - - return 0; -} - -start() { - # if exists, exit. - load_process_info - if [[ 0 -eq $? ]]; then failed_msg "SRS-api started(pid ${srs_api_id}), should not start it again."; return 0; fi - - # not exists, start server - ok_msg "Starting SRS-api..." - # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000" - # TODO: FIXME: write log to, for instance, the same dir of log. - # TODO: FIXME: support daemon, without nohup. - (cd ${ROOT}; nohup ${APP} ${CONFIG} >/dev/null 2>&1 &) - - # check again after start server - load_process_info - ret=$?; if [[ 0 -eq $? ]]; then ok_msg "SRS-api started(pid ${srs_api_id})"; return 0; fi - - failed_msg "SRS-api not started" - return $ret -} - -stop() { - # not start, exit - load_process_info - if [[ 0 -ne $? ]]; then failed_msg "SRS-api not start."; return 0; fi - - ok_msg "Stopping SRS-api(pid ${srs_api_id})..." - - # process exists, kill util stop - for((;;)); do - load_process_info - if [[ 0 -eq $? ]]; then - kill -s SIGKILL ${srs_api_id} 2>/dev/null - ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGKILL failed ret=$ret"; return $ret; fi - sleep 0.1 - else - ok_msg "SRS-api stopped" - break; - fi - done - - sleep 0.1 - return 0 -} - -# get the status of srs-api process -# @return 0 if srs-api is running; otherwise, 1 for stopped. -status() { - load_process_info - ret=$?; if [[ 0 -eq $ret ]]; then echo "SRS-api(pid ${srs_api_id}) is running."; return 0; fi - - echo "SRS-api is stopped" - return 1 -} - -menu() { - case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - status) - status - ;; - *) - echo "Usage: $0 {start|stop|status|restart}" - return 1 - ;; - esac -} - -menu $1 - -code=$? -exit ${code} diff --git a/trunk/scripts/install.sh b/trunk/scripts/install.sh index 6f161b13f..416c6537d 100755 --- a/trunk/scripts/install.sh +++ b/trunk/scripts/install.sh @@ -129,7 +129,7 @@ else fi echo "" -echo "see: https://github.com/ossrs/srs/wiki/v3_CN_LinuxService" +echo "see: https://github.com/ossrs/srs/wiki/v4_CN_LinuxService" echo "install success, you can start SRS on CentOS6:" echo -e "${GREEN} sudo /etc/init.d/srs start${BLACK}" echo "or CentOS7:" diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 32ef05add..d3c84788e 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 226 +#define VERSION_REVISION 227 #endif From 8830d267f299d8edca255f27d37157483ea8fc7e Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 16:20:03 +0800 Subject: [PATCH 14/18] Refine conf for vm.conf --- trunk/conf/{lighthouse.conf => vm.conf} | 0 trunk/doc/CHANGELOG.md | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename trunk/conf/{lighthouse.conf => vm.conf} (100%) diff --git a/trunk/conf/lighthouse.conf b/trunk/conf/vm.conf similarity index 100% rename from trunk/conf/lighthouse.conf rename to trunk/conf/vm.conf diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index db13e5838..d1652f169 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -12,7 +12,7 @@ The changelog for SRS. * v4.0, 2022-01-13, For [#2880](https://github.com/ossrs/srs/pull/2880): Add SrsAutoFreeH to release ptr with hooks. (#2880). v4.0.226 * v4.0, 2022-01-13, Support api_port to specify the WebRTC API port. v4.0.224 * v4.0, 2022-01-13, Merge [#2873](https://github.com/ossrs/srs/pull/2873): LiveSource: Refine fetch for external exposed interface. (#2873). v4.0.223 -* v4.0, 2022-01-13, Add conf/lighthouse.conf for LightHouse. v4.0.222 +* v4.0, 2022-01-13, Add conf/vm.conf for cloud virtual machine. v4.0.222 * v4.0, 2022-01-12, Refine the running homepage. v4.0.221 * v4.0, 2022-01-12, Merge [#2863](https://github.com/ossrs/srs/pull/2863): RTC: fix play crash or no stream for rtmp2rtc tips. (#2863). v4.0.220 * v4.0, 2022-01-05, For [#2717](https://github.com/ossrs/srs/issues/2717): When reopening segment, never update the duration. (#2717). v4.0.219 From 99ff853de9ed4cfff8c5d6afa67469a49210ae14 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 17:01:57 +0800 Subject: [PATCH 15/18] Refine package variables. v4.0.228 --- .github/workflows/release.yml | 8 ++++++-- trunk/Dockerfile.pkg | 3 --- trunk/src/core/srs_core_version4.hpp | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2e86f11db..9e0185715 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,8 +49,10 @@ jobs: # SRS_PACKAGE_ZIP=SRS-CentOS7-x86_64-4.0.145.zip # SRS_PACKAGE_MD5=3880a26e30b283edf05700a4e69956e5 - name: Create package zip + env: + PACKAGER: ${{ secrets.SRS_PACKAGER_BINARY }} run: | - docker build --tag srs:pkg --build-arg version=$SRS_VERSION -f trunk/Dockerfile.pkg . && + docker build --tag srs:pkg --build-arg version=$SRS_VERSION --build-arg SRS_AUTO_PACKAGER=$PACKAGER -f trunk/Dockerfile.pkg . && SRS_PACKAGE_ZIP=SRS-CentOS7-x86_64-$SRS_VERSION.zip && docker run --rm -v $(pwd):/output srs:pkg cp objs/$SRS_PACKAGE_ZIP /output/ && du -sh $SRS_PACKAGE_ZIP && @@ -72,9 +74,11 @@ jobs: # Build # Build SRS image - name: Build SRS docker image + env: + PACKAGER: ${{ secrets.SRS_PACKAGER_DOCKER }} run: | echo "Release ossrs/srs:$SRS_TAG" - docker build --tag ossrs/srs:$SRS_TAG -f trunk/Dockerfile . + docker build --tag ossrs/srs:$SRS_TAG --build-arg SRS_AUTO_PACKAGER=$PACKAGER -f trunk/Dockerfile . ################################################################ # Docker diff --git a/trunk/Dockerfile.pkg b/trunk/Dockerfile.pkg index ade5778cd..ca6602ef3 100644 --- a/trunk/Dockerfile.pkg +++ b/trunk/Dockerfile.pkg @@ -6,9 +6,6 @@ ARG version # Install depends tools. RUN yum install -y zip -# Setup the packager env. -ENV SRS_AUTO_PACKAGER ossrs - # Build and install SRS. ADD srs-server-${version}.tar.gz /srs WORKDIR /srs/srs-server-${version}/trunk diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index d3c84788e..10978e4cc 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 227 +#define VERSION_REVISION 228 #endif From 584889754c4807fc95b6c0bddb275c9f1a65ca72 Mon Sep 17 00:00:00 2001 From: chundonglinlin Date: Thu, 13 Jan 2022 17:03:03 +0800 Subject: [PATCH 16/18] RTC: fix play rtc judge for config rtc2rtmp on.(#2863) (#2872) --- trunk/src/app/srs_app_rtc_api.cpp | 9 ++++++++- trunk/src/app/srs_app_rtc_source.hpp | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_api.cpp b/trunk/src/app/srs_app_rtc_api.cpp index d72b192e1..38fd28c76 100644 --- a/trunk/src/app/srs_app_rtc_api.cpp +++ b/trunk/src/app/srs_app_rtc_api.cpp @@ -186,8 +186,15 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe server_enabled, rtc_enabled, ruc.req_->vhost.c_str()); } + // Whether RTC stream is active. + bool is_rtc_stream_active = false; + if (true) { + SrsRtcSource* source = _srs_rtc_sources->fetch(ruc.req_); + is_rtc_stream_active = (source && !source->can_publish()); + } + // For RTMP to RTC, fail if disabled and RTMP is active, see https://github.com/ossrs/srs/issues/2728 - if (!_srs_config->get_rtc_from_rtmp(ruc.req_->vhost)) { + if (!is_rtc_stream_active && !_srs_config->get_rtc_from_rtmp(ruc.req_->vhost)) { SrsLiveSource* rtmp = _srs_sources->fetch(ruc.req_); if (rtmp && !rtmp->inactive()) { return srs_error_new(ERROR_RTC_DISABLED, "Disabled rtmp_to_rtc of %s, see #2728", ruc.req_->vhost.c_str()); diff --git a/trunk/src/app/srs_app_rtc_source.hpp b/trunk/src/app/srs_app_rtc_source.hpp index 1b9555a04..c4095946d 100644 --- a/trunk/src/app/srs_app_rtc_source.hpp +++ b/trunk/src/app/srs_app_rtc_source.hpp @@ -112,7 +112,7 @@ public: // @param r the client request. // @param pps the matched source, if success never be NULL. virtual srs_error_t fetch_or_create(SrsRequest* r, SrsRtcSource** pps); -private: +public: // Get the exists source, NULL when not exists. virtual SrsRtcSource* fetch(SrsRequest* r); }; From 7796083e9a6a5f9b5c9aa550b4146a1381ef4a2f Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 17:04:50 +0800 Subject: [PATCH 17/18] RTC: fix play rtc judge for config rtc2rtmp on. (#2872). v4.0.229 --- trunk/doc/CHANGELOG.md | 1 + trunk/src/core/srs_core_version4.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index d1652f169..00c838483 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, 2022-01-13, Merge [#2872](https://github.com/ossrs/srs/pull/2872): RTC: fix play rtc judge for config rtc2rtmp on. (#2872). v4.0.229 * v4.0, 2022-01-13, Support configure with --config as default config file. v4.0.227 * v4.0, 2022-01-13, For [#2880](https://github.com/ossrs/srs/pull/2880): Add SrsAutoFreeH to release ptr with hooks. (#2880). v4.0.226 * v4.0, 2022-01-13, Support api_port to specify the WebRTC API port. v4.0.224 diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 10978e4cc..32d01f087 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 228 +#define VERSION_REVISION 229 #endif From 0dd6246c2fcacc7650b5b7615a077c1ceb0ea9d2 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 13 Jan 2022 17:08:01 +0800 Subject: [PATCH 18/18] Release v4.0-b3, 4.0 beta3, v4.0.229, 144393 lines. --- README.md | 1 + trunk/Dockerfile | 2 ++ trunk/Dockerfile.pkg | 1 + trunk/src/main/srs_main_server.cpp | 4 ++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 32b84ddce..fb93a0684 100755 --- a/README.md +++ b/README.md @@ -130,6 +130,7 @@ A big THANK YOU goes to: ## Releases +* 2022-01-13, Release [v4.0-b3](https://github.com/ossrs/srs/releases/tag/v4.0-b3), v4.0-b3, 4.0 beta3, v4.0.229, 144393 lines. * 2022-01-03, Release [v4.0-b2](https://github.com/ossrs/srs/releases/tag/v4.0-b2), v4.0-b2, 4.0 beta2, v4.0.215, 144278 lines. * 2021-12-19, Release [v4.0-b1](https://github.com/ossrs/srs/releases/tag/v4.0-b1), v4.0-b1, 4.0 beta1, v4.0.206, 144126 lines. * 2021-12-01, Release [v4.0-b0](https://github.com/ossrs/srs/releases/tag/v4.0-b0), v4.0-b0, 4.0 beta0, v4.0.201, 144022 lines. diff --git a/trunk/Dockerfile b/trunk/Dockerfile index bd37ef08c..922cf2eed 100644 --- a/trunk/Dockerfile +++ b/trunk/Dockerfile @@ -3,6 +3,8 @@ FROM ossrs/srs:dev AS build # Install depends tools. RUN yum install -y gcc make gcc-c++ patch unzip perl git +ARG SRS_AUTO_PACKAGER + # Build and install SRS. COPY . /srs WORKDIR /srs/trunk diff --git a/trunk/Dockerfile.pkg b/trunk/Dockerfile.pkg index ca6602ef3..1fb3d600a 100644 --- a/trunk/Dockerfile.pkg +++ b/trunk/Dockerfile.pkg @@ -2,6 +2,7 @@ FROM ossrs/srs:dev # version=4.0.145 ARG version +ARG SRS_AUTO_PACKAGER # Install depends tools. RUN yum install -y zip diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 46465c62d..c45bcf5ea 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -127,8 +127,8 @@ srs_error_t do_main(int argc, char** argv) srs_trace2(TAG_MAIN, "%s, %s", RTMP_SIG_SRS_SERVER, RTMP_SIG_SRS_LICENSE); srs_trace("authors: %s", RTMP_SIG_SRS_AUTHORS); srs_trace("contributors: %s", SRS_CONSTRIBUTORS); - srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d", - _srs_config->cwd().c_str(), cwd.c_str(), SRS_BUILD_DATE, SRS_USER_CONFIGURE, SRS_UNAME, SRS_OSX_BOOL); + srs_trace("cwd=%s, work_dir=%s, build: %s, configure: %s, uname: %s, osx: %d, pkg: %s", + _srs_config->cwd().c_str(), cwd.c_str(), SRS_BUILD_DATE, SRS_USER_CONFIGURE, SRS_UNAME, SRS_OSX_BOOL, SRS_PACKAGER); srs_trace("configure detail: " SRS_CONFIGURE); #ifdef SRS_EMBEDED_TOOL_CHAIN srs_trace("crossbuild tool chain: " SRS_EMBEDED_TOOL_CHAIN);