From 4067f2beb6e21f3c1dede60cd87bf64fb6762dc3 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Thu, 21 Oct 2021 10:21:52 +0800 Subject: [PATCH] =?UTF-8?q?ps=20rtp=E6=8E=A8=E6=B5=81=E6=8E=A5=E5=8F=A3(st?= =?UTF-8?q?artSendRtp)=E6=94=AF=E6=8C=81=E6=8E=A8=E9=80=81=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0mp4=E5=BD=95=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postman/ZLMediaKit.postman_collection.json | 6 ++++++ server/WebApi.cpp | 2 +- src/Common/MediaSource.cpp | 16 ++++++++-------- src/Common/MediaSource.h | 10 +++------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/postman/ZLMediaKit.postman_collection.json b/postman/ZLMediaKit.postman_collection.json index 5f2598a8..68072313 100644 --- a/postman/ZLMediaKit.postman_collection.json +++ b/postman/ZLMediaKit.postman_collection.json @@ -1329,6 +1329,12 @@ "value": "0", "description": "指定tcp/udp客户端使用的本地端口,0时为随机端口,该参数非必选参数,不传时为随机端口。", "disabled": true + }, + { + "key": "from_mp4", + "value": "0", + "description": "是否推送本地MP4录像,该参数非必选参数", + "disabled": true } ] } diff --git a/server/WebApi.cpp b/server/WebApi.cpp index cdcc68ac..b01cb18a 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -967,7 +967,7 @@ void installWebApi() { CHECK_SECRET(); CHECK_ARGS("vhost", "app", "stream", "ssrc", "dst_url", "dst_port", "is_udp"); - auto src = MediaSource::find(allArgs["vhost"], allArgs["app"], allArgs["stream"]); + auto src = MediaSource::find(allArgs["vhost"], allArgs["app"], allArgs["stream"], allArgs["from_mp4"].as()); if (!src) { throw ApiRetException("该媒体流不存在", API::OtherFailed); } diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index d9374c33..53dd6951 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -288,7 +288,7 @@ void MediaSource::for_each_media(const function &cb, } } -static MediaSource::Ptr find_l(const string &schema, const string &vhost_in, const string &app, const string &id, bool create_new) { +static MediaSource::Ptr find_l(const string &schema, const string &vhost_in, const string &app, const string &id, bool from_mp4) { string vhost = vhost_in; GET_CONFIG(bool,enableVhost,General::kEnableVhost); if(vhost.empty() || !enableVhost){ @@ -303,7 +303,7 @@ static MediaSource::Ptr find_l(const string &schema, const string &vhost_in, con MediaSource::Ptr ret; MediaSource::for_each_media([&](const MediaSource::Ptr &src) { ret = std::move(const_cast(src)); }, schema, vhost, app, id); - if(!ret && create_new && schema != HLS_SCHEMA){ + if(!ret && from_mp4 && schema != HLS_SCHEMA){ //未查找媒体源,则读取mp4创建一个 //播放hls不触发mp4点播(因为HLS也可以用于录像,不是纯粹的直播) ret = MediaSource::createFromMP4(schema, vhost, app, id); @@ -387,20 +387,20 @@ void MediaSource::findAsync(const MediaInfo &info, const std::shared_ptr &session, const function &cb); // 遍历所有流 - static void for_each_media(const function &cb, - const string &schema = "", - const string &vhost = "", - const string &app = "", - const string &stream = ""); + static void for_each_media(const function &cb, const string &schema = "", const string &vhost = "", const string &app = "", const string &stream = ""); // 从mp4文件生成MediaSource static MediaSource::Ptr createFromMP4(const string &schema, const string &vhost, const string &app, const string &stream, const string &file_path = "", bool check_app = true);