Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
626bf3dc
Commit
626bf3dc
authored
Aug 25, 2021
by
baiyfcu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加http文件服务可挂载物理目录,新增ENABLE_API_STATIC_LIB
sa
parent
4a063bee
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
29 行增加
和
5 行删除
+29
-5
CMakeLists.txt
+1
-0
api/CMakeLists.txt
+1
-3
src/Common/config.cpp
+2
-0
src/Common/config.h
+2
-0
src/Http/HttpFileManager.cpp
+23
-2
没有找到文件。
CMakeLists.txt
查看文件 @
626bf3dc
...
...
@@ -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
...
...
api/CMakeLists.txt
查看文件 @
626bf3dc
...
...
@@ -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
)
...
...
src/Common/config.cpp
查看文件 @
626bf3dc
...
...
@@ -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"
;
//是否显示文件夹菜单
...
...
src/Common/config.h
查看文件 @
626bf3dc
...
...
@@ -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
;
//是否显示文件夹菜单
...
...
src/Http/HttpFileManager.cpp
查看文件 @
626bf3dc
...
...
@@ -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
<<
"<li><span>"
<<
i
++
<<
"</span>
\t
"
;
ss
<<
"<a href=
\"
"
;
if
(
!
last_dir_name
.
empty
())
{
ss
<<
last_dir_name
<<
"/"
<<
strFile
;
ss
<<
httpPath
<<
"/"
<<
strFile
;
}
else
{
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
){
GET_CONFIG
(
bool
,
enableVhost
,
General
::
kEnableVhost
);
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
));
return
ret
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论