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
12551be3
Commit
12551be3
authored
Sep 16, 2022
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提炼ProtocolOption赋值相关逻辑
parent
c094751f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
45 行增加
和
61 行删除
+45
-61
server/WebApi.cpp
+3
-16
server/WebHook.cpp
+12
-45
src/Common/MultiMediaSourceMuxer.h
+30
-0
没有找到文件。
server/WebApi.cpp
查看文件 @
12551be3
...
...
@@ -1011,20 +1011,7 @@ void installWebApi() {
CHECK_SECRET
();
CHECK_ARGS
(
"vhost"
,
"app"
,
"stream"
,
"url"
);
ProtocolOption
option
;
getArgsValue
(
allArgs
,
"enable_hls"
,
option
.
enable_hls
);
getArgsValue
(
allArgs
,
"enable_mp4"
,
option
.
enable_mp4
);
getArgsValue
(
allArgs
,
"mp4_as_player"
,
option
.
mp4_as_player
);
getArgsValue
(
allArgs
,
"enable_rtsp"
,
option
.
enable_rtsp
);
getArgsValue
(
allArgs
,
"enable_rtmp"
,
option
.
enable_rtmp
);
getArgsValue
(
allArgs
,
"enable_ts"
,
option
.
enable_ts
);
getArgsValue
(
allArgs
,
"enable_fmp4"
,
option
.
enable_fmp4
);
getArgsValue
(
allArgs
,
"enable_audio"
,
option
.
enable_audio
);
getArgsValue
(
allArgs
,
"add_mute_audio"
,
option
.
add_mute_audio
);
getArgsValue
(
allArgs
,
"mp4_save_path"
,
option
.
mp4_save_path
);
getArgsValue
(
allArgs
,
"mp4_max_second"
,
option
.
mp4_max_second
);
getArgsValue
(
allArgs
,
"hls_save_path"
,
option
.
hls_save_path
);
getArgsValue
(
allArgs
,
"modify_stamp"
,
option
.
modify_stamp
);
ProtocolOption
option
(
allArgs
);
addStreamProxy
(
allArgs
[
"vhost"
],
allArgs
[
"app"
],
...
...
@@ -1629,9 +1616,9 @@ void installWebApi() {
api_regist
(
"/index/hook/on_publish"
,[](
API_ARGS_JSON
){
//开始推流事件
//转换hls
val
[
"enable
H
ls"
]
=
true
;
val
[
"enable
_h
ls"
]
=
true
;
//不录制mp4
val
[
"enable
MP
4"
]
=
false
;
val
[
"enable
_mp
4"
]
=
false
;
});
api_regist
(
"/index/hook/on_play"
,[](
API_ARGS_JSON
){
...
...
server/WebHook.cpp
查看文件 @
12551be3
...
...
@@ -292,6 +292,16 @@ static void pullStreamFromOrigin(const vector<string>& urls, size_t index, size_
static
void
*
web_hook_tag
=
nullptr
;
static
mINI
jsonToMini
(
const
Value
&
obj
)
{
mINI
ret
;
if
(
obj
.
isObject
())
{
for
(
auto
it
=
obj
.
begin
();
it
!=
obj
.
end
();
++
it
)
{
ret
[
it
.
name
()]
=
(
*
it
).
asString
();
}
}
return
ret
;
}
void
installWebHook
(){
GET_CONFIG
(
bool
,
hook_enable
,
Hook
::
kEnable
);
GET_CONFIG
(
string
,
hook_adminparams
,
Hook
::
kAdminParams
);
...
...
@@ -311,55 +321,12 @@ void installWebHook(){
body
[
"originTypeStr"
]
=
getOriginTypeString
(
type
);
//执行hook
do_http_hook
(
hook_publish
,
body
,
[
invoker
](
const
Value
&
obj
,
const
string
&
err
)
mutable
{
ProtocolOption
option
;
if
(
err
.
empty
())
{
//推流鉴权成功
if
(
obj
.
isMember
(
"enable_hls"
))
{
option
.
enable_hls
=
obj
[
"enable_hls"
].
asBool
();
}
if
(
obj
.
isMember
(
"enable_mp4"
))
{
option
.
enable_mp4
=
obj
[
"enable_mp4"
].
asBool
();
}
if
(
obj
.
isMember
(
"enable_audio"
))
{
option
.
enable_audio
=
obj
[
"enable_audio"
].
asBool
();
}
if
(
obj
.
isMember
(
"add_mute_audio"
))
{
option
.
add_mute_audio
=
obj
[
"add_mute_audio"
].
asBool
();
}
if
(
obj
.
isMember
(
"mp4_save_path"
))
{
option
.
mp4_save_path
=
obj
[
"mp4_save_path"
].
asString
();
}
if
(
obj
.
isMember
(
"mp4_max_second"
))
{
option
.
mp4_max_second
=
obj
[
"mp4_max_second"
].
asUInt
();
}
if
(
obj
.
isMember
(
"hls_save_path"
))
{
option
.
hls_save_path
=
obj
[
"hls_save_path"
].
asString
();
}
if
(
obj
.
isMember
(
"enable_rtsp"
))
{
option
.
enable_rtsp
=
obj
[
"enable_rtsp"
].
asBool
();
}
if
(
obj
.
isMember
(
"enable_rtmp"
))
{
option
.
enable_rtmp
=
obj
[
"enable_rtmp"
].
asBool
();
}
if
(
obj
.
isMember
(
"enable_ts"
))
{
option
.
enable_ts
=
obj
[
"enable_ts"
].
asBool
();
}
if
(
obj
.
isMember
(
"enable_fmp4"
))
{
option
.
enable_fmp4
=
obj
[
"enable_fmp4"
].
asBool
();
}
if
(
obj
.
isMember
(
"continue_push_ms"
))
{
option
.
continue_push_ms
=
obj
[
"continue_push_ms"
].
asUInt
();
}
if
(
obj
.
isMember
(
"mp4_as_player"
))
{
option
.
mp4_as_player
=
obj
[
"mp4_as_player"
].
asBool
();
}
if
(
obj
.
isMember
(
"modify_stamp"
))
{
option
.
modify_stamp
=
obj
[
"modify_stamp"
].
asBool
();
}
invoker
(
err
,
option
);
invoker
(
err
,
ProtocolOption
(
jsonToMini
(
obj
)));
}
else
{
//推流鉴权失败
invoker
(
err
,
option
);
invoker
(
err
,
ProtocolOption
()
);
}
});
});
...
...
src/Common/MultiMediaSourceMuxer.h
查看文件 @
12551be3
...
...
@@ -60,6 +60,36 @@ public:
//时间戳修复这一路流标志位
bool
modify_stamp
;
template
<
typename
MAP
>
ProtocolOption
(
const
MAP
&
allArgs
)
:
ProtocolOption
()
{
#define GET_OPT_VALUE(key) getArgsValue(allArgs, #key, key)
GET_OPT_VALUE
(
enable_hls
);
GET_OPT_VALUE
(
enable_mp4
);
GET_OPT_VALUE
(
mp4_as_player
);
GET_OPT_VALUE
(
enable_rtsp
);
GET_OPT_VALUE
(
enable_rtmp
);
GET_OPT_VALUE
(
enable_ts
);
GET_OPT_VALUE
(
enable_fmp4
);
GET_OPT_VALUE
(
enable_audio
);
GET_OPT_VALUE
(
add_mute_audio
);
GET_OPT_VALUE
(
mp4_save_path
);
GET_OPT_VALUE
(
mp4_max_second
);
GET_OPT_VALUE
(
hls_save_path
);
GET_OPT_VALUE
(
continue_push_ms
);
GET_OPT_VALUE
(
modify_stamp
);
}
ProtocolOption
(
const
ProtocolOption
&
)
=
default
;
private
:
template
<
typename
MAP
,
typename
KEY
,
typename
TYPE
>
static
void
getArgsValue
(
const
MAP
&
allArgs
,
const
KEY
&
key
,
TYPE
&
value
)
{
auto
val
=
((
MAP
&
)
allArgs
)[
key
];
if
(
!
val
.
empty
())
{
value
=
(
TYPE
)
val
;
}
}
};
class
MultiMediaSourceMuxer
:
public
MediaSourceEventInterceptor
,
public
MediaSink
,
public
std
::
enable_shared_from_this
<
MultiMediaSourceMuxer
>
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论