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
6b621d42
Commit
6b621d42
authored
4 years ago
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化接口
parent
7823d2c1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
15 行增加
和
14 行删除
+15
-14
server/WebApi.cpp
+15
-14
没有找到文件。
server/WebApi.cpp
查看文件 @
6b621d42
...
@@ -38,11 +38,12 @@ using namespace mediakit;
...
@@ -38,11 +38,12 @@ using namespace mediakit;
namespace
API
{
namespace
API
{
typedef
enum
{
typedef
enum
{
InvalidArgs
=
-
300
,
Exception
=
-
400
,
//代码抛异常
SqlFailed
=
-
200
,
InvalidArgs
=
-
300
,
//参数不合法
AuthFailed
=
-
100
,
SqlFailed
=
-
200
,
//sql执行失败
OtherFailed
=
-
1
,
AuthFailed
=
-
100
,
//鉴权失败
Success
=
0
OtherFailed
=
-
1
,
//业务代码执行失败,
Success
=
0
//执行成功
}
ApiErr
;
}
ApiErr
;
#define API_FIELD "api."
#define API_FIELD "api."
...
@@ -208,7 +209,7 @@ static inline void addHttpListener(){
...
@@ -208,7 +209,7 @@ static inline void addHttpListener(){
}
}
#endif// ENABLE_MYSQL
#endif// ENABLE_MYSQL
catch
(
std
::
exception
&
ex
)
{
catch
(
std
::
exception
&
ex
)
{
val
[
"code"
]
=
API
::
OtherFailed
;
val
[
"code"
]
=
API
::
Exception
;
val
[
"msg"
]
=
ex
.
what
();
val
[
"msg"
]
=
ex
.
what
();
invoker
(
"200 OK"
,
headerOut
,
val
.
toStyledString
());
invoker
(
"200 OK"
,
headerOut
,
val
.
toStyledString
());
}
}
...
@@ -448,9 +449,11 @@ void installWebApi() {
...
@@ -448,9 +449,11 @@ void installWebApi() {
bool
flag
=
src
->
close
(
allArgs
[
"force"
].
as
<
bool
>
());
bool
flag
=
src
->
close
(
allArgs
[
"force"
].
as
<
bool
>
());
val
[
"result"
]
=
flag
?
0
:
-
1
;
val
[
"result"
]
=
flag
?
0
:
-
1
;
val
[
"msg"
]
=
flag
?
"success"
:
"close failed"
;
val
[
"msg"
]
=
flag
?
"success"
:
"close failed"
;
val
[
"code"
]
=
API
::
OtherFailed
;
}
else
{
}
else
{
val
[
"result"
]
=
-
2
;
val
[
"result"
]
=
-
2
;
val
[
"msg"
]
=
"can not find the stream"
;
val
[
"msg"
]
=
"can not find the stream"
;
val
[
"code"
]
=
API
::
OtherFailed
;
}
}
});
});
...
@@ -726,21 +729,25 @@ void installWebApi() {
...
@@ -726,21 +729,25 @@ void installWebApi() {
api_regist1
(
"/index/api/startRecord"
,[](
API_ARGS1
){
api_regist1
(
"/index/api/startRecord"
,[](
API_ARGS1
){
CHECK_SECRET
();
CHECK_SECRET
();
CHECK_ARGS
(
"type"
,
"vhost"
,
"app"
,
"stream"
);
CHECK_ARGS
(
"type"
,
"vhost"
,
"app"
,
"stream"
);
val
[
"result"
]
=
Recorder
::
startRecord
((
Recorder
::
type
)
allArgs
[
"type"
].
as
<
int
>
(),
auto
result
=
Recorder
::
startRecord
((
Recorder
::
type
)
allArgs
[
"type"
].
as
<
int
>
(),
allArgs
[
"vhost"
],
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"app"
],
allArgs
[
"stream"
],
allArgs
[
"stream"
],
allArgs
[
"customized_path"
]);
allArgs
[
"customized_path"
]);
val
[
"result"
]
=
result
;
val
[
"code"
]
=
result
?
API
::
Success
:
API
::
OtherFailed
;
});
});
// 停止录制hls或MP4
// 停止录制hls或MP4
api_regist1
(
"/index/api/stopRecord"
,[](
API_ARGS1
){
api_regist1
(
"/index/api/stopRecord"
,[](
API_ARGS1
){
CHECK_SECRET
();
CHECK_SECRET
();
CHECK_ARGS
(
"type"
,
"vhost"
,
"app"
,
"stream"
);
CHECK_ARGS
(
"type"
,
"vhost"
,
"app"
,
"stream"
);
val
[
"result"
]
=
Recorder
::
stopRecord
((
Recorder
::
type
)
allArgs
[
"type"
].
as
<
int
>
(),
auto
result
=
Recorder
::
stopRecord
((
Recorder
::
type
)
allArgs
[
"type"
].
as
<
int
>
(),
allArgs
[
"vhost"
],
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"app"
],
allArgs
[
"stream"
]);
allArgs
[
"stream"
]);
val
[
"result"
]
=
result
;
val
[
"code"
]
=
result
?
API
::
Success
:
API
::
OtherFailed
;
});
});
// 获取hls或MP4录制状态
// 获取hls或MP4录制状态
...
@@ -803,12 +810,10 @@ void installWebApi() {
...
@@ -803,12 +810,10 @@ void installWebApi() {
api_regist1
(
"/index/hook/on_play"
,[](
API_ARGS1
){
api_regist1
(
"/index/hook/on_play"
,[](
API_ARGS1
){
//开始播放事件
//开始播放事件
throw
SuccessException
();
});
});
api_regist1
(
"/index/hook/on_flow_report"
,[](
API_ARGS1
){
api_regist1
(
"/index/hook/on_flow_report"
,[](
API_ARGS1
){
//流量统计hook api
//流量统计hook api
throw
SuccessException
();
});
});
api_regist1
(
"/index/hook/on_rtsp_realm"
,[](
API_ARGS1
){
api_regist1
(
"/index/hook/on_rtsp_realm"
,[](
API_ARGS1
){
...
@@ -828,7 +833,6 @@ void installWebApi() {
...
@@ -828,7 +833,6 @@ void installWebApi() {
api_regist1
(
"/index/hook/on_stream_changed"
,[](
API_ARGS1
){
api_regist1
(
"/index/hook/on_stream_changed"
,[](
API_ARGS1
){
//媒体注册或反注册事件
//媒体注册或反注册事件
throw
SuccessException
();
});
});
...
@@ -891,12 +895,10 @@ void installWebApi() {
...
@@ -891,12 +895,10 @@ void installWebApi() {
api_regist1
(
"/index/hook/on_record_mp4"
,[](
API_ARGS1
){
api_regist1
(
"/index/hook/on_record_mp4"
,[](
API_ARGS1
){
//录制mp4分片完毕事件
//录制mp4分片完毕事件
throw
SuccessException
();
});
});
api_regist1
(
"/index/hook/on_shell_login"
,[](
API_ARGS1
){
api_regist1
(
"/index/hook/on_shell_login"
,[](
API_ARGS1
){
//shell登录调试事件
//shell登录调试事件
throw
SuccessException
();
});
});
api_regist1
(
"/index/hook/on_stream_none_reader"
,[](
API_ARGS1
){
api_regist1
(
"/index/hook/on_stream_none_reader"
,[](
API_ARGS1
){
...
@@ -932,7 +934,6 @@ void installWebApi() {
...
@@ -932,7 +934,6 @@ void installWebApi() {
api_regist1
(
"/index/hook/on_server_started"
,[](
API_ARGS1
){
api_regist1
(
"/index/hook/on_server_started"
,[](
API_ARGS1
){
//服务器重启报告
//服务器重启报告
throw
SuccessException
();
});
});
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论