From 7852fdc215b8d93845ab6f3a70b881565ca0cd04 Mon Sep 17 00:00:00 2001 From: custompal <1040801756@qq.com> Date: Thu, 16 Jun 2022 19:48:00 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=8E=BB=E9=99=A4rtp=5Fsender=5Fmtx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/MultiMediaSourceMuxer.cpp | 5 ----- src/Common/MultiMediaSourceMuxer.h | 1 - src/Rtp/RtpProcess.cpp | 4 ++++ src/Rtp/RtpProcess.h | 1 + 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index 88886330..cdfdde39 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -230,7 +230,6 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &, const MediaSourceEvent:: rtp_sender->addTrack(track); } rtp_sender->addTrackCompleted(); - lock_guard lck(strong_self->_rtp_sender_mtx); strong_self->_rtp_sender[args.ssrc] = rtp_sender; }); #else @@ -249,13 +248,11 @@ bool MultiMediaSourceMuxer::stopSendRtp(MediaSource &sender, const string &ssrc) } if (ssrc.empty()) { //关闭全部 - lock_guard lck(_rtp_sender_mtx); auto size = _rtp_sender.size(); _rtp_sender.clear(); return size; } //关闭特定的 - lock_guard lck(_rtp_sender_mtx); return _rtp_sender.erase(ssrc); #else return false; @@ -340,7 +337,6 @@ void MultiMediaSourceMuxer::resetTracks() { #endif #if defined(ENABLE_RTPPROXY) - lock_guard lck(_rtp_sender_mtx); for (auto &pr : _rtp_sender) { pr.second->resetTracks(); } @@ -447,7 +443,6 @@ bool MultiMediaSourceMuxer::onTrackFrame(const Frame::Ptr &frame_in) { #endif #if defined(ENABLE_RTPPROXY) - lock_guard lck(_rtp_sender_mtx); for (auto &pr : _rtp_sender) { ret = pr.second->inputFrame(frame) ? true : ret; } diff --git a/src/Common/MultiMediaSourceMuxer.h b/src/Common/MultiMediaSourceMuxer.h index 92c98f1b..caedd25d 100644 --- a/src/Common/MultiMediaSourceMuxer.h +++ b/src/Common/MultiMediaSourceMuxer.h @@ -180,7 +180,6 @@ private: std::weak_ptr _track_listener; std::function _get_origin_url; #if defined(ENABLE_RTPPROXY) - std::mutex _rtp_sender_mtx; std::unordered_map _rtp_sender; #endif //ENABLE_RTPPROXY diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index 511c9581..39d985a6 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -277,5 +277,9 @@ std::shared_ptr RtpProcess::getOriginSock(MediaSource &sender) const { return const_cast(this)->shared_from_this(); } +toolkit::EventPoller::Ptr RtpProcess::getOwnerPoller(MediaSource &sender) { + return _sock ? _sock->getPoller() : MediaSourceEvent::getOwnerPoller(sender); +} + }//namespace mediakit #endif//defined(ENABLE_RTPPROXY) \ No newline at end of file diff --git a/src/Rtp/RtpProcess.h b/src/Rtp/RtpProcess.h index c9a992b9..93dd37fe 100644 --- a/src/Rtp/RtpProcess.h +++ b/src/Rtp/RtpProcess.h @@ -76,6 +76,7 @@ protected: MediaOriginType getOriginType(MediaSource &sender) const override; std::string getOriginUrl(MediaSource &sender) const override; std::shared_ptr getOriginSock(MediaSource &sender) const override; + toolkit::EventPoller::Ptr getOwnerPoller(MediaSource &sender) override; private: void emitOnPublish(); From 260b3ff02cedbc319ac0d6ae2c23c04911acd513 Mon Sep 17 00:00:00 2001 From: custompal <1040801756@qq.com> Date: Thu, 16 Jun 2022 19:53:50 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AC=94=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtp/RtpProcess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index 39d985a6..9f15da7a 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -278,7 +278,7 @@ std::shared_ptr RtpProcess::getOriginSock(MediaSource &sender) const { } toolkit::EventPoller::Ptr RtpProcess::getOwnerPoller(MediaSource &sender) { - return _sock ? _sock->getPoller() : MediaSourceEvent::getOwnerPoller(sender); + return _sock ? _sock->getPoller() : MediaSourceEventInterceptor::getOwnerPoller(sender); } }//namespace mediakit From 3e62775db7809875212654c22715ca7324688b9e Mon Sep 17 00:00:00 2001 From: custompal <1040801756@qq.com> Date: Fri, 17 Jun 2022 18:21:00 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=97=A0=E4=BA=BA=E8=A7=82=E7=9C=8B?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E5=99=A8=E6=8C=87=E5=AE=9A=E4=B8=BAMediaSour?= =?UTF-8?q?ce=E5=AF=B9=E8=B1=A1=E6=89=80=E5=B1=9Epoller=E4=BB=A5=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E8=AF=BB=E5=8F=96=E8=A7=82=E7=9C=8B=E6=95=B0=E6=98=AF?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E5=AE=89=E5=85=A8=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/MediaSource.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index 4a3b4373..531221ba 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -581,7 +581,7 @@ MediaSource::Ptr MediaSource::createFromMP4(const string &schema, const string & /////////////////////////////////////MediaSourceEvent////////////////////////////////////// void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){ - if (size || totalReaderCount(sender)) { + if (size) { //还有人观看该视频,不触发关闭事件 _async_close_timer = nullptr; return; @@ -618,7 +618,7 @@ void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){ strong_sender->close(false); } return false; - }, nullptr); + }, getOwnerPoller(sender)); } string MediaSourceEvent::getOriginUrl(MediaSource &sender) const { From d3b37b76bd8d48a607667f57264858e7e1b3bbb6 Mon Sep 17 00:00:00 2001 From: custompal <1040801756@qq.com> Date: Fri, 15 Jul 2022 19:53:10 +0800 Subject: [PATCH 4/5] =?UTF-8?q?getMp4RecordFile=E6=8E=A5=E5=8F=A3=E5=8F=AF?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E8=87=AA=E5=AE=9A=E4=B9=89=E7=9A=84=E5=BD=95?= =?UTF-8?q?=E5=83=8F=E4=BF=9D=E5=AD=98=E6=A0=B9=E7=9B=AE=E5=BD=95=E6=9D=A5?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postman/ZLMediaKit.postman_collection.json | 7 ++++++- server/WebApi.cpp | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/postman/ZLMediaKit.postman_collection.json b/postman/ZLMediaKit.postman_collection.json index 12f8fe4f..6a0ea56d 100644 --- a/postman/ZLMediaKit.postman_collection.json +++ b/postman/ZLMediaKit.postman_collection.json @@ -900,7 +900,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{ZLMediaKit_URL}}/index/api/getMp4RecordFile?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=proxy&stream=2&period=2020-05-26", + "raw": "{{ZLMediaKit_URL}}/index/api/getMp4RecordFile?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=proxy&stream=2&customized_path=/www&period=2020-05-26", "host": [ "{{ZLMediaKit_URL}}" ], @@ -930,6 +930,11 @@ "value": "2", "description": "流id,例如 test" }, + { + "key": "customized_path", + "value": "/www", + "description": "录像文件保存自定义根目录,为空则采用配置文件设置" + }, { "key": "period", "value": "2020-05-26", diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 35c8a3c6..0af223dd 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit). @@ -1334,7 +1334,7 @@ void installWebApi() { api_regist("/index/api/getMp4RecordFile", [](API_ARGS_MAP){ CHECK_SECRET(); CHECK_ARGS("vhost", "app", "stream"); - auto record_path = Recorder::getRecordPath(Recorder::type_mp4, allArgs["vhost"], allArgs["app"],allArgs["stream"]); + auto record_path = Recorder::getRecordPath(Recorder::type_mp4, allArgs["vhost"], allArgs["app"], allArgs["stream"], allArgs["customized_path"]); auto period = allArgs["period"]; //判断是获取mp4文件列表还是获取文件夹列表 From 1291bf1d218782cd10f53c5682f3934ef24c36be Mon Sep 17 00:00:00 2001 From: custompal <1040801756@qq.com> Date: Fri, 15 Jul 2022 20:01:00 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0bom=E5=A4=B4?= 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 0af223dd..a7e6c34a 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved. * * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).