mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
添加http文件服务可挂载物理目录,新增ENABLE_API_STATIC_LIB
sa
This commit is contained in:
parent
4a063bee43
commit
626bf3dcf9
@ -57,6 +57,7 @@ option(ENABLE_ASAN "Enable Address Sanitize" false)
|
|||||||
option(ENABLE_WEBRTC "Enable WebRTC" false)
|
option(ENABLE_WEBRTC "Enable WebRTC" false)
|
||||||
option(ENABLE_PLAYER "Enable Player" true)
|
option(ENABLE_PLAYER "Enable Player" true)
|
||||||
option(ENABLE_MSVC_MT "Enable MSVC Mt/Mtd lib" 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)
|
if (MSVC AND ENABLE_MSVC_MT)
|
||||||
set(CompilerFlags
|
set(CompilerFlags
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
|
|
||||||
file(GLOB api_src_list include/*.h source/*.cpp source/*.h source/*.c)
|
file(GLOB api_src_list include/*.h source/*.cpp source/*.h source/*.c)
|
||||||
|
|
||||||
set(ENABLE_API_STATIC false)
|
|
||||||
|
|
||||||
if (IOS)
|
if (IOS)
|
||||||
add_library(mk_api STATIC ${api_src_list})
|
add_library(mk_api STATIC ${api_src_list})
|
||||||
target_link_libraries(mk_api ${LINK_LIB_LIST})
|
target_link_libraries(mk_api ${LINK_LIB_LIST})
|
||||||
else ()
|
else ()
|
||||||
if(ENABLE_API_STATIC)
|
if(ENABLE_API_STATIC_LIB)
|
||||||
add_library(mk_api STATIC ${api_src_list})
|
add_library(mk_api STATIC ${api_src_list})
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
add_definitions(-DMediaKitApi_STATIC)
|
add_definitions(-DMediaKitApi_STATIC)
|
||||||
|
@ -112,6 +112,8 @@ const string kKeepAliveSecond = HTTP_FIELD"keepAliveSecond";
|
|||||||
const string kCharSet = HTTP_FIELD"charSet";
|
const string kCharSet = HTTP_FIELD"charSet";
|
||||||
//http 服务器根目录
|
//http 服务器根目录
|
||||||
const string kRootPath = HTTP_FIELD"rootPath";
|
const string kRootPath = HTTP_FIELD"rootPath";
|
||||||
|
//http 服务器虚拟目录
|
||||||
|
const string kVirtualPath = HTTP_FIELD "virtualPath";
|
||||||
//http 404错误提示内容
|
//http 404错误提示内容
|
||||||
const string kNotFound = HTTP_FIELD"notFound";
|
const string kNotFound = HTTP_FIELD"notFound";
|
||||||
//是否显示文件夹菜单
|
//是否显示文件夹菜单
|
||||||
|
@ -183,6 +183,8 @@ extern const string kKeepAliveSecond;
|
|||||||
extern const string kCharSet;
|
extern const string kCharSet;
|
||||||
//http 服务器根目录
|
//http 服务器根目录
|
||||||
extern const string kRootPath;
|
extern const string kRootPath;
|
||||||
|
//http 服务器虚拟目录 虚拟目录名和磁盘物理路径使用“,”隔开,多个配置路径间用 "|"隔开,例如 path1,d:/record|path2,e:/record
|
||||||
|
extern const string kVirtualPath;
|
||||||
//http 404错误提示内容
|
//http 404错误提示内容
|
||||||
extern const string kNotFound;
|
extern const string kNotFound;
|
||||||
//是否显示文件夹菜单
|
//是否显示文件夹菜单
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "HttpConst.h"
|
#include "HttpConst.h"
|
||||||
#include "HttpSession.h"
|
#include "HttpSession.h"
|
||||||
#include "Record/HlsMediaSource.h"
|
#include "Record/HlsMediaSource.h"
|
||||||
|
#include "Common/Parser.h"
|
||||||
|
|
||||||
namespace mediakit {
|
namespace mediakit {
|
||||||
|
|
||||||
@ -131,6 +132,15 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st
|
|||||||
}
|
}
|
||||||
setFile.emplace(pDirent->d_name);
|
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;
|
int i = 0;
|
||||||
for (auto &strFile :setFile) {
|
for (auto &strFile :setFile) {
|
||||||
string strAbsolutePath = strPathPrefix + "/" + strFile;
|
string strAbsolutePath = strPathPrefix + "/" + strFile;
|
||||||
@ -138,7 +148,7 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st
|
|||||||
ss << "<li><span>" << i++ << "</span>\t";
|
ss << "<li><span>" << i++ << "</span>\t";
|
||||||
ss << "<a href=\"";
|
ss << "<a href=\"";
|
||||||
if (!last_dir_name.empty()) {
|
if (!last_dir_name.empty()) {
|
||||||
ss << last_dir_name << "/" << strFile;
|
ss << httpPath << "/" << strFile;
|
||||||
} else {
|
} else {
|
||||||
ss << strFile;
|
ss << strFile;
|
||||||
}
|
}
|
||||||
@ -461,7 +471,18 @@ static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo
|
|||||||
static string getFilePath(const Parser &parser,const MediaInfo &mediaInfo, TcpSession &sender){
|
static string getFilePath(const Parser &parser,const MediaInfo &mediaInfo, TcpSession &sender){
|
||||||
GET_CONFIG(bool, enableVhost, General::kEnableVhost);
|
GET_CONFIG(bool, enableVhost, General::kEnableVhost);
|
||||||
GET_CONFIG(string, rootPath, Http::kRootPath);
|
GET_CONFIG(string, rootPath, Http::kRootPath);
|
||||||
auto ret = File::absolutePath(enableVhost ? mediaInfo._vhost + parser.Url() : parser.Url(), rootPath);
|
GET_CONFIG(string, virtualPath, Http::kVirtualPath);
|
||||||
|
mediakit::Parser pathParser;
|
||||||
|
StrCaseMap args = pathParser.parseArgs(virtualPath, "|", ",");
|
||||||
|
auto path = args[mediaInfo._app];
|
||||||
|
string ret;
|
||||||
|
if (path == "") {
|
||||||
|
ret = File::absolutePath(
|
||||||
|
enableVhost ? mediaInfo._vhost + parser.Url() : parser.Url(), rootPath);
|
||||||
|
}else {
|
||||||
|
ret = File::absolutePath(
|
||||||
|
enableVhost ? mediaInfo._vhost + "/" + mediaInfo._streamid : mediaInfo._streamid, path);
|
||||||
|
}
|
||||||
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastHttpBeforeAccess, parser, ret, static_cast<SockInfo &>(sender));
|
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastHttpBeforeAccess, parser, ret, static_cast<SockInfo &>(sender));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user