From 626bf3dcf9c0adcca00c8090fb2bd8a7767e485b Mon Sep 17 00:00:00 2001 From: baiyfcu <87684855@qq.com> Date: Wed, 25 Aug 2021 14:30:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0http=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=8F=AF=E6=8C=82=E8=BD=BD=E7=89=A9=E7=90=86?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=EF=BC=8C=E6=96=B0=E5=A2=9EENABLE=5FAPI=5FSTA?= =?UTF-8?q?TIC=5FLIB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sa --- CMakeLists.txt | 1 + api/CMakeLists.txt | 4 +--- src/Common/config.cpp | 2 ++ src/Common/config.h | 2 ++ src/Http/HttpFileManager.cpp | 25 +++++++++++++++++++++++-- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af75cbac..71637ee8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,7 @@ option(ENABLE_ASAN "Enable Address Sanitize" false) option(ENABLE_WEBRTC "Enable WebRTC" false) option(ENABLE_PLAYER "Enable Player" true) option(ENABLE_MSVC_MT "Enable MSVC Mt/Mtd lib" true) +option(ENABLE_API_STATIC_LIB "Enable mk_api static lib" false) if (MSVC AND ENABLE_MSVC_MT) set(CompilerFlags diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt index 6f460300..c9c991c8 100644 --- a/api/CMakeLists.txt +++ b/api/CMakeLists.txt @@ -2,13 +2,11 @@ file(GLOB api_src_list include/*.h source/*.cpp source/*.h source/*.c) -set(ENABLE_API_STATIC false) - if (IOS) add_library(mk_api STATIC ${api_src_list}) target_link_libraries(mk_api ${LINK_LIB_LIST}) else () - if(ENABLE_API_STATIC) + if(ENABLE_API_STATIC_LIB) add_library(mk_api STATIC ${api_src_list}) if (WIN32) add_definitions(-DMediaKitApi_STATIC) diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 42626291..93dc71d6 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -112,6 +112,8 @@ const string kKeepAliveSecond = HTTP_FIELD"keepAliveSecond"; const string kCharSet = HTTP_FIELD"charSet"; //http 服务器根目录 const string kRootPath = HTTP_FIELD"rootPath"; +//http 服务器虚拟目录 +const string kVirtualPath = HTTP_FIELD "virtualPath"; //http 404错误提示内容 const string kNotFound = HTTP_FIELD"notFound"; //是否显示文件夹菜单 diff --git a/src/Common/config.h b/src/Common/config.h index fe2f6605..23430020 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -183,6 +183,8 @@ extern const string kKeepAliveSecond; extern const string kCharSet; //http 服务器根目录 extern const string kRootPath; +//http 服务器虚拟目录 虚拟目录名和磁盘物理路径使用“,”隔开,多个配置路径间用 "|"隔开,例如 path1,d:/record|path2,e:/record +extern const string kVirtualPath; //http 404错误提示内容 extern const string kNotFound; //是否显示文件夹菜单 diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index d00f194f..0e1e34c4 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -18,6 +18,7 @@ #include "HttpConst.h" #include "HttpSession.h" #include "Record/HlsMediaSource.h" +#include "Common/Parser.h" namespace mediakit { @@ -131,6 +132,15 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st } setFile.emplace(pDirent->d_name); } + //如果是root目录,添加虚拟目录 + if (httpPath == "/") { + GET_CONFIG(string, virtualPath, Http::kVirtualPath); + mediakit::Parser pathParser; + StrCaseMap args = pathParser.parseArgs(virtualPath, "|", ","); + for (auto arg : args) { + setFile.emplace(arg.first); + } + } int i = 0; for (auto &strFile :setFile) { string strAbsolutePath = strPathPrefix + "/" + strFile; @@ -138,7 +148,7 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st ss << "
  • " << i++ << "\t"; ss << "(sender)); return ret; }