From 90c164f7f774ba6186931fdc1dc995c09f8fb55a Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sun, 20 Aug 2023 11:19:57 +0800 Subject: [PATCH 1/9] =?UTF-8?q?rtsp=E6=92=AD=E6=94=BE=E5=99=A8=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E9=9D=9E=E6=B3=95=E7=9A=84=E5=9B=9E=E5=A4=8D=20(#2760?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 提高对一些rtsp流的兼容性 --- src/Rtsp/RtspPlayer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 599677ec..676d89b1 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -483,6 +483,11 @@ void RtspPlayer::handleResPAUSE(const Parser &parser, int type) { } void RtspPlayer::onWholeRtspPacket(Parser &parser) { + if (!start_with(parser.method(), "RTSP")) { + // 不是rtsp回复,忽略 + WarnL << "Not rtsp response: " << parser.method(); + return; + } try { decltype(_on_response) func; _on_response.swap(func); From 0c80f0c13c9a2c33bded1d93eeafbf11fe5b097d Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sun, 20 Aug 2023 11:22:37 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0zltoolkit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复在收到tcp reset时,获取socket对端地址失败的问题: #2749 --- 3rdpart/ZLToolKit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index d2016522..bb49f04d 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit d2016522a0e4b1d8df51a78b7415fe148f7245ca +Subproject commit bb49f04deeec40eb4331f6e317fd2164af6a7d95 From 895e93cb6aae82f9fd6f19b0980c28062b6b9d2f Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sun, 20 Aug 2023 12:07:04 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E6=B1=A0=E5=88=86?= =?UTF-8?q?=E9=85=8D=E7=AB=AF=E5=8F=A3=E6=94=B9=E6=88=90=E6=97=A0=E5=BA=8F?= =?UTF-8?q?=E5=88=86=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决zlmediakit重启后端口重复分配导致国标串流问题 --- src/Rtsp/Rtsp.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Rtsp/Rtsp.cpp b/src/Rtsp/Rtsp.cpp index b5b50360..579a881e 100644 --- a/src/Rtsp/Rtsp.cpp +++ b/src/Rtsp/Rtsp.cpp @@ -8,12 +8,13 @@ * may be found in the AUTHORS file in the root of the source tree. */ +#include +#include +#include #include "Rtsp.h" #include "Common/Parser.h" #include "Common/config.h" #include "Network/Socket.h" -#include -#include using namespace std; using namespace toolkit; @@ -392,9 +393,13 @@ public: private: void setRange(uint16_t start_pos, uint16_t end_pos) { + std::mt19937 rng(std::random_device {}()); lock_guard lck(_pool_mtx); + auto it = _port_pair_pool.begin(); while (start_pos < end_pos) { - _port_pair_pool.emplace_back(start_pos++); + // 随机端口排序,防止重启后导致分配的端口重复 + _port_pair_pool.insert(it, start_pos++); + it = _port_pair_pool.begin() + (rng() % (1 + _port_pair_pool.size())); } } From b4fd445f2d10025a87481e51d6494b00a87f934d Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 26 Aug 2023 11:33:54 +0800 Subject: [PATCH 4/9] =?UTF-8?q?webrtc=E6=B5=8B=E8=AF=95=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E5=88=B7=E6=96=B0=E6=B5=81=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- www/webrtc/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/webrtc/index.html b/www/webrtc/index.html index 269ae9b2..a340f0c1 100644 --- a/www/webrtc/index.html +++ b/www/webrtc/index.html @@ -322,7 +322,7 @@ json.then((json)=> fillStreamList(json)); } setInterval(() => { - get_media_list(); + // get_media_list(); }, 5000); From f3f4b4933264b8513d987b24ea9d8f3e669c87c0 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 26 Aug 2023 11:34:12 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=82=B9=E6=92=AD=E9=80=9F=E5=BA=A6=E5=90=8E=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=B3=E8=B7=B3=E8=B7=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Record/MP4Reader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Record/MP4Reader.cpp b/src/Record/MP4Reader.cpp index 5c144d2e..2def3781 100644 --- a/src/Record/MP4Reader.cpp +++ b/src/Record/MP4Reader.cpp @@ -184,8 +184,10 @@ bool MP4Reader::speed(MediaSource &sender, float speed) { WarnL << "播放速度取值范围非法:" << speed; return false; } - //设置播放速度后应该恢复播放 - pause(sender, false); + //_seek_ticker重置,赋值_seek_to + setCurrentStamp(getCurrentStamp()); + // 设置播放速度后应该恢复播放 + _paused = false; if (_speed == speed) { return true; } From cb4ab21548291241aea276462d5ad8d6ea7cdd4c Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 26 Aug 2023 11:34:22 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8Drtsp=E7=BB=84=E6=92=AD?= =?UTF-8?q?=E9=81=8D=E5=8E=86=E8=BF=AD=E4=BB=A3=E5=99=A8=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/UDPServer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Rtsp/UDPServer.cpp b/src/Rtsp/UDPServer.cpp index 4f648ddf..bb9e4642 100644 --- a/src/Rtsp/UDPServer.cpp +++ b/src/Rtsp/UDPServer.cpp @@ -82,10 +82,12 @@ void UDPServer::onRecv(int interleaved, const Buffer::Ptr &buf, struct sockaddr* return; } auto &ref = it0->second; - for (auto it1 = ref.begin(); it1 != ref.end(); ++it1) { + for (auto it1 = ref.begin(); it1 != ref.end();) { auto &func = it1->second; if (!func(interleaved, buf, peer_addr)) { it1 = ref.erase(it1); + } else { + ++it1; } } if (ref.size() == 0) { From f36ccee3de9356a1bbdfc911afbbb68226ffefc3 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 26 Aug 2023 11:34:30 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0zltoolkit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index bb49f04d..a4b8b5e0 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit bb49f04deeec40eb4331f6e317fd2164af6a7d95 +Subproject commit a4b8b5e00aac6251254a513c7759605c0ba35f90 From 06a6d26491043277361bf5a67dfdadcdca29cb61 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 26 Aug 2023 19:43:11 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E6=8F=90=E9=AB=98http=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=AE=89=E5=85=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpFileManager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index 3ec4d40c..66e5f7fa 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -524,7 +524,7 @@ static void accessFile(Session &sender, const Parser &parser, const MediaInfo &m }); } -static string getFilePath(const Parser &parser,const MediaInfo &media_info, Session &sender){ +static string getFilePath(const Parser &parser,const MediaInfo &media_info, Session &sender) { GET_CONFIG(bool, enableVhost, General::kEnableVhost); GET_CONFIG(string, rootPath, Http::kRootPath); GET_CONFIG_FUNC(StrCaseMap, virtualPathMap, Http::kVirtualPath, [](const string &str) { @@ -549,6 +549,13 @@ static string getFilePath(const Parser &parser,const MediaInfo &media_info, Sess } } auto ret = File::absolutePath(enableVhost ? media_info.vhost + url : url, path); + auto http_root = File::absolutePath(enableVhost ? media_info.vhost + "/" : "/", path); + if (!start_with(ret, http_root)) { + // 访问的http文件不得在http根目录之外 + throw std::runtime_error("Attempting to access files outside of the http root directory"); + } + // 替换url,防止返回的目录索引网页被注入非法内容 + const_cast(parser).setUrl("/" + ret.substr(http_root.size())); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastHttpBeforeAccess, parser, ret, static_cast(sender)); return ret; } From 0844f09e24f5fae96da987f16df17dc75e7fe851 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sat, 26 Aug 2023 23:02:19 +0800 Subject: [PATCH 9/9] =?UTF-8?q?addStreamProxy=E9=87=8D=E5=A4=8D=E6=8B=89?= =?UTF-8?q?=E6=B5=81=E6=97=B6=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF=20(#2773?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 11e06ea1..6f40403d 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -537,7 +537,7 @@ void addStreamProxy(const string &vhost, const string &app, const string &stream lock_guard lck(s_proxyMapMtx); if (s_proxyMap.find(key) != s_proxyMap.end()) { //已经在拉流了 - cb(SockException(Err_success), key); + cb(SockException(Err_other, "This stream already exists"), key); return; } //添加拉流代理