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; }