From 8db2c3d8211751f166b21731e05b0d97456879a8 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 16 Mar 2020 11:39:20 +0800 Subject: [PATCH 01/13] For #1635, refine inotify watch for relative path --- trunk/src/kernel/srs_kernel_utility.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 861be3610..5fe03a129 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -652,15 +652,20 @@ bool srs_path_exists(std::string path) string srs_path_dirname(string path) { std::string dirname = path; + + // No slash, it must be current dir. size_t pos = string::npos; - - if ((pos = dirname.rfind("/")) != string::npos) { - if (pos == 0) { - return "/"; - } - dirname = dirname.substr(0, pos); + if ((pos = dirname.rfind("/")) == string::npos) { + return "./"; } - + + // Path under root. + if (pos == 0) { + return "/"; + } + + // Fetch the directory. + dirname = dirname.substr(0, pos); return dirname; } From a8ddd5afe7e87dddf5119e18df38b64ba00e51e6 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 16 Mar 2020 11:52:31 +0800 Subject: [PATCH 02/13] For #1635, refine inotify watch for relative path --- trunk/src/utest/srs_utest_kernel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk/src/utest/srs_utest_kernel.cpp b/trunk/src/utest/srs_utest_kernel.cpp index f0270f9b6..acfdeeff0 100644 --- a/trunk/src/utest/srs_utest_kernel.cpp +++ b/trunk/src/utest/srs_utest_kernel.cpp @@ -2565,7 +2565,7 @@ VOID TEST(KernelUtility, BytesUtils) VOID TEST(KernelUtility, PathUtils) { if (true) { - EXPECT_TRUE("" == srs_path_dirname("")); + EXPECT_TRUE("./" == srs_path_dirname("")); EXPECT_TRUE("/" == srs_path_dirname("/")); EXPECT_TRUE("/" == srs_path_dirname("//")); EXPECT_TRUE("/" == srs_path_dirname("/stream")); From 9ba861f42fcd95d3db15bd3bcc6263566cbefb29 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 16 Mar 2020 15:11:34 +0800 Subject: [PATCH 03/13] 3.0release is beta now --- trunk/src/main/srs_main_server.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index 5ded5d40a..603e0f1e2 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -331,8 +331,8 @@ void show_macro_features() #endif #if VERSION_MAJOR > VERSION_STABLE -#warning "Current branch is unstable." - srs_warn("Develop is unstable, please use branch: git checkout -b %s origin/%s", VERSION_STABLE_BRANCH, VERSION_STABLE_BRANCH); + #warning "Current branch is beta." + srs_warn("%s/%s is beta", RTMP_SIG_SRS_KEY, RTMP_SIG_SRS_VERSION); #endif #if defined(SRS_PERF_SO_SNDBUF_SIZE) && !defined(SRS_PERF_MW_SO_SNDBUF) From aead1a5b74f75fc4f9d1db0b7041f6582c43397e Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 18 Mar 2020 16:33:08 +0800 Subject: [PATCH 04/13] Release 3.0.134, 3.0-b3 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3ab704f65..962d715db 100755 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ For previous versions, please read: ## V3 changes +* v3.0, 2020-03-18, [3.0 beta3(3.0.134)][r3.0b3] released. 122509 lines. * v3.0, 2020-03-12, For [#1635][bug #1635], inotify watch ConfigMap for reload. 3.0.134 * v3.0, 2020-03-12, For [#1635][bug #1635], support auto reaload config by inotify. 3.0.129 * v3.0, 2020-03-12, For [#1630][bug #1630], disable cache for stream changing, and drop dup header. 3.0.128 @@ -752,6 +753,7 @@ For previous versions, please read: ## Releases +* 2020-03-18, [Release v3.0-b3][r3.0b3], 3.0 beta3, 3.0.134, 122509 lines. * 2020-03-05, [Release v3.0-b2][r3.0b2], 3.0 beta2, 3.0.123, 122170 lines. * 2020-02-14, [Release v3.0-b1][r3.0b1], 3.0 beta1, 3.0.117, 121964 lines. * 2020-02-02, [Release v3.0-b0][r3.0b0], 3.0 beta0, 3.0.112, 121709 lines. @@ -1674,6 +1676,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r3.0b3]: https://github.com/ossrs/srs/releases/tag/v3.0-b3 [r3.0b2]: https://github.com/ossrs/srs/releases/tag/v3.0-b2 [r3.0b1]: https://github.com/ossrs/srs/releases/tag/v3.0-b1 [r3.0b0]: https://github.com/ossrs/srs/releases/tag/v3.0-b0 From 83f743645b69cb3bb33fb80b0929e37b187fed0a Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 19 Mar 2020 17:49:37 +0800 Subject: [PATCH 05/13] Release multiple processes for SRS by reuseport --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 962d715db..780a103a8 100755 --- a/README.md +++ b/README.md @@ -853,7 +853,7 @@ Comparing with other media servers, SRS is much better and stronger, for details | Feature | SRS | NGINX | CRTMPD | AMS | WOWZA | | ----------- | ------- | ----- | --------- | -------- | ------ | | Concurrency | 7.5k | 3k | 2k | 2k | 3k | -|MultipleProcess| Experiment| Stable | X | X | X | +|MultipleProcess| [Stable][v3_CN_ReusePort] | Stable | X | X | X | | RTMP Latency| 0.1s | 3s | 3s | 3s | 3s | | HLS Latency | 10s | 30s | X | 30s | 30s | @@ -1355,6 +1355,8 @@ Winlin [v3_CN_LowLatency#merged-write]: https://github.com/ossrs/srs/wiki/v3_CN_LowLatency#merged-write [v3_CN_NgExec]:https://github.com/ossrs/srs/wiki/v3_CN_NgExec [v3_EN_NgExec]:https://github.com/ossrs/srs/wiki/v3_EN_NgExec +[v3_CN_ReusePort]:https://github.com/ossrs/srs/wiki/v3_CN_ReusePort +[v3_EN_ReusePort]:https://github.com/ossrs/srs/wiki/v3_EN_ReusePort [bug #213]: https://github.com/ossrs/srs/issues/213 [bug #194]: https://github.com/ossrs/srs/issues/194 From 737e4bc32da79be5b256d52261d3fdc5e1a1cfe9 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 19 Mar 2020 17:57:23 +0800 Subject: [PATCH 06/13] Update --- README.md | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 780a103a8..fd4dcfafb 100755 --- a/README.md +++ b/README.md @@ -916,18 +916,18 @@ The data for playing RTMP was benchmarked by [SB][srs-bench]: | Update | SRS | Clients | Type | CPU | Memory | Commit | | ------------- | --------- | ------------- | ------------- | --------- | -------- | ------------ | -| 2013-11-28 | 0.5.0 | 1.8k(1800) | players | 90% | 41M | - | -| 2014-07-12 | 0.9.156 | 1.8k(1800) | players | 68% | 38MB | - | -| 2014-07-12 | 0.9.156 | 2.7k(2700) | players | 89% | 61MB | [code][p6] | -| 2014-11-11 | 1.0.5 | 2.7k(2700) | players | 85% | 66MB | - | -| 2014-11-11 | 2.0.12 | 2.7k(2700) | players | 85% | 66MB | - | -| 2014-11-12 | 2.0.14 | 2.7k(2700) | players | 69% | 59MB | - | -| 2014-11-12 | 2.0.14 | 3.5k(3500) | players | 95% | 78MB | [code][p7] | -| 2014-11-13 | 2.0.15 | 6.0k(6000) | players | 82% | 203MB | [code][p8] | -| 2014-11-22 | 2.0.30 | 7.5k(7500) | players | 87% | 320MB | [code][p9] | -| 2014-12-05 | 2.0.55 | 8.0k(8000) | players | 89% | 360MB | [code][p10] | -| 2014-12-05 | 2.0.57 | 9.0k(9000) | players | 90% | 468MB | [code][p11] | | 2014-12-07 | 2.0.67 | 10k(10000) | players | 95% | 656MB | [code][p12] | +| 2014-12-05 | 2.0.57 | 9.0k(9000) | players | 90% | 468MB | [code][p11] | +| 2014-12-05 | 2.0.55 | 8.0k(8000) | players | 89% | 360MB | [code][p10] | +| 2014-11-22 | 2.0.30 | 7.5k(7500) | players | 87% | 320MB | [code][p9] | +| 2014-11-13 | 2.0.15 | 6.0k(6000) | players | 82% | 203MB | [code][p8] | +| 2014-11-12 | 2.0.14 | 3.5k(3500) | players | 95% | 78MB | [code][p7] | +| 2014-11-12 | 2.0.14 | 2.7k(2700) | players | 69% | 59MB | - | +| 2014-11-11 | 2.0.12 | 2.7k(2700) | players | 85% | 66MB | - | +| 2014-11-11 | 1.0.5 | 2.7k(2700) | players | 85% | 66MB | - | +| 2014-07-12 | 0.9.156 | 2.7k(2700) | players | 89% | 61MB | [code][p6] | +| 2014-07-12 | 0.9.156 | 1.8k(1800) | players | 68% | 38MB | - | +| 2013-11-28 | 0.5.0 | 1.8k(1800) | players | 90% | 41M | - | **Publish RTMP benchmark** @@ -936,15 +936,15 @@ The data for publishing RTMP was benchmarked by [SB][srs-bench]: | Update | SRS | Clients | Type | CPU | Memory | Commit | | ------------- | --------- | ------------- | ------------- | --------- | -------- | ------------ | -| 2014-12-03 | 1.0.10 | 1.2k(1200) | publishers | 96% | 43MB | - | -| 2014-12-03 | 2.0.12 | 1.2k(1200) | publishers | 96% | 43MB | - | -| 2014-12-03 | 2.0.47 | 1.2k(1200) | publishers | 84% | 76MB | [code][p1] | -| 2014-12-03 | 2.0.47 | 1.4k(1400) | publishers | 95% | 140MB | - | -| 2014-12-03 | 2.0.48 | 1.4k(1400) | publishers | 95% | 140MB | [code][p2] | -| 2014-12-04 | 2.0.49 | 1.4k(1400) | publishers | 68% | 144MB | - | -| 2014-12-04 | 2.0.49 | 2.5k(2500) | publishers | 95% | 404MB | [code][p3] | -| 2014-12-04 | 2.0.51 | 2.5k(2500) | publishers | 91% | 259MB | [code][p4] | | 2014-12-04 | 2.0.52 | 4.0k(4000) | publishers | 80% | 331MB | [code][p5] | +| 2014-12-04 | 2.0.51 | 2.5k(2500) | publishers | 91% | 259MB | [code][p4] | +| 2014-12-04 | 2.0.49 | 2.5k(2500) | publishers | 95% | 404MB | [code][p3] | +| 2014-12-04 | 2.0.49 | 1.4k(1400) | publishers | 68% | 144MB | - | +| 2014-12-03 | 2.0.48 | 1.4k(1400) | publishers | 95% | 140MB | [code][p2] | +| 2014-12-03 | 2.0.47 | 1.4k(1400) | publishers | 95% | 140MB | - | +| 2014-12-03 | 2.0.47 | 1.2k(1200) | publishers | 84% | 76MB | [code][p1] | +| 2014-12-03 | 2.0.12 | 1.2k(1200) | publishers | 96% | 43MB | - | +| 2014-12-03 | 1.0.10 | 1.2k(1200) | publishers | 96% | 43MB | - | **Play HTTP FLV benchmark** @@ -954,11 +954,11 @@ The data for playing HTTP FLV was benchmarked by [SB][srs-bench]: | Update | SRS | Clients | Type | CPU | Memory | Commit | | ------------- | --------- | ------------- | ------------- | --------- | -------- | ------------ | -| 2014-05-24 | 2.0.167 | 1.0k(1000) | players | 82% | 86MB | - | -| 2014-05-24 | 2.0.168 | 2.3k(2300) | players | 92% | 276MB | [code][p17] | -| 2014-05-24 | 2.0.169 | 3.0k(3000) | players | 94% | 188MB | [code][p18] | -| 2014-05-24 | 2.0.170 | 3.0k(3000) | players | 89% | 96MB | [code][p19] | | 2014-05-25 | 2.0.171 | 6.0k(6000) | players | 84% | 297MB | [code][p20] | +| 2014-05-24 | 2.0.170 | 3.0k(3000) | players | 89% | 96MB | [code][p19] | +| 2014-05-24 | 2.0.169 | 3.0k(3000) | players | 94% | 188MB | [code][p18] | +| 2014-05-24 | 2.0.168 | 2.3k(2300) | players | 92% | 276MB | [code][p17] | +| 2014-05-24 | 2.0.167 | 1.0k(1000) | players | 82% | 86MB | - | **Latency benchmark** @@ -968,9 +968,9 @@ The latency between encoder and player with realtime config([CN][v3_CN_LowLatenc | Update | SRS | VP6 | H.264 | VP6+MP3 | H.264+MP3 | | ------------- | --------- | --------- | --------- | --------- | -------- | -| 2014-12-03 | 1.0.10 | 0.4s | 0.4s | 0.9s | 1.2s | -| 2014-12-12 | 2.0.70 |[0.1s][p13]|[0.4s][p14]| 1.0s | 0.9s | | 2014-12-16 | 2.0.72 | 0.1s | 0.4s |[0.8s][p15]|[0.6s][p16]| +| 2014-12-12 | 2.0.70 |[0.1s][p13]|[0.4s][p14]| 1.0s | 0.9s | +| 2014-12-03 | 1.0.10 | 0.4s | 0.4s | 0.9s | 1.2s | > 2018-08-05, [c45f72e](https://github.com/ossrs/srs/commit/c45f72ef7bac9c7cf85b9125fc9e3aafd53f396f), Refine HTTP-FLV latency, support realtime mode. 2.0.252 From 2911c814c413cf16c1413970aedcbeb85879cebd Mon Sep 17 00:00:00 2001 From: yanghuiwen Date: Fri, 20 Mar 2020 17:07:16 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E6=9B=B4=E6=96=B0CMakeLists.txt=E6=96=87?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E4=BD=BF=E9=A1=B9=E7=9B=AE=E8=83=BD=E5=9C=A8?= =?UTF-8?q?clion=E7=BC=96=E8=AF=91=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/ide/srs_clion/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/trunk/ide/srs_clion/CMakeLists.txt b/trunk/ide/srs_clion/CMakeLists.txt index 453e81e9b..ed2734e1d 100755 --- a/trunk/ide/srs_clion/CMakeLists.txt +++ b/trunk/ide/srs_clion/CMakeLists.txt @@ -1,15 +1,17 @@ cmake_minimum_required(VERSION 2.6.4) project(srs CXX) -INCLUDE_DIRECTORIES(../../objs - ../../objs/st ../../objs/hp ../../objs/openssl/include - ../../src/core ../../src/kernel ../../src/protocol ../../src/app) +INCLUDE_DIRECTORIES(../../objs + ../../objs/st ../../objs/hp ../../objs/openssl/include + ../../src/core ../../src/kernel ../../src/protocol ../../src/app + ../../src/service) set(SOURCE_FILES ../../src/main/srs_main_server.cpp) AUX_SOURCE_DIRECTORY(../../src/core SOURCE_FILES) AUX_SOURCE_DIRECTORY(../../src/kernel SOURCE_FILES) AUX_SOURCE_DIRECTORY(../../src/protocol SOURCE_FILES) AUX_SOURCE_DIRECTORY(../../src/app SOURCE_FILES) +AUX_SOURCE_DIRECTORY(../../src/service SOURCE_FILES) ADD_DEFINITIONS("-g -O0") @@ -18,7 +20,6 @@ TARGET_LINK_LIBRARIES(srs dl) TARGET_LINK_LIBRARIES(srs ${PROJECT_SOURCE_DIR}/../../objs/st/libst.a) TARGET_LINK_LIBRARIES(srs ${PROJECT_SOURCE_DIR}/../../objs/openssl/lib/libssl.a) TARGET_LINK_LIBRARIES(srs ${PROJECT_SOURCE_DIR}/../../objs/openssl/lib/libcrypto.a) -TARGET_LINK_LIBRARIES(srs ${PROJECT_SOURCE_DIR}/../../objs/hp/libhttp_parser.a) TARGET_LINK_LIBRARIES(srs -ldl) IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/../../objs/st/libst.a) From 5a55cff7ba440eb238a8a2999f813c1c1e5dc599 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 21 Mar 2020 16:30:29 +0800 Subject: [PATCH 08/13] Update mirror --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fd4dcfafb..cde53ea3f 100755 --- a/README.md +++ b/README.md @@ -1121,23 +1121,25 @@ A big THANK YOU goes to: OSChina: [https://gitee.com/winlinvip/srs.oschina][oschina], the GIT usage([CN][v1_CN_Git], [EN][v1_EN_Git]) ``` -git clone https://gitee.com/winlinvip/srs.oschina.git +git clone https://gitee.com/winlinvip/srs.oschina.git srs && +cd srs && git remote set-url origin https://github.com/ossrs/srs.git && git pull ``` > Remark: For users in China, recomment to use mirror from CSDN or OSChina, because they are much faster. +Gitlab: [https://gitlab.com/winlinvip/srs-gitlab][gitlab], the GIT usage([CN][v1_CN_Git], [EN][v1_EN_Git]) + +``` +git clone https://gitlab.com/winlinvip/srs-gitlab.git srs && +cd srs && git remote set-url origin https://github.com/ossrs/srs.git && git pull +``` + Github: [https://github.com/ossrs/srs][srs], the GIT usage([CN][v1_CN_Git], [EN][v1_EN_Git]) ``` git clone https://github.com/ossrs/srs.git ``` -Gitlab: [https://gitlab.com/winlinvip/srs-gitlab][gitlab], the GIT usage([CN][v1_CN_Git], [EN][v1_EN_Git]) - -``` -git clone https://gitlab.com/winlinvip/srs-gitlab.git -``` - | Branch | Cost | Size | CMD | | --- | --- | --- | --- | | 3.0release | 2m19.931s | 262MB | git clone -b 3.0release https://gitee.com/winlinvip/srs.oschina.git | From 75f62dc653465c4f474fe77619b6a9c59de75adb Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 21 Mar 2020 16:34:18 +0800 Subject: [PATCH 09/13] Update mirror --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cde53ea3f..b56e9edaf 100755 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ SRS is a RTMP/HLS/WebRTC/SRT/GB28181 streaming cluster, high efficiency, stable **Step 1:** Get SRS. ``` -git clone https://github.com/ossrs/srs && -cd srs/trunk +git clone https://gitee.com/winlinvip/srs.oschina.git srs && +cd srs/trunk && git remote set-url origin https://github.com/ossrs/srs.git && git pull ``` > Note: Repository too large? Please clone from these [mirrors](#mirrors) instead. From 734e8487410e2e22e2a88bbb912f341aba4ac5c8 Mon Sep 17 00:00:00 2001 From: xiaozhihong Date: Sun, 22 Mar 2020 16:54:31 +0800 Subject: [PATCH 10/13] Update RtcSession peer address when changed. --- trunk/src/app/srs_app_listener.cpp | 26 ++++++++++++-------------- trunk/src/app/srs_app_listener.hpp | 9 ++++++--- trunk/src/app/srs_app_rtc_conn.cpp | 22 +++++++++++++++++++--- trunk/src/app/srs_app_rtc_conn.hpp | 5 ++++- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/trunk/src/app/srs_app_listener.cpp b/trunk/src/app/srs_app_listener.cpp index 667dd5036..00a9d7560 100755 --- a/trunk/src/app/srs_app_listener.cpp +++ b/trunk/src/app/srs_app_listener.cpp @@ -237,23 +237,21 @@ SrsUdpMuxSocket::~SrsUdpMuxSocket() srs_freepa(buf); } -SrsUdpMuxSocket::SrsUdpMuxSocket(const SrsUdpMuxSocket& rhs) +SrsUdpMuxSocket* SrsUdpMuxSocket::copy_sendonly() { - operator=(rhs); -} + SrsUdpMuxSocket* sendonly = new SrsUdpMuxSocket(lfd); -SrsUdpMuxSocket& SrsUdpMuxSocket::operator=(const SrsUdpMuxSocket& rhs) -{ - buf = NULL; - nb_buf = 0; - nread = 0; - lfd = rhs.lfd; - from = rhs.from; - fromlen = rhs.fromlen; - peer_ip = rhs.peer_ip; - peer_port = rhs.peer_port; + // Don't copy buffer + srs_freepa(sendonly->buf); + sendonly->nb_buf = 0; + sendonly->nread = 0; + sendonly->lfd = lfd; + sendonly->from = from; + sendonly->fromlen = fromlen; + sendonly->peer_ip = peer_ip; + sendonly->peer_port = peer_port; - return *this; + return sendonly; } int SrsUdpMuxSocket::recvfrom(srs_utime_t timeout) diff --git a/trunk/src/app/srs_app_listener.hpp b/trunk/src/app/srs_app_listener.hpp index 1a73b6faf..75aea4c52 100644 --- a/trunk/src/app/srs_app_listener.hpp +++ b/trunk/src/app/srs_app_listener.hpp @@ -143,9 +143,6 @@ public: SrsUdpMuxSocket(srs_netfd_t fd); virtual ~SrsUdpMuxSocket(); - SrsUdpMuxSocket(const SrsUdpMuxSocket& rhs); - SrsUdpMuxSocket& operator=(const SrsUdpMuxSocket& rhs); - int recvfrom(srs_utime_t timeout); srs_error_t sendto(void* data, int size, srs_utime_t timeout); @@ -154,6 +151,12 @@ public: std::string get_peer_ip() const { return peer_ip; } int get_peer_port() const { return peer_port; } std::string get_peer_id(); +public: + SrsUdpMuxSocket* copy_sendonly(); +private: + // Don't allow copy, user copy_sendonly instead + SrsUdpMuxSocket(const SrsUdpMuxSocket& rhs); + SrsUdpMuxSocket& operator=(const SrsUdpMuxSocket& rhs); }; class SrsUdpMuxListener : public ISrsCoroutineHandler diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 77de89bd6..da08a5cf3 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -605,18 +605,19 @@ srs_error_t SrsDtlsSession::unprotect_rtcp(char* out_buf, const char* in_buf, in } SrsRtcSenderThread::SrsRtcSenderThread(SrsRtcSession* s, SrsUdpMuxSocket* u, int parent_cid) - : ukt(NULL) + : sendonly_ukt(NULL) { _parent_cid = parent_cid; trd = new SrsDummyCoroutine(); rtc_session = s; - ukt = *u; + sendonly_ukt = u->copy_sendonly(); } SrsRtcSenderThread::~SrsRtcSenderThread() { srs_freep(trd); + srs_freep(sendonly_ukt); } int SrsRtcSenderThread::cid() @@ -695,10 +696,19 @@ srs_error_t SrsRtcSenderThread::cycle() continue; } - send_and_free_messages(msgs.msgs, msg_count, &ukt); + send_and_free_messages(msgs.msgs, msg_count, sendonly_ukt); } } +void SrsRtcSenderThread::update_sendonly_socket(SrsUdpMuxSocket* ukt) +{ + srs_trace("session %s address changed, update %s -> %s", + rtc_session->id().c_str(), sendonly_ukt->get_peer_id().c_str(), ukt->get_peer_id().c_str()); + + srs_freep(sendonly_ukt); + sendonly_ukt = ukt->copy_sendonly(); +} + void SrsRtcSenderThread::send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, SrsUdpMuxSocket* udp_mux_skt) { srs_error_t err = srs_success; @@ -776,6 +786,12 @@ srs_error_t SrsRtcSession::on_stun(SrsUdpMuxSocket* udp_mux_skt, SrsStunPacket* last_stun_time = srs_get_system_time(); + if (strd && strd->sendonly_ukt) { + if (strd->sendonly_ukt->get_peer_id() != udp_mux_skt->get_peer_id()) { + strd->update_sendonly_socket(udp_mux_skt); + } + } + return err; } diff --git a/trunk/src/app/srs_app_rtc_conn.hpp b/trunk/src/app/srs_app_rtc_conn.hpp index 029c8d4ab..aaf0cbe62 100644 --- a/trunk/src/app/srs_app_rtc_conn.hpp +++ b/trunk/src/app/srs_app_rtc_conn.hpp @@ -165,7 +165,8 @@ protected: int _parent_cid; private: SrsRtcSession* rtc_session; - SrsUdpMuxSocket ukt; +public: + SrsUdpMuxSocket* sendonly_ukt; public: SrsRtcSenderThread(SrsRtcSession* s, SrsUdpMuxSocket* u, int parent_cid); virtual ~SrsRtcSenderThread(); @@ -177,6 +178,8 @@ public: virtual void stop_loop(); public: virtual srs_error_t cycle(); +public: + void update_sendonly_socket(SrsUdpMuxSocket* ukt); private: void send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, SrsUdpMuxSocket* udp_mux_skt); }; From 2f4ccc27f673499877d96c829e47a61d59df0d83 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 22 Mar 2020 18:59:43 +0800 Subject: [PATCH 11/13] Update authors --- AUTHORS.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/AUTHORS.txt b/AUTHORS.txt index 37935bc9a..e992742ce 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -58,4 +58,6 @@ CONTRIBUTORS ordered by first contribution. * XiaLixin * xiaozhihong * HuyaJohn +* yanghuiwen +* Bepartofyou From 41acc5033e2d4c4af3b2d3ba0446ed652fb5ab26 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 22 Mar 2020 19:26:26 +0800 Subject: [PATCH 12/13] For #307, support disable asm for FFMPEG --- .../ffmpeg-4.2-fit/libavutil/avconfig.h | 2 +- trunk/auto/depends.sh | 18 ++++++++++++------ trunk/auto/options.sh | 6 ++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h b/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h index c289fbb55..8558b3502 100644 --- a/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h +++ b/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h @@ -2,5 +2,5 @@ #ifndef AVUTIL_AVCONFIG_H #define AVUTIL_AVCONFIG_H #define AV_HAVE_BIGENDIAN 0 -#define AV_HAVE_FAST_UNALIGNED 1 +#define AV_HAVE_FAST_UNALIGNED 0 #endif /* AVUTIL_AVCONFIG_H */ diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 81e6f1f4b..870bb8f51 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -84,11 +84,13 @@ function Ubuntu_prepare() echo "The unzip is installed." fi - nasm -v >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing nasm." - require_sudoer "sudo apt-get install -y --force-yes nasm" - sudo apt-get install -y --force-yes nasm; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The nasm is installed." + if [[ $SRS_NASM == YES ]]; then + nasm -v >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then + echo "Installing nasm." + require_sudoer "sudo apt-get install -y --force-yes nasm" + sudo apt-get install -y --force-yes nasm; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi + echo "The nasm is installed." + fi fi if [[ $SRS_VALGRIND == YES ]]; then @@ -420,6 +422,10 @@ fi # ffmpeg-fix, for WebRTC to transcode AAC with Opus. ##################################################################################### if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then + FFMPEG_OPTIONS="" + if [[ $SRS_NASM == NO ]]; then + FFMPEG_OPTIONS="--disable-asm --disable-x86asm --disable-inline-asm" + fi if [[ -f ${SRS_OBJS}/ffmpeg/lib/libavcodec.a ]]; then echo "The ffmpeg-4.2-fit is ok."; else @@ -429,7 +435,7 @@ if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then ln -sf ../3rdparty/ffmpeg-4.2-fit && cd ffmpeg-4.2-fit && PKG_CONFIG_PATH=$ABS_OBJS/opus/lib/pkgconfig ./configure \ --prefix=`pwd`/_release \ - --pkg-config-flags="--static" --extra-libs=-lpthread --extra-libs=-lm \ + --pkg-config-flags="--static" --extra-libs=-lpthread --extra-libs=-lm ${FFMPEG_OPTIONS} \ --disable-programs --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages \ --disable-avdevice --disable-avformat --disable-swscale --disable-postproc --disable-avfilter --disable-network \ --disable-dct --disable-dwt --disable-error-resilience --disable-lsp --disable-lzo --disable-faan --disable-pixelutils \ diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 3f142b4a8..97de92ec2 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -18,6 +18,7 @@ help=no SRS_HDS=NO SRS_SRT=NO SRS_RTC=YES +SRS_NASM=YES SRS_NGINX=NO SRS_FFMPEG_TOOL=NO SRS_LIBRTMP=NO @@ -179,6 +180,8 @@ Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuec --ld= Use linker tool LD, default is ld. --randlib= Use randlib tool RANDLIB, default is randlib. --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS. + --with-nasm Build FFMPEG for RTC with nasm support. + --without-nasm Build FFMPEG for RTC without nasm support, for CentOS6 nasm is too old. Conflicts: 1. --with-gmc vs --with-gmp: @@ -229,6 +232,7 @@ function parse_user_option() { --with-utest) SRS_UTEST=YES ;; --with-srt) SRS_SRT=YES ;; --with-rtc) SRS_RTC=YES ;; + --with-nasm) SRS_NASM=YES ;; --with-gperf) SRS_GPERF=YES ;; --with-gmc) SRS_GPERF_MC=YES ;; --with-gmd) SRS_GPERF_MD=YES ;; @@ -246,6 +250,7 @@ function parse_user_option() { --without-utest) SRS_UTEST=NO ;; --without-srt) SRS_SRT=NO ;; --without-rtc) SRS_RTC=NO ;; + --without-nasm) SRS_NASM=NO ;; --without-gperf) SRS_GPERF=NO ;; --without-gmc) SRS_GPERF_MC=NO ;; --without-gmd) SRS_GPERF_MD=NO ;; @@ -545,6 +550,7 @@ function regenerate_options() { if [ $SRS_UTEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-utest"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-utest"; fi if [ $SRS_SRT = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-srt"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-srt"; fi if [ $SRS_RTC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-rtc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-rtc"; fi + if [ $SRS_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-nasm"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-nasm"; fi if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gperf"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gperf"; fi if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmc"; fi if [ $SRS_GPERF_MD = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmd"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmd"; fi From e5e2d05da01967a3fdb537f3799c504526edb002 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 22 Mar 2020 19:46:56 +0800 Subject: [PATCH 13/13] For #307, support play with WebRTC. 4.0.14 --- README.md | 1 + trunk/auto/depends.sh | 2 +- trunk/configure | 4 ++++ trunk/src/core/srs_core.hpp | 5 +++++ trunk/src/core/srs_core_version4.hpp | 2 +- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e67fc5f1c..7f4d9fe70 100755 --- a/README.md +++ b/README.md @@ -153,6 +153,7 @@ For previous versions, please read: ## V4 changes +* v4.0, 2020-03-22, For [#307][bug #307], support play with WebRTC. 4.0.14 * v4.0, 2020-03-13, For [#1636][bug #1636], fix bug for mux AAC to ADTS, never overwrite by RTMP sampling rate. 4.0.13 * v4.0, 2020-03-07, For [#1612][bug #1612], fix crash bug for RTSP. 4.0.12 * v4.0, 2020-03-07, For [#1631][bug #1631], support sei_filter for SRT. 4.0.11 diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 870bb8f51..36cc3a40d 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -443,7 +443,7 @@ if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then --disable-avfoundation --disable-securetransport --disable-iconv --disable-lzma --disable-sdl2 --disable-everything \ --enable-decoder=aac --enable-decoder=aac_fixed --enable-decoder=aac_latm --enable-decoder=libopus --enable-encoder=aac \ --enable-encoder=opus --enable-encoder=libopus --enable-libopus && - make ${SRS_JOBS} && make install + make ${SRS_JOBS} && make install && cd .. && rm -rf ffmpeg && ln -sf ffmpeg-4.2-fit/_release ffmpeg ) fi diff --git a/trunk/configure b/trunk/configure index 30757bdc3..3b07b394c 100755 --- a/trunk/configure +++ b/trunk/configure @@ -192,6 +192,10 @@ fi if [[ $SRS_GCOV == YES ]]; then SrsLinkOptions="${SrsLinkOptions} ${SrsGcov}"; fi +# For FFMPEG/RTC. +if [[ $SRS_RTC == YES && $SRS_NASM == NO ]]; then + SrsLinkOptions="${SrsLinkOptions} -lrt"; +fi ##################################################################################### # Modules, compile each module, then link to binary diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 3f76b2513..edf2003ab 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -62,6 +62,11 @@ #define __STDC_FORMAT_MACROS #endif +// For RTC/FFMPEG build. +#if defined(SRS_AUTO_RTC) && !defined(__STDC_CONSTANT_MACROS) + #define __STDC_CONSTANT_MACROS +#endif + // For srs-librtmp, @see https://github.com/ossrs/srs/issues/213 #ifndef _WIN32 #include diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index dbb90abd4..02cc62335 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION4_HPP #define SRS_CORE_VERSION4_HPP -#define SRS_VERSION4_REVISION 13 +#define SRS_VERSION4_REVISION 14 #endif