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
be8403c3
Commit
be8403c3
authored
Mar 14, 2021
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善代码
parent
c0f48999
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
30 行增加
和
30 行删除
+30
-30
server/WebApi.cpp
+22
-22
server/WebHook.cpp
+3
-3
src/Http/HttpFileManager.cpp
+2
-2
src/Record/MP4Recorder.cpp
+3
-3
没有找到文件。
server/WebApi.cpp
查看文件 @
be8403c3
...
...
@@ -644,12 +644,12 @@ void installWebApi() {
allArgs
[
"enable_hls"
],
/* 是否hls转发 */
allArgs
[
"enable_mp4"
],
/* 是否MP4录制 */
allArgs
[
"rtp_type"
],
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
){
if
(
ex
)
{
const_cast
<
Value
&>
(
val
)
[
"code"
]
=
API
::
OtherFailed
;
const_cast
<
Value
&>
(
val
)
[
"msg"
]
=
ex
.
what
();
}
else
{
const_cast
<
Value
&>
(
val
)
[
"data"
][
"key"
]
=
key
;
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
)
mutable
{
if
(
ex
)
{
val
[
"code"
]
=
API
::
OtherFailed
;
val
[
"msg"
]
=
ex
.
what
();
}
else
{
val
[
"data"
][
"key"
]
=
key
;
}
invoker
(
200
,
headerOut
,
val
.
toStyledString
());
});
...
...
@@ -708,12 +708,12 @@ void installWebApi() {
auto
enable_mp4
=
allArgs
[
"enable_mp4"
].
as
<
int
>
();
addFFmpegSource
(
allArgs
[
"ffmpeg_cmd_key"
],
src_url
,
dst_url
,
timeout_ms
,
enable_hls
,
enable_mp4
,
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
)
{
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
)
mutable
{
if
(
ex
)
{
const_cast
<
Value
&>
(
val
)
[
"code"
]
=
API
::
OtherFailed
;
const_cast
<
Value
&>
(
val
)
[
"msg"
]
=
ex
.
what
();
val
[
"code"
]
=
API
::
OtherFailed
;
val
[
"msg"
]
=
ex
.
what
();
}
else
{
const_cast
<
Value
&>
(
val
)
[
"data"
][
"key"
]
=
key
;
val
[
"data"
][
"key"
]
=
key
;
}
invoker
(
200
,
headerOut
,
val
.
toStyledString
());
});
...
...
@@ -815,12 +815,12 @@ void installWebApi() {
}
//src_port为空时,则随机本地端口
src
->
startSendRtp
(
allArgs
[
"dst_url"
],
allArgs
[
"dst_port"
],
allArgs
[
"ssrc"
],
allArgs
[
"is_udp"
],
allArgs
[
"src_port"
],
[
val
,
headerOut
,
invoker
](
uint16_t
local_port
,
const
SockException
&
ex
){
src
->
startSendRtp
(
allArgs
[
"dst_url"
],
allArgs
[
"dst_port"
],
allArgs
[
"ssrc"
],
allArgs
[
"is_udp"
],
allArgs
[
"src_port"
],
[
val
,
headerOut
,
invoker
](
uint16_t
local_port
,
const
SockException
&
ex
)
mutable
{
if
(
ex
)
{
const_cast
<
Value
&>
(
val
)
[
"code"
]
=
API
::
OtherFailed
;
const_cast
<
Value
&>
(
val
)
[
"msg"
]
=
ex
.
what
();
val
[
"code"
]
=
API
::
OtherFailed
;
val
[
"msg"
]
=
ex
.
what
();
}
const_cast
<
Value
&>
(
val
)
[
"local_port"
]
=
local_port
;
val
[
"local_port"
]
=
local_port
;
invoker
(
200
,
headerOut
,
val
.
toStyledString
());
});
});
...
...
@@ -1116,12 +1116,12 @@ void installWebApi() {
(
1000
*
timeout_sec
)
-
500
,
false
,
false
,
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
){
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
)
mutable
{
if
(
ex
){
const_cast
<
Value
&>
(
val
)
[
"code"
]
=
API
::
OtherFailed
;
const_cast
<
Value
&>
(
val
)
[
"msg"
]
=
ex
.
what
();
val
[
"code"
]
=
API
::
OtherFailed
;
val
[
"msg"
]
=
ex
.
what
();
}
else
{
const_cast
<
Value
&>
(
val
)
[
"data"
][
"key"
]
=
key
;
val
[
"data"
][
"key"
]
=
key
;
}
invoker
(
200
,
headerOut
,
val
.
toStyledString
());
});
...
...
@@ -1141,12 +1141,12 @@ void installWebApi() {
true
,
/* 开启hls转发 */
false
,
/* 禁用MP4录制 */
0
,
//rtp over tcp方式拉流
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
){
[
invoker
,
val
,
headerOut
](
const
SockException
&
ex
,
const
string
&
key
)
mutable
{
if
(
ex
){
const_cast
<
Value
&>
(
val
)
[
"code"
]
=
API
::
OtherFailed
;
const_cast
<
Value
&>
(
val
)
[
"msg"
]
=
ex
.
what
();
val
[
"code"
]
=
API
::
OtherFailed
;
val
[
"msg"
]
=
ex
.
what
();
}
else
{
const_cast
<
Value
&>
(
val
)
[
"data"
][
"key"
]
=
key
;
val
[
"data"
][
"key"
]
=
key
;
}
invoker
(
200
,
headerOut
,
val
.
toStyledString
());
});
...
...
server/WebHook.cpp
查看文件 @
be8403c3
...
...
@@ -126,9 +126,9 @@ void do_http_hook(const string &url,const ArgsType &body,const function<void(con
requester
->
startRequester
(
url
,
[
url
,
func
,
bodyStr
,
requester
,
pTicker
](
const
SockException
&
ex
,
const
string
&
status
,
const
HttpClient
::
HttpHeader
&
header
,
const
string
&
strRecvBody
)
{
onceToken
token
(
nullptr
,
[
&
]()
{
const_cast
<
HttpRequester
::
Ptr
&>
(
requester
)
.
reset
();
const
string
&
strRecvBody
)
mutable
{
onceToken
token
(
nullptr
,
[
&
]()
mutable
{
requester
.
reset
();
});
parse_http_response
(
ex
,
status
,
header
,
strRecvBody
,[
&
](
const
Value
&
obj
,
const
string
&
err
){
if
(
func
)
{
...
...
src/Http/HttpFileManager.cpp
查看文件 @
be8403c3
...
...
@@ -494,9 +494,9 @@ void HttpFileManager::onAccessPath(TcpSession &sender, Parser &parser, const Htt
return
;
}
//判断是否有权限访问该目录
canAccessPath
(
sender
,
parser
,
mediaInfo
,
true
,
[
strMenu
,
cb
](
const
string
&
errMsg
,
const
HttpServerCookie
::
Ptr
&
cookie
)
{
canAccessPath
(
sender
,
parser
,
mediaInfo
,
true
,
[
strMenu
,
cb
](
const
string
&
errMsg
,
const
HttpServerCookie
::
Ptr
&
cookie
)
mutable
{
if
(
!
errMsg
.
empty
())
{
const_cast
<
string
&>
(
strMenu
)
=
errMsg
;
strMenu
=
errMsg
;
}
StrCaseMap
headerOut
;
if
(
cookie
)
{
...
...
src/Record/MP4Recorder.cpp
查看文件 @
be8403c3
...
...
@@ -76,16 +76,16 @@ void MP4Recorder::asyncClose() {
auto
strFileTmp
=
_strFileTmp
;
auto
strFile
=
_strFile
;
auto
info
=
_info
;
WorkThreadPool
::
Instance
().
getExecutor
()
->
async
([
muxer
,
strFileTmp
,
strFile
,
info
]()
{
WorkThreadPool
::
Instance
().
getExecutor
()
->
async
([
muxer
,
strFileTmp
,
strFile
,
info
]()
mutable
{
//获取文件录制时间,放在关闭mp4之前是为了忽略关闭mp4执行时间
const_cast
<
RecordInfo
&>
(
info
)
.
time_len
=
(
float
)(
::
time
(
NULL
)
-
info
.
start_time
);
info
.
time_len
=
(
float
)(
::
time
(
NULL
)
-
info
.
start_time
);
//关闭mp4非常耗时,所以要放在后台线程执行
muxer
->
closeMP4
();
//获取文件大小
struct
stat
fileData
;
stat
(
strFileTmp
.
data
(),
&
fileData
);
const_cast
<
RecordInfo
&>
(
info
)
.
file_size
=
fileData
.
st_size
;
info
.
file_size
=
fileData
.
st_size
;
if
(
fileData
.
st_size
<
1024
)
{
//录像文件太小,删除之
File
::
delete_file
(
strFileTmp
.
data
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论